TextRange (PsiElement first, PsiElement last) { while (true) { PsiElement prev = first.getPrevSibling(); prev = skipWhitespaceBack(prev); if (isOneLineFeed(prev)) prev = prev.getPrevSibling(); prev = skipWhitespaceBack(prev); if (prev != null && prev.getNode().getElementType() == GroovyTokenTypes.mSEMI || prev instanceof GrStatement) { first = prev; } else { break; } } while (true) { PsiElement next = last.getNextSibling(); next = skipWhitespacesForward(next); if (isOneLineFeed(next)) next = next.getNextSibling(); next = skipWhitespacesForward(next); if (next != null && next.getNode().getElementType() == GroovyTokenTypes.mSEMI || next instanceof GrStatement) { last = next; } else { break; } } return new TextRange(first.getTextRange().getStartOffset(), last.getTextRange().getEndOffset()); }