Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [xcore] Extending metamodel created by Xtext leads to erroneous generated code
[xcore] Extending metamodel created by Xtext leads to erroneous generated code [message #1089323] Sun, 18 August 2013 14:50 Go to next message
Robert Walter is currently offline Robert Walter
Messages: 29
Registered: July 2011
Junior Member
Hi,
I just got my hands on Xcore to see if I can extend a metamodel that has been created using Xtext.

So I used the default Xtext grammar from the project wizard, created a Xcore project with a first Xcore model file like this:

package org.experiment.subTyping

import org.xtext.example.mydsl.myDsl.Model

class SubModel extends Model {

} 


Model is the root element of the "MyDsl" grammar.
This leads to a problem in the generated code: "org.experiment.subTyping.SubTypingPackage", line 96:
"MODEL_OPERATION_COUNT cannot be resolved or is not a field"

So I tried wrapping the "Model" interface (though I haven't fully understood the semantics of the wrapping feature):

package org.experiment.subTyping

interface Model wraps org.xtext.example.mydsl.myDsl.Model
{}

class SubModel extends Model {
  
}


Now, the generated code complains at line 21 in org.experiment.subTyping.impl.SubModelImpl:
"The type SubModelImpl must implement the inherited abstract method Model.getGreetings()", so I added the operation to the wrapping interface:

package org.experiment.subTyping

import org.xtext.example.mydsl.myDsl.Greeting

interface Model wraps org.xtext.example.mydsl.myDsl.Model {
	op Greeting[] getGreetings() 
}

class SubModel extends Model {
  
} 


No more errors, but is this how it is supposed to work to extend types of existing meta models with Xcore? I certainly get something wrong here...?

I work with
EMF 2.10.0.v20130812-1102
Xcore 1.2.0.v20130814-0706
Xtext 2.4.3.v201308080741

Thanks,
Robert
Re: [xcore] Extending metamodel created by Xtext leads to erroneous generated code [message #1089328 is a reply to message #1089323] Sun, 18 August 2013 14:57 Go to previous message
Robert Walter is currently offline Robert Walter
Messages: 29
Registered: July 2011
Junior Member
Okay, withdrawn... another search revealed the solution:
Previous Topic:Adding popup menu submenu similar to New Child
Next Topic:Hello World CDO ?
Goto Forum:
  


Current Time: Fri Oct 24 20:51:12 GMT 2014

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

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