aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-05-25 13:56:26 +0100
committerAleksey Kladov <[email protected]>2020-05-25 13:56:26 +0100
commita30bdd9795770329e4562d8bfca60ebe2e52dea1 (patch)
tree510b580723f06fd3ae1e4c641001afa82a426b60 /crates
parent8686d0b0ac765c2144b22b897de1d8fda68ecc6e (diff)
Cleanup lsp extensions on the client side
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs2
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs11
2 files changed, 4 insertions, 9 deletions
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 {
50#[serde(rename_all = "camelCase")] 50#[serde(rename_all = "camelCase")]
51pub struct ExpandMacroParams { 51pub struct ExpandMacroParams {
52 pub text_document: TextDocumentIdentifier, 52 pub text_document: TextDocumentIdentifier,
53 pub position: Option<Position>, 53 pub position: Position,
54} 54}
55 55
56#[derive(Deserialize, Serialize, Debug)] 56#[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(
72 let _p = profile("handle_expand_macro"); 72 let _p = profile("handle_expand_macro");
73 let file_id = from_proto::file_id(&world, &params.text_document.uri)?; 73 let file_id = from_proto::file_id(&world, &params.text_document.uri)?;
74 let line_index = world.analysis().file_line_index(file_id)?; 74 let line_index = world.analysis().file_line_index(file_id)?;
75 let offset = params.position.map(|p| from_proto::offset(&line_index, p)); 75 let offset = from_proto::offset(&line_index, params.position);
76 76
77 match offset { 77 let res = world.analysis().expand_macro(FilePosition { file_id, offset })?;
78 None => Ok(None), 78 Ok(res.map(|it| lsp_ext::ExpandedMacro { name: it.name, expansion: it.expansion }))
79 Some(offset) => {
80 let res = world.analysis().expand_macro(FilePosition { file_id, offset })?;
81 Ok(res.map(|it| lsp_ext::ExpandedMacro { name: it.name, expansion: it.expansion }))
82 }
83 }
84} 79}
85 80
86pub fn handle_selection_range( 81pub fn handle_selection_range(