Per-file, per-name scans are shared by every ref in the file; cleared with the other memos on sync.
(context: ResolutionContext, key: string, scan: () => T)
| 608 | const PYTHON_NAME_SCANS = new WeakMap<ResolutionContext, Map<string, unknown>>(); |
| 609 | /** Per-file, per-name scans are shared by every ref in the file; cleared with the other memos on sync. */ |
| 610 | function pythonNameScan<T>(context: ResolutionContext, key: string, scan: () => T): T { |
| 611 | let memo = PYTHON_NAME_SCANS.get(context); |
| 612 | if (!memo) { memo = new Map(); PYTHON_NAME_SCANS.set(context, memo); } |
| 613 | if (!memo.has(key)) memo.set(key, scan()); |
| 614 | return memo.get(key) as T; |
| 615 | } |
| 616 | |
| 617 | function scanPythonImportKeys(name: string, filePath: string, context: ResolutionContext): Set<string> { |
| 618 | const lines = pythonMemberLines(filePath, context); |
no test coverage detected