Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Using oclIsTypeOf() with a variable argument
Using oclIsTypeOf() with a variable argument [message #870888] Thu, 10 May 2012 07:41 Go to next message
Eclipse UserFriend
Hi,

I want specify the type argument in oclIsTypeOf(OclType) as a variable,
for example like so:

var searchType : String := "MyClass";
someSet->select(o | o->oclIsTypeOf(searchType);

Is something this this possible?

Regards
Marius
Re: Using oclIsTypeOf() with a variable argument [message #870905 is a reply to message #870888] Thu, 10 May 2012 08:43 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The status of type-valued expressions is pretty unclear in the OCL
specification; it could be argued that even oclIsTypeOf(Integer) is
unparseable.

The thinking for OCL 2.5, that is prototyped in the pivot-binding of
Eclipse OCL is that type-valued and potentially element-valued
expressions should be no different from datatype and object-valued
expressions.

So today if you're using the Xtext OCL Console, or the Java API for the
pivot model, some usages may be possible, although I'm fairly sure that
I've fixed some relevant issues for Juno, so the Indigo release may be
flaky in this area.

Your specific text makes no sense, since you're mixing string-valued and
type-valued arguments without providing an overload.

You should be able to do, in OCL.

let searchType : Type = MyClass in someSet->select(oclIsKindOf(searchType))

[oclIsKindOf is nearly always better than oclIsTypeOf]

Or

let searchType : String = 'MyClass' in someSet->select(oclType().name =
searchType)

oclType() is also not implemented in the Ecore binding of Eclipse OCL,
but you can do

select(oclAsType(ecore::EObject).eClass().name = searchType)

Regards

Ed Willink





On 10/05/2012 08:41, Marius Gröger wrote:
> Hi,
>
> I want specify the type argument in oclIsTypeOf(OclType) as a variable,
> for example like so:
>
> var searchType : String := "MyClass";
> someSet->select(o | o->oclIsTypeOf(searchType);
>
> Is something this this possible?
>
> Regards
> Marius
Re: Using oclIsTypeOf() with a variable argument [message #870917 is a reply to message #870905] Thu, 10 May 2012 09:07 Go to previous message
Eclipse UserFriend
On 10.05.2012 10:43, Ed Willink wrote:
> let searchType : String = 'MyClass' in someSet->select(oclType().name =
> searchType)
>
> oclType() is also not implemented in the Ecore binding of Eclipse OCL,
> but you can do
>
> select(oclAsType(ecore::EObject).eClass().name = searchType)

Thanks!

Marius
Previous Topic:Error "ObjectDeclsCS" expected after "object"
Next Topic:Proper use of libraries
Goto Forum:
  


Current Time: Thu Apr 18 21:07:50 GMT 2024

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

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

Back to the top