From c47b7de77f35d8684096646af2ff8f2e48cee32f Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 18 Sep 2018 14:19:13 +0200 Subject: [PATCH] add motivating "Try to avoid processing PSI events at all cost!" javadocs --- .../com/intellij/psi/PsiTreeChangeEvent.java | 17 ++++++++++++++++- .../com/intellij/psi/PsiTreeChangeListener.java | 4 +++- .../psi/impl/PsiTreeChangePreprocessor.java | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/platform/core-api/src/com/intellij/psi/PsiTreeChangeEvent.java b/platform/core-api/src/com/intellij/psi/PsiTreeChangeEvent.java index 8f5946a42bc2..efddc5484f87 100644 --- a/platform/core-api/src/com/intellij/psi/PsiTreeChangeEvent.java +++ b/platform/core-api/src/com/intellij/psi/PsiTreeChangeEvent.java @@ -21,7 +21,22 @@ import org.jetbrains.annotations.Nullable; import java.util.EventObject; /** - * Provides information about a change in the PSI tree of a project. + * Provides information about a change in the PSI tree of a project.

+ * + * Try to avoid processing PSI events at all cost! It's very hard to do this correctly and handle all edge cases. + * Please use {@link com.intellij.psi.util.CachedValue} with {@link com.intellij.psi.util.PsiModificationTracker#MODIFICATION_COUNT} + * or VFS events where possible. Here are just some of the complications with PSI events: + *

* * @see PsiTreeChangeListener */ diff --git a/platform/core-api/src/com/intellij/psi/PsiTreeChangeListener.java b/platform/core-api/src/com/intellij/psi/PsiTreeChangeListener.java index b0b5979c1c82..47db1fff5234 100644 --- a/platform/core-api/src/com/intellij/psi/PsiTreeChangeListener.java +++ b/platform/core-api/src/com/intellij/psi/PsiTreeChangeListener.java @@ -20,7 +20,9 @@ import org.jetbrains.annotations.NotNull; import java.util.EventListener; /** - * Listener for receiving notifications about all changes in the PSI tree of a project. + * Listener for receiving notifications about all changes in the PSI tree of a project.

+ * + * Try to avoid processing PSI events at all cost! See {@link PsiTreeChangeEvent} documentation for more details. * * @see PsiManager#addPsiTreeChangeListener(PsiTreeChangeListener) * @see PsiManager#removePsiTreeChangeListener(PsiTreeChangeListener) diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessor.java b/platform/core-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessor.java index 7eaac7f30076..eba9c1191b9a 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessor.java +++ b/platform/core-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessor.java @@ -20,6 +20,10 @@ import com.intellij.openapi.extensions.ExtensionPointName; import org.jetbrains.annotations.NotNull; /** + * An extension called before notifying {@link com.intellij.psi.PsiTreeChangeListener}s of events.

+ * + * Try to avoid processing PSI events at all cost! See {@link com.intellij.psi.PsiTreeChangeEvent} documentation for more details. + * * @author yole */ public interface PsiTreeChangePreprocessor {