From e69ff21207d83864e13f6c8631733f4f0c32ba0d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 15 Sep 2018 23:19:41 +0300 Subject: kill old module_map --- crates/libanalysis/src/imp.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'crates/libanalysis/src/imp.rs') diff --git a/crates/libanalysis/src/imp.rs b/crates/libanalysis/src/imp.rs index 8734813f4..6f3191fe7 100644 --- a/crates/libanalysis/src/imp.rs +++ b/crates/libanalysis/src/imp.rs @@ -5,6 +5,7 @@ use std::{ }, fmt, collections::{HashSet, VecDeque}, + iter, }; use relative_path::RelativePath; @@ -75,14 +76,12 @@ impl AnalysisHostImpl { } pub fn change_files(&mut self, changes: &mut dyn Iterator)>) { let data = self.data_mut(); - for (file_id, text) in changes { - data.root.update(file_id, text); - } + data.root = Arc::new(data.root.apply_changes(changes, None)); } pub fn set_file_resolver(&mut self, resolver: FileResolverImp) { let data = self.data_mut(); data.file_resolver = resolver.clone(); - data.root.set_file_resolver(resolver); + data.root = Arc::new(data.root.apply_changes(&mut iter::empty(), Some(resolver))); } pub fn set_crate_graph(&mut self, graph: CrateGraph) { let mut visited = HashSet::new(); @@ -124,18 +123,17 @@ 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() } - pub fn file_syntax(&self, file_id: FileId) -> &File { + pub fn file_syntax(&self, file_id: FileId) -> File { self.root(file_id).syntax(file_id) } - pub fn file_line_index(&self, file_id: FileId) -> &LineIndex { + pub fn file_line_index(&self, file_id: FileId) -> Arc { self.root(file_id).lines(file_id) } pub fn world_symbols(&self, query: Query, token: &JobToken) -> Vec<(FileId, FileSymbol)> { - self.reindex(); let mut buf = Vec::new(); if query.libs { self.data.libs.iter() @@ -308,19 +306,13 @@ impl AnalysisImpl { }; module_tree.child_module_by_name(file_id, name.as_str()) } - - fn reindex(&self) { - if self.needs_reindex.compare_and_swap(true, false, SeqCst) { - self.data.root.reindex(); - } - } } #[derive(Default, Clone, Debug)] struct WorldData { file_resolver: FileResolverImp, crate_graph: CrateGraph, - root: WritableSourceRoot, + root: Arc, libs: Vec>, } -- cgit v1.2.3