DEV Community

Ashok Kumar
Ashok Kumar

Posted on

Groovy ASTTransformation - Executing forLoop's collectionExpression inside closure

I am building custom DSL in Groovy and I want to execute the conditional expression of the forLoop inside a closure.

Basically, I am modifying the forLoop like this during the INSTRUCTION_SELECTION compile phase

visitForLoop(forLoop: ForStatement) {
.
.
.
.
forLoop.collectionExpression = ClosureExpression(emptyArray(),
                        GeneralUtils.stmt(forLoop.collectionExpression))
}

This is my Groovy…

Top comments (0)