Code generation with Xtend provides faster and better supported code generation compared to Xpand. It uses templates with expressions for concatenating strings. Types are statically checked like Java but higher-order functions are supported through libraries. Modules can be created and dependencies injected to customize code generation. The IDE supports features like content assist and debugging.
25. 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 modify
Use Guice to wire up the generator
26. content assist
syntax coloring
quick assist outline
rename refactoring
formating
call hierarchy
type hierarchy
extract method
debugging
etc...
IDE Support