void (Document document, int startOffset, int endOffset, @NotNull Commenter commenter, boolean removeSpace) { final String commentedSuffix = commenter.getCommentedBlockCommentSuffix(); final String commentedPrefix = commenter.getCommentedBlockCommentPrefix(); final String prefix = commenter.getBlockCommentPrefix(); final String suffix = commenter.getBlockCommentSuffix(); if (prefix == null || suffix == null) { return; } CharSequence chars = document.getCharsSequence(); if (endOffset >= suffix.length() && CharArrayUtil.regionMatches(chars, endOffset - suffix.length(), suffix)) { int from = endOffset - suffix.length(); if (removeSpace && StringUtil.isChar(chars, from - 1, ' ')) { from--; } document.deleteString(from, endOffset); endOffset = from; } if (commentedPrefix != null && commentedSuffix != null) { CommentByBlockCommentHandler.commentNestedComments(document, new TextRange(startOffset, endOffset), commenter); } int to = startOffset + prefix.length(); if (removeSpace && StringUtil.isChar(chars, to, ' ')) { to++; } document.deleteString(startOffset, to); }