Groovy AST Demyistified - 33degree
-
Upload
andres-almiray -
Category
Technology
-
view
1.409 -
download
2
Transcript of Groovy AST Demyistified - 33degree
Groovy AST Demystified
Andres Almiray @aalmiray
ABOUT THE SPEAKER Java developer since the beginning
True believer in Open Source
Groovy committer since 2007
Project lead of the Griffon framework
Currently working for
AGENDA AST, How did we get here?
AST Transformations
Building your own AST
AST, HOW DID WE GET HERE?
AST TRANSFORMATIONS
E V I L
G E N I U S
STANDARD GROOVY DISTRO INCLUDES: * @EqualsAndHashCode * @ToString * @TupleConstructor * @Canonical * @InheritConstructors * @IndexedProperty * @Lazy * @PackageScope * @NotYetImplemented
* @AutoClone * @AutoExternalize * @Synchronized * @Field * @Grab * @GrabResolver * @CompileStatic * @TypeChecked
STANDARD GROOVY DISTRO INCLUDES: * @Bindable * @Vetoable * @ListenerList * @ConditionalInterrupt * @ThreadInterrupt * @TimedInterrupt * @WithReadLock * @WithWriteLock * @Newify
* @Log * @Slf4j * @Log4j * @Commons * @Singleton * @Immutable * @Delegate * @Category * @Mixin
GROOVY ECOSYSTEM BRINGS: * @ByteCode * @Scalify * GContracts * @Invariant * @Requires * @Ensures * Grails * @Entity * @TestFor
* Griffon * @EventPublisher * @Threading * @PropertyListener * @MVCAware * @MessageSourceAware * @ResourceResolverAware * @ResourcesAware * @ThreadingAware
GLOBAL AST TRANSFORMATIONS Groovy – Grab
Grails – GORM API
Griffon – Threading injection
Spock – the whole shebang
BUILDING YOUR OWN AST
LOCAL AST TRANSFORMATION 1. Define an @interface
• Easy peasy … right? 2. Define AST implementation
• huh …… 3. Profit!
GLOBAL AST TRANSFORMATION 1. Add AST implementation entry to
• META-INF/services/org.codehaus.groovy.transform.ASTTransformation
2. Define AST implementation
• ??? !!! ??? !!! 3. Profit!
ADDITIONAL TOOLS AST browser
AST Builder
Thank You! @aalmiray