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() {