EA-89693 - NPE: ContentEntryEditor.isExcludedOrUnderExcludedDirectory
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Fri, 14 Oct 2016 11:08:28 +0000 (14:08 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Fri, 14 Oct 2016 11:08:28 +0000 (14:08 +0300)
platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentEntryEditor.java

index a905dd56e54215b6b81a51c6035b4cebc522ec69..a9e9a497add104200f702d33f629b13a3168eb4b 100644 (file)
@@ -287,21 +287,24 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
     return folder != null ? folder.getRootType() : null;
   }
 
-  public boolean isExcludedOrUnderExcludedDirectory(@NotNull final VirtualFile file) {
-    Project project = getModel().getProject();
-    final ContentEntry contentEntry = getContentEntry();
+  public boolean isExcludedOrUnderExcludedDirectory(@NotNull VirtualFile file) {
+    ModifiableRootModel model = getModel();
+    Project project = model != null ? model.getProject() : null;
+    ContentEntry contentEntry = getContentEntry();
     if (contentEntry == null) {
       return false;
     }
     return isExcludedOrUnderExcludedDirectory(project, contentEntry, file);
   }
 
-  public static boolean isExcludedOrUnderExcludedDirectory(@NotNull Project project,
+  public static boolean isExcludedOrUnderExcludedDirectory(@Nullable Project project,
                                                            @NotNull ContentEntry entry,
                                                            @NotNull VirtualFile file) {
     List<VirtualFile> excludedFiles = ContainerUtil.newArrayList(entry.getExcludeFolderFiles());
-    for (DirectoryIndexExcludePolicy policy : DirectoryIndexExcludePolicy.getExtensions(project)) {
-      ContainerUtil.addAllNotNull(excludedFiles, policy.getExcludeRootsForProject());
+    if (project != null) {
+      for (DirectoryIndexExcludePolicy policy : DirectoryIndexExcludePolicy.getExtensions(project)) {
+        ContainerUtil.addAllNotNull(excludedFiles, policy.getExcludeRootsForProject());
+      }
     }
     for (VirtualFile excludedFile : excludedFiles) {
       if (VfsUtilCore.isAncestor(excludedFile, file, false)) {