private static int processIndents(Document document, int tabSize, TextRange textRange, IndentBuilder indentBuilder) {
    int[] changedLines = {0};
    DocumentUtil.executeInBulk(document, () -> {
      int startLine = document.getLineNumber(textRange.getStartOffset());
      int endLine = document.getLineNumber(textRange.getEndOffset());
      for (int line = startLine; line <= endLine; line++) {
        int indent = 0;
        final int lineStart = document.getLineStartOffset(line);
        final int lineEnd = document.getLineEndOffset(line);
        int indentEnd = lineEnd;
        for(int offset = Math.max(lineStart, textRange.getStartOffset()); offset < lineEnd; offset++) {
          char c = document.getCharsSequence().charAt(offset);
          if (c == ' ') {
            indent++;
          }
          else if (c == '\t') {
            indent = ((indent / tabSize) + 1) * tabSize;
          }
          else {
            indentEnd = offset;
            break;
          }
        }
        if (indent > 0) {
          String oldIndent = document.getCharsSequence().subSequence(lineStart, indentEnd).toString();
          String newIndent = indentBuilder.buildIndent(indent, tabSize);
          if (!oldIndent.equals(newIndent)) {
            document.replaceString(lineStart, indentEnd, newIndent);
            changedLines[0]++;
          }
        }
      }
    });
    return changedLines[0];
  }
private static int processIndents(Document document, int tabSize, TextRange textRange, IndentBuilder indentBuilder)