Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Simple SuperType Problem in Grammar - Cannot find compatible feature
Simple SuperType Problem in Grammar - Cannot find compatible feature [message #1847866] Wed, 10 November 2021 19:50 Go to next message
Brandon Lewis is currently online Brandon LewisFriend
Messages: 232
Registered: May 2012
Senior Member
I have two ecore models:

ModelA.ecore and ModelB.ecore

I'm trying to create a xtext grammar that handles both models.

ModelA's plugins all work perfectly. No issues.

ModelA has a Class called LibraryElement. That LibraryElement has attributes: vendor, library, name, version.

ModelB has a Class called YpxComponent -> LibraryElement. i.e. LibraryElement is a SuperType of YpxComponent.

All ecore stuff works in ModelB. I can generate the emf models no problem and without issue. All types and supertypes look exactly like I expect. All hyperlinking in editors take me to the correct Types in the correct probjects.

Harmony acheived! ... until I try to make a grammar.

My grammar has all the correct imports. i.e. all the modelA::stuff is appropriately referenced (in the xtext file and workflow) - xtext has already figured out the Class hierarchy from me telling it what packages to use and selecting an entry point.

BUT

My YpxComponent has the following grammar:

 YpxComponent returns YpxComponent:
	'YpxComponent'
	id=ID0
	'{'
		'vendor' vendor=Name
		'library' library=Name
		'name' name=NMTOKEN
		'version' version=NMTOKEN


The vendor, library, name, version are all provided by the LibraryElement, but every single one of them is reporting an error like this:

Cannot find compatible feature vendor in sealed EClass YpxComponent from imported package http://my_company/ypx_1685_2014: The type 'YpxComponent' does not have a feature 'vendor'.

YpxComponent _clearly_ has this feature (it's inherited from the SuperType) so I suspect Xtext is telling me thing else, but I've spent the entire day not understanding how to get past this.

I'm tried all the import "platform/resource" substitutions I've seen from Google searches and nothing works.

This is basic inheritance stuff, EMF isn't having any issues.
Re: Simple SuperType Problem in Grammar - Cannot find compatible feature [message #1847867 is a reply to message #1847866] Wed, 10 November 2021 19:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14113
Registered: July 2009
Senior Member
can you please provide a minimal reproducer?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Simple SuperType Problem in Grammar - Cannot find compatible feature [message #1847868 is a reply to message #1847867] Wed, 10 November 2021 20:11 Go to previous messageGo to next message
Brandon Lewis is currently online Brandon LewisFriend
Messages: 232
Registered: May 2012
Senior Member
I'll try to make one. This only seems to happen when the SuperClass is in another ecore model. (although any type I'm using in ModelB from ModelA has the same or similar issues).
Re: Simple SuperType Problem in Grammar - Cannot find compatible feature [message #1847869 is a reply to message #1847868] Wed, 10 November 2021 21:54 Go to previous messageGo to next message
Brandon Lewis is currently online Brandon LewisFriend
Messages: 232
Registered: May 2012
Senior Member
Shoot. Of course my basic example works without issues! :-)

So there's something subtle and complex going on. I've never seen this before.

Do these warnings trigger any thoughts? My main modelA was created by importing an XML schema.

While the imports appear to work in my modelB grammar (which gives the grammar for modelB and modelA), I do get the following warning for these imports:

	The imported package refers to elements in the package registry instead of using the instances from the workspace
	
	import "http://www.eclipse.org/emf/2003/XMLType" as type
	import "http://www.accellera.org/XMLSchema/IPXACT/1685-2014" as ipx


Then in my modelB grammar, whenever I make any kind of containment reference to to classes in the ipx package, I get an error like this:

Cannot find compatible feature choices in sealed EClass YpxComponentType from imported package http://com/modelA: The type 'ChoicesType' used in the reference 'choices' is inconsistent. Probably this is due to an unsupported kind of metamodel hierarchy.


choices=ChoicesType is _not_ inconsistent, ecore is handling it in all cases just fine.
Re: Simple SuperType Problem in Grammar - Cannot find compatible feature [message #1847870 is a reply to message #1847869] Wed, 10 November 2021 22:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14113
Registered: July 2009
Senior Member
depends on how the ecores and genmodels reference each other and where they ly and if their projects have xtext nature etc

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Simple SuperType Problem in Grammar - Cannot find compatible feature [message #1847891 is a reply to message #1847870] Thu, 11 November 2021 15:53 Go to previous messageGo to next message
Brandon Lewis is currently online Brandon LewisFriend
Messages: 232
Registered: May 2012
Senior Member
Starting from a very basic example, I worked my way back to realize that my complex modelA import was causing the issue.

In the end, I had to change the import style from:

import "http://www.accellera.org/XMLSchema/IPXACT/1685-2014" as ipx

to:

import "platform:/resource/com.ipxact_1685_2014/model/ipxact_1685_2014.ecore" as ipx

And I also had to change my modelB import to also use the platform/resource style import. (if I didn't, Xtext lost track of modelB too)

Once I did that, the world made sense again.

I have no idea why that was needed.
Re: Simple SuperType Problem in Grammar - Cannot find compatible feature [message #1847894 is a reply to message #1847891] Thu, 11 November 2021 17:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14113
Registered: July 2009
Senior Member
again a reproducer would help

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Simple SuperType Problem in Grammar - Cannot find compatible feature [message #1847895 is a reply to message #1847894] Thu, 11 November 2021 18:07 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7383
Registered: July 2009
Senior Member
Hi

For pure EMF usage,

http://www.accellera.org/XMLSchema/IPXACT/1685-2014 references the Java code of a model installed a plugin and registered by an extension point.

platform:/resource/com.ipxact_1685_2014/model/ipxact_1685_2014.ecore references the Ecore model stored as a file in a project using a direct reference to that file.

(Since the project may be under development there is no reason to expect the two references to locate equivalent metamodels. If both are accidentally used, metamodel schizophrenia results.)

This is simple and provided you only use one style, many EMF tools work. However it is not always natural; users instinctively, and guided by poor tutorials, try to import development models using nsURIs.It is not always convenient, particularly when genmodels are involved since they must use *.ecore/*.genmodel references. Various tools provide often inconsistent techniques for helpfully resolving 'the wrong variant'. Xtext's help comes in the form of an index that I endeavour to avoid since many years of experience have convinced me that this kind of help ultimately contributes to greater confusion.

I find that Xtext works consistently and well with platform:/... references to manually maintained *.ecore; you just need to set the "Package not imported through URI" preference to Ignore. But beware, if any of your metamodels refer to an nsURI anywhere, it all falls over rather obscurely in genmodel.

IIRC Xtext's autogenerated *.ecore flles have inappropriate references that cause problems if the metamodels are used by other EMF-based tools such as M2Ms that do not share Xtext's helpful indexing strategy.

Regards

Ed Willink

Previous Topic:[Xtext] Grammar - Enhancing the infered model for language expressions
Next Topic:Gradle Build Folder not Ignored
Goto Forum:
  


Current Time: Thu Jan 27 12:38:45 GMT 2022

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

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

Back to the top