davsclaus commented on code in PR #27487:
URL: https://github.com/apache/camel/pull/27487#discussion_r4205668246
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SyntaxHighlighter.java:
##########
@@ -230,6 +230,11 @@ static Language detectLanguage(String filename) {
return Language.PLAIN;
}
ext = ext.toLowerCase();
+ // the last extension: a Kamelet is name.kamelet.yaml, which onlyExt
gives as kamelet.yaml (CAMEL-25411)
+ int dot = ext.lastIndexOf('.');
+ if (dot >= 0) {
+ ext = ext.substring(dot + 1);
Review Comment:
Fixed in 0ad69e4da5d5: the `camel.yaml`, `camel.yml` and `camel.xml` arms
are gone, as only the last extension reaches the switch now.
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java:
##########
@@ -1489,6 +1495,32 @@ private void scanYamlRoutes(Path file, List<RouteEntry>
fromEntries, List<ToEntr
}
}
+ /** The metadata.name of a Kamelet file, or null. */
+ static String kameletName(List<String> lines) {
+ boolean metadata = false;
+ for (String line : lines) {
+ if (line.isBlank() || line.trim().startsWith("#")) {
+ continue;
+ }
+ if (lineIndent(line) == 0) {
+ metadata = line.trim().equals("metadata:");
+ } else if (metadata && line.trim().startsWith("name:")) {
+ String name = extractYamlValue(line.trim(), "name");
+ return name != null && !name.isEmpty() ? name : null;
+ }
+ }
+ return null;
+ }
+
+ private static String kameletRouteId(String kamelet, String routeId) {
+ return kamelet != null && (routeId == null || routeId.isEmpty()) ?
kamelet : routeId;
+ }
+
+ /** An action or a sink is entered from kamelet:source: the routes reach
it as kamelet:<its name>. */
+ private static String kameletFromUri(String kamelet, String uri) {
+ return kamelet != null && uri.startsWith("kamelet:source") ?
"kamelet:" + kamelet : uri;
Review Comment:
Fixed in 0ad69e4da5d5: it matches `kamelet:source` exactly, or with a query
(`kamelet:source?...`).
--
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]