@NotNull
  private Processor<VirtualFile> buildProcessor(@NotNull AnalysisScope scope,
                                                EnabledInspectionsProvider enabledInspectionsProvider,
                                                SearchScope searchScope,
                                                InspectionManager inspectionManager,
                                                Map<String, InspectionToolWrapper<?, ?>> map) {
    PsiManager psiManager = PsiManager.getInstance(getProject());
    boolean inspectInjectedPsi = Registry.is("idea.batch.inspections.inspect.injected.psi", true);

    return virtualFile -> {
      ProgressManager.checkCanceled();

      final var wrappersForThisFile = new AtomicReference<EnabledInspectionsProvider.ToolWrappers>(null);

      Computable<Boolean> inspection = () -> {
        long start = getPathProfile() == null ? 0 : System.currentTimeMillis();
        PsiFile file = virtualFile.isValid() ? psiManager.findFile(virtualFile) : null;
        if (file == null) {
          return true;
        }
        if (!scope.contains(virtualFile)) {
          LOG.info(file.getName() + "; scope: " + scope + "; " + virtualFile);
          return true;
        }
        boolean includeDoNotShow = includeDoNotShow(getCurrentProfile());
        var wrappers = getWrappersFromTools(enabledInspectionsProvider, file, includeDoNotShow);
        wrappersForThisFile.set(wrappers);

        inspectFile(file, getEffectiveRange(searchScope, file), inspectionManager, map,
                    wrappers.getGlobalSimpleRegularWrappers(),
                    wrappers.getLocalRegularWrappers(),
                    inspectInjectedPsi && scope.isAnalyzeInjectedCode());
        if (start != 0) {
          updateProfile(virtualFile, System.currentTimeMillis() - start);
        }
        return true;
      };
      Boolean readActionSuccess = DumbService.getInstance(getProject())
        .tryRunReadActionInSmartMode(
          inspection,
          LangBundle.message("popup.content.inspect.code.not.available.until.indices.are.ready"),
          DumbModeBlockedFunctionality.GlobalInspectionContext
        );

      if (readActionSuccess == null || !readActionSuccess) {
        throw new ProcessCanceledException();
      }

      PsiFile file = ReadAction.compute(() -> psiManager.findFile(virtualFile));
      if (file == null) {
        return true;
      }
      getInspectionEventPublisher().fileAnalyzed(file, getProject());

      boolean includeDoNotShow = includeDoNotShow(getCurrentProfile());

      var cachedWrappersValue = wrappersForThisFile.get();
      var wrappers =
        (cachedWrappersValue != null) ? cachedWrappersValue : getWrappersFromTools(enabledInspectionsProvider, file, includeDoNotShow);

      wrappers.getExternalAnnotatorWrappers()
        .forEach(wrapper -> {
          var tool = ((ExternalAnnotatorBatchInspection)wrapper.getTool());
          var descriptors = tool.checkFile(file, this, inspectionManager);
          InspectionToolResultExporter toolPresentation = getPresentation(wrapper);
          ReadAction.run(() -> BatchModeDescriptorsUtil
            .addProblemDescriptors(Arrays.asList(descriptors), false, this, null, toolPresentation, CONVERT));
        });

      return true;
    };
  }
@NotNull
  private Processor<VirtualFile> buildProcessor(@NotNull AnalysisScope scope,
                                                EnabledInspectionsProvider enabledInspectionsProvider,
                                                SearchScope searchScope,
                                                InspectionManager inspectionManager,
                                                Map<String, InspectionToolWrapper<?, ?>> map)