Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/load-cargo/src/lib.rs18
-rw-r--r--crates/project-model/src/workspace.rs41
2 files changed, 38 insertions, 21 deletions
diff --git a/crates/load-cargo/src/lib.rs b/crates/load-cargo/src/lib.rs
index 00446b27cf..5654c04a59 100644
--- a/crates/load-cargo/src/lib.rs
+++ b/crates/load-cargo/src/lib.rs
@@ -256,6 +256,24 @@ impl ProjectFolders {
fsc.add_file_set(file_set_roots)
}
+ for ws in workspaces.iter() {
+ let mut file_set_roots: Vec<VfsPath> = vec![];
+ let mut entries = vec![];
+
+ for buildfile in ws.buildfiles() {
+ file_set_roots.push(VfsPath::from(buildfile.to_owned()));
+ entries.push(buildfile.to_owned());
+ }
+
+ if !file_set_roots.is_empty() {
+ let entry = vfs::loader::Entry::Files(entries);
+ res.watch.push(res.load.len());
+ res.load.push(entry);
+ local_filesets.push(fsc.len() as u64);
+ fsc.add_file_set(file_set_roots)
+ }
+ }
+
if let Some(user_config_path) = user_config_dir_path {
let ratoml_path = {
let mut p = user_config_path.to_path_buf();
diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs
index f98d983ac0..dcd62753cb 100644
--- a/crates/project-model/src/workspace.rs
+++ b/crates/project-model/src/workspace.rs
@@ -524,6 +524,17 @@ impl ProjectWorkspace {
}
}
+ pub fn buildfiles(&self) -> Vec<AbsPathBuf> {
+ match &self.kind {
+ ProjectWorkspaceKind::Json(project) => project
+ .crates()
+ .filter_map(|(_, krate)| krate.build.as_ref().map(|build| build.build_file.clone()))
+ .map(|build_file| self.workspace_root().join(build_file))
+ .collect(),
+ _ => vec![],
+ }
+ }
+
pub fn find_sysroot_proc_macro_srv(&self) -> anyhow::Result<AbsPathBuf> {
self.sysroot.discover_proc_macro_srv()
}
@@ -568,27 +579,15 @@ impl ProjectWorkspace {
match &self.kind {
ProjectWorkspaceKind::Json(project) => project
.crates()
- .map(|(_, krate)| {
- // FIXME: PackageRoots dont allow specifying files, only directories
- let build_file = krate
- .build
- .as_ref()
- .map(|build| self.workspace_root().join(&build.build_file))
- .as_deref()
- .and_then(AbsPath::parent)
- .map(ToOwned::to_owned);
-
- PackageRoot {
- is_local: krate.is_workspace_member,
- include: krate
- .include
- .iter()
- .cloned()
- .chain(build_file)
- .chain(self.extra_includes.iter().cloned())
- .collect(),
- exclude: krate.exclude.clone(),
- }
+ .map(|(_, krate)| PackageRoot {
+ is_local: krate.is_workspace_member,
+ include: krate
+ .include
+ .iter()
+ .cloned()
+ .chain(self.extra_includes.iter().cloned())
+ .collect(),
+ exclude: krate.exclude.clone(),
})
.collect::<FxHashSet<_>>()
.into_iter()