don't restore stub elements from PsiAnchor when the file has become binary(EA-89806...
authorpeter <peter@jetbrains.com>
Wed, 16 Nov 2016 18:26:15 +0000 (19:26 +0100)
committerpeter <peter@jetbrains.com>
Wed, 16 Nov 2016 18:27:20 +0000 (19:27 +0100)
platform/core-impl/src/com/intellij/psi/PsiAnchor.java

index e6f497ffa6b40ce9ce81500b2b7c6469e97aa514..d4e2b98f78c2e61b472c12f1f14a702af6047a10 100644 (file)
@@ -453,14 +453,9 @@ public abstract class PsiAnchor {
       if (myProject.isDisposed() || !myVirtualFile.isValid()) {
         return null;
       }
-      final PsiFile file = PsiManager.getInstance(myProject).findFile(myVirtualFile);
-      if (file == null) {
-        return null;
-      }
-      if (file.getLanguage() == myLanguage) {
-        return file;
-      }
-      return file.getViewProvider().getPsi(myLanguage);
+      FileViewProvider viewProvider = PsiManager.getInstance(myProject).findViewProvider(myVirtualFile);
+      PsiFile file = viewProvider == null ? null : viewProvider.getPsi(myLanguage);
+      return file instanceof PsiFileWithStubSupport ? file : null;
     }
 
     @Override