diff options
Diffstat (limited to 'crates/libanalysis/src/imp.rs')
-rw-r--r-- | crates/libanalysis/src/imp.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/libanalysis/src/imp.rs b/crates/libanalysis/src/imp.rs index 97802bd50..6a6e1e933 100644 --- a/crates/libanalysis/src/imp.rs +++ b/crates/libanalysis/src/imp.rs | |||
@@ -23,6 +23,7 @@ use { | |||
23 | module_map::Problem, | 23 | module_map::Problem, |
24 | symbol_index::FileSymbols, | 24 | symbol_index::FileSymbols, |
25 | module_map::{ModuleMap, ChangeKind}, | 25 | module_map::{ModuleMap, ChangeKind}, |
26 | JobToken, | ||
26 | }; | 27 | }; |
27 | 28 | ||
28 | #[derive(Debug)] | 29 | #[derive(Debug)] |
@@ -111,9 +112,10 @@ impl AnalysisImpl { | |||
111 | .clone() | 112 | .clone() |
112 | } | 113 | } |
113 | 114 | ||
114 | pub fn world_symbols(&self, mut query: Query) -> Vec<(FileId, FileSymbol)> { | 115 | pub fn world_symbols(&self, mut query: Query, token: &JobToken) -> Vec<(FileId, FileSymbol)> { |
115 | self.reindex(); | 116 | self.reindex(); |
116 | self.data.file_map.iter() | 117 | self.data.file_map.iter() |
118 | .take_while(move |_| !token.is_canceled()) | ||
117 | .flat_map(move |(id, data)| { | 119 | .flat_map(move |(id, data)| { |
118 | let symbols = data.symbols(); | 120 | let symbols = data.symbols(); |
119 | query.process(symbols).into_iter().map(move |s| (*id, s)) | 121 | query.process(symbols).into_iter().map(move |s| (*id, s)) |
@@ -147,11 +149,12 @@ impl AnalysisImpl { | |||
147 | &self, | 149 | &self, |
148 | id: FileId, | 150 | id: FileId, |
149 | offset: TextUnit, | 151 | offset: TextUnit, |
152 | token: &JobToken, | ||
150 | ) -> Vec<(FileId, FileSymbol)> { | 153 | ) -> Vec<(FileId, FileSymbol)> { |
151 | let file = self.file_syntax(id); | 154 | let file = self.file_syntax(id); |
152 | let syntax = file.syntax(); | 155 | let syntax = file.syntax(); |
153 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { | 156 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { |
154 | return self.index_resolve(name_ref); | 157 | return self.index_resolve(name_ref, token); |
155 | } | 158 | } |
156 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, offset) { | 159 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, offset) { |
157 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { | 160 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { |
@@ -245,12 +248,12 @@ impl AnalysisImpl { | |||
245 | .collect() | 248 | .collect() |
246 | } | 249 | } |
247 | 250 | ||
248 | fn index_resolve(&self, name_ref: ast::NameRef) -> Vec<(FileId, FileSymbol)> { | 251 | fn index_resolve(&self, name_ref: ast::NameRef, token: &JobToken) -> Vec<(FileId, FileSymbol)> { |
249 | let name = name_ref.text(); | 252 | let name = name_ref.text(); |
250 | let mut query = Query::new(name.to_string()); | 253 | let mut query = Query::new(name.to_string()); |
251 | query.exact(); | 254 | query.exact(); |
252 | query.limit(4); | 255 | query.limit(4); |
253 | self.world_symbols(query) | 256 | self.world_symbols(query, token) |
254 | } | 257 | } |
255 | 258 | ||
256 | fn resolve_module(&self, id: FileId, module: ast::Module) -> Vec<FileId> { | 259 | fn resolve_module(&self, id: FileId, module: ast::Module) -> Vec<FileId> { |