Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added headings to sections

...

Generally speaking, there is more type information available later in the phases. If your transformation is concerned with reading the AST, then a later phase where information is more plentiful might be a good choice. If your transformation is concerned with writing AST, then an earlier phase where the tree is more sparse might be more convenient.

Static Property Transformations

As a particular example, Groovy aggressively and statically types the static properties of a class, as demonstrated here:

...

So if you want to create an AST transform that creates a static property, you have to hook in before this check is performed: in practice, this means the Conversion phase (Semantic Analysis is where you get busted).  In using a phase that early, though, most types won't be resolved, and so insofar as type resolution is significant (e.g. in checking for annotations of a particular class), it will have to be hand-rolled.

Further Information

To learn more about what AST is produced in each phase, you can use the AST viewer in Groovy console to explore the output in different phases.