private boolean exportPsiFile(@NotNull PsiFile psiFile,
                                @NotNull Path outDir,
                                Project project,
                                Map<PsiFile, PsiFile> filesMap) {
    if (psiFile instanceof PsiBinaryFile) {
      return true;
    }

    ApplicationManager.getApplication().runReadAction(() -> {
      if (!psiFile.isValid()) {
        return;
      }

      Int2ObjectMap<PsiReference> refMap = null;
      for (PrintOption printOption : PrintOption.EP_NAME.getExtensionList()) {
        Map<Integer, PsiReference> map = printOption.collectReferences(psiFile, filesMap);
        if (map != null) {
          refMap = new Int2ObjectRBTreeMap<>(map);
        }
      }

      try {
        HTMLTextPainter painter = new HTMLTextPainter(psiFile, project, new HtmlStyleManager(false),
                                                      ExportToHTMLSettings.getInstance(project).PRINT_LINE_NUMBERS, true);
        doPaint(constructOutputDirectory(psiFile.getContainingDirectory(), outDir), painter, refMap);
      }
      catch (NoSuchFileException e) {
        myLastException = e;
      }
      catch (IOException e) {
        LOG.error(e);
      }
    });
    return myLastException == null;
  }
private boolean exportPsiFile(@NotNull PsiFile psiFile,
                                @NotNull Path outDir,
                                Project project,
                                Map<PsiFile, PsiFile> filesMap)