fix: only skip DO_TRY edges to internal children, keep continuation edges
The previous fix skipped ALL edges from DO_TRY nodes, which also removed the continuation edge to the next node in the main flow (causing LOG nodes to appear disconnected). Now checks if the target is a descendant of the DO_TRY ELK node — only internal edges are skipped, continuation edges to the next main flow node are kept. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -295,19 +295,20 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
|||||||
// Create ELK edges — skip edges that cross between different ELK root graphs
|
// Create ELK edges — skip edges that cross between different ELK root graphs
|
||||||
if (graph.getEdges() != null) {
|
if (graph.getEdges() != null) {
|
||||||
for (RouteEdge re : graph.getEdges()) {
|
for (RouteEdge re : graph.getEdges()) {
|
||||||
// Skip all edges originating from DO_TRY nodes — these are entry/handler
|
|
||||||
// edges that don't need layout (try body has its own internal flow,
|
|
||||||
// handler edges are like route-level ON_EXCEPTION edges)
|
|
||||||
if (doTryNodeIds.contains(re.getSource())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ElkNode sourceElk = elkNodeMap.get(re.getSource());
|
ElkNode sourceElk = elkNodeMap.get(re.getSource());
|
||||||
ElkNode targetElk = elkNodeMap.get(re.getTarget());
|
ElkNode targetElk = elkNodeMap.get(re.getTarget());
|
||||||
if (sourceElk == null || targetElk == null) {
|
if (sourceElk == null || targetElk == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip edges from DO_TRY to its own children (entry + handler edges).
|
||||||
|
// Keep edges from DO_TRY to nodes OUTSIDE it (continuation edges).
|
||||||
|
if (doTryNodeIds.contains(re.getSource())) {
|
||||||
|
if (isDescendantOf(targetElk, sourceElk)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Skip edges that cross ELK root boundaries
|
// Skip edges that cross ELK root boundaries
|
||||||
ElkNode sourceRoot = getElkRoot(sourceElk);
|
ElkNode sourceRoot = getElkRoot(sourceElk);
|
||||||
ElkNode targetRoot = getElkRoot(targetElk);
|
ElkNode targetRoot = getElkRoot(targetElk);
|
||||||
@@ -717,6 +718,16 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
|||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
/** Walk up to the top-level root of an ELK node's hierarchy. */
|
/** Walk up to the top-level root of an ELK node's hierarchy. */
|
||||||
|
/** Check if 'child' is a descendant of 'ancestor' in the ELK node hierarchy. */
|
||||||
|
private boolean isDescendantOf(ElkNode child, ElkNode ancestor) {
|
||||||
|
ElkNode current = child.getParent();
|
||||||
|
while (current != null) {
|
||||||
|
if (current == ancestor) return true;
|
||||||
|
current = current.getParent();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private ElkNode getElkRoot(ElkNode node) {
|
private ElkNode getElkRoot(ElkNode node) {
|
||||||
ElkNode current = node;
|
ElkNode current = node;
|
||||||
while (current.getParent() != null) {
|
while (current.getParent() != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user