Skip to content

FindUsages Aspect¶ ⧉

Implement custom finders for discovering related nodes in this aspect.

I click Find Usages in the context menu of a node, and it doesn't find anything.

The standard search scope is the project. Try to expand it to global in the find usages settings. Check also that you are using the correcting finders in the Finders section of the dialog.

I want to execute Find Usages repeatedly, but the result tab gets overridden.

Select the option Open in new tab in the section View of the Find usages preferences or pin the result tabs by right-clicking and selecting Pin Tab.

How to restrict the scope of a Finder execution?

I use this finder ⧉ and would like to restrict the scope from global to project.

How do I do this?

You can pass any FindUsages Scope implementation to the expression, for instance, the ProjectScope ⧉:

SearchResults results = execute finders(NodeUsages, node, new ProjectScope(project), <default>);

How can I invoke the find usages manager programmatically without UI?

Use one of the methods in #project.getComponent(FindUsagesmanager.class). If no project is available, you can use the deprecated method FindUsagesManager.getInstance(). If the function needs a Consumer, use the class CollectConsumer ⧉ , which adds the results to the provided collection. There is also the method getResults() to get back the collection.

A model doesn't support fast usages search.

When specifying the scope, exclude models that don't support fast usages search (e.g., temporary models such as the console model). Models are only loaded when accessed, so keep the scope of the find usages. If you are filtering a global or similar scope, the following methods might be helpful:

  • module.isPackaged() to check for installed languages/solutions/devkits
  • model.isReadOnly() to check if a model allows updates
  • SModelStereotype.isX() to check if the model has a specific stereotype, for example, the model is a test model