This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 4922ab502d3d chore: camel-jbang - remove the inline quick doc of the
source viewer, which the quick doc panel replaced in August
4922ab502d3d is described below
commit 4922ab502d3debbea3d8a851315ea0fcf9ad6b2c
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Oct 12 16:43:21 2026 +0200
chore: camel-jbang - remove the inline quick doc of the source viewer,
which the quick doc panel replaced in August
Pressing i in the source viewer once showed the docs of every line
under the line itself. The quick doc panel at the bottom replaced it on
2026-08-13 (681f1ae5b15d): the key and the drawing were removed, but the
providers stayed wired up and were never called, as the view could no
longer be switched on. CAMEL-25208 later added one for Java and XML
routes.
Removed: SourceViewer.QuickDocProvider with its fields, setter and
refreshQuickDoc; its ten hook-up calls in the Source, Routes and
Diagram tabs; the four whole-file providers (provideCamelQuickDocs,
providePropertiesQuickDocs, provideRouteQuickDocs and
DiagramDetailSupport.provideAllQuickDocs); and the EipDocSupport and
SourceEditAssist helpers only they used. The quick doc panel
(EditQuickDocProvider, CursorQuickDocProvider and the provide*QuickDoc
methods for a line) is unchanged; the Java route test now checks the
panel's doc of the later endpoint step instead.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
---
.../core/commands/tui/DiagramDetailSupport.java | 38 ---
.../dsl/jbang/core/commands/tui/DiagramTab.java | 2 -
.../dsl/jbang/core/commands/tui/EipDocSupport.java | 292 +--------------------
.../dsl/jbang/core/commands/tui/RoutesTab.java | 3 -
.../jbang/core/commands/tui/SourceEditAssist.java | 123 ---------
.../dsl/jbang/core/commands/tui/SourceTab.java | 5 -
.../dsl/jbang/core/commands/tui/SourceViewer.java | 36 ---
.../commands/tui/SourceRouteValidationTest.java | 16 +-
8 files changed, 5 insertions(+), 510 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/DiagramDetailSupport.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/DiagramDetailSupport.java
index effb2df04065..7adea2c9c1e8 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/DiagramDetailSupport.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/DiagramDetailSupport.java
@@ -19,9 +19,7 @@ package org.apache.camel.dsl.jbang.core.commands.tui;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Deque;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import dev.tamboui.layout.Rect;
import dev.tamboui.markdown.MarkdownView;
@@ -146,42 +144,6 @@ final class DiagramDetailSupport {
return null;
}
- Map<Integer, List<SourceViewer.DocEntry>>
provideAllQuickDocs(List<JsonObject> cd) {
- if (cachedRouteDetail == null || cd.isEmpty()) {
- return Map.of();
- }
-
- List<JsonObject> processors = getAllProcessors(cachedRouteDetail);
- if (processors.isEmpty()) {
- return Map.of();
- }
-
- IntegrationInfo info = ctx.findSelectedIntegration();
- CamelCatalog catalog = info != null ? getCatalog(info) : null;
-
- Map<Integer, List<SourceViewer.DocEntry>> result = new
LinkedHashMap<>();
- for (JsonObject proc : processors) {
- Integer line = proc.getInteger("line");
- if (line == null || line <= 0) {
- continue;
- }
-
- int eipIdx = findCodeDataIndex(cd, line, -1);
- if (eipIdx < 0 || result.containsKey(eipIdx)) {
- continue;
- }
- String endpointUri = proc.getString("endpointUri");
- String type = proc.getString("type");
-
- if (endpointUri != null && catalog != null) {
- buildEndpointInlineDoc(result, cd, catalog, endpointUri,
eipIdx);
- } else if (type != null) {
- buildEipInlineDoc(result, cd, catalog, type,
proc.getMap("options"), eipIdx);
- }
- }
- return result;
- }
-
static Line buildBreadcrumbTitle(Deque<String> routeNavigationStack,
String drillDownRouteId) {
Style nameStyle = Theme.label().bold();
List<Span> spans = new ArrayList<>();
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/DiagramTab.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/DiagramTab.java
index d3d65c194a00..2fe279569323 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/DiagramTab.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/DiagramTab.java
@@ -1042,7 +1042,6 @@ class DiagramTab extends AbstractTab {
diagram.scrollToSelectedEipNode();
}
});
- sourceViewer.setQuickDocProvider(detail::provideAllQuickDocs);
detail.ensureProcessorDetailLoaded(routeId);
var rl = diagram.getRouteLayout(routeId);
sourceViewer.loadSource(ctx, routeId, 0, rl != null ? rl.source :
null);
@@ -1066,7 +1065,6 @@ class DiagramTab extends AbstractTab {
sourceViewer.hide();
}
});
- sourceViewer.setQuickDocProvider(detail::provideAllQuickDocs);
detail.ensureProcessorDetailLoaded(drillDownRouteId);
var rl2 = diagram.getRouteLayout(drillDownRouteId);
sourceViewer.loadSource(ctx, drillDownRouteId, targetLine, rl2 != null
? rl2.source : null);
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/EipDocSupport.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/EipDocSupport.java
index acb7732a2d33..281b5b29c5d0 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/EipDocSupport.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/EipDocSupport.java
@@ -30,8 +30,8 @@ import org.apache.camel.util.json.JsonArray;
import org.apache.camel.util.json.JsonObject;
/**
- * Stateless helpers that turn catalog metadata (EIP and component models)
into markdown detail text and inline
- * quick-doc entries for the source viewer.
+ * Stateless helpers that turn catalog metadata (EIP and component models)
into markdown detail text and option docs for
+ * the source viewer.
* <p>
* Shared by {@link RoutesTab}, {@link DiagramTab} and {@link SourceTab}.
*/
@@ -69,264 +69,6 @@ final class EipDocSupport {
return List.of();
}
- static void buildEndpointInlineDoc(
- Map<Integer, List<SourceViewer.DocEntry>> result, List<JsonObject>
cd,
- CamelCatalog catalog, String endpointUri, int eipIdx) {
-
- String component = endpointUri.contains(":") ?
endpointUri.substring(0, endpointUri.indexOf(':')) : endpointUri;
- ComponentModel model = catalog.componentModel(component);
- if (model == null) {
- return;
- }
-
- String compTitle = model.getTitle() != null ? model.getTitle() :
component;
- String desc = model.getDescription() != null ?
truncateText(model.getDescription(), 80) : "";
-
- Map<String, BaseOptionModel> optionDocs = new LinkedHashMap<>();
- for (ComponentModel.EndpointOptionModel opt :
model.getEndpointOptions()) {
- if (opt.getName() != null) {
- optionDocs.put(opt.getName(), opt);
- }
- }
-
- int beforeSize = result.size();
- List<SourceViewer.DocEntry> titleLines = new ArrayList<>();
- titleLines.add(SourceViewer.DocEntry.of(compTitle + " — " + desc));
- result.put(eipIdx, titleLines);
-
- inlineParameterDocs(result, cd, eipIdx, optionDocs);
-
- // For Java/XML where params are in the URI (not on separate source
lines),
- // cluster the option docs under the title
- if (result.size() == beforeSize + 1) {
- clusterEndpointOptions(titleLines, catalog, endpointUri,
optionDocs);
- }
- }
-
- private static void clusterEndpointOptions(
- List<SourceViewer.DocEntry> docLines, CamelCatalog catalog,
- String endpointUri, Map<String, BaseOptionModel> optionDocs) {
- try {
- Map<String, String> props =
catalog.endpointProperties(endpointUri);
- if (props != null) {
- for (Map.Entry<String, String> entry : props.entrySet()) {
- BaseOptionModel optModel = optionDocs.get(entry.getKey());
- if (optModel != null) {
- String optDoc = formatOptionDoc(optModel);
- if (optDoc != null) {
- String text = entry.getKey() + ": " +
entry.getValue() + " — " + optDoc;
- docLines.add(optModel.isDeprecated()
- ? SourceViewer.DocEntry.deprecated(text)
- : SourceViewer.DocEntry.of(text));
- }
- }
- }
- }
- } catch (Exception e) {
- // ignore URI parse errors
- }
- }
-
- static void buildEipInlineDoc(
- Map<Integer, List<SourceViewer.DocEntry>> result, List<JsonObject>
cd,
- CamelCatalog catalog, String type, JsonObject opts, int eipIdx) {
-
- EipModel model = catalog != null ? catalog.eipModel(type) : null;
-
- // For endpoint-bearing EIPs, resolve the component from the uri option
- ComponentModel compModel = null;
- if (opts != null && catalog != null) {
- Object uriObj = opts.get("uri");
- if (uriObj != null) {
- String uri = uriObj.toString();
- String comp = uri.contains(":") ? uri.substring(0,
uri.indexOf(':')) : uri;
- compModel = catalog.componentModel(comp);
- }
- }
-
- List<SourceViewer.DocEntry> titleLines = new ArrayList<>();
- if (model != null && model.getTitle() != null) {
- String eipTitle = model.getTitle();
- if (compModel != null && compModel.getTitle() != null) {
- eipTitle += " (" + compModel.getTitle() + ")";
- }
- String desc;
- if (compModel != null && compModel.getDescription() != null) {
- desc = truncateText(compModel.getDescription(), 80);
- } else {
- desc = model.getDescription() != null ?
truncateText(model.getDescription(), 80) : "";
- }
- titleLines.add(SourceViewer.DocEntry.of(eipTitle + " — " + desc));
- } else {
- titleLines.add(SourceViewer.DocEntry.of(type));
- }
-
- int beforeSize = result.size();
- result.put(eipIdx, titleLines);
-
- if (model != null) {
- Map<String, BaseOptionModel> optionDocs = new LinkedHashMap<>();
- for (BaseOptionModel opt : model.getOptions()) {
- if (opt.getName() != null) {
- optionDocs.put(opt.getName(), opt);
- }
- }
- if (compModel != null) {
- for (ComponentModel.EndpointOptionModel opt :
compModel.getEndpointOptions()) {
- if (opt.getName() != null &&
!optionDocs.containsKey(opt.getName())) {
- optionDocs.put(opt.getName(), opt);
- }
- }
- }
- inlineParameterDocs(result, cd, eipIdx, optionDocs);
-
- // For Java/XML where options are on the same line,
- // cluster the option docs under the title
- if (result.size() == beforeSize + 1 && opts != null) {
- boolean hasParams = hasParametersChild(cd, eipIdx);
- clusterEipOptions(titleLines, opts, optionDocs, hasParams);
- }
- }
- }
-
- private static void clusterEipOptions(
- List<SourceViewer.DocEntry> docLines, JsonObject opts,
- Map<String, BaseOptionModel> optionDocs, boolean skipUri) {
- for (Map.Entry<String, Object> entry : opts.entrySet()) {
- if (skipUri && "uri".equals(entry.getKey())) {
- continue;
- }
- BaseOptionModel optModel = optionDocs.get(entry.getKey());
- if (optModel != null) {
- String optDoc = formatOptionDoc(optModel);
- if (optDoc != null) {
- String text = entry.getKey() + ": " + entry.getValue() + "
— " + optDoc;
- docLines.add(optModel.isDeprecated()
- ? SourceViewer.DocEntry.deprecated(text)
- : SourceViewer.DocEntry.of(text));
- }
- }
- }
- }
-
- static boolean hasParametersChild(List<JsonObject> cd, int eipIdx) {
- int eipIndent = lineIndent(cd, eipIdx);
- for (int i = eipIdx + 1; i < cd.size(); i++) {
- String code = cd.get(i).get("code") != null ?
cd.get(i).get("code").toString() : "";
- int indent = leadingSpaces(code);
- if (indent < eipIndent && !code.isBlank()) {
- break;
- }
- String trimmed = code.stripLeading();
- if (trimmed.startsWith("parameters:")) {
- return true;
- }
- }
- return false;
- }
-
- static void inlineParameterDocs(
- Map<Integer, List<SourceViewer.DocEntry>> result, List<JsonObject>
cd,
- int eipIdx, Map<String, BaseOptionModel> optionDocs) {
-
- if (optionDocs.isEmpty()) {
- return;
- }
-
- int eipIndent = lineIndent(cd, eipIdx);
- int childIndent = -1;
- boolean inParameters = false;
- int paramIndent = -1;
- int parametersLineIndent = -1;
-
- for (int i = eipIdx + 1; i < cd.size(); i++) {
- String code = cd.get(i).get("code") != null ?
cd.get(i).get("code").toString() : "";
- int indent = leadingSpaces(code);
- if (indent < eipIndent && !code.isBlank()) {
- break;
- }
- if (childIndent < 0 && indent > eipIndent) {
- childIndent = indent;
- }
-
- if (inParameters) {
- if (paramIndent < 0 && indent > parametersLineIndent &&
!code.isBlank()) {
- paramIndent = indent;
- }
- if (paramIndent > 0 && indent <= parametersLineIndent &&
!code.isBlank()) {
- inParameters = false;
- paramIndent = -1;
- parametersLineIndent = -1;
- } else if (paramIndent > 0 && indent == paramIndent) {
- String trimmed = code.stripLeading();
- int colon = trimmed.indexOf(':');
- if (colon > 0) {
- String key = trimmed.substring(0, colon).strip();
- BaseOptionModel doc = optionDocs.get(key);
- if (doc != null) {
- String docLine = formatOptionDoc(doc);
- if (docLine != null) {
- int docIdx = lastContinuationLine(cd, i,
indent);
- result.put(docIdx, List.of(doc.isDeprecated()
- ?
SourceViewer.DocEntry.deprecated(docLine)
- : SourceViewer.DocEntry.of(docLine)));
- }
- }
- }
- continue;
- } else {
- continue;
- }
- }
-
- if (childIndent > 0 && indent != childIndent) {
- continue;
- }
- String trimmed = code.stripLeading();
- int colon = trimmed.indexOf(':');
- if (colon <= 0) {
- continue;
- }
- String key = trimmed.substring(0, colon).strip();
- if ("parameters".equals(key)) {
- inParameters = true;
- parametersLineIndent = indent;
- continue;
- }
- if ("uri".equals(key) || "steps".equals(key)
- || "id".equals(key) || "description".equals(key)) {
- continue;
- }
-
- BaseOptionModel doc = optionDocs.get(key);
- if (doc != null) {
- String docLine = formatOptionDoc(doc);
- if (docLine != null) {
- int docIdx = lastContinuationLine(cd, i, indent);
- result.put(docIdx, List.of(doc.isDeprecated()
- ? SourceViewer.DocEntry.deprecated(docLine)
- : SourceViewer.DocEntry.of(docLine)));
- }
- }
- }
- }
-
- static int lastContinuationLine(List<JsonObject> cd, int keyIdx, int
keyIndent) {
- int last = keyIdx;
- for (int j = keyIdx + 1; j < cd.size(); j++) {
- String c = cd.get(j).get("code") != null ?
cd.get(j).get("code").toString() : "";
- if (c.isBlank()) {
- continue;
- }
- if (leadingSpaces(c) > keyIndent) {
- last = j;
- } else {
- break;
- }
- }
- return last;
- }
-
static String formatOptionDoc(BaseOptionModel doc) {
StringBuilder sb = new StringBuilder();
if (doc.getDescription() != null && !doc.getDescription().isEmpty()) {
@@ -351,36 +93,6 @@ final class EipDocSupport {
return !sb.isEmpty() ? sb.toString() : null;
}
- static int lineIndent(List<JsonObject> cd, int idx) {
- if (idx < 0 || idx >= cd.size()) {
- return 0;
- }
- String code = cd.get(idx).get("code") != null ?
cd.get(idx).get("code").toString() : "";
- return leadingSpaces(code);
- }
-
- static int leadingSpaces(String s) {
- int count = 0;
- for (int i = 0; i < s.length(); i++) {
- if (s.charAt(i) == ' ') {
- count++;
- } else {
- break;
- }
- }
- return count;
- }
-
- static int findCodeDataIndex(List<JsonObject> cd, int targetLine, int
fallback) {
- for (int i = 0; i < cd.size(); i++) {
- Integer lineNum = cd.get(i).getInteger("line");
- if (lineNum != null && lineNum == targetLine) {
- return i;
- }
- }
- return Math.max(0, fallback);
- }
-
/**
* The period that ends the first sentence: one followed by a space or the
end of the text, and not the period of an
* abbreviation (e.g., i.e.) - not the dot of (i.e., a number such as 0.5,
or a name such as file.txt.
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RoutesTab.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RoutesTab.java
index 1187897c2cb0..14c119494c60 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RoutesTab.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RoutesTab.java
@@ -1456,7 +1456,6 @@ class RoutesTab extends AbstractTab {
diagram.scrollToSelectedEipNode();
}
});
- sourceViewer.setQuickDocProvider(detail::provideAllQuickDocs);
detail.ensureProcessorDetailLoaded(routeId);
var rl = diagram.getRouteLayout(routeId);
sourceViewer.loadSource(ctx, routeId, 0, rl != null ? rl.source :
null);
@@ -1490,7 +1489,6 @@ class RoutesTab extends AbstractTab {
diagram.scrollToSelectedEipNode();
}
});
- sourceViewer.setQuickDocProvider(detail::provideAllQuickDocs);
detail.ensureProcessorDetailLoaded(routeId);
var rl2 = diagram.getRouteLayout(routeId);
sourceViewer.loadSource(ctx, routeId, 0, rl2 != null ? rl2.source :
null);
@@ -1514,7 +1512,6 @@ class RoutesTab extends AbstractTab {
sourceViewer.hide();
}
});
- sourceViewer.setQuickDocProvider(detail::provideAllQuickDocs);
detail.ensureProcessorDetailLoaded(drillDownRouteId);
var rl3 = diagram.getRouteLayout(drillDownRouteId);
sourceViewer.loadSource(ctx, drillDownRouteId, targetLine, rl3 != null
? rl3.source : null);
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceEditAssist.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceEditAssist.java
index c421f9ab93f9..bf939d460254 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceEditAssist.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceEditAssist.java
@@ -26,7 +26,6 @@ import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -160,40 +159,6 @@ final class SourceEditAssist {
return catalog;
}
- Map<Integer, List<SourceViewer.DocEntry>>
provideCamelQuickDocs(List<JsonObject> codeData) {
- CamelCatalog catalog = validationCatalog();
- if (catalog == null || codeData.isEmpty()) {
- return Map.of();
- }
-
- Map<Integer, List<SourceViewer.DocEntry>> result = new
LinkedHashMap<>();
- for (int i = 0; i < codeData.size(); i++) {
- String code = codeData.get(i).getString("code");
- if (code == null) {
- continue;
- }
-
- Matcher uriMatcher = YAML_URI_PATTERN.matcher(code);
- if (uriMatcher.find()) {
- String uri = uriMatcher.group(1);
- if (uri.endsWith("\"")) {
- uri = uri.substring(0, uri.length() - 1);
- }
- EipDocSupport.buildEndpointInlineDoc(result, codeData,
catalog, uri, i);
- continue;
- }
-
- Matcher keyMatcher = YAML_KEY_PATTERN.matcher(code);
- if (keyMatcher.find()) {
- String key = keyMatcher.group(1);
- if (catalog.eipModel(key) != null) {
- EipDocSupport.buildEipInlineDoc(result, codeData, catalog,
key, null, i);
- }
- }
- }
- return result;
- }
-
List<SourceViewer.DocEntry> provideEditQuickDoc(List<String> lines, int
cursorRow) {
CamelCatalog catalog = validationCatalog();
if (catalog == null || lines == null || cursorRow < 0 || cursorRow >=
lines.size()) {
@@ -1632,56 +1597,6 @@ final class SourceEditAssist {
return answer;
}
- Map<Integer, List<SourceViewer.DocEntry>>
providePropertiesQuickDocs(List<JsonObject> codeData) {
- CamelCatalog catalog = getCatalog();
- if (catalog == null || codeData.isEmpty()) {
- return Map.of();
- }
- ensureMainOptionsCache(catalog);
-
- Map<Integer, List<SourceViewer.DocEntry>> result = new
LinkedHashMap<>();
- for (int i = 0; i < codeData.size(); i++) {
- String code = codeData.get(i).getString("code");
- if (code == null) {
- continue;
- }
- String trimmed = code.trim();
- if (trimmed.isEmpty() || trimmed.startsWith("#") ||
trimmed.startsWith("!")) {
- continue;
- }
- int eq = trimmed.indexOf('=');
- if (eq <= 0) {
- continue;
- }
- String key = trimmed.substring(0, eq).trim();
- BaseOptionModel opt = lookupPropertyOption(catalog, key);
- if (opt != null) {
- String doc = EipDocSupport.formatOptionDoc(opt);
- if (doc != null) {
- result.put(i, List.of(opt.isDeprecated()
- ? SourceViewer.DocEntry.deprecated(doc)
- : SourceViewer.DocEntry.of(doc)));
- }
- continue;
- }
- // fallback to Spring Boot configuration metadata for non-camel
properties
- ensureSpringBootMetadataCache();
- if (springBootMetadataCache != null) {
- JsonObject sbProp = springBootMetadataCache.get(key);
- if (sbProp != null) {
- String doc = SpringBootMetadataHelper.formatDoc(sbProp);
- if (doc != null) {
- boolean deprecated =
Boolean.TRUE.equals(sbProp.get("deprecated"));
- result.put(i, List.of(deprecated
- ? SourceViewer.DocEntry.deprecated(doc)
- : SourceViewer.DocEntry.of(doc)));
- }
- }
- }
- }
- return result;
- }
-
Set<Integer> scanDeprecatedProperties(List<JsonObject> codeData) {
CamelCatalog catalog = getCatalog();
if (catalog == null || codeData.isEmpty()) {
@@ -1836,35 +1751,6 @@ final class SourceEditAssist {
return answer;
}
- /**
- * The quick doc of each line of a Java or XML DSL route file
(CAMEL-25208), read from its model: the component of
- * an endpoint and the options it is given, the EIP of a step.
- */
- Map<Integer, List<SourceViewer.DocEntry>> provideRouteQuickDocs(Path file,
List<JsonObject> codeData) {
- CamelCatalog catalog = validationCatalog();
- if (catalog == null || codeData.isEmpty()) {
- return Map.of();
- }
- List<String> lines = new ArrayList<>(codeData.size());
- for (JsonObject jo : codeData) {
- lines.add(jo.getString("code") != null ? jo.getString("code") :
"");
- }
- Map<Integer, List<SourceViewer.DocEntry>> result = new
LinkedHashMap<>();
- for (RouteNodes.Node n : routeNodes(file, lines)) {
- int idx = n.line() - 1;
- if (idx < 0 || idx >= codeData.size() || result.containsKey(idx)) {
- continue;
- }
- if (n.kind() == RouteNodes.Kind.ENDPOINT) {
- EipDocSupport.buildEndpointInlineDoc(result, codeData,
catalog, n.uri(), idx);
- } else if (n.kind() == RouteNodes.Kind.STEP && !hasEndpoint(file,
lines, n.line())
- && catalog.eipModel(n.eip()) != null) {
- EipDocSupport.buildEipInlineDoc(result, codeData, catalog,
n.eip(), null, idx);
- }
- }
- return result;
- }
-
/**
* The quick doc of the line the cursor is on in a Java or XML DSL route
file (CAMEL-25208): the component of an
* endpoint with the options it is given, else the EIP of the step and the
language of its expression.
@@ -1928,15 +1814,6 @@ final class SourceEditAssist {
}
}
- private boolean hasEndpoint(Path file, List<String> lines, int line) {
- for (RouteNodes.Node n : RouteNodes.at(routeNodes(file, lines), line))
{
- if (n.kind() == RouteNodes.Kind.ENDPOINT) {
- return true;
- }
- }
- return false;
- }
-
/** The nodes of a route file's content, read again only when the content
changed. */
private List<RouteNodes.Node> routeNodes(Path file, List<String> lines) {
String content = String.join("\n", lines);
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
index 9b7a302843bb..cb9a55efe09a 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
@@ -921,7 +921,6 @@ class SourceTab extends AbstractTab {
sourceViewer.setXmlCompletion(routeFile &&
name.toLowerCase().endsWith(".xml") ? assist::provideXmlCompletions : null);
sourceViewer.setSemanticCompletion(SourceEditAssist.isYamlFile(filePath) ?
assist::provideSemanticCompletions : null);
if (isCamelSourceFile(filePath)) {
- sourceViewer.setQuickDocProvider(assist::provideCamelQuickDocs);
sourceViewer.setDeprecatedLineScanner(null);
if (SourceEditAssist.isYamlFile(filePath)) {
// the options of a kamelet: endpoint start with the
properties of its Kamelet (CAMEL-25411)
@@ -939,7 +938,6 @@ class SourceTab extends AbstractTab {
sourceViewer.setEditQuickDocProvider(withProjectDocs(assist::provideEditQuickDoc));
} else {
// XML: the quick doc of the routes read into the model, Tab
in the uri attributes (CAMEL-25208)
- sourceViewer.setQuickDocProvider(cd ->
assist.provideRouteQuickDocs(filePath, cd));
sourceViewer.setAutocompleteProvider(assist::provideYamlKeyCompletions);
sourceViewer.setAutocompleteValueProvider(assist::provideYamlValueCompletions);
sourceViewer.setEditQuickDocProvider(
@@ -947,7 +945,6 @@ class SourceTab extends AbstractTab {
}
} else if (routeFile) {
// Java: the quick doc of the routes read into the model by the
Java DSL parser (CAMEL-25208)
- sourceViewer.setQuickDocProvider(cd ->
assist.provideRouteQuickDocs(filePath, cd));
sourceViewer.setDeprecatedLineScanner(null);
// Tab in the endpoint uri of from, to, toD...: component names,
options and values, as YAML uris have
sourceViewer.setAutocompleteProvider(assist::provideYamlKeyCompletions);
@@ -955,14 +952,12 @@ class SourceTab extends AbstractTab {
sourceViewer.setEditQuickDocProvider(
withProjectDocs((lines, row) ->
assist.provideRouteEditQuickDoc(filePath, lines, row)));
} else if (SourceEditAssist.isPropertiesFile(filePath)) {
-
sourceViewer.setQuickDocProvider(assist::providePropertiesQuickDocs);
sourceViewer.setDeprecatedLineScanner(assist::scanDeprecatedProperties);
sourceViewer.setAutocompleteProvider(assist::providePropertyCompletions);
sourceViewer.setAutocompleteValueProvider(assist::providePropertyValueCompletions);
sourceViewer.setPropertiesValidator(assist::validatePropertyLine);
sourceViewer.setEditQuickDocProvider(withProjectDocs(assist::provideEditPropertyQuickDoc));
} else {
- sourceViewer.setQuickDocProvider(null);
sourceViewer.setDeprecatedLineScanner(null);
sourceViewer.setAutocompleteProvider(null);
sourceViewer.setEditQuickDocProvider(null);
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceViewer.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceViewer.java
index 1df5455c890b..4849d8f4fa35 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceViewer.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceViewer.java
@@ -98,11 +98,6 @@ class SourceViewer {
}
}
- @FunctionalInterface
- interface QuickDocProvider {
- Map<Integer, List<DocEntry>> provideAll(List<JsonObject> codeData);
- }
-
@FunctionalInterface
interface EditQuickDocProvider {
List<DocEntry> provideForLine(List<String> lines, int cursorRow);
@@ -188,9 +183,6 @@ class SourceViewer {
private int markdownScroll;
// the furthest the markdown view scrolls, from the last render (unknown
before it)
private int markdownMaxScroll = Integer.MAX_VALUE;
- private QuickDocProvider quickDocProvider;
- private boolean quickDocEnabled;
- private Map<Integer, List<DocEntry>> quickDocEntries =
Collections.emptyMap();
private EditQuickDocProvider editQuickDocProvider;
private boolean editQuickDocEnabled = true;
private DeprecatedLineScanner deprecatedLineScanner;
@@ -592,8 +584,6 @@ class SourceViewer {
exitEditMode();
visible = false;
onLineSelected = null;
- quickDocEnabled = false;
- quickDocEntries = Collections.emptyMap();
deprecatedLines = Collections.emptySet();
editableFile = null;
propertiesValidator = null;
@@ -636,9 +626,6 @@ class SourceViewer {
rawMarkdownContent = null;
markdownScroll = 0;
markdownMaxScroll = Integer.MAX_VALUE;
- quickDocProvider = null;
- quickDocEnabled = false;
- quickDocEntries = Collections.emptyMap();
deprecatedLineScanner = null;
deprecatedLines = Collections.emptySet();
jumpLinks = Collections.emptyMap();
@@ -804,19 +791,6 @@ class SourceViewer {
return loadedFilePath;
}
- private void refreshQuickDoc() {
- if (quickDocEnabled && quickDocProvider != null &&
!codeData.isEmpty()) {
- quickDocEntries = quickDocProvider.provideAll(codeData);
- if (quickDocEntries == null) {
- quickDocEntries = Collections.emptyMap();
- }
- }
- }
-
- void setQuickDocProvider(QuickDocProvider provider) {
- this.quickDocProvider = provider;
- }
-
void setEditQuickDocProvider(EditQuickDocProvider provider) {
this.editQuickDocProvider = provider;
}
@@ -898,7 +872,6 @@ class SourceViewer {
}
}
idx = (idx + 1) % formats.length;
- quickDocEntries = Collections.emptyMap();
switchFormat(formats[idx]);
return true;
}
@@ -1318,7 +1291,6 @@ class SourceViewer {
editStartTop = markdownMode ? -1 : scrollY;
markdownModeBeforeEdit = markdownMode;
markdownMode = false;
- quickDocEnabled = false;
search.closeInputOnly();
dirty = false;
validationErrors = null;
@@ -3974,7 +3946,6 @@ class SourceViewer {
scrollX = 0;
pendingScroll = true;
search.reset();
- refreshQuickDoc();
return;
}
@@ -4064,7 +4035,6 @@ class SourceViewer {
scrollX = 0;
pendingScroll = true;
search.reset();
- refreshQuickDoc();
});
}
@@ -4225,12 +4195,6 @@ class SourceViewer {
int count = 0;
for (int i = fromLine; i < toLine && i < lines.size(); i++) {
count += wrapRowCount(lines.get(i), contentWidth);
- if (quickDocEnabled) {
- List<DocEntry> docs = quickDocEntries.get(i);
- if (docs != null) {
- count += docs.size();
- }
- }
}
return count;
}
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceRouteValidationTest.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceRouteValidationTest.java
index 6d4b9dc1fcc7..ff1ba23592d6 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceRouteValidationTest.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceRouteValidationTest.java
@@ -19,15 +19,12 @@ package org.apache.camel.dsl.jbang.core.commands.tui;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import dev.tamboui.tui.event.KeyCode;
import dev.tamboui.tui.event.KeyEvent;
import dev.tamboui.tui.event.KeyModifiers;
-import org.apache.camel.util.json.JsonObject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -117,18 +114,11 @@ class SourceRouteValidationTest {
assertThat(filter).extracting(SourceViewer.DocEntry::text)
.containsExactly(filter.get(0).text(), "Simple predicate:
${header.foo} == 'bar'");
assertThat(filter.get(0).text()).startsWith("Filter — ");
+ // the endpoint of a later step has its quick doc too
+ assertThat(assist.provideRouteEditQuickDoc(Path.of("MyRoute.java"),
lines, 7)).extracting(SourceViewer.DocEntry::text)
+ .satisfies(t -> assertThat(t.get(0)).startsWith("SEDA — "));
// a line of plain Java has none
assertThat(assist.provideRouteEditQuickDoc(Path.of("MyRoute.java"),
lines, 2)).isEmpty();
-
- List<JsonObject> codeData = new ArrayList<>();
- for (String l : lines) {
- JsonObject jo = new JsonObject();
- jo.put("code", l);
- codeData.add(jo);
- }
- Map<Integer, List<SourceViewer.DocEntry>> all =
assist.provideRouteQuickDocs(Path.of("MyRoute.java"), codeData);
- assertThat(all).containsKeys(5, 6, 7);
- assertThat(all.get(7).get(0).text()).startsWith("SEDA — ");
}
@Test