SlideShare a Scribd company logo
1 of 36
What’s new in Groovy & Grails Support?
DSL Support in Groovy-Eclipse
Andrew Eisenberg, SpringSource Tools Team




                                            © 2011 SpringSource, A division of VMware. All rights reserved
What’s new in Groovy & Grails Support?

Part 1




                                 © 2011 SpringSource, A division of VMware. All rights reserved
New Groovy-Eclipse Support in 2.5.0

  DSL Descriptors (discussed later)
  Groovy 1.8
  Parameter guessing content assist
  Script outline view
  Distinguish read vs. write access in search
  Conditional breakpoints in Groovy files (STS only)




                                                        3
New Grails tooling support in STS 2.7.0.M1

  Service field content assist
  Groovy search results in GSPs




                                             4
Gradle support in STS

Part 1.5




                        © 2011 SpringSource, A division of VMware. All rights reserved
First cut at Gradle support now available in STS

  Demoed this morning in the Gradle talk
  Yay!




                                                   6
DSL Support in Groovy-Eclipse

Part 2




                                © 2011 SpringSource, A division of VMware. All rights reserved
The Problem




              8
A DSL for distance calculations




                  3.m + 2.yd + 2.mi - 1.km
       In the Groovy editor:




                                  Uh oh!


      Can we do better???
                                             9
The Solution:
DSL Descriptors (DSLDs)




                          10
DSL Descriptors

  Teach the IDE about DSLs through scripting




                               CONFIDENTIAL     11
DSL Descriptors

  In English:
  •  “Any subtype of Number should have the following properties: m, yd, mi, km”
  In DSLD:
  •  “Any subtype of Number”:
      currentType( subType( Number ) )!
  •  “…the following properties…”:
       [ “m”, “yd”, “cm”, “mi”, “km” ].each {!
            property name:it, type:"Distance”!
       }!




               3.m + 2.yd + 2.mi - 1.km

                                                                                   12
Let’s see that

  Ex 1: Distances




                     13
Anatomy of a DSLD file




                         14
DSLD and the Inferencing Engine
  Hooks into Groovy-Eclipse’s type inferencing engine
 •  Visit each expression AST node
 •  Determine type using previous expression
 •  Move to next expression
  DSLD operates on Groovy AST Expression nodes
 •  Exposes Groovy AST nodes and uses Groovy API
  In the background, while typing (reconciling)
              org.codehaus.groovy.ast.expr.Expression!




                                                         15
Pointcuts and Contribution blocks
  Pointcuts:
  •  Where to do it.
  •  What is the current expression?
  •  Declaring type?                             class Other {!
  •  Enclosing class?                               def x!
                                                 }!
  Contribution blocks:                          class Foo {!
  •  What to do                                     def method() {!
  •  “Add” method                                      new Other().x!
  •  “Add” property                                 }!
                                                 }!
       •  (not at runtime, in the editor only)




                                                                        16
What goes in a Contribution Block?

  property : “adds” a property                  (…).accept {!
 •  arguments                                       property name: “myName”!
   •  name: “blarb”                                 method name: “getMyName”!
                                                 }!
   •  type: “java.lang.String”
   •  declaringType :”com.foo.Frumble”
   •  isStatic: false
   •  doc: “Some html”
   •  provider: “My DSL”
  method : “adds” a method
 •  all arguments above, and
   •  params: [firstName:“java.lang.String”, lastName:“java.lang.String”]
   •  useNamedArgs: true


  name is required, others optional

                                                                            17
Pointcuts

  currentType() : Matches on the current declaring type
  enclosingClass() : Matches on the enclosing class
  currentType(“com.bar.Foo”)
  methods(“run”)
  annotatedBy(“org.junit.runner.RunWith”)
  enclosingClass(
  annotatedBy(“org.junit.runner.RunWith”) ) &
 currentType(methods(“run”) )




                                                           18
Where does this pointcut match? What does it add?
(enclosingClass(annotatedBy(“org.junit.runner.RunWith”)) & 

currentType(methods(“run”))).accept { property name:”blarb” }!

                                       Looking for an expression that:
