Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Problem with Xtext based OCL and accessing inherited properties
Problem with Xtext based OCL and accessing inherited properties [message #799075] Wed, 15 February 2012 12:14 Go to next message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 43
Registered: January 2012
Member
Hi,

I found a weird behavior with the Xtext based OCL editors (including console) related to properties inherited from multiple classes:

I made this model example of 4 classes A,B,C and D to demonstrate:

module _'My.ecore'
package my : my = 'http://my.me/'
{
	class A
	{
		attribute name : String[1] { ordered };
	}
	class B
	{
		attribute type : String[1] { ordered };
	}
	class C extends B, A
	{
		attribute required : Boolean[1] { ordered };
	}
	class D
	{		
		attribute main : Boolean[1] { ordered };
		
		invariant myinv:
			main implies property.name <> '' and property.type <> '';
		property property : C[1] { ordered };
		
	}
}


I got an error in the editor: unresolved property 'name' for 'My.ecore::my::C', but there is a property 'name' in type C it is inherited from A. The other inherited property 'type' works just fine.

The same happens if I try to use the Xtext OCL console from the context D: self.property.name:

My.xmi:
<?xml version="1.0" encoding="ASCII"?>
<my:D xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://my.me/" xsi:schemaLocation="http://my.me/ My.ecore">
  <property type="Type1" name="Name1"/>
</my:D>


Evaluating:
self
Results:
D false

Evaluating:
self.property.name
Results:
Parsing failure
null
Unresolved property 'name' for 'My.ecore::my::C'

Evaluating:
self.property.type
Results:
'Type1'


On the other hand from the old OCL console it works fine:

Evaluating:
self
Results:
D false

Evaluating:
self.property.name
Results:
'Name1'

Evaluating:
self.property.type
Results:
'Type1'


What is interesting that if I change the inheritance order of the class C to:

class C extends A, B


It will work file - both properties ('name' and 'type') are resolved just fine.

I don't know if it is a bug or I'm missing something?

Thanks
Filip

EDIT: added test project.
  • Attachment: ocltest.zip
    (Size: 4.76KB, Downloaded 73 times)

[Updated on: Wed, 15 February 2012 12:16]

Report message to a moderator

Re: Problem with Xtext based OCL and accessing inherited properties [message #799255 is a reply to message #799075] Wed, 15 February 2012 16:58 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi Filip

Sorry; it's a bug in the Indigo Pivot release; lookups of secondary
bases fails.

Works fine in the Juno M5 release.

Regards

Ed Willink


On 15/02/2012 12:14, Filip Krikava wrote:
> Hi,
>
> I found a weird behavior with the Xtext based OCL editors (including
> console) related to properties inherited from multiple classes:
>
> I made this model example of 4 classes A,B,C and D to demonstrate:
>
>
> module _'My.ecore'
> package my : my = 'http://my.me/'
> {
> class A
> {
> attribute name : String[1] { ordered };
> }
> class B
> {
> attribute type : String[1] { ordered };
> }
> class C extends B, A
> {
> attribute required : Boolean[1] { ordered };
> }
> class D
> {
> attribute main : Boolean[1] { ordered };
>
> invariant myinv:
> main implies property.name <> '' and property.type <> '';
> property property : C[1] { ordered };
>
> }
> }
>
>
> I got an error in the editor: unresolved property 'name' for
> 'My.ecore::my::C', but there is a property 'name' in type C it is
> inherited from A. The other inherited property 'type' works just fine.
>
> The same happens if I try to use the Xtext OCL console from the
> context D: self.property.name:
>
> My.xmi:
>
> <?xml version="1.0" encoding="ASCII"?>
> <my:D xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:my="http://my.me/" xsi:schemaLocation="http://my.me/ My.ecore">
> <property type="Type1" name="Name1"/>
> </my:D>
>
>
> Evaluating:
> self
> Results:
> D false
>
> Evaluating:
> self.property.name
> Results:
> Parsing failure
> null
> Unresolved property 'name' for 'My.ecore::my::C'
>
> Evaluating:
> self.property.type
> Results:
> 'Type1'
>
>
> On the other hand from the old OCL console it works fine:
>
>
> Evaluating:
> self
> Results:
> D false
>
> Evaluating:
> self.property.name
> Results:
> 'Name1'
>
> Evaluating:
> self.property.type
> Results:
> 'Type1'
>
>
> What is interesting that if I change the inheritance order of the
> class C to:
>
> class C extends A, B
>
> It will work file - both properties ('name' and 'type') are resolved
> just fine.
> I don't know if it is a bug or I'm missing something?
>
> Thanks
> Filip
Previous Topic:Getting the OCL File
Next Topic:[OCLInEcore] Cannot find operation
Goto Forum:
  


Current Time: Thu Nov 27 06:10:34 GMT 2014

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

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