in src/main/java/org/jetbrains/plugins/spotbugs/actions/AnalyzeProjectFiles.java [70:122]
void analyze(
@NotNull final AnActionEvent e,
@NotNull final Project project,
@NotNull final ToolWindow toolWindow,
@NotNull final FindBugsState state
) {
new FindBugsStarter(project, "Running SpotBugs analysis for project '" + project.getName() + "'...") {
@Override
protected void createCompileScope(@NotNull final CompilerManager compilerManager, @NotNull final Consumer<CompileScope> consumer) {
consumer.consume(compilerManager.createProjectCompileScope(project));
}
@Override
protected boolean configure(@NotNull final ProgressIndicator indicator, @NotNull final FindBugsProjects projects, final boolean justCompiled) {
final Module[] modules = ModuleManager.getInstance(project).getModules();
final List<Pair.NonNull<Module, VirtualFile>> compilerOutputPaths = new ArrayList<>();
for (final Module module : modules) {
final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
if (extension == null) {
throw new IllegalStateException("No compiler extension for module " + module.getName());
}
final VirtualFile compilerOutputPath = extension.getCompilerOutputPath();
if (compilerOutputPath != null) {
/*
* Otherwise ignore it. Maybe this module is only used to contains fact (think of Android)
* or to aggregate modules (think of maven).
*/
compilerOutputPaths.add(Pair.createNonNull(module, compilerOutputPath));
}
if (includeTests) {
final VirtualFile compilerOutputPathForTests = extension.getCompilerOutputPathForTests();
if (compilerOutputPathForTests != null) {
compilerOutputPaths.add(Pair.createNonNull(module, compilerOutputPathForTests));
}
}
}
if (compilerOutputPaths.isEmpty()) {
showWarning(ResourcesLoader.getString("analysis.noOutputPaths"));
return false;
}
indicator.setText("Collecting files for analysis...");
final int[] count = new int[1];
for (final Pair.NonNull<Module, VirtualFile> compilerOutputPath : compilerOutputPaths) {
final FindBugsProject findBugsProject = projects.get(compilerOutputPath.getFirst(), includeTests);
RecurseFileCollector.addFiles(project, indicator, findBugsProject, new File(compilerOutputPath.getSecond().getCanonicalPath()), count);
}
return true;
}
}.start();
}