void (int startOffset, int endOffset, String commentPrefix, String commentSuffix, Commenter commenter) { if (breaksExistingComment(startOffset, true) || breaksExistingComment(endOffset, false)) { myWarning = CodeInsightBundle.message("block.comment.intersects.existing.comment"); return; } final CharSequence chars = myDocument.getCharsSequence(); LogicalPosition caretPosition = myCaret.getLogicalPosition(); CommonCodeStyleSettings settings = getLanguageSettings(); if (startOffset == 0 || chars.charAt(startOffset - 1) == '\n') { if (endOffset == myDocument.getTextLength() || endOffset > 0 && chars.charAt(endOffset - 1) == '\n') { String space; Boolean forced = commenter instanceof IndentedCommenter ? ((IndentedCommenter)commenter).forceIndentedBlockComment() : null; if ((forced == null && !settings.BLOCK_COMMENT_AT_FIRST_COLUMN) || forced == Boolean.TRUE) { int line1 = myEditor.offsetToLogicalPosition(startOffset).line; int line2 = myEditor.offsetToLogicalPosition(endOffset - 1).line; IndentData minIndent = CommentUtil.getMinLineIndent(myDocument, line1, line2, myFile); if (minIndent == null) { minIndent = new IndentData(0); } space = minIndent.createIndentInfo().generateNewWhiteSpace(CodeStyle.getIndentOptions(myFile)); } else { space = ""; } final StringBuilder nestingPrefix = new StringBuilder(space).append(commentPrefix); if (!commentPrefix.endsWith("\n")) { nestingPrefix.append("\n"); } String nestingSuffix = space + (commentSuffix.startsWith("\n") ? commentSuffix.substring(1) : commentSuffix) + "\n"; TextRange range = insertNestedComments(startOffset, endOffset, nestingPrefix.toString(), nestingSuffix, commenter); if (range != null) { myCaret.setSelection(range.getStartOffset(), range.getEndOffset()); LogicalPosition pos = new LogicalPosition(caretPosition.line + 1, caretPosition.column); myCaret.moveToLogicalPosition(pos); } return; } } String nestingPrefix = commentPrefix; String nestingSuffix = commentSuffix; if (settings.BLOCK_COMMENT_ADD_SPACE) { nestingPrefix += " "; nestingSuffix = " " + nestingSuffix; } TextRange range = insertNestedComments(startOffset, endOffset, nestingPrefix, nestingSuffix, commenter); if (range != null) { myCaret.setSelection(range.getStartOffset(), range.getEndOffset()); LogicalPosition pos = new LogicalPosition(caretPosition.line, caretPosition.column + nestingPrefix.length()); myCaret.moveToLogicalPosition(pos); } }