Xtend2, Eclipse Indigo Feature #5

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
  • Closures
  • 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

screenshot 130 Xtend2, Eclipse Indigo Feature #5

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:

screenshot 131 Xtend2, Eclipse Indigo Feature #5Xtext now has a graphical view of the grammar

screenshot 133 Xtend2, Eclipse Indigo Feature #5

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

screenshot 137 Xtend2, Eclipse Indigo Feature #5

Finally we can call the generator to create the textual representation of the post:

screenshot 136 Xtend2, Eclipse Indigo Feature #5Sven Efftinge is the master mind of the whole X family (according to Peter Friese).  Kudos also go out to Sebastian Zarnekow, Jan Köhnlein, Holger Schill, Moritz Eysholdt and Dennis Huebner.

5 Responses to “Xtend2, Eclipse Indigo Feature #5”

  1. David Carver says:

    Hmmm…think I’ll stick with DocBook.

  2. Wow, that’s a lot more powerful than I realized Xtext was…

  3. Ian Bull says:

    @David. What, you don’t like my documentation publishing system that I developed in 10 minutes ;).

    @Chris. Yep. You get all the Eclipse tooling (content assist, outline view, syntax highlighting, error messages, quick fix, etc…) plus the generation with 15 lines of grammar, and < 30 lines of transformation. All the code (minus the few import import statements which I cropped) are shown in this post. It’s pretty incredible. This project had great vision and great execution!

  4. Ed Merks says:

    What a cool post with such excellent details!

  5. Dread says:

    >@David. What, you don’t like my documentation publishing system that I developed in 10 minutes ;) .

    Humm… may be you have forgotten 5 1/2 years to get these 10 minutes ;).

5 responses so far

Written by . Published in Categories: EclipseSource News, Planet Eclipse

Author:
Published:
Jun 16th, 2011
Follow:

Twitter LinkedIn Google+ GitHub