@RunWith(Sumthin) !
class Foo {!
   def someTest() {!                         enclosed by
                                             @RunWith
      print “Hello”!
      def x = new MyRunner()!
      x.blarb!                                          has run method
   }!
                                                blarb
}!
 class MyRunner { def run() {…} }!




                                                                    19
Wait…isn’t this Aspect-Oriented Programming?

  Pointcut
  •  Intentionally borrowed from AOP
  AspectJ: pointcuts and advice
  •  operates on Java instructions at runtime
                                                               class Foo {!
  DSLD: pointcuts and contribution blocks                       def x = {!
  •  operates on AST                                               def i = 0!
   org.codehaus.groovy.ast.expr.*!
  Join Point Model                                                      i++!
                                                                    }!
  •  Join points (e.g., instructions, expressions)
                                                               }!
  •  Mechanism for quantifying join points (e.g., pointcuts)
  •  Means of affect at a join point (e.g., advice,
   contribution blocks)




                                                                                20
Other things to help with DSLDs




                                  21
New DSLD Wizard

  File  New  Groovy DSL Descriptor




                                        22
DSLD Preferences Page




                        23
Groovy Event Console

  Keep this open while implementing DSLDs:
 •  Shows exceptions
 •  Pointcuts
 •  Matches




  Find the Console here:




                                              24
Groovy AST Viewer

  Exploration of AST of current Groovy file




                                               25
Examples




           26
Basic Script
Ex 2: Using the DSLD wizard




                              27
Meta DSL
Ex 3: DSLD script for editing DSLDs




                                      28
AST Transforms
Ex 3: Standard AST Transforms




                                29
SwingBuilder
Ex 4: Long script, but simple to understand




                                              30
Grails Constraints DSL
Ex 5: encapsulate Grails domain knowledge in a script




                                                        31
Criteria Queries
Ex 6: simple script, large effect




                                    32
Griffon
Ex 7: from last night




                        33
What’s next?




               34
DSLD is not complete

  Guided by user feedback
  Collaboration with library developers
 •  Grails, Gaelyk, Griffon, etc.
  Release standard DSLDs (AST Transforms, Builders, etc.)
 •  With Groovy-Eclipse?
 •  With Groovy core?
  More pointcuts
 •  What do users need that isn’t implemented?
 •  regex(), instanceof(), superType(), enclosingEnum(), etc.
  What about IntelliJ’s GDSL?




                                                                35
Thanks!

  More information:
  •  Google: groovy eclipse dsld
  Full documentation on Codehaus.org:
  •  http://docs.codehaus.org/display/GROOVY/DSL+Descriptors+for+Groovy-Eclipse
  Install from update site:
  •  http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/
  Mailing list:
  •  eclipse-plugin-users@codehaus.org
  Or chat with me whenever




                                                                                  36

More Related Content

What's hot

Metaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And GrailsMetaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And GrailszenMonkey
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy PluginsPaul King
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGuillaume Laforge
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!Iván López Martín
 
Embedding Groovy in a Java Application
Embedding Groovy in a Java ApplicationEmbedding Groovy in a Java Application
Embedding Groovy in a Java ApplicationPaolo Predonzani
 
Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Guillaume Laforge
 
Groovy Grails DevJam Jam Session
Groovy Grails DevJam Jam SessionGroovy Grails DevJam Jam Session
Groovy Grails DevJam Jam SessionMike Hugo
 
Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To GrailsEric Berry
 
tictactoe groovy
tictactoe groovytictactoe groovy
tictactoe groovyPaul King
 
Gradle in a Polyglot World
Gradle in a Polyglot WorldGradle in a Polyglot World
Gradle in a Polyglot WorldSchalk Cronjé
 
groovy transforms
groovy transformsgroovy transforms
groovy transformsPaul King
 
Little Helpers for Android Development with Kotlin
Little Helpers for Android Development with KotlinLittle Helpers for Android Development with Kotlin
Little Helpers for Android Development with KotlinKai Koenig
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Guillaume Laforge
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеSergey Platonov
 
