Testing gutter icon

Hi, 
i am trying to write a test to see if gutter icons where generated. To do that i am using: 
List<GutterMark> findAllGutters(@NotNull @TestDataFile String filePath); 
from 
https://github.com/JetBrains/intellij-community/blob/master/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java

 

Unfortunately i keep getting this error: 
ERROR: Performance warning: LineMarker is supposed to be registered for leaf elements only, but got: PyExpressionStatement (class com.jetbrains.python.psi.impl.PyExpressionStatementImpl) instead. First child: PyCallExpression: a (class com.jetbrains.python.psi.impl.PyCallExpressionImpl) 
Please see LineMarkerProvider#getLineMarkerInfo(PsiElement) javadoc for detailed explanations.

 

From what i understand getLineMarkerInfo method should get only LeafElements as a argument. But if run my plugin it works fine without any errors even with PyExpressionStatement as a argument for getLineMarkerInfo method.

 

This is part of code from my plugin:

val navigationGutterIconBuilder = NavigationGutterIconBuilder 
.create(AllIcons.General.Error) 
.setTarget(targetPsiElement) 
.setTooltipText("File ${targetVirtualFile.name}, Line ${fileMark.targetLine}") 

resultCollection.add(navigationGutterIconBuilder.createLineMarkerInfo(psiElement)) 

where targetPsiElement is PsiWhiteSpace and psiElement is PyExpressionStatement.

 

Why it works when i run plugin and it doesnt work when i run a test? Is this a bug? Or do i misunderstood something?

 

I managed to fix the error by finding first leaf element of PyExpressionStatement and put it as a parameter to createLineMarkerInfo method. But this create another problem for me. In my plugin it is possible to have 2 gutter icons at one line. In this case, after clicking on such a stacked gutter icons, popup with text of each gutter icon appears. So user can choose which gutter icon want to use. Unfortunately, this text is taken from psiElement passed to createLineMarkerInfo method. So in this case it will be text of leaf element and thats not what i want.

 

Is there a way to change text of Gutter icon/psiElement? Or is there a way to fix the error using another method and keep my original psiElement?

 

Thank you for your help 
Tomas

1 comment

We managed to solve this issue by using two different gutter icons next to each other. This way we can keep to use leaf element (so we dotn get error) and we dont need to change gutter icon text since it never appears. 

0

Please sign in to leave a comment.