Fold edges into one row per file at the far end, ordered by symbol count.
( edges: readonly Edge[], endpoint: (edge: Edge) => string, nodes: Map<string, Node> )
| 248 | |
| 249 | /** Fold edges into one row per file at the far end, ordered by symbol count. */ |
| 250 | function groupByFile( |
| 251 | edges: readonly Edge[], |
| 252 | endpoint: (edge: Edge) => string, |
| 253 | nodes: Map<string, Node> |
| 254 | ): WireImportRow[] { |
| 255 | const byFile = new Map<string, Map<string, Node>>(); |
| 256 | for (const edge of edges) { |
| 257 | const node = nodes.get(endpoint(edge)); |
| 258 | if (!node) continue; |
| 259 | const file = toPosixPath(node.filePath); |
| 260 | let bucket = byFile.get(file); |
| 261 | if (!bucket) { |
| 262 | bucket = new Map<string, Node>(); |
| 263 | byFile.set(file, bucket); |
| 264 | } |
| 265 | bucket.set(node.id, node); |
| 266 | } |
| 267 | |
| 268 | return [...byFile.entries()] |
| 269 | .map(([file, symbols]) => { |
| 270 | const ordered = [...symbols.values()].sort( |
| 271 | (a, b) => a.startLine - b.startLine || a.name.localeCompare(b.name) |
| 272 | ); |
| 273 | return { |
| 274 | file, |
| 275 | test: isTestFile(file), |
| 276 | symbols: ordered.slice(0, MAX_SYMBOLS_PER_IMPORT).map((n) => ({ |
| 277 | id: n.id, |
| 278 | name: n.name, |
| 279 | kind: n.kind, |
| 280 | line: n.startLine, |
| 281 | })), |
| 282 | symbolCount: ordered.length, |
| 283 | }; |
| 284 | }) |
| 285 | .sort((a, b) => b.symbolCount - a.symbolCount || a.file.localeCompare(b.file)); |
| 286 | } |
| 287 | |
| 288 | function unresolvedImportsOf( |
| 289 | cg: CodeGraph, |
no test coverage detected