boolean (Block block, final int line, final Commenter commenter) { boolean commented; int lineEndForBlockCommenting = -1; Document document = block.editor.getDocument(); int lineStart = document.getLineStartOffset(line); CharSequence chars = document.getCharsSequence(); lineStart = CharArrayUtil.shiftForward(chars, lineStart, " \t"); if (commenter instanceof SelfManagingCommenter selfManagingCommenter) { commented = selfManagingCommenter.isLineCommented(line, lineStart, document, block.commenterStateMap.get(selfManagingCommenter)); } else { String prefix = commenter.getLineCommentPrefix(); if (prefix != null) { commented = CharArrayUtil.regionMatches(chars, lineStart, StringUtil.trimTrailing(prefix)); } else { prefix = commenter.getBlockCommentPrefix(); String suffix = commenter.getBlockCommentSuffix(); final int textLength = document.getTextLength(); lineEndForBlockCommenting = document.getLineEndOffset(line); if (lineEndForBlockCommenting == textLength) { final int shifted = CharArrayUtil.shiftBackward(chars, textLength - 1, " \t"); if (shifted < textLength - 1) lineEndForBlockCommenting = shifted; } else { lineEndForBlockCommenting = CharArrayUtil.shiftBackward(chars, lineEndForBlockCommenting, " \t"); } commented = lineStart == lineEndForBlockCommenting && block.startLine != block.endLine || CharArrayUtil.regionMatches(chars, lineStart, prefix) && CharArrayUtil.regionMatches(chars, lineEndForBlockCommenting - suffix.length(), suffix); } } if (commented) { block.startOffsets[line - block.startLine] = lineStart; block.endOffsets[line - block.startLine] = lineEndForBlockCommenting; } return commented; }