diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 15 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/req.rs | 15 |
3 files changed, 31 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 379dab438..f828efdee 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -436,6 +436,7 @@ fn on_request( | |||
436 | })? | 436 | })? |
437 | .on::<req::AnalyzerStatus>(handlers::handle_analyzer_status)? | 437 | .on::<req::AnalyzerStatus>(handlers::handle_analyzer_status)? |
438 | .on::<req::SyntaxTree>(handlers::handle_syntax_tree)? | 438 | .on::<req::SyntaxTree>(handlers::handle_syntax_tree)? |
439 | .on::<req::ExpandMacro>(handlers::handle_expand_macro)? | ||
439 | .on::<req::OnTypeFormatting>(handlers::handle_on_type_formatting)? | 440 | .on::<req::OnTypeFormatting>(handlers::handle_on_type_formatting)? |
440 | .on::<req::DocumentSymbolRequest>(handlers::handle_document_symbol)? | 441 | .on::<req::DocumentSymbolRequest>(handlers::handle_document_symbol)? |
441 | .on::<req::WorkspaceSymbol>(handlers::handle_workspace_symbol)? | 442 | .on::<req::WorkspaceSymbol>(handlers::handle_workspace_symbol)? |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 20f9aee13..783b0a827 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -47,6 +47,21 @@ pub fn handle_syntax_tree(world: WorldSnapshot, params: req::SyntaxTreeParams) - | |||
47 | Ok(res) | 47 | Ok(res) |
48 | } | 48 | } |
49 | 49 | ||
50 | pub fn handle_expand_macro( | ||
51 | world: WorldSnapshot, | ||
52 | params: req::ExpandMacroParams, | ||
53 | ) -> Result<Option<(String, String)>> { | ||
54 | let _p = profile("handle_expand_macro"); | ||
55 | let file_id = params.text_document.try_conv_with(&world)?; | ||
56 | let line_index = world.analysis().file_line_index(file_id)?; | ||
57 | let offset = params.position.map(|p| p.conv_with(&line_index)); | ||
58 | |||
59 | match offset { | ||
60 | None => Ok(None), | ||
61 | Some(offset) => Ok(world.analysis().expand_macro(FilePosition { file_id, offset })?), | ||
62 | } | ||
63 | } | ||
64 | |||
50 | pub fn handle_selection_range( | 65 | pub fn handle_selection_range( |
51 | world: WorldSnapshot, | 66 | world: WorldSnapshot, |
52 | params: req::SelectionRangeParams, | 67 | params: req::SelectionRangeParams, |
diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index d25fc5726..dbc0e9624 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs | |||
@@ -45,6 +45,21 @@ pub struct SyntaxTreeParams { | |||
45 | pub range: Option<Range>, | 45 | pub range: Option<Range>, |
46 | } | 46 | } |
47 | 47 | ||
48 | pub enum ExpandMacro {} | ||
49 | |||
50 | impl Request for ExpandMacro { | ||
51 | type Params = ExpandMacroParams; | ||
52 | type Result = Option<(String, String)>; | ||
53 | const METHOD: &'static str = "rust-analyzer/expandMacro"; | ||
54 | } | ||
55 | |||
56 | #[derive(Deserialize, Debug)] | ||
57 | #[serde(rename_all = "camelCase")] | ||
58 | pub struct ExpandMacroParams { | ||
59 | pub text_document: TextDocumentIdentifier, | ||
60 | pub position: Option<Position>, | ||
61 | } | ||
62 | |||
48 | pub enum SelectionRangeRequest {} | 63 | pub enum SelectionRangeRequest {} |
49 | 64 | ||
50 | impl Request for SelectionRangeRequest { | 65 | impl Request for SelectionRangeRequest { |