List<TextRange> (@NotNull PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) { TextRange originalRange; PsiElement first; PsiElement last; if (e instanceof GrStatement) { first = e; PsiElement next = e.getNextSibling(); next = skipWhitespacesForward(next); if (next != null && next.getNode().getElementType() == GroovyTokenTypes.mSEMI) { originalRange = new TextRange(e.getTextRange().getStartOffset(), next.getTextRange().getEndOffset()); last = next; } else { originalRange = e.getTextRange(); last = e; } } else { last = e; PsiElement prev = e.getPrevSibling(); prev = skipWhitespaceBack(prev); if (prev instanceof GrStatement) { originalRange = new TextRange(prev.getTextRange().getStartOffset(), e.getTextRange().getEndOffset()); first = prev; } else { originalRange = e.getTextRange(); first = e; } } final List<TextRange> ranges = ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, originalRange); final TextRange blockRange = inferBlockRange(first, last); if (!blockRange.equals(originalRange)) { ranges.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, blockRange, true)); } return ranges; }