Problem with Xtext based OCL and accessing inherited properties [message #799075] |
Wed, 15 February 2012 12:14 |
Filip Krikava Messages: 45 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:
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 275 times)
[Updated on: Wed, 15 February 2012 12:16] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03324 seconds