boolean (boolean online, @NotNull Project project, @NotNull Runnable rerunAction) { Module[] modules = ModuleManager.getInstance(project).getModules(); if (online) { if (modules.length == 0) { Messages.showMessageDialog(project, JavaBundle.message("inspection.no.modules.error.message"), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return false; } if (isBadSdk(project, modules)) { Messages.showMessageDialog(project, JavaBundle.message("inspection.no.jdk.error.message"), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); SdkPopupFactory .newBuilder() .withProject(project) .withSdkType(JavaSdk.getInstance()) .updateProjectSdkFromSelection() .onSdkSelected(sdk -> { DumbService.getInstance(project).completeJustSubmittedTasks(); rerunAction.run(); }) .buildPopup() .showInFocusCenter(); return false; } } else { if (modules.length == 0) { System.err.println(JavaBundle.message("inspection.no.modules.error.message")); return false; } if (isBadSdk(project, modules)) { System.err.println(JavaBundle.message("inspection.no.jdk.error.message")); System.err.println( JavaBundle.message("offline.inspections.jdk.not.found", ProjectRootManager.getInstance(project).getProjectSdkName())); return false; } for (Module module : modules) { ModuleRootManager rootManager = ModuleRootManager.getInstance(module); if (ModuleType.get(module) instanceof JavaModuleType && rootManager.getSourceRoots(true).length == 0) { LOG.info(JavaBundle.message("offline.inspections.no.source.roots", module.getName())); } OrderEntry[] entries = rootManager.getOrderEntries(); for (OrderEntry entry : entries) { if (entry instanceof JdkOrderEntry) { if (!ModuleType.get(module).isValidSdk(module, null)) { System.err.println(InspectionsBundle.message("offline.inspections.module.jdk.not.found", ((JdkOrderEntry)entry).getJdkName(), module.getName())); return false; } } else if (entry instanceof LibraryOrderEntry libraryOrderEntry) { Library library = libraryOrderEntry.getLibrary(); if (library == null) { System.err.println(JavaBundle.message("offline.inspections.library.was.not.resolved", libraryOrderEntry.getPresentableName(), module.getName())); } else { Set<String> detectedUrls = Arrays.stream(library.getFiles(OrderRootType.CLASSES)).map(VirtualFile::getUrl).collect(Collectors.toSet()); Set<String> declaredUrls = ContainerUtil.newHashSet(library.getUrls(OrderRootType.CLASSES)); declaredUrls.removeAll(detectedUrls); declaredUrls.removeIf(library::isJarDirectory); if (!declaredUrls.isEmpty()) { System.err.println(JavaBundle.message("offline.inspections.library.urls.were.not.resolved", StringUtil.join(declaredUrls, ", "), libraryOrderEntry.getPresentableName(), module.getName())); } } } } } } return true; }