From 080b7c4f760f6eb5211047e1b82d8621a3280ab9 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Fri, 16 Jun 2017 17:39:25 +0300 Subject: [PATCH] EA-102311 - PIEAE: PsiUtilCore.ensureValid - fix for exception --- .../openapi/src/com/intellij/debugger/SourcePosition.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/java/debugger/openapi/src/com/intellij/debugger/SourcePosition.java b/java/debugger/openapi/src/com/intellij/debugger/SourcePosition.java index 662976e34157..2bf52d1f08b2 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/SourcePosition.java +++ b/java/debugger/openapi/src/com/intellij/debugger/SourcePosition.java @@ -55,7 +55,7 @@ public abstract class SourcePosition implements Navigatable{ private abstract static class SourcePositionCache extends SourcePosition { @NotNull private final PsiFile myFile; - @NotNull private final SmartPsiElementPointer myFilePointer; + @Nullable private final SmartPsiElementPointer myFilePointer; private long myModificationStamp = -1L; private WeakReference myPsiElementRef; @@ -64,14 +64,15 @@ public abstract class SourcePosition implements Navigatable{ public SourcePositionCache(@NotNull PsiFile file) { myFile = file; - myFilePointer = SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(file); + myFilePointer = ReadAction.compute( + () -> file.isValid() ? SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(file) : null); updateData(); } @Override @NotNull public PsiFile getFile() { - PsiFile file = myFilePointer.getElement(); + PsiFile file = myFilePointer != null ? myFilePointer.getElement() : null; return file != null ? file : myFile; // in case of full invalidation, rollback to the original psiFile }