private void findProblemsInFile(@NotNull PsiFile file,
                                  @NotNull List<? extends LocalInspectionToolWrapper> localTools,
                                  @Nullable TextRange range,
                                  @NotNull SearchScope searchScope,
                                  @NotNull List<? super ProblemDescriptor> descriptorResults,
                                  @NotNull Set<? super PsiFile> visitedFiles,
                                  @NotNull Predicate<? super ProblemDescriptor> shouldApplyFix) {
    try {
      TextRange restrictRange =
        range == null ? file.getTextRange() : range;
      ApplicationManager.getApplication().runReadAction(() -> {
        Map<LocalInspectionToolWrapper, List<ProblemDescriptor>> map =
          InspectionEngine.inspectEx(localTools, file, restrictRange,
                                     restrictRange, false, true, true,
                                     myProgressIndicator,
                                     (__, ___) -> true);
        for (Map.Entry<LocalInspectionToolWrapper, List<ProblemDescriptor>> entry : map.entrySet()) {
          LocalInspectionToolWrapper toolWrapper = entry.getKey();
          List<ProblemDescriptor> descriptors = entry.getValue();
          InspectionToolPresentation toolPresentation =
            getPresentation(toolWrapper);
          BatchModeDescriptorsUtil.addProblemDescriptors(descriptors,
                                                         toolPresentation,
                                                         true,
                                                         this,
                                                         toolWrapper.getTool());
        }
      });

      Set<ProblemDescriptor> localDescriptors =
        new TreeSet<>(CommonProblemDescriptor.DESCRIPTOR_COMPARATOR);
      for (LocalInspectionToolWrapper tool : localTools) {
        InspectionToolResultExporter toolPresentation =
          getPresentation(tool);
        for (CommonProblemDescriptor descriptor : toolPresentation.getProblemDescriptors()) {
          if (descriptor instanceof ProblemDescriptor) {
            localDescriptors.add((ProblemDescriptor)descriptor);
          }
        }
      }

      if (searchScope instanceof LocalSearchScope) {
        for (Iterator<ProblemDescriptor> iterator =
             localDescriptors.iterator(); iterator.hasNext(); ) {
          ProblemDescriptor descriptor = iterator.next();
          TextRange infoRange =
            descriptor instanceof ProblemDescriptorBase
            ? ((ProblemDescriptorBase)descriptor).getTextRange()
            : null;
          if (infoRange != null &&
              !((LocalSearchScope)searchScope).containsRange(file,
                                                             infoRange)) {
            iterator.remove();
          }
        }
      }
      if (!localDescriptors.isEmpty()) {
        for (ProblemDescriptor descriptor : localDescriptors) {
          if (shouldApplyFix.test(descriptor)) {
            descriptorResults.add(descriptor);
          }
        }
        visitedFiles.add(file);
      }
    }
    finally {
      myPresentationMap.clear();
    }
  }
private void findProblemsInFile(@NotNull PsiFile file,
                                  @NotNull List<? extends LocalInspectionToolWrapper> localTools,
                                  @Nullable TextRange range,
                                  @NotNull SearchScope searchScope,
                                  @NotNull List<? super ProblemDescriptor> descriptorResults,
                                  @NotNull Set<? super PsiFile> visitedFiles,
                                  @NotNull Predicate<? super ProblemDescriptor> shouldApplyFix)