PY-71549 Eliminate global shared state inside annotators

Before, when entering an `annotate` method, a reference to `AnnotationHolder` was stored in the annotator field. And this required synchronization. Now this reference is stored into a temporary PyElementVisitor object actually used to perform highlighting.

Also, register all python annotators using a regular 'annotator' EP. There is no point in using 'Pythonid.pyAnnotator'.

GitOrigin-RevId: ad1df8ce743bc62d3f43e6bf9b1a8ea370ff7de7
This commit is contained in:
Petr
2025-07-02 12:43:09 +02:00
committed by intellij-monorepo-bot
parent 6db8559cd4
commit a51b604bd4
35 changed files with 837 additions and 700 deletions

View File

@@ -21,18 +21,12 @@
<typedHandler implementation="com.jetbrains.python.codeInsight.PyKeywordTypedHandler" id="pyCommaAfterKwd"/>
<typedHandler implementation="com.jetbrains.python.editor.PythonSpaceHandler"/>
<backspaceHandlerDelegate implementation="com.jetbrains.python.codeInsight.editorActions.PyTripleQuoteBackspaceDelegate"/>
<annotator language="Python" implementationClass="com.jetbrains.python.validation.PyCompositeAnnotator"/>
<colorSettingsPage implementation="com.jetbrains.python.highlighting.PythonColorsPage"/>
<statementUpDownMover implementation="com.jetbrains.python.codeInsight.editorActions.moveUpDown.PyStatementMover" id="pyStatementMover"
order="before line"/>
<joinLinesHandler implementation="com.jetbrains.python.editor.PyJoinLinesHandler"/>
<lang.foldingBuilder language="Python" implementationClass="com.jetbrains.python.PythonFoldingBuilder"/>
<applicationService serviceImplementation="com.jetbrains.python.PythonFoldingSettings"/>
<annotator language="Python" implementationClass="com.jetbrains.python.validation.PyHighlightingAnnotator"/>
</extensions>
<extensions defaultExtensionNs="Pythonid">
<pyAnnotator implementation="com.jetbrains.python.validation.PyHighlightingAnnotator"/>
</extensions>
<extensionPoints>
<extensionPoint qualifiedName="Pythonid.pyAnnotator" interface="com.jetbrains.python.validation.PyAnnotatorBase" dynamic="true"/>
</extensionPoints>
</idea-plugin>

View File

@@ -1,16 +0,0 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.validation;
import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.lang.annotation.Annotator;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
public final class PyCompositeAnnotator implements Annotator {
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
PyAnnotatorBase[] annotators = ExtensionPointName.<PyAnnotatorBase>create("Pythonid.pyAnnotator").getExtensions();
PyAnnotatorBase.runAnnotators(element, holder, annotators);
}
}