static void doIndent(final int endIndex, final int startIndex, final Document document, final Project project, final Editor editor,
                       final int blockIndent) {
    final int[] caretOffset = {editor.getCaretModel().getOffset()};

    SelectionModel selectionModel = editor.getSelectionModel();
    boolean extendSelection = selectionModel.hasSelection() &&
                              DocumentUtil.isAtLineStart(selectionModel.getSelectionStart(), document) &&
                              (selectionModel.getSelectionEnd() == document.getTextLength() ||
                               DocumentUtil.isAtLineStart(selectionModel.getSelectionEnd(), document));

    boolean bulkMode = endIndex - startIndex > 50;
    DocumentUtil.executeInBulk(document, bulkMode, () -> {
      List<Integer> nonModifiableLines = new ArrayList<>();
      if (project != null) {
        int indentationStartOffset = document.getLineStartOffset(startIndex);
        int indentationEndOffset = document.getLineStartOffset(endIndex);
        PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
        IndentStrategy indentStrategy = LanguageIndentStrategy.getIndentStrategy(file);
        if (file != null && !LanguageIndentStrategy.isDefault(indentStrategy)) {
          for (int i = startIndex; i <= endIndex; i++) {
            PsiElement element = file.findElementAt(document.getLineStartOffset(i));
            if (element != null && !indentStrategy.canIndent(indentationStartOffset, indentationEndOffset, element)) {
              nonModifiableLines.add(i);
            }
          }
        }
      }
      for (int i = startIndex; i <= endIndex; i++) {
        if (!nonModifiableLines.contains(i)) {
          caretOffset[0] = EditorActionUtil.indentLine(project, editor, i, blockIndent, caretOffset[0]);
        }
      }
    });

    if (extendSelection) {
      selectionModel.setSelection(DocumentUtil.getLineStartOffset(selectionModel.getSelectionStart(), document),
                                  selectionModel.getSelectionEnd());
    }

    editor.getCaretModel().moveToOffset(caretOffset[0]);
  }
static void doIndent(final int endIndex, final int startIndex, final Document document, final Project project, final Editor editor,
                       final int blockIndent)