Global operation for oclAny [message #1726348] |
Fri, 11 March 2016 16:33 |
Nils Przigoda Messages: 14 Registered: September 2013 Location: Bremen, Germany |
Junior Member |
|
|
Hi all,
while reading some of the last topics (e.g. 1, 2) I got the idea to play a little bit with operations inside an OCL file (not OCLinEcore).
My goal was define an operation which can be called on any OCLExpression, like e.g. oclIsUndefined can. Reading the others topics and using google was very helpful, but now I'm getting stucked at the following point:
import MyEcoreModel : 'MyEcoreModel.ecore#/'
import oclTypes : 'http://www.eclipse.org/ocl/1.1.0/OCL/Types'
context oclTypes::AnyType def: newGlobalOperation(arg : oclTypes::AnyType) : oclTypes::AnyType = null
package MyEcoreModel
context MyClass1
inv test : self.newGlobalOperation(true)
endpackage
In the invariant test there is no operation "newGlobalOperation" available, I do not understand why. Adding the operation to the class directly as follows works:
import MyEcoreModel : 'MyEcoreModel.ecore#/'
import oclTypes : 'http://www.eclipse.org/ocl/1.1.0/OCL/Types'
package MyEcoreModel
context MyClass1
def: newGlobalOperation(arg : oclTypes::AnyType) : oclTypes::AnyType = null
inv test : self.newGlobalOperation()
endpackage
But there are two problems: First, the parameter/argument has been omitted and when I'm trying to add it, the invariant could not be parsed. Second, The newGlobalOperation is only available the MyClass1, but not for MyClass2.
Can anyone help me with this problem?
Regards,
Nils
|
|
|
Re: Global operation for oclAny [message #1726350 is a reply to message #1726348] |
Fri, 11 March 2016 17:21 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
There are two Eclipse OCL's.
The Classic Eclipse OCL supports an Ecore and a UML binding. It has a
number of limitations particularly in regard to extensibility.
'http://www.eclipse.org/ocl/1.1.0/OCL/Types' is the Library URI for the
Classic implementation.
The new Unified Pivot-based Eclipse OCL prototypes an extensible
UML-aligned implementation. It has an extensible library, with an Xtext
editor for it. It also has an Xtext editor for a Complete OCL document.
Using Complete OCL you can do something like
package ocl
context OCLExpression
def newGlobalOperation(arg : OclAny) : OclAny
But as I write this, I am really confused by your example. I don't see
why you use AnyType at all to define something for OCLExpression. It is
all at the wrong metalevel. You probably want to define
package ocl
context OclElement
def newGlobalOperation(arg : OclAny) : OclAny ...
since the Pivot-based OCL prototypes an OCL specification that
OclElement is the implicit supertype of all user-defined types (e.g.
MyClass1).
[OCL 2.0 had a special type called OclElement, but did not explain what
it was for and did not use it for anything. OCL 2.2 therefore removed
it. The Pivot-based OCL re-introduces it with a modeled definition. See
http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/plugins/org.eclipse.ocl.pivot/model/OCL-2.5.oclstdlib
]
Regards
Ed Willink
On 11/03/2016 16:33, Nils Przigoda wrote:
> Hi all,
>
> while reading some of the last topics (e.g.
> https://www.eclipse.org/forums/index.php/t/1074939/,
> https://www.eclipse.org/forums/index.php/t/1073767/) I got the idea to
> play a little bit with operations inside an OCL file (not OCLinEcore).
>
> My goal was define an operation which can be called on any
> OCLExpression, like e.g. oclIsUndefined can. Reading the others topics
> and using google was very helpful, but now I'm getting stucked at the
> following point:
>
>
> import MyEcoreModel : 'MyEcoreModel.ecore#/'
> import oclTypes : 'http://www.eclipse.org/ocl/1.1.0/OCL/Types'
>
> context oclTypes::AnyType def: newGlobalOperation(arg :
> oclTypes::AnyType) : oclTypes::AnyType = null
>
> package MyEcoreModel
> context MyClass1
> inv test : self.newGlobalOperation(true)
> endpackage
>
>
> In the invariant test there is no operation "newGlobalOperation"
> available, I do not understand why. Adding the operation to the class
> directly as follows works:
>
>
> import MyEcoreModel : 'MyEcoreModel.ecore#/'
> import oclTypes : 'http://www.eclipse.org/ocl/1.1.0/OCL/Types'
>
> package MyEcoreModel
> context MyClass1
> def: newGlobalOperation(arg : oclTypes::AnyType) :
> oclTypes::AnyType = null
> inv test : self.newGlobalOperation() endpackage
>
>
> But there are two problems: First, the parameter/argument has been
> omitted and when I'm trying to add it, the invariant could not be
> parsed. Second, The newGlobalOperation is only available the MyClass1,
> but not for MyClass2.
>
> Can anyone help me with this problem?
>
> Regards,
> Nils
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03709 seconds