GrExpression (@NotNull String text, PsiElement context) { GroovyFile file = createGroovyFile(text, false, context); GrTopStatement[] topStatements = file.getTopStatements(); if (topStatements.length == 0 || !(topStatements[0] instanceof GrExpression)) { throw new IncorrectOperationException("incorrect expression = '" + text + "'"); } return (GrExpression) topStatements[0]; }