Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Problem with variables
Problem with variables [message #41018] Wed, 17 October 2007 14:08 Go to next message
Eclipse UserFriend
Originally posted by: mike.aol.com

I'm using OCL 1.0.1 (I have to) and am having a problem getting
variables to work as parameters to EMF operations. For example:

I have an EMF class Foo with operation bar taking one argument of type
String. The instance foo is of type Foo. When I define a variable in my
environment of type String and pass it to Foo.bar, I get an error like this:
Cannot find operation (bar(String)) for the type (Foo))

Using the debugger, I see where the problem occurs.
TypeUtils.matchArgs() tries to match the arg with the parm. Both are
instances of PrimitiveStringImpl (good!). It ends up calling
PrimitiveStringImpl.getRelationshipTo() which has this as the first test:
if(this == type) return SAME_TYPE

This test fails! It fails because "this" is not the same instance as
"type" though they are both instances of PrimitiveStringImpl.

I really must be able to use variables, and I'm willing to patch the
plugin or use a workaround. Any suggestions?

Thanks,
Mike Gering
Re: Problem with variables [message #41080 is a reply to message #41018] Wed, 17 October 2007 14:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mike.aol.com

I found I caused the problem myself when I created the variable and put
it into the ocl environment. I used the EMF factory method to create the
variable type, PrimitiveString. Instead, I now use
PrimitiveStringImpl.INSTANCE. This seems to work fine. If there is a
better way, please let me know.

Mike Gering
Re: Problem with variables [message #41111 is a reply to message #41080] Wed, 17 October 2007 14:42 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Mike,

Good self-catch!

In OCL 1.0, you would rather do Types.OCL_STRING (which is an alias for the
ugly impl).

Cheers,

Christian


Mike Gering wrote:

> I found I caused the problem myself when I created the variable and put
> it into the ocl environment. I used the EMF factory method to create the
> variable type, PrimitiveString. Instead, I now use
> PrimitiveStringImpl.INSTANCE. This seems to work fine. If there is a
> better way, please let me know.
>
> Mike Gering
Previous Topic:Finding all decendants of a Classifier
Next Topic:[Announce] MDT OCL 1.2.0 I200710171533 is available
Goto Forum:
  


Current Time: Wed Apr 24 22:25:50 GMT 2024

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

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

Back to the top