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

Function reachesProgram

src/resolution/ambient-modules.ts:765–772  ·  view source on GitHub ↗

* Whether a `declare module` in `file` can be in the program `fromFile` is in. * Each package of a monorepo has a program of its own, so it can if `fromFile` * is in the package `file` is in, or in a package nested under that one: * vscode's extensions are packages of their own, and each has its

(file: string, test: boolean, fromFile: string, fromTest: boolean, context: ResolutionContext)

Source from the content-addressed store, hash-verified

763 * under copilot's `test/fixtures` are left out of its build and shadow nothing.
764 */
765function reachesProgram(file: string, test: boolean, fromFile: string, fromTest: boolean, context: ResolutionContext): boolean {
766 if (test && !fromTest) return false;
767 const folder = packageFolder(dirOf(file), context);
768 if (folder === '' || fromFile.startsWith(`${folder}/`)) return true;
769 if (test) return false;
770 const name = packageManifest(folder, context)?.name;
771 return !!name && !!packageManifest(packageFolder(dirOf(fromFile), context), context)?.dependencies.has(name);
772}
773
774/** Whether a `declare module` in `declaringFile` counts for a file in `fromFile` (see reachesProgram). */
775export function declaringFileAnswers(declaringFile: string, fromFile: string, context: ResolutionContext): boolean {

Callers 2

declaringFileAnswersFunction · 0.85
declarationsForFunction · 0.85

Calls 4

packageFolderFunction · 0.85
packageManifestFunction · 0.85
hasMethod · 0.80
dirOfFunction · 0.70

Tested by

no test coverage detected