void (@NotNull List<? super Path> inspectionsResults, @NotNull Path outputDir) { List<Tools> globalToolsWithProblems = new ArrayList<>(); List<Tools> toolsWithResultsToAggregate = new ArrayList<>(); for (Map.Entry<String, Tools> entry : getTools().entrySet()) { Tools sameTools = entry.getValue(); boolean hasProblems = false; String toolName = entry.getKey(); if (sameTools != null) { for (ScopeToolState toolDescr : sameTools.getTools()) { InspectionToolWrapper<?, ?> toolWrapper = toolDescr.getTool(); InspectionToolResultExporter presentation = getPresentation(toolWrapper); try { if (presentation instanceof AggregateResultsExporter) { ReadAction.run(() -> presentation.updateContent()); if (presentation.hasReportedProblems().toBoolean()) { toolsWithResultsToAggregate.add(sameTools); break; } } if (toolWrapper instanceof LocalInspectionToolWrapper) { hasProblems = Files.exists(InspectionsResultUtil.getInspectionResultPath(outputDir, toolWrapper.getShortName())); } else { ReadAction.run(() -> presentation.updateContent()); if (presentation.hasReportedProblems().toBoolean()) { globalToolsWithProblems.add(sameTools); LOG.assertTrue(!hasProblems, toolName); break; } } } catch (ProcessCanceledException | IndexNotReadyException e) { throw e; } catch (Throwable e) { LOG.error(e); } } } // close "problem" tag for local inspections (see DefaultInspectionToolResultExporter.addProblemElement()) if (hasProblems) { try { Path file = InspectionsResultUtil.getInspectionResultPath(outputDir, sameTools.getShortName()); inspectionsResults.add(file); Files.writeString(file, "</" + PROBLEMS_TAG_NAME + ">", StandardOpenOption.APPEND); } catch (IOException e) { LOG.error(e); } } } exportResultsWithAggregation(inspectionsResults, toolsWithResultsToAggregate, outputDir); // export global inspections if (!globalToolsWithProblems.isEmpty()) { XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newDefaultFactory(); ContainerUtil.splitListToChunks(globalToolsWithProblems, MAX_OPEN_GLOBAL_INSPECTION_XML_RESULT_FILES) .forEach(inspections -> exportResults(inspectionsResults, inspections, outputDir, xmlOutputFactory)); } }