Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem with Super Grammar and an Ecore based SubGrammar(Cannot find compatible feature greetings in sealed EClass Model8 from imported package )
Problem with Super Grammar and an Ecore based SubGrammar [message #1114519] Sun, 22 September 2013 21:42 Go to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
I have a super grammar(mydsl7) and a subgrammar(mydsl8) which is based on an predefined ecore model(My8,ecore). In the sub grammar I get the following error:
Cannot find compatible feature greetings in sealed EClass Model8 from imported package http:/www.xtext.org/example/mydsl8/Mydsl8: The existing reference 'greetings' has an incompatible type 'Greeting7'. The expected type is 'Greeting7'.


I guess I missed something to configure.
Can any body give me a hint how to fix this?

I prepared an example setup see the atached zip file.
It is an eclipse kepler setup. I remove the anlr jar and the class files
Re: Problem with Super Grammar and an Ecore based SubGrammar [message #1114730 is a reply to message #1114519] Mon, 23 September 2013 05:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
No idea what you want to do (you dont generate anything, you refer the
"will be deleted" ecore from the current grammar etc.
maybe you want to:

grammar org.xtext.example.mydsl8.MyDsl8 with org.xtext.example.mydsl7.MyDsl7

import "http://www.xtext.org/example/mydsl7/MyDsl7" as model7
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Model8 returns model7::Model7:
	 greetings+=Greeting7 ( "," greetings+=Greeting7)*
	;



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem with Super Grammar and an Ecore based SubGrammar [message #1115244 is a reply to message #1114730] Mon, 23 September 2013 22:10 Go to previous messageGo to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
Thank you for your answer. My problem is I have super grammar that has a generated ecore model from Xtext and I have a grammar that is inheriting form that grammar but this one has a predifined ecore model and I want to reuse the rules from the super grammar to form the rules for the current grammar. But the error indicates some type mismatches in the ecore models.

Even though in Model8 the greetings feature is declared with the Greeting7 type from the MyDsl7 the Xtext editor for Model8 shows up the mentioned error.

When you opened my example didn't you see the error in the Xtext editor of Model8 ?
If you don't see the error then something is wrong with my environment.
If you see the error then you hopefully can explain to me what's the reason and how to fix it.

Thanks
Re: Problem with Super Grammar and an Ecore based SubGrammar [message #1115445 is a reply to message #1115244] Tue, 24 September 2013 05:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

no
bad idea to but it to src gen. i get Multiple markers at this line - The imported package is not on the classpath of this project which may lead
to follow up errors.

next to this you will need a genmodel for this metamodel too.
and you should register it in the standalonesetup (same as xtext does for xbase)

and you should consider to move it to a separate (empty emf) project. (dont forget to add xtext nature)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem with Super Grammar and an Ecore based SubGrammar [message #1115972 is a reply to message #1115445] Tue, 24 September 2013 20:50 Go to previous messageGo to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
Hi,

Christian Dietrich wrote on Tue, 24 September 2013 01:50

Hi,

no

no - you did not open it because you got mutiliple markers ?
Quote:

bad idea to but it to src gen. i get Multiple markers at this line - The imported

What I should not have put to src-gen ?
Quote:

package is not on the classpath of this project which may lead
to follow up errors.

next to this you will need a genmodel for this metamodel too.

I have a genmodel (/org.xtext.example.mydsl8.ecore/model/My8.genmodel) and it is a separate project.
Quote:

and you should register it in the standalonesetup (same as xtext does for xbase)

You think of this ?
registerGeneratedEPackage = "org.xtext.example.mydsl7.myDsl7.MyDsl7Package"
registerGenModelFile = "platform:/resource/org.xtext.example.mydsl7/model/generated/MyDsl7.genmodel"
registerGeneratedEPackage = "my8.My8Package"
registerGenModelFile = "platform:/resource/org.xtext.example.mydsl8.ecore/model/My8.genmodel"


The error message seems to point to the fact that the reference type of greetings in Model7 is more specific (qualified) than in Model8 (unqualified)
Caused by: java.lang.IllegalStateException: Problem parsing 'classpath:/org/xtext/example/mydsl8/MyDsl8.xtext':[TransformationDiagnostic: null:8 Cannot find compatible feature greetings in sealed EClass Model8 from imported package http:/www.xtext.org/example/mydsl8/Mydsl8: The existing reference 'greetings' has an incompatible type 'Greeting7' [org.xtext.example.mydsl7.myDsl7.Greeting7]. The expected type is 'Greeting7'. (ErrorCode: CannotCreateTypeInSealedMetamodel)]

Because I reference the genmodel od Model7 in Model8 and now inherit Model8 from Model7 the greetings feature in Model8 is inherited from Model7 and should have the same type as in Model7.
For me it smells to be a bug in Xtext incorrectly matching the types of inherited grammar rules and predefined ecore model feature types.

I made some corrections to the project files and hope you can open it with only the mentioned error. They are ready to use eclipse projects except you need to download the antlr runtime and build the projects to generate the class files.

Thank you for taking the time to investigate the problem.

Re: Problem with Super Grammar and an Ecore based SubGrammar [message #1115993 is a reply to message #1115972] Tue, 24 September 2013 21:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
can you please file a bug.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem with Super Grammar and an Ecore based SubGrammar [message #1116004 is a reply to message #1114519] Tue, 24 September 2013 21:59 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The OCL and QVT editors have multiple levels of manually defined Ecore
metamodels and so I have seen this error many times.

Xtext 2.0 had a single unhelpful error message in this area against
which I identified many distinct causes in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=316610.

From my experience, Xtext was generally correct but unhelpful in
explaining the problem. The messages are now much better.

If you can't spot your error, switch to an auto-generated Ecore
meta-model so that you can see what Xtext wants. Then raise a bug about
the inadequate diagnostic case.

Regards

Ed Willink


On 22/09/2013 17:42, Olaf Bigalk wrote:
> I have a super grammar(mydsl7) and a subgrammar(mydsl8) which is based on an predefined ecore model(My8,ecore). In the sub grammar I get the following error:
>
> Cannot find compatible feature greetings in sealed EClass Model8 from imported package http:/www.xtext.org/example/mydsl8/Mydsl8: The existing reference 'greetings' has an incompatible type 'Greeting7'. The expected type is 'Greeting7'.
>
>
> I guess I missed something to configure.
> Can any body give me a hint how to fix this?
>
> I prepared an example setup see the atached zip file.
> It is an eclipse kepler setup. I remove the anlr jar and the class files
Previous Topic:Alternative types in cross references
Next Topic:How to build a correct grammar without conflicting keywords and ID's
Goto Forum:
  


Current Time: Thu Mar 28 20:25:05 GMT 2024

Powered by FUDForum. Page generated in 0.02509 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top