* Die Selbstschleifen: eine je Fehlertyp und Datei, in der Reihenfolge, in der * der Block sie erhebt.
(
view: FlowView,
indexOf: ReadonlyMap<string, number>,
lifelines: readonly DiagramLifeline[],
)
| 359 | * der Block sie erhebt. |
| 360 | */ |
| 361 | function loopsOf( |
| 362 | view: FlowView, |
| 363 | indexOf: ReadonlyMap<string, number>, |
| 364 | lifelines: readonly DiagramLifeline[], |
| 365 | ): DiagramLoop[] { |
| 366 | const out: DiagramLoop[] = []; |
| 367 | const seen = new Map<string, DiagramLoop>(); |
| 368 | view.steps.forEach((step, stepIndex) => { |
| 369 | if (step.line.kind !== 'raise') { |
| 370 | return; |
| 371 | } |
| 372 | const type = sanitizeLabel(step.line.targetName ?? ''); |
| 373 | const file = step.line.targetFile === undefined |
| 374 | ? '' |
| 375 | : sanitizeLabel(baseNameOf(step.line.targetFile)); |
| 376 | // Ohne Lebenslinie fuer die Datei haengt die Schleife an der Wurzel: |
| 377 | // der Fakt nennt sie, das Bild zeigt sie nicht, und die Beschriftung |
| 378 | // sagt trotzdem, welcher Typ es ist. |
| 379 | const lifeline = indexOf.get(file) ?? 0; |
| 380 | const key = `${lifeline} ${type}`; |
| 381 | const known = seen.get(key); |
| 382 | if (known !== undefined) { |
| 383 | known.steps.push(stepIndex); |
| 384 | return; |
| 385 | } |
| 386 | const loop: DiagramLoop = { |
| 387 | index: out.length, |
| 388 | lifeline, |
| 389 | x: lifelines[lifeline]?.x ?? DIAGRAM_PAD_X, |
| 390 | y: 0, |
| 391 | width: DIAGRAM_LOOP_WIDTH, |
| 392 | height: 18, |
| 393 | label: step.line.text.replace(/^\d+\.\s*/, ''), |
| 394 | type, |
| 395 | steps: [stepIndex], |
| 396 | labelX: 0, |
| 397 | labelY: 0, |
| 398 | labelAnchor: 'start', |
| 399 | }; |
| 400 | out.push(loop); |
| 401 | seen.set(key, loop); |
| 402 | }); |
| 403 | return out; |
| 404 | } |
| 405 | |
| 406 | /** |
| 407 | * Welche Schleife ein Schritt anleuchtet, oder -1. |
no test coverage detected