Promise<Object> (@NotNull final PlaybackContext context) { final ActionCallback actionCallback = new ActionCallbackProfilerStopper(); final String[] commandArguments = extractCommandArgument(PREFIX).split("\\s+", 2); String shortInspectionName = commandArguments[0]; String extension = ""; if (commandArguments.length > 1) { extension = commandArguments[1]; } @NotNull Project project = context.getProject(); final InspectionProfile currentProfile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile(); final InspectionToolWrapper toolWrapper = currentProfile.getInspectionTool(shortInspectionName, project); InspectionManagerEx inspectionManagerEx = (InspectionManagerEx)InspectionManager.getInstance(project); if (toolWrapper != null) { final InspectionProfileImpl model = RunInspectionIntention.createProfile(toolWrapper, inspectionManagerEx, null); //noinspection TestOnlyProblems GlobalInspectionContextImpl inspectionContext = new GlobalInspectionContextImpl(project, inspectionManagerEx.getContentManager()) { private long numberOfProblems = 0; @Override protected void notifyInspectionsFinished(@NotNull AnalysisScope scope) { super.notifyInspectionsFinished(scope); try { File tempDirectory = FileUtil.createTempDirectory("inspection", "result"); final InspectionResultsView view = getView(); if (view != null) { ExportToXMLActionKt.dumpToXml(view.getCurrentProfile(), view.getTree(), view.getProject(), view.getGlobalInspectionContext(), tempDirectory.toPath()); File[] files = tempDirectory.listFiles(); if (files != null) { for (File file : files) { if (file.isHidden()) { continue; } Path path = file.toPath(); try (Stream<String> lines = Files.lines(path).filter(line -> line.contains("<problem>"))) { this.numberOfProblems = lines.count(); } } } else { LOGGER.error("tempDirectory.listFiles() is null"); } } } catch (IOException ex) { LOGGER.error(ex); } context.message(PerformanceTestingBundle.message("command.inspection.finish") + " " + PerformanceTestingBundle.message("command.inspection.finish.result", this.numberOfProblems), getLine()); actionCallback.setDone(); } }; inspectionContext.setExternalProfile(model); AnalysisScope scope = InspectionCommand.getAnalysisScope(extension, project); if (scope == null) { context.message(PerformanceTestingBundle.message("command.inspection.extension") + " " + extension, getLine()); } else { inspectionContext.doInspections(scope); } } else { actionCallback.reject(PerformanceTestingBundle.message("command.singleInspection.noinspection", shortInspectionName)); } return Promises.toPromise(actionCallback); }