From d727b6b5b9da6d7fe700d6e7de97fbaed54bbb80 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Tue, 9 Apr 2019 03:01:58 +0300 Subject: [PATCH] IDEA-CR-23750 drop registry keys for deprecated trackers --- .../psi/util/PsiModificationTracker.java | 1 - .../psi/impl/PsiModificationTrackerImpl.java | 46 +------------------ .../impl/PsiTreeChangePreprocessorBase.java | 2 +- .../util/resources/misc/registry.properties | 7 --- 4 files changed, 3 insertions(+), 53 deletions(-) diff --git a/platform/core-api/src/com/intellij/psi/util/PsiModificationTracker.java b/platform/core-api/src/com/intellij/psi/util/PsiModificationTracker.java index f902b4bd6539..19541477aa78 100644 --- a/platform/core-api/src/com/intellij/psi/util/PsiModificationTracker.java +++ b/platform/core-api/src/com/intellij/psi/util/PsiModificationTracker.java @@ -32,7 +32,6 @@ import org.jetbrains.annotations.NotNull; *
  • Make a {@link CachedValue} instance dependent on a specific PSI modification tracker. * To achieve that, one should can one of the constants in this interface as {@link CachedValueProvider.Result} * dependencies. - * See {@link #MODIFICATION_COUNT}, {@link #JAVA_STRUCTURE_MODIFICATION_COUNT}, {@link #OUT_OF_CODE_BLOCK_MODIFICATION_COUNT} * *
  • Subscribe to any PSI change (for example, to drop caches in the listener manually). * See {@link PsiModificationTracker.Listener} diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiModificationTrackerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/PsiModificationTrackerImpl.java index 1d40eeb160c8..ca73cc9475ce 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/PsiModificationTrackerImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/PsiModificationTrackerImpl.java @@ -24,8 +24,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.ModificationTracker; import com.intellij.openapi.util.SimpleModificationTracker; -import com.intellij.openapi.util.registry.Registry; -import com.intellij.openapi.util.registry.RegistryValue; import com.intellij.psi.*; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiModificationTracker; @@ -47,15 +45,10 @@ import static com.intellij.psi.impl.PsiTreeChangeEventImpl.PsiEventType.PROPERTY * @author mike */ public class PsiModificationTrackerImpl implements PsiModificationTracker, PsiTreeChangePreprocessor { - private static final RegistryValue ourEnableCodeBlockTracker = Registry.get("psi.modification.tracker.code-block"); - private static final RegistryValue ourEnableJavaStructureTracker = Registry.get("psi.modification.tracker.java-structure"); - private static final RegistryValue ourEnableLanguageTracker = Registry.get("psi.modification.tracker.per-language"); - - private final boolean myTestMode = false; //ApplicationManager.getApplication().isUnitTestMode(); private final SimpleModificationTracker myModificationCount = new SimpleModificationTracker(); - private final SimpleModificationTracker myOutOfCodeBlockModificationTracker = wrapped(ourEnableCodeBlockTracker, myModificationCount, myTestMode); - private final SimpleModificationTracker myJavaStructureModificationTracker = wrapped(ourEnableJavaStructureTracker, myModificationCount, myTestMode); + private final SimpleModificationTracker myOutOfCodeBlockModificationTracker = myModificationCount; + private final SimpleModificationTracker myJavaStructureModificationTracker = myModificationCount; private final Map myLanguageTrackers = ConcurrentFactoryMap.createMap(language -> new SimpleModificationTracker()); @@ -124,7 +117,6 @@ public class PsiModificationTrackerImpl implements PsiModificationTracker, PsiTr } protected void incLanguageTrackers(@NotNull PsiTreeChangeEventImpl event) { - if (!ourEnableLanguageTracker.asBoolean()) return; incLanguageModificationCount(Language.ANY); PsiElement[] elements = { event.getFile(), event.getParent(), event.getOldParent(), event.getNewParent(), @@ -181,18 +173,6 @@ public class PsiModificationTrackerImpl implements PsiModificationTracker, PsiTr return myJavaStructureModificationTracker; } - - @ApiStatus.Experimental - public boolean isEnableCodeBlockTracker() { - if (myTestMode) return true; - return ourEnableCodeBlockTracker.asBoolean(); - } - - @ApiStatus.Experimental - public boolean isEnableLanguageTracker() { - return ourEnableLanguageTracker.asBoolean(); - } - @ApiStatus.Experimental public void incLanguageModificationCount(@Nullable Language language) { if (language == null) return; @@ -202,14 +182,12 @@ public class PsiModificationTrackerImpl implements PsiModificationTracker, PsiTr @ApiStatus.Experimental @NotNull public ModificationTracker forLanguage(@NotNull Language language) { - if (!ourEnableLanguageTracker.asBoolean()) return this; return myLanguageTrackers.get(language); } @ApiStatus.Experimental @NotNull public ModificationTracker forLanguages(@NotNull Condition condition) { - if (!ourEnableLanguageTracker.asBoolean()) return this; return () -> { long result = 0; for (Language l : myLanguageTrackers.keySet()) { @@ -219,24 +197,4 @@ public class PsiModificationTrackerImpl implements PsiModificationTracker, PsiTr return result; }; } - - @NotNull - private static SimpleModificationTracker wrapped(RegistryValue value, SimpleModificationTracker fallback, boolean testMode) { - if (testMode) { - return new SimpleModificationTracker(); - } - return new SimpleModificationTracker() { - @Override - public long getModificationCount() { - return value.asBoolean() ? super.getModificationCount() : - fallback.getModificationCount(); - } - - @Override - public void incModificationCount() { - if (value.asBoolean()) super.incModificationCount(); - //else fallback.incModificationCount(); - } - }; - } } diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessorBase.java b/platform/core-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessorBase.java index 68075a3c7217..e25142be766e 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessorBase.java +++ b/platform/core-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessorBase.java @@ -9,7 +9,7 @@ import com.intellij.psi.PsiManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -/** @deprecated to be removed */ +/** @deprecated see {@link com.intellij.psi.util.PsiModificationTracker#getOutOfCodeBlockModificationTracker()} */ @Deprecated public abstract class PsiTreeChangePreprocessorBase implements PsiTreeChangePreprocessor { protected final PsiManager myPsiManager; diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 52ad10fc1a81..92e964969821 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -539,13 +539,6 @@ psi.track.invalidation.description=When PSI elements are invalidated, store stac psi.element.list.cell.renderer.focus.border.enabled=false psi.element.list.cell.renderer.focus.border.enabled.description=Enables default focus border in a list of PSI elements. -psi.modification.tracker.code-block=false -psi.modification.tracker.code-block.description=Controls out-of-code-block PSI modification tracker optimization -psi.modification.tracker.java-structure=false -psi.modification.tracker.java-structure.description=Controls java-structure PSI modification tracker optimization -psi.modification.tracker.per-language=true -psi.modification.tracker.per-language.description=Controls per-language PSI modification tracker optimization - ide.suggest.file.when.creating.filename.like.directory=true ide.suggest.file.when.creating.filename.like.directory.description=When creating a directory named foo.txt, suggest to create a file with such a name instead