| Problems when referencing Ecore elements using an imported Ecore model [message #1754821] |
Wed, 22 February 2017 13:47  |
Eclipse User |
|
|
|
Hi
in a new DSL I started to work on, I refer to Ecore elements in the DSL, something like
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
generate myDsl "...my uri..."
...
Program:
...
('metamodel' metamodels+=[ecore::EPackage|STRING])*
...
;
So far so good, everything works. Now I'd like to switch to a manually maintained ecore model. I performed the steps to switch to an imported ecore model (starting from the one that Xtext had previously generated).
As soon as I switch in the grammar:
...
import "...my uri..."
...
The grammar editor starts complaining with a warning for the import:
"The imported package refers to elements in the package registry
instead of using the instances from the workspace"
and for the assignment metamodels+=[ecore::EPackage|STRING]) I get an error:
"Cannot find compatible feature metamodels in sealed EClass
Program from imported package myuri:
The type 'EPackage' [org.eclipse.emf.ecore.EPackage] used in
the reference 'metamodels' is inconsistent. Probably this is
due to an unsupported kind of metamodel hierarchy."
However, the workflow mwe2 still runs (of course, I updated it so that it references my genmodel).
The warning (not the error) proposes a quickfix to "update the imported package". The quickfix transforms in my ecore the reference:
<eStructuralFeatures xsi:type="ecore:EReference" name="metamodels" unique="false"
upperBound="-1" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EPackage"/>
into
<eStructuralFeatures xsi:type="ecore:EReference" name="metamodels" unique="false"
upperBound="-1" eType="ecore:EClass ../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EPackage"/>
Now the editor is happy (no more errors nor warnings). However, now it is the mwe2 workflow that complains with the same error I used to have in the editor:
"Cannot find compatible feature metamodels in sealed EClass EdeltaProgram from imported package ...myuri...: The type 'EPackage' used in the reference 'metamodels' is inconsistent. Probably this is due to an unsupported kind of metamodel hierarchy. (ErrorCode: CannotCreateTypeInSealedMetamodel)"
is there anything I could do to make "everyone" happy?
Could this be related https://github.com/eclipse/xtext-core/issues/41?
thanks in advance
Lorenzo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: Problems when referencing Ecore elements using an imported Ecore model [message #1754892 is a reply to message #1754855] |
Thu, 23 February 2017 11:02  |
Eclipse User |
|
|
|
Christian Dietrich wrote on Thu, 23 February 2017 04:17i assume you should use "platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore"
If Xtext tooling is the limit of your modeling aspirations, platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore may be convenient since you benefit from an Xtext-ism (? the Xtext index) whereby Xtext tooling doesn't actually use the Ecore.ecore that you say should be used.
However if you want to use your *.xtext model in another regular tool, in my case in an Xtext2LPG M2M, you need to use a correct reference; the nsURI.
I have no idea why the nsURI reference does not work for you, but without seeing all your tooling, who knows what magic you may have accidentally done.
Regards
Ed Willink
|
|
|
Powered by
FUDForum. Page generated in 0.11464 seconds