RelatedItemLineMarkerProvider shows the line itself


Implemented RelatedItemLineMarkerProvider for XML files, when clicking on the gutter it shows the line itself but not line what it points

<CUSTOMER NAME="Customer Name" ....... />

I want to display where the customer with such a name is used, for that I do 

val subIcon = NavigationGutterIconBuilder.create(AllIcons.Gutter.ImplementedMethod)
.setTarget(subTag)//sugtag target line

The result of clicking on the gutter is a few lines but with the same title "<CUSTOMER NAME="Customer Name" ....... />" clicking on any line of displayed lines leads me to the correct place.

How do I show the name of the target not of the source?

Comment actions Permalink

Sargo, try calling the setTooltipText(String) on your builder passing the proper subTag's name.

Check SimpleLineMarkerProvider code sample for some details.

Comment actions Permalink

setTooltipText shows tooltip when you hover the cursor over the gutter, if there are 5 lines it will just show 5 tag.names or whatever I pass, eliminating lines with the same names.

But if use setTargets(list<tag>) instead of setTarget(tag) it shows almost what I need, the target XML tag name (instead of source lines if use setTarget(tag)) but this is still not enough, I want to show whole target lines tag and its attributes, not just target, maybe I can pass the line itself (if it is PSI element too)instead of XML Tag,  how can I do this.

Comment actions Permalink

Use com.intellij.codeInsight.navigation.NavigationGutterIconBuilder#setNamer

Comment actions Permalink

Tried with setNamer, it is invoked (in debug mode) but the result still the same 

val subIcon = NavigationGutterIconBuilder.create(AllIcons.Gutter.ImplementingMethod)
.setNamer { it.text + "sf" }

tried .setNamer("aaa"), nothing changed. If I use setTarget(tag) instead of setTargets(tags) the namer is never called. 

Comment actions Permalink

Hard to tell why it doesn't work in your case. As alternative, try providing custom renderer via com.intellij.codeInsight.navigation.NavigationGutterIconBuilder#setCellRenderer

Comment actions Permalink

Thank you, setCellRenderer helped


Please sign in to leave a comment.