Daniel Sun created GROOVY-9324:
----------------------------------

             Summary: Implement `AstStringCompiler` in Java
                 Key: GROOVY-9324
                 URL: https://issues.apache.org/jira/browse/GROOVY-9324
             Project: Groovy
          Issue Type: Improvement
            Reporter: Daniel Sun
            Assignee: Daniel Sun
             Fix For: 3.0.0-rc-2


We can use {{AstStringCompiler}} to construct AST in Java code, it will be 
especially useful when we want to implement {{ASTTransformation}} and generate 
complicated bytecode. For example,

{code:java}
AsmClassGenerator acg = controller.getAcg();

// Using text block in Java 13(preview)
new AstStringCompiler().compile("""
     if ('a' == x) {
          ...
     } else {
          ...
     }
""", CompilePhase.CONVERSION, true).get(0).visit(acg);
{code}

So we do not have to contruct AST with util methods of {{GeneralUtils}}  any 
more.





--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to