private void runMainPasses(@NotNull ProgressIndicator daemonIndicator,
                             @NotNull Map<? super Document, ? super List<HighlightInfo>> result,
                             @NotNull PsiFile psiFile,
                             @NotNull Document document) {
    Project project = psiFile.getProject();
    DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
    ProcessCanceledException exception = null;
    DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
    // repeat several times when accidental background activity cancels highlighting
    int retries = 100;
    for (int i = 0; i < retries; i++) {
      int oldDelay = settings.getAutoReparseDelay();
      try {
        InspectionProfile currentProfile = myInspectionProfile;
        settings.setAutoReparseDelay(0);
        Function<InspectionProfile, InspectionProfileWrapper> profileProvider =
          p -> currentProfile == null
               ? new InspectionProfileWrapper((InspectionProfileImpl)p)
               : new InspectionProfileWrapper(currentProfile, ((InspectionProfileImpl)p).getProfileManager());
        InspectionProfileWrapper.runWithCustomInspectionWrapper(psiFile, profileProvider, () -> {
          List<HighlightInfo> infos = codeAnalyzer.runMainPasses(psiFile, document, daemonIndicator);
          result.put(document, infos);
        });
        break;
      }
      catch (ProcessCanceledException e) {
        Throwable cause = e.getCause();
        if (cause != null && cause.getClass() != Throwable.class) {
          // canceled because of an exception, no need to repeat the same a lot of times
          throw e;
        }

        exception = e;
      }
      finally {
        settings.setAutoReparseDelay(oldDelay);
      }
    }
    if (exception != null) {
      throw exception;
    }
  }
private void runMainPasses(@NotNull ProgressIndicator daemonIndicator,
                             @NotNull Map<? super Document, ? super List<HighlightInfo>> result,
                             @NotNull PsiFile psiFile,
                             @NotNull Document document)