public static void autoIndent(@NotNull Editor editor) {
    Project project = editor.getProject();
    if (project != null) {
      PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
      Document document = editor.getDocument();
      documentManager.commitDocument(document);
      int lineOffset = document.getLineStartOffset(document.getLineNumber(editor.getCaretModel().getOffset()));
      CodeStyleManager.getInstance(project).adjustLineIndent(document, lineOffset);
    }
  }
public static void autoIndent(@NotNull Editor editor)