public boolean addFile()

in src/main/java/org/jetbrains/plugins/spotbugs/core/FindBugsProjects.java [84:122]


	public boolean addFile(@NotNull final VirtualFile file, final boolean checkCompiled, final boolean includeTests) {
		if (!IdeaUtilImpl.isValidFileType(file.getFileType())) {
			return true;
		}

		final Module module = ModuleUtilCore.findModuleForFile(file, project);
		if (module == null) {
			throw new IllegalStateException("No module found for " + file);
		}

		if (checkCompiled) {
			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) {
				showWarning("Source is not compiled.");
				return false;
			}
			final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
			if (psiFile instanceof PsiJavaFile) { // think of scala, groovy, aj etc
				final PsiJavaFile javaFile = (PsiJavaFile) psiFile;
				String fileName = javaFile.getName();
				if (fileName.endsWith(".java")) {
					fileName = fileName.substring(0, fileName.length() - ".java".length());
				}
				final File outputPath = new File(compilerOutputPath.getCanonicalPath(), javaFile.getPackageName().replace(".", File.separator) + File.separator + fileName + ".class");
				if (!outputPath.exists()) {
					showWarning("Source is not compiled (" + outputPath + ").");
					return false;
				}
			}
		}

		final FindBugsProject findBugsProject = get(module, includeTests);
		findBugsProject.addOutputFile(file);
		return true;
	}