From 7ccfd3772d0d65236787b6c451aa57a58043ebe0 Mon Sep 17 00:00:00 2001 From: Daniil Kalinin Date: Mon, 19 Aug 2024 15:23:56 +0200 Subject: [PATCH] PY-72185 disable reparseable leaves by default for further investigation GitOrigin-RevId: 87a1d99a80415128b303f2b0cb343afd2c939b6a --- .../resources/META-INF/PythonParser.xml | 2 +- .../resources/intellij.python.parser.xml | 2 +- .../PythonIncrementalParsingTestCase.java | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/python/python-parser/resources/META-INF/PythonParser.xml b/python/python-parser/resources/META-INF/PythonParser.xml index a8387752c569..2718fb745ed6 100644 --- a/python/python-parser/resources/META-INF/PythonParser.xml +++ b/python/python-parser/resources/META-INF/PythonParser.xml @@ -11,7 +11,7 @@ extensions="pyi" implementationClass="com.jetbrains.python.pyi.PyiFileType" fieldName="INSTANCE"/> - diff --git a/python/python-parser/resources/intellij.python.parser.xml b/python/python-parser/resources/intellij.python.parser.xml index a8387752c569..2718fb745ed6 100644 --- a/python/python-parser/resources/intellij.python.parser.xml +++ b/python/python-parser/resources/intellij.python.parser.xml @@ -11,7 +11,7 @@ extensions="pyi" implementationClass="com.jetbrains.python.pyi.PyiFileType" fieldName="INSTANCE"/> - diff --git a/python/testSrc/com/jetbrains/python/parsing/PythonIncrementalParsingTestCase.java b/python/testSrc/com/jetbrains/python/parsing/PythonIncrementalParsingTestCase.java index e649cc8f917c..2fedd2af8e25 100644 --- a/python/testSrc/com/jetbrains/python/parsing/PythonIncrementalParsingTestCase.java +++ b/python/testSrc/com/jetbrains/python/parsing/PythonIncrementalParsingTestCase.java @@ -2,6 +2,7 @@ package com.jetbrains.python.parsing; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.registry.Registry; import com.intellij.testFramework.ParsingTestUtil; import com.jetbrains.python.fixtures.PyTestCase; import org.jetbrains.annotations.NotNull; @@ -11,6 +12,9 @@ import java.io.IOException; public abstract class PythonIncrementalParsingTestCase extends PyTestCase { + private static final String STATEMENTS_REGISTRY_KEY = "python.statement.lists.incremental.reparse"; + private static final String AST_LEAVES_REGISTRY_KEY = "python.ast.leaves.incremental.reparse"; + protected @NotNull String getFileExtension() { return ".py"; } @@ -35,20 +39,29 @@ public abstract class PythonIncrementalParsingTestCase extends PyTestCase { @NotNull String newTextFileBaseName, boolean checkInitialTreeForErrors, boolean checkFinalTreeForErrors) { + boolean statementListsRegistryFlag = Registry.is(STATEMENTS_REGISTRY_KEY); + boolean leavesRegistryFlag = Registry.is(AST_LEAVES_REGISTRY_KEY); + var sourceFileName = sourceFileBaseName + "/" + sourceFileBaseName + getFileExtension(); myFixture.configureByFile(sourceFileName); var newTextFileName = sourceFileBaseName + "/" + newTextFileBaseName + ".new"; String newText; try { + Registry.get(STATEMENTS_REGISTRY_KEY).setValue(true); + Registry.get(AST_LEAVES_REGISTRY_KEY).setValue(true); + newText = FileUtil.loadFile(new File(getTestDataPath(), newTextFileName)).replace("\r", ""); + ParsingTestUtil.testIncrementalParsing(myFixture.getFile(), newText, getAnswersFilePath(), + checkInitialTreeForErrors, checkFinalTreeForErrors); } catch (IOException e) { fail(e.getMessage()); throw new RuntimeException(); } - - ParsingTestUtil.testIncrementalParsing(myFixture.getFile(), newText, getAnswersFilePath(), - checkInitialTreeForErrors, checkFinalTreeForErrors); + finally { + Registry.get(STATEMENTS_REGISTRY_KEY).setValue(statementListsRegistryFlag); + Registry.get(AST_LEAVES_REGISTRY_KEY).setValue(leavesRegistryFlag); + } } protected String getAnswersFilePath() {