Groovy AST Demystified

Preview:

Citation preview

Groovy AST DemystifiedAndres Almiray

Canoo Engineering AG

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

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

Agenda

AST, how did we get here?

AST Transformations

EVIL

GENIUS

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 @ResourceResolverAw

are @ResourcesAware @ThreadingAware

Groovy – Grab

Grails – GORM API

Griffon – Threading injection

Spock – the whole shebang

Global AST transformations

Building your own AST

1. Define an @interface Easy peasy … right?

2. Define AST implementation huh ……

3. Profit!

Local AST Transformation

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

org.codehaus.groovy.transform.ASTTransformation

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

3. Profit!

Global AST Transformation

AST browser AST Builder

Additional Tools

Thank You!@aalmiray

andres.almiray@canoo.com

Recommended