private static int reformatBrace(Editor editor, int tailOffset, int startOffset) {
    Project project = editor.getProject();
    if (project != null) {
      PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
      if (psiFile != null) {
        editor.getCaretModel().moveToOffset(tailOffset);
        CodeStyleManager.getInstance(project).reformatText(psiFile, startOffset, tailOffset);
        tailOffset = editor.getCaretModel().getOffset();
      }
    }
    return tailOffset;
  }
private static int reformatBrace(Editor editor, int tailOffset, int startOffset)