diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-09-15 22:11:25 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-09-15 22:11:25 +0100 |
commit | 3993bb4de95af407e5edc1fe551bec0f001a3f0f (patch) | |
tree | 31893552cd739187080048df24a629d416174305 /crates/libanalysis/src/lib.rs | |
parent | 2a56b5c4f096736d6795eecb835cc2dc14b00107 (diff) | |
parent | fcdf3a52b4b61a39474950486ea0edf5ebf33bea (diff) |
Merge #67
67: Salsa r=matklad a=matklad
The aim of this PR is to transition from rather ad-hock FileData and ModuleMap caching strategy to something resembling a general-purpose red-green engine.
Ideally, we shouldn't recompute ModuleMap at all, unless the set of mod decls or files changes.
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/libanalysis/src/lib.rs')
-rw-r--r-- | crates/libanalysis/src/lib.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs index 80cde079f..b4b7a6a30 100644 --- a/crates/libanalysis/src/lib.rs +++ b/crates/libanalysis/src/lib.rs | |||
@@ -9,12 +9,17 @@ extern crate rayon; | |||
9 | extern crate relative_path; | 9 | extern crate relative_path; |
10 | #[macro_use] | 10 | #[macro_use] |
11 | extern crate crossbeam_channel; | 11 | extern crate crossbeam_channel; |
12 | extern crate im; | ||
13 | extern crate salsa; | ||
12 | 14 | ||
13 | mod symbol_index; | 15 | mod symbol_index; |
14 | mod module_map; | 16 | mod module_map; |
15 | mod imp; | 17 | mod imp; |
16 | mod job; | 18 | mod job; |
17 | mod roots; | 19 | mod roots; |
20 | mod db; | ||
21 | mod queries; | ||
22 | mod descriptors; | ||
18 | 23 | ||
19 | use std::{ | 24 | use std::{ |
20 | sync::Arc, | 25 | sync::Arc, |
@@ -161,8 +166,8 @@ impl Analysis { | |||
161 | pub fn file_syntax(&self, file_id: FileId) -> File { | 166 | pub fn file_syntax(&self, file_id: FileId) -> File { |
162 | self.imp.file_syntax(file_id).clone() | 167 | self.imp.file_syntax(file_id).clone() |
163 | } | 168 | } |
164 | pub fn file_line_index(&self, file_id: FileId) -> LineIndex { | 169 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { |
165 | self.imp.file_line_index(file_id).clone() | 170 | self.imp.file_line_index(file_id) |
166 | } | 171 | } |
167 | pub fn extend_selection(&self, file: &File, range: TextRange) -> TextRange { | 172 | pub fn extend_selection(&self, file: &File, range: TextRange) -> TextRange { |
168 | libeditor::extend_selection(file, range).unwrap_or(range) | 173 | libeditor::extend_selection(file, range).unwrap_or(range) |
@@ -172,19 +177,19 @@ impl Analysis { | |||
172 | } | 177 | } |
173 | pub fn syntax_tree(&self, file_id: FileId) -> String { | 178 | pub fn syntax_tree(&self, file_id: FileId) -> String { |
174 | let file = self.imp.file_syntax(file_id); | 179 | let file = self.imp.file_syntax(file_id); |
175 | libeditor::syntax_tree(file) | 180 | libeditor::syntax_tree(&file) |
176 | } | 181 | } |
177 | pub fn join_lines(&self, file_id: FileId, range: TextRange) -> SourceChange { | 182 | pub fn join_lines(&self, file_id: FileId, range: TextRange) -> SourceChange { |
178 | let file = self.imp.file_syntax(file_id); | 183 | let file = self.imp.file_syntax(file_id); |
179 | SourceChange::from_local_edit(file_id, "join lines", libeditor::join_lines(file, range)) | 184 | SourceChange::from_local_edit(file_id, "join lines", libeditor::join_lines(&file, range)) |
180 | } | 185 | } |
181 | pub fn on_eq_typed(&self, file_id: FileId, offset: TextUnit) -> Option<SourceChange> { | 186 | pub fn on_eq_typed(&self, file_id: FileId, offset: TextUnit) -> Option<SourceChange> { |
182 | let file = self.imp.file_syntax(file_id); | 187 | let file = self.imp.file_syntax(file_id); |
183 | Some(SourceChange::from_local_edit(file_id, "add semicolon", libeditor::on_eq_typed(file, offset)?)) | 188 | Some(SourceChange::from_local_edit(file_id, "add semicolon", libeditor::on_eq_typed(&file, offset)?)) |
184 | } | 189 | } |
185 | pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { | 190 | pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { |
186 | let file = self.imp.file_syntax(file_id); | 191 | let file = self.imp.file_syntax(file_id); |
187 | libeditor::file_structure(file) | 192 | libeditor::file_structure(&file) |
188 | } | 193 | } |
189 | pub fn symbol_search(&self, query: Query, token: &JobToken) -> Vec<(FileId, FileSymbol)> { | 194 | pub fn symbol_search(&self, query: Query, token: &JobToken) -> Vec<(FileId, FileSymbol)> { |
190 | self.imp.world_symbols(query, token) | 195 | self.imp.world_symbols(query, token) |
@@ -203,15 +208,15 @@ impl Analysis { | |||
203 | } | 208 | } |
204 | pub fn runnables(&self, file_id: FileId) -> Vec<Runnable> { | 209 | pub fn runnables(&self, file_id: FileId) -> Vec<Runnable> { |
205 | let file = self.imp.file_syntax(file_id); | 210 | let file = self.imp.file_syntax(file_id); |
206 | libeditor::runnables(file) | 211 | libeditor::runnables(&file) |
207 | } | 212 | } |
208 | pub fn highlight(&self, file_id: FileId) -> Vec<HighlightedRange> { | 213 | pub fn highlight(&self, file_id: FileId) -> Vec<HighlightedRange> { |
209 | let file = self.imp.file_syntax(file_id); | 214 | let file = self.imp.file_syntax(file_id); |
210 | libeditor::highlight(file) | 215 | libeditor::highlight(&file) |
211 | } | 216 | } |
212 | pub fn completions(&self, file_id: FileId, offset: TextUnit) -> Option<Vec<CompletionItem>> { | 217 | pub fn completions(&self, file_id: FileId, offset: TextUnit) -> Option<Vec<CompletionItem>> { |
213 | let file = self.imp.file_syntax(file_id); | 218 | let file = self.imp.file_syntax(file_id); |
214 | libeditor::scope_completion(file, offset) | 219 | libeditor::scope_completion(&file, offset) |
215 | } | 220 | } |
216 | pub fn assists(&self, file_id: FileId, range: TextRange) -> Vec<SourceChange> { | 221 | pub fn assists(&self, file_id: FileId, range: TextRange) -> Vec<SourceChange> { |
217 | self.imp.assists(file_id, range) | 222 | self.imp.assists(file_id, range) |