aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r--crates/ra_analysis/src/imp.rs15
-rw-r--r--crates/ra_analysis/src/lib.rs6
-rw-r--r--crates/ra_analysis/src/mock_analysis.rs2
3 files changed, 16 insertions, 7 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 46169d863..9e441ca79 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -43,10 +43,19 @@ impl AnalysisHostImpl {
43 pub fn apply_change(&mut self, change: AnalysisChange) { 43 pub fn apply_change(&mut self, change: AnalysisChange) {
44 log::info!("apply_change {:?}", change); 44 log::info!("apply_change {:?}", change);
45 // self.gc_syntax_trees(); 45 // self.gc_syntax_trees();
46 for root_id in change.new_roots { 46 if !change.new_roots.is_empty() {
47 let mut local_roots = Vec::clone(&self.db.local_roots());
48 for (root_id, is_local) in change.new_roots {
49 self.db
50 .query_mut(ra_db::SourceRootQuery)
51 .set(root_id, Default::default());
52 if is_local {
53 local_roots.push(root_id);
54 }
55 }
47 self.db 56 self.db
48 .query_mut(ra_db::SourceRootQuery) 57 .query_mut(ra_db::LocalRootsQuery)
49 .set(root_id, Default::default()); 58 .set((), Arc::new(local_roots));
50 } 59 }
51 60
52 for (root_id, root_change) in change.roots_changed { 61 for (root_id, root_change) in change.roots_changed {
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index 0db3c3479..a1d462528 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -44,7 +44,7 @@ pub use ra_db::{
44 44
45#[derive(Default)] 45#[derive(Default)]
46pub struct AnalysisChange { 46pub struct AnalysisChange {
47 new_roots: Vec<SourceRootId>, 47 new_roots: Vec<(SourceRootId, bool)>,
48 roots_changed: FxHashMap<SourceRootId, RootChange>, 48 roots_changed: FxHashMap<SourceRootId, RootChange>,
49 files_changed: Vec<(FileId, Arc<String>)>, 49 files_changed: Vec<(FileId, Arc<String>)>,
50 libraries_added: Vec<LibraryData>, 50 libraries_added: Vec<LibraryData>,
@@ -95,8 +95,8 @@ impl AnalysisChange {
95 pub fn new() -> AnalysisChange { 95 pub fn new() -> AnalysisChange {
96 AnalysisChange::default() 96 AnalysisChange::default()
97 } 97 }
98 pub fn add_root(&mut self, root_id: SourceRootId) { 98 pub fn add_root(&mut self, root_id: SourceRootId, is_local: bool) {
99 self.new_roots.push(root_id); 99 self.new_roots.push((root_id, is_local));
100 } 100 }
101 pub fn add_file( 101 pub fn add_file(
102 &mut self, 102 &mut self,
diff --git a/crates/ra_analysis/src/mock_analysis.rs b/crates/ra_analysis/src/mock_analysis.rs
index 0c042e672..7cbdfb953 100644
--- a/crates/ra_analysis/src/mock_analysis.rs
+++ b/crates/ra_analysis/src/mock_analysis.rs
@@ -80,7 +80,7 @@ impl MockAnalysis {
80 let mut file_map = FileMap::default(); 80 let mut file_map = FileMap::default();
81 let source_root = SourceRootId(0); 81 let source_root = SourceRootId(0);
82 let mut change = AnalysisChange::new(); 82 let mut change = AnalysisChange::new();
83 change.add_root(source_root); 83 change.add_root(source_root, true);
84 for (path, contents) in self.files.into_iter() { 84 for (path, contents) in self.files.into_iter() {
85 assert!(path.starts_with('/')); 85 assert!(path.starts_with('/'));
86 let path = RelativePathBuf::from_path(&path[1..]).unwrap(); 86 let path = RelativePathBuf::from_path(&path[1..]).unwrap();