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


##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/TextBodyFlow.java:
##########
@@ -171,16 +214,25 @@ Set<String> readable() {
      * What a walk knows besides the body: the route, the routes of the file, 
where reports go (null for a route a step
      * calls, which reports from its own walk), whether an http producer sends 
the body with POST, the verbs of the
      * OpenAPI operations a rest-openapi call can be judged by (empty when a 
REST binding may write the body), with the
-     * fields their JSON requests need, and the body types of the catalog.
+     * fields their JSON requests need, the body types of the catalog, and 
what is known about the variables of the
+     * message.
      */
     private record Walk(String routeId, Map<String, JsonNode> byFrom, 
List<Error> errors, Set<String> seen, boolean post,
             Map<String, Map<String, String>> operations, Map<String, 
Map<String, List<String>>> requestFields,
             Map<String, ProjectFacts.Observed> observed, CatalogBodyTypes 
bodyTypes,
-            Map<String, ProjectFacts.KameletDataTypes> kamelets) {
+            Map<String, ProjectFacts.KameletDataTypes> kamelets, Map<String, 
Body> variables) {
 
-        /** The walk of a route a step calls: for its outcome alone. */
+        /** The walk of a route a step calls: for its outcome alone, and the 
variables of the message it changes. */
         Walk called() {

Review Comment:
   💬 **Clarification:** The Javadoc already says `called()` is for the outcome 
of the called route and for the variables the message changes — but it doesn't 
make it explicit *why* `variables` is shared (same `Map` reference) while 
`branch()` copies it. Adding a word or two would make the intent clear without 
requiring the reader to diff `branch()` and `called()` side by side:
   
   ```suggestion
           /** The walk of a route a step calls: for its outcome alone, and the 
variables of the message it changes.
            * The called route operates on the same Exchange, so variable 
mutations must be visible to the caller.
            */
           Walk called() {
   ```



##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/TextBodyFlow.java:
##########
@@ -134,6 +152,27 @@ final class TextBodyFlow {
     /** The REST binding modes that write a Map or a List for the route. */
     private static final Set<String> BINDS = Set.of("auto", "json", "xml", 
"json_xml");
 
+    /** The steps that send the body to an endpoint, and can need it as text. 
*/
+    private static final Set<String> SENDS_THE_BODY = Set.of("to", "toD", 
"wireTap", "enrich");
+
+    /** The steps whose uri, and whose endpoint options, are simple templates 
read for each message. */
+    private static final Set<String> TEMPLATE_URIS = Set.of("to", "toD", 
"wireTap");
+
+    /** The steps that may set any variable, which the walk then forgets. */
+    private static final Set<String> SETS_VARIABLES = Set.of("bean", 
"process", "script", "setVariables",
+            "removeVariables", "convertVariableTo", "kamelet", "claimCheck");
+
+    /** The components whose endpoint is a route, which may set variables of 
the message. */
+    private static final Set<String> ROUTES = Set.of("direct", "seda", 
"direct-vm", "vm", "kamelet");
+
+    /** What a block that may set variables has in it: a step that does, or a 
call of a route. */
+    private static final List<String> MAY_SET_VARIABLES = List.of("ariable", 
"\"bean\"", "\"process\"", "\"script\"",

Review Comment:
   💬 **Clarification:** `"ariable"` without the leading `v` is a smart trick to 
match `setVariable`, `removeVariable`, `variableSend`, `variableReceive`, 
`convertVariableTo`, etc. in one substring. A future reader will wonder why 
`"variable"` wasn't used instead. A one-line comment would save the detour:
   
   ```suggestion
       /** What a block that may set variables has in it: a step that does, or 
a call of a route. */
       // "ariable" (not "variable") matches setVariable, removeVariable, 
variableSend, variableReceive,
       // convertVariableTo, etc. in one substring, without matching the 
component name "direct" or "seda".
       private static final List<String> MAY_SET_VARIABLES = List.of("ariable", 
"\"bean\"", "\"process\"", "\"script\"",
   ```



-- 
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