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

   Fixes [CAMEL-25241](https://issues.apache.org/jira/browse/CAMEL-25241). 
Stacked on #27236 (XML completion); the base is its branch, so this diff is 
only the Java DSL completion. It retargets to `main` when #27236 merges.
   
   After a dot in a Java route chain, **Tab** lists the methods that compile 
there:
   - the **options of the EIP the chain is on** first: `.split(body()).` offers 
`parallelProcessing`, `streaming`, `aggregationStrategy`...;
   - then the **EIPs**, and the `end()`, `endChoice()`, `endDoTry()` that 
closes the current block;
   - documentation from the catalog, the signatures in the details panel; the 
method goes in with its parentheses, the cursor inside them when it takes 
arguments.
   
   ![java 
completion](https://raw.githubusercontent.com/apache/camel/fix/CAMEL-25241/docs/user-manual/modules/ROOT/images/jbang/camel-tui-source-java-completion.png)
   
   ### How
   - `JavaChainContext`: the calls of the statement up to the cursor, read from 
the text (comments, strings, text blocks, lambdas and anonymous class bodies in 
arguments, type arguments skipped), so it works while the file does not parse; 
nothing inside arguments, strings or comments.
   - `JavaDslCompletions`: walks the chain from its start (`from`, 
`onException`, `intercept*`, `onCompletion`) over the model classes with 
reflection (camel-core-model is on the TUI classpath already) with a stack of 
open blocks, the semantics the DSL has at runtime (`ChainReplayer` of the Java 
DSL parser uses the returned object, not the declared type):
     - a block EIP (`OutputNode`, choice) opens one, also of the same class (a 
choice in a choice); `end()` closes it, or ends a non-block EIP such as 
`recipientList(..)`; `endChoice()` / `endDoTry()` / `endCircuitBreaker()` go 
back to it;
     - methods returning `Type` (`to`, `log`...) keep the chain where it is, so 
`.split(x).to("a").streaming()` stays on the split;
     - builder clauses (`ExpressionClause`, `DataFormatClause`, 
`ProcessClause`) and model configurations ended by `end()` 
(`resilience4jConfiguration()`) return to their EIP; a clause's options 
(`marshal().variableSend(..)`) stay on it;
     - overloads the text cannot tell apart (`recipientList(header("x"))` vs 
`recipientList(",")`, `aggregate(..)`, `validate(..)`) are kept until a 
following call rules them out.
   - What is offered: public, `org.apache.camel.model`/`builder` methods 
returning a definition, `Type` or a clause (so getters and void internals such 
as `addOutput`, `preCreateProcessor` drop out; a get/set prefix rule would be 
wrong, `setBody` is DSL), no CamelContext ones, no deprecated ones (those are 
still followed in a chain).
   - `SourceViewer`: tried in Java route files after the simple and uri 
completions.
   
   ### Recall
   A scratch run (not committed) over the Java route tests of the repo: at 
every dot of a route chain, is the method written next among the offered ones?
   
   | Corpus | Files | Chain positions | Not followed | Offered |
   |---|---|---|---|---|
   | camel-core tests | 2,500 | 13,650 | 0 | 13,636 (99.9%) |
   | tests of 191 components | 3,000 | 12,330 | 0 | 12,329 (99.99%) |
   
   The 15 misses are all deprecated methods (`tracing()`, `noDelayer()`, 
`parallelAggregate()`...), left out on purpose. The run found the overload, 
nested-choice, non-block `end()`, clause-option, configuration and 
anonymous-class cases above.
   
   ### Docs
   The source editor page lists the **known limitations** of Tab completion 
(routes in variables, REST DSL, expression builders in arguments, lambdas, own 
beans and classes, Spring XML wrappers, runtime-only header names...), states 
it is light assistance for smaller hand-written edits, and points to the AI 
panel and to coding agents for more: the TUI works with any agent that speaks 
ACP (the agents page now says the listed ones are known to work, `acp:custom` 
runs any other). Help (`source.md`) updated.
   
   ### Testing
   - `JavaDslCompletionTest`: the chain scanner on awkward Java, options first, 
blocks (`end`, choice/when/endChoice, nested choice), non-block EIPs, clauses 
and configurations, overloads decided by what follows, end to end Tab + Enter 
(EIP with cursor in its arguments, an option), uri strings left to the uri 
completion.
   - The `camel-jbang-plugin-tui` suite passes (1576 tests).
   - Tried live in the TUI on a file that does not parse; the screenshot is 
from that run.
   
   _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