(nodes: readonly GraphNode[])
| 106 | |
| 107 | /** Den Index einmal bauen. */ |
| 108 | export function buildPlacementIndex(nodes: readonly GraphNode[]): PlacementIndex { |
| 109 | const byPath = new Map<string, GraphNode[]>(); |
| 110 | const named: GraphNode[] = []; |
| 111 | for (const node of nodes) { |
| 112 | const path = normalizePath(node.file_path ?? ''); |
| 113 | if (path.length === 0) { |
| 114 | continue; |
| 115 | } |
| 116 | const bucket = byPath.get(path); |
| 117 | if (bucket === undefined) { |
| 118 | byPath.set(path, [node]); |
| 119 | } else { |
| 120 | bucket.push(node); |
| 121 | } |
| 122 | named.push(node); |
| 123 | } |
| 124 | return { byPath, named }; |
| 125 | } |
| 126 | |
| 127 | /** Wie viele Zeilen ein Knoten umspannt. Unbekannt heisst: unendlich weit. */ |
| 128 | function spanOf(node: GraphNode): number { |
no test coverage detected