IDEA-CR-23750 drop registry keys for deprecated trackers

This commit is contained in:
Gregory.Shrago
2019-04-09 03:55:14 +03:00
parent a565cc61df
commit d727b6b5b9
4 changed files with 3 additions and 53 deletions
@@ -32,7 +32,6 @@ import org.jetbrains.annotations.NotNull;
* <li/> 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}
*
* <li/> Subscribe to any PSI change (for example, to drop caches in the listener manually).
* See {@link PsiModificationTracker.Listener}
@@ -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<Language, ModificationTracker> 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<? super Language> 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();
}
};
}
}
@@ -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;
@@ -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