Skip to content

Commit

Permalink
Include buildfiles in vfs
Browse files Browse the repository at this point in the history
  • Loading branch information
darichey committed Sep 26, 2024
1 parent 2904b35 commit 75ca498
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/load-cargo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ impl ProjectFolders {
entries.push(manifest.to_owned());
}

for buildfile in ws.buildfiles() {
file_set_roots.push(VfsPath::from(buildfile.to_owned()));
entries.push(buildfile.to_owned());
}

// In case of detached files we do **not** look for a rust-analyzer.toml.
if !matches!(ws.kind, ProjectWorkspaceKind::DetachedFile { .. }) {
let ws_root = ws.workspace_root();
Expand Down
11 changes: 11 additions & 0 deletions src/tools/rust-analyzer/crates/project-model/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,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(AbsPathBuf::assert)
.collect(),
_ => vec![],
}
}

pub fn find_sysroot_proc_macro_srv(&self) -> anyhow::Result<AbsPathBuf> {
self.sysroot.discover_proc_macro_srv()
}
Expand Down

0 comments on commit 75ca498

Please sign in to comment.