Problem with variables [message #41018] |
Wed, 17 October 2007 14:08 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03342 seconds