Greach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyGreach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyIván López Martín
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoRodolfo Carvalho
 
Introduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transformsIntroduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transformsMarcin Grzejszczak
 

What's hot (20)

Metaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And GrailsMetaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And Grails
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy Plugins
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!
 
Embedding Groovy in a Java Application
Embedding Groovy in a Java ApplicationEmbedding Groovy in a Java Application
Embedding Groovy in a Java Application
 
Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013
 
Groovy Grails DevJam Jam Session
Groovy Grails DevJam Jam SessionGroovy Grails DevJam Jam Session
Groovy Grails DevJam Jam Session
 
Groovy 2.0 webinar
Groovy 2.0 webinarGroovy 2.0 webinar
Groovy 2.0 webinar
 
Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To Grails
 
tictactoe groovy
tictactoe groovytictactoe groovy
tictactoe groovy
 
OpenLogic
OpenLogicOpenLogic
OpenLogic
 
Gradle in a Polyglot World
Gradle in a Polyglot WorldGradle in a Polyglot World
Gradle in a Polyglot World
 
groovy transforms
groovy transformsgroovy transforms
groovy transforms
 
Little Helpers for Android Development with Kotlin
Little Helpers for Android Development with KotlinLittle Helpers for Android Development with Kotlin
Little Helpers for Android Development with Kotlin
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI веке
 
Greach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyGreach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovy
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
 
Introduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transformsIntroduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transforms
 

Similar to New in Groovy & Grails Support

Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easyroialdaag
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part IIEugene Lazutkin
 
Dojo for programmers (TXJS 2010)
Dojo for programmers (TXJS 2010)Dojo for programmers (TXJS 2010)
Dojo for programmers (TXJS 2010)Eugene Lazutkin
 
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...AboutYouGmbH
 
Dojo GFX workshop slides
Dojo GFX workshop slidesDojo GFX workshop slides
Dojo GFX workshop slidesEugene Lazutkin
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)JiandSon
 
DSL's with Groovy
DSL's with GroovyDSL's with Groovy
DSL's with Groovypaulbowler
 
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...David Beazley (Dabeaz LLC)
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdbWei-Bo Chen
 
Simple Ruby DSL Techniques: Big Project Impact!
Simple Ruby DSL Techniques: Big Project Impact!Simple Ruby DSL Techniques: Big Project Impact!
Simple Ruby DSL Techniques: Big Project Impact!Aman King
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overviewJesse Warden
 
Javaone2008 Bof 5102 Groovybuilders
Javaone2008 Bof 5102 GroovybuildersJavaone2008 Bof 5102 Groovybuilders
Javaone2008 Bof 5102 GroovybuildersAndres Almiray
 
Go Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGo Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGlobalLogic Ukraine
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!Alessandro Giorgetti
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0Michael Vorburger
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Vitaly Baum
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring ClojurescriptLuke Donnet
 
The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185Mahmoud Samir Fayed
 

Similar to New in Groovy & Grails Support (20)

Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easy
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part II
 
Dojo for programmers (TXJS 2010)
Dojo for programmers (TXJS 2010)Dojo for programmers (TXJS 2010)
Dojo for programmers (TXJS 2010)
 
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
 
Dojo GFX workshop slides
Dojo GFX workshop slidesDojo GFX workshop slides
Dojo GFX workshop slides
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
Pulsar
PulsarPulsar
Pulsar
 
DSL's with Groovy
DSL's with GroovyDSL's with Groovy
DSL's with Groovy
 
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdb
 
Simple Ruby DSL Techniques: Big Project Impact!
Simple Ruby DSL Techniques: Big Project Impact!Simple Ruby DSL Techniques: Big Project Impact!
Simple Ruby DSL Techniques: Big Project Impact!
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
 
Javaone2008 Bof 5102 Groovybuilders
Javaone2008 Bof 5102 GroovybuildersJavaone2008 Bof 5102 Groovybuilders
Javaone2008 Bof 5102 Groovybuilders
 
