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

This commit is contained in:
Eugene Zhuravlev
2013-04-24 18:35:20 +04:00
parent 186fe4229c
commit 0fd0dce580
@@ -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<File> outputs = new HashSet<File>();
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<VirtualFile> genSourceRoots = new HashSet<VirtualFile>();
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() {