Register virtual workspace Cargo.toml files in the VFS

This commit is contained in:
Lukas Wirth 2024-06-09 12:54:50 +02:00
parent 7f1f85ac16
commit d4dc3ca83b
15 changed files with 77 additions and 37 deletions

View file

@ -167,6 +167,11 @@ impl ProjectJson {
&self.project_root
}
/// Returns the path to the project's manifest file, if it exists.
pub fn manifest(&self) -> Option<&ManifestPath> {
self.manifest.as_ref()
}
/// Returns the path to the project's manifest or root folder, if no manifest exists.
pub fn manifest_or_root(&self) -> &AbsPath {
self.manifest.as_ref().map_or(&self.project_root, |manifest| manifest.as_ref())

View file

@ -527,6 +527,16 @@ impl ProjectWorkspace {
}
}
pub fn manifest(&self) -> Option<&ManifestPath> {
match &self.kind {
ProjectWorkspaceKind::Cargo { cargo, .. } => Some(cargo.manifest_path()),
ProjectWorkspaceKind::Json(project) => project.manifest(),
ProjectWorkspaceKind::DetachedFile { cargo, .. } => {
Some(cargo.as_ref()?.0.manifest_path())
}
}
}
pub fn find_sysroot_proc_macro_srv(&self) -> anyhow::Result<AbsPathBuf> {
self.sysroot.discover_proc_macro_srv()
}