void (GrStringInjection injection) { final GrExpression expression = injection.getExpression(); LOG.assertTrue(expression != null); final GroovyPsiElementFactory instance = GroovyPsiElementFactory.getInstance(injection.getProject()); final GrClosableBlock closure = instance.createClosureFromText("{foo}"); closure.getNode().replaceChild(closure.getStatements()[0].getNode(), expression.getNode()); injection.getNode().addChild(closure.getNode()); CodeEditUtil.setNodeGeneratedRecursively(expression.getNode(), true); }