Critical bug fixes and recall improvements (#68)

This commit is contained in:
Eli Peter 2026-05-11 12:42:39 -04:00 committed by GitHub
parent 7d0e7320e2
commit 55247b7fcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
352 changed files with 60069 additions and 900 deletions

View file

@ -262,5 +262,31 @@ pub fn normalize_namespace(abs_path: &str, root: Option<&str>) -> String {
abs_path.to_string()
}
/// Phase-04 namespace builder that prefixes a project-relative path with
/// the canonical package name when the importer file lies inside a
/// resolved [`crate::resolve::PackageEntry`].
///
/// Returns `"@scope/name::src/file.ts"` when the file is in a package
/// and `"src/file.ts"` (the same value `normalize_namespace` produces)
/// otherwise. Phase 04 ships this helper unused at the resolution
/// site, phase 10 will route [`FuncKey`] construction through it for
/// JS/TS files so cross-file callee lookup honours the package
/// boundary.
pub fn namespace_with_package(
abs_path: &str,
root: Option<&str>,
module_graph: Option<&crate::resolve::ModuleGraph>,
) -> String {
let plain = normalize_namespace(abs_path, root);
let Some(graph) = module_graph else {
return plain;
};
let path = std::path::Path::new(abs_path);
match graph.package_for(path) {
Some(pkg) => format!("{}::{}", pkg.name, plain),
None => plain,
}
}
#[cfg(test)]
mod tests;