Documentation Provider "Multiple Implementations" problem

I am writing a plugin for a language that has a limited number of variables which are numbered (ie. VAR0-9, OBV0-9, MV00-MV99). In the documentation though, each set is described as a single entry VARx, OBVx and MVxx.

I wanted to have all instances of the same numbered variable highlight together. So all VAR9's would be highlighted if one is selected. I have tried many things, and the only thing that works is to return the variable itself along with the documentation element from PsiPolyVariant reference. This has led to a problem where when you CMD+hover, it says "multiple implementations," and does not show the actual documentation.

If I return only the documentation element, it shows the correct text, but it does not highlight any of the variables. I tried implementing  QueryExecutorBase, but it only passes in the resolved variable ( ie. "VARx"), not the one currently at caret VAR0-9. Which means I cannot detect which variable to highlight.

I also could not get find usages to work. I have tried both implementing PsiNamedElement and not, I have tried every combination of Tokens in FindUsagesProvider, from the raw token to the parent tokens, and their parents. I have tried making different parents PsiNamedElements, I have tried nesting the elements further. It will not highlight. I can get the other language elements, which are defined the same way, but which point to an element with the exact name as the command used. I do not know how to point "VARx" to the VAR0-VAR9.

I could navigate to the correct element with CMD+click before I started returning the usage itself with the resolved entry in the definitions. Now it lists both, and the correct one has to be selected.

Is there any way to remove "multiple implementations" and instead force one element for documentation? It would still not solve the find usages problem, but that is less of a worry right now as things are highlighting right now which is more important to me.

Truth be told, if a user is using this language, then they should already be aware of the variables, but it would be nice to have a complete set of hover docs. Most important though, like I said is to highlight same variable usage, which is working now.

If anyone could help me solve the "multiple implementations" problem, or help me find a better solution to highlighting these variables, I would really appreciate it.

1 comment

Sorry this got lost. You might want to try using com.intellij.codeInsight.highlighting.HighlightUsagesHandlerFactory to highlight "arbitrary" set of "related elements" AFAIU.


Please sign in to leave a comment.