private @NotNull StubTreeAndIndexUnmatchCoarseException doCreateCoarseExceptionStubTreeAndIndexDoNotMatch(
    @Nullable ObjectStubTree<?> stubTree,
    @NotNull PsiFileWithStubSupport psiFile,
    @Nullable Throwable cause,
    @NotNull StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source
  ) {
    return ProgressManager.getInstance().computeInNonCancelableSection(() -> {
      VirtualFile file = psiFile.getViewProvider().getVirtualFile();
      boolean compiled = psiFile instanceof PsiCompiledElement;
      Document document = compiled ? null : FileDocumentManager.getInstance().getDocument(file);
      IndexingStampInfo indexingStampInfo = getIndexingStampInfo(file);
      boolean upToDate = indexingStampInfo != null && indexingStampInfo.isUpToDate(document, file, psiFile);

      @NonNls String msg = "PSI and index do not match.\nPlease report the problem to JetBrains with the files attached\n";

      if (upToDate) {
        msg += "INDEXED VERSION IS THE CURRENT ONE";
      }

      msg += " file=" + psiFile;
      msg += ", file.class=" + psiFile.getClass();
      msg += ", file.lang=" + psiFile.getLanguage();
      msg += ", modStamp=" + psiFile.getModificationStamp();

      if (!compiled) {
        String text = psiFile.getText();
        PsiFile fromText =
          PsiFileFactory.getInstance(psiFile.getProject()).createFileFromText(psiFile.getName(), psiFile.getFileType(), text);
        if (fromText.getLanguage().equals(psiFile.getLanguage())) {
          boolean consistent = DebugUtil.psiToString(psiFile, false).equals(DebugUtil.psiToString(fromText, false));
          msg += consistent ? "\n tree consistent" : "\n AST INCONSISTENT, perhaps after incremental reparse; " + fromText;
        }
      }

      if (stubTree != null) {
        msg += "\n stub debugInfo=" + stubTree.getDebugInfo();
      }


      FileViewProvider viewProvider = psiFile.getViewProvider();
      msg += "\n viewProvider=" + viewProvider;
      msg += "\n viewProvider stamp: " + viewProvider.getModificationStamp();

      msg += "; file stamp: " + file.getModificationStamp();
      msg += "; file modCount: " + file.getModificationCount();
      msg += "; file length: " + file.getLength();

      if (document != null) {
        msg += "\n doc saved: " + !FileDocumentManager.getInstance().isDocumentUnsaved(document);
        msg += "; doc stamp: " + document.getModificationStamp();
        msg += "; doc size: " + document.getTextLength();
        msg += "; committed: " + PsiDocumentManager.getInstance(psiFile.getProject()).isCommitted(document);
      }

      msg += "\nindexing info: " + indexingStampInfo;
      msg += "\nref: 50cf572587cf";

      ArrayList<Attachment> attachments = createAttachments(stubTree, psiFile, file);
      StubInconsistencyReporter.getInstance().reportStubTreeAndIndexDoNotMatch(psiFile.getProject(), source);
      return new StubTreeAndIndexUnmatchCoarseException(psiFile, file, msg, attachments, upToDate, cause, stubTree);
    });
  }
private @NotNull StubTreeAndIndexUnmatchCoarseException doCreateCoarseExceptionStubTreeAndIndexDoNotMatch(
    @Nullable ObjectStubTree<?> stubTree,
    @NotNull PsiFileWithStubSupport psiFile,
    @Nullable Throwable cause,
    @NotNull StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source
  )