Find usages is not working with "cascading references"
Hi
I have an issue when a first elements (ref:'Address' in my example) refers to a second element (Component ('Address') for example) ... and this second element refers to a third one (interface Address for example) ...
The problem is that when asking for "Find Usage" the second (i.e "Component ('Address')"... the usages view displays usages of the third one instead of the second ! And the first one is not even part of the results...
Can you please help me to fine a solution to deal with this problem ?
Regards
Maxime
Please sign in to leave a comment.
Hello. Looks like you are using some plugin which supports some file format "sjs" where some literals can reference other elements via "reference" thing. In IDEA the reference can be resolved to some declared element (which has a name). In your example, the #1 reference apparently resolves to the Component("Address"). Please note that it doesn't resolve to a string 'Address' or to another reference named 'Address'. Instead, it resolves to a whole component named 'address'. So it happened that this component has another reference embedded in a literal 'Address' (#2 in your example) which resolves to the java class Address (#3 in your example). "Find usages" action finds all references for the given element. For example, for java class Address it will find the reference #2, not #3. If you run find usages for "Component ('Address')" it will find reference #1. The problem here is how to run "find usages" for "Component ('Address')". It seems that in this language this component name is also a reference, so when you point caret to #2 and invoke find usages it resolves the reference first, goes to java class Address and starts finding usages of that class instead of a component. So you need to contact plugin vendor I am afraid and ask them to support that strange case.
Wait, you are the Jspresso plugin author aren't you?
Then, I think, to give users ability to search for Component('Address') you'll need to write your own
which will e.g. search for Component('Address') when the caret is on "Component" part and for java class "Address" when the caret is on 'Address' part.
Hello Alexey
Thanks to your help, I managed it ! As you suggested I've created my own "FindUsagesHandlerFactory" which creates custom "FindUsagesHandler"... which returns both the "class" and the "Component"
Now the "find usages" reports both usages :
Thank you !
Kind regards,
Maxime