mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix disappearing green arrow on the gutter
Sometimes the green arrow disappears, because the marker contributor isn't executed on IfStatement. Seems that it is always executed on IF token, though.
This commit is contained in:
@@ -22,8 +22,10 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.psi.PyIfStatement;
|
||||
import com.jetbrains.python.psi.PyUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -43,6 +45,15 @@ public class PyRunLineMarkerContributor extends RunLineMarkerContributor {
|
||||
}
|
||||
|
||||
private static boolean isMainClauseOnTopLevel(@NotNull PsiElement element) {
|
||||
return element instanceof PyIfStatement && element.getParent() instanceof PsiFile && PyUtil.isIfNameEqualsMain(((PyIfStatement)element));
|
||||
if (element.getNode().getElementType() == PyTokenTypes.IF_KEYWORD) {
|
||||
element = PsiTreeUtil.getParentOfType(element, PyIfStatement.class);
|
||||
|
||||
return element != null &&
|
||||
element.getParent() instanceof PsiFile &&
|
||||
PyUtil.isIfNameEqualsMain(((PyIfStatement)element));
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user