mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Add is_workspace_member for rust-project.json
It is currently unused, but, in the future, it will be used to: * drive certain UX (symbols search by default will look only in the members) * improve performance (rust-analyzer will assume that non-members change rarely) If not specified, is_workspace member is inferred from the path
This commit is contained in:
parent
c7ccfb072c
commit
bc4d047267
1 changed files with 36 additions and 24 deletions
|
@ -34,6 +34,7 @@ pub struct Crate {
|
||||||
pub(crate) target: Option<String>,
|
pub(crate) target: Option<String>,
|
||||||
pub(crate) out_dir: Option<AbsPathBuf>,
|
pub(crate) out_dir: Option<AbsPathBuf>,
|
||||||
pub(crate) proc_macro_dylib_path: Option<AbsPathBuf>,
|
pub(crate) proc_macro_dylib_path: Option<AbsPathBuf>,
|
||||||
|
pub(crate) is_workspace_member: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProjectJson {
|
impl ProjectJson {
|
||||||
|
@ -43,32 +44,42 @@ impl ProjectJson {
|
||||||
crates: data
|
crates: data
|
||||||
.crates
|
.crates
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|crate_data| Crate {
|
.map(|crate_data| {
|
||||||
root_module: base.join(crate_data.root_module),
|
let is_workspace_member = crate_data.is_workspace_member.unwrap_or_else(|| {
|
||||||
edition: crate_data.edition.into(),
|
crate_data.root_module.is_relative()
|
||||||
deps: crate_data
|
&& !crate_data.root_module.starts_with("..")
|
||||||
.deps
|
|| crate_data.root_module.starts_with(base)
|
||||||
.into_iter()
|
});
|
||||||
.map(|dep_data| Dependency {
|
Crate {
|
||||||
crate_id: CrateId(dep_data.krate as u32),
|
root_module: base.join(crate_data.root_module),
|
||||||
name: dep_data.name,
|
edition: crate_data.edition.into(),
|
||||||
})
|
deps: crate_data
|
||||||
.collect::<Vec<_>>(),
|
.deps
|
||||||
cfg: {
|
.into_iter()
|
||||||
let mut cfg = CfgOptions::default();
|
.map(|dep_data| Dependency {
|
||||||
for entry in &crate_data.cfg {
|
crate_id: CrateId(dep_data.krate as u32),
|
||||||
match split_delim(entry, '=') {
|
name: dep_data.name,
|
||||||
Some((key, value)) => {
|
})
|
||||||
cfg.insert_key_value(key.into(), value.into());
|
.collect::<Vec<_>>(),
|
||||||
|
cfg: {
|
||||||
|
let mut cfg = CfgOptions::default();
|
||||||
|
for entry in &crate_data.cfg {
|
||||||
|
match split_delim(entry, '=') {
|
||||||
|
Some((key, value)) => {
|
||||||
|
cfg.insert_key_value(key.into(), value.into());
|
||||||
|
}
|
||||||
|
None => cfg.insert_atom(entry.into()),
|
||||||
}
|
}
|
||||||
None => cfg.insert_atom(entry.into()),
|
|
||||||
}
|
}
|
||||||
}
|
cfg
|
||||||
cfg
|
},
|
||||||
},
|
target: crate_data.target,
|
||||||
target: crate_data.target,
|
out_dir: crate_data.out_dir.map(|it| base.join(it)),
|
||||||
out_dir: crate_data.out_dir.map(|it| base.join(it)),
|
proc_macro_dylib_path: crate_data
|
||||||
proc_macro_dylib_path: crate_data.proc_macro_dylib_path.map(|it| base.join(it)),
|
.proc_macro_dylib_path
|
||||||
|
.map(|it| base.join(it)),
|
||||||
|
is_workspace_member,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
}
|
}
|
||||||
|
@ -91,6 +102,7 @@ struct CrateData {
|
||||||
target: Option<String>,
|
target: Option<String>,
|
||||||
out_dir: Option<PathBuf>,
|
out_dir: Option<PathBuf>,
|
||||||
proc_macro_dylib_path: Option<PathBuf>,
|
proc_macro_dylib_path: Option<PathBuf>,
|
||||||
|
is_workspace_member: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue