How to create Multi PsiReference for Tag name?
Answered
If TagName needs to point to a custom PsiReference, it needs to be done through a custom XMLExtension. override XMLExtension.createTagNameReference(), define custom TagNameReference , and the PsiReference is processed in TagNameReference, but only one PsiReference can be returned. For example, Tag Name is com.example.EntityName, if "EntityName" and "com.example" are reference to different PsiElement, how to handle it?
Please sign in to leave a comment.
Hi,
It seems that it is not possible to do with
XMLExtension
. I suggest trying to implementcom.intellij.psi.PsiReferenceContributor
, which will contribute references for tag name.com.intellij.psi.PsiReferenceProvider
should return references for each class element (package parts and a class name). You can usecom.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceSet
to build the references for a fully qualified class name and return itsgetReferences()
.from this : ReferenceProvider on XmlTokenType.XML_NAME – IDEs Support (IntelliJ Platform) | JetBrains
“Go to Declaration doesn't work in your case because XML_TAG already has a reference to itself. You can change this behavior by creating your own XmlExtension(com.intellij.xml.XmlExtension) and overriding method XmlExtension.createTagNameReference().”
PsiReferenceProvider can't apply to TagName, Isn't it ?