|
Re: [acceleo] @main & invoking generated Java class [message #730799 is a reply to message #730588] |
Thu, 29 September 2011 07:58 |
|
Hi Marc,
If your tree's root type (let's call it "Component") is the same as its sub-nodes, and you define an Acceleo "template" with a parameter of type "Component", then this template will be called on each "Component" we can find. That is the normal behavior. That would give something like this :
[template generate(component : Component)]
[comment @main/]
However you can change your template so that it has a "guard" preventing it from being called on sub-nodes. Something like this :
[template generate(component : Component) ? (component.eContainer().oclIsUndefined())]
[comment @main/]
Laurent Goubet
Obeo
|
|
|
|
|
|
|
|
Re: [acceleo] @main & invoking generated Java class [message #733606 is a reply to message #731196] |
Wed, 05 October 2011 08:12 |
|
Marc,
This was indeed ill-explained in the documentation, we have added a proper documentation for the "main" behavior ... though the platform we're using is currently bugging. The page is located at http://www.obeonetwork.com/page/the-acceleo-main-modules ... If it still fails to load when you read this, here is the content of the part we've added there :
Quote:
Behavior
The main template will be called on all the elements of the model with the given type. The beginning of the execution of the main template initialized the generation. As such, if you have a main template defined on a UML Class, this template will be called for all your classes but it also mean that the generator will be initialized for each call to this main template so, for example, the cache of the queries will be cleared after each call. It is recommended to define the main module on the root of your metamodel and then to navigate manually in your model to call all the other templates. On a UML model, you would improve performances by defining your generator on the root concept Model instead of Class.
Laurent Goubet
Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.03331 seconds