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

Function isInModuleBlock

src/resolution/ambient-modules.ts:915–927  ·  view source on GitHub ↗
(file: string, line: number, column: number, specifier: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

913 * first time one is asked about.
914 */
915export function isInModuleBlock(file: string, line: number, column: number, specifier: string, context: ResolutionContext): boolean {
916 let blocks: readonly AmbientModuleBlock[] | undefined = scanned(context).byFile.get(file);
917 if (!blocks && !DECLARATION_FILE.test(file)) {
918 const memo = memoFor(context);
919 blocks = memo.otherBlocks.get(file);
920 if (!blocks) {
921 const source = context.readFile(file);
922 blocks = source && /\bdeclare\s+module\s*['"]/.test(source) ? scanAmbientModules(source).blocks : [];
923 memo.otherBlocks.set(file, blocks);
924 }
925 }
926 return (blocks ?? []).some((block) => block.specifier === specifier && inBlock({ startLine: line, startColumn: column }, block));
927}
928
929/**
930 * Whether `node` is one of several declarations of the same name that the

Callers 1

reachesAmbientModuleFunction · 0.90

Calls 7

scanAmbientModulesFunction · 0.85
inBlockFunction · 0.85
scannedFunction · 0.70
memoForFunction · 0.70
getMethod · 0.65
readFileMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected