From 8d3d5cbdb0418e72737158d82bdd64e177960dfa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 10 Oct 2019 16:37:56 +0300 Subject: tweak fn labels in completion --- crates/ra_ide_api/src/completion/complete_dot.rs | 14 ++++++------- crates/ra_ide_api/src/completion/complete_path.rs | 12 +++++------ crates/ra_ide_api/src/completion/complete_scope.rs | 24 +++++++++++----------- crates/ra_ide_api/src/completion/presentation.rs | 19 ++++++++--------- 4 files changed, 33 insertions(+), 36 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 86c11a283..b4df6ee2a 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs @@ -121,7 +121,7 @@ mod tests { @r###" [ CompletionItem { - label: "foo(…)", + label: "foo()", source_range: [187; 187), delete: [187; 187), insert: "foo()$0", @@ -161,7 +161,7 @@ mod tests { @r###" [ CompletionItem { - label: "foo(…)", + label: "foo()", source_range: [126; 126), delete: [126; 126), insert: "foo()$0", @@ -214,7 +214,7 @@ mod tests { @r###" [ CompletionItem { - label: "the_method(…)", + label: "the_method()", source_range: [144; 144), delete: [144; 144), insert: "the_method()$0", @@ -243,7 +243,7 @@ mod tests { @r###" [ CompletionItem { - label: "the_method(…)", + label: "the_method()", source_range: [151; 151), delete: [151; 151), insert: "the_method()$0", @@ -272,7 +272,7 @@ mod tests { @r###" [ CompletionItem { - label: "the_method(…)", + label: "the_method()", source_range: [155; 155), delete: [155; 155), insert: "the_method()$0", @@ -324,7 +324,7 @@ mod tests { @r###" [ CompletionItem { - label: "the_method(…)", + label: "the_method()", source_range: [249; 249), delete: [249; 249), insert: "the_method()$0", @@ -394,7 +394,7 @@ mod tests { @r###" [ CompletionItem { - label: "blah(…)", + label: "blah()", source_range: [299; 300), delete: [299; 300), insert: "blah()$0", diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index b5e8bf591..23dece73c 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -378,7 +378,7 @@ mod tests { @r###" [ CompletionItem { - label: "m(…)", + label: "m()", source_range: [100; 100), delete: [100; 100), insert: "m()$0", @@ -480,7 +480,7 @@ mod tests { @r###" [ CompletionItem { - label: "m(…)", + label: "m()", source_range: [100; 100), delete: [100; 100), insert: "m()$0", @@ -516,7 +516,7 @@ mod tests { @r###" [ CompletionItem { - label: "m(…)", + label: "m()", source_range: [101; 101), delete: [101; 101), insert: "m()$0", @@ -576,7 +576,7 @@ mod tests { @r###" [ CompletionItem { - label: "bar(…)", + label: "bar()", source_range: [185; 185), delete: [185; 185), insert: "bar()$0", @@ -585,7 +585,7 @@ mod tests { detail: "fn bar()", }, CompletionItem { - label: "foo(…)", + label: "foo()", source_range: [185; 185), delete: [185; 185), insert: "foo()$0", @@ -624,7 +624,7 @@ mod tests { detail: "#[macro_export]\nmacro_rules! foo", }, CompletionItem { - label: "main(…)", + label: "main()", source_range: [179; 179), delete: [179; 179), insert: "main()$0", diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index b64540365..4e56de3f5 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs @@ -211,7 +211,7 @@ mod tests { detail: "i32", }, CompletionItem { - label: "quux(…)", + label: "quux()", source_range: [242; 242), delete: [242; 242), insert: "quux()$0", @@ -239,7 +239,7 @@ mod tests { @r###" [ CompletionItem { - label: "quux(…)", + label: "quux()", source_range: [95; 95), delete: [95; 95), insert: "quux()$0", @@ -279,7 +279,7 @@ mod tests { kind: TypeParam, }, CompletionItem { - label: "quux(…)", + label: "quux()", source_range: [52; 52), delete: [52; 52), insert: "quux()$0", @@ -384,7 +384,7 @@ mod tests { kind: Struct, }, CompletionItem { - label: "quux(…)", + label: "quux()", source_range: [105; 105), delete: [105; 105), insert: "quux()$0", @@ -443,7 +443,7 @@ mod tests { kind: Struct, }, CompletionItem { - label: "quux(…)", + label: "quux()", source_range: [117; 117), delete: [117; 117), insert: "quux()$0", @@ -475,7 +475,7 @@ mod tests { kind: Struct, }, CompletionItem { - label: "x(…)", + label: "x()", source_range: [55; 55), delete: [55; 55), insert: "x()$0", @@ -513,7 +513,7 @@ mod tests { detail: "i32", }, CompletionItem { - label: "foo(…)", + label: "foo()", source_range: [146; 146), delete: [146; 146), insert: "foo()$0", @@ -577,7 +577,7 @@ mod tests { kind: Struct, }, CompletionItem { - label: "foo(…)", + label: "foo()", source_range: [18; 18), delete: [18; 18), insert: "foo()$0", @@ -671,7 +671,7 @@ mod tests { kind: Module, }, CompletionItem { - label: "main(…)", + label: "main()", source_range: [252; 252), delete: [252; 252), insert: "main()$0", @@ -710,7 +710,7 @@ mod tests { detail: "macro_rules! foo", }, CompletionItem { - label: "foo(…)", + label: "foo()", source_range: [49; 49), delete: [49; 49), insert: "foo()$0", @@ -749,7 +749,7 @@ mod tests { detail: "macro_rules! foo", }, CompletionItem { - label: "main(…)", + label: "main()", source_range: [57; 57), delete: [57; 57), insert: "main()$0", @@ -788,7 +788,7 @@ mod tests { detail: "macro_rules! foo", }, CompletionItem { - label: "main(…)", + label: "main()", source_range: [50; 50), delete: [50; 50), insert: "main()$0", diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 175a27ba9..20242d293 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -188,16 +188,13 @@ impl Completions { && ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis") { tested_by!(inserts_parens_for_function_calls); - let snippet = + let (snippet, label) = if data.params().is_empty() || data.has_self_param() && data.params().len() == 1 { - format!("{}()$0", data.name()) + (format!("{}()$0", data.name()), format!("{}()", name)) } else { - format!("{}($0)", data.name()) + (format!("{}($0)", data.name()), format!("{}(…)", name)) }; - builder = builder - .lookup_by(name.clone()) - .label(format!("{}(…)", name)) - .insert_snippet(snippet); + builder = builder.lookup_by(name.clone()).label(label).insert_snippet(snippet); } self.add(builder) @@ -279,7 +276,7 @@ mod tests { @r###" [ CompletionItem { - label: "main(…)", + label: "main()", source_range: [61; 64), delete: [61; 64), insert: "main()$0", @@ -288,7 +285,7 @@ mod tests { detail: "fn main()", }, CompletionItem { - label: "no_args(…)", + label: "no_args()", source_range: [61; 64), delete: [61; 64), insert: "no_args()$0", @@ -309,7 +306,7 @@ mod tests { @r###" [ CompletionItem { - label: "main(…)", + label: "main()", source_range: [80; 85), delete: [80; 85), insert: "main()$0", @@ -344,7 +341,7 @@ mod tests { @r###" [ CompletionItem { - label: "foo(…)", + label: "foo()", source_range: [163; 164), delete: [163; 164), insert: "foo()$0", -- cgit v1.2.3