ReferenceContributor for XML
已回答
I've implemented PsiReferenceContributor to navigate across specific XML files when a user press CTRL + B on an attribute or tag and if it has more than one usages it shows a popup where all places are listed but the problem that it shows only the name of the attributes so the user can't distinguish between them. Like
customer
customer
customer
customer
each on a new line. I've implemented as well PsiReferenceBase and PsiPolyVariantReference all methods are overridden and only three methods are triggered multiResolve and resolve and isSoft. But methods
getVariants, getCanonicalText, resolveReference, getValue
never triggered.
How can I display custom words?
请先登录再写评论。
See com.intellij.codeInsight.navigation.GotoTargetRendererProvider
Implemented, never triggered, nothing changed.
class XmlGotoTargetRendererProvider : GotoTargetRendererProvider {override fun getRenderer(element: PsiElement, gotoData: GotoTargetHandler.GotoData): PsiElementListCellRenderer<*> {
return XmlPsiElementListCellRenderer()
}
}
class XmlPsiElementListCellRenderer : PsiElementListCellRenderer<PsiElement>() {
override fun getElementText(element: PsiElement?): String {
if (element is PsiNamedElement) {
val name: @Nullable String? = element.name
return name ?: ""
}
return element!!.text
}
override fun getContainerText(element: PsiElement?, name: String?): String? {
if (element is NavigationItem) {
val presentation: @Nullable ItemPresentation? = (element as NavigationItem).presentation
if (presentation != null) {
return presentation.locationString
}
}
return null
}
override fun getIconFlags(): Int {
return 0;
}
}
Could you link your full plugin's sources?