RelatedItemLineMarkerProvider shows the line itself

Answered

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
.createLineMarkerInfo(element)
result.add(subIcon)

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?

6 comments
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.

0
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 Tag.name, maybe I can pass the line itself (if it is PSI element too)instead of XML Tag,  how can I do this.

0
Comment actions Permalink

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

0
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)
.setTargets(tags)
.setNamer { it.text + "sf" }

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

0
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

1
Comment actions Permalink

Thank you, setCellRenderer helped

0

Please sign in to leave a comment.