aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/imp.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-10-20 20:15:03 +0100
committerAleksey Kladov <[email protected]>2018-10-20 20:15:03 +0100
commite74bf6e56e45a26002ef2a77fb3ac27f523277fb (patch)
treef96443bfde82dc64bbccd01f78d80eccea2c8b63 /crates/ra_analysis/src/imp.rs
parent9fb41716de095fa365eecedab3427af7b5001644 (diff)
mark module queries as cacelable
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r--crates/ra_analysis/src/imp.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index d60fb8278..df5aacb2d 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -159,7 +159,7 @@ impl AnalysisImpl {
159 } 159 }
160 pub fn parent_module(&self, file_id: FileId) -> Cancelable<Vec<(FileId, FileSymbol)>> { 160 pub fn parent_module(&self, file_id: FileId) -> Cancelable<Vec<(FileId, FileSymbol)>> {
161 let root = self.root(file_id); 161 let root = self.root(file_id);
162 let module_tree = root.module_tree(); 162 let module_tree = root.module_tree()?;
163 let res = module_tree 163 let res = module_tree
164 .parent_modules(file_id) 164 .parent_modules(file_id)
165 .iter() 165 .iter()
@@ -177,8 +177,8 @@ impl AnalysisImpl {
177 .collect(); 177 .collect();
178 Ok(res) 178 Ok(res)
179 } 179 }
180 pub fn crate_for(&self, file_id: FileId) -> Vec<CrateId> { 180 pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> {
181 let module_tree = self.root(file_id).module_tree(); 181 let module_tree = self.root(file_id).module_tree()?;
182 let crate_graph = &self.data.crate_graph; 182 let crate_graph = &self.data.crate_graph;
183 let mut res = Vec::new(); 183 let mut res = Vec::new();
184 let mut work = VecDeque::new(); 184 let mut work = VecDeque::new();
@@ -196,7 +196,7 @@ impl AnalysisImpl {
196 .filter(|&id| visited.insert(id)); 196 .filter(|&id| visited.insert(id));
197 work.extend(parents); 197 work.extend(parents);
198 } 198 }
199 res 199 Ok(res)
200 } 200 }
201 pub fn crate_root(&self, crate_id: CrateId) -> FileId { 201 pub fn crate_root(&self, crate_id: CrateId) -> FileId {
202 self.data.crate_graph.crate_roots[&crate_id] 202 self.data.crate_graph.crate_roots[&crate_id]
@@ -205,9 +205,9 @@ impl AnalysisImpl {
205 &self, 205 &self,
206 file_id: FileId, 206 file_id: FileId,
207 offset: TextUnit, 207 offset: TextUnit,
208 ) -> Vec<(FileId, FileSymbol)> { 208 ) -> Cancelable<Vec<(FileId, FileSymbol)>> {
209 let root = self.root(file_id); 209 let root = self.root(file_id);
210 let module_tree = root.module_tree(); 210 let module_tree = root.module_tree()?;
211 let file = root.syntax(file_id); 211 let file = root.syntax(file_id);
212 let syntax = file.syntax(); 212 let syntax = file.syntax();
213 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { 213 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) {
@@ -223,10 +223,10 @@ impl AnalysisImpl {
223 }, 223 },
224 )); 224 ));
225 225
226 return vec; 226 return Ok(vec);
227 } else { 227 } else {
228 // If that fails try the index based approach. 228 // If that fails try the index based approach.
229 return self.index_resolve(name_ref); 229 return Ok(self.index_resolve(name_ref));
230 } 230 }
231 } 231 }
232 if let Some(name) = find_node_at_offset::<ast::Name>(syntax, offset) { 232 if let Some(name) = find_node_at_offset::<ast::Name>(syntax, offset) {
@@ -250,11 +250,11 @@ impl AnalysisImpl {
250 }) 250 })
251 .collect(); 251 .collect();
252 252
253 return res; 253 return Ok(res);
254 } 254 }
255 } 255 }
256 } 256 }
257 vec![] 257 Ok(vec![])
258 } 258 }
259 259
260 pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit) -> Vec<(FileId, TextRange)> { 260 pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit) -> Vec<(FileId, TextRange)> {
@@ -289,9 +289,9 @@ impl AnalysisImpl {
289 ret 289 ret
290 } 290 }
291 291
292 pub fn diagnostics(&self, file_id: FileId) -> Vec<Diagnostic> { 292 pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> {
293 let root = self.root(file_id); 293 let root = self.root(file_id);
294 let module_tree = root.module_tree(); 294 let module_tree = root.module_tree()?;
295 let syntax = root.syntax(file_id); 295 let syntax = root.syntax(file_id);
296 296
297 let mut res = ra_editor::diagnostics(&syntax) 297 let mut res = ra_editor::diagnostics(&syntax)
@@ -346,7 +346,7 @@ impl AnalysisImpl {
346 }; 346 };
347 res.push(diag) 347 res.push(diag)
348 } 348 }
349 res 349 Ok(res)
350 } 350 }
351 351
352 pub fn assists(&self, file_id: FileId, range: TextRange) -> Vec<SourceChange> { 352 pub fn assists(&self, file_id: FileId, range: TextRange) -> Vec<SourceChange> {