GrTopStatement (@NotNull String text) { GroovyFile dummyFile = createGroovyFileChecked(text); final GrTopStatement[] topStatements = dummyFile.getTopStatements(); if (topStatements.length != 1) throw new IncorrectOperationException("text = '" + text + "'"); return topStatements[0]; }