Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo 3] Protected Area
[Acceleo 3] Protected Area [message #655097] Fri, 18 February 2011 10:12 Go to next message
Alexandre Cortier is currently offline Alexandre CortierFriend
Messages: 9
Registered: January 2011
Junior Member
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 13:57 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

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 Very Happy
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 13:58]

Report message to a moderator

Re: [Acceleo 3] Protected Area [message #656248 is a reply to message #655150] Thu, 24 February 2011 17:07 Go to previous messageGo to next message
Alexandre Cortier is currently offline Alexandre CortierFriend
Messages: 9
Registered: January 2011
Junior Member
Ok thanks...


But, in wich situations a'.lost' file is generated ?
Because I'm quite sure that the identifiers I use for my protected areas are unique...

My scenario is the following :
Step 1- I have protected areas
Step 2- I generate some C source code
Step 3- I modify the C source code (inside the protected areas)
Step 4- I re-launch the generation

Then :
- a .lost file is generated where I can retrieve the source code that I have added in Step 3...

I will re-check the identifiers I use for my protected areas, but I'm quite sure they are unique...

Alex
Re: [Acceleo 3] Protected Area [message #656363 is a reply to message #655150] Fri, 25 February 2011 09:59 Go to previous messageGo to next message
Alexandre Cortier is currently offline Alexandre CortierFriend
Messages: 9
Registered: January 2011
Junior Member


Hi,

It seems that there really exists a bug concerning protected area.

If not, can you explain me this following error :

1/ First I generate code using the following protected area :



- In the generated code, I had user code ("TOTO") in the corresponding protected area.
- I re-generate the code (no source code modification in my Acceleo modules).
- Result : a .lost file is generated. I retrieve "TOTO" in the .lost file but not directly in the generated code....


2/ Second : I modify my protected area :


/* [protected(' for ' + name + ' includes */')]
/* [/protected] for [name/] includes */

As you can see : I just move '*/' in the protected area name.

Then I follow exactly the same process :
- I generate code,
- I modify the protected area in the generated code,
- I re-generate the code

Result : It works... No .lost file is generated. I retrieve my user-code in the appropriate protected area...


This point is really blocking. Is it a bug ? Did I miss something ?

Thanks...

Alex
Re: [Acceleo 3] Protected Area [message #656367 is a reply to message #655150] Fri, 25 February 2011 10:26 Go to previous messageGo to next message
Alexandre Cortier is currently offline Alexandre CortierFriend
Messages: 9
Registered: January 2011
Junior Member
(sorry, i made a mistake in my last message)

Hi Stephane,

It seems that there really exists a bug concerning protected area.

If not, can you explain me this following error :

1/ First I generate code using the following protected area :

/* [protected(' for ' + name + ' includes ')] */
/* [/protected] for [name/] includes */

- In the generated code, I had user code ("TOTO") in the corresponding protected area.
- I re-generate the code (no source code modification in my Acceleo modules).
- Result : a .lost file is generated. I retrieve "TOTO" in the .lost file but not directly in the generated code....


2/ Second : I modify my protected area :


/* [protected(' for ' + name + ' includes */')]
/* [/protected] for [name/] includes */

As you can see : I just move '*/' in the protected area name.

Then I follow exactly the same process :
- I generate code,
- I modify the protected area in the generated code,
- I re-generate the code

Result : It works... No .lost file is generated. I retrieve my user-code in the appropriate protected area...


This point is really blocking. Is it a bug ? Did I miss something ?

Thanks...

Alex
Re: [Acceleo 3] Protected Area [message #656410 is a reply to message #656367] Fri, 25 February 2011 13:34 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
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
Previous Topic:xPand and TaggedValues
Next Topic:[Acceleo] Outsource Computation to Java
Goto Forum:
  


Current Time: Thu Apr 18 11:13:55 GMT 2024

Powered by FUDForum. Page generated in 0.02220 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top