Improve completion of cfg attributes

The completion of cfg will look at the enabled cfg keys when
performing completion.

It will also look crate features when completing a feature cfg
option. A fixed list of known values for some cfg options are
provided.

For unknown keys it will look at the enabled values for that cfg key,
which means that completion will only show enabled options for those.
This commit is contained in:
Jamie Cunliffe 2021-05-30 14:52:19 +01:00
parent 1b05dbba39
commit 284483b347
8 changed files with 185 additions and 0 deletions

View file

@ -387,6 +387,7 @@ fn project_json_to_crate_graph(
cfg_options,
env,
proc_macro.unwrap_or_default(),
Default::default(),
),
)
})
@ -582,6 +583,7 @@ fn detached_files_to_crate_graph(
cfg_options.clone(),
Env::default(),
Vec::new(),
Default::default(),
);
for (name, krate) in public_deps.iter() {
@ -726,6 +728,7 @@ fn add_target_crate_root(
cfg_options,
env,
proc_macro,
pkg.features.clone(),
);
crate_id
@ -755,6 +758,7 @@ fn sysroot_to_crate_graph(
cfg_options.clone(),
env,
proc_macro,
Default::default(),
);
Some((krate, crate_id))
})