diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 7 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/req.rs | 9 |
2 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 783b0a827..0461bf385 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -50,7 +50,7 @@ pub fn handle_syntax_tree(world: WorldSnapshot, params: req::SyntaxTreeParams) - | |||
50 | pub fn handle_expand_macro( | 50 | pub fn handle_expand_macro( |
51 | world: WorldSnapshot, | 51 | world: WorldSnapshot, |
52 | params: req::ExpandMacroParams, | 52 | params: req::ExpandMacroParams, |
53 | ) -> Result<Option<(String, String)>> { | 53 | ) -> Result<Option<req::ExpandedMacro>> { |
54 | let _p = profile("handle_expand_macro"); | 54 | let _p = profile("handle_expand_macro"); |
55 | let file_id = params.text_document.try_conv_with(&world)?; | 55 | let file_id = params.text_document.try_conv_with(&world)?; |
56 | let line_index = world.analysis().file_line_index(file_id)?; | 56 | let line_index = world.analysis().file_line_index(file_id)?; |
@@ -58,7 +58,10 @@ pub fn handle_expand_macro( | |||
58 | 58 | ||
59 | match offset { | 59 | match offset { |
60 | None => Ok(None), | 60 | None => Ok(None), |
61 | Some(offset) => Ok(world.analysis().expand_macro(FilePosition { file_id, offset })?), | 61 | Some(offset) => { |
62 | let res = world.analysis().expand_macro(FilePosition { file_id, offset })?; | ||
63 | Ok(res.map(|it| req::ExpandedMacro { name: it.name, expansion: it.expansion })) | ||
64 | } | ||
62 | } | 65 | } |
63 | } | 66 | } |
64 | 67 | ||
diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index dbc0e9624..39361b7e8 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs | |||
@@ -45,11 +45,18 @@ pub struct SyntaxTreeParams { | |||
45 | pub range: Option<Range>, | 45 | pub range: Option<Range>, |
46 | } | 46 | } |
47 | 47 | ||
48 | #[derive(Serialize, Debug)] | ||
49 | #[serde(rename_all = "camelCase")] | ||
50 | pub struct ExpandedMacro { | ||
51 | pub name: String, | ||
52 | pub expansion: String, | ||
53 | } | ||
54 | |||
48 | pub enum ExpandMacro {} | 55 | pub enum ExpandMacro {} |
49 | 56 | ||
50 | impl Request for ExpandMacro { | 57 | impl Request for ExpandMacro { |
51 | type Params = ExpandMacroParams; | 58 | type Params = ExpandMacroParams; |
52 | type Result = Option<(String, String)>; | 59 | type Result = Option<ExpandedMacro>; |
53 | const METHOD: &'static str = "rust-analyzer/expandMacro"; | 60 | const METHOD: &'static str = "rust-analyzer/expandMacro"; |
54 | } | 61 | } |
55 | 62 | ||