diff options
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 9 | ||||
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 8 |
2 files changed, 12 insertions, 5 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 51bcd5a73..54f38b285 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -43,14 +43,17 @@ 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 { | ||
47 | self.db | ||
48 | .query_mut(ra_db::SourceRootQuery) | ||
49 | .set(root_id, Default::default()); | ||
50 | } | ||
46 | 51 | ||
47 | for (root_id, root_change) in change.roots_changed { | 52 | for (root_id, root_change) in change.roots_changed { |
48 | self.apply_root_change(root_id, root_change); | 53 | self.apply_root_change(root_id, root_change); |
49 | } | 54 | } |
50 | for (file_id, text) in change.files_changed { | 55 | for (file_id, text) in change.files_changed { |
51 | self.db | 56 | self.db.query_mut(ra_db::FileTextQuery).set(file_id, text) |
52 | .query_mut(ra_db::FileTextQuery) | ||
53 | .set(file_id, Arc::new(text)) | ||
54 | } | 57 | } |
55 | if !change.libraries_added.is_empty() { | 58 | if !change.libraries_added.is_empty() { |
56 | let mut libraries = Vec::clone(&self.db.libraries()); | 59 | let mut libraries = Vec::clone(&self.db.libraries()); |
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index b806c974d..8882feca3 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -44,8 +44,9 @@ pub use ra_db::{ | |||
44 | 44 | ||
45 | #[derive(Default)] | 45 | #[derive(Default)] |
46 | pub struct AnalysisChange { | 46 | pub struct AnalysisChange { |
47 | new_roots: Vec<SourceRootId>, | ||
47 | roots_changed: FxHashMap<SourceRootId, RootChange>, | 48 | roots_changed: FxHashMap<SourceRootId, RootChange>, |
48 | files_changed: Vec<(FileId, String)>, | 49 | files_changed: Vec<(FileId, Arc<String>)>, |
49 | libraries_added: Vec<LibraryData>, | 50 | libraries_added: Vec<LibraryData>, |
50 | crate_graph: Option<CrateGraph>, | 51 | crate_graph: Option<CrateGraph>, |
51 | } | 52 | } |
@@ -93,6 +94,9 @@ impl AnalysisChange { | |||
93 | pub fn new() -> AnalysisChange { | 94 | pub fn new() -> AnalysisChange { |
94 | AnalysisChange::default() | 95 | AnalysisChange::default() |
95 | } | 96 | } |
97 | pub fn add_root(&mut self, root_id: SourceRootId) { | ||
98 | self.new_roots.push(root_id); | ||
99 | } | ||
96 | pub fn add_file( | 100 | pub fn add_file( |
97 | &mut self, | 101 | &mut self, |
98 | root_id: SourceRootId, | 102 | root_id: SourceRootId, |
@@ -111,7 +115,7 @@ impl AnalysisChange { | |||
111 | .added | 115 | .added |
112 | .push(file); | 116 | .push(file); |
113 | } | 117 | } |
114 | pub fn change_file(&mut self, file_id: FileId, new_text: String) { | 118 | pub fn change_file(&mut self, file_id: FileId, new_text: Arc<String>) { |
115 | self.files_changed.push((file_id, new_text)) | 119 | self.files_changed.push((file_id, new_text)) |
116 | } | 120 | } |
117 | pub fn remove_file(&mut self, root_id: SourceRootId, file_id: FileId, path: RelativePathBuf) { | 121 | pub fn remove_file(&mut self, root_id: SourceRootId, file_id: FileId, path: RelativePathBuf) { |