diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java index 5d227aa08c1e..46f7968208a0 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java @@ -30,11 +30,13 @@ import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.impl.FreeThreadedFileViewProvider; +import com.intellij.psi.impl.PsiManagerEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.lang.ref.Reference; import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; class SmartPsiElementPointerImpl implements SmartPointerEx { private Reference myElement; @@ -91,7 +93,9 @@ class SmartPsiElementPointerImpl implements SmartPointerEx } private void cacheElement(E element) { - myElement = element == null ? null : new SoftReference(element); + myElement = element == null ? null : + ((PsiManagerEx)element.getManager()).isBatchFilesProcessingMode() ? new WeakReference(element) : + new SoftReference(element); } @Override