mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 20:31:59 +00:00
Explicitly add buildfiles when constructing ProjectFolders
This commit is contained in:
parent
6e4c29f7ce
commit
c0c7d5a2e1
2 changed files with 38 additions and 21 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue