The Builders and Sortable AST do something similar and use:
https://github.com/apache/groovy/blob/master/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java#L129


On Mon, Apr 12, 2021 at 8:36 PM Saravanan Palanichamy <[email protected]>
wrote:

> Hello
>
> What is the right way to add a new class through an AST during the Groovy
> compilation phase? What I am trying to do is this
>
> * Compile N different classes
> * During the compile process, create a new class for each of these N
> classes that denotes how it should be serialized (for example)
> * Add these classes as sub classes of one master class, called Types
>
> For example:-
>
> /**************** These are my classes ****************************/
> Class Car {
> }
>
> class Cycle {
> }
>
>
> /***************** This class must be auto generated with all of its inner
> classes ***************/
> class Types {
>     static class CarSeralizer extends TypeReference<Car> {}
>
>     static class CycleSerializer extends TypeReference<Cycle> {}
> }
>
> How do I achieve this through ASTs ?
>
> regards
> Saravanan
>

Reply via email to