davsclaus opened a new pull request, #27172: URL: https://github.com/apache/camel/pull/27172
_Claude Code on behalf of davsclaus_ JIRA: https://issues.apache.org/jira/browse/CAMEL-25208 The editing help of the TUI Source tab (validation, quick doc, completion) was for the YAML DSL only. XML files were only checked to be well formed, and Java files only by javac, which cannot see inside the strings, where most Camel mistakes are (endpoint uris and their options, simple expressions, `to` vs `toD`). Instead of repeating the YAML line patterns per DSL, this adds one model-based layer in camel-jbang-core, usable by any tool (TUI, MCP, CLI). It is shaped like the operations of a language server, without the protocol. ### Core (camel-jbang-core) - **`RouteModel`** reads a Java DSL source (LwJavaParser) or an XML DSL source (camel-xml-io `ModelParser`) into the Camel model with lines, without compiling or running it. For Java the endpoint DSL and constants are resolved. - **`RouteNodes`** lists the steps, endpoints and expressions by line. An expression is put on the line its text is on: the `<simple>` element, or a `simple("...")` on a later line. - **`ModelChecks`** runs the checks the YAML DSL has, on the model: - endpoint uris against the catalog; - simple syntax (predicate or expression by the EIP); - a `to` whose uri holds `${...}`, which should be a `toD`; - a producer-only component as `from`; - several endpoints in one uri; - `direct:`/`seda:` endpoints no route consumes; - XML elements the XML DSL does not have. A value the parser could not know is left unchecked. - **`RouteAssist`** is the entry point: `diagnostics(...)` and `nodes(...)`. - The per-uri and per-expression checks of `EndpointChecks` and `SimpleChecks` are shared with the YAML checks. ### Validation (CLI, MCP) `SourceValidator.validate` adds these checks for `.java` files (after javac) and Camel `.xml` files. That covers `camel validate source`, `camel_validate_source` and `camel_write_file`. `camel_validate_source` also lists what the parser could not read (`notChecked`). ### Precision The checks were run over about 3700 route files: camel-examples, camel-jbang-examples, the Spring Boot and Quarkus examples, camelinaction2, and Camel's own tests. There were no crashes, and the run takes about 10 seconds. The false positives this found are fixed in the shared code, so the YAML checks lose them too: - `exchangePattern` on a `to` (SendProcessor reads it from the uri); - kamelet parameters; - map options written `name[key]`; - `simple("resource:...")` scripts; - application classes and custom simple functions; - CDI `beans.xml` files. ### TUI Source tab - Java and XML routes are checked while typing and on save, with the problems marked on their lines (F9 jumps to the next). An XML file with problems is not saved, as for YAML. A Java file is saved and its problems are reported. - Quick doc for Java and XML: the component and options of an endpoint, the EIP of a step, the language of its expression. It also works when no integration is selected. - Tab completion in endpoint uris, in Java strings and XML `uri` attributes: component names, options and their values. - The completion popup puts an exact or prefix match first (`seda` before `hazelcast-seda`, YAML too). Option docs keep their first sentence whole (they were cut at the dot of "i.e."). - Tested live in the TUI through its MCP server; the problems found that way are fixed in this PR. ### Docs TUI page, F1 help, devtools (`camel validate`), MCP tool table, and an upgrade guide note (4.23): files that validated before can now report errors. Simple language completion is a follow-up: CAMEL-25219. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
