protected void reformatRange(@NotNull Project project, @NotNull Editor editor, int startOffset, int endOffset) {
    Document document = editor.getDocument();
    final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
    documentManager.commitDocument(document);
    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
    if (file == null) return;
    try {
      FormattingServiceUtil.asyncFormatElement(file, new TextRange(startOffset, endOffset), true);
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
    }
  }
protected void reformatRange(@NotNull Project project, @NotNull Editor editor, int startOffset, int endOffset)