Community
Participate
Working Groups
There is a problem with extending grammars from which an EPackage is derived. It results in an error "Cannot add supertype 'X' to sealed type 'X'. (ErrorCode: CannotCreateTypeInSealedMetamodel)". The base grammar is defined as follows: grammar org.xtext.example.mydsl.MyDsl1 with org.eclipse.xtext.common.Terminals generate myDsl1 "http://www.xtext.org/example/mydsl/MyDsl1" //import "http://www.xtext.org/example/mydsl/MyDsl1" Model: greetings+=Greeting*; Greeting: 'Hello' name=ID '!'; The derived grammar is: grammar org.xtext.example.mydsl.MyDsl2 with org.xtext.example.mydsl.MyDsl1 import "http://www.xtext.org/example/mydsl/MyDsl2" as mydsl2 Model returns mydsl2::Model2: greetings+=Greeting*; The EPackage mydsl2 only contains a single EClass Model2 which extends mydsl1::Model. Both the editor and the generator end up reporting the following problem: Cannot add supertype 'Model' to sealed type 'Model2'. (ErrorCode: CannotCreateTypeInSealedMetamodel). A workaround is to also have the base grammar import the mydsl1 EPackage instead of generating it.
The references in MyDsl2 to MyDsl1 need to be absolute platform:/resource / uris. Is that the case?
No, as in the description MyDsl2 only references the MyDsl1 grammar directly (by its qualified name), not the EPackage. Adding an import for the generated EPackage using a platform:/resource URI is not possible: import "platform:/resource/org.xtext.example.mydsl1/src-gen/org/xtext/example/mydsl/MyDsl1.ecore" It results in the following error: "Metamodels that have been generated by a super grammar must be referenced by nsURI: http://www.xtext.org/example/mydsl/MyDsl1". Importing the MyDsl1 EPackage by its nsURI doesn't make any difference. I.e. the same error as originally reported remains.
I can imagine that the proxies MyDsl2.ecore resolve to the generated *.ecore file before the super grammar inferred the ecore model that should be the actual resolve target. Nasty :-(