41
Groovy AST Demystified Andres Almiray Canoo Engineering AG

Groovy AST Demystified

Embed Size (px)

Citation preview

Page 1: Groovy AST Demystified

Groovy AST DemystifiedAndres Almiray

Canoo Engineering AG

Page 2: Groovy AST Demystified

Java developer since the beginning True believer in Open Source Groovy committer since 2007 Project lead of the Griffon framework Currently working for

About the Speaker

Page 3: Groovy AST Demystified

AST, How did we get here? AST Transformations Building your own AST

Agenda

Page 4: Groovy AST Demystified

AST, how did we get here?

Page 5: Groovy AST Demystified
Page 6: Groovy AST Demystified
Page 7: Groovy AST Demystified
Page 8: Groovy AST Demystified
Page 9: Groovy AST Demystified
Page 10: Groovy AST Demystified
Page 11: Groovy AST Demystified

AST Transformations

Page 12: Groovy AST Demystified

EVIL

GENIUS

Page 13: Groovy AST Demystified
Page 14: Groovy AST Demystified
Page 15: Groovy AST Demystified
Page 16: Groovy AST Demystified

Standard Groovy Distro includes:

@EqualsAndHashCode @ToString @TupleConstructor @Canonical @InheritConstructors @IndexedProperty @Lazy @PackageScope @NotYetImplemented

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

Page 17: Groovy AST Demystified

Standard Groovy Distro includes:

@Bindable @Vetoable @ListenerList @ConditionalInterrupt @ThreadInterrupt @TimedInterrupt @WithReadLock @WithWriteLock @Newify

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

Page 18: Groovy AST Demystified

Groovy Ecosystem brings:

@ByteCode @Scalify GContracts

@Invariant @Requires @Ensures

Grails @Entity @TestFor

Griffon @EventPublisher @Threading @PropertyListener @MVCAware @MessageSourceAware @ResourceResolverAw

are @ResourcesAware @ThreadingAware

Page 19: Groovy AST Demystified

Groovy – Grab

Grails – GORM API

Griffon – Threading injection

Spock – the whole shebang

Global AST transformations

Page 20: Groovy AST Demystified

Building your own AST

Page 21: Groovy AST Demystified
Page 22: Groovy AST Demystified

1. Define an @interface Easy peasy … right?

2. Define AST implementation huh ……

3. Profit!

Local AST Transformation

Page 23: Groovy AST Demystified

1. Add AST implementation entry to META-INF/services/

org.codehaus.groovy.transform.ASTTransformation

2. Define AST implementation ??? !!! ??? !!!

3. Profit!

Global AST Transformation

Page 24: Groovy AST Demystified
Page 25: Groovy AST Demystified
Page 26: Groovy AST Demystified
Page 27: Groovy AST Demystified
Page 28: Groovy AST Demystified
Page 29: Groovy AST Demystified
Page 30: Groovy AST Demystified
Page 31: Groovy AST Demystified
Page 32: Groovy AST Demystified
Page 33: Groovy AST Demystified
Page 34: Groovy AST Demystified

AST browser AST Builder

Additional Tools

Page 35: Groovy AST Demystified
Page 36: Groovy AST Demystified
Page 37: Groovy AST Demystified
Page 38: Groovy AST Demystified
Page 39: Groovy AST Demystified
Page 40: Groovy AST Demystified
Page 41: Groovy AST Demystified

Thank You!@aalmiray

[email protected]