Reference contributor extension point is not being executed

Answered

Hi,

I am not sure if I'm going insane or something, but PsiReferenceContributor#registerReferenceProviders seems to never be called.

I have the implementation stubbed to throw an exception

override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) {
TODO("Not implemented")
}

There is a relevant entry in the plugin.xml

<psi.referenceContributor
language="MyLang"
implementation="mylang.MyLangReferenceContributor"/>

I also have a file type, parser, syntax highlighter, folding builder, commenter registered. Those are all working as expected. I am running against IU 2022.1, java 11, gradle 7.4.

Let me know if any other information is helpful! Thanks in advance.

2
2 comments

Seems like exceptions might be silenced in this case? I have also tried the implementation from the tutorial series, printing a string when its called, setting a breakpoint there. It certainly does not appear to be getting called.

0

Hi,
Are you sure that you call the logic creating references for your language? Please take a look at PsiReferenceContributor's Javadoc and make sure elements in your language follow these rules, especially:

Note that, if you're implementing a custom language, it won't by default support references registered through PsiReferenceContributor. If you want to support that, you need to call com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry.getReferencesFromProviders(PsiElement) from your implementation of PsiElement.getReferences().

Your contributor won't be instantiated and providers won't be registered until PSI for your language file is built and one of its elements asks for contributed references. See also: ContributedReferenceHost.

0

Please sign in to leave a comment.