Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Using keyword 'super' in GenModel annotation
Using keyword 'super' in GenModel annotation [message #422737] Mon, 15 September 2008 17:08 Go to next message
Eclipse UserFriend
Originally posted by: fdo.scodi.ch

Hello

I noticed some strange behavior in the ecore code generation.

I have a ecore model and try to override the toString method using the
'http://www.eclipse.org/emf/2002/GenModel' annotation.
This works if I add a 'body' part like <% return super.getName(); %>

If I add <% return super.toString(); %> my generated class gets
messed up.

Here the ecore part:
<eOperations eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EString" name="toString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="&lt;% return super.toString(); %&gt;"/>
</eAnnotations>
</eOperations>

And here my class:


package ch.scodi.model.model.impl;

import return super.toString(); ;

import ch.scodi.model.basic.impl.RoleBasicImpl;

import ch.scodi.model.model.ModelPackage;
import ch.scodi.model.model.Role;

import org.eclipse.emf.ecore.EClass;

/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Role</b></em>'.
* <!-- end-user-doc -->
* <p>
* </p>
*
* @generated
*/
public class RoleImpl extends RoleBasicImpl implements Role
{
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected RoleImpl()
{
super();
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass()
{
return ModelPackage.Literals.ROLE;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String toString()
{
toString();
}

} //RoleImpl


Now notice the first import statement??? Also the toString method is
missing the 'super' part.

Am I doing something wrong or is this a EMF Bug? Is super somehow used to
add additional imports?
Re: Using keyword 'super' in GenModel annotation [message #422742 is a reply to message #422737] Mon, 15 September 2008 18:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30810
Registered: July 2009
Senior Member
Flavio,

Comments below.

Flavio Donzé wrote:
> Hello
>
> I noticed some strange behavior in the ecore code generation.
>
> I have a ecore model and try to override the toString method using the
> 'http://www.eclipse.org/emf/2002/GenModel' annotation.
> This works if I add a 'body' part like &lt;% return super.getName();
> %&gt;
>
> If I add &lt;% return super.toString(); %&gt; my generated class gets
> messed up.
The <%%> is supposed to surround just the fully qualified name that you
want imported. In this case you don't need any such brackets.
>
> Here the ecore part:
> <eOperations eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString" name="toString">
> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
> <details key="body" value="&lt;% return super.toString(); %&gt;"/>
> </eAnnotations>
> </eOperations>
>
> And here my class:
>
>
> package ch.scodi.model.model.impl;
>
> import return super.toString(); ;
>
> import ch.scodi.model.basic.impl.RoleBasicImpl;
>
> import ch.scodi.model.model.ModelPackage;
> import ch.scodi.model.model.Role;
>
> import org.eclipse.emf.ecore.EClass;
>
> /**
> * <!-- begin-user-doc -->
> * An implementation of the model object '<em><b>Role</b></em>'.
> * <!-- end-user-doc -->
> * <p>
> * </p>
> *
> * @generated
> */
> public class RoleImpl extends RoleBasicImpl implements Role
> {
> /**
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> protected RoleImpl()
> {
> super();
> }
>
> /**
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> protected EClass eStaticClass()
> {
> return ModelPackage.Literals.ROLE;
> }
>
> /**
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> public String toString()
> {
> toString(); }
>
> } //RoleImpl
>
>
> Now notice the first import statement??? Also the toString method is
> missing the 'super' part.
>
> Am I doing something wrong or is this a EMF Bug? Is super somehow used
> to add additional imports?
Since your snippet contains no fully qualified class names, you
shouldn't use <%...%>
>
>
Re: Using keyword 'super' in GenModel annotation [message #422812 is a reply to message #422742] Tue, 16 September 2008 06:15 Go to previous message
Eclipse UserFriend
Originally posted by: fdo.scodi.ch

Thanks Ed, got it to work! I misunderstood the EMF Book.

Ed Merks wrote:

> Flavio,

> Comments below.

> Flavio Donzé wrote:
>> Hello
>>
>> I noticed some strange behavior in the ecore code generation.
>>
>> I have a ecore model and try to override the toString method using the
>> 'http://www.eclipse.org/emf/2002/GenModel' annotation.
>> This works if I add a 'body' part like &lt;% return super.getName();
>> %&gt;
>>
>> If I add &lt;% return super.toString(); %&gt; my generated class gets
>> messed up.
> The <%%> is supposed to surround just the fully qualified name that you
> want imported. In this case you don't need any such brackets.
>>
>> Here the ecore part:
>> <eOperations eType="ecore:EDataType
>> http://www.eclipse.org/emf/2002/Ecore#//EString" name="toString">
>> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
>> <details key="body" value="&lt;% return super.toString(); %&gt;"/>
>> </eAnnotations>
>> </eOperations>
>>
>> And here my class:
>>
>>
>> package ch.scodi.model.model.impl;
>>
>> import return super.toString(); ;
>>
>> import ch.scodi.model.basic.impl.RoleBasicImpl;
>>
>> import ch.scodi.model.model.ModelPackage;
>> import ch.scodi.model.model.Role;
>>
>> import org.eclipse.emf.ecore.EClass;
>>
>> /**
>> * <!-- begin-user-doc -->
>> * An implementation of the model object '<em><b>Role</b></em>'.
>> * <!-- end-user-doc -->
>> * <p>
>> * </p>
>> *
>> * @generated
>> */
>> public class RoleImpl extends RoleBasicImpl implements Role
>> {
>> /**
>> * <!-- begin-user-doc -->
>> * <!-- end-user-doc -->
>> * @generated
>> */
>> protected RoleImpl()
>> {
>> super();
>> }
>>
>> /**
>> * <!-- begin-user-doc -->
>> * <!-- end-user-doc -->
>> * @generated
>> */
>> protected EClass eStaticClass()
>> {
>> return ModelPackage.Literals.ROLE;
>> }
>>
>> /**
>> * <!-- begin-user-doc -->
>> * <!-- end-user-doc -->
>> * @generated
>> */
>> public String toString()
>> {
>> toString(); }
>>
>> } //RoleImpl
>>
>>
>> Now notice the first import statement??? Also the toString method is
>> missing the 'super' part.
>>
>> Am I doing something wrong or is this a EMF Bug? Is super somehow used
>> to add additional imports?
> Since your snippet contains no fully qualified class names, you
> shouldn't use <%...%>
>>
>>
Previous Topic:Generated editor load resource dialog missing button?
Next Topic:[CDO] Explicit locking / Changes to EPackages
Goto Forum:
  


Current Time: Tue Jan 21 23:56:13 GMT 2020

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

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

Back to the top