()
| 119 | /** Save call graphs to persistent storage (debounced) */ |
| 120 | let saveTimeout: NodeJS.Timeout | null = null; |
| 121 | function saveCallGraphsToStorage(): void { |
| 122 | if (!extensionContext) return; |
| 123 | |
| 124 | // Debounce saves to avoid excessive writes |
| 125 | if (saveTimeout) clearTimeout(saveTimeout); |
| 126 | saveTimeout = setTimeout(() => { |
| 127 | try { |
| 128 | const toStore: Record<string, SerializedCallGraph> = {}; |
| 129 | for (const [key, value] of cachedCallGraphs.entries()) { |
| 130 | toStore[key] = serializeCallGraph(value); |
| 131 | } |
| 132 | extensionContext!.globalState.update(CALL_GRAPH_CACHE_KEY, toStore); |
| 133 | } catch (e) { |
| 134 | console.error('[CallGraph] Failed to save to storage:', e); |
| 135 | } |
| 136 | }, 1000); |
| 137 | } |
| 138 | |
| 139 | export function getCachedCallGraph(filePath: string): ExtractedCallGraph | undefined { |
| 140 | return cachedCallGraphs.get(filePath); |
no test coverage detected