* Resolve a symbol name to a single node ID, preferring candidates * from the same file as the caller to avoid cross-file collisions.
(key: string, callerFile?: string)
| 585 | * from the same file as the caller to avoid cross-file collisions. |
| 586 | */ |
| 587 | function resolveSymbol(key: string, callerFile?: string): number | undefined { |
| 588 | const candidates = nodeSymbolIndex.get(key); |
| 589 | if (!candidates?.length) return undefined; |
| 590 | if (candidates.length === 1) return candidates[0]; |
| 591 | if (callerFile) { |
| 592 | const sameFile = candidates.find(id => nodes[id - 1]?.file === callerFile); |
| 593 | if (sameFile !== undefined) return sameFile; |
| 594 | } |
| 595 | return candidates[0]; |
| 596 | } |
| 597 | |
| 598 | async function processNextBatch() { |
| 599 | if (pendingFileQueue.length === 0) { |