gnodet-bot commented on code in PR #27585:
URL: https://github.com/apache/camel/pull/27585#discussion_r4223900303


##########
components/camel-dataweave/src/main/java/org/apache/camel/component/dataweave/DataWeaveConverter.java:
##########
@@ -153,12 +158,14 @@ private String emitNode(DataWeaveAst node) {
             return emitAttributeAccess(aa);
         } else if (node instanceof ExistenceCheck ec) {
             return emitExistenceCheck(ec);
+        } else if (node instanceof DoubleDollar && shorthandDoubleDollar != 
null) {
+            return shorthandDoubleDollar;
         } else if (node instanceof DoubleDollar) {
-            // $$ means accumulator only inside reduce. In 
map/filter/mapObject/pluck it means index or key.
-            // Outside the reduce-shorthand emitter this context is unknown, 
so emit a TODO.
+            // $$ means accumulator inside reduce and index inside map. In 
filter/mapObject/pluck it means index or key,
+            // which is not supported, so emit a TODO.

Review Comment:
   💡 **Minor:** The comment lists `filter/mapObject/pluck` but omits other 
DataWeave functions that also support `$$` as an index/key (e.g. `groupBy`, 
`orderBy`, `distinctBy`, `flatMap`). Consider using a more inclusive phrasing 
such as:
   
   ```suggestion
               // $$ means accumulator inside reduce and index inside map. In 
other contexts
               // (filter, mapObject, pluck, groupBy, etc.) it means index or 
key,
   ```



##########
components/camel-dataweave/src/main/java/org/apache/camel/component/dataweave/DataWeaveConverter.java:
##########
@@ -153,12 +158,14 @@ private String emitNode(DataWeaveAst node) {
             return emitAttributeAccess(aa);
         } else if (node instanceof ExistenceCheck ec) {
             return emitExistenceCheck(ec);
+        } else if (node instanceof DoubleDollar && shorthandDoubleDollar != 
null) {
+            return shorthandDoubleDollar;
         } else if (node instanceof DoubleDollar) {
-            // $$ means accumulator only inside reduce. In 
map/filter/mapObject/pluck it means index or key.
-            // Outside the reduce-shorthand emitter this context is unknown, 
so emit a TODO.
+            // $$ means accumulator inside reduce and index inside map. In 
filter/mapObject/pluck it means index or key,
+            // which is not supported, so emit a TODO.
             todoCount++;
             return includeComments
-                    ? "/* TODO: manual conversion needed -- $$ outside reduce 
context */" + "\nnull"
+                    ? "/* TODO: manual conversion needed -- $$ outside map and 
reduce */" + "\nnull"

Review Comment:
   💡 **Nit:** The TODO message `$$ outside map and reduce` may be slightly 
confusing when encountered inside `filter`, `mapObject`, or `pluck`, where `$$` 
is technically supported by DataWeave (as index/key) but not handled by the 
converter. A more precise wording would be:
   
   ```suggestion
                       ? "/* TODO: manual conversion needed -- $$ is only 
supported in map (as index) and reduce (as accumulator) */" + "\nnull"
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to