Make: heuristics for processing removed constant fields, part2: handle cases when dependent files appear in already processed modules

This commit is contained in:
Eugene Zhuravlev
2010-01-20 12:08:31 +03:00
parent bb7108ca42
commit 0ab057e0ca
4 changed files with 26 additions and 15 deletions
@@ -79,7 +79,7 @@ public class AnnotationProcessingCompiler implements TranslatingCompiler{
};
final JavacCompiler javacCompiler = getBackEndCompiler();
final boolean processorMode = javacCompiler.setAnnotationProcessorMode(true);
final BackendCompilerWrapper wrapper = new BackendCompilerWrapper(moduleChunk, myProject, Arrays.asList(files), _context, javacCompiler, sink);
final BackendCompilerWrapper wrapper = new BackendCompilerWrapper(myProject, Arrays.asList(files), _context, javacCompiler, sink);
try {
wrapper.compile();
}
@@ -79,7 +79,6 @@ public class BackendCompilerWrapper {
private final CompileContextEx myCompileContext;
private final List<VirtualFile> myFilesToCompile;
private final TranslatingCompiler.OutputSink mySink;
private final Chunk<Module> myChunk;
private final Project myProject;
private final Set<VirtualFile> myFilesToRecompile;
private final Map<Module, VirtualFile> myModuleToTempDirMap = new THashMap<Module, VirtualFile>();
@@ -90,11 +89,10 @@ public class BackendCompilerWrapper {
public final Map<String, Set<CompiledClass>> myFileNameToSourceMap= new THashMap<String, Set<CompiledClass>>();
public BackendCompilerWrapper(Chunk<Module> chunk, @NotNull final Project project,
public BackendCompilerWrapper(@NotNull final Project project,
@NotNull List<VirtualFile> filesToCompile,
@NotNull CompileContextEx compileContext,
@NotNull BackendCompiler compiler, TranslatingCompiler.OutputSink sink) {
myChunk = chunk;
myProject = project;
myCompiler = compiler;
myCompileContext = compileContext;
@@ -186,9 +184,6 @@ public class BackendCompilerWrapper {
}
private Map<Module, List<VirtualFile>> buildModuleToFilesMap(final List<VirtualFile> filesToCompile) {
if (myChunk.getNodes().size() == 1) {
return Collections.singletonMap(myChunk.getNodes().iterator().next(), Collections.unmodifiableList(filesToCompile));
}
return CompilerUtil.buildModuleToFilesMap(myCompileContext, filesToCompile);
}
@@ -224,12 +219,10 @@ public class BackendCompilerWrapper {
final List<VirtualFile> filesInScope = new ArrayList<VirtualFile>(files.size());
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
final CompileScope compileScope = myCompileContext.getCompileScope();
for (VirtualFile file : files) {
if (myCompileContext.getCompileScope().belongs(file.getUrl())) {
final Module module = myCompileContext.getModuleByFile(file);
if (myChunk.getNodes().contains(module)) {
filesInScope.add(file);
}
if (compileScope.belongs(file.getUrl())) {
filesInScope.add(file);
}
}
}
@@ -239,14 +232,32 @@ public class BackendCompilerWrapper {
private void compileModules(final Map<Module, List<VirtualFile>> moduleToFilesMap) throws CompilerException {
myProcessedFilesCount = 0;
final List<ModuleChunk> chunks = getModuleChunks(moduleToFilesMap);
try {
compileChunk(new ModuleChunk(myCompileContext, myChunk, moduleToFilesMap));
for (final ModuleChunk chunk : chunks) {
compileChunk(chunk);
}
}
catch (IOException e) {
throw new CompilerException(e.getMessage(), e);
}
}
private List<ModuleChunk> getModuleChunks(final Map<Module, List<VirtualFile>> moduleToFilesMap) {
final List<Module> modules = new ArrayList<Module>(moduleToFilesMap.keySet());
final List<Chunk<Module>> chunks = ApplicationManager.getApplication().runReadAction(new Computable<List<Chunk<Module>>>() {
public List<Chunk<Module>> compute() {
return ModuleCompilerUtil.getSortedModuleChunks(myProject, modules);
}
});
final List<ModuleChunk> moduleChunks = new ArrayList<ModuleChunk>(chunks.size());
for (final Chunk<Module> chunk : chunks) {
moduleChunks.add(new ModuleChunk(myCompileContext, chunk, moduleToFilesMap));
}
return moduleChunks;
}
private void compileChunk(ModuleChunk chunk) throws IOException {
runTransformingCompilers(chunk);
@@ -58,7 +58,7 @@ public class JavaCompiler implements TranslatingCompiler {
public void compile(CompileContext context, Chunk<Module> moduleChunk, VirtualFile[] files, OutputSink sink) {
final BackendCompiler backEndCompiler = getBackEndCompiler();
final BackendCompilerWrapper wrapper = new BackendCompilerWrapper(moduleChunk, myProject, Arrays.asList(files), (CompileContextEx)context, backEndCompiler, sink);
final BackendCompilerWrapper wrapper = new BackendCompilerWrapper(myProject, Arrays.asList(files), (CompileContextEx)context, backEndCompiler, sink);
try {
wrapper.compile();
}
@@ -45,7 +45,7 @@ class ChangedConstantsDependencyProcessor {
private final int myQName;
private final FieldChangeInfo[] myChangedFields;
private final FieldChangeInfo[] myRemovedFields;
private static final long ANALYSIS_DURATION_THRESHOLD_MILLIS = 30000L /*30 sec*/;
private static final long ANALYSIS_DURATION_THRESHOLD_MILLIS = 15000L /*15 sec*/;
public ChangedConstantsDependencyProcessor(Project project, CachingSearcher searcher, DependencyCache dependencyCache, int qName, FieldChangeInfo[] changedFields, FieldChangeInfo[] removedFields) {