Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/base-db/src/change.rs')
| -rw-r--r-- | crates/base-db/src/change.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/crates/base-db/src/change.rs b/crates/base-db/src/change.rs index 90413a573a..1f19556a76 100644 --- a/crates/base-db/src/change.rs +++ b/crates/base-db/src/change.rs @@ -3,20 +3,18 @@ use std::fmt; -use rustc_hash::FxHashMap; use salsa::Durability; use triomphe::Arc; use vfs::FileId; -use crate::{CrateGraph, CrateId, CrateWorkspaceData, RootQueryDb, SourceRoot, SourceRootId}; +use crate::{CrateGraphBuilder, CratesIdMap, RootQueryDb, SourceRoot, SourceRootId}; /// Encapsulate a bunch of raw `.set` calls on the database. #[derive(Default)] pub struct FileChange { pub roots: Option<Vec<SourceRoot>>, pub files_changed: Vec<(FileId, Option<String>)>, - pub crate_graph: Option<CrateGraph>, - pub ws_data: Option<FxHashMap<CrateId, Arc<CrateWorkspaceData>>>, + pub crate_graph: Option<CrateGraphBuilder>, } impl fmt::Debug for FileChange { @@ -48,15 +46,11 @@ impl FileChange { self.files_changed.push((file_id, new_text)) } - pub fn set_crate_graph(&mut self, graph: CrateGraph) { + pub fn set_crate_graph(&mut self, graph: CrateGraphBuilder) { self.crate_graph = Some(graph); } - pub fn set_ws_data(&mut self, data: FxHashMap<CrateId, Arc<CrateWorkspaceData>>) { - self.ws_data = Some(data); - } - - pub fn apply(self, db: &mut dyn RootQueryDb) { + pub fn apply(self, db: &mut dyn RootQueryDb) -> Option<CratesIdMap> { let _p = tracing::info_span!("FileChange::apply").entered(); if let Some(roots) = self.roots { for (idx, root) in roots.into_iter().enumerate() { @@ -79,12 +73,11 @@ impl FileChange { let text = text.unwrap_or_default(); db.set_file_text_with_durability(file_id, &text, durability) } + if let Some(crate_graph) = self.crate_graph { - db.set_crate_graph_with_durability(Arc::new(crate_graph), Durability::HIGH); - } - if let Some(data) = self.ws_data { - db.set_crate_workspace_data_with_durability(Arc::new(data), Durability::HIGH); + return Some(crate_graph.set_in_db(db)); } + None } } |