TextRange (GroovyPsiElement element) { assert element instanceof GrWhileStatement; GrCondition condition = ((GrWhileStatement) element).getCondition(); int endOffset = element.getTextRange().getEndOffset(); if (condition != null) { endOffset = condition.getTextRange().getStartOffset(); condition.getParent().getNode().removeChild(condition.getNode()); } return new TextRange(endOffset, endOffset); }