Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext -> Xcore -> Xtext(Using an Xcore meta model in conjunction with multiple Xtext projects.)
Xtext -> Xcore -> Xtext [message #1350708] Mon, 12 May 2014 19:54 Go to next message
Andrew Clark is currently offline Andrew ClarkFriend
Messages: 23
Registered: June 2010
Junior Member
I currently have 2 xtext projects 'foo' and 'bar', where bar model instances reference foo model instances.

I would now like to define *some* of the meta model externally. There is a reason I don't wish to define the entire meta model in xcore, but I won't go into it here.

So I am trying to use xcore defined meta models working together together with 2 xtext meta models. And I cannot get it to work!

ie.

Foo : xtext : defines a grammar and has an inferred model
FooCore : xcore : defines classes that reference Foo objects.
Bar : xtext : defines a grammar and has an inferred model , but uses FooCore defined classes.
(examples of the meta models are at the end of this post)

I get "Cannot find compatible feature fooDef in sealed EClass FooClass from imported package FooCore: The existing reference 'fooDef' has an incompatible type 'FooDef'. The expected type is 'FooDef'."

Is this possible or have I fundamentally misunderstood how this works?

Any help gratefully accepted, I tried to attach the Eclipse example projects but the attachments don't appear (no error). I can provide them if it helps.

I am working with the latest version of Kepler with Xtext 2.5 and Xcore 1.1

E.g. of the meta models.

Foo

"grammar org.xtext.example.foo.Foo with org.eclipse.xtext.common.Terminals

generate foo "http://www.xtext.org/example/foo/Foo"

Model:
foos+=FooDef*;

FooDef:
'Hello' name=ID '!';

"

FooCore

"
package FooCore

import org.xtext.example.foo.foo.FooDef

enum FooEnum {
one two three
}

class FooClass {
String name
contains FooDef fooDef
}
"

Bar

"
grammar org.xtext.example.bar.Bar with org.eclipse.xtext.common.Terminals

import "FooCore"

import "http://www.xtext.org/example/foo/Foo" as Foo

generate bar "http://www.xtext.org/example/bar/Bar"

BarModel:
barClasses+=BarClass*
;


BarClass returns FooClass :
'name' name=STRING
'foo' fooDef=[Foo::FooDef]
;
"

[Updated on: Mon, 12 May 2014 20:05]

Report message to a moderator

Re: Xtext -> Xcore -> Xtext [message #1350778 is a reply to message #1350708] Mon, 12 May 2014 20:33 Go to previous messageGo to next message
Andrew Clark is currently offline Andrew ClarkFriend
Messages: 23
Registered: June 2010
Junior Member
Some more information.

The error appears in the editor but there is no marker in the package explorer and no error in the Problems view!

If I run the workflow the error there is

3336 [main] ERROR ipse.xtext.generator.LanguageConfig  - [TransformationDiagnostic: null:16 Cannot find compatible feature fooDef in sealed EClass FooClass from imported package FooCore: The existing feature 'fooDef' has an incompatible type 'EJavaObject' [java.lang.Object]. The expected type is 'FooDef' [org.xtext.example.foo.foo.FooDef]. (ErrorCode: CannotCreateTypeInSealedMetamodel)]


I guess the clue is in CannotCreateTypeInSealedMetamodel, which seems to be referenced in some bug reports, this one look particularly interesting https://bugs.eclipse.org/bugs/show_bug.cgi?id=370525 , is it the same problem?
Re: Xtext -> Xcore -> Xtext [message #1351873 is a reply to message #1350778] Tue, 13 May 2014 07:45 Go to previous messageGo to next message
Andrew Clark is currently offline Andrew ClarkFriend
Messages: 23
Registered: June 2010
Junior Member
OK I am in danger of having a conversation with myself here, but one more bit of information.

If I generate ecore and genmodel files from the xcore metamodel and register them in the workflow standalonesetup as normal

    	registerGeneratedEPackage = "org.xtext.example.foo.foo.FooPackage"
    	registerGenModelFile = "platform:/resource/org.xtext.example.foocore/model/FooCore.genmodel"


and remove (comment out) the xcore load resource

    	language = auto-inject {
//    		loadedResource = "platform:/resource/org.xtext.example.foocore/model/FooCore.xcore"
    		uri = grammarURI


everything seems to work fine.
Re: Xtext -> Xcore -> Xtext [message #1352202 is a reply to message #1351873] Tue, 13 May 2014 10:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Yes you have to use loadresource for xcore

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext -> Xcore -> Xtext [message #1354413 is a reply to message #1352202] Wed, 14 May 2014 08:42 Go to previous messageGo to next message
Andrew Clark is currently offline Andrew ClarkFriend
Messages: 23
Registered: June 2010
Junior Member
Of course I tried to use loadedResource first, I am sorry that wasn't clear from the original post. However when I use loadedResource I get the CannotCreateTypeInSealedMetamodel error.

On the other hand when I generate an ecore and load in the standalone setup, its works.

i.e. it seems to be that the loadedResource mechanism is causing the problem.
Re: Xtext -> Xcore -> Xtext [message #1354460 is a reply to message #1354413] Wed, 14 May 2014 09:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i fear without a complete reproducable sample it is hard to help


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext -> Xcore -> Xtext [message #1540514 is a reply to message #1354460] Thu, 01 January 2015 14:54 Go to previous message
Aykut  Kilic is currently offline Aykut KilicFriend
Messages: 2
Registered: July 2009
Junior Member
I get a similar error and created added a bug report with a sample project.

In my case it fails depending on the order I load the resources (xcore files)

Bug ID: 456482
Previous Topic:How to convert from my language to XML template
Next Topic:dealing with type computation of array access
Goto Forum:
  


Current Time: Fri Apr 26 04:39:46 GMT 2024

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

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

Back to the top