The purpose of PsiReferenceContributor


I do have a quick question about the PsiReferenceContributor's purpose.
Imagine I have an annotation and I want to establish a reference relationship like the following:

void foo();


class Bar {}

I do get the behavior of a GotoDeclarationHandler for the literal "foo.Bar" but what baffels me is:

  • If the reference is invalid, no error is shown, contrary to what I read elsewhere
  • Bar is marked as unused although the reference exists

The question is if those components in question have to be developed as individual extensions.
In that case, I don't understand why the GotoDeclarationHandler / completion via variants
part is already handled via reference contributor.

Did I simply implement the PsiReferenceContributor wrong or is this expected?


Comment actions Permalink

Hi Joa,

For the first question: what does the isSoft() method of your reference return? The reference won't be highlighted if isSoft() returns true.
For the second one: you probably need to implement a searcher (an extension for the referencesSearch extension point) so that your "foo.Bar" string will be found as a usage of the Bar class.

Comment actions Permalink

Hi Dmitry,

thanks for the reply. The isSoft() method returns false. Attached is a screenshot of how it looks.
Also: if I type @Delegate("ErrorsErrorsErrors") I see that the class (which is in the same Editor) is highlighted.

Source code is also available at

I will implement the searcher as suggested. Thanks!



Please sign in to leave a comment.