From 0fd0dce5804cecbf18983a5e8fae9dd80f3fd4ab Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 24 Apr 2013 17:33:41 +0400 Subject: [PATCH] at the end of compilation additionally refresh output roots for generated sources, if they are located under module's source content. Need this to update errors highlighting in IDEA, if annotation processors generated something --- .../intellij/compiler/impl/CompileDriver.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index d9f3aac34d4f..f6bc2f473598 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -854,15 +854,37 @@ public class CompileDriver { if (refreshOutputRoots) { // refresh on output roots is required in order for the order enumerator to see all roots via VFS final Set outputs = new HashSet(); - for (final String path : CompilerPathsEx.getOutputPaths(ModuleManager.getInstance(myProject).getModules())) { + final Module[] affectedModules = compileContext.getCompileScope().getAffectedModules(); + for (final String path : CompilerPathsEx.getOutputPaths(affectedModules)) { outputs.add(new File(path)); } + final LocalFileSystem lfs = LocalFileSystem.getInstance(); if (!outputs.isEmpty()) { final ProgressIndicator indicator = compileContext.getProgressIndicator(); indicator.setText("Synchronizing output directories..."); - LocalFileSystem.getInstance().refreshIoFiles(outputs, false, false, null); + lfs.refreshIoFiles(outputs, false, false, null); indicator.setText(""); } + if (compileContext.isAnnotationProcessorsEnabled()) { + final Set genSourceRoots = new HashSet(); + final CompilerConfiguration config = CompilerConfiguration.getInstance(myProject); + for (Module module : affectedModules) { + if (config.getAnnotationProcessingConfiguration(module).isEnabled()) { + final String path = CompilerPaths.getAnnotationProcessorsGenerationPath(module); + if (path != null) { + final File genPath = new File(path); + final VirtualFile vFile = lfs.findFileByIoFile(genPath); + if (vFile != null && ModuleRootManager.getInstance(module).getFileIndex().isInSourceContent(vFile)) { + genSourceRoots.add(vFile); + } + } + } + } + if (!genSourceRoots.isEmpty()) { + // refresh generates source roots asynchronously; needed for error highlighting update + lfs.refreshFiles(genSourceRoots, true, true, null); + } + } } SwingUtilities.invokeLater(new Runnable() { public void run() {