Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext] Problem : Cannot find compatible feature foo in sealed EClass
[Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #43269] Thu, 07 May 2009 12:46 Go to next message
Eclipse UserFriend
Originally posted by: sderrienREMOVE.irisa.fr

Hello,

I want to define a DSL for an existing ecore meta model.

In this model I have an AbstractClass which has a feature named foo, and
a ConcreteClass that inherits from this AbstractClass.

I want to write a Rule to create an initialized instance of
ConcreteClass in which I initialize the feature foo (inherited from
AbstractClass).

I use the following Xtext Rule for this

MyRule1 returns ConcreteClass:
foo+=AnotherRule

However, I get the following error :

Cannot find compatible feature foo in sealed EClass ConcreteClass from
imported package http://mypackageURI.

Is there a way to specify that the feature belongs to the ParentClass
(something like super.foo+=AnotherRule) ? If not is there any alternive
solution ?

Steven Derrien
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #43326 is a reply to message #43269] Thu, 07 May 2009 15:55 Go to previous messageGo to next message
Heiko Behrens is currently offline Heiko BehrensFriend
Messages: 11
Registered: July 2009
Junior Member
Hey Steven,

> MyRule1 returns ConcreteClass:
> foo+=AnotherRule
>
> However, I get the following error :
>
> Cannot find compatible feature foo in sealed EClass ConcreteClass from
> imported package http://mypackageURI.
>

the problem here is that Xtext tries to find a proper feature that
corresponds to "foo+=AnotherRule" in your meta model. Each assignment
has to match with respect to its name, cardinality and type.

Just looking at your snippet I would guess that AnotherRules does not
return the proper type for the given feature foo defined in your
existing meta model.

This should work:

MyRule returns ConcreteClass:
foo=AnotherRule;

AnotherRule returns TypeOfFeatureFooInConcreteClass:
some?="rule that matches return type";

Also, please be aware that "+=" and "=" expect different configurations
of your meta model. The former expects a multi value containment feature
where as the latter expect a single value containment.

Hope that helps,
Heiko
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #43419 is a reply to message #43326] Thu, 07 May 2009 19:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sderrienREMOVE.irisa.fr

Hello Heiko,

Thank you for your help.

Actually my example was not correct, since my DSL involves
cross-references. Here is the actual code snippet :

import "http://www.irisa.fr/cairn/datapath/fsm" as fsm
import "http://www.irisa.fr/cairn/datapath/port" as ports

....

FSMRule returns fsm::FSM :
ports+=InputPortRule terms+=PredicateTermRule;


InputPortRule returns ports::InControlPort:
name=ID;

PredicateTermRule returns fsm::PredicateTerm :
(negated?=('!'))? flag=[ports::InControlPort];
^^^^

It is the flag feature that causes the error message :

"Cannot find compatible feature flag in sealed EClass PredicateTerm from
imported package http://www.irisa.fr/cairn/datapath/fsm."

In the ecore file defining the fsm package, the EClass *PredicateTerm*
has a EReference feature named *flag* of type *InControlPort*, with
upperBound set to 1, and containment set to false.

Unless I am missing something obvious, everything seems consistent
to me (I double-checked before writing this mail).

Do you have any hints ?

Thanks in advance,

Steven


Heiko Behrens a écrit :
> Hey Steven,
>
> the problem here is that Xtext tries to find a proper feature that
> corresponds to "foo+=AnotherRule" in your meta model. Each assignment
> has to match with respect to its name, cardinality and type.
>
> Just looking at your snippet I would guess that AnotherRules does not
> return the proper type for the given feature foo defined in your
> existing meta model.
>
> This should work:
>
> MyRule returns ConcreteClass:
> foo=AnotherRule;
>
> AnotherRule returns TypeOfFeatureFooInConcreteClass:
> some?="rule that matches return type";
>
> Also, please be aware that "+=" and "=" expect different configurations
> of your meta model. The former expects a multi value containment feature
> where as the latter expect a single value containment.
>
> Hope that helps,
> Heiko
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #43512 is a reply to message #43419] Fri, 08 May 2009 06:37 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
You use namespace URIs this implies that you have installed both
EPackages into the workbench. Did you?
We also need to have a look at the EPackages in order track the problem
down.

Sven


Steven Derrien schrieb:
> Hello Heiko,
>
> Thank you for your help.
>
> Actually my example was not correct, since my DSL involves
> cross-references. Here is the actual code snippet :
>
> import "http://www.irisa.fr/cairn/datapath/fsm" as fsm
> import "http://www.irisa.fr/cairn/datapath/port" as ports
>
> ...
>
> FSMRule returns fsm::FSM :
> ports+=InputPortRule terms+=PredicateTermRule;
>
>
> InputPortRule returns ports::InControlPort:
> name=ID;
>
> PredicateTermRule returns fsm::PredicateTerm :
> (negated?=('!'))? flag=[ports::InControlPort];
> ^^^^
>
> It is the flag feature that causes the error message :
>
> "Cannot find compatible feature flag in sealed EClass PredicateTerm from
> imported package http://www.irisa.fr/cairn/datapath/fsm."
>
> In the ecore file defining the fsm package, the EClass *PredicateTerm*
> has a EReference feature named *flag* of type *InControlPort*, with
> upperBound set to 1, and containment set to false.
>
> Unless I am missing something obvious, everything seems consistent
> to me (I double-checked before writing this mail).
>
> Do you have any hints ?
>
> Thanks in advance,
>
> Steven
>
>
> Heiko Behrens a écrit :
>> Hey Steven,
>>
>> the problem here is that Xtext tries to find a proper feature that
>> corresponds to "foo+=AnotherRule" in your meta model. Each assignment
>> has to match with respect to its name, cardinality and type.
>>
>> Just looking at your snippet I would guess that AnotherRules does not
>> return the proper type for the given feature foo defined in your
>> existing meta model.
>>
>> This should work:
>>
>> MyRule returns ConcreteClass:
>> foo=AnotherRule;
>>
>> AnotherRule returns TypeOfFeatureFooInConcreteClass:
>> some?="rule that matches return type";
>>
>> Also, please be aware that "+=" and "=" expect different
>> configurations of your meta model. The former expects a multi value
>> containment feature where as the latter expect a single value
>> containment.
>>
>> Hope that helps,
>> Heiko
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #43662 is a reply to message #43512] Fri, 08 May 2009 09:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sderrienREMOVE.irisa.fr

Hi Sven,

Sven Efftinge a écrit :

> You use namespace URIs this implies that you have installed both
> EPackages into the workbench. Did you?

Yes, I can see them in the EMF package registry view. Anyhow, if
packages are not registered, the Xtext editor shows an error directly on
the corresponding *import* line.

> We also need to have a look at the EPackages in order track the problem
> down.

I'll see If I can send them to you by mail.

Thanks for the support.

Steven

>
> Sven
>
>
> Steven Derrien schrieb:
>> Hello Heiko,
>>
>> Thank you for your help.
>>
>> Actually my example was not correct, since my DSL involves
>> cross-references. Here is the actual code snippet :
>>
>> import "http://www.irisa.fr/cairn/datapath/fsm" as fsm
>> import "http://www.irisa.fr/cairn/datapath/port" as ports
>>
>> ...
>>
>> FSMRule returns fsm::FSM :
>> ports+=InputPortRule terms+=PredicateTermRule;
>>
>>
>> InputPortRule returns ports::InControlPort:
>> name=ID;
>>
>> PredicateTermRule returns fsm::PredicateTerm :
>> (negated?=('!'))? flag=[ports::InControlPort];
>> ^^^^
>>
>> It is the flag feature that causes the error message :
>>
>> "Cannot find compatible feature flag in sealed EClass PredicateTerm
>> from imported package http://www.irisa.fr/cairn/datapath/fsm."
>>
>> In the ecore file defining the fsm package, the EClass *PredicateTerm*
>> has a EReference feature named *flag* of type *InControlPort*, with
>> upperBound set to 1, and containment set to false.
>>
>> Unless I am missing something obvious, everything seems consistent
>> to me (I double-checked before writing this mail).
>>
>> Do you have any hints ?
>>
>> Thanks in advance,
>>
>> Steven
>>
>>
>> Heiko Behrens a écrit :
>>> Hey Steven,
>>>
>>> the problem here is that Xtext tries to find a proper feature that
>>> corresponds to "foo+=AnotherRule" in your meta model. Each assignment
>>> has to match with respect to its name, cardinality and type.
>>>
>>> Just looking at your snippet I would guess that AnotherRules does not
>>> return the proper type for the given feature foo defined in your
>>> existing meta model.
>>>
>>> This should work:
>>>
>>> MyRule returns ConcreteClass:
>>> foo=AnotherRule;
>>>
>>> AnotherRule returns TypeOfFeatureFooInConcreteClass:
>>> some?="rule that matches return type";
>>>
>>> Also, please be aware that "+=" and "=" expect different
>>> configurations of your meta model. The former expects a multi value
>>> containment feature where as the latter expect a single value
>>> containment.
>>>
>>> Hope that helps,
>>> Heiko
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #656376 is a reply to message #43662] Fri, 25 February 2011 11:19 Go to previous messageGo to next message
Amine is currently offline AmineFriend
Messages: 9
Registered: April 2010
Location: France
Junior Member

Hi gays,

I just jumped into the same issue and can't find any solution.

The problem is that I'm writing a FSM (FinitStateMachine) like DSL.
In the FSM, there is two type of nodes: controlNodes and simpleNodes.
I have an abstract node in my ecore which is an abstract super class for both nodes.
Both nodes have an id, so the id belongs to the AbstractNode and concrete node will inherit it.

The problem is, when I write some thing like :
ControlNode returns ControlNode:
 {ControlNode}
 	( 'ControlNode' id=EString 
         ...


I got the runtime error :
 java.lang.IllegalArgumentException: ControlNode.id does not exist


So, How can I assign a value to the id when creating an instance for my concrete steps.

Thanks

[Updated on: Fri, 25 February 2011 11:19]

Report message to a moderator

Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #656396 is a reply to message #656376] Fri, 25 February 2011 12:47 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Amine,

where do you get the runtime exception from? Does it occur when you
generate your language? Or when you edit your language files? In the
grammar editor?

Please make sure that your plugin.xml files are all up-to date (a quick
diff with the plugin.xml_gen will help).

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 25.02.11 12:19, schrieb Amine:
> Hi gays,
> I just jumped into the same issue and can't find any solution.
> The problem is that I'm writing a FSM (FinitStateMachine) like DSL. In
> the FSM, there is two type of nodes: controlNodes and simpleNodes. I
> have an abstract node in my ecore which is an abstract super class for
> both nodes. Both nodes have an id, so the id belongs to the AbstractNode
> and concrete node will inherit it.
> The problem is, when I write some thing like :
>
> ControlNode returns ControlNode:
> {ControlNode}
> ( 'ControlNode' id=EString ...
>
>
> I got the runtime error :
>
> java.lang.IllegalArgumentException: ControlNode.id does not exist
>
>
> So, How can I assign a value to the id when creating an instance for my
> concrete steps.
> Thanks
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #656713 is a reply to message #656396] Mon, 28 February 2011 08:51 Go to previous messageGo to next message
Amine is currently offline AmineFriend
Messages: 9
Registered: April 2010
Location: France
Junior Member

Hi Sebastian,

Thank you for your response.
My error came when I try to edit my language files.

I think that it is not the way to assign a value to a feature that belongs to the superclass. I'm I wrong ?

Thanks
Amine
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #656754 is a reply to message #656713] Mon, 28 February 2011 12:42 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
The assignment should work for all (local and inherited) features.
How does your EString rule look like? Does it return a value that is
compatible to the type of the AbstractNode.id attribute? Do you define
the Ecore model yourself? Is it error free and registered correctly in
the plugin.xml?

Am 28.02.11 09:51, schrieb Amine:
> Hi Sebastian,
>
> Thank you for your response. My error came when I try to edit my
> language files.
> I think that it is not the way to assign a value to a feature that
> belongs to the superclass. I'm I wrong ?
> Thanks
> Amine


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #656759 is a reply to message #656754] Mon, 28 February 2011 13:11 Go to previous messageGo to next message
Amine is currently offline AmineFriend
Messages: 9
Registered: April 2010
Location: France
Junior Member

Jan Koehnlein wrote on Mon, 28 February 2011 07:42
The assignment should work for all (local and inherited) features.
How does your EString rule look like? Does it return a value that is
compatible to the type of the AbstractNode.id attribute? Do you define




My EString rule works for attributes owned by subclasses and the compatibility is fine. Here is its code:
EString returns ecore::EString:
	STRING | ID;


Quote:
the Ecore model yourself? Is it error free and registered correctly in
the plugin.xml?

Yes, I have an already defined Ecore and my xText editor is about to create models conform to my Ecore metamodel.
It's error free and registered correctly (since it works without the inheritance staff).

Amine


Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #657047 is a reply to message #656759] Tue, 01 March 2011 12:53 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
And what is the signature of the AbstractNode.id attribute?

Am 28.02.11 14:11, schrieb Amine:
> Jan Koehnlein wrote on Mon, 28 February 2011 07:42
>> The assignment should work for all (local and inherited) features.
>> How does your EString rule look like? Does it return a value that is
>> compatible to the type of the AbstractNode.id attribute? Do you define
>
>
> My EString rule works for attributes owned by subclasses and the
> compatibility is fine. Here is its code:
>
> EString returns ecore::EString:
> STRING | ID;
>
>
> Quote:
>> the Ecore model yourself? Is it error free and registered correctly in
>> the plugin.xml?
>
> Yes, I have an already defined Ecore and my xText editor is about to
> create models conform to my Ecore metamodel. It's error free and
> registered correctly (since it works without the inheritance staff).
>
> Amine
>
>
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #657049 is a reply to message #657047] Tue, 01 March 2011 13:14 Go to previous messageGo to next message
Amine is currently offline AmineFriend
Messages: 9
Registered: April 2010
Location: France
Junior Member

The AbstractNode.id attribute is an EString too.

ControlNode returns ControlNode:
 {ControlNode}
 	( 'ControlNode' id=EString ':'
 		...
 	);


Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #657152 is a reply to message #657049] Tue, 01 March 2011 17:35 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Amine,

I guess Jan meant the signature of the actual EClass / Java class, e.g.
something like
public String getId() { .. }
in AbstractNode.java.

Please provide this snippet as well.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 01.03.11 14:14, schrieb Amine:
> The AbstractNode.id attribute is an EString too.
>
>
> ControlNode returns ControlNode:
> {ControlNode}
> ( 'ControlNode' id=EString ':'
> ...
> );
>
>
>
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #657330 is a reply to message #657152] Wed, 02 March 2011 13:27 Go to previous messageGo to next message
Amine is currently offline AmineFriend
Messages: 9
Registered: April 2010
Location: France
Junior Member

Hi,

Problem solved, I just changed the name of the attribute from "id" to "name" and it works !!! Shocked

I don't have any explanation to this. I also tried to do the reverse thing for other attributes that was used to identify the objects from "name" to "id" and had the same issue !!!

Is this probably a bug ? or am I just doing something wrong.

Many thanks

Amine
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #657333 is a reply to message #657330] Wed, 02 March 2011 13:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

Xtext references work (by default) though a feature (attribute) called "name". You can change this by using a own IQualifiedNameProvider

So this works out of the box:

ThingIWantToReference:
 "thing" name=ID;

Reference:
  "ref" thing=[ThingIWantToReference];


and this with a changed NameProvider

ThingIWantToReference:
 "thing" afeature=ID;

Reference:
  "ref" thing=[ThingIWantToReference];


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtext] Problem : Cannot find compatible feature foo in sealed EClass [message #671499 is a reply to message #43269] Wed, 18 May 2011 06:50 Go to previous message
Martin Domig is currently offline Martin DomigFriend
Messages: 12
Registered: August 2010
Junior Member
I just found the following while googling for the same problem, posting it here so that others don't have to:

Check your model containment attributes.

I had an ecore model containing a multi-valued reference to another class, but forgot to set the containment flag on the reference. The result was the "incompatible feature" error.

Check this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=316610


Hope this helps.
Previous Topic:Help with dot operator implementation
Next Topic:White Spaces into keywords of Xtext grammar
Goto Forum:
  


Current Time: Fri Sep 20 12:54:40 GMT 2024

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

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

Back to the top