()
| 748 | } |
| 749 | |
| 750 | async function processNextBatch() { |
| 751 | if (pendingFileQueue.length === 0) { |
| 752 | // Cross-linking phase |
| 753 | console.log(`[Diagnostic] ==========================================`); |
| 754 | console.log(`[Diagnostic] ENTERING HIGH-FIDELITY SEMANTIC LINKING PHASE`); |
| 755 | console.log(`[Diagnostic] Total Nodes Created: ${nodes.length}`); |
| 756 | console.log(`[Diagnostic] Total Containment Links: ${links.length}`); |
| 757 | console.log(`[Diagnostic] Symbol Index Size: ${nodeSymbolIndex.size} entries`); |
| 758 | console.log(`[Diagnostic] File Call Sites Map Size: ${fileCalls.size} callers`); |
| 759 | console.log(`[Diagnostic] Class Inheritance Map Size: ${inheritances.size} classes`); |
| 760 | const pmLinkStart = (performance as any).memory; |
| 761 | if (pmLinkStart) { |
| 762 | console.log(`[Diagnostic] Heap Memory Pre-Linking: ${(pmLinkStart.usedJSHeapSize / 1048576).toFixed(1)} MB`); |
| 763 | } |
| 764 | |
| 765 | const tStart = performance.now(); |
| 766 | self.postMessage({ type: 'PROGRESS', payload: { msg: "Building high-fidelity relationships...", percent: 95 } }); |
| 767 | await new Promise(r => setTimeout(r, 0)); |
| 768 | |
| 769 | const MAX_CALL_EDGES = indexOptions.maxEdges || 50000; |
| 770 | let callsAdded = 0; |
| 771 | let callsScanned = 0; |
| 772 | |
| 773 | for (const [callerId, calls] of fileCalls.entries()) { |
| 774 | if (callsAdded >= MAX_CALL_EDGES) { |
| 775 | console.warn(`[Diagnostic] [Warning] Reached MAX_CALL_EDGES (${MAX_CALL_EDGES}) limit! Truncating call relationships.`); |
| 776 | break; |
| 777 | } |
| 778 | const callerFile = nodes[callerId - 1]?.file; |
| 779 | for (const calledName of calls) { |
| 780 | callsScanned++; |
| 781 | const targetId = resolveSymbol(`Function:${calledName}`, callerFile) || |
| 782 | resolveSymbol(`Class:${calledName}`, callerFile) || |
| 783 | resolveSymbol(calledName, callerFile); |
| 784 | if (targetId && targetId !== callerId) { |
| 785 | links.push({ source: callerId, target: targetId, type: 'CALLS' }); |
| 786 | callsAdded++; |
| 787 | if (callsAdded >= MAX_CALL_EDGES) break; |
| 788 | } |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | let inheritsAdded = 0; |
| 793 | for (const [classId, bases] of inheritances.entries()) { |
| 794 | const classFile = nodes[classId - 1]?.file; |
| 795 | for (const baseName of bases) { |
| 796 | const targetId = resolveSymbol(`Class:${baseName}`, classFile) || resolveSymbol(baseName, classFile); |
| 797 | if (targetId) { |
| 798 | links.push({ source: classId, target: targetId, type: 'INHERITS' }); |
| 799 | inheritsAdded++; |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | |
| 804 | const tEnd = performance.now(); |
| 805 | console.log(`[Diagnostic] Semantic Linking Complete in ${(tEnd - tStart).toFixed(1)} ms`); |
| 806 | console.log(`[Diagnostic] Calls Scanned: ${callsScanned}, Calls Added: ${callsAdded}`); |
| 807 | console.log(`[Diagnostic] Inherits Added: ${inheritsAdded}`); |
no test coverage detected