aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-24 16:05:20 +0100
committerGitHub <[email protected]>2020-05-24 16:05:20 +0100
commitfbb8b884a2dbc3ced720c84f4604466e223f6d69 (patch)
tree358370ac7f84396ad19ce004097497bfcbae9d18 /crates
parentd959c913eaeae36b9e04c7b5ee8b341f6c5b678b (diff)
parent5276bfff819520cd27703b5d33a95d9674649e1e (diff)
Merge #4593
4593: Document some rust-analyzer specific protocol extensions r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs26
-rw-r--r--crates/rust-analyzer/src/main_loop.rs4
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs8
3 files changed, 18 insertions, 20 deletions
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs
index c25d90a50..52e4fcbec 100644
--- a/crates/rust-analyzer/src/lsp_ext.rs
+++ b/crates/rust-analyzer/src/lsp_ext.rs
@@ -38,13 +38,6 @@ pub struct SyntaxTreeParams {
38 pub range: Option<Range>, 38 pub range: Option<Range>,
39} 39}
40 40
41#[derive(Deserialize, Serialize, Debug)]
42#[serde(rename_all = "camelCase")]
43pub struct ExpandedMacro {
44 pub name: String,
45 pub expansion: String,
46}
47
48pub enum ExpandMacro {} 41pub enum ExpandMacro {}
49 42
50impl Request for ExpandMacro { 43impl Request for ExpandMacro {
@@ -60,19 +53,26 @@ pub struct ExpandMacroParams {
60 pub position: Option<Position>, 53 pub position: Option<Position>,
61} 54}
62 55
63pub enum FindMatchingBrace {} 56#[derive(Deserialize, Serialize, Debug)]
57#[serde(rename_all = "camelCase")]
58pub struct ExpandedMacro {
59 pub name: String,
60 pub expansion: String,
61}
62
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..f1287d52c 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -509,9 +509,7 @@ 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| handlers::handle_matching_brace(s.snapshot(), p))?
513 handlers::handle_find_matching_brace(s.snapshot(), p)
514 })?
515 .on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status)? 513 .on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status)?
516 .on::<lsp_ext::SyntaxTree>(handlers::handle_syntax_tree)? 514 .on::<lsp_ext::SyntaxTree>(handlers::handle_syntax_tree)?
517 .on::<lsp_ext::ExpandMacro>(handlers::handle_expand_macro)? 515 .on::<lsp_ext::ExpandMacro>(handlers::handle_expand_macro)?
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);