@@ -137,17 +137,20 @@ func (fb *flowBuilder) addIfStatement(s *ast.IfStmt) model.ID {
137137 fb .flows = append (fb .flows , flow )
138138 } else {
139139 var flow * microflows.SequenceFlow
140- if pendingThenCase != "" {
140+ originAnchor := prevThenAnchor
141+ destAnchor := thisAnchor
142+ if pendingThenCase != "" || pendingThenAnchor != nil {
143+ originAnchor , destAnchor = pendingFlowAnchors (prevThenAnchor , pendingThenAnchor , thisAnchor )
141144 flow = newHorizontalFlowWithCase (lastThenID , actID , pendingThenCase )
142- if pendingThenAnchor != nil {
143- prevThenAnchor = pendingThenAnchor
145+ if pendingThenCase == "" {
146+ flow = newHorizontalFlow ( lastThenID , actID )
144147 }
145148 pendingThenCase = ""
146149 pendingThenAnchor = nil
147150 } else {
148151 flow = newHorizontalFlow (lastThenID , actID )
149152 }
150- applyUserAnchors (flow , prevThenAnchor , thisAnchor )
153+ applyUserAnchors (flow , originAnchor , destAnchor )
151154 fb .flows = append (fb .flows , flow )
152155 }
153156 prevThenAnchor = thisAnchor
@@ -171,15 +174,18 @@ func (fb *flowBuilder) addIfStatement(s *ast.IfStmt) model.ID {
171174 if ! thenReturns && needMerge {
172175 if lastThenID != "" {
173176 var flow * microflows.SequenceFlow
174- if pendingThenCase != "" {
177+ originAnchor := prevThenAnchor
178+ destAnchor := (* ast .FlowAnchors )(nil )
179+ if pendingThenCase != "" || pendingThenAnchor != nil {
180+ originAnchor , destAnchor = pendingFlowAnchors (prevThenAnchor , pendingThenAnchor , nil )
175181 flow = newHorizontalFlowWithCase (lastThenID , mergeID , pendingThenCase )
176- if pendingThenAnchor != nil {
177- prevThenAnchor = pendingThenAnchor
182+ if pendingThenCase == "" {
183+ flow = newHorizontalFlow ( lastThenID , mergeID )
178184 }
179185 } else {
180186 flow = newHorizontalFlow (lastThenID , mergeID )
181187 }
182- applyUserAnchors (flow , prevThenAnchor , nil )
188+ applyUserAnchors (flow , originAnchor , destAnchor )
183189 fb .flows = append (fb .flows , flow )
184190 } else {
185191 // Empty THEN body - connect split directly to merge with true case
@@ -214,17 +220,20 @@ func (fb *flowBuilder) addIfStatement(s *ast.IfStmt) model.ID {
214220 fb .flows = append (fb .flows , flow )
215221 } else {
216222 var flow * microflows.SequenceFlow
217- if pendingElseCase != "" {
223+ originAnchor := prevElseAnchor
224+ destAnchor := thisAnchor
225+ if pendingElseCase != "" || pendingElseAnchor != nil {
226+ originAnchor , destAnchor = pendingFlowAnchors (prevElseAnchor , pendingElseAnchor , thisAnchor )
218227 flow = newHorizontalFlowWithCase (lastElseID , actID , pendingElseCase )
219- if pendingElseAnchor != nil {
220- prevElseAnchor = pendingElseAnchor
228+ if pendingElseCase == "" {
229+ flow = newHorizontalFlow ( lastElseID , actID )
221230 }
222231 pendingElseCase = ""
223232 pendingElseAnchor = nil
224233 } else {
225234 flow = newHorizontalFlow (lastElseID , actID )
226235 }
227- applyUserAnchors (flow , prevElseAnchor , thisAnchor )
236+ applyUserAnchors (flow , originAnchor , destAnchor )
228237 fb .flows = append (fb .flows , flow )
229238 }
230239 prevElseAnchor = thisAnchor
@@ -248,16 +257,18 @@ func (fb *flowBuilder) addIfStatement(s *ast.IfStmt) model.ID {
248257 if ! elseReturns && needMerge {
249258 if lastElseID != "" {
250259 flow := newUpwardFlow (lastElseID , mergeID )
251- if pendingElseCase != "" {
252- flow .CaseValue = microflows.EnumerationCase {
253- BaseElement : model.BaseElement {ID : model .ID (types .GenerateID ())},
254- Value : pendingElseCase ,
255- }
256- if pendingElseAnchor != nil {
257- prevElseAnchor = pendingElseAnchor
260+ originAnchor := prevElseAnchor
261+ destAnchor := (* ast .FlowAnchors )(nil )
262+ if pendingElseCase != "" || pendingElseAnchor != nil {
263+ originAnchor , destAnchor = pendingFlowAnchors (prevElseAnchor , pendingElseAnchor , nil )
264+ if pendingElseCase != "" {
265+ flow .CaseValue = microflows.EnumerationCase {
266+ BaseElement : model.BaseElement {ID : model .ID (types .GenerateID ())},
267+ Value : pendingElseCase ,
268+ }
258269 }
259270 }
260- applyUserAnchors (flow , prevElseAnchor , nil )
271+ applyUserAnchors (flow , originAnchor , destAnchor )
261272 fb .flows = append (fb .flows , flow )
262273 }
263274 }
@@ -329,17 +340,20 @@ func (fb *flowBuilder) addIfStatement(s *ast.IfStmt) model.ID {
329340 fb .flows = append (fb .flows , flow )
330341 } else {
331342 var flow * microflows.SequenceFlow
332- if pendingThenCase != "" {
343+ originAnchor := prevThenAnchor
344+ destAnchor := thisAnchor
345+ if pendingThenCase != "" || pendingThenAnchor != nil {
346+ originAnchor , destAnchor = pendingFlowAnchors (prevThenAnchor , pendingThenAnchor , thisAnchor )
333347 flow = newHorizontalFlowWithCase (lastThenID , actID , pendingThenCase )
334- if pendingThenAnchor != nil {
335- prevThenAnchor = pendingThenAnchor
348+ if pendingThenCase == "" {
349+ flow = newHorizontalFlow ( lastThenID , actID )
336350 }
337351 pendingThenCase = ""
338352 pendingThenAnchor = nil
339353 } else {
340354 flow = newHorizontalFlow (lastThenID , actID )
341355 }
342- applyUserAnchors (flow , prevThenAnchor , thisAnchor )
356+ applyUserAnchors (flow , originAnchor , destAnchor )
343357 fb .flows = append (fb .flows , flow )
344358 }
345359 prevThenAnchor = thisAnchor
@@ -363,16 +377,18 @@ func (fb *flowBuilder) addIfStatement(s *ast.IfStmt) model.ID {
363377 if ! thenReturns && needMerge {
364378 if lastThenID != "" {
365379 flow := newUpwardFlow (lastThenID , mergeID )
366- if pendingThenCase != "" {
367- flow .CaseValue = microflows.EnumerationCase {
368- BaseElement : model.BaseElement {ID : model .ID (types .GenerateID ())},
369- Value : pendingThenCase ,
370- }
371- if pendingThenAnchor != nil {
372- prevThenAnchor = pendingThenAnchor
380+ originAnchor := prevThenAnchor
381+ destAnchor := (* ast .FlowAnchors )(nil )
382+ if pendingThenCase != "" || pendingThenAnchor != nil {
383+ originAnchor , destAnchor = pendingFlowAnchors (prevThenAnchor , pendingThenAnchor , nil )
384+ if pendingThenCase != "" {
385+ flow .CaseValue = microflows.EnumerationCase {
386+ BaseElement : model.BaseElement {ID : model .ID (types .GenerateID ())},
387+ Value : pendingThenCase ,
388+ }
373389 }
374390 }
375- applyUserAnchors (flow , prevThenAnchor , nil )
391+ applyUserAnchors (flow , originAnchor , destAnchor )
376392 fb .flows = append (fb .flows , flow )
377393 } else {
378394 // Empty THEN body - connect split directly to merge going down and back up
0 commit comments