How to add a reference from XmlAttributeValue to PsiClass?

Answered

I created a ReferenceContributor and then register some ReferenceProviders:


public class MyXmlReferenceContributor extends PsiReferenceContributor {

@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
registrar.registerReferenceProvider(xmlAttributeValue(),
new PsiReferenceProvider() {})

It seems to be all right,when it jump from the xmlAttributeValue to the declaration of psiClass.

But it couldn't  find Usages what i wanted in the PsiClass when ctrl+B .

By the way , I tried to use :

ReferencesSearch.search(psiClass).findAll()

,the results were disappointing.

It puzzled me !!!

If i edited the “demo_MyUserModel” to "demo.MyUserModel" or "demo$MyUserModel" or "demo/MyUserModel" ,it works for me.

Why?What should I do?What’s wrong with the ' _ ' ? 

 

0
1 comment

You'll need to provide custom com.intellij.referencesSearch extension point implementation that understands how to search for this notation (otherwise, platform assumes that reference notation is exactly same as declaration).

0

Please sign in to leave a comment.