davsclaus opened a new pull request, #27236:
URL: https://github.com/apache/camel/pull/27236

   Fixes [CAMEL-25240](https://issues.apache.org/jira/browse/CAMEL-25240).
   
   XML routes in the source editor got completion only in the `uri` attribute 
(CAMEL-25208) and in simple expressions (CAMEL-25219). Now **Tab** completes 
the XML DSL itself:
   
   | Cursor | Tab lists |
   |---|---|
   | after `<`, or on an empty line | the elements that go inside the parent 
element: the EIPs of a route, `when`/`otherwise` in a `choice`, the languages 
where an expression goes (left out once the element has its expression). 
Inserted with required attributes and end tag, the cursor where you go on: `<to 
uri="\|"/>`, `<split>\|</split>`, `<simple>\|</simple>` |
   | in a start tag | the element's attributes, required first, without the 
ones already given, with their documentation |
   | in an attribute value | enums and `true`/`false` from the catalog models, 
property placeholders; opens right after an attribute is chosen |
   | in `uri="..."` | unchanged: the uri completion |
   
   ![xml 
completion](https://raw.githubusercontent.com/apache/camel/fix/CAMEL-25240/docs/user-manual/modules/ROOT/images/jbang/camel-tui-source-xml-completion.png)
   
   ### How
   - `XmlSchemaModel`: reads `CamelCatalog.xmlIoSchemaAsXml()` (the XSD of the 
project's Camel version) once per catalog: element → type, type → attributes 
(`use="required"`, documentation) and child elements, through `xs:extension` 
bases and inline types of local elements. The XSD lists the allowed children 
per type explicitly (no substitution groups), so this stays small.
   - The XSD leaves out `required` and documentation of some inherited 
attributes (`uri` of `to`/`toD`/`wireTap` sits on the abstract 
`sendDefinition`), so the catalog EIP/language model completes them; enum 
values come from the catalog too, since XSD attribute types are `xs:string` 
(placeholders).
   - `XmlCompletionContext`: the context read from the text above the cursor 
(the tag stack through comments, CDATA, processing instructions, self-closing 
tags, start tags spread over lines, `>` in quoted values, namespace prefixes 
such as `camel:`), so it works while the file does not parse.
   - `SourceViewer`: the XML completion is tried after the simple and uri ones; 
inserts place the cursor (a caret marker in the snippet). `openUriAutocomplete` 
now says whether the cursor was in a uri.
   
   ### Testing
   - `XmlCompletionTest`: schema structure and inheritance, inline types, the 
context scanner on awkward XML, snippets (incl. namespace prefix), attribute 
values, end to end Tab + Enter (element then language inside it, attribute then 
its value, uri attribute untouched).
   - Scanner precision run (not committed) over 155 XML-DSL files of the repo: 
3058 contexts, no failures; 4 of 2371 element paths unresolved, all `<list>` 
inside a bean `<property>`, which the XSD does not have.
   - The `camel-jbang-plugin-tui` suite passes (1561 tests).
   - Tried live in the TUI; the screenshot is from that run.
   
   ### Not in this PR
   - Spring XML (`camel-spring.xsd`): legacy, its Camel elements still resolve 
as top-level elements.
   - CAMEL-25241 (Java DSL route chain completion), the sibling ticket.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 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]

Reply via email to