differentiate make compile session from compile session invoked to build artifacts

This commit is contained in:
Eugene Zhuravlev
2010-03-26 18:37:15 +03:00
parent 6677b08eef
commit 8c7f133360
5 changed files with 20 additions and 15 deletions
@@ -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<String, JBZipFile> myOpenZipFiles = new java.util.HashMap<String, JBZipFile>();
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();
}
@@ -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()) {
@@ -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<Key<?>> CONTENT_ID_KEY = Key.create("CONTENT_ID");
private Key<Key<?>> myContentIdKey = CONTENT_ID_KEY;
private final Key<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<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);
}
}
@@ -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<Artifact[]> ARTIFACTS_KEY = Key.create("artifacts");
private static final Key<Set<Artifact>> CACHED_ARTIFACTS_KEY = Key.create("cached_artifacts");
private static final Key<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<Artifact> artifacts) {
baseScope.putUserData(ARTIFACTS_KEY, artifacts.toArray(new Artifact[artifacts.size()]));
baseScope.putUserData(CompilerManager.CONTENT_ID_KEY, ARTIFACTS_CONTENT_ID_KEY);
return baseScope;
}
@@ -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<Key> CONTENT_ID_KEY = Key.create("COMPILATION_CONTENT_ID_CUSTOM_KEY");
/**
* Returns the compiler manager instance for the specified project.
*