private void reformat() {
    if (!myProject.isInitialized()) return;
    CommandProcessor.getInstance().executeCommand(
      myProject,
      () -> ApplicationManager.getApplication().runWriteAction(
        () -> {
          PsiFile originalPsiFile = resolveOriginalPsi();
          if (originalPsiFile != null) {
            CodeStyleSettings settings = CodeStyle.getSettings(originalPsiFile);
            PsiFile psiFile = createPsi(originalPsiFile.getFileType());
            psiFile.putUserData(PsiFileFactory.ORIGINAL_FILE, originalPsiFile);
            CodeStyle.runWithLocalSettings(
              myProject, settings, () -> CodeStyleManager.getInstance(myProject).reformatText(psiFile, 0, psiFile.getTextLength()));
            myDocument.replaceString(0, myDocument.getTextLength(), psiFile.getText());
          }
        }),
      EditorConfigBundle.message("command.name.reformat"), null);
  }
private void reformat()