PY-71549 Move numeric literal validation from PyKeywordHighlightingAnnotator

It also caused double highlighting on the frontend as PyKeywordHighlightingAnnotator is currently registered in both frontend and backend.

GitOrigin-RevId: 1f653d1d259fb8ca6b5471b6cd0d2974f62b4fae
This commit is contained in:
Petr
2025-07-04 17:56:39 +02:00
committed by intellij-monorepo-bot
parent 2402957c9d
commit 6c6af5e129
3 changed files with 28 additions and 17 deletions

View File

@@ -22,17 +22,13 @@ 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;
import com.jetbrains.python.ast.*;
import com.jetbrains.python.highlighting.PyHighlighter;
import com.jetbrains.python.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
public final class PyKeywordHighlightingAnnotator extends PyAnnotatorBase implements HighlightRangeExtension {
@Override
@@ -57,15 +53,6 @@ public final class PyKeywordHighlightingAnnotator extends PyAnnotatorBase implem
}
}
@Override
public void visitPyNumericLiteralExpression(@NotNull PyAstNumericLiteralExpression node) {
String suffix = node.getIntegerLiteralSuffix();
if (suffix == null || "l".equalsIgnoreCase(suffix)) return;
if (node.getContainingFile().getLanguage() != PythonLanguage.getInstance()) return;
myHolder.newAnnotation(HighlightSeverity.ERROR, PySyntaxCoreBundle.message("INSP.python.trailing.suffix.not.support", suffix))
.range(node).create();
}
@Override
public void visitPyForStatement(@NotNull PyAstForStatement node) {
highlightKeyword(node, PyTokenTypes.ASYNC_KEYWORD);