[ 
https://issues.apache.org/jira/browse/CAMEL-25208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18121344#comment-18121344
 ] 

Claus Ibsen commented on CAMEL-25208:
-------------------------------------

Progress (local commits on branch feature/CAMEL-25208-code-assist, not pushed 
yet):

*Core (camel-jbang-core), for any tool*
* RouteModel reads a Java (LwJavaParser) or XML (ModelParser) DSL source into 
the Camel model with lines; RouteNodes lists its steps, endpoints and 
expressions by line; ModelChecks runs the checks the YAML DSL has on that 
model; RouteAssist is the entry point (diagnostics, nodes by line), shaped like 
the operations of a language server without the protocol.
* Checks: endpoint uris against the catalog (also built with the endpoint DSL 
or from constants; options written on their own line reported there), simple 
syntax (predicate or expression by the EIP), a to whose uri holds ${...} (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. What the 
parser could not read is left unchecked and listed (camel_validate_source 
notChecked).
* SourceValidator.validate adds them for .java and Camel .xml files: camel 
validate source, camel_validate_source and camel_write_file get them.
* Precision: run over ~3700 route files (camel-examples, camel-jbang-examples, 
the Spring Boot and Quarkus examples, camelinaction2, Camel's own tests), no 
crash, ~10 s. The false positives found were 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 functions, CDI beans.xml.

*TUI Source tab*
* Java and XML routes are checked while typing and on save; problems marked on 
their lines (F9), said on save, never blocking it.
* Quick doc panel for Java and XML (component + options of an endpoint, EIP, 
language of the expression), also with no integration selected.
* Tab completion in the endpoint uris of Java strings and XML uri attributes: 
component names, options, values.
* Completion popup puts an exact or prefix match first (seda before 
hazelcast-seda, YAML too); option docs keep their first sentence whole ("(i.e." 
was cut).
* Tested live in the TUI through its MCP server.

_Claude Code on behalf of davsclaus_


> camel-jbang - Camel validation and code assistance for Java and XML DSL 
> routes (model based)
> --------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25208
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25208
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jbang
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>
> The editing help of the TUI Source tab (quick doc, autocomplete, validation) 
> is for the YAML DSL only. XML files are only checked to be well formed, and 
> Java files only get the diagnostics of javac, which cannot see inside strings 
> where most Camel mistakes are (endpoint URIs and their options, simple 
> expressions, to vs toD).
> The YAML help is built from YAML-shaped line patterns. Instead of repeating 
> that per DSL, add one model-based layer in camel-jbang-core: parse the source 
> into route definitions with line numbers (LwJavaParser for Java, ModelParser 
> for XML), find the node on a line, and run Camel checks on the model and ask 
> the catalog about the node.
> The API is shaped like the operations of a language server (diagnostics, 
> hover, completion with line and column) without the protocol, so the TUI, the 
> MCP tools (camel_validate_source) and the camel validate CLI call it 
> in-process, and other tools could use it later.
> First part (this ticket):
> * Camel validation of Java and XML routes: endpoint URIs (unknown options, 
> invalid values, missing required path) including the endpoint DSL, simple 
> expression syntax, to with an expression that needs toD, direct/seda 
> endpoints no route consumes, and what the parser could not read reported as 
> information.
> * Quick doc for Java and XML routes in the TUI Source tab (EIP, endpoint and 
> language docs by line).
> * Autocomplete inside the strings of Java routes where it is simple 
> (component names, endpoint options, simple functions), working on half-edited 
> files.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to