| 103 | const rootKey = identityOf(closure.root); |
| 104 | |
| 105 | const walk = (from: string, path: readonly string[], depth: number): void => { |
| 106 | for (const to of outgoing.get(from) ?? []) { |
| 107 | if (out.length >= FLOW_NODE_CAP) { |
| 108 | return; |
| 109 | } |
| 110 | const ref = symbols.get(to); |
| 111 | if (ref === undefined) { |
| 112 | continue; |
| 113 | } |
| 114 | const cycle = path.includes(to); |
| 115 | const next = cycle ? path : [...path, to]; |
| 116 | out.push({ |
| 117 | kind: 'symbol', |
| 118 | id: `flow.${out.length}`, |
| 119 | ref, |
| 120 | badges: cycle ? { cycle: true } : {}, |
| 121 | depth, |
| 122 | path: next, |
| 123 | // Nothing here looked up whether the symbol is test code or |
| 124 | // whether the step constructs a class, so nothing here claims to |
| 125 | // have. The badges a closure can support are the cycle and |
| 126 | // nothing else. |
| 127 | enriched: false, |
| 128 | }); |
| 129 | if (!cycle) { |
| 130 | walk(to, next, depth + 1); |
| 131 | } |
| 132 | } |
| 133 | }; |
| 134 | walk(rootKey, [rootKey], 1); |
| 135 | return out; |
| 136 | } |