mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
PY-71549 Move None, True and False rehighlighting from PyHighlightingAnnotatorVisitor to PyKeywordHighlightingAnnotator
GitOrigin-RevId: 4ca534b964d02236ad688fd8446cd963d647e350
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3e1cf2afd5
commit
efc364c13f
+11
@@ -21,6 +21,7 @@ import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.jetbrains.python.PySyntaxCoreBundle;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.PythonLanguage;
|
||||
@@ -108,6 +109,16 @@ public final class PyKeywordHighlightingAnnotator extends PyAnnotatorBase implem
|
||||
highlightKeyword(node, PyTokenTypes.TYPE_KEYWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitElement(@NotNull PsiElement element) {
|
||||
// Highlight None, True and False as keywords once again inside annotations after PyHighlighter
|
||||
// to keep their original color
|
||||
if (PyTokenTypes.EXPRESSION_KEYWORDS.contains(element.getNode().getElementType()) &&
|
||||
PsiTreeUtil.getParentOfType(element, PyAstAnnotation.class) != null) {
|
||||
myHolder.addHighlightingAnnotation(element, PyHighlighter.PY_KEYWORD);
|
||||
}
|
||||
}
|
||||
|
||||
private void highlightKeyword(@NotNull PsiElement node, @NotNull PyElementType elementType) {
|
||||
highlightAsKeyword(node.getNode().findChildByType(elementType));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user