From 76c51fae77d5dc2d7791132ecc78e444118e48de Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Oct 2018 22:05:21 +0300 Subject: Tweak writable root API --- crates/ra_analysis/src/imp.rs | 12 ++++++------ crates/ra_analysis/src/roots.rs | 7 ++----- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'crates/ra_analysis/src') diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index fb711491b..0cf6db40d 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -94,12 +94,12 @@ impl AnalysisHostImpl { } } pub fn change_files(&mut self, changes: &mut dyn Iterator)>) { - let data = self.data_mut(); - data.root = Arc::new(data.root.apply_changes(changes, None)); + self.data_mut() + .root.apply_changes(changes, None); } pub fn set_file_resolver(&mut self, resolver: FileResolverImp) { - let data = self.data_mut(); - data.root = Arc::new(data.root.apply_changes(&mut iter::empty(), Some(resolver))); + self.data_mut() + .root.apply_changes(&mut iter::empty(), Some(resolver)); } pub fn set_crate_graph(&mut self, graph: CrateGraph) { let mut visited = FxHashSet::default(); @@ -141,7 +141,7 @@ impl Clone for AnalysisImpl { impl AnalysisImpl { fn root(&self, file_id: FileId) -> &SourceRoot { if self.data.root.contains(file_id) { - return &*self.data.root; + return &self.data.root; } &**self.data.libs.iter().find(|it| it.contains(file_id)).unwrap() } @@ -405,7 +405,7 @@ impl AnalysisImpl { #[derive(Default, Clone, Debug)] struct WorldData { crate_graph: CrateGraph, - root: Arc, + root: WritableSourceRoot, libs: Vec>, } diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs index 766548c70..42833af36 100644 --- a/crates/ra_analysis/src/roots.rs +++ b/crates/ra_analysis/src/roots.rs @@ -35,10 +35,10 @@ pub(crate) struct WritableSourceRoot { impl WritableSourceRoot { pub fn apply_changes( - &self, + &mut self, changes: &mut dyn Iterator)>, file_resolver: Option, - ) -> WritableSourceRoot { + ) { let db = self.db.write(); let mut changed = FxHashSet::default(); let mut removed = FxHashSet::default(); @@ -65,9 +65,6 @@ impl WritableSourceRoot { let resolver = file_resolver.unwrap_or_else(|| file_set.resolver.clone()); db.query(db::FileSetQuery) .set((), Arc::new(db::FileSet { files, resolver })); - // TODO: reconcile sasla's API with our needs - // https://github.com/salsa-rs/salsa/issues/12 - self.clone() } } -- cgit v1.2.3