aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
authorVille Penttinen <[email protected]>2019-03-03 10:02:55 +0000
committerVille Penttinen <[email protected]>2019-03-03 17:49:50 +0000
commitac52d9a1f1a94e2c836c8a04a316f6454936a79a (patch)
treebf0e217ed101a32c1597fb6ed0e20fc755954d2c /crates/ra_lsp_server/src
parent17aaece6b39c2fb525be0eccce4626fc622e8236 (diff)
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.
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs4
-rw-r--r--crates/ra_lsp_server/src/req.rs1
2 files changed, 4 insertions, 1 deletions
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<String> {
32 32
33pub fn handle_syntax_tree(world: ServerWorld, params: req::SyntaxTreeParams) -> Result<String> { 33pub fn handle_syntax_tree(world: ServerWorld, params: req::SyntaxTreeParams) -> Result<String> {
34 let id = params.text_document.try_conv_with(&world)?; 34 let id = params.text_document.try_conv_with(&world)?;
35 let res = world.analysis().syntax_tree(id); 35 let line_index = world.analysis().file_line_index(id);
36 let text_range = params.range.map(|p| p.conv_with(&line_index));
37 let res = world.analysis().syntax_tree(id, text_range);
36 Ok(res) 38 Ok(res)
37} 39}
38 40
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 {
39#[serde(rename_all = "camelCase")] 39#[serde(rename_all = "camelCase")]
40pub struct SyntaxTreeParams { 40pub struct SyntaxTreeParams {
41 pub text_document: TextDocumentIdentifier, 41 pub text_document: TextDocumentIdentifier,
42 pub range: Option<Range>,
42} 43}
43 44
44pub enum ExtendSelection {} 45pub enum ExtendSelection {}