Gold sponsors

IBM Corporation

Jasmine Conseil logo

Cloudsoft logo

Sonatype logo

SAP logo

Xored logo


Amazon logo

Silver sponsors

Blackberry logo

ZeroTurnaround logo

Amazon Web Services logo

bsi logo

OnPositive logo


Nuxeo logo


Bronze sponsors



Microsoft logo

Paremus logo

JBoss logo

Genuitec logo

Juniper logo

Soyatec logo

itemis logo

Totvs logo

AccuRev logo

Activity sponsor


Media sponsors

Methods & Tools logo

Codegeneration Goodies

Moritz Eysholdt (itemis AG )

Making at Eclipse · Standard
Wednesday, 10:40, 20 minutes | Stevens Creek


Codegeneration Goodies This talk demos three barely known but extremely useful tricks to related to generating code.

1. EmfGen with Generation Gap Pattern and without JMerge
Did you ever want to physically separate code generated by EMF and manually written code? Did you ever want to customize the generated code but you did not want to put it under version control? Or you have have been wondering how many of your generated files are orphaned because JMerge doesn't delete them even though the EClasses are long gone? I'll show how one can can subclass EMF's Impl-classes and then make EMF use these custom classes instead. In case you are thinking of adapting the EFactory: that's not it, since this would require to touch the generated code and it doesn't allow to customize the classes that are subclassed by other Impl-Classes.
I've successfully been using this approach in several industrial projects and the small tool needed for it is part of EMFT's Modeling Workflow Engine (MWE).

2. NoTemplate 1: Why EMF can do better than Xpand or Acceleo when generating XML
In this demo I'll shows how easy it is to generate XML files based on an XML Schema using EMF. The advantages compared to a template language are obvious: forget all worries about syntax, forgotten closing-tags, compliance to an XSD, well-formedness, formatting, unresolvable references, encoding, escaping of entities, etc.

3. NoTemplate 2: Use a Grammar instead of a template language
Another way to generate code is to create a grammar for the language targeted by code generation. Instead of writing templates, one instantiates an EMF Model and then serializes it to disk. The Ecore model can automatically be derived from the Grammar. This approach enforces syntactical correctness and cleanly separates the aspects of syntactical details, abstract structure, determining of names for cross-references, formatting, etc. Did I mention that one gets a smart editor for the targeted language for free (free as in effort, not as in sold-to-a-marketing-person)? This approach is based on Xtext.

download slides:
download source code:

I'm an Eclipse Committer from northern Germany, actively working on the Eclipse Projects Xtext and Xpand and several industrial ones. I'm employed by itemis AG.