Go Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii ShapovalGo Is Your Next Language — Sergii Shapoval
Go Is Your Next Language — Sergii Shapoval
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
cadec-2017-golang
cadec-2017-golangcadec-2017-golang
cadec-2017-golang
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185
 

More from GR8Conf

DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your TeamGR8Conf
 
Creating and testing REST contracts with Accurest Gradle
Creating and testing REST contracts with Accurest Gradle Creating and testing REST contracts with Accurest Gradle
Creating and testing REST contracts with Accurest Gradle GR8Conf
 
Mum, I want to be a Groovy full-stack developer
Mum, I want to be a Groovy full-stack developerMum, I want to be a Groovy full-stack developer
Mum, I want to be a Groovy full-stack developerGR8Conf
 
Metaprogramming with Groovy
Metaprogramming with GroovyMetaprogramming with Groovy
Metaprogramming with GroovyGR8Conf
 
Scraping with Geb
Scraping with GebScraping with Geb
Scraping with GebGR8Conf
 
How to create a conference android app with Groovy and Android
How to create a conference android app with Groovy and AndroidHow to create a conference android app with Groovy and Android
How to create a conference android app with Groovy and AndroidGR8Conf
 
Ratpack On the Docks
Ratpack On the DocksRatpack On the Docks
Ratpack On the DocksGR8Conf
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean CodeGR8Conf
 
Cut your Grails application to pieces - build feature plugins
Cut your Grails application to pieces - build feature pluginsCut your Grails application to pieces - build feature plugins
Cut your Grails application to pieces - build feature pluginsGR8Conf
 
Performance tuning Grails applications
 Performance tuning Grails applications Performance tuning Grails applications
Performance tuning Grails applicationsGR8Conf
 
Ratpack and Grails 3
 Ratpack and Grails 3 Ratpack and Grails 3
Ratpack and Grails 3GR8Conf
 
Grails & DevOps: continuous integration and delivery in the cloud
Grails & DevOps: continuous integration and delivery in the cloudGrails & DevOps: continuous integration and delivery in the cloud
Grails & DevOps: continuous integration and delivery in the cloudGR8Conf
 
Functional testing your Grails app with GEB
Functional testing your Grails app with GEBFunctional testing your Grails app with GEB
Functional testing your Grails app with GEBGR8Conf
 
Deploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPCDeploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPCGR8Conf
 
The Grails introduction workshop
The Grails introduction workshopThe Grails introduction workshop
The Grails introduction workshopGR8Conf
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spockGR8Conf
 
The Groovy Ecosystem Revisited
The Groovy Ecosystem RevisitedThe Groovy Ecosystem Revisited
The Groovy Ecosystem RevisitedGR8Conf
 
Groovy 3 and the new Groovy Meta Object Protocol in examples
Groovy 3 and the new Groovy Meta Object Protocol in examplesGroovy 3 and the new Groovy Meta Object Protocol in examples
Groovy 3 and the new Groovy Meta Object Protocol in examplesGR8Conf
 
Integration using Apache Camel and Groovy
Integration using Apache Camel and GroovyIntegration using Apache Camel and Groovy
Integration using Apache Camel and GroovyGR8Conf
 
CRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual MachineCRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual MachineGR8Conf
 

More from GR8Conf (20)

DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your Team
 
Creating and testing REST contracts with Accurest Gradle
Creating and testing REST contracts with Accurest Gradle Creating and testing REST contracts with Accurest Gradle
Creating and testing REST contracts with Accurest Gradle
 
Mum, I want to be a Groovy full-stack developer
Mum, I want to be a Groovy full-stack developerMum, I want to be a Groovy full-stack developer
Mum, I want to be a Groovy full-stack developer
 
Metaprogramming with Groovy
Metaprogramming with GroovyMetaprogramming with Groovy
Metaprogramming with Groovy
 
Scraping with Geb
Scraping with GebScraping with Geb
Scraping with Geb
 
How to create a conference android app with Groovy and Android
How to create a conference android app with Groovy and AndroidHow to create a conference android app with Groovy and Android
How to create a conference android app with Groovy and Android
 
