From 0ab057e0ca81f90c1a6ca9980ed8a28535ffa06b Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Tue, 19 Jan 2010 16:10:31 +0300 Subject: [PATCH] Make: heuristics for processing removed constant fields, part2: handle cases when dependent files appear in already processed modules --- .../AnnotationProcessingCompiler.java | 2 +- .../javaCompiler/BackendCompilerWrapper.java | 35 ++++++++++++------- .../impl/javaCompiler/JavaCompiler.java | 2 +- .../ChangedConstantsDependencyProcessor.java | 2 +- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/AnnotationProcessingCompiler.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/AnnotationProcessingCompiler.java index f93c1e191aa6..21861c3b6eba 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/AnnotationProcessingCompiler.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/AnnotationProcessingCompiler.java @@ -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(); } diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java index 4a3916c1e73f..378a26731786 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java @@ -79,7 +79,6 @@ public class BackendCompilerWrapper { private final CompileContextEx myCompileContext; private final List myFilesToCompile; private final TranslatingCompiler.OutputSink mySink; - private final Chunk myChunk; private final Project myProject; private final Set myFilesToRecompile; private final Map myModuleToTempDirMap = new THashMap(); @@ -90,11 +89,10 @@ public class BackendCompilerWrapper { public final Map> myFileNameToSourceMap= new THashMap>(); - public BackendCompilerWrapper(Chunk chunk, @NotNull final Project project, + public BackendCompilerWrapper(@NotNull final Project project, @NotNull List 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> buildModuleToFilesMap(final List 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 filesInScope = new ArrayList(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> moduleToFilesMap) throws CompilerException { myProcessedFilesCount = 0; + + final List 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 getModuleChunks(final Map> moduleToFilesMap) { + final List modules = new ArrayList(moduleToFilesMap.keySet()); + final List> chunks = ApplicationManager.getApplication().runReadAction(new Computable>>() { + public List> compute() { + return ModuleCompilerUtil.getSortedModuleChunks(myProject, modules); + } + }); + final List moduleChunks = new ArrayList(chunks.size()); + for (final Chunk chunk : chunks) { + moduleChunks.add(new ModuleChunk(myCompileContext, chunk, moduleToFilesMap)); + } + return moduleChunks; + } + private void compileChunk(ModuleChunk chunk) throws IOException { runTransformingCompilers(chunk); diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/JavaCompiler.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/JavaCompiler.java index 20601f3abc23..068ade2ad6d1 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/JavaCompiler.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/JavaCompiler.java @@ -58,7 +58,7 @@ public class JavaCompiler implements TranslatingCompiler { public void compile(CompileContext context, Chunk 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(); } diff --git a/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java b/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java index ce11da5d72bb..7dde0840a348 100644 --- a/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java +++ b/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java @@ -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) {