transition enricher

This commit is contained in:
2026-06-19 07:44:54 +02:00
parent 8d4ba0697e
commit e894566112
36 changed files with 230 additions and 289 deletions

View File

@@ -240,7 +240,7 @@ public class AstTransitionParser {
t.setEvent(Event.of(QuotedExpression.of(resolved).toStringWithoutQuotes()));
}
}
case "guard" -> {
case "guard", "guardExpression" -> {
Expression resolved = resolveArg((Expression) args.get(0), argsMap);
parseGuard(resolved, t, cu, context);
}
@@ -248,6 +248,10 @@ public class AstTransitionParser {
Expression resolved = resolveArg((Expression) args.get(0), argsMap);
parseAction(resolved, t, cu, context);
}
case "timer", "timerOnce" -> {
Expression resolved = resolveArg((Expression) args.get(0), argsMap);
t.setEvent(Event.of(methodName + "(" + resolved.toString() + ")", methodName + "(" + resolved.toString() + ")"));
}
}
}
return t;

View File

@@ -116,23 +116,19 @@ public class PlantUml implements StateMachineExporter {
sb.append(" <<").append(styleClass).append(">>");
if (t.getEvent() != null) {
String eventStr = options.formatEvent(t.getEvent());
if (eventStr != null && !eventStr.isBlank()) {
sb.append(" <<e_").append(normalize(eventStr)).append(">>");
}
}
String label = buildLabel(t, options);
if (options.isEmbedIdentifiers()) {
String eventStr = t.getEvent() != null ? options.formatEvent(t.getEvent()) : null;
String linkId = eventStr != null && !eventStr.isBlank() ? "link_" + normalize(source) + "__" + normalize(eventStr) : "link_anon_" + normalize(source) + "_" + normalize(target);
// Force a label even if empty to ensure the link group exists in SVG
String displayLabel = label.isEmpty() ? " " : label;
// Brackets [...] in the label break PlantUML link syntax [[url label]],
// so we strip them for the interactive identification label.
String safeLabel = displayLabel.replaceAll("[\\[\\]]", "");
sb.append(" : ").append("[[#").append(linkId).append(" ").append(safeLabel).append("]]");
sb.append(" : [[#").append(linkId).append(" ");
if (!label.isEmpty()) {
sb.append(label);
} else {
sb.append("<U+00A0>");
}
sb.append("]]");
} else if (!label.isEmpty()) {
sb.append(" : ").append(label);
}