Extending "Find Usages" for existing languages
My use case is this: I've defined a custom syntax for metadata within existing language formats. It looks like this for a java file:
// <CustomSyntax Definition>
int foo;
Elsewhere in the code:
// <CustomSyntax Usage>
int bar;
(The "//" here does really mean a Java comment. That way, the Java compiler can simply ignore my custom syntax definition, while a parser I built can correctly interpret it).
I'd like to find usages of "<CustomSyntax Definition>" and find "<CustomSyntax Usage>". Is it possible to extend the "find usages" API to achieve that?
I understand this would be perfectly possible if I was defining a custom language (something like .javacustom), but I'd like to avoid that if possible.
Please sign in to leave a comment.
You can provide a custom "referencesSearch" (or "methodReferencesSearch" for methods) extension to find custom usages when "your" field is being searched. You can look at some examples in intellij-community source for that: SPIReferencesSearcher, ConstructorReferencesSearcher etc.