Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Groovy AST Demystified

Greach 2013 - Groovy AST Demystified

Groovy AST Demystified

  1. 1. Andres Almiray Canoo Engineering AGGroovy AST Demystified
  2. 2. 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
  3. 3. Agenda∗ AST, How did we get here?∗ AST Transformations∗ Building your own AST
  4. 4. AST,how did we get here?
  5. 5. AST Transformations
  6. 6. GE EV NI IL U S
  7. 7. Standard Groovy Distro includes:∗ @EqualsAndHashCode ∗ @AutoClone∗ @ToString ∗ @AutoExternalize∗ @TupleConstructor ∗ @Synchronized∗ @Canonical ∗ @Field∗ @InheritConstructors ∗ @Grab∗ @IndexedProperty ∗ @GrabResolver∗ @Lazy∗ @PackageScope ∗ @CompileStatic∗ @NotYetImplemented ∗ @TypeChecked
  8. 8. Standard Groovy Distro includes:∗ @Bindable ∗ @Log∗ @Vetoable ∗ @Slf4j∗ @ListenerList ∗ @Log4j∗ @ConditionalInterrupt ∗ @Commons∗ @ThreadInterrupt ∗ @Singleton∗ @TimedInterrupt ∗ @Immutable∗ @WithReadLock ∗ @Delegate∗ @WithWriteLock ∗ @Category∗ @Newify ∗ @Mixin
  9. 9. Groovy Ecosystem brings:∗ @ByteCode ∗ Griffon∗ @Scalify ∗ @EventPublisher∗ GContracts ∗ @Threading ∗ @Invariant ∗ @PropertyListener ∗ @Requires ∗ @MVCAware ∗ @Ensures ∗ @MessageSourceAware∗ Grails ∗ @ResourceResolverAwa ∗ @Entity re ∗ @ResourcesAware ∗ @TestFor ∗ @ThreadingAware
  10. 10. Global AST transformations∗ Groovy – Grab∗ Grails – GORM API∗ Griffon – Threading injection∗ Spock – the whole shebang
  11. 11. Building your own AST
  12. 12. Local AST Transformation1. Define an @interface ∗ Easy peasy … right?1. Define AST implementation ∗ huh ……1. Profit!
  13. 13. Global AST Transformation1. Add AST implementation entry to ∗ META- INF/services/org.codehaus.groovy.transform.ASTTra nsformation1. Define AST implementation ∗ ??? !!! ??? !!!1. Profit!
  14. 14. Additional Tools∗ AST browser∗ AST Builder
  15. 15. Thank You! @aalmirayandres.almiray@canoo.com

×