gnodet-bot commented on code in PR #27487:
URL: https://github.com/apache/camel/pull/27487#discussion_r4205635900
##########
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:
nit: After this extraction, `ext` will never contain a dot, so the
`"camel.yaml"`, `"camel.yml"` and `"camel.xml"` arms in the switch below become
dead code. Not a bug — they still compile and the tests pass — but they may
confuse a future reader who thinks the multi-dot extensions are still reachable.
##########
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:
nit: `uri.startsWith("kamelet:source")` also matches a hypothetical
`kamelet:source-events`. An `equals` check (or `"kamelet:source".equals(uri)` /
checking for a `?` after `source`) would be exact. In practice it's safe
because this only runs inside a Kamelet template (`kamelet != null`), where the
canonical from URI is literally `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]