[Acceleo 3] Protected Area [message #655097] |
Fri, 18 February 2011 05:12  |
Eclipse User |
|
|
|
Hello,
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,
Alexandre
|
|
|
Re: [Acceleo 3] Protected Area [message #655150 is a reply to message #655097] |
Fri, 18 February 2011 08:57   |
Eclipse User |
|
|
|
Hi Alexandre,
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
--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
[Updated on: Fri, 18 February 2011 08:58] by Moderator
|
|
|
|
|
|
Re: [Acceleo 3] Protected Area [message #656410 is a reply to message #656367] |
Fri, 25 February 2011 08:34  |
Eclipse User |
|
|
|
Hi Alexandre,
Acceleo does not allow anything to be located between the protected area identifier and the following line separator. Your first use case is wrong because of that, the second correct.
If you really need to put something there, you have to make it be part of the protected area identifier.
Laurent Goubet
Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.04671 seconds