aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-10-20 20:02:41 +0100
committerAleksey Kladov <[email protected]>2018-10-20 20:02:41 +0100
commit998f2ae7627053a9363a05a1ab79359882dce39f (patch)
tree6be2e60ebae8c03d117edec200aa942d810b3e31 /crates
parentc4b0d3cd56ab68f4fa23f7c1f6c76f7f6148153e (diff)
remove job tokens
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/imp.rs16
-rw-r--r--crates/ra_analysis/src/lib.rs44
-rw-r--r--crates/ra_analysis/src/symbol_index.rs5
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs62
4 files changed, 61 insertions, 66 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 3a135ef13..4cfb681d8 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -148,14 +148,14 @@ impl AnalysisImpl {
148 pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { 148 pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> {
149 self.root(file_id).lines(file_id) 149 self.root(file_id).lines(file_id)
150 } 150 }
151 pub fn world_symbols(&self, query: Query, token: &JobToken) -> Vec<(FileId, FileSymbol)> { 151 pub fn world_symbols(&self, query: Query) -> Vec<(FileId, FileSymbol)> {
152 let mut buf = Vec::new(); 152 let mut buf = Vec::new();
153 if query.libs { 153 if query.libs {
154 self.data.libs.iter().for_each(|it| it.symbols(&mut buf)); 154 self.data.libs.iter().for_each(|it| it.symbols(&mut buf));
155 } else { 155 } else {
156 self.data.root.symbols(&mut buf); 156 self.data.root.symbols(&mut buf);
157 } 157 }
158 query.search(&buf, token) 158 query.search(&buf)
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);
@@ -205,7 +205,6 @@ impl AnalysisImpl {
205 &self, 205 &self,
206 file_id: FileId, 206 file_id: FileId,
207 offset: TextUnit, 207 offset: TextUnit,
208 token: &JobToken,
209 ) -> Vec<(FileId, FileSymbol)> { 208 ) -> Vec<(FileId, FileSymbol)> {
210 let root = self.root(file_id); 209 let root = self.root(file_id);
211 let module_tree = root.module_tree(); 210 let module_tree = root.module_tree();
@@ -227,7 +226,7 @@ impl AnalysisImpl {
227 return vec; 226 return vec;
228 } else { 227 } else {
229 // If that fails try the index based approach. 228 // If that fails try the index based approach.
230 return self.index_resolve(name_ref, token); 229 return self.index_resolve(name_ref);
231 } 230 }
232 } 231 }
233 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) {
@@ -258,7 +257,7 @@ impl AnalysisImpl {
258 vec![] 257 vec![]
259 } 258 }
260 259
261 pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit, _token: &JobToken) -> Vec<(FileId, TextRange)> { 260 pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit) -> Vec<(FileId, TextRange)> {
262 let root = self.root(file_id); 261 let root = self.root(file_id);
263 let file = root.syntax(file_id); 262 let file = root.syntax(file_id);
264 let syntax = file.syntax(); 263 let syntax = file.syntax();
@@ -380,7 +379,6 @@ impl AnalysisImpl {
380 &self, 379 &self,
381 file_id: FileId, 380 file_id: FileId,
382 offset: TextUnit, 381 offset: TextUnit,
383 token: &JobToken,
384 ) -> Option<(FnDescriptor, Option<usize>)> { 382 ) -> Option<(FnDescriptor, Option<usize>)> {
385 let root = self.root(file_id); 383 let root = self.root(file_id);
386 let file = root.syntax(file_id); 384 let file = root.syntax(file_id);
@@ -391,7 +389,7 @@ impl AnalysisImpl {
391 let name_ref = calling_node.name_ref()?; 389 let name_ref = calling_node.name_ref()?;
392 390
393 // Resolve the function's NameRef (NOTE: this isn't entirely accurate). 391 // Resolve the function's NameRef (NOTE: this isn't entirely accurate).
394 let file_symbols = self.index_resolve(name_ref, token); 392 let file_symbols = self.index_resolve(name_ref);
395 for (_, fs) in file_symbols { 393 for (_, fs) in file_symbols {
396 if fs.kind == FN_DEF { 394 if fs.kind == FN_DEF {
397 if let Some(fn_def) = find_node_at_offset(syntax, fs.node_range.start()) { 395 if let Some(fn_def) = find_node_at_offset(syntax, fs.node_range.start()) {
@@ -442,12 +440,12 @@ impl AnalysisImpl {
442 None 440 None
443 } 441 }
444 442
445 fn index_resolve(&self, name_ref: ast::NameRef, token: &JobToken) -> Vec<(FileId, FileSymbol)> { 443 fn index_resolve(&self, name_ref: ast::NameRef) -> Vec<(FileId, FileSymbol)> {
446 let name = name_ref.text(); 444 let name = name_ref.text();
447 let mut query = Query::new(name.to_string()); 445 let mut query = Query::new(name.to_string());
448 query.exact(); 446 query.exact();
449 query.limit(4); 447 query.limit(4);
450 self.world_symbols(query, token) 448 self.world_symbols(query)
451 } 449 }
452 450
453 fn resolve_module( 451 fn resolve_module(
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index 988a45b46..7e9798c29 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -219,47 +219,46 @@ impl Analysis {
219 let file = self.imp.file_syntax(file_id); 219 let file = self.imp.file_syntax(file_id);
220 ra_editor::file_structure(&file) 220 ra_editor::file_structure(&file)
221 } 221 }
222 pub fn symbol_search(&self, query: Query, token: &JobToken) -> Vec<(FileId, FileSymbol)> { 222 pub fn symbol_search(&self, query: Query) -> Vec<(FileId, FileSymbol)> {
223 self.imp.world_symbols(query, token) 223 self.imp.world_symbols(query)
224 } 224 }
225 pub fn approximately_resolve_symbol( 225 pub fn approximately_resolve_symbol(
226 &self, 226 &self,
227 file_id: FileId, 227 file_id: FileId,
228 offset: TextUnit, 228 offset: TextUnit
229 token: &JobToken,
230 ) -> Vec<(FileId, FileSymbol)> { 229 ) -> Vec<(FileId, FileSymbol)> {
231 self.imp 230 self.imp
232 .approximately_resolve_symbol(file_id, offset, token) 231 .approximately_resolve_symbol(file_id, offset)
233 } 232 }
234 pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit, token: &JobToken) -> Vec<(FileId, TextRange)> { 233 pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit, ) -> Vec<(FileId, TextRange)> {
235 self.imp.find_all_refs(file_id, offset, token) 234 self.imp.find_all_refs(file_id, offset)
236 } 235 }
237 pub fn parent_module(&self, file_id: FileId) -> Cancelable<Vec<(FileId, FileSymbol)>> { 236 pub fn parent_module(&self, file_id: FileId) -> Cancelable<Vec<(FileId, FileSymbol)>> {
238 self.imp.parent_module(file_id) 237 self.imp.parent_module(file_id)
239 } 238 }
240 pub fn crate_for(&self, file_id: FileId) -> Vec<CrateId> { 239 pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> {
241 self.imp.crate_for(file_id) 240 Ok(self.imp.crate_for(file_id))
242 } 241 }
243 pub fn crate_root(&self, crate_id: CrateId) -> FileId { 242 pub fn crate_root(&self, crate_id: CrateId) -> Cancelable<FileId> {
244 self.imp.crate_root(crate_id) 243 Ok(self.imp.crate_root(crate_id))
245 } 244 }
246 pub fn runnables(&self, file_id: FileId) -> Vec<Runnable> { 245 pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> {
247 let file = self.imp.file_syntax(file_id); 246 let file = self.imp.file_syntax(file_id);
248 ra_editor::runnables(&file) 247 Ok(ra_editor::runnables(&file))
249 } 248 }
250 pub fn highlight(&self, file_id: FileId) -> Vec<HighlightedRange> { 249 pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> {
251 let file = self.imp.file_syntax(file_id); 250 let file = self.imp.file_syntax(file_id);
252 ra_editor::highlight(&file) 251 Ok(ra_editor::highlight(&file))
253 } 252 }
254 pub fn completions(&self, file_id: FileId, offset: TextUnit) -> Option<Vec<CompletionItem>> { 253 pub fn completions(&self, file_id: FileId, offset: TextUnit) -> Cancelable<Option<Vec<CompletionItem>>> {
255 let file = self.imp.file_syntax(file_id); 254 let file = self.imp.file_syntax(file_id);
256 ra_editor::scope_completion(&file, offset) 255 Ok(ra_editor::scope_completion(&file, offset))
257 } 256 }
258 pub fn assists(&self, file_id: FileId, range: TextRange) -> Vec<SourceChange> { 257 pub fn assists(&self, file_id: FileId, range: TextRange) -> Cancelable<Vec<SourceChange>> {
259 self.imp.assists(file_id, range) 258 Ok(self.imp.assists(file_id, range))
260 } 259 }
261 pub fn diagnostics(&self, file_id: FileId) -> Vec<Diagnostic> { 260 pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> {
262 self.imp.diagnostics(file_id) 261 Ok(self.imp.diagnostics(file_id))
263 } 262 }
264 pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> { 263 pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> {
265 let file = self.imp.file_syntax(file_id); 264 let file = self.imp.file_syntax(file_id);
@@ -270,9 +269,8 @@ impl Analysis {
270 &self, 269 &self,
271 file_id: FileId, 270 file_id: FileId,
272 offset: TextUnit, 271 offset: TextUnit,
273 token: &JobToken,
274 ) -> Option<(FnDescriptor, Option<usize>)> { 272 ) -> Option<(FnDescriptor, Option<usize>)> {
275 self.imp.resolve_callable(file_id, offset, token) 273 self.imp.resolve_callable(file_id, offset)
276 } 274 }
277} 275}
278 276
diff --git a/crates/ra_analysis/src/symbol_index.rs b/crates/ra_analysis/src/symbol_index.rs
index 51eef8170..19f9ea47d 100644
--- a/crates/ra_analysis/src/symbol_index.rs
+++ b/crates/ra_analysis/src/symbol_index.rs
@@ -1,4 +1,4 @@
1use crate::{FileId, JobToken, Query}; 1use crate::{FileId, Query};
2use fst::{self, Streamer}; 2use fst::{self, Streamer};
3use ra_editor::{file_symbols, FileSymbol}; 3use ra_editor::{file_symbols, FileSymbol};
4use ra_syntax::{ 4use ra_syntax::{
@@ -59,7 +59,6 @@ impl Query {
59 pub(crate) fn search( 59 pub(crate) fn search(
60 self, 60 self,
61 indices: &[Arc<SymbolIndex>], 61 indices: &[Arc<SymbolIndex>],
62 token: &JobToken,
63 ) -> Vec<(FileId, FileSymbol)> { 62 ) -> Vec<(FileId, FileSymbol)> {
64 let mut op = fst::map::OpBuilder::new(); 63 let mut op = fst::map::OpBuilder::new();
65 for file_symbols in indices.iter() { 64 for file_symbols in indices.iter() {
@@ -69,7 +68,7 @@ impl Query {
69 let mut stream = op.union(); 68 let mut stream = op.union();
70 let mut res = Vec::new(); 69 let mut res = Vec::new();
71 while let Some((_, indexed_values)) = stream.next() { 70 while let Some((_, indexed_values)) = stream.next() {
72 if res.len() >= self.limit || token.is_canceled() { 71 if res.len() >= self.limit {
73 break; 72 break;
74 } 73 }
75 for indexed_value in indexed_values { 74 for indexed_value in indexed_values {
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index b0b983d0c..9e76a51c1 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -161,7 +161,7 @@ pub fn handle_document_symbol(
161pub fn handle_workspace_symbol( 161pub fn handle_workspace_symbol(
162 world: ServerWorld, 162 world: ServerWorld,
163 params: req::WorkspaceSymbolParams, 163 params: req::WorkspaceSymbolParams,
164 token: JobToken, 164 _token: JobToken,
165) -> Result<Option<Vec<SymbolInformation>>> { 165) -> Result<Option<Vec<SymbolInformation>>> {
166 let all_symbols = params.query.contains("#"); 166 let all_symbols = params.query.contains("#");
167 let libs = params.query.contains("*"); 167 let libs = params.query.contains("*");
@@ -181,11 +181,11 @@ pub fn handle_workspace_symbol(
181 q.limit(128); 181 q.limit(128);
182 q 182 q
183 }; 183 };
184 let mut res = exec_query(&world, query, &token)?; 184 let mut res = exec_query(&world, query)?;
185 if res.is_empty() && !all_symbols { 185 if res.is_empty() && !all_symbols {
186 let mut query = Query::new(params.query); 186 let mut query = Query::new(params.query);
187 query.limit(128); 187 query.limit(128);
188 res = exec_query(&world, query, &token)?; 188 res = exec_query(&world, query)?;
189 } 189 }
190 190
191 return Ok(Some(res)); 191 return Ok(Some(res));
@@ -193,10 +193,9 @@ pub fn handle_workspace_symbol(
193 fn exec_query( 193 fn exec_query(
194 world: &ServerWorld, 194 world: &ServerWorld,
195 query: Query, 195 query: Query,
196 token: &JobToken,
197 ) -> Result<Vec<SymbolInformation>> { 196 ) -> Result<Vec<SymbolInformation>> {
198 let mut res = Vec::new(); 197 let mut res = Vec::new();
199 for (file_id, symbol) in world.analysis().symbol_search(query, token) { 198 for (file_id, symbol) in world.analysis().symbol_search(query) {
200 let line_index = world.analysis().file_line_index(file_id); 199 let line_index = world.analysis().file_line_index(file_id);
201 let info = SymbolInformation { 200 let info = SymbolInformation {
202 name: symbol.name.to_string(), 201 name: symbol.name.to_string(),
@@ -214,7 +213,7 @@ pub fn handle_workspace_symbol(
214pub fn handle_goto_definition( 213pub fn handle_goto_definition(
215 world: ServerWorld, 214 world: ServerWorld,
216 params: req::TextDocumentPositionParams, 215 params: req::TextDocumentPositionParams,
217 token: JobToken, 216 _token: JobToken,
218) -> Result<Option<req::GotoDefinitionResponse>> { 217) -> Result<Option<req::GotoDefinitionResponse>> {
219 let file_id = params.text_document.try_conv_with(&world)?; 218 let file_id = params.text_document.try_conv_with(&world)?;
220 let line_index = world.analysis().file_line_index(file_id); 219 let line_index = world.analysis().file_line_index(file_id);
@@ -222,7 +221,7 @@ pub fn handle_goto_definition(
222 let mut res = Vec::new(); 221 let mut res = Vec::new();
223 for (file_id, symbol) in world 222 for (file_id, symbol) in world
224 .analysis() 223 .analysis()
225 .approximately_resolve_symbol(file_id, offset, &token) 224 .approximately_resolve_symbol(file_id, offset)
226 { 225 {
227 let line_index = world.analysis().file_line_index(file_id); 226 let line_index = world.analysis().file_line_index(file_id);
228 let location = to_location(file_id, symbol.node_range, &world, &line_index)?; 227 let location = to_location(file_id, symbol.node_range, &world, &line_index)?;
@@ -255,14 +254,14 @@ pub fn handle_runnables(
255 let line_index = world.analysis().file_line_index(file_id); 254 let line_index = world.analysis().file_line_index(file_id);
256 let offset = params.position.map(|it| it.conv_with(&line_index)); 255 let offset = params.position.map(|it| it.conv_with(&line_index));
257 let mut res = Vec::new(); 256 let mut res = Vec::new();
258 for runnable in world.analysis().runnables(file_id) { 257 for runnable in world.analysis().runnables(file_id)? {
259 if let Some(offset) = offset { 258 if let Some(offset) = offset {
260 if !contains_offset_nonstrict(runnable.range, offset) { 259 if !contains_offset_nonstrict(runnable.range, offset) {
261 continue; 260 continue;
262 } 261 }
263 } 262 }
264 263
265 let args = runnable_args(&world, file_id, &runnable.kind); 264 let args = runnable_args(&world, file_id, &runnable.kind)?;
266 265
267 let r = req::Runnable { 266 let r = req::Runnable {
268 range: runnable.range.conv_with(&line_index), 267 range: runnable.range.conv_with(&line_index),
@@ -282,9 +281,9 @@ pub fn handle_runnables(
282 } 281 }
283 return Ok(res); 282 return Ok(res);
284 283
285 fn runnable_args(world: &ServerWorld, file_id: FileId, kind: &RunnableKind) -> Vec<String> { 284 fn runnable_args(world: &ServerWorld, file_id: FileId, kind: &RunnableKind) -> Result<Vec<String>> {
286 let spec = if let Some(&crate_id) = world.analysis().crate_for(file_id).first() { 285 let spec = if let Some(&crate_id) = world.analysis().crate_for(file_id)?.first() {
287 let file_id = world.analysis().crate_root(crate_id); 286 let file_id = world.analysis().crate_root(crate_id)?;
288 let path = world.path_map.get_path(file_id); 287 let path = world.path_map.get_path(file_id);
289 world 288 world
290 .workspaces 289 .workspaces
@@ -319,7 +318,7 @@ pub fn handle_runnables(
319 } 318 }
320 } 319 }
321 } 320 }
322 res 321 Ok(res)
323 } 322 }
324 323
325 fn spec_args(pkg_name: &str, tgt_name: &str, tgt_kind: TargetKind, buf: &mut Vec<String>) { 324 fn spec_args(pkg_name: &str, tgt_name: &str, tgt_kind: TargetKind, buf: &mut Vec<String>) {
@@ -356,7 +355,7 @@ pub fn handle_decorations(
356 _token: JobToken, 355 _token: JobToken,
357) -> Result<Vec<Decoration>> { 356) -> Result<Vec<Decoration>> {
358 let file_id = params.try_conv_with(&world)?; 357 let file_id = params.try_conv_with(&world)?;
359 Ok(highlight(&world, file_id)) 358 highlight(&world, file_id)
360} 359}
361 360
362pub fn handle_completion( 361pub fn handle_completion(
@@ -367,7 +366,7 @@ pub fn handle_completion(
367 let file_id = params.text_document.try_conv_with(&world)?; 366 let file_id = params.text_document.try_conv_with(&world)?;
368 let line_index = world.analysis().file_line_index(file_id); 367 let line_index = world.analysis().file_line_index(file_id);
369 let offset = params.position.conv_with(&line_index); 368 let offset = params.position.conv_with(&line_index);
370 let items = match world.analysis().completions(file_id, offset) { 369 let items = match world.analysis().completions(file_id, offset)? {
371 None => return Ok(None), 370 None => return Ok(None),
372 Some(items) => items, 371 Some(items) => items,
373 }; 372 };
@@ -427,7 +426,7 @@ pub fn handle_folding_range(
427pub fn handle_signature_help( 426pub fn handle_signature_help(
428 world: ServerWorld, 427 world: ServerWorld,
429 params: req::TextDocumentPositionParams, 428 params: req::TextDocumentPositionParams,
430 token: JobToken, 429 _token: JobToken,
431) -> Result<Option<req::SignatureHelp>> { 430) -> Result<Option<req::SignatureHelp>> {
432 use languageserver_types::{ParameterInformation, SignatureInformation}; 431 use languageserver_types::{ParameterInformation, SignatureInformation};
433 432
@@ -436,7 +435,7 @@ pub fn handle_signature_help(
436 let offset = params.position.conv_with(&line_index); 435 let offset = params.position.conv_with(&line_index);
437 436
438 if let Some((descriptor, active_param)) = 437 if let Some((descriptor, active_param)) =
439 world.analysis().resolve_callable(file_id, offset, &token) 438 world.analysis().resolve_callable(file_id, offset)
440 { 439 {
441 let parameters: Vec<ParameterInformation> = descriptor 440 let parameters: Vec<ParameterInformation> = descriptor
442 .params 441 .params
@@ -466,7 +465,7 @@ pub fn handle_signature_help(
466pub fn handle_prepare_rename( 465pub fn handle_prepare_rename(
467 world: ServerWorld, 466 world: ServerWorld,
468 params: req::TextDocumentPositionParams, 467 params: req::TextDocumentPositionParams,
469 token: JobToken, 468 _token: JobToken,
470) -> Result<Option<PrepareRenameResponse>> { 469) -> Result<Option<PrepareRenameResponse>> {
471 let file_id = params.text_document.try_conv_with(&world)?; 470 let file_id = params.text_document.try_conv_with(&world)?;
472 let line_index = world.analysis().file_line_index(file_id); 471 let line_index = world.analysis().file_line_index(file_id);
@@ -474,7 +473,7 @@ pub fn handle_prepare_rename(
474 473
475 // We support renaming references like handle_rename does. 474 // We support renaming references like handle_rename does.
476 // In the future we may want to reject the renaming of things like keywords here too. 475 // In the future we may want to reject the renaming of things like keywords here too.
477 let refs = world.analysis().find_all_refs(file_id, offset, &token); 476 let refs = world.analysis().find_all_refs(file_id, offset);
478 if refs.is_empty() { 477 if refs.is_empty() {
479 return Ok(None); 478 return Ok(None);
480 } 479 }
@@ -488,7 +487,7 @@ pub fn handle_prepare_rename(
488pub fn handle_rename( 487pub fn handle_rename(
489 world: ServerWorld, 488 world: ServerWorld,
490 params: RenameParams, 489 params: RenameParams,
491 token: JobToken, 490 _token: JobToken,
492) -> Result<Option<WorkspaceEdit>> { 491) -> Result<Option<WorkspaceEdit>> {
493 let file_id = params.text_document.try_conv_with(&world)?; 492 let file_id = params.text_document.try_conv_with(&world)?;
494 let line_index = world.analysis().file_line_index(file_id); 493 let line_index = world.analysis().file_line_index(file_id);
@@ -498,7 +497,7 @@ pub fn handle_rename(
498 return Ok(None); 497 return Ok(None);
499 } 498 }
500 499
501 let refs = world.analysis().find_all_refs(file_id, offset, &token); 500 let refs = world.analysis().find_all_refs(file_id, offset);
502 if refs.is_empty() { 501 if refs.is_empty() {
503 return Ok(None); 502 return Ok(None);
504 } 503 }
@@ -525,13 +524,13 @@ pub fn handle_rename(
525pub fn handle_references( 524pub fn handle_references(
526 world: ServerWorld, 525 world: ServerWorld,
527 params: req::ReferenceParams, 526 params: req::ReferenceParams,
528 token: JobToken, 527 _token: JobToken,
529) -> Result<Option<Vec<Location>>> { 528) -> Result<Option<Vec<Location>>> {
530 let file_id = params.text_document.try_conv_with(&world)?; 529 let file_id = params.text_document.try_conv_with(&world)?;
531 let line_index = world.analysis().file_line_index(file_id); 530 let line_index = world.analysis().file_line_index(file_id);
532 let offset = params.position.conv_with(&line_index); 531 let offset = params.position.conv_with(&line_index);
533 532
534 let refs = world.analysis().find_all_refs(file_id, offset, &token); 533 let refs = world.analysis().find_all_refs(file_id, offset);
535 534
536 Ok(Some(refs.into_iter() 535 Ok(Some(refs.into_iter()
537 .filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok()) 536 .filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok())
@@ -547,10 +546,10 @@ pub fn handle_code_action(
547 let line_index = world.analysis().file_line_index(file_id); 546 let line_index = world.analysis().file_line_index(file_id);
548 let range = params.range.conv_with(&line_index); 547 let range = params.range.conv_with(&line_index);
549 548
550 let assists = world.analysis().assists(file_id, range).into_iter(); 549 let assists = world.analysis().assists(file_id, range)?.into_iter();
551 let fixes = world 550 let fixes = world
552 .analysis() 551 .analysis()
553 .diagnostics(file_id) 552 .diagnostics(file_id)?
554 .into_iter() 553 .into_iter()
555 .filter_map(|d| Some((d.range, d.fix?))) 554 .filter_map(|d| Some((d.range, d.fix?)))
556 .filter(|(range, _fix)| contains_offset_nonstrict(*range, range.start())) 555 .filter(|(range, _fix)| contains_offset_nonstrict(*range, range.start()))
@@ -579,7 +578,7 @@ pub fn publish_diagnostics(
579 let line_index = world.analysis().file_line_index(file_id); 578 let line_index = world.analysis().file_line_index(file_id);
580 let diagnostics = world 579 let diagnostics = world
581 .analysis() 580 .analysis()
582 .diagnostics(file_id) 581 .diagnostics(file_id)?
583 .into_iter() 582 .into_iter()
584 .map(|d| Diagnostic { 583 .map(|d| Diagnostic {
585 range: d.range.conv_with(&line_index), 584 range: d.range.conv_with(&line_index),
@@ -600,19 +599,20 @@ pub fn publish_decorations(
600 let uri = world.file_id_to_uri(file_id)?; 599 let uri = world.file_id_to_uri(file_id)?;
601 Ok(req::PublishDecorationsParams { 600 Ok(req::PublishDecorationsParams {
602 uri, 601 uri,
603 decorations: highlight(&world, file_id), 602 decorations: highlight(&world, file_id)?,
604 }) 603 })
605} 604}
606 605
607fn highlight(world: &ServerWorld, file_id: FileId) -> Vec<Decoration> { 606fn highlight(world: &ServerWorld, file_id: FileId) -> Result<Vec<Decoration>> {
608 let line_index = world.analysis().file_line_index(file_id); 607 let line_index = world.analysis().file_line_index(file_id);
609 world 608 let res = world
610 .analysis() 609 .analysis()
611 .highlight(file_id) 610 .highlight(file_id)?
612 .into_iter() 611 .into_iter()
613 .map(|h| Decoration { 612 .map(|h| Decoration {
614 range: h.range.conv_with(&line_index), 613 range: h.range.conv_with(&line_index),
615 tag: h.tag, 614 tag: h.tag,
616 }) 615 })
617 .collect() 616 .collect();
617 Ok(res)
618} 618}