void (@NotNull final Project project, @NotNull final AnalysisScope scope) { PropertiesComponent.getInstance().setValue(ANNOTATE_LOCAL_VARIABLES, isAnnotateLocalVariables()); final ProgressManager progressManager = ProgressManager.getInstance(); final Set<Module> modulesWithoutAnnotations = new HashSet<>(); final Set<Module> modulesWithLL = new HashSet<>(); final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project); final String defaultNullable = NullableNotNullManager.getInstance(project).getDefaultNullable(); final int[] fileCount = new int[] {0}; if (!progressManager.runProcessWithProgressSynchronously(() -> scope.accept(new PsiElementVisitor() { final private Set<Module> processed = new HashSet<>(); @Override public void visitFile(@NotNull PsiFile file) { fileCount[0]++; final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { progressIndicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, project)); } progressIndicator.setText(AnalysisBundle.message("scanning.scope.progress.title")); if (!(file instanceof PsiJavaFile)) return; final Module module = ModuleUtilCore.findModuleForPsiElement(file); if (module != null && processed.add(module)) { if (PsiUtil.getLanguageLevel(file).compareTo(LanguageLevel.JDK_1_5) < 0) { modulesWithLL.add(module); } else if (javaPsiFacade.findClass(defaultNullable, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)) == null) { modulesWithoutAnnotations.add(module); } } } }), JavaBundle.message("progress.title.check.applicability"), true, project)) { return; } if (!modulesWithLL.isEmpty()) { Messages.showErrorDialog(project, JavaBundle .message("dialog.message.infer.nullity.annotations.requires.the.project.language.level"), JavaBundle.message("action.title.infer.nullity.annotations")); return; } if (!modulesWithoutAnnotations.isEmpty()) { addAnnotationsDependency(project, modulesWithoutAnnotations, defaultNullable, JavaBundle.message("action.title.infer.nullity.annotations")) .onSuccess(__ -> { restartAnalysis(project, scope); }); return; } PsiDocumentManager.getInstance(project).commitAllDocuments(); final UsageInfo[] usageInfos = findUsages(project, scope, fileCount[0]); if (usageInfos == null) return; processUsages(project, scope, usageInfos); }