LineMarkerProvider multiple gutter icons
Hi Community,
I implemented a LineMarkerProvider and it works fine, but if the user edits the line which is marked the gutter icon is shown multiple times.
The multiple icons are removed if the user edits some other code in the file.
I followed thistutorial: http://confluence.jetbrains.com/display/IntelliJIDEA/Line+Marker+Provider
Is there a way to prevent this behavior?
Thanks in advance,
Markus
Attachment(s):
Gutter_Icons.png
Please sign in to leave a comment.
Hi Markus,
Are you passing the same element to builder.createLineMarkerInfo() that was passed to your collectNavigationMarkers() implementation?
Yes I do.
Is it wrong?
No, this is correct. To which element are you trying to attach the line marker?
I tried to attach it to a PsiClass and to a list of PsiMethods depending on a comment in the marked line
Please try to attach it to the class's or method's name identifier (the result of calling getNameIdentifier()) instead. Among other reasons, this is important because it places the icon correctly when the declaration is split over multiple lines.
This should be correct, right?
I still get the same behavior.
No, I don't mean changing the target, I mean changing the element on which the icon is displayed.
PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
if (psiClass != null && element == psiClass.getNameIdentifier()) {
...
result.add(gutterIconBuilder.createLineMarkerInfo(element));
}
Sorry but I don't understand what you mean.
Is the problem the element in this call: gutterIconBuilder.createLineMarkerInfo(element)?
My current implementation is this:
Could you provide more info please?
Please help me the code I posted doesn't work, because I still get the duplicate gutter icons.
I don't see anything wrong with this code. It looks like you may be running into an IntelliJ issue with not being able to correctly match PSI elements when a file is reparsed. Could you please file a YouTrack issue with a link to your plugin and some steps to reproduce? Thanks!
I created the issue https://youtrack.jetbrains.com/issue/IDEA-135209
Thank you