GrReferenceExpression (@NotNull String idText, PsiElement context) { GroovyFile file = createGroovyFileChecked(idText, false, context); GrTopStatement[] statements = file.getTopStatements(); if (statements.length != 1) throw new IncorrectOperationException("refText: " + idText); if (!(statements[0] instanceof GrReferenceExpression)) throw new IncorrectOperationException("refText: " + idText); return (GrReferenceExpression)statements[0]; }