Groovy AST Demyistified - 33degree

45
Groovy AST Demystified Andres Almiray @aalmiray

Transcript of Groovy AST Demyistified - 33degree

Page 1: Groovy AST Demyistified - 33degree

Groovy AST Demystified

Andres  Almiray  @aalmiray  

Page 2: Groovy AST Demyistified - 33degree

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

Page 3: Groovy AST Demyistified - 33degree

AGENDA AST, How did we get here?

AST Transformations

Building your own AST

Page 4: Groovy AST Demyistified - 33degree

AST, HOW DID WE GET HERE?

Page 5: Groovy AST Demyistified - 33degree
Page 6: Groovy AST Demyistified - 33degree
Page 7: Groovy AST Demyistified - 33degree
Page 8: Groovy AST Demyistified - 33degree
Page 9: Groovy AST Demyistified - 33degree
Page 10: Groovy AST Demyistified - 33degree
Page 11: Groovy AST Demyistified - 33degree

AST TRANSFORMATIONS

Page 12: Groovy AST Demyistified - 33degree

E V I L

G E N I U S

Page 13: Groovy AST Demyistified - 33degree
Page 14: Groovy AST Demyistified - 33degree
Page 15: Groovy AST Demyistified - 33degree
Page 16: Groovy AST Demyistified - 33degree
Page 17: Groovy AST Demyistified - 33degree

STANDARD GROOVY DISTRO INCLUDES: *  @EqualsAndHashCode *  @ToString *  @TupleConstructor *  @Canonical *  @InheritConstructors *  @IndexedProperty *  @Lazy *  @PackageScope *  @NotYetImplemented

*  @AutoClone *  @AutoExternalize *  @Synchronized *  @Field *  @Grab *  @GrabResolver *  @CompileStatic *  @TypeChecked

Page 18: Groovy AST Demyistified - 33degree

STANDARD GROOVY DISTRO INCLUDES: *  @Bindable *  @Vetoable *  @ListenerList *  @ConditionalInterrupt *  @ThreadInterrupt *  @TimedInterrupt *  @WithReadLock *  @WithWriteLock *  @Newify

*  @Log *  @Slf4j *  @Log4j *  @Commons *  @Singleton *  @Immutable *  @Delegate *  @Category *  @Mixin

Page 19: Groovy AST Demyistified - 33degree

GROOVY ECOSYSTEM BRINGS: *  @ByteCode *  @Scalify *  GContracts *  @Invariant *  @Requires *  @Ensures *  Grails *  @Entity *  @TestFor

*  Griffon *  @EventPublisher *  @Threading *  @PropertyListener *  @MVCAware *  @MessageSourceAware *  @ResourceResolverAware *  @ResourcesAware *  @ThreadingAware

Page 20: Groovy AST Demyistified - 33degree

GLOBAL AST TRANSFORMATIONS Groovy – Grab

Grails – GORM API

Griffon – Threading injection

Spock – the whole shebang

Page 21: Groovy AST Demyistified - 33degree

BUILDING YOUR OWN AST

Page 22: Groovy AST Demyistified - 33degree
Page 23: Groovy AST Demyistified - 33degree

LOCAL AST TRANSFORMATION 1.  Define an @interface

•  Easy peasy … right? 2.  Define AST implementation

•  huh …… 3.  Profit!

Page 24: Groovy AST Demyistified - 33degree

GLOBAL AST TRANSFORMATION 1.  Add AST implementation entry to

• META-INF/services/org.codehaus.groovy.transform.ASTTransformation

2.  Define AST implementation

•  ??? !!! ??? !!! 3.  Profit!

Page 25: Groovy AST Demyistified - 33degree
Page 26: Groovy AST Demyistified - 33degree
Page 27: Groovy AST Demyistified - 33degree
Page 28: Groovy AST Demyistified - 33degree
Page 29: Groovy AST Demyistified - 33degree
Page 30: Groovy AST Demyistified - 33degree
Page 31: Groovy AST Demyistified - 33degree
Page 32: Groovy AST Demyistified - 33degree
Page 33: Groovy AST Demyistified - 33degree
Page 34: Groovy AST Demyistified - 33degree
Page 35: Groovy AST Demyistified - 33degree
Page 36: Groovy AST Demyistified - 33degree

ADDITIONAL TOOLS AST browser

AST Builder

Page 37: Groovy AST Demyistified - 33degree
Page 38: Groovy AST Demyistified - 33degree
Page 39: Groovy AST Demyistified - 33degree
Page 40: Groovy AST Demyistified - 33degree
Page 41: Groovy AST Demyistified - 33degree
Page 42: Groovy AST Demyistified - 33degree
Page 43: Groovy AST Demyistified - 33degree
Page 44: Groovy AST Demyistified - 33degree
Page 45: Groovy AST Demyistified - 33degree

Thank You! @aalmiray

[email protected]