public boolean validateConfiguration(CompileScope compileScope) {
// Allow for usage of just the syntax hilighter if no facets are enabled for compilation.
boolean hasAnyModulesEnabledForCompilation = false;
Module[] modules = compileScope.getAffectedModules();
for (Module module : modules) {
PbFacet facet = FacetManager.getInstance(module).getFacetByType(PbFacetType.ID);
if (facet != null && facet.getConfiguration().isCompilationEnabled()) {
hasAnyModulesEnabledForCompilation = true;
break;
}
}
if (!hasAnyModulesEnabledForCompilation) {
// Bail early.
LOG.info("No facets detected for compilation. Giving up on configuration check.");
return true;
}
// Check if the compiler supports current operating system.
if (getCompilerExecutableName() == null) {
Messages.showErrorDialog(PbBundle.message(
"compiler.validate.error.unsupported.os"),
PbBundle.message("compiler.validate.error.title"));
return false;
}
// Check the to path to the compiler.
final String pathToCompiler = getPathToCompiler();
File compilerFile = new File(pathToCompiler);
if (!compilerFile.exists()) {
Messages.showErrorDialog(PbBundle.message(
"compiler.validate.error.path.to.protoc", pathToCompiler),
PbBundle.message("compiler.validate.error.title"));
return false;
} else if (!compilerFile.canExecute()) {
Messages.showErrorDialog(PbBundle.message(
"compiler.validate.error.protoc.not.executable", pathToCompiler + "/protoc"),
PbBundle.message("compiler.validate.error.title"));
return false;
}
for (Module module : modules) {
PbFacet facet = FacetManager.getInstance(module).getFacetByType(PbFacetType.ID);
if (facet != null) {
String outputPath = facet.getConfiguration().getCompilerOutputPath();
// Make sure the configuration has a value for the output source directory.
if (outputPath == null) {
Messages.showErrorDialog(PbBundle.message(
"compiler.validate.error.output.source.directory.not.set", module.getName()),