Find usages coming for free somehow?

Answered

I am writing a language plugin. Among the features I implemented are:

(1) A FindUsagesHandler.

(2) References, which are returned on usage points, and resolve to the definition.

With these, I get the following features:

(3) All definition and usages are highlighted when the cursor is either on a definition or a usage

(4) Ctrl-click on a usage goes to the definition.

Amazingly, it looks like I also got another feature for free without any extra effort:

(5) Ctrl-click on a definition goes to its usage (when unique), or shows a combo with a list of usages to chose from. All that even though I did NOT implement a FindUsageProvider, which is great!

 

However, I recently rewrote my implementation of (1) and (2), and I can see that (3) and (4) are still 100% working, but (5) stopped working (it always shows "No usage found in project file" while correctly highlighting those usages). As it was not documented, and I didn't do anything to make it work in the first place, I don't know what I broke. How is (5) working exactly when it's based on (1) and (2)? What should I look at to get it back?

 

0
2 comments

Hi Jerome,

It's hard to tell what's the reason without more details, but I suggest debugging com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.startFindUsages() to find what is the reason.

0

Thanks Karol,

You are right, it could have been anything. In my case, it was a change in getUseScope() which limited the search to a small part of the file.

0

Please sign in to leave a comment.