GrStatement (@NotNull CharSequence text, @Nullable PsiElement context) { GroovyFile file = createGroovyFileChecked(text, false, context); GrTopStatement[] statements = file.getTopStatements(); if (statements.length != 1) { throw new IncorrectOperationException("count = " + statements.length + ", " + text); } if (!(statements[0] instanceof GrStatement)) { throw new IncorrectOperationException("type = " + statements[0].getClass().getName() + ", " + text); } return (GrStatement)statements[0]; }