Ratpack On the Docks
Ratpack On the DocksRatpack On the Docks
Ratpack On the Docks
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean Code
 
Cut your Grails application to pieces - build feature plugins
Cut your Grails application to pieces - build feature pluginsCut your Grails application to pieces - build feature plugins
Cut your Grails application to pieces - build feature plugins
 
Performance tuning Grails applications
 Performance tuning Grails applications Performance tuning Grails applications
Performance tuning Grails applications
 
Ratpack and Grails 3
 Ratpack and Grails 3 Ratpack and Grails 3
Ratpack and Grails 3
 
Grails & DevOps: continuous integration and delivery in the cloud
Grails & DevOps: continuous integration and delivery in the cloudGrails & DevOps: continuous integration and delivery in the cloud
Grails & DevOps: continuous integration and delivery in the cloud
 
Functional testing your Grails app with GEB
Functional testing your Grails app with GEBFunctional testing your Grails app with GEB
Functional testing your Grails app with GEB
 
Deploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPCDeploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPC
 
The Grails introduction workshop
The Grails introduction workshopThe Grails introduction workshop
The Grails introduction workshop
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spock
 
The Groovy Ecosystem Revisited
The Groovy Ecosystem RevisitedThe Groovy Ecosystem Revisited
The Groovy Ecosystem Revisited
 
Groovy 3 and the new Groovy Meta Object Protocol in examples
Groovy 3 and the new Groovy Meta Object Protocol in examplesGroovy 3 and the new Groovy Meta Object Protocol in examples
Groovy 3 and the new Groovy Meta Object Protocol in examples
 
Integration using Apache Camel and Groovy
Integration using Apache Camel and GroovyIntegration using Apache Camel and Groovy
Integration using Apache Camel and Groovy
 
CRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual MachineCRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual Machine
 

Recently uploaded

Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 

