|
Re: creating services with lambda arguments [message #1861440 is a reply to message #1861318] |
Thu, 12 October 2023 13:24 |
|
The sources of LambdaValue is visible here: https://github.com/eclipse-acceleo/acceleo/blob/master/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/runtime/impl/LambdaValue.java
Though I'm not sure it helps.
It's the runtime type of "code blocks" in AQL expression, as in:
Sequence{'a', 'b', 'c'}->collect(str | str.toUpper())
"Sequence{'a', 'b', 'c'}" evaluates to a Java List, and "str | str.toUpper()" into a LambdaValue, so AQL invokes the "collect(List<?> sequence, LambdaValue lambda)" Java service method defined here: https://github.com/eclipse-acceleo/acceleo/blob/master/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/services/CollectionServices.java#L596 with the list value as "sequence" and a LambdaValue representing the code block "str | str.toUpper()" as "lambda".
I've never tried it myself, but it should be possible to use the same patterns in your own Java services.
AFAIK, the ones AQL defines in its standard library like in CollectionServices have no special treatment/super-power; it's just that they are available by default.
EDITED: Actually it looks like the AQL parser will only accept this kind of code blocks (and produce LambaValue for them) for a fixed set of services (collect being one of them): https://github.com/eclipse-acceleo/acceleo/blob/079024efac839526674ae37876437037fe5b1f9c/query/plugins/org.eclipse.acceleo.query/src/org/eclipse/acceleo/query/parser/Query.g4#L71. So it seems that it is not possible to use this pattern for your own services.
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
[Updated on: Thu, 12 October 2023 13:33] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03900 seconds