[Acceleo] Strange behavior for queries using the "iterate" method [message #1767836] |
Tue, 11 July 2017 13:27  |
Mad Vin Messages: 40 Registered: September 2013 |
Member |
|
|
Hello,
Here is the code of simple queries of a module (no need to comment about the stupidity of the code of these queries, the important thing is to understand the behaviour at compilation and execution) :
[query private getStr(aString : String) : String = aString/]
[query private createStr(contextObj : OclAny, s : String) : String = 'Create ' + s/]
[query public mainQuery(contextObj : OclAny) : String =
OrderedSet{'blabla', 'miammiam'}->iterate(str : String; result : String = 'result=' | result + ' ' + createStr(str)).getStr()/]
At the execution of the "mainQuery" query with the contextObj as a Class, you got the following error :
java.lang.UnsupportedOperationException: Operation createStr(String) is undefined on type org.eclipse.uml2.uml.internal.impl.ClassImpl.
If you remove the call to "getStr()" at the end of the "mainQuery", the execution is OK... But why the behavior of the call to "createStr(str)" inside the "iterate" expression is different with the call to "getStr()" at the end ? I suppose there is something i don't understand with the "iterate" method...
You can see this different behavior at the compilation : if you make a CTRL + mouse click on the call to "createStr(str)" in the "iterate", the editor selects the "createStr" query in the module when it's ok (without the call to "getStr()" at the end), and when it's not ok (with the call to "getStr()" at the end), it opens and selects in the .emtl file view of the module the "createStr(String) : String" method applied on "OclAny_Class" .
Thank you.
Best regards.
Version : Acceleo 3.4.1
[Updated on: Tue, 11 July 2017 13:49] Report message to a moderator
|
|
|
|
|
|
Re: [Acceleo] Strange behavior for queries using the "iterate" method [message #1767847 is a reply to message #1767845] |
Tue, 11 July 2017 14:39   |
Mad Vin Messages: 40 Registered: September 2013 |
Member |
|
|
I don't see how Acceleo can be confused, even if you execute the code like this, it doesn't work :
[query public mainQuery(contextObj : OclAny) : String =
(OrderedSet{'blabla', 'miammiam'}->iterate(str : String; result : String = 'result=' | result + ' ' + contextObj.createStr(str))).getStr()/]
Even like this :
[query public mainQuery(contextObj : OclAny) : String =
getStr(OrderedSet{'blabla', 'miammiam'}->iterate(str : String; result : String = 'result=' | result + ' ' + contextObj.createStr(str)))/]
I think there is clearly a problem with the compilator in that way.
[Updated on: Tue, 11 July 2017 14:43] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03172 seconds