void (Editor editor, Project project) { int oldSelectionStart = editor.getSelectionModel().getSelectionStart(); int oldSelectionEnd = editor.getSelectionModel().getSelectionEnd(); if (!editor.getSelectionModel().hasSelection()) { oldSelectionStart = editor.getCaretModel().getOffset(); oldSelectionEnd = oldSelectionStart; } Document document = editor.getDocument(); int startIndex = document.getLineNumber(oldSelectionStart); if (startIndex == -1) { startIndex = document.getLineCount() - 1; } int endIndex = document.getLineNumber(oldSelectionEnd); if (endIndex > 0 && document.getLineStartOffset(endIndex) == oldSelectionEnd && editor.getSelectionModel().hasSelection()) { endIndex--; } if (endIndex == -1) { endIndex = document.getLineCount() - 1; } int blockIndent = CodeStyle.getIndentOptions(project, document).INDENT_SIZE; doIndent(endIndex, startIndex, document, project, editor, blockIndent); }