MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / getFileExportIndex

Function getFileExportIndex

src/resolution/import-resolver.ts:84–102  ·  view source on GitHub ↗
(filePath: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

82const fileExportIndexes = new WeakMap<ResolutionContext, Map<string, FileExportIndex>>();
83
84function 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). */
105export function clearImportResolverMemos(context: ResolutionContext): void {

Callers 1

findExportedSymbolWalkFunction · 0.85

Calls 4

hasMethod · 0.80
getMethod · 0.65
getNodesInFileMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected