Skip to content

Commit

Permalink
project scope is composite scope of all modules, fixed Rebuild All ac…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
VISTALL committed Mar 13, 2015
1 parent 4a50495 commit be83cb7
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ void addMessage(CompilerMessageCategory category, String message, @Nullable Stri
*/
CompileScope getCompileScope();

/**
* Returns the compile scope which would be used if the entire project was rebuilt.
* {@link #getCompileScope()} may return the scope, that is more narrow than ProjectCompileScope.
*
* @return project-wide compile scope.
*/
CompileScope getProjectCompileScope();

/**
* A compiler may call this method in order to request complete project rebuild.
* This may be necessary, for example, when compiler caches are corrupted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.consulo.lombok.annotations.ProjectService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.mustbe.consulo.RequiredReadAction;

import java.util.Collection;

Expand Down Expand Up @@ -210,6 +211,7 @@ public abstract class CompilerManager {
*
* @param callback a notification callback, or null if no notifications needed
*/
@RequiredReadAction
public abstract void rebuild(@Nullable CompileStatusNotification callback);

/**
Expand Down Expand Up @@ -252,14 +254,16 @@ public abstract void executeTask(@NotNull CompileTask task, @NotNull CompileScop
*/
@NotNull
public abstract CompileScope createFilesCompileScope(@NotNull VirtualFile[] files);

@NotNull
@RequiredReadAction
public abstract CompileScope createProjectCompileScope();
@NotNull
public abstract CompileScope createModuleCompileScope(@NotNull Module module, final boolean includeDependentModules);
@NotNull
public abstract CompileScope createModulesCompileScope(@NotNull Module[] modules, final boolean includeDependentModules);
@NotNull
public abstract CompileScope createModuleGroupCompileScope(@NotNull Project project, @NotNull Module[] modules, final boolean includeDependentModules);
@NotNull
public abstract CompileScope createProjectCompileScope(@NotNull Project project);

public abstract boolean isValidationEnabled(Module moduleType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ public CompileScope getCompileScope() {
return myDelegate.getCompileScope();
}

@Override
public CompileScope getProjectCompileScope() {
return myDelegate.getProjectCompileScope();
}

@Override
public void requestRebuildNextTime(final String message) {
myDelegate.requestRebuildNextTime(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
private Set<VirtualFile> myTestOutputDirectories;
private final TIntHashSet myGeneratedSources = new TIntHashSet();
private final ProjectFileIndex myProjectFileIndex; // cached for performance reasons
private final ProjectCompileScope myProjectCompileScope;
private final long myStartCompilationStamp;
private final UUID mySessionId = UUID.randomUUID();

Expand All @@ -103,7 +102,6 @@ public CompileContextImpl(final Project project,
myIsRebuild = isRebuild;
myStartCompilationStamp = System.currentTimeMillis();
myProjectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
myProjectCompileScope = new ProjectCompileScope(myProject);

recalculateOutputDirs();
}
Expand Down Expand Up @@ -325,11 +323,6 @@ public CompileScope getCompileScope() {
return myCompileScope;
}

@Override
public CompileScope getProjectCompileScope() {
return myProjectCompileScope;
}

@Override
public void requestRebuildNextTime(String message) {
if (!myRebuildRequested) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import org.mustbe.consulo.RequiredReadAction;
import org.mustbe.consulo.compiler.roots.CompilerPathsImpl;
import org.mustbe.consulo.roots.ContentFolderScopes;
import org.mustbe.consulo.roots.ContentFolderTypeProvider;
Expand Down Expand Up @@ -189,9 +190,10 @@ public void setCompilerFilter(Condition<Compiler> compilerFilter) {
myCompilerFilter = compilerFilter == null ? Conditions.<Compiler>alwaysTrue() : compilerFilter;
}

@RequiredReadAction
public void rebuild(CompileStatusNotification callback) {
final CompileScope compileScope;
ProjectCompileScope projectScope = new ProjectCompileScope(myProject);
CompileScope projectScope = CompilerManager.getInstance(myProject).createProjectCompileScope();
CompileScope scopeWithArtifacts =
ArtifactCompileScope.createScopeWithArtifacts(projectScope, ArtifactUtil.getArtifactWithOutputPaths(myProject), false);
compileScope = addAdditionalRoots(scopeWithArtifacts, ALL_EXCEPT_SOURCE_PROCESSING);
Expand Down Expand Up @@ -1422,7 +1424,7 @@ private void deleteAll(final CompileContextEx context) {
@Override
public void run() {
//final boolean isTestMode = ApplicationManager.getApplication().isUnitTestMode();
final VirtualFile[] allSources = context.getProjectCompileScope().getFiles(null, true);
final VirtualFile[] allSources = CompilerManager.getInstance(myProject).createProjectCompileScope().getFiles(null, true);
if (myShouldClearOutputDirectory) {
CompilerUtil.clearOutputDirectories(myAllOutputDirectories);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ public CompileScope getCompileScope() {
return null;
}

@Override
public CompileScope getProjectCompileScope() {
return null;
}

@Override
public void requestRebuildNextTime(String message) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.intellij.openapi.components.*;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Conditions;
Expand All @@ -43,6 +44,7 @@
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.mustbe.consulo.RequiredReadAction;

import java.io.File;
import java.lang.reflect.Array;
Expand Down Expand Up @@ -269,7 +271,7 @@ public void compile(@NotNull CompileScope scope, CompileStatusNotification callb

@Override
public void make(CompileStatusNotification callback) {
new CompileDriver(myProject).make(createProjectCompileScope(myProject), new ListenerNotificator(callback));
new CompileDriver(myProject).make(createProjectCompileScope(), new ListenerNotificator(callback));
}

@Override
Expand Down Expand Up @@ -300,6 +302,7 @@ public boolean isUpToDate(@NotNull final CompileScope scope) {
}

@Override
@RequiredReadAction
public void rebuild(CompileStatusNotification callback) {
new CompileDriver(myProject).rebuild(new ListenerNotificator(callback));
}
Expand Down Expand Up @@ -354,6 +357,14 @@ public CompileScope createFilesCompileScope(@NotNull final VirtualFile[] files)
return new CompositeScope(scopes);
}

@NotNull
@Override
@RequiredReadAction
public CompileScope createProjectCompileScope() {
Module[] modules = ModuleManager.getInstance(myProject).getModules();
return createModulesCompileScope(modules, false);
}

@Override
@NotNull
public CompileScope createModuleCompileScope(@NotNull final Module module, final boolean includeDependentModules) {
Expand Down Expand Up @@ -388,12 +399,6 @@ public CompileScope createModuleGroupCompileScope(@NotNull final Project project
return new CompositeScope(list);
}

@Override
@NotNull
public CompileScope createProjectCompileScope(@NotNull final Project project) {
return new ProjectCompileScope(project);
}

@Override
public boolean isValidationEnabled(Module moduleType) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected CompilerManager getCompilerManager() {
}

protected void assertModulesUpToDate() {
boolean upToDate = getCompilerManager().isUpToDate(getCompilerManager().createProjectCompileScope(myProject));
boolean upToDate = getCompilerManager().isUpToDate(getCompilerManager().createProjectCompileScope());
assertTrue("Modules are not up to date", upToDate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void run() {
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
if (Comparing.equal(Boolean.TRUE.toString(), System.getProperty(MAKE_PROJECT_ON_RUN_KEY))) {
// user explicitly requested whole-project make
scope = compilerManager.createProjectCompileScope(myProject);
scope = compilerManager.createProjectCompileScope();
}
else {
final Module[] modules = runConfiguration.getModules();
Expand All @@ -162,7 +162,7 @@ public void run() {
scope = compilerManager.createModulesCompileScope(modules, true);
}
else {
scope = compilerManager.createProjectCompileScope(myProject);
scope = compilerManager.createProjectCompileScope();
}
}

Expand Down

0 comments on commit be83cb7

Please sign in to comment.