| Summary: | Inconsistent query evaluation | ||
|---|---|---|---|
| Product: | [Modeling] Acceleo | Reporter: | Ed Willink <ed> |
| Component: | Core | Assignee: | Project Inbox <acceleo-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | laurent.goubet, stephane.begaudeau |
| Version: | 3.0.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows Vista | ||
| Whiteboard: | |||
Ed,
I must admit that I have no idea as to why we wouldn't be able to find the proper operation call in the second case except ... what would be the priority of both operations?
i.e, does it evaluate correctly with this :
[generateJava(('list_'+getSymbolName(ast)), part)/]
I think that the parser does not manage to understand the type of its parameter when a "+" operator is embedded in there (having the "+" between Strings is one of the many things we've had to 'hack' OCL for since it takes precedence over us for this operation).
(In reply to comment #1) > one of the many things we've had to 'hack' OCL Very plausible explanation; I am consistently amazed at how accurate Acceleo is despite inaccuracy in OCL underneath. + is one of many things that are fixed by the pivot binding; + is just a modeled operator, so the library model specifies what it does. >>> 'list_'+getSymbolName(ast) evaluates to the mumbo-jumbo
>>> for invalid.
If an ocl operation uses the result of another operation as an argument and if this other operation is an Acceleo operation (aka template or query call) then the operation call is changed to a template or query operation call. This "hack" was not performed if the operation was a *non standard* operation like "+". A fix has been contributed along with a unit test for "+". The unit tests will need to be expand to test all the operation in the Acceleo non standard library. The fix will be available in Acceleo 3.1.1
This has been fixed since then. |
The following partial template works fine [template public generateJava(result : String, ast : CollectionLiteralExp)] [let listVarName : String = 'list_'+getSymbolName(ast)] [let resultVarName : String = 'result_'+getSymbolName(ast)] Value result_[getSymbolName(ast)/]; try { List<Value> [listVarName/] = new ArrayList<Value>(); [for (part : CollectionLiteralPart | ast.part)] [generateJava(listVarName, part)/] [/for] invoking [query public getSymbolName(elem : Element) : String = invoke('org.eclipse.ocl.examples.build.acceleo.NameQueries', 'getSymbolName(java.lang.Object)', Sequence{elem}) /] successfully. But if changed to [let listVarName : String = 'list_'+getSymbolName(ast)] [let resultVarName : String = 'result_'+getSymbolName(ast)] Value result_[getSymbolName(ast)/]; try { List<Value> [listVarName/] = new ArrayList<Value>(); [for (part : CollectionLiteralPart | ast.part)] [generateJava('list_'+getSymbolName(ast), part)/] [/for] the getSymbolName in 'list_'+getSymbolName(ast) evaluates to the mumbo-jumbo for invalid.