EA-49101: getContainingFile() must not be called on invalid PsiElement phpstorm/132.910
authorOleg Sukhodolsky <oleg.sukhodolsky@jetbrains.com>
Sat, 2 Nov 2013 04:26:42 +0000 (08:26 +0400)
committerOleg Sukhodolsky <oleg.sukhodolsky@jetbrains.com>
Sat, 2 Nov 2013 04:26:42 +0000 (08:26 +0400)
platform/projectModel-api/src/com/intellij/openapi/module/ModuleUtilCore.java

index d3db67dfaeef079fd67099f550f5715f21062af3..d466794efd006eb73c63b30425ca22a089573b45 100644 (file)
@@ -79,13 +79,11 @@ public class ModuleUtilCore {
 
   @Nullable
   public static Module findModuleForPsiElement(@NotNull PsiElement element) {
-    PsiFile containingFile = element.getContainingFile();
-    if (containingFile == null) {
-      if (!element.isValid()) return null;
-    }
-    else {
-      if (!containingFile.isValid()) return null;
+    if (!element.isValid()) {
+      return null;
     }
+    PsiFile containingFile = element.getContainingFile();
+    if (containingFile != null && !containingFile.isValid()) return null;
 
     Project project = (containingFile == null ? element : containingFile).getProject();
     if (project.isDefault()) return null;