List<TextRange> (@NotNull PsiElement element, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) { List<TextRange> result = super.select(element, editorText, cursorOffset, editor); assert result != null; PsiElement firstComment = element; PsiElement e = element; while (e != null) { if (e instanceof PsiComment) { firstComment = e; } else if (!(e instanceof PsiWhiteSpace)) { break; } e = e.getPrevSibling(); } PsiElement lastComment = element; e = element; while (e != null) { if (e instanceof PsiComment) { lastComment = e; } else if (!(e instanceof PsiWhiteSpace)) { break; } e = e.getNextSibling(); } result.addAll(expandToWholeLine(editorText, new TextRange(firstComment.getTextRange().getStartOffset(), lastComment.getTextRange().getEndOffset()))); return result; }