diff options
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 32 |
1 files 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 { | |||
73 | .set(library.root_id, Default::default()); | 73 | .set(library.root_id, Default::default()); |
74 | self.db | 74 | self.db |
75 | .query_mut(LibrarySymbolsQuery) | 75 | .query_mut(LibrarySymbolsQuery) |
76 | .set(library.root_id, Arc::new(library.symbol_index)); | 76 | .set_constant(library.root_id, Arc::new(library.symbol_index)); |
77 | self.apply_root_change(library.root_id, library.root_change); | 77 | self.apply_root_change_constant(library.root_id, library.root_change); |
78 | } | 78 | } |
79 | self.db | 79 | self.db |
80 | .query_mut(ra_db::LibraryRootsQuery) | 80 | .query_mut(ra_db::LibraryRootsQuery) |
@@ -115,6 +115,34 @@ impl AnalysisHostImpl { | |||
115 | .set(root_id, Arc::new(source_root)); | 115 | .set(root_id, Arc::new(source_root)); |
116 | } | 116 | } |
117 | 117 | ||
118 | fn apply_root_change_constant(&mut self, root_id: SourceRootId, root_change: RootChange) { | ||
119 | let mut source_root = SourceRoot::clone(&self.db.source_root(root_id)); | ||
120 | for add_file in root_change.added { | ||
121 | self.db | ||
122 | .query_mut(ra_db::FileTextQuery) | ||
123 | .set_constant(add_file.file_id, add_file.text); | ||
124 | self.db | ||
125 | .query_mut(ra_db::FileRelativePathQuery) | ||
126 | .set_constant(add_file.file_id, add_file.path.clone()); | ||
127 | self.db | ||
128 | .query_mut(ra_db::FileSourceRootQuery) | ||
129 | .set_constant(add_file.file_id, root_id); | ||
130 | source_root.files.insert(add_file.path, add_file.file_id); | ||
131 | } | ||
132 | for remove_file in root_change.removed { | ||
133 | self.db | ||
134 | .query_mut(ra_db::FileTextQuery) | ||
135 | .set_constant(remove_file.file_id, Default::default()); | ||
136 | self.db | ||
137 | .query_mut(ra_db::FileRelativePathQuery) | ||
138 | .set_constant(remove_file.file_id, Default::default()); | ||
139 | source_root.files.remove(&remove_file.path); | ||
140 | } | ||
141 | self.db | ||
142 | .query_mut(ra_db::SourceRootQuery) | ||
143 | .set_constant(root_id, Arc::new(source_root)); | ||
144 | } | ||
145 | |||
118 | #[allow(unused)] | 146 | #[allow(unused)] |
119 | /// Ideally, we should call this function from time to time to collect heavy | 147 | /// Ideally, we should call this function from time to time to collect heavy |
120 | /// syntax trees. However, if we actually do that, everything is recomputed | 148 | /// syntax trees. However, if we actually do that, everything is recomputed |