groovy ast demystified

Post on 15-Apr-2017

1.701 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Groovy AST Demystified

Andres Almiray Canoo Engineering AG

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.  Define AST implementation ¡  ??? !!! ??? !!!

2.  Add AST implementation entry to ¡  META-INF/services/

org.codehaus.groovy.transform.ASTTransformation

3.  Profit!

Additional Tools ¡ AST browser

¡ AST Builder

Thank You! @aalmiray

andres.almiray@canoo.com

top related