From 8c7f133360b4a4422d82b8b31978dcdeeb9ae1a2 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 26 Mar 2010 18:36:29 +0300 Subject: [PATCH] differentiate make compile session from compile session invoked to build artifacts --- .../compiler/impl/CompileContextImpl.java | 12 ++++-------- .../com/intellij/compiler/impl/CompileDriver.java | 3 +-- .../intellij/compiler/progress/CompilerTask.java | 15 ++++++++++----- .../impl/compiler/ArtifactCompileScope.java | 3 +++ .../openapi/compiler/CompilerManager.java | 2 ++ 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java index db182d31725f..2c5cc4cd8ff4 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java @@ -24,10 +24,7 @@ package com.intellij.compiler.impl; import com.intellij.compiler.CompilerMessageImpl; import com.intellij.compiler.make.DependencyCache; import com.intellij.compiler.progress.CompilerTask; -import com.intellij.openapi.compiler.CompileScope; -import com.intellij.openapi.compiler.CompilerMessage; -import com.intellij.openapi.compiler.CompilerMessageCategory; -import com.intellij.openapi.compiler.CompilerPaths; +import com.intellij.openapi.compiler.*; import com.intellij.openapi.compiler.ex.CompileContextEx; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; @@ -45,7 +42,6 @@ import com.intellij.util.containers.HashMap; import com.intellij.util.containers.HashSet; import com.intellij.util.containers.OrderedSet; import com.intellij.util.indexing.FileBasedIndex; -import com.intellij.util.io.zip.JBZipFile; import gnu.trove.TIntHashSet; import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NotNull; @@ -74,14 +70,13 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon private final ProjectFileIndex myProjectFileIndex; // cached for performance reasons private final ProjectCompileScope myProjectCompileScope; private final long myStartCompilationStamp; - private final Map myOpenZipFiles = new java.util.HashMap(); public CompileContextImpl(Project project, - CompilerTask indicator, + CompilerTask compilerSession, CompileScope compileScope, DependencyCache dependencyCache, boolean isMake, boolean isRebuild) { myProject = project; - myTask = indicator; + myTask = compilerSession; myCompileScope = compileScope; myDependencyCache = dependencyCache; myMake = isMake; @@ -90,6 +85,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon myProjectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); myProjectCompileScope = new ProjectCompileScope(myProject); + compilerSession.setContentIdKey(compileScope.getUserData(CompilerManager.CONTENT_ID_KEY)); recalculateOutputDirs(); } diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index aef725908db7..e0428ae65089 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -192,8 +192,7 @@ public class CompileDriver { scope = addAdditionalRoots(scope, ALL_EXCEPT_SOURCE_PROCESSING); final CompilerTask task = new CompilerTask(myProject, true, "", true); - final CompileContextImpl compileContext = - new CompileContextImpl(myProject, task, scope, createDependencyCache(), true, false); + final CompileContextImpl compileContext = new CompileContextImpl(myProject, task, scope, createDependencyCache(), true, false); checkCachesVersion(compileContext); if (compileContext.isRebuildRequested()) { diff --git a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java index 43598f24d845..5112ef7a29dd 100644 --- a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java +++ b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java @@ -38,10 +38,10 @@ import com.intellij.openapi.progress.ProgressFunComponentProvider; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; import com.intellij.openapi.progress.util.ProgressIndicatorBase; +import com.intellij.openapi.project.DumbModeAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ProjectManagerListener; -import com.intellij.openapi.project.DumbModeAction; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Key; @@ -73,6 +73,7 @@ public class CompilerTask extends Task.Backgroundable { private static final boolean IS_UNIT_TEST_MODE = ApplicationManager.getApplication().isUnitTestMode(); private static final int UPDATE_INTERVAL = 50; //msec. 20 frames per second. private static final Key> CONTENT_ID_KEY = Key.create("CONTENT_ID"); + private Key> myContentIdKey = CONTENT_ID_KEY; private final Key> myContentId = Key.create("compile_content"); private CompilerProgressDialog myDialog; private NewErrorTreeViewPanel myErrorTreeView; @@ -97,6 +98,10 @@ public class CompilerTask extends Task.Backgroundable { myHeadlessMode = headlessMode || IS_UNIT_TEST_MODE; } + public void setContentIdKey(Key> contentIdKey) { + myContentIdKey = contentIdKey != null? contentIdKey : CONTENT_ID_KEY; + } + public String getProcessId() { return ProgressFunComponentProvider.COMPILATION_ID; } @@ -388,7 +393,7 @@ public class CompilerTask extends Task.Backgroundable { final MessageView messageView = MessageView.SERVICE.getInstance(myProject); final Content content = PeerFactory.getInstance().getContentFactory().createContent(component, myContentName, true); - content.putUserData(CONTENT_ID_KEY, myContentId); + content.putUserData(myContentIdKey, myContentId); messageView.getContentManager().addContent(content); myCloseListener.setContent(content, messageView.getContentManager()); removeAllContents(myProject, content); @@ -402,7 +407,7 @@ public class CompilerTask extends Task.Backgroundable { final MessageView messageView = MessageView.SERVICE.getInstance(myProject); Content[] contents = messageView.getContentManager().getContents(); for (Content content : contents) { - if (content.getUserData(CONTENT_ID_KEY) != null) { + if (content.getUserData(myContentIdKey) != null) { messageView.getContentManager().setSelectedContent(content); return; } @@ -411,13 +416,13 @@ public class CompilerTask extends Task.Backgroundable { } } - public static void removeAllContents(Project project, Content notRemove) { + private void removeAllContents(Project project, Content notRemove) { MessageView messageView = MessageView.SERVICE.getInstance(project); Content[] contents = messageView.getContentManager().getContents(); for (Content content : contents) { if (content.isPinned()) continue; if (content == notRemove) continue; - if (content.getUserData(CONTENT_ID_KEY) != null) { // the content was added by me + if (content.getUserData(myContentIdKey) != null) { // the content was added by me messageView.getContentManager().removeContent(content, true); } } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompileScope.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompileScope.java index 38805aa9083c..bf3a13544524 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompileScope.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompileScope.java @@ -17,6 +17,7 @@ package com.intellij.packaging.impl.compiler; import com.intellij.compiler.impl.ModuleCompileScope; import com.intellij.openapi.compiler.CompileScope; +import com.intellij.openapi.compiler.CompilerManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; @@ -39,6 +40,7 @@ import java.util.*; public class ArtifactCompileScope { private static final Key ARTIFACTS_KEY = Key.create("artifacts"); private static final Key> CACHED_ARTIFACTS_KEY = Key.create("cached_artifacts"); + private static final Key> ARTIFACTS_CONTENT_ID_KEY = Key.create("build_artifacts_task"); private ArtifactCompileScope() { } @@ -67,6 +69,7 @@ public class ArtifactCompileScope { public static CompileScope createScopeWithArtifacts(final CompileScope baseScope, @NotNull Collection artifacts) { baseScope.putUserData(ARTIFACTS_KEY, artifacts.toArray(new Artifact[artifacts.size()])); + baseScope.putUserData(CompilerManager.CONTENT_ID_KEY, ARTIFACTS_CONTENT_ID_KEY); return baseScope; } diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java index 20701898fe3f..01eb4aa8006c 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java @@ -19,6 +19,7 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,6 +31,7 @@ import java.util.Set; * and invoke various types of compilations (make, compile, rebuild) */ public abstract class CompilerManager { + public static final Key CONTENT_ID_KEY = Key.create("COMPILATION_CONTENT_ID_CUSTOM_KEY"); /** * Returns the compiler manager instance for the specified project. *