From 6782fe2a5b84315f66a227b035c6beae7834f0b0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 20 Dec 2018 12:05:29 +0300 Subject: Treat --- crates/ra_analysis/src/imp.rs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 2d00d23be..4ef2129c3 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -73,8 +73,8 @@ impl AnalysisHostImpl { .set(library.root_id, Default::default()); self.db .query_mut(LibrarySymbolsQuery) - .set(library.root_id, Arc::new(library.symbol_index)); - self.apply_root_change(library.root_id, library.root_change); + .set_constant(library.root_id, Arc::new(library.symbol_index)); + self.apply_root_change_constant(library.root_id, library.root_change); } self.db .query_mut(ra_db::LibraryRootsQuery) @@ -115,6 +115,34 @@ impl AnalysisHostImpl { .set(root_id, Arc::new(source_root)); } + fn apply_root_change_constant(&mut self, root_id: SourceRootId, root_change: RootChange) { + let mut source_root = SourceRoot::clone(&self.db.source_root(root_id)); + for add_file in root_change.added { + self.db + .query_mut(ra_db::FileTextQuery) + .set_constant(add_file.file_id, add_file.text); + self.db + .query_mut(ra_db::FileRelativePathQuery) + .set_constant(add_file.file_id, add_file.path.clone()); + self.db + .query_mut(ra_db::FileSourceRootQuery) + .set_constant(add_file.file_id, root_id); + source_root.files.insert(add_file.path, add_file.file_id); + } + for remove_file in root_change.removed { + self.db + .query_mut(ra_db::FileTextQuery) + .set_constant(remove_file.file_id, Default::default()); + self.db + .query_mut(ra_db::FileRelativePathQuery) + .set_constant(remove_file.file_id, Default::default()); + source_root.files.remove(&remove_file.path); + } + self.db + .query_mut(ra_db::SourceRootQuery) + .set_constant(root_id, Arc::new(source_root)); + } + #[allow(unused)] /// Ideally, we should call this function from time to time to collect heavy /// syntax trees. However, if we actually do that, everything is recomputed -- cgit v1.2.3