New in Groovy & Grails Support

  • 1. What’s new in Groovy & Grails Support? DSL Support in Groovy-Eclipse Andrew Eisenberg, SpringSource Tools Team © 2011 SpringSource, A division of VMware. All rights reserved
  • 2. What’s new in Groovy & Grails Support? Part 1 © 2011 SpringSource, A division of VMware. All rights reserved
  • 3. New Groovy-Eclipse Support in 2.5.0   DSL Descriptors (discussed later)   Groovy 1.8   Parameter guessing content assist   Script outline view   Distinguish read vs. write access in search   Conditional breakpoints in Groovy files (STS only) 3
  • 4. New Grails tooling support in STS 2.7.0.M1   Service field content assist   Groovy search results in GSPs 4
  • 5. Gradle support in STS Part 1.5 © 2011 SpringSource, A division of VMware. All rights reserved
  • 6. First cut at Gradle support now available in STS   Demoed this morning in the Gradle talk   Yay! 6
  • 7. DSL Support in Groovy-Eclipse Part 2 © 2011 SpringSource, A division of VMware. All rights reserved
  • 9. A DSL for distance calculations 3.m + 2.yd + 2.mi - 1.km In the Groovy editor: Uh oh! Can we do better??? 9
  • 11. DSL Descriptors   Teach the IDE about DSLs through scripting CONFIDENTIAL 11
  • 12. DSL Descriptors   In English: •  “Any subtype of Number should have the following properties: m, yd, mi, km”   In DSLD: •  “Any subtype of Number”: currentType( subType( Number ) )! •  “…the following properties…”: [ “m”, “yd”, “cm”, “mi”, “km” ].each {! property name:it, type:"Distance”! }! 3.m + 2.yd + 2.mi - 1.km 12
  • 13. Let’s see that   Ex 1: Distances 13
  • 14. Anatomy of a DSLD file 14
  • 15. DSLD and the Inferencing Engine   Hooks into Groovy-Eclipse’s type inferencing engine •  Visit each expression AST node •  Determine type using previous expression •  Move to next expression   DSLD operates on Groovy AST Expression nodes •  Exposes Groovy AST nodes and uses Groovy API   In the background, while typing (reconciling) org.codehaus.groovy.ast.expr.Expression! 15
  • 16. Pointcuts and Contribution blocks   Pointcuts: •  Where to do it. •  What is the current expression? •  Declaring type? class Other {! •  Enclosing class? def x! }!   Contribution blocks: class Foo {! •  What to do def method() {! •  “Add” method new Other().x! •  “Add” property }! }! •  (not at runtime, in the editor only) 16
  • 17. What goes in a Contribution Block?   property : “adds” a property (…).accept {! •  arguments property name: “myName”! •  name: “blarb” method name: “getMyName”! }! •  type: “java.lang.String” •  declaringType :”com.foo.Frumble” •  isStatic: false •  doc: “Some html” •  provider: “My DSL”   method : “adds” a method •  all arguments above, and •  params: [firstName:“java.lang.String”, lastName:“java.lang.String”] •  useNamedArgs: true   name is required, others optional 17
  • 18. Pointcuts   currentType() : Matches on the current declaring type   enclosingClass() : Matches on the enclosing class   currentType(“com.bar.Foo”)   methods(“run”)   annotatedBy(“org.junit.runner.RunWith”)   enclosingClass( annotatedBy(“org.junit.runner.RunWith”) ) & currentType(methods(“run”) ) 18
  • 19. Where does this pointcut match? What does it add? (enclosingClass(annotatedBy(“org.junit.runner.RunWith”)) & 
 currentType(methods(“run”))).accept { property name:”blarb” }! Looking for an expression that: @RunWith(Sumthin) ! class Foo {! def someTest() {! enclosed by @RunWith print “Hello”! def x = new MyRunner()! x.blarb! has run method }! blarb }! class MyRunner { def run() {…} }! 19
  • 20. Wait…isn’t this Aspect-Oriented Programming?   Pointcut •  Intentionally borrowed from AOP   AspectJ: pointcuts and advice •  operates on Java instructions at runtime class Foo {!   DSLD: pointcuts and contribution blocks def x = {! •  operates on AST def i = 0! org.codehaus.groovy.ast.expr.*!   Join Point Model i++! }! •  Join points (e.g., instructions, expressions) }! •  Mechanism for quantifying join points (e.g., pointcuts) •  Means of affect at a join point (e.g., advice, contribution blocks) 20
  • 21. Other things to help with DSLDs 21
  • 22. New DSLD Wizard   File  New  Groovy DSL Descriptor 22
  • 24. Groovy Event Console   Keep this open while implementing DSLDs: •  Shows exceptions •  Pointcuts •  Matches   Find the Console here: 24
  • 25. Groovy AST Viewer   Exploration of AST of current Groovy file 25
  • 26. Examples 26
  • 27. Basic Script Ex 2: Using the DSLD wizard 27
  • 28. Meta DSL Ex 3: DSLD script for editing DSLDs 28
  • 29. AST Transforms Ex 3: Standard AST Transforms 29
  • 30. SwingBuilder Ex 4: Long script, but simple to understand 30
  • 31. Grails Constraints DSL Ex 5: encapsulate Grails domain knowledge in a script 31
  • 32. Criteria Queries Ex 6: simple script, large effect 32
  • 33. Griffon Ex 7: from last night 33
  • 35. DSLD is not complete   Guided by user feedback   Collaboration with library developers •  Grails, Gaelyk, Griffon, etc.   Release standard DSLDs (AST Transforms, Builders, etc.) •  With Groovy-Eclipse? •  With Groovy core?   More pointcuts •  What do users need that isn’t implemented? •  regex(), instanceof(), superType(), enclosingEnum(), etc.   What about IntelliJ’s GDSL? 35
  • 36. Thanks!   More information: •  Google: groovy eclipse dsld   Full documentation on Codehaus.org: •  http://docs.codehaus.org/display/GROOVY/DSL+Descriptors+for+Groovy-Eclipse   Install from update site: •  http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/   Mailing list: •  eclipse-plugin-users@codehaus.org   Or chat with me whenever 36