Scala generation with Acceleo 3.1

Posted on in Blog

I started Scala few months ago and since then I’m loving it. At the beginning, I’ve started by creating basic Scala applications in order to learn the language and after that I moved to small prototypes that I will present and improve in the months to come.

Quickly I was impressed by the structure of the Scala language and I started to look for a Scala metamodel in order to study the concepts of this language. Without any surprise, I didn’t found anything except a few people who were also looking for a Scala metamodel. Well since I am familiar with modeling technologies, I had to try to create a metamodel of Scala by myself, and you know me, if I have a metamodel, I have to generate code out of it.

This generator uses a PSM to generate scala source code. You can create the Scala model with the good old tree based EMF editor. For those who want to have fun, you can also grab an evaluation version of Obeo Designer and try to create diagrams for Scala. In less than five min, you can already have a small class diagram editor.

I have mainly focus my work on an Acceleo generator that I’ve recently updated to be conform with the best practices defined for Acceleo and I also switched to the latest version of Acceleo released with Eclipse 3.7 Indigo in order to use some of the brand new features coming with Acceleo 3.1.

You can easily build the generator very easily, thanks to maven and tycho, with a simple command: “mvn clean package”. After that, you will have an Eclipse update site in order to deploy the generator in an Eclipse instance of your choice.

This generator can generate Scala classes, objects and traits as you can see on the following screenshots.

The metamodel, the generator and their source code are available on Github under the open source EPL licence, feel free to test, use or even fork them as you want. For more information on Acceleo, you can follow me on twitter or google+.

Auteur d'origine: sbegaudeau