diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-18 13:00:43 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-18 13:00:43 +0000 |
commit | 3a7724e44181ccd5c248589538bd82458b5a9407 (patch) | |
tree | e7dfad0f3f90e709580040a3a8894658ee926fe4 /crates/ra_ide/src/inlay_hints.rs | |
parent | d1d91dfe4d52856403a17e2644a22c919690010d (diff) | |
parent | 18ec4e3403854995d44841a066ff3b190d8115e6 (diff) |
Merge #2875
2875: Improve parameter hints a bit & add emacs support r=matklad a=flodiebold
- just include the name, not e.g. `mut`
- don't return empty hints (or `_`)
CC @brotzeit for the Emacs change
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/inlay_hints.rs')
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 1b631c7cd..236557541 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -116,7 +116,7 @@ fn get_param_name_hints( | |||
116 | let hints = parameters | 116 | let hints = parameters |
117 | .zip(args) | 117 | .zip(args) |
118 | .filter_map(|(param, arg)| { | 118 | .filter_map(|(param, arg)| { |
119 | if arg.syntax().kind() == SyntaxKind::LITERAL { | 119 | if arg.syntax().kind() == SyntaxKind::LITERAL && !param.is_empty() { |
120 | Some((arg.syntax().text_range(), param)) | 120 | Some((arg.syntax().text_range(), param)) |
121 | } else { | 121 | } else { |
122 | None | 122 | None |
@@ -683,12 +683,12 @@ fn main() { | |||
683 | struct Test {} | 683 | struct Test {} |
684 | 684 | ||
685 | impl Test { | 685 | impl Test { |
686 | fn method(&self, param: i32) -> i32 { | 686 | fn method(&self, mut param: i32) -> i32 { |
687 | param * 2 | 687 | param * 2 |
688 | } | 688 | } |
689 | } | 689 | } |
690 | 690 | ||
691 | fn test_func(foo: i32, bar: i32, msg: &str, _: i32, last: i32) -> i32 { | 691 | fn test_func(mut foo: i32, bar: i32, msg: &str, _: i32, last: i32) -> i32 { |
692 | foo + bar | 692 | foo + bar |
693 | } | 693 | } |
694 | 694 | ||
@@ -704,37 +704,32 @@ fn main() { | |||
704 | assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###" | 704 | assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###" |
705 | [ | 705 | [ |
706 | InlayHint { | 706 | InlayHint { |
707 | range: [207; 218), | 707 | range: [215; 226), |
708 | kind: TypeHint, | 708 | kind: TypeHint, |
709 | label: "i32", | 709 | label: "i32", |
710 | }, | 710 | }, |
711 | InlayHint { | 711 | InlayHint { |
712 | range: [251; 252), | 712 | range: [259; 260), |
713 | kind: ParameterHint, | 713 | kind: ParameterHint, |
714 | label: "foo", | 714 | label: "foo", |
715 | }, | 715 | }, |
716 | InlayHint { | 716 | InlayHint { |
717 | range: [254; 255), | 717 | range: [262; 263), |
718 | kind: ParameterHint, | 718 | kind: ParameterHint, |
719 | label: "bar", | 719 | label: "bar", |
720 | }, | 720 | }, |
721 | InlayHint { | 721 | InlayHint { |
722 | range: [257; 264), | 722 | range: [265; 272), |
723 | kind: ParameterHint, | 723 | kind: ParameterHint, |
724 | label: "msg", | 724 | label: "msg", |
725 | }, | 725 | }, |
726 | InlayHint { | 726 | InlayHint { |
727 | range: [266; 267), | 727 | range: [331; 334), |
728 | kind: ParameterHint, | ||
729 | label: "_", | ||
730 | }, | ||
731 | InlayHint { | ||
732 | range: [323; 326), | ||
733 | kind: ParameterHint, | 728 | kind: ParameterHint, |
734 | label: "param", | 729 | label: "param", |
735 | }, | 730 | }, |
736 | InlayHint { | 731 | InlayHint { |
737 | range: [350; 354), | 732 | range: [358; 362), |
738 | kind: ParameterHint, | 733 | kind: ParameterHint, |
739 | label: "param", | 734 | label: "param", |
740 | }, | 735 | }, |