Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly add buildfiles when constructing ProjectFolders #19019

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions crates/load-cargo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
41 changes: 20 additions & 21 deletions crates/project-model/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
Expand Down
Loading