MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / processNextBatch

Function processNextBatch

website/src/lib/parser.worker.ts:750–1032  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

748}
749
750async 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}`);

Callers 1

parser.worker.tsFile · 0.85

Calls 15

addNodeFunction · 0.85
getOrCreateFolderChainFunction · 0.85
getLanguageForFileFunction · 0.85
getLanguageQueryKeyFunction · 0.85
getCompiledQueriesFunction · 0.85
getNodeDisplayLabelFunction · 0.85
valForLabelFunction · 0.85
calculateComplexityFunction · 0.85
getPythonDocstringFunction · 0.85
fromMethod · 0.80
keysMethod · 0.80
resolveSymbolFunction · 0.70

Tested by

no test coverage detected