Passing a Type as parameter in acceleo always results in AnyType [message #1843459] |
Fri, 30 July 2021 14:07 |
Thomas Barth Messages: 22 Registered: March 2021 |
Junior Member |
|
|
I want to pass a Type to a query.
However, whenever I try:
[query public Test(T : OclType) : String = T.toString()/]
I get:
org.eclipse.ocl.ecore.impl.AnyTypeImpl@12dbef96 (name: T) (instanceClassName: null)
.toString() directly at the type gives me the expected result, e.g.:
org.eclipse.emf.ecore.impl.EClassImpl@1f799f4c (name: TechnicalFunction) (instanceClassName: null) (abstract: false, interface: false)
Version:
[Updated on: Fri, 30 July 2021 14:08] Report message to a moderator
|
|
|
|
|
Re: Passing a Type as parameter in acceleo always results in AnyType [message #1843464 is a reply to message #1843463] |
Fri, 30 July 2021 20:22 |
Thomas Barth Messages: 22 Registered: March 2021 |
Junior Member |
|
|
Hi Ed,
thanks for the insight!
Yeah, I tried to use the passed type as kind of template parameter, e.g.:
[query public Test(any : OclAny, tpe : OclType) : OrderedSet(tpe ) = any.eInverse(tpe )/]
However, it seems like the signature cannot contain "template" parameters (though I could simply use a common base-class) and also OCL is not happy about variable types.
The query I want to write will only use 3 types, I can check for the passed type with if-statements and have static typed queries or is there another way? For now I have 3 times the same query with different types, which is not too elegant I think.
[Updated on: Fri, 30 July 2021 22:42] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03972 seconds