Find usages: injected language

Do injected languages support Find Usages?
I have injected the language into HTML attribute values and return the FindUsagesProvider instance from the MyLanguage.getFindUsagesProvider() method.

The find usages dialog is shown but the FindUsagesProvider methods aren't called after pressing the Find button.
Also the my FindUsagesProvider.getWordsScanner() method is never called.

Example: the are HTML file, Java file.
Java file contains the getLastName() method and its usage.
HTML contains


Injected 'ognl:lastName' value references to the getLastName() method. When I search usages of the lastName property (from HTML, cursor in the injected fragment) then method usage in the Java file is found but isn't found usage in the HTML (injected ognl:lastName).
Looks like Idea doesn't search Java method usages in the injected fragments.

Comment actions Permalink

Is it possible to add my seach results (to usages found by Idea)?
I can find references to a Java class or method from HTML template myself. So I need an extension point to return my search results.

Comment actions Permalink

Alex, from what you've posted it seems that you are trying to search for the Java method usages injected into the HTML tag attribute.
So it is the Java language that should be asked about its find usage provider.
Find usages proceeds as follows:
- All files are searched for the occurences of the name of the element to be searched (e.g. Java method name)
- For all references in all the occurences found, PsiReference.isReferenceTo() check is performed.
So as soon as you injected the reference with the correct isReferenceTo() and supplied (optionally) your custom ReferenceSearch (to assist the first stage of the Find usages described above, e.g. to find all files that are contain 'lastName' word when searching for the Java method getLastName()), all should work.

For injected fragments corresponding getWordsScanner() is not called due to performance considerations, all words are supplied by the host file language word scanner, e.g. HTML in your example.


Please sign in to leave a comment.