GrCodeBlock (@NotNull String text) { final GroovyFileBase file = createGroovyFileChecked("def foo () {" + text + "}"); final GrMethod method = (GrMethod) file.getTopStatements()[0]; return method.getBlock(); }