int (@NotNull Editor editor, int offset, @NotNull CodeDocumentationAwareCommenter commenter) { if (offset < 1) return -1; EditorHighlighter highlighter = editor.getHighlighter(); HighlighterIterator iterator = highlighter.createIterator(offset - 1); String prefix = commenter.getLineCommentPrefix(); return iterator.getTokenType() == commenter.getLineCommentTokenType() && (iterator.getStart() + (prefix == null ? 0 : prefix.length())) <= offset ? iterator.getStart() : -1; }