Acceleo 3.0 A short practical review

Acceleo features that I found after searching a little bit:

1. The variable i in a for loop is implicitly defined to represent the iteration counter

It can be used like this: [i/] and prints out 1 for the first iteration, 2 for the second, and so on and on.

2. You can define querys just like functions that can be invoked from anywhere.
[query public foo(muh : String) : OclAnyType = self /]
Call: [foo(“est”)/]

However, you can also define the query in that way, that it can be executed on a specific object.
[query public foo(e: E) : OclAnyType = self /]
Call: [e.foo()/]

3. For my current project, i have to increase the memory size of eclipse to 2048MB. Otherwise, it is unusable slow. I have more than 100 template files.

4. Properties can be used, however, there is no error message if a property is not found. Therefore, they should be used with caution as wrong text can be generated without your knowledge.

5. If you import a module which in turn also imports a module, you can only use the methods defined in the module you import yourself. This does not work transitively.

Example: Module A imports Module B; Module B imports Module C;
Module A can only use public queries and templates defined in Module B, not the ones in Module C

This has the negative side effect in my project, that i have to use about 10 or more imports on top of each file.

6. String concatenation with runtime-executed function results does not work

Example: [functionX(‘muh sadf’ + getNumberAsString(5)) /]

Solution: Use variables of the templates

[template private generateIt(path : String)
{
fullPath : String = path + ‘Filename.extension’;
}]

This is also more selfdocumenting.

7. If you need some conditional logic in your queries, just use static java methods and import them into your project as modules. This is way more easier. You can also you the types your ecore model defines in java.

Nevertheless, Eclipse Acceleo 3.0 MTL is quite a promising template framework and I enjoy using it. I hope, some of the issues above will be solved in the future.

If you have questions reguarding these issues, just contact me via email.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s