Xtext define a syntax with subpakages in the ecore file

33 views Asked by At

I would like to generate a syntax using Xtext from an Ecore file. I successfully created an Xtext project from an existing Ecore but when I create a sub package in my Ecore, and regenerate the .xtext file (which will include a reference to uri of the sub package as shown in the following figure) enter image description here the execution of the mwe2 file shows the following error :

Caused by: java.lang.IllegalStateException: Problem parsing 'file:/Users/abdelghanialidra/eclipse-workspace/test2/org.xtext.example.lang4Dsl/../org.xtext.example.lang4Dsl/src/org/xtext/example/mydsl1/MyDsl.xtext':
XtextLinkingDiagnostic: null:5 Couldn't resolve reference to EPackage 'http://www.example.fr/pack'

Where http://www.example.fr/pack is the url of the sub package in my Ecore file. Note if I remove the reference to the sub package in my .xtext file every thing works fine again but I cannot, obviously, access the Classes inside the sub package.

Any idea how I can make it work with sub packages?

Thanks in advance

1

There are 1 answers

0
Banoffee On

Apologies as this is not the answer you are looking for, but nested EPackages should not be used in EMF as it breaks the 1-1 relationship between nsURIs and EPackages. Many tools won't work properly. If you need to separate concerns, simply use a second metamodel.

I would not be too surprised if nested EPackages were explicitly not supported in Xtext.