module cycles validation for annotation processing

This commit is contained in:
Eugene Zhuravlev
2009-10-12 13:25:42 +04:00
parent 98b15b698a
commit 8fefdd24a4
3 changed files with 23 additions and 0 deletions
@@ -197,6 +197,9 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
}
public JavacCompiler getJavacCompiler() {
if (JAVAC_EXTERNAL_BACKEND == null) {
createCompilers();
}
return JAVAC_EXTERNAL_BACKEND;
}
@@ -1829,11 +1829,21 @@ public class CompileDriver {
}
}
final List<Chunk<Module>> chunks = ModuleCompilerUtil.getSortedModuleChunks(myProject, Arrays.asList(scopeModules));
final CompilerConfiguration config = CompilerConfiguration.getInstance(myProject);
for (final Chunk<Module> chunk : chunks) {
final Set<Module> chunkModules = chunk.getNodes();
if (chunkModules.size() <= 1) {
continue; // no need to check one-module chunks
}
if (config.isAnnotationProcessorsEnabled()) {
final Set<Module> excluded = config.getExcludedModules();
for (Module chunkModule : chunkModules) {
if (!excluded.contains(chunkModule)) {
showCyclesNotSupportedForAnnotationProcessors(chunkModules.toArray(new Module[chunkModules.size()]));
return false;
}
}
}
Sdk jdk = null;
LanguageLevel languageLevel = null;
for (final Module module : chunkModules) {
@@ -1887,6 +1897,15 @@ public class CompileDriver {
showConfigurationDialog(moduleNameToSelect, null);
}
private void showCyclesNotSupportedForAnnotationProcessors(Module[] modulesInChunk) {
LOG.assertTrue(modulesInChunk.length > 0);
String moduleNameToSelect = modulesInChunk[0].getName();
final String moduleNames = getModulesString(modulesInChunk);
Messages.showMessageDialog(myProject, CompilerBundle.message("error.annotation.processing.not.supported.for.module.cycles", moduleNames),
CommonBundle.getErrorTitle(), Messages.getErrorIcon());
showConfigurationDialog(moduleNameToSelect, null);
}
private static String getModulesString(Module[] modulesInChunk) {
final StringBuilder moduleNames = StringBuilderSpinAllocator.alloc();
try {
@@ -71,6 +71,7 @@ progress.executing.postcompile.tasks=Executing post-compile tasks...
error.failed.to.create.directory=Failed to create directory {0}
error.chunk.modules.must.have.same.jdk=The following modules must have the same JDK assigned because of cyclic dependencies between them:\n{0}\nPlease update modules configuration
error.chunk.modules.must.have.same.language.level=The following modules must have the same language level assigned because of cyclic dependencies between them:\n{0}\nPlease update modules configuration
error.annotation.processing.not.supported.for.module.cycles=Annotation processors running is not supported for module cycles. The following modules form a cycle:\n{0}\nPlease either update modules configuration or exclude these modules from annotation processing
warning.sources.under.output.paths=Compiler option \"Clear output directory on rebuild\" is currently on.\nHowever, source files may exist in the following output paths:\n{0}\nCompilation will proceed without clearing output directories.
action.compiler.properties.text=Compiler Properties
actions.exclude.from.compile.text=Exclude from Compile