Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Overriding operations
Overriding operations [message #422942] Fri, 19 September 2008 13:03 Go to next message
Eclipse UserFriend
Originally posted by: NOSPAM-magnus.rundlof.saabgroup.com-NOSPAM

Hi

Operations can be overridden in EClasses. However, this only affects the
interfaces of the generated code. I would like a method stub to be generated
for me in the implementation class, in the same way a method stub is
generated in the superclass where the method was originally declared. Is
this possible?

Regards/
Magnus
Re: Overriding operations [message #422943 is a reply to message #422942] Fri, 19 September 2008 13:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Magnus,

Since you will need to supply an operation body, anyway, and tag it with
"@generated NOT", you can just create the override in the appropriate
impl class when you are ready to fill in the body.

The current code pattern ensures that the superclass implementation will
be inherited instead of replacing it with an
UnsupportedOperationException :-)

HTH,

Christian

Magnus Rundlof wrote:
> Hi
>
> Operations can be overridden in EClasses. However, this only affects the
> interfaces of the generated code. I would like a method stub to be generated
> for me in the implementation class, in the same way a method stub is
> generated in the superclass where the method was originally declared. Is
> this possible?
>
> Regards/
> Magnus
>
>
Re: Overriding operations [message #422950 is a reply to message #422942] Fri, 19 September 2008 14:09 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
On 9/19/2008 9:03 AM, Magnus Rundlof wrote:
> Hi
>
> Operations can be overridden in EClasses. However, this only affects the
> interfaces of the generated code. I would like a method stub to be generated
> for me in the implementation class, in the same way a method stub is
> generated in the superclass where the method was originally declared. Is
> this possible?

Note that you can use a GenModel EAnnotation attached to the EOperation
to specify the impl code in the model itself. That way you don't have to
worry about adding non-generated code to the impl class; EMF will
automatically insert the code from the EAnnotation directly into the
generated impl class.
This blog describes the technique in detail:
< http://blog.eclipse-tips.com/2008/05/adding-util-methods-to- generated-emf.html>

Hope this helps,
Eric
Re: Overriding operations [message #423044 is a reply to message #422950] Mon, 22 September 2008 07:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: NOSPAM-magnus.rundlof.saabgroup.com-NOSPAM

Thanks! I'll try it out

-M


"Eric Rizzo" <eclipse-news@rizzoweb.com> wrote in message
news:gb0bp0$2q3$1@build.eclipse.org...
> On 9/19/2008 9:03 AM, Magnus Rundlof wrote:
>> Hi
>>
>> Operations can be overridden in EClasses. However, this only affects the
>> interfaces of the generated code. I would like a method stub to be
>> generated
>> for me in the implementation class, in the same way a method stub is
>> generated in the superclass where the method was originally declared. Is
>> this possible?
>
> Note that you can use a GenModel EAnnotation attached to the EOperation to
> specify the impl code in the model itself. That way you don't have to
> worry about adding non-generated code to the impl class; EMF will
> automatically insert the code from the EAnnotation directly into the
> generated impl class.
> This blog describes the technique in detail:
> < http://blog.eclipse-tips.com/2008/05/adding-util-methods-to- generated-emf.html>
>
> Hope this helps,
> Eric
Re: Overriding operations [message #423045 is a reply to message #422943] Mon, 22 September 2008 07:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: NOSPAM-magnus.rundlof.saabgroup.com-NOSPAM

Hi Christian, thanks for a quick reply!

I usually don't tag methods with the "@generated NOT", since the result
seems the same as not adding the tag at all. However, it might simplify
searching for hand-coded methods.

If I declare an overriding operation in the model I probably want to add
some behaviour to the implementing method. Why would I otherwise model it?
This means that I prefer the method to throw an
UnsupportedOperationException instead of just calling a superclass
implementation. It makes it easier to find unimplemented behaviour and that
was the origin of my question.

Regards/
Magnus



"Christian W. Damus" <cdamus@zeligsoft.com> wrote in message
news:gb08ei$c1k$1@build.eclipse.org...
> Hi, Magnus,
>
> Since you will need to supply an operation body, anyway, and tag it with
> "@generated NOT", you can just create the override in the appropriate impl
> class when you are ready to fill in the body.
>
> The current code pattern ensures that the superclass implementation will
> be inherited instead of replacing it with an UnsupportedOperationException
> :-)
>
> HTH,
>
> Christian
>
> Magnus Rundlof wrote:
>> Hi
>>
>> Operations can be overridden in EClasses. However, this only affects the
>> interfaces of the generated code. I would like a method stub to be
>> generated for me in the implementation class, in the same way a method
>> stub is generated in the superclass where the method was originally
>> declared. Is this possible?
>>
>> Regards/
>> Magnus
>>
Re: Overriding operations [message #423063 is a reply to message #423045] Mon, 22 September 2008 14:57 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020908090303020208090905
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Magnus,

In the last release we changed the algorithm so that if the operation
has a body, it will definitely be generated in the Impl, so you can
generate overrides this way. You can also suppress the visibility of
the operation so it doesn't appear in the interface avoiding redundancy
in the API. And of course if you want a TODO you can make that the
method body, though that seems a bit pointless...


Magnus Rundlof wrote:
> Hi Christian, thanks for a quick reply!
>
> I usually don't tag methods with the "@generated NOT", since the result
> seems the same as not adding the tag at all. However, it might simplify
> searching for hand-coded methods.
>
> If I declare an overriding operation in the model I probably want to add
> some behaviour to the implementing method. Why would I otherwise model it?
> This means that I prefer the method to throw an
> UnsupportedOperationException instead of just calling a superclass
> implementation. It makes it easier to find unimplemented behaviour and that
> was the origin of my question.
>
> Regards/
> Magnus
>
>
>
> "Christian W. Damus" <cdamus@zeligsoft.com> wrote in message
> news:gb08ei$c1k$1@build.eclipse.org...
>
>> Hi, Magnus,
>>
>> Since you will need to supply an operation body, anyway, and tag it with
>> "@generated NOT", you can just create the override in the appropriate impl
>> class when you are ready to fill in the body.
>>
>> The current code pattern ensures that the superclass implementation will
>> be inherited instead of replacing it with an UnsupportedOperationException
>> :-)
>>
>> HTH,
>>
>> Christian
>>
>> Magnus Rundlof wrote:
>>
>>> Hi
>>>
>>> Operations can be overridden in EClasses. However, this only affects the
>>> interfaces of the generated code. I would like a method stub to be
>>> generated for me in the implementation class, in the same way a method
>>> stub is generated in the superclass where the method was originally
>>> declared. Is this possible?
>>>
>>> Regards/
>>> Magnus
>>>
>>>
>
>

--------------020908090303020208090905
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Magnus,<br>
<br>
In the last release we changed the algorithm so that if the operation
has a body, it will definitely be generated in the Impl, so you can
generate overrides this way.&nbsp; You can also suppress the visibility of
the operation so it doesn't appear in the interface avoiding redundancy
in the API. &nbsp; And of course if you want a TODO you can make that the
method body, though that seems a bit pointless...<br>
<br>
<br>
Magnus Rundlof wrote:
<blockquote cite="mid:gb7gku$28e$1@build.eclipse.org" type="cite">
<pre wrap="">Hi Christian, thanks for a quick reply!

I usually don't tag methods with the "@generated NOT", since the result
seems the same as not adding the tag at all. However, it might simplify
searching for hand-coded methods.

If I declare an overriding operation in the model I probably want to add
some behaviour to the implementing method. Why would I otherwise model it?
This means that I prefer the method to throw an
UnsupportedOperationException instead of just calling a superclass
implementation. It makes it easier to find unimplemented behaviour and that
was the origin of my question.

Regards/
Magnus



"Christian W. Damus" <a class="moz-txt-link-rfc2396E" href="mailto:cdamus@zeligsoft.com">&lt;cdamus@zeligsoft.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:gb08ei$c1k$1@build.eclipse.org">news:gb08ei$c1k$1@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Hi, Magnus,

Since you will need to supply an operation body, anyway, and tag it with
"@generated NOT", you can just create the override in the appropriate impl
class when you are ready to fill in the body.

The current code pattern ensures that the superclass implementation will
be inherited instead of replacing it with an UnsupportedOperationException
:-)

HTH,

Christian

Magnus Rundlof wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi

Operations can be overridden in EClasses. However, this only affects the
interfaces of the generated code. I would like a method stub to be
generated for me in the implementation class, in the same way a method
stub is generated in the superclass where the method was originally
declared. Is this possible?

Regards/
Magnus

</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>

--------------020908090303020208090905--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Thanks for helping out on the ChangeRecorder
Next Topic:Manage compatibility between model files
Goto Forum:
  


Current Time: Sat Apr 20 03:36:51 GMT 2024

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

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

Back to the top