From ee47a549eae535a9b7e2098a21ef5df1e68a4e9a Mon Sep 17 00:00:00 2001 From: nik Date: Mon, 16 Jan 2012 13:07:42 +0400 Subject: [PATCH] IDEA-79500: IDEA crashed and deleted whole directories --- .../impl/compiler/ArtifactCompilerUtil.java | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerUtil.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerUtil.java index 6915ae2e3379..e13b8ec07b36 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerUtil.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerUtil.java @@ -15,9 +15,14 @@ */ package com.intellij.packaging.impl.compiler; +import com.intellij.facet.Facet; +import com.intellij.facet.FacetManager; +import com.intellij.facet.FacetRootsProvider; import com.intellij.openapi.compiler.CompileContext; import com.intellij.openapi.compiler.CompilerMessageCategory; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.JarFileSystem; @@ -92,7 +97,7 @@ public class ArtifactCompilerUtil { ContainerUtil.addIfNotNull(artifact.getOutputFile(), allOutputs); } - final Set affectedOutputPaths = new HashSet(); + final Set roots = new HashSet(); final PackagingElementResolvingContext context = ArtifactManager.getInstance(project).getResolvingContext(); for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) { ArtifactUtil.processPackagingElements(artifact, null, new PackagingElementProcessor>() { @@ -106,17 +111,32 @@ public class ArtifactCompilerUtil { if (element instanceof FileOrDirectoryCopyPackagingElement) { final VirtualFile file = ((FileOrDirectoryCopyPackagingElement)element).findFile(); if (file != null) { - for (VirtualFile output : allOutputs) { - if (VfsUtilCore.isAncestor(output, file, false)) { - affectedOutputPaths.add(output); - } - } + roots.add(file); } } return true; } }, context, true); } + + final Module[] modules = ModuleManager.getInstance(project).getModules(); + for (Module module : modules) { + final Facet[] facets = FacetManager.getInstance(module).getAllFacets(); + for (Facet facet : facets) { + if (facet instanceof FacetRootsProvider) { + roots.addAll(((FacetRootsProvider)facet).getFacetRoots()); + } + } + } + + final Set affectedOutputPaths = new HashSet(); + for (VirtualFile output : allOutputs) { + for (VirtualFile root : roots) { + if (VfsUtilCore.isAncestor(output, root, false)) { + affectedOutputPaths.add(output); + } + } + } return affectedOutputPaths; } }