Community
Participate
Working Groups
Created attachment 176761 [details] Sample project that demonstrates the problem. I created a new Xtext language for an existing metamodel (Sample.ecore). In my model I reference elements in the Ecore metamodel (e.g. EClass): import "platform:/resource/model/model/Sample.ecore" import "http://www.eclipse.org/emf/2002/Ecore" as ecore Model returns Model: reference=[ecore::EClass] //<- validation error ; The problem is that I get a validation error for the "reference" feature("Cannot find referenced feature reference in sealed EClass model...:"). I took me a while to figure out that the problem was mixing imports by platform resource URI and NSURI. When I import my existing metamodel via its NSURI ("http://sample") everything works fine. I think it would help a lot here to have a corresponding validation. I attached also an example project that demonstrates the problem.
Scheduled for M5 as grammar mixin and Ecore import will become more popular with Xbase.
(In reply to comment #1) > Scheduled for M5 as grammar mixin and Ecore import will become more popular > with Xbase. thats because Sample.ecore refers to Ecore.ecore as platform:/plugin-uri <eStructuralFeatures xsi:type="ecore:EReference" name="reference" eType="ecore:EClass platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EClass"/> instead of its ns-uri form <eStructuralFeatures xsi:type="ecore:EReference" name="reference" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EClass"/> should we add an additional check for this kind of errors see http://www.eclipse.org/forums/index.php?t=msg&goto=551227&S=b33a349f818bb2e41cfceb0b7048056b and http://www.eclipse.org/forums/index.php?t=msg&goto=540574&S=85734ae7f35dff9fae4e185c63d0dc08
(In reply to comment #2) > should we add an additional check for this kind of errors Yes. How would you do it?
(In reply to comment #3) > (In reply to comment #2) > > should we add an additional check for this kind of errors > > Yes. How would you do it? I'd assume something along if (eClass.ePackage.nsURI == otherEClass.ePackage.nsURI && eClass.fragment == otherEClass.fragment && eClass.uri != otherEClass.uri) { ... } would work.
(In reply to comment #4) > (In reply to comment #3) > > (In reply to comment #2) > > > should we add an additional check for this kind of errors > > > > Yes. How would you do it? > > I'd assume something along > > if (eClass.ePackage.nsURI == otherEClass.ePackage.nsURI && eClass.fragment == > otherEClass.fragment && eClass.uri != otherEClass.uri) { > ... > } > > would work. As for the other validation issues that cover misleading errors in the Xtext grammar editor, this would require changes in the grammar inference code.
We could just check whether any EPackages are referenced twice instead of checking the EClass references. The EPackage reference should be flagged with an error not the EClass reference.
Created attachment 188432 [details] proposed patch pls review
Michael, I had to refactor the patch to support grammar inheritance. Pushed fix to master.
Closing all bugs that were set to RESOLVED before Neon.0