Message-ID: <1807351541.829.1430665059689.JavaMail.firstname.lastname@example.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_828_1686713363.1430665059688" ------=_Part_828_1686713363.1430665059688 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Although at times, it may sound like a good idea to extend the syntax of= Groovy to implement new features (like this is the case for instance for m= ultiple assignments), most of the time, we can't just add a new keyword to = the grammar, or create some new syntax construct to represent a new concept= . However, with the idea of AST (Abstract Syntax Tree) Transformations, we = are able to tackle new and innovative ideas without necessary grammar chang= es.
When the Groovy compiler compiles Groovy scripts and classes, at some po= int in the process, the source code will end up being represented in memory= in the form of a Concrete Syntax Tree, then transformed into an Abstract S= yntax Tree. The purpose of AST Transformations is to let developers hook in= to the compilation process to be able to modify the AST before it is turned= into bytecode that will be run by the JVM.
AST Transformations provides Groovy with improved compile-time m= etaprogramming capabilities allowing powerful flexibility at the l= anguage level, without a runtime performance penalty.
One hook for accessing this capability is via annotations. In your Groov= y code you can make use of one of more annotations to mark a class for rece= iving an AST transformation during compilation. Behind the scenes, an AST p= rocessor relevant to the annotation you are using is inserted into the comp= iler phases at the appropriate point.
There are a number of standard Annotations that cause AST transformation= s to be performed.
Grape also provides its own transf= ormation with @Grab.
There are two kinds of transformations: global and local transformations= .