The Eclipse Indigo release is now less than 1 week away, which means I’m into the Top 5 Entries in my Eclipse Indigo Top 10 List. Number 5 on my Top 10 List is near and dear to my heart as I started using some of this technology 5 years ago when it was hosted at openArchitectureWare. In fact, I spent 5 1/2 years of my life studying Model Driven Development, and I find the entire Model-2-Text and Text-2-Model fascinating.
Number 5 on my Top 10 Indigo Feature List is Xtend 2. Xtend 2 (part of the Xtext project) is a code generation language compiled to performant Java code. The language supports a number of constructs such as:
- Both static and injected dynamic extensions
- Polymorphic method dispatching
- Smart string processing
- Type inference
- and more…
But the best way to demonstrate this is through a real example. Let’s assume we get tired of writing Top 10 Lists and we simply want to specify the elements and have the blogs write themselves. We could use the smart string processing of Xtend 2 to describe the Model-2-Text transformation
While this particular example would simply output text, we could enhance the transformation to write out HTML, XML, DocBook, LaTeX, etc… From here, we could use Xtext to describe a Top 10 List Grammar:
There are also a new quick fix options available, refactoring support and a content assist improvements.
Once we have our grammar, we can now use the generated language (and generated tool support) to create our top 10 list
Finally we can call the generator to create the textual representation of the post: