This commit is contained in:
Eugene Zhuravlev
2010-01-20 12:08:34 +03:00
parent 0ab057e0ca
commit 3a43cf0a09
3 changed files with 15 additions and 26 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(myProject, Arrays.asList(files), _context, javacCompiler, sink);
final BackendCompilerWrapper wrapper = new BackendCompilerWrapper(moduleChunk, myProject, Arrays.asList(files), _context, javacCompiler, sink);
try {
wrapper.compile();
}
@@ -79,6 +79,7 @@ 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>();
@@ -89,10 +90,11 @@ public class BackendCompilerWrapper {
public final Map<String, Set<CompiledClass>> myFileNameToSourceMap= new THashMap<String, Set<CompiledClass>>();
public BackendCompilerWrapper(@NotNull final Project project,
public BackendCompilerWrapper(Chunk<Module> chunk, @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;
@@ -178,12 +180,15 @@ public class BackendCompilerWrapper {
myFilesToRecompile.addAll(allDependent);
}
final List<TranslatingCompiler.OutputItem> outputs = processPackageInfoFiles();
if (!myFilesToRecompile.isEmpty() || !outputs.isEmpty()) {
if (myFilesToRecompile.size() > 0 || outputs.size() > 0) {
mySink.add(null, outputs, VfsUtil.toVirtualFileArray(myFilesToRecompile));
}
}
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);
}
@@ -219,10 +224,12 @@ 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 (compileScope.belongs(file.getUrl())) {
filesInScope.add(file);
if (myCompileContext.getCompileScope().belongs(file.getUrl())) {
final Module module = myCompileContext.getModuleByFile(file);
if (myChunk.getNodes().contains(module)) {
filesInScope.add(file);
}
}
}
}
@@ -232,32 +239,14 @@ public class BackendCompilerWrapper {
private void compileModules(final Map<Module, List<VirtualFile>> moduleToFilesMap) throws CompilerException {
myProcessedFilesCount = 0;
final List<ModuleChunk> chunks = getModuleChunks(moduleToFilesMap);
try {
for (final ModuleChunk chunk : chunks) {
compileChunk(chunk);
}
compileChunk(new ModuleChunk(myCompileContext, myChunk, moduleToFilesMap));
}
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(myProject, Arrays.asList(files), (CompileContextEx)context, backEndCompiler, sink);
final BackendCompilerWrapper wrapper = new BackendCompilerWrapper(moduleChunk, myProject, Arrays.asList(files), (CompileContextEx)context, backEndCompiler, sink);
try {
wrapper.compile();
}