Adjust PsiElement display text for RelatedItemLineMarkerProvider

My current situation is...

I am developing a plugin that adds RelatedItemLineMarkerInfo - Objects to XML nodes. They point to other XML nodes, sometimes in the same file, sometimes in a different file. As seen in the picture, multiple target nodes might match. In this specific case, the structure is always like this:

<parentNode id="someUniqueAndImportantId"><value>...</value></parentNode>

I want to give the user the ability to jump directly to the value nodes, but the information on how to distinguish all the matching value - nodes lies in their parents or even higher in the XML tree.


Now I would like to...

...adjust how these PsiElements get displayed in the selection dropdown. Instead of "value", I want to display the content of the id attribute of the parent in the given example case. Ideally I could provide custom display strings for each PsiElement here.

 Is this possible? If yes, how can I achieve this?

1 comment

Well, I found a solution myself: I created a decorator class around a PsiNamedElement, and adjusted its #getName - method to return a custom string instead. For some reason, the containing file path gets not displayed anymore now, but that is ok for me.

But if anybody finds a more elegant solution, let me know :)


Please sign in to leave a comment.