int (@NotNull Editor editor, int offset, @NotNull CodeDocumentationAwareCommenter commenter) { EditorHighlighter highlighter = editor.getHighlighter(); HighlighterIterator iterator = highlighter.createIterator(offset); if (iterator.atEnd() || iterator.getTokenType() != commenter.getBlockCommentTokenType()) return -1; String prefix = ObjectUtils.notNull(commenter.getBlockCommentPrefix(), ""); int tokenStart = iterator.getStart(); int tokenEnd = iterator.getEnd(); int prefixEnd = tokenStart + prefix.length(); if (prefixEnd > tokenEnd || prefixEnd > offset) return -1; String suffix = ObjectUtils.notNull(commenter.getBlockCommentSuffix(), ""); if (StringUtil.endsWith(editor.getDocument().getImmutableCharSequence().subSequence(prefixEnd, tokenEnd), suffix) && offset > tokenEnd - suffix.length()) { return -1; } return tokenStart; }