|[Acceleo 3] Protected Area [message #655097]
||Fri, 18 February 2011 05:12
| Alexandre Cortier
Registered: January 2011
I am not sure I understand how protected areas should work.
The source code placed in a protected area is always lost during a re-generation (a .lost file is generated).
The protected code should not reappear in the generated files ?
In my project (UML --> C), I have a lot of protected areas...
It's quite long and boring to have to copy and paste the contents of the .lost files in my re-generated .c files...
Is there a solution to automate the process ?
Thanks for all,
|Re: [Acceleo 3] Protected Area [message #655150 is a reply to message #655097]
||Fri, 18 February 2011 08:57
| Stephane Begaudeau
Registered: April 2010
Location: Nantes (France)
So let me explain protected areas:
1- you generate some code, then you modify that generated code and you launch the generation once again -> your modification in the generated files are lost
2- you generate some code with a protected area (with an unique identifier -> [protected ('myIdentifier')] ... [/protected] in a given file), you modify your generated code inside of the protected area and outside of the protected area, you launch the generation once again -> the code modified in the generated file outside of the protected area is lost, the code modify inside of the protected area is still there.
Since with a code generation project, you will one day have to modify the generated code. Even when you think that you won't, you will because you will be lazy / late / anything else
The protected area allow you to prepare some parts of the generated code for modifications. You can predict where those modifications should appear and where your generator will support those modifications.
If you create an UML to Java generator, you want to create a protected area between the last attribute and the constructor so that you can modify without risk the generated code to add a new attributes and you want to create a protected area after all your generated method to give the user the opportunity to add new methods.
For more information on protected area, you can find here a video that I've realized for the conference Topcased Days, during the "part 7" I show how protected areas work (start at 7min 25s in the video part7).
Stephane Begaudeau, Obeo
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
[Updated on: Fri, 18 February 2011 08:58]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02812 seconds