aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-05-24 15:18:46 +0100
committerAleksey Kladov <[email protected]>2020-05-24 15:53:18 +0100
commit934227361623b258d833be20e464e1509cb432ad (patch)
treecfb43f218d80f8e29045cf75e6e31ccfd6ca3782 /crates
parent7e862626cc892662c3c95ba393483ac89c07e31a (diff)
Document matchingBrace LSP request
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs12
-rw-r--r--crates/rust-analyzer/src/main_loop.rs4
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs8
3 files changed, 12 insertions, 12 deletions
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs
index c25d90a50..b8b9e65ed 100644
--- a/crates/rust-analyzer/src/lsp_ext.rs
+++ b/crates/rust-analyzer/src/lsp_ext.rs
@@ -60,19 +60,19 @@ pub struct ExpandMacroParams {
60 pub position: Option<Position>, 60 pub position: Option<Position>,
61} 61}
62 62
63pub enum FindMatchingBrace {} 63pub enum MatchingBrace {}
64 64
65impl Request for FindMatchingBrace { 65impl Request for MatchingBrace {
66 type Params = FindMatchingBraceParams; 66 type Params = MatchingBraceParams;
67 type Result = Vec<Position>; 67 type Result = Vec<Position>;
68 const METHOD: &'static str = "rust-analyzer/findMatchingBrace"; 68 const METHOD: &'static str = "experimental/matchingBrace";
69} 69}
70 70
71#[derive(Deserialize, Serialize, Debug)] 71#[derive(Deserialize, Serialize, Debug)]
72#[serde(rename_all = "camelCase")] 72#[serde(rename_all = "camelCase")]
73pub struct FindMatchingBraceParams { 73pub struct MatchingBraceParams {
74 pub text_document: TextDocumentIdentifier, 74 pub text_document: TextDocumentIdentifier,
75 pub offsets: Vec<Position>, 75 pub positions: Vec<Position>,
76} 76}
77 77
78pub enum ParentModule {} 78pub enum ParentModule {}
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 87795fffb..e28a32c26 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -509,8 +509,8 @@ fn on_request(
509 .on_sync::<lsp_types::request::SelectionRangeRequest>(|s, p| { 509 .on_sync::<lsp_types::request::SelectionRangeRequest>(|s, p| {
510 handlers::handle_selection_range(s.snapshot(), p) 510 handlers::handle_selection_range(s.snapshot(), p)
511 })? 511 })?
512 .on_sync::<lsp_ext::FindMatchingBrace>(|s, p| { 512 .on_sync::<lsp_ext::MatchingBrace>(|s, p| {
513 handlers::handle_find_matching_brace(s.snapshot(), p) 513 handlers::handle_matching_brace(s.snapshot(), p)
514 })? 514 })?
515 .on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status)? 515 .on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status)?
516 .on::<lsp_ext::SyntaxTree>(handlers::handle_syntax_tree)? 516 .on::<lsp_ext::SyntaxTree>(handlers::handle_syntax_tree)?
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index 2aaff3ea4..d73107968 100644
--- a/crates/rust-analyzer/src/main_loop/handlers.rs
+++ b/crates/rust-analyzer/src/main_loop/handlers.rs
@@ -126,15 +126,15 @@ pub fn handle_selection_range(
126 Ok(Some(res?)) 126 Ok(Some(res?))
127} 127}
128 128
129pub fn handle_find_matching_brace( 129pub fn handle_matching_brace(
130 world: WorldSnapshot, 130 world: WorldSnapshot,
131 params: lsp_ext::FindMatchingBraceParams, 131 params: lsp_ext::MatchingBraceParams,
132) -> Result<Vec<Position>> { 132) -> Result<Vec<Position>> {
133 let _p = profile("handle_find_matching_brace"); 133 let _p = profile("handle_matching_brace");
134 let file_id = from_proto::file_id(&world, &params.text_document.uri)?; 134 let file_id = from_proto::file_id(&world, &params.text_document.uri)?;
135 let line_index = world.analysis().file_line_index(file_id)?; 135 let line_index = world.analysis().file_line_index(file_id)?;
136 let res = params 136 let res = params
137 .offsets 137 .positions
138 .into_iter() 138 .into_iter()
139 .map(|position| { 139 .map(|position| {
140 let offset = from_proto::offset(&line_index, position); 140 let offset = from_proto::offset(&line_index, position);