diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-04 10:50:40 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-04 10:50:40 +0000 |
commit | 698aa9b3f6420351a41a3fb4819b871fec3c891c (patch) | |
tree | c782b2b62dcfaa253b8ed55824772ea7bf8fa16d /crates/ra_lsp_server/src | |
parent | 17aaece6b39c2fb525be0eccce4626fc622e8236 (diff) | |
parent | 1ef2c0613134633ef0fe0d515f7d416e482f07fb (diff) |
Merge #924
924: Improve show syntax tree r=matklad a=vipentti
This implements some of the features discussed in #820.
You can now select a range of syntax in a file and then use "Show Syntax Tree" to show its syntax. In addition you can select a range of syntax that is inside a string (typically test cases) and show its syntax as well.
Previous behavior is still available, simply use "Show Syntax Tree" without a selection, and you get the live updating syntax tree. Additionally now the live updating tree will update when the active file is changed. Previously you had to type something in the new file to get the syntax tree to update.
Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 4 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/req.rs | 1 |
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 | ||
33 | pub fn handle_syntax_tree(world: ServerWorld, params: req::SyntaxTreeParams) -> Result<String> { | 33 | pub 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")] |
40 | pub struct SyntaxTreeParams { | 40 | pub struct SyntaxTreeParams { |
41 | pub text_document: TextDocumentIdentifier, | 41 | pub text_document: TextDocumentIdentifier, |
42 | pub range: Option<Range>, | ||
42 | } | 43 | } |
43 | 44 | ||
44 | pub enum ExtendSelection {} | 45 | pub enum ExtendSelection {} |