find usages for a custom language

I'm trying to implement find usages but facing few issues. If a method has CustomAnnotation with some value, and find usage is called upon it, it has to show the custom langauge references. I guess it should be possible to add entries to the java method find usage with my custom entries.

java method:

@CustomAnnotation("step with <param>")
public void someMethod(String param) {


}


custom language:

* step with "foo"

So this psiElement is a NamedPsiElement whose getName() returns 'step with {placeholder}'

so it has to index more than just words split by whitespace which is done by DefaultWordScanner. So I tried creating a FindUsagesProvider with my customLexer with identiferToSearch as the corresponding IElementType for that above mentioned psiElement.

<lang.findUsagesProvider implementationClass="CustomUsagesProvider" language="JAVA"/>

I'm assuming langauge has to be java since I'm invoking find usages on java method. Now I have to override the way it finds the usages by processing the annotation text and matching with the custom identifer's getName(). I have set breakpoints on all the overrriden methds of FindUsagesProvider but doesn't seem to hit any of them.

PS I have go to reference working, from my custom language to the method.
If I can just have a reverse process of it, that would also be fine.

Could you please provide some guidance in this?

Thanks

1 comment
Comment actions Permalink

If you want your custom language elements to be usages of Java methods, you should tell the IDE that this method can also be found under the name "step with smth". To do this, you need to implement a reference searcher, check that it's your method being searched and do collector.searchWord(customName, yourScope, ...). For an example, see GrAliasedImportedElementSearcher

0

Please sign in to leave a comment.