diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 25 | ||||
-rw-r--r-- | crates/ra_mbe/src/lib.rs | 24 | ||||
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 8 |
3 files changed, 43 insertions, 14 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index c25adb8b9..4720a8843 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -599,9 +599,6 @@ pub fn handle_code_action( | |||
599 | let title = source_edit.label.clone(); | 599 | let title = source_edit.label.clone(); |
600 | let edit = source_edit.try_conv_with(&world)?; | 600 | let edit = source_edit.try_conv_with(&world)?; |
601 | 601 | ||
602 | // We cannot use the 'editor.action.showReferences' command directly | ||
603 | // because that command requires vscode types which we convert in the handler | ||
604 | // on the client side. | ||
605 | let cmd = Command { | 602 | let cmd = Command { |
606 | title, | 603 | title, |
607 | command: "rust-analyzer.applySourceChange".to_string(), | 604 | command: "rust-analyzer.applySourceChange".to_string(), |
@@ -713,17 +710,21 @@ pub fn handle_code_lens_resolve(world: ServerWorld, code_lens: CodeLens) -> Resu | |||
713 | format!("{} implementations", locations.len()) | 710 | format!("{} implementations", locations.len()) |
714 | }; | 711 | }; |
715 | 712 | ||
713 | // We cannot use the 'editor.action.showReferences' command directly | ||
714 | // because that command requires vscode types which we convert in the handler | ||
715 | // on the client side. | ||
716 | let cmd = Command { | ||
717 | title, | ||
718 | command: "rust-analyzer.showReferences".into(), | ||
719 | arguments: Some(vec![ | ||
720 | to_value(&Ser::new(&lens_params.text_document.uri)).unwrap(), | ||
721 | to_value(code_lens.range.start).unwrap(), | ||
722 | to_value(locations).unwrap(), | ||
723 | ]), | ||
724 | }; | ||
716 | return Ok(CodeLens { | 725 | return Ok(CodeLens { |
717 | range: code_lens.range, | 726 | range: code_lens.range, |
718 | command: Some(Command { | 727 | command: Some(cmd), |
719 | title, | ||
720 | command: "rust-analyzer.showReferences".into(), | ||
721 | arguments: Some(vec![ | ||
722 | to_value(&Ser::new(&lens_params.text_document.uri)).unwrap(), | ||
723 | to_value(code_lens.range.start).unwrap(), | ||
724 | to_value(locations).unwrap(), | ||
725 | ]), | ||
726 | }), | ||
727 | data: None, | 728 | data: None, |
728 | }); | 729 | }); |
729 | } | 730 | } |
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index 6f719acbf..2c8ad4429 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs | |||
@@ -256,4 +256,28 @@ impl_froms!(TokenTree: Leaf, Subtree); | |||
256 | assert_expansion(&rules, "foo! { eggs Baz }", "struct Baz ;"); | 256 | assert_expansion(&rules, "foo! { eggs Baz }", "struct Baz ;"); |
257 | } | 257 | } |
258 | 258 | ||
259 | #[test] | ||
260 | fn test_match_group_pattern_by_separator_token() { | ||
261 | let rules = create_rules( | ||
262 | r#" | ||
263 | macro_rules! foo { | ||
264 | ($ ($ i:ident),*) => ($ ( | ||
265 | mod $ i {} | ||
266 | )*); | ||
267 | ($ ($ i:ident)#*) => ($ ( | ||
268 | fn $ i() {} | ||
269 | )*); | ||
270 | ($ i:ident ,# $ j:ident) => ( | ||
271 | struct $ i; | ||
272 | struct $ j; | ||
273 | ) | ||
274 | } | ||
275 | "#, | ||
276 | ); | ||
277 | |||
278 | assert_expansion(&rules, "foo! { foo, bar }", "mod foo {} mod bar {}"); | ||
279 | assert_expansion(&rules, "foo! { foo# bar }", "fn foo () {} fn bar () {}"); | ||
280 | assert_expansion(&rules, "foo! { Foo,# Bar }", "struct Foo ; struct Bar ;"); | ||
281 | } | ||
282 | |||
259 | } | 283 | } |
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index 212e2ea92..04b5a4035 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs | |||
@@ -140,8 +140,12 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Option<Bindings> | |||
140 | }) => { | 140 | }) => { |
141 | while let Some(nested) = match_lhs(subtree, input) { | 141 | while let Some(nested) = match_lhs(subtree, input) { |
142 | res.push_nested(nested)?; | 142 | res.push_nested(nested)?; |
143 | if separator.is_some() && !input.is_eof() { | 143 | if let Some(separator) = *separator { |
144 | input.eat_punct()?; | 144 | if !input.is_eof() { |
145 | if input.eat_punct()?.char != separator { | ||
146 | return None; | ||
147 | } | ||
148 | } | ||
145 | } | 149 | } |
146 | } | 150 | } |
147 | } | 151 | } |