From ac52d9a1f1a94e2c836c8a04a316f6454936a79a Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sun, 3 Mar 2019 12:02:55 +0200 Subject: Add optional range parameter to SyntaxTreeParams When range is provided, instead of showing the syntax for the whole file, we'll show the syntax tree for the given range. --- crates/ra_lsp_server/src/main_loop/handlers.rs | 4 +++- crates/ra_lsp_server/src/req.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index dce6fcc67..89e96a33a 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -32,7 +32,9 @@ pub fn handle_analyzer_status(world: ServerWorld, _: ()) -> Result { pub fn handle_syntax_tree(world: ServerWorld, params: req::SyntaxTreeParams) -> Result { let id = params.text_document.try_conv_with(&world)?; - let res = world.analysis().syntax_tree(id); + let line_index = world.analysis().file_line_index(id); + let text_range = params.range.map(|p| p.conv_with(&line_index)); + let res = world.analysis().syntax_tree(id, text_range); Ok(res) } diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index e224ede80..5c589f969 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs @@ -39,6 +39,7 @@ impl Request for SyntaxTree { #[serde(rename_all = "camelCase")] pub struct SyntaxTreeParams { pub text_document: TextDocumentIdentifier, + pub range: Option, } pub enum ExtendSelection {} -- cgit v1.2.3