Problem when generating Xtext problem from different EMF models [message #1032904] |
Wed, 03 April 2013 11:44  |
Eclipse User |
|
|
|
I have three ecore metamodels:
Meta Model A
There is a class Model which contains a collection of elements (containments = true, cardinality 1...*)
Element is defines a a reference to an object of type Category which is defined in the meta model C (containment = false, cardinality 1...1).
It also contains a collection of Attribute (containments = true, cardinality 0...*)
Meta Model B
This metamodel defines two classes that extend Attribute: SimpleAttribute and ComplexAttribute
Meta Model C
Defies the class Category
Now I would like to generate a DSL for the MetaModel A.
This should replace the tree editor provided by EMF.
I tried to cretae a new "Xtext project from EMF". This is the result:
// automatically generated by Xtext
grammar MyDSL with org.eclipse.xtext.common.Terminals
import "http://metamodelA" as mA
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://metamodelB" as mB
import "http://metamodelC" as mC
Model returns mA::Model:
'Model'
name=EString
'{'
'elements' '{' elements+=Element ( "," elements+=Element)* '}'
'}';
EString returns ecore::EString:
STRING | ID;
Element returns ma::Element:
'Element'
name=EString
'{'
'category' category=[mc::Category|EString]
('attributes' '{' attributes+=Attribute ( "," attributes+=Attribute)* '}' )?
'}';
Category returns mC::Category:
...
;
This code gives me two errors:
1) Cannot find compatible category category in sealed EClass Element from imported package http://metamodelA: The existing reference 'category' has an incompatible type 'Category'. The expected type is 'Category'.
2) Attribute cannot be resolved to a rule
For the second problem I tried to define
Attribute returns mA::Attribute :
SimpleAttribute | ComplexAttribute
;
SimpleAttribute returns mb::SimpleAttribute:
....
;
ComplexAttribute returns mb::ComplexAttribute:
....
;
However the first rules returns the error : "Cannot add supertype 'Attribute' to sealed type 'SimpleAttribute'".
But actually SimpleAttribute is already a sub-class of Attribute.
How can I fix these problems?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.25129 seconds