From 998f2ae7627053a9363a05a1ab79359882dce39f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Oct 2018 22:02:41 +0300 Subject: remove job tokens --- crates/ra_lsp_server/src/main_loop/handlers.rs | 62 +++++++++++++------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop') 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( pub fn handle_workspace_symbol( world: ServerWorld, params: req::WorkspaceSymbolParams, - token: JobToken, + _token: JobToken, ) -> Result>> { let all_symbols = params.query.contains("#"); let libs = params.query.contains("*"); @@ -181,11 +181,11 @@ pub fn handle_workspace_symbol( q.limit(128); q }; - let mut res = exec_query(&world, query, &token)?; + let mut res = exec_query(&world, query)?; if res.is_empty() && !all_symbols { let mut query = Query::new(params.query); query.limit(128); - res = exec_query(&world, query, &token)?; + res = exec_query(&world, query)?; } return Ok(Some(res)); @@ -193,10 +193,9 @@ pub fn handle_workspace_symbol( fn exec_query( world: &ServerWorld, query: Query, - token: &JobToken, ) -> Result> { let mut res = Vec::new(); - for (file_id, symbol) in world.analysis().symbol_search(query, token) { + for (file_id, symbol) in world.analysis().symbol_search(query) { let line_index = world.analysis().file_line_index(file_id); let info = SymbolInformation { name: symbol.name.to_string(), @@ -214,7 +213,7 @@ pub fn handle_workspace_symbol( pub fn handle_goto_definition( world: ServerWorld, params: req::TextDocumentPositionParams, - token: JobToken, + _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -222,7 +221,7 @@ pub fn handle_goto_definition( let mut res = Vec::new(); for (file_id, symbol) in world .analysis() - .approximately_resolve_symbol(file_id, offset, &token) + .approximately_resolve_symbol(file_id, offset) { let line_index = world.analysis().file_line_index(file_id); let location = to_location(file_id, symbol.node_range, &world, &line_index)?; @@ -255,14 +254,14 @@ pub fn handle_runnables( let line_index = world.analysis().file_line_index(file_id); let offset = params.position.map(|it| it.conv_with(&line_index)); let mut res = Vec::new(); - for runnable in world.analysis().runnables(file_id) { + for runnable in world.analysis().runnables(file_id)? { if let Some(offset) = offset { if !contains_offset_nonstrict(runnable.range, offset) { continue; } } - let args = runnable_args(&world, file_id, &runnable.kind); + let args = runnable_args(&world, file_id, &runnable.kind)?; let r = req::Runnable { range: runnable.range.conv_with(&line_index), @@ -282,9 +281,9 @@ pub fn handle_runnables( } return Ok(res); - fn runnable_args(world: &ServerWorld, file_id: FileId, kind: &RunnableKind) -> Vec { - let spec = if let Some(&crate_id) = world.analysis().crate_for(file_id).first() { - let file_id = world.analysis().crate_root(crate_id); + fn runnable_args(world: &ServerWorld, file_id: FileId, kind: &RunnableKind) -> Result> { + let spec = if let Some(&crate_id) = world.analysis().crate_for(file_id)?.first() { + let file_id = world.analysis().crate_root(crate_id)?; let path = world.path_map.get_path(file_id); world .workspaces @@ -319,7 +318,7 @@ pub fn handle_runnables( } } } - res + Ok(res) } fn spec_args(pkg_name: &str, tgt_name: &str, tgt_kind: TargetKind, buf: &mut Vec) { @@ -356,7 +355,7 @@ pub fn handle_decorations( _token: JobToken, ) -> Result> { let file_id = params.try_conv_with(&world)?; - Ok(highlight(&world, file_id)) + highlight(&world, file_id) } pub fn handle_completion( @@ -367,7 +366,7 @@ pub fn handle_completion( let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); let offset = params.position.conv_with(&line_index); - let items = match world.analysis().completions(file_id, offset) { + let items = match world.analysis().completions(file_id, offset)? { None => return Ok(None), Some(items) => items, }; @@ -427,7 +426,7 @@ pub fn handle_folding_range( pub fn handle_signature_help( world: ServerWorld, params: req::TextDocumentPositionParams, - token: JobToken, + _token: JobToken, ) -> Result> { use languageserver_types::{ParameterInformation, SignatureInformation}; @@ -436,7 +435,7 @@ pub fn handle_signature_help( let offset = params.position.conv_with(&line_index); if let Some((descriptor, active_param)) = - world.analysis().resolve_callable(file_id, offset, &token) + world.analysis().resolve_callable(file_id, offset) { let parameters: Vec = descriptor .params @@ -466,7 +465,7 @@ pub fn handle_signature_help( pub fn handle_prepare_rename( world: ServerWorld, params: req::TextDocumentPositionParams, - token: JobToken, + _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -474,7 +473,7 @@ pub fn handle_prepare_rename( // We support renaming references like handle_rename does. // In the future we may want to reject the renaming of things like keywords here too. - let refs = world.analysis().find_all_refs(file_id, offset, &token); + let refs = world.analysis().find_all_refs(file_id, offset); if refs.is_empty() { return Ok(None); } @@ -488,7 +487,7 @@ pub fn handle_prepare_rename( pub fn handle_rename( world: ServerWorld, params: RenameParams, - token: JobToken, + _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -498,7 +497,7 @@ pub fn handle_rename( return Ok(None); } - let refs = world.analysis().find_all_refs(file_id, offset, &token); + let refs = world.analysis().find_all_refs(file_id, offset); if refs.is_empty() { return Ok(None); } @@ -525,13 +524,13 @@ pub fn handle_rename( pub fn handle_references( world: ServerWorld, params: req::ReferenceParams, - token: JobToken, + _token: JobToken, ) -> Result>> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); let offset = params.position.conv_with(&line_index); - let refs = world.analysis().find_all_refs(file_id, offset, &token); + let refs = world.analysis().find_all_refs(file_id, offset); Ok(Some(refs.into_iter() .filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok()) @@ -547,10 +546,10 @@ pub fn handle_code_action( let line_index = world.analysis().file_line_index(file_id); let range = params.range.conv_with(&line_index); - let assists = world.analysis().assists(file_id, range).into_iter(); + let assists = world.analysis().assists(file_id, range)?.into_iter(); let fixes = world .analysis() - .diagnostics(file_id) + .diagnostics(file_id)? .into_iter() .filter_map(|d| Some((d.range, d.fix?))) .filter(|(range, _fix)| contains_offset_nonstrict(*range, range.start())) @@ -579,7 +578,7 @@ pub fn publish_diagnostics( let line_index = world.analysis().file_line_index(file_id); let diagnostics = world .analysis() - .diagnostics(file_id) + .diagnostics(file_id)? .into_iter() .map(|d| Diagnostic { range: d.range.conv_with(&line_index), @@ -600,19 +599,20 @@ pub fn publish_decorations( let uri = world.file_id_to_uri(file_id)?; Ok(req::PublishDecorationsParams { uri, - decorations: highlight(&world, file_id), + decorations: highlight(&world, file_id)?, }) } -fn highlight(world: &ServerWorld, file_id: FileId) -> Vec { +fn highlight(world: &ServerWorld, file_id: FileId) -> Result> { let line_index = world.analysis().file_line_index(file_id); - world + let res = world .analysis() - .highlight(file_id) + .highlight(file_id)? .into_iter() .map(|h| Decoration { range: h.range.conv_with(&line_index), tag: h.tag, }) - .collect() + .collect(); + Ok(res) } -- cgit v1.2.3