( ref: UnresolvedRef, context: ResolutionContext )
| 2645 | * FQN/module matchers), so there is no trustworthy oracle to consult here. |
| 2646 | */ |
| 2647 | export 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 | } |
no test coverage detected