The EMF Parsley DSL: an extensive use case of Xtext/Xbase powerful mechanisms
By Francesco Guidieri, Vincenzo Caselli & Lorenzo Bettini
EMF Parsley is a GUI renderer built on top of EMF that allows developers to quickly develop User Interfaces. The main goal of the Project is to provide an easy way to build complex applications, hiding some boring details, with simple and powerful APIs. EMF Parsley in fact provides some built-in components like Trees, Tables and Forms that can be easily mashed up and customized.
One of the greatest strengths of EMF Parsley is the DSL that lets the user fully customize the UI in a very simple way, thanks to the Dependency Injection that is deeply used in its core. We also work-shadowed at Xtext and re-used a polymorphic approach to correctly dispatch the customized code depending on user-defined EMF types.
For all these reasons, in this talk we will present EMF Parsley as an Xtext-success-story because of several mechanisms that have been re-used as well as in Xtext.
Starting from a single specification file, Parsley generates many (possibly related) Java classes; in order to do that, we fully exploit all the features of the Xbase model inferrer.
It also generates a plugin.xml file for the generated extension points; this plugin.xml is kept in synchronization (i.e., merged) with possible manual modifications by the developer. In order to achieve this, we implemented a custom Eclipse builder which seamlessly cohabits with the standard Xtext builder. Note that since in a single project there might be many EMF Parsley specifications, but only one single plugin.xml can be there, this also shows an example of how to generate a single source starting from several DSL specifications.
The EMF Parsley DSL is meant to live together with EMF Parsley Java API: Java API exploits generic types and generic methods and Xbase, thanks to its powerful type inference mechanisms, allows the EMF Parsley DSL developer to write simple, readable and concise specifications, while still enjoying the benefits of a static type system.