mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Split out proc-macros from the CrateGraph
This commit is contained in:
parent
71b23360e7
commit
d154ea88f9
12 changed files with 141 additions and 176 deletions
|
@ -235,7 +235,6 @@ impl Analysis {
|
|||
cfg_options.clone(),
|
||||
cfg_options,
|
||||
Env::default(),
|
||||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
Err("Analysis::from_single_file has no target layout".into()),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use ide_db::{
|
||||
base_db::{salsa::Durability, CrateGraph, SourceDatabase},
|
||||
base_db::{salsa::Durability, CrateGraph, ProcMacros, SourceDatabase},
|
||||
FxHashMap, RootDatabase,
|
||||
};
|
||||
|
||||
|
@ -16,6 +16,7 @@ use ide_db::{
|
|||
// |===
|
||||
pub(crate) fn shuffle_crate_graph(db: &mut RootDatabase) {
|
||||
let crate_graph = db.crate_graph();
|
||||
let proc_macros = db.proc_macros();
|
||||
|
||||
let mut shuffled_ids = crate_graph.iter().collect::<Vec<_>>();
|
||||
|
||||
|
@ -23,6 +24,7 @@ pub(crate) fn shuffle_crate_graph(db: &mut RootDatabase) {
|
|||
stdx::rand::shuffle(&mut shuffled_ids, |i| rng.rand_range(0..i as u32) as usize);
|
||||
|
||||
let mut new_graph = CrateGraph::default();
|
||||
let mut new_proc_macros = ProcMacros::default();
|
||||
|
||||
let mut map = FxHashMap::default();
|
||||
for old_id in shuffled_ids.iter().copied() {
|
||||
|
@ -35,11 +37,11 @@ pub(crate) fn shuffle_crate_graph(db: &mut RootDatabase) {
|
|||
data.cfg_options.clone(),
|
||||
data.potential_cfg_options.clone(),
|
||||
data.env.clone(),
|
||||
data.proc_macro.clone(),
|
||||
data.is_proc_macro,
|
||||
data.origin.clone(),
|
||||
data.target_layout.clone(),
|
||||
);
|
||||
new_proc_macros.insert(new_id, proc_macros[&old_id].clone());
|
||||
map.insert(old_id, new_id);
|
||||
}
|
||||
|
||||
|
@ -53,4 +55,5 @@ pub(crate) fn shuffle_crate_graph(db: &mut RootDatabase) {
|
|||
}
|
||||
|
||||
db.set_crate_graph_with_durability(Arc::new(new_graph), Durability::HIGH);
|
||||
db.set_proc_macros_with_durability(Arc::new(new_proc_macros), Durability::HIGH);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue