(filePath: string, context: ResolutionContext)
| 82 | const fileExportIndexes = new WeakMap<ResolutionContext, Map<string, FileExportIndex>>(); |
| 83 | |
| 84 | function getFileExportIndex(filePath: string, context: ResolutionContext): FileExportIndex { |
| 85 | let perFile = fileExportIndexes.get(context); |
| 86 | if (!perFile) { |
| 87 | perFile = new Map(); |
| 88 | fileExportIndexes.set(context, perFile); |
| 89 | } |
| 90 | let idx = perFile.get(filePath); |
| 91 | if (!idx) { |
| 92 | idx = { byName: new Map(), defaultComponent: undefined, defaultFnClass: undefined }; |
| 93 | for (const n of context.getNodesInFile(filePath)) { |
| 94 | if (!n.isExported) continue; |
| 95 | if (!idx.byName.has(n.name)) idx.byName.set(n.name, n); |
| 96 | if (idx.defaultComponent === undefined && n.kind === 'component') idx.defaultComponent = n; |
| 97 | if (idx.defaultFnClass === undefined && (n.kind === 'function' || n.kind === 'class')) idx.defaultFnClass = n; |
| 98 | } |
| 99 | perFile.set(filePath, idx); |
| 100 | } |
| 101 | return idx; |
| 102 | } |
| 103 | |
| 104 | /** Drop the per-context memo tables (see ReferenceResolver.clearCaches). */ |
| 105 | export function clearImportResolverMemos(context: ResolutionContext): void { |
no test coverage detected