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

Function isBoundToOutOfRepoImport

src/resolution/import-resolver.ts:4572–4595  ·  view source on GitHub ↗
(
  ref: UnresolvedRef,
  context: ResolutionContext,
  target?: Node | null
)

Source from the content-addressed store, hash-verified

4570 * `target` is what a strategy found, when the caller has it.
4571 */
4572export function isBoundToOutOfRepoImport(
4573 ref: UnresolvedRef,
4574 context: ResolutionContext,
4575 target?: Node | null
4576): boolean {
4577 const name = ref.referenceName;
4578 if (name.includes('::') || name.includes('.')) return false; // qualified refs resolve by path
4579
4580 // (A 2015-edition crate-relative path can shadow a stdlib root with a local
4581 // module of the same name: a `use core::…` with a `mod core;` is the crate's.)
4582 if (ref.language === 'rust') return isRustNameFromStd(ref, context);
4583 if (ref.language === 'python') return isPythonNameFromOutside(name, ref.filePath, target, context);
4584
4585 if (!ESM_IMPORT_LANGUAGES.has(ref.language)) return false;
4586 for (const imp of context.getImportMappings(ref.filePath, ref.language)) {
4587 if (imp.localName !== name) continue;
4588 // A package the repository declares itself (`declare module 'x'`) has
4589 // its declarations in the repository.
4590 return isExternalImport(imp.source, ref.language, context, { fromFile: ref.filePath }) &&
4591 resolveImportPath(imp.source, ref.filePath, ref.language, context) === null &&
4592 !ambientModuleDeclares(imp.source, imp.exportedName, imp.isDefault, ref, context);
4593 }
4594 return false;
4595}
4596
4597/**
4598 * The tail a reference that failed to resolve is parked under when it goes

Callers 1

gateTargetKindMethod · 0.90

Calls 5

ambientModuleDeclaresFunction · 0.90
isExternalImportFunction · 0.85
resolveImportPathFunction · 0.85
hasMethod · 0.80
getImportMappingsMethod · 0.80

Tested by

no test coverage detected