( ref: UnresolvedRef, context: ResolutionContext, target?: Node | null )
| 4792 | * `target` is what a strategy found, when the caller has it. |
| 4793 | */ |
| 4794 | export function isBoundToOutOfRepoImport( |
| 4795 | ref: UnresolvedRef, |
| 4796 | context: ResolutionContext, |
| 4797 | target?: Node | null |
| 4798 | ): boolean { |
| 4799 | const name = ref.referenceName; |
| 4800 | if (name.includes('::') || name.includes('.')) return false; // qualified refs resolve by path |
| 4801 | |
| 4802 | // (A 2015-edition crate-relative path can shadow a stdlib root with a local |
| 4803 | // module of the same name: a `use core::…` with a `mod core;` is the crate's.) |
| 4804 | if (ref.language === 'rust') return isRustNameFromStd(ref, context); |
| 4805 | if (ref.language === 'python') return isPythonNameFromOutside(name, ref.filePath, target, context); |
| 4806 | |
| 4807 | if (!ESM_IMPORT_LANGUAGES.has(ref.language)) return false; |
| 4808 | for (const imp of context.getImportMappings(ref.filePath, ref.language)) { |
| 4809 | if (imp.localName !== name) continue; |
| 4810 | // A package the repository declares itself (`declare module 'x'`) has |
| 4811 | // its declarations in the repository. |
| 4812 | return isExternalImport(imp.source, ref.language, context, { fromFile: ref.filePath }) && |
| 4813 | resolveImportPath(imp.source, ref.filePath, ref.language, context) === null && |
| 4814 | !ambientModuleDeclares(imp.source, imp.exportedName, imp.isDefault, ref, context); |
| 4815 | } |
| 4816 | return false; |
| 4817 | } |
| 4818 | |
| 4819 | /** |
| 4820 | * The tail a reference that failed to resolve is parked under when it goes |
no test coverage detected