Codegeneration With Xtend
Upcoming SlideShare
Loading in...5
×
 

Codegeneration With Xtend

on

  • 10,966 views

Why you should implement Code Generators with Xtend.

Why you should implement Code Generators with Xtend.

Statistics

Views

Total Views
10,966
Views on SlideShare
2,253
Embed Views
8,713

Actions

Likes
1
Downloads
21
Comments
0

17 Embeds 8,713

http://blog.efftinge.de 8657
http://www.feedly.com 14
http://cloud.feedly.com 13
https://twitter.com 6
http://webcache.googleusercontent.com 4
http://translate.googleusercontent.com 3
http://www.newsblur.com 2
http://feedly.com 2
http://10.70.168.173 2
http://www.directrss.co.il 2
http://127.0.0.1 2
http://prlog.ru 1
http://24248206_544fa2458144776076d4c27dece855f0d20f5cf1.blogspot.com 1
http://www.tubebox.us 1
http://www-ig-opensocial.googleusercontent.com 1
http://www.tuicool.com 1
http://blog.efftinge.de&_=1410949989741 HTTP 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Codegeneration With Xtend Codegeneration With Xtend Presentation Transcript

  • Code Generation withSven Efftinge - itemis
  • What is it?
  • Successor to XpandBuilt with
  • Why ?much faster (as fast as Java)much better IDE supportgeneralized set of featuressimpler
  • Code Generation Essentials
  • Template Expression(aka string concatenation)same syntax as in Xpandjust an expressiongreyspace support!
  • static typingsimply Javano pluggable type systemcan be emulated withactive annotations
  • longitude & latitude
  • higher-order functionsmap, filter, flatten, etc.it’s just library!
  • class TypeProviderExample { def getHourlyData() { data.weather.hourlys } def getTimeWithHighestSwell() { hourlyData.sortBy[swellheightM].head.time } def getAverageWindSpeed() { hourlyData.map[windspeedkmph].reduce[a,b|a+b] / hourlyData.size }}
  • dynamic dispatch
  • dynamic dispatch
  • dynamic dispatcheasily debuggable & extendable
  • dynamic dispatch def generate(ETypedElement e) { switch e { EAttribute : attribute EReference case e.isContainment: containment reference EReference : reference EOperation : operation default : throw new IllegalArgumentException("not handled : "+e) } }dispatch over type and statefirst comefirst serve
  • modularization
  • AOP?
  • Dependency Injection!
  • class MainGenerator { @Inject extension EcoreGen ecoreGenerator def doGenerate(EClass it) class «name» { «FOR f : EStructuralFeatures» «f.generate» «ENDFOR» } }class EcoreGen { def dispatch generate(EAttribute attribute) generate attribute def dispatch generate(EReference reference) generate reference def dispatch generate(EOperation operation) generate operation }declare the dependency
  • class MySpecialEcoreGen extends EcoreGen { override dispatch generate(EAttribute attribute) special EAttribute def dispatch generate(EParameter param) parameter }class CustomizedGenerator { def static void main(String[] args) { val injector = Guice::createInjector [ bind(typeof(EcoreGen)).to(typeof(MySpecialEcoreGen)) ] val mainGenerator = injector.getInstance(typeof(MainGenerator)) mainGenerator.doGenerate(EcorePackage::eINSTANCE.EClass) }}Extend the class you want to modifyUse Guice to wire up the generator
  • content assistsyntax coloringquick assist outlinerename refactoringformatingcall hierarchytype hierarchyextract methoddebuggingetc...IDE Support
  • But why always a DSL?
  • MyBeanString valueclass
  • MyBeanString valueclass {}@Observable
  • future worktooling via librarymore macro supportembedded languagessnappiness!
  • Thank you!@svenefftinge / @xtext / @xtendlang (c) 2013 by