use weak references in smart pointers when in bulk mode

This commit is contained in:
peter
2015-03-26 12:46:24 +01:00
parent cd4238cf94
commit 5817fae090
@@ -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<E extends PsiElement> implements SmartPointerEx<E> {
private Reference<E> myElement;
@@ -91,7 +93,9 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
}
private void cacheElement(E element) {
myElement = element == null ? null : new SoftReference<E>(element);
myElement = element == null ? null :
((PsiManagerEx)element.getManager()).isBatchFilesProcessingMode() ? new WeakReference<E>(element) :
new SoftReference<E>(element);
}
@Override