Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » define getter of derived volatile attribute
define getter of derived volatile attribute [message #1060723] Tue, 28 May 2013 08:55 Go to next message
Jens von Pilgrim is currently offline Jens von PilgrimFriend
Messages: 313
Registered: July 2009
Senior Member
Hi,

I have defined a derived volatile attribute. Now I need to implement the
getter. By default, the EMF generator creates a method stub, and I have
to manually implement the body. In order to avoid trouble in case of
re-generation (actually, I'm using an Xtext post processor to add the
derived attribute, so "@generate not" is not working), I would like to
define the body of the getter in the model, similar to the body of an
operation (which can to be defined in an annotation). Is that possible?
Actually, I would like to simply add the body in the post processing
step, when I define the attribute.

Regards,
Jens
Re: define getter of derived volatile attribute [message #1060765 is a reply to message #1060723] Tue, 28 May 2013 11:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Jens,

The generator has methods like this

protected String getGetterBody()
{
EStructuralFeature eStructuralFeature = getEcoreFeature();
EAnnotation eAnnotation =
eStructuralFeature.getEAnnotation(GenModelPackage.eNS_URI);
return eAnnotation == null ? null :
(String)eAnnotation.getDetails().get("get");
}

that will extract the stub into the generated code.


On 28/05/2013 10:55 AM, Jens v.P. wrote:
> Hi,
>
> I have defined a derived volatile attribute. Now I need to implement
> the getter. By default, the EMF generator creates a method stub, and I
> have to manually implement the body. In order to avoid trouble in case
> of re-generation (actually, I'm using an Xtext post processor to add
> the derived attribute, so "@generate not" is not working), I would
> like to define the body of the getter in the model, similar to the
> body of an operation (which can to be defined in an annotation). Is
> that possible? Actually, I would like to simply add the body in the
> post processing step, when I define the attribute.
>
> Regards,
> Jens


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: define getter of derived volatile attribute [message #1060945 is a reply to message #1060765] Wed, 29 May 2013 09:13 Go to previous message
Jens von Pilgrim is currently offline Jens von PilgrimFriend
Messages: 313
Registered: July 2009
Senior Member
Ed,

thank you! That was what I was looking for.

Just in case others have a similar question: Search for
GenModelPackage.eNS_URI
in the org.eclipse.emf.codegen.ecore sources to find other annotation keys

Regards,
Jens
Previous Topic:Run generated Editors in Eclipse4 RCP
Next Topic:[EMF] Change volatile and transient properties
Goto Forum:
  


Current Time: Fri Apr 26 01:03:30 GMT 2024

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

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

Back to the top