From a30bdd9795770329e4562d8bfca60ebe2e52dea1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 25 May 2020 14:56:26 +0200 Subject: Cleanup lsp extensions on the client side --- crates/rust-analyzer/src/lsp_ext.rs | 2 +- crates/rust-analyzer/src/main_loop/handlers.rs | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index 1cce1baa4..c571c62ae 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs @@ -50,7 +50,7 @@ impl Request for ExpandMacro { #[serde(rename_all = "camelCase")] pub struct ExpandMacroParams { pub text_document: TextDocumentIdentifier, - pub position: Option, + pub position: Position, } #[derive(Deserialize, Serialize, Debug)] diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index a13a0e1f5..3ccc95c23 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs @@ -72,15 +72,10 @@ pub fn handle_expand_macro( let _p = profile("handle_expand_macro"); let file_id = from_proto::file_id(&world, ¶ms.text_document.uri)?; let line_index = world.analysis().file_line_index(file_id)?; - let offset = params.position.map(|p| from_proto::offset(&line_index, p)); + let offset = from_proto::offset(&line_index, params.position); - match offset { - None => Ok(None), - Some(offset) => { - let res = world.analysis().expand_macro(FilePosition { file_id, offset })?; - Ok(res.map(|it| lsp_ext::ExpandedMacro { name: it.name, expansion: it.expansion })) - } - } + let res = world.analysis().expand_macro(FilePosition { file_id, offset })?; + Ok(res.map(|it| lsp_ext::ExpandedMacro { name: it.name, expansion: it.expansion })) } pub fn handle_selection_range( -- cgit v1.2.3