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

Function ambientModuleDeclarations

src/resolution/ambient-modules.ts:893–906  ·  view source on GitHub ↗
(context: ResolutionContext)

Source from the content-addressed store, hash-verified

891 * resolver settles costs a lookup (see reachesAmbientModule).
892 */
893export function ambientModuleDeclarations(context: ResolutionContext): ReadonlyMap<string, string> {
894 const memo = memoFor(context);
895 if (memo.declarationIds) return memo.declarationIds;
896 const ids = new Map<string, string>();
897 for (const [file, modules] of scanned(context).byFile) {
898 for (const node of context.getNodesInFile(file)) {
899 if (!isBlockLevel(node)) continue;
900 const mod = modules.find((m) => inBlock(node, m));
901 if (mod) ids.set(node.id, mod.specifier);
902 }
903 }
904 memo.declarationIds = ids;
905 return ids;
906}
907
908/**
909 * Whether line:column of `file` lies inside a block declaring `specifier`:

Callers 1

resolveOneInMethod · 0.90

Calls 6

isBlockLevelFunction · 0.85
inBlockFunction · 0.85
memoForFunction · 0.70
scannedFunction · 0.70
getNodesInFileMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected