Reference Contributor
Answered
Hello, I'm having troubles with registered reference contributor.
I've created the most simple pattern -> PlatformPatterns.psiElement(), which I thought should offer completion everywhere in the code. But it still somehow selects only certain places and I can't figure out why.
This is an example, where contributor successfully offers references after '123' number on line 17, yet just one line below after '$' char or inside those double quotes, it seems to not fire up at all.
Even in debug mode, getVariants() of that reference method is not called.
Is there something else that might be deciding if contributor should be called or not besides given pattern?
Thank you for any advice, and have a nice day.
Please sign in to leave a comment.
Hi,
It’s hard to tell what the reason can be without reproducing the issue. Maybe for some reason, references are not created in some contexts.
I suggest setting a breakpoint in
com.intellij.codeInsight.completion.CompletionContributor#fillCompletionVariants()
and see what is the completion context and if references are created by the contributor.Ah, thank you, it helped me to find a place where to debug from and I've found out my mistake.
Element starting with '$' no longer extended PsiNamedElement, which I forgot is required for references (highlighted in tutorial), while number 123 falls under all purpose named reference - which is weird ... but my guess atm is that it creates a PsiErrorElement at cursor, which if unresolved is parsed as general purpose named reference.
Sorry to bother you and thank you for a quick response.
Have a nice day.