Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo 3.1] Problem with identifiers of protected
[Acceleo 3.1] Problem with identifiers of protected [message #723298] Thu, 08 September 2011 09:22 Go to next message
Norman  is currently offline Norman Friend
Messages: 17
Registered: June 2011
Junior Member
Hi everyone,

I have a Problem with the identifiers of protected areas.

Let me explain this in an example:
this is my acceleo part to generate User-define code for Operations:

[template public genOP(op : Operation)]
/*[protected ('for: ' +op.name+'*/')]

/*[/protected]*/
...

If im generating and putting something between the protected tags, the code is still there if im regenerating.

If im changing the Operation name, the identifier changes and the code is lost.

I know that changing the name worked in the past. What i doing wrong? Is it possible to bind user define code to the exact id in the uml file(at least with java)?

For my project it is necessary that changing identifiers is possible.

Any suggestions`?

Thanks much.

Greets,
Norman
Re: [Acceleo 3.1] Problem with identifiers of protected [message #723332 is a reply to message #723298] Thu, 08 September 2011 11:10 Go to previous messageGo to next message
Norman  is currently offline Norman Friend
Messages: 17
Registered: June 2011
Junior Member
ok i get it, is it possible to modify the generated string for protected?
Re: [Acceleo 3.1] Problem with identifiers of protected [message #724364 is a reply to message #723298] Mon, 12 September 2011 07:53 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 413
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi Norman,

Norman wrote on Thu, 08 September 2011 11:22

I know that changing the name worked in the past.


I don't see how it could have worked, we are matching the previously generated protected marker with the newly generated ones.

Anyway, you can change the protected area marker manually or you can ignore protected areas and have your users override the method of the generated classes instead of modifying the generated classes. It may break after some changes (if the method changes it may not compile anymore) but the user code will not be put into a ."lost" file. Finally if you are generating Java source code, you can use JMerge insttead. With JMerge, you can put a "@generated NOT" tag in the documentation of the method and Acceleo will consider the whole method as being protected. You can see an example of JMerge in the generated Java launcher class created by Acceleo. If you want to see JMerge in action, you can have a look at this video.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo



Re: [Acceleo 3.1] Problem with identifiers of protected [message #726998 is a reply to message #724364] Tue, 20 September 2011 06:46 Go to previous messageGo to next message
Norman  is currently offline Norman Friend
Messages: 17
Registered: June 2011
Junior Member
Stephane Begaudeau wrote on Mon, 12 September 2011 03:53

Anyway, you can change the protected area marker manually or you can ignore protected areas and have your users override the method of the generated classes instead of modifying the generated classes.


would you tell me, how to do this? That will be great.

Im generating C Soruce Code.

Thank you.
Re: [Acceleo 3.1] Problem with identifiers of protected [message #727015 is a reply to message #726998] Tue, 20 September 2011 08:01 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 413
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

I had in mind an object oriented language where you can easily extend a method with another one. With C source code, you may have to stick with protected areas.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo



Re: [Acceleo 3.1] Problem with identifiers of protected [message #729431 is a reply to message #727015] Mon, 26 September 2011 07:48 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1638
Registered: July 2009
Senior Member
Hi Norman,

Changing the identifier of a protected area, whatever the change, will result in a .lost file. That has always stood true for all versions of Acceleo. Changing the name of your operation, which incidentally is part of the identifier, is thus a change that never "worked".

What you should use here is not the name of the operation, but its ID. The ID cannot be obtained through Acceleo code alone, you'll have to resort to a Java service of this sort :

Quote:

public String getXMIID(EObject eObject) {
if (eObject.eResource() instanceof XMIResource) {
return ((XMIResource)eObject.eResource()).getID(eObject);
} else {
// This Object does not have an XMI ID. Resort on its name or throw exception
...
}
}


UML resources should all have XMI IDs... so you should never have to see the "else" in this code. It is a possibility though, and I'll let you code the logic that suits you there Smile.

Laurent Goubet
Obeo
Previous Topic:acceleo .emtl not found exception in jar file
Next Topic:[acceleo] how to return a List (or array or whatever) from an query
Goto Forum:
  


Current Time: Thu Nov 27 17:43:22 GMT 2014

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

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