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