I’ve spent much time to understand how to do it in my own custom languages and why it didn’t work
Things that help me to inject references to my psi elements:
add override fun getReferences(): Array<PsiReference> = ReferenceProvidersRegistry.getReferencesFromProviders(this) to the element should have references
add { implements=["com.intellij.psi.NavigatablePsiElement"] } into the bnf to the according psi element pattern declaration
Do not forget to rebuild parser.
Also I’ve noticed that your snippet has error, there are no “implementation” attribute, so correct version will be: <psi.referenceContributor language="MyLanguage" implementation="xxxxx.MyReferenceContributor" />
Languages must explicitly enable references in places where they expect contributed references. It cannot be done automatically since has performance and correctness consequences.