diff options
author | Kirill Bulatov <[email protected]> | 2019-09-11 22:24:39 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2019-09-12 10:15:33 +0100 |
commit | 1852b272334b436865cb36089a91b5dba3148c7f (patch) | |
tree | 34a1c26d72311cb9a0edde1b1b2436b10bac5fe5 | |
parent | 037e02c08da80f25a6e0ddac06b36adac93f2076 (diff) |
Add `!` to the macro completion label
4 files changed, 24 insertions, 20 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs b/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs index dfba97f17..a08fb3b5c 100644 --- a/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs +++ b/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs | |||
@@ -37,7 +37,7 @@ mod tests { | |||
37 | ), | 37 | ), |
38 | @r##"[ | 38 | @r##"[ |
39 | CompletionItem { | 39 | CompletionItem { |
40 | label: "foo", | 40 | label: "foo!", |
41 | source_range: [46; 46), | 41 | source_range: [46; 46), |
42 | delete: [46; 46), | 42 | delete: [46; 46), |
43 | insert: "foo!($0)", | 43 | insert: "foo!($0)", |
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 465edf6dd..457a3d10c 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -605,7 +605,7 @@ mod tests { | |||
605 | ), | 605 | ), |
606 | @r###"[ | 606 | @r###"[ |
607 | CompletionItem { | 607 | CompletionItem { |
608 | label: "foo", | 608 | label: "foo!", |
609 | source_range: [179; 179), | 609 | source_range: [179; 179), |
610 | delete: [179; 179), | 610 | delete: [179; 179), |
611 | insert: "foo!($0)", | 611 | insert: "foo!($0)", |
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 7380d8508..2ea22876f 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs | |||
@@ -568,7 +568,7 @@ mod tests { | |||
568 | ), | 568 | ), |
569 | @r##"[ | 569 | @r##"[ |
570 | CompletionItem { | 570 | CompletionItem { |
571 | label: "bar", | 571 | label: "bar!", |
572 | source_range: [252; 252), | 572 | source_range: [252; 252), |
573 | delete: [252; 252), | 573 | delete: [252; 252), |
574 | insert: "bar!($0)", | 574 | insert: "bar!($0)", |
@@ -576,7 +576,7 @@ mod tests { | |||
576 | detail: "macro_rules! bar", | 576 | detail: "macro_rules! bar", |
577 | }, | 577 | }, |
578 | CompletionItem { | 578 | CompletionItem { |
579 | label: "baz", | 579 | label: "baz!", |
580 | source_range: [252; 252), | 580 | source_range: [252; 252), |
581 | delete: [252; 252), | 581 | delete: [252; 252), |
582 | insert: "baz!($0)", | 582 | insert: "baz!($0)", |
@@ -584,7 +584,7 @@ mod tests { | |||
584 | detail: "#[macro_export]\nmacro_rules! baz", | 584 | detail: "#[macro_export]\nmacro_rules! baz", |
585 | }, | 585 | }, |
586 | CompletionItem { | 586 | CompletionItem { |
587 | label: "foo", | 587 | label: "foo!", |
588 | source_range: [252; 252), | 588 | source_range: [252; 252), |
589 | delete: [252; 252), | 589 | delete: [252; 252), |
590 | insert: "foo!($0)", | 590 | insert: "foo!($0)", |
@@ -637,17 +637,17 @@ mod tests { | |||
637 | label: "foo", | 637 | label: "foo", |
638 | source_range: [49; 49), | 638 | source_range: [49; 49), |
639 | delete: [49; 49), | 639 | delete: [49; 49), |
640 | insert: "foo!($0)", | 640 | insert: "foo()$0", |
641 | kind: Macro, | 641 | kind: Function, |
642 | detail: "macro_rules! foo", | 642 | detail: "fn foo()", |
643 | }, | 643 | }, |
644 | CompletionItem { | 644 | CompletionItem { |
645 | label: "foo", | 645 | label: "foo!", |
646 | source_range: [49; 49), | 646 | source_range: [49; 49), |
647 | delete: [49; 49), | 647 | delete: [49; 49), |
648 | insert: "foo()$0", | 648 | insert: "foo!($0)", |
649 | kind: Function, | 649 | kind: Macro, |
650 | detail: "fn foo()", | 650 | detail: "macro_rules! foo", |
651 | }, | 651 | }, |
652 | ]"## | 652 | ]"## |
653 | ); | 653 | ); |
@@ -670,7 +670,7 @@ mod tests { | |||
670 | ), | 670 | ), |
671 | @r##"[ | 671 | @r##"[ |
672 | CompletionItem { | 672 | CompletionItem { |
673 | label: "foo", | 673 | label: "foo!", |
674 | source_range: [57; 57), | 674 | source_range: [57; 57), |
675 | delete: [57; 57), | 675 | delete: [57; 57), |
676 | insert: "foo!($0)", | 676 | insert: "foo!($0)", |
@@ -706,7 +706,7 @@ mod tests { | |||
706 | ), | 706 | ), |
707 | @r##"[ | 707 | @r##"[ |
708 | CompletionItem { | 708 | CompletionItem { |
709 | label: "foo", | 709 | label: "foo!", |
710 | source_range: [50; 50), | 710 | source_range: [50; 50), |
711 | delete: [50; 50), | 711 | delete: [50; 50), |
712 | insert: "foo!($0)", | 712 | insert: "foo!($0)", |
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 1995e8971..301c878b1 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs | |||
@@ -108,13 +108,17 @@ impl Completions { | |||
108 | let ast_node = macro_.source(ctx.db).ast; | 108 | let ast_node = macro_.source(ctx.db).ast; |
109 | if let Some(name) = name { | 109 | if let Some(name) = name { |
110 | let detail = macro_label(&ast_node); | 110 | let detail = macro_label(&ast_node); |
111 | let code_declaration = name + "!"; | ||
111 | 112 | ||
112 | let builder = | 113 | let builder = CompletionItem::new( |
113 | CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.clone()) | 114 | CompletionKind::Reference, |
114 | .kind(CompletionItemKind::Macro) | 115 | ctx.source_range(), |
115 | .set_documentation(macro_.docs(ctx.db)) | 116 | &code_declaration, |
116 | .detail(detail) | 117 | ) |
117 | .insert_snippet(format!("{}!($0)", name)); | 118 | .kind(CompletionItemKind::Macro) |
119 | .set_documentation(macro_.docs(ctx.db)) | ||
120 | .detail(detail) | ||
121 | .insert_snippet(format!("{}($0)", &code_declaration)); | ||
118 | 122 | ||
119 | self.add(builder); | 123 | self.add(builder); |
120 | } | 124 | } |