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

Function isBoundToOutOfRepoImport

src/resolution/import-resolver.ts:2647–2672  ·  view source on GitHub ↗
(
  ref: UnresolvedRef,
  context: ResolutionContext
)

Source from the content-addressed store, hash-verified

2645 * FQN/module matchers), so there is no trustworthy oracle to consult here.
2646 */
2647export function isBoundToOutOfRepoImport(
2648 ref: UnresolvedRef,
2649 context: ResolutionContext
2650): boolean {
2651 const name = ref.referenceName;
2652 if (name.includes('::') || name.includes('.')) return false; // qualified refs resolve by path
2653
2654 if (ref.language === 'rust') {
2655 const content = context.readFile(ref.filePath);
2656 if (!content) return false;
2657 const usePath = collectRustUseBindings(content).get(name);
2658 if (!usePath) return false;
2659 const segments = usePath.split('::');
2660 if (segments.length < 2 || !RUST_STDLIB_ROOTS.has(segments[0]!)) return false;
2661 // 2015-edition crate-relative paths can shadow a stdlib root with a local
2662 // module of the same name — if the path walks to a real file, it's local.
2663 return resolveRustModuleFile(segments.slice(0, -1), ref.filePath, context) === null;
2664 }
2665
2666 if (!ESM_IMPORT_LANGUAGES.has(ref.language)) return false;
2667 for (const imp of context.getImportMappings(ref.filePath, ref.language)) {
2668 if (imp.localName !== name) continue;
2669 return isExternalImport(imp.source, ref.language, context);
2670 }
2671 return false;
2672}

Callers 1

gateTargetKindMethod · 0.90

Calls 7

collectRustUseBindingsFunction · 0.85
resolveRustModuleFileFunction · 0.85
isExternalImportFunction · 0.85
readFileMethod · 0.80
hasMethod · 0.80
getImportMappingsMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected