From 31561b118f1a57c9c1c5145493c5fcd3dd40876e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 10 Oct 2019 13:03:20 +0300 Subject: if completion does auto-insertion, indicate this in the label --- crates/ra_ide_api/src/completion/complete_dot.rs | 185 +++---- crates/ra_ide_api/src/completion/complete_path.rs | 166 ++++--- crates/ra_ide_api/src/completion/complete_scope.rs | 534 +++++++++++---------- .../ra_ide_api/src/completion/completion_item.rs | 4 + crates/ra_ide_api/src/completion/presentation.rs | 148 +++--- 5 files changed, 562 insertions(+), 475 deletions(-) diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 28c8324d0..86c11a283 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs @@ -119,27 +119,28 @@ mod tests { ", ), @r###" - ⋮[ - ⋮ CompletionItem { - ⋮ label: "foo", - ⋮ source_range: [187; 187), - ⋮ delete: [187; 187), - ⋮ insert: "foo()$0", - ⋮ kind: Method, - ⋮ detail: "fn foo(self)", - ⋮ }, - ⋮ CompletionItem { - ⋮ label: "the_field", - ⋮ source_range: [187; 187), - ⋮ delete: [187; 187), - ⋮ insert: "the_field", - ⋮ kind: Field, - ⋮ detail: "(u32,)", - ⋮ documentation: Documentation( - ⋮ "This is the_field", - ⋮ ), - ⋮ }, - ⋮] + [ + CompletionItem { + label: "foo(…)", + source_range: [187; 187), + delete: [187; 187), + insert: "foo()$0", + kind: Method, + lookup: "foo", + detail: "fn foo(self)", + }, + CompletionItem { + label: "the_field", + source_range: [187; 187), + delete: [187; 187), + insert: "the_field", + kind: Field, + detail: "(u32,)", + documentation: Documentation( + "This is the_field", + ), + }, + ] "### ); } @@ -158,24 +159,25 @@ mod tests { ", ), @r###" - ⋮[ - ⋮ CompletionItem { - ⋮ label: "foo", - ⋮ source_range: [126; 126), - ⋮ delete: [126; 126), - ⋮ insert: "foo()$0", - ⋮ kind: Method, - ⋮ detail: "fn foo(&self)", - ⋮ }, - ⋮ CompletionItem { - ⋮ label: "the_field", - ⋮ source_range: [126; 126), - ⋮ delete: [126; 126), - ⋮ insert: "the_field", - ⋮ kind: Field, - ⋮ detail: "(u32, i32)", - ⋮ }, - ⋮] + [ + CompletionItem { + label: "foo(…)", + source_range: [126; 126), + delete: [126; 126), + insert: "foo()$0", + kind: Method, + lookup: "foo", + detail: "fn foo(&self)", + }, + CompletionItem { + label: "the_field", + source_range: [126; 126), + delete: [126; 126), + insert: "the_field", + kind: Field, + detail: "(u32, i32)", + }, + ] "### ); } @@ -210,16 +212,17 @@ mod tests { ", ), @r###" - ⋮[ - ⋮ CompletionItem { - ⋮ label: "the_method", - ⋮ source_range: [144; 144), - ⋮ delete: [144; 144), - ⋮ insert: "the_method()$0", - ⋮ kind: Method, - ⋮ detail: "fn the_method(&self)", - ⋮ }, - ⋮] + [ + CompletionItem { + label: "the_method(…)", + source_range: [144; 144), + delete: [144; 144), + insert: "the_method()$0", + kind: Method, + lookup: "the_method", + detail: "fn the_method(&self)", + }, + ] "### ); } @@ -238,16 +241,17 @@ mod tests { ", ), @r###" - ⋮[ - ⋮ CompletionItem { - ⋮ label: "the_method", - ⋮ source_range: [151; 151), - ⋮ delete: [151; 151), - ⋮ insert: "the_method()$0", - ⋮ kind: Method, - ⋮ detail: "fn the_method(&self)", - ⋮ }, - ⋮] + [ + CompletionItem { + label: "the_method(…)", + source_range: [151; 151), + delete: [151; 151), + insert: "the_method()$0", + kind: Method, + lookup: "the_method", + detail: "fn the_method(&self)", + }, + ] "### ); } @@ -266,16 +270,17 @@ mod tests { ", ), @r###" - ⋮[ - ⋮ CompletionItem { - ⋮ label: "the_method", - ⋮ source_range: [155; 155), - ⋮ delete: [155; 155), - ⋮ insert: "the_method()$0", - ⋮ kind: Method, - ⋮ detail: "fn the_method(&self)", - ⋮ }, - ⋮] + [ + CompletionItem { + label: "the_method(…)", + source_range: [155; 155), + delete: [155; 155), + insert: "the_method()$0", + kind: Method, + lookup: "the_method", + detail: "fn the_method(&self)", + }, + ] "### ); } @@ -317,16 +322,17 @@ mod tests { ", ), @r###" - ⋮[ - ⋮ CompletionItem { - ⋮ label: "the_method", - ⋮ source_range: [249; 249), - ⋮ delete: [249; 249), - ⋮ insert: "the_method()$0", - ⋮ kind: Method, - ⋮ detail: "fn the_method(&self)", - ⋮ }, - ⋮] + [ + CompletionItem { + label: "the_method(…)", + source_range: [249; 249), + delete: [249; 249), + insert: "the_method()$0", + kind: Method, + lookup: "the_method", + detail: "fn the_method(&self)", + }, + ] "### ); } @@ -386,16 +392,17 @@ mod tests { ", ), @r###" - ⋮[ - ⋮ CompletionItem { - ⋮ label: "blah", - ⋮ source_range: [299; 300), - ⋮ delete: [299; 300), - ⋮ insert: "blah()$0", - ⋮ kind: Method, - ⋮ detail: "pub fn blah(&self)", - ⋮ }, - ⋮] + [ + CompletionItem { + label: "blah(…)", + source_range: [299; 300), + delete: [299; 300), + insert: "blah()$0", + kind: Method, + lookup: "blah", + detail: "pub fn blah(&self)", + }, + ] "### ); } diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index e01197fe4..b5e8bf591 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -375,19 +375,22 @@ mod tests { fn foo() { let _ = S::<|> } " ), - @r###"[ - CompletionItem { - label: "m", - source_range: [100; 100), - delete: [100; 100), - insert: "m()$0", - kind: Function, - detail: "fn m()", - documentation: Documentation( - "An associated method", - ), - }, -]"### + @r###" + [ + CompletionItem { + label: "m(…)", + source_range: [100; 100), + delete: [100; 100), + insert: "m()$0", + kind: Function, + lookup: "m", + detail: "fn m()", + documentation: Documentation( + "An associated method", + ), + }, + ] + "### ); } @@ -474,19 +477,22 @@ mod tests { fn foo() { let _ = S::<|> } " ), - @r###"[ - CompletionItem { - label: "m", - source_range: [100; 100), - delete: [100; 100), - insert: "m()$0", - kind: Function, - detail: "fn m()", - documentation: Documentation( - "An associated method", - ), - }, -]"### + @r###" + [ + CompletionItem { + label: "m(…)", + source_range: [100; 100), + delete: [100; 100), + insert: "m()$0", + kind: Function, + lookup: "m", + detail: "fn m()", + documentation: Documentation( + "An associated method", + ), + }, + ] + "### ); } @@ -507,19 +513,22 @@ mod tests { fn foo() { let _ = U::<|> } " ), - @r###"[ - CompletionItem { - label: "m", - source_range: [101; 101), - delete: [101; 101), - insert: "m()$0", - kind: Function, - detail: "fn m()", - documentation: Documentation( - "An associated method", - ), - }, -]"### + @r###" + [ + CompletionItem { + label: "m(…)", + source_range: [101; 101), + delete: [101; 101), + insert: "m()$0", + kind: Function, + lookup: "m", + detail: "fn m()", + documentation: Documentation( + "An associated method", + ), + }, + ] + "### ); } @@ -564,24 +573,28 @@ mod tests { } " ), - @r###"[ - CompletionItem { - label: "bar", - source_range: [185; 185), - delete: [185; 185), - insert: "bar()$0", - kind: Function, - detail: "fn bar()", - }, - CompletionItem { - label: "foo", - source_range: [185; 185), - delete: [185; 185), - insert: "foo()$0", - kind: Function, - detail: "fn foo()", - }, -]"### + @r###" + [ + CompletionItem { + label: "bar(…)", + source_range: [185; 185), + delete: [185; 185), + insert: "bar()$0", + kind: Function, + lookup: "bar", + detail: "fn bar()", + }, + CompletionItem { + label: "foo(…)", + source_range: [185; 185), + delete: [185; 185), + insert: "foo()$0", + kind: Function, + lookup: "foo", + detail: "fn foo()", + }, + ] + "### ); } @@ -600,24 +613,27 @@ mod tests { } " ), - @r###"[ - CompletionItem { - label: "foo!", - source_range: [179; 179), - delete: [179; 179), - insert: "foo!($0)", - kind: Macro, - detail: "#[macro_export]\nmacro_rules! foo", - }, - CompletionItem { - label: "main", - source_range: [179; 179), - delete: [179; 179), - insert: "main()$0", - kind: Function, - detail: "fn main()", - }, -]"### + @r###" + [ + CompletionItem { + label: "foo!", + source_range: [179; 179), + delete: [179; 179), + insert: "foo!($0)", + kind: Macro, + detail: "#[macro_export]\nmacro_rules! foo", + }, + CompletionItem { + label: "main(…)", + source_range: [179; 179), + delete: [179; 179), + insert: "main()$0", + kind: Function, + lookup: "main", + detail: "fn main()", + }, + ] + "### ); } } diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 84826cdcc..b64540365 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs @@ -145,32 +145,35 @@ mod tests { } " ), - @r###"[ - CompletionItem { - label: "quux", - source_range: [91; 91), - delete: [91; 91), - insert: "quux($0)", - kind: Function, - detail: "fn quux(x: i32)", - }, - CompletionItem { - label: "x", - source_range: [91; 91), - delete: [91; 91), - insert: "x", - kind: Binding, - detail: "i32", - }, - CompletionItem { - label: "y", - source_range: [91; 91), - delete: [91; 91), - insert: "y", - kind: Binding, - detail: "i32", - }, -]"### + @r###" + [ + CompletionItem { + label: "quux(…)", + source_range: [91; 91), + delete: [91; 91), + insert: "quux($0)", + kind: Function, + lookup: "quux", + detail: "fn quux(x: i32)", + }, + CompletionItem { + label: "x", + source_range: [91; 91), + delete: [91; 91), + insert: "x", + kind: Binding, + detail: "i32", + }, + CompletionItem { + label: "y", + source_range: [91; 91), + delete: [91; 91), + insert: "y", + kind: Binding, + detail: "i32", + }, + ] + "### ); } @@ -190,31 +193,34 @@ mod tests { } " ), - @r###"[ - CompletionItem { - label: "a", - source_range: [242; 242), - delete: [242; 242), - insert: "a", - kind: Binding, - }, - CompletionItem { - label: "b", - source_range: [242; 242), - delete: [242; 242), - insert: "b", - kind: Binding, - detail: "i32", - }, - CompletionItem { - label: "quux", - source_range: [242; 242), - delete: [242; 242), - insert: "quux()$0", - kind: Function, - detail: "fn quux()", - }, -]"### + @r###" + [ + CompletionItem { + label: "a", + source_range: [242; 242), + delete: [242; 242), + insert: "a", + kind: Binding, + }, + CompletionItem { + label: "b", + source_range: [242; 242), + delete: [242; 242), + insert: "b", + kind: Binding, + detail: "i32", + }, + CompletionItem { + label: "quux(…)", + source_range: [242; 242), + delete: [242; 242), + insert: "quux()$0", + kind: Function, + lookup: "quux", + detail: "fn quux()", + }, + ] + "### ); } @@ -230,23 +236,26 @@ mod tests { } " ), - @r###"[ - CompletionItem { - label: "quux", - source_range: [95; 95), - delete: [95; 95), - insert: "quux()$0", - kind: Function, - detail: "fn quux()", - }, - CompletionItem { - label: "x", - source_range: [95; 95), - delete: [95; 95), - insert: "x", - kind: Binding, - }, -]"### + @r###" + [ + CompletionItem { + label: "quux(…)", + source_range: [95; 95), + delete: [95; 95), + insert: "quux()$0", + kind: Function, + lookup: "quux", + detail: "fn quux()", + }, + CompletionItem { + label: "x", + source_range: [95; 95), + delete: [95; 95), + insert: "x", + kind: Binding, + }, + ] + "### ); } @@ -260,23 +269,26 @@ mod tests { } " ), - @r###"[ - CompletionItem { - label: "T", - source_range: [52; 52), - delete: [52; 52), - insert: "T", - kind: TypeParam, - }, - CompletionItem { - label: "quux", - source_range: [52; 52), - delete: [52; 52), - insert: "quux()$0", - kind: Function, - detail: "fn quux()", - }, -]"### + @r###" + [ + CompletionItem { + label: "T", + source_range: [52; 52), + delete: [52; 52), + insert: "T", + kind: TypeParam, + }, + CompletionItem { + label: "quux(…)", + source_range: [52; 52), + delete: [52; 52), + insert: "quux()$0", + kind: Function, + lookup: "quux", + detail: "fn quux()", + }, + ] + "### ); } @@ -300,11 +312,12 @@ mod tests { kind: TypeParam, }, CompletionItem { - label: "X", + label: "X<…>", source_range: [54; 54), delete: [54; 54), insert: "X<$0>", kind: Struct, + lookup: "X", }, ] "### @@ -354,30 +367,33 @@ mod tests { } " ), - @r###"[ - CompletionItem { - label: "Baz", - source_range: [105; 105), - delete: [105; 105), - insert: "Baz", - kind: Enum, - }, - CompletionItem { - label: "Foo", - source_range: [105; 105), - delete: [105; 105), - insert: "Foo", - kind: Struct, - }, - CompletionItem { - label: "quux", - source_range: [105; 105), - delete: [105; 105), - insert: "quux()$0", - kind: Function, - detail: "fn quux()", - }, -]"### + @r###" + [ + CompletionItem { + label: "Baz", + source_range: [105; 105), + delete: [105; 105), + insert: "Baz", + kind: Enum, + }, + CompletionItem { + label: "Foo", + source_range: [105; 105), + delete: [105; 105), + insert: "Foo", + kind: Struct, + }, + CompletionItem { + label: "quux(…)", + source_range: [105; 105), + delete: [105; 105), + insert: "quux()$0", + kind: Function, + lookup: "quux", + detail: "fn quux()", + }, + ] + "### ); } @@ -417,23 +433,26 @@ mod tests { } " ), - @r###"[ - CompletionItem { - label: "Bar", - source_range: [117; 117), - delete: [117; 117), - insert: "Bar", - kind: Struct, - }, - CompletionItem { - label: "quux", - source_range: [117; 117), - delete: [117; 117), - insert: "quux()$0", - kind: Function, - detail: "fn quux()", - }, -]"### + @r###" + [ + CompletionItem { + label: "Bar", + source_range: [117; 117), + delete: [117; 117), + insert: "Bar", + kind: Struct, + }, + CompletionItem { + label: "quux(…)", + source_range: [117; 117), + delete: [117; 117), + insert: "quux()$0", + kind: Function, + lookup: "quux", + detail: "fn quux()", + }, + ] + "### ); } @@ -456,11 +475,12 @@ mod tests { kind: Struct, }, CompletionItem { - label: "x", + label: "x(…)", source_range: [55; 55), delete: [55; 55), insert: "x()$0", kind: Function, + lookup: "x", detail: "fn x()", }, ] @@ -482,24 +502,27 @@ mod tests { } " ), - @r###"[ - CompletionItem { - label: "bar", - source_range: [146; 146), - delete: [146; 146), - insert: "bar", - kind: Binding, - detail: "i32", - }, - CompletionItem { - label: "foo", - source_range: [146; 146), - delete: [146; 146), - insert: "foo()$0", - kind: Function, - detail: "fn foo()", - }, -]"### + @r###" + [ + CompletionItem { + label: "bar", + source_range: [146; 146), + delete: [146; 146), + insert: "bar", + kind: Binding, + detail: "i32", + }, + CompletionItem { + label: "foo(…)", + source_range: [146; 146), + delete: [146; 146), + insert: "foo()$0", + kind: Function, + lookup: "foo", + detail: "fn foo()", + }, + ] + "### ); } @@ -554,11 +577,12 @@ mod tests { kind: Struct, }, CompletionItem { - label: "foo", + label: "foo(…)", source_range: [18; 18), delete: [18; 18), insert: "foo()$0", kind: Function, + lookup: "foo", detail: "fn foo()", }, CompletionItem { @@ -606,54 +630,57 @@ mod tests { } " ), - @r##"[ - CompletionItem { - label: "bar!", - source_range: [252; 252), - delete: [252; 252), - insert: "bar!($0)", - kind: Macro, - detail: "macro_rules! bar", - }, - CompletionItem { - label: "baz!", - source_range: [252; 252), - delete: [252; 252), - insert: "baz!($0)", - kind: Macro, - detail: "#[macro_export]\nmacro_rules! baz", - }, - CompletionItem { - label: "foo!", - source_range: [252; 252), - delete: [252; 252), - insert: "foo!($0)", - kind: Macro, - detail: "macro_rules! foo", - }, - CompletionItem { - label: "m1", - source_range: [252; 252), - delete: [252; 252), - insert: "m1", - kind: Module, - }, - CompletionItem { - label: "m2", - source_range: [252; 252), - delete: [252; 252), - insert: "m2", - kind: Module, - }, - CompletionItem { - label: "main", - source_range: [252; 252), - delete: [252; 252), - insert: "main()$0", - kind: Function, - detail: "fn main()", - }, -]"## + @r###" + [ + CompletionItem { + label: "bar!", + source_range: [252; 252), + delete: [252; 252), + insert: "bar!($0)", + kind: Macro, + detail: "macro_rules! bar", + }, + CompletionItem { + label: "baz!", + source_range: [252; 252), + delete: [252; 252), + insert: "baz!($0)", + kind: Macro, + detail: "#[macro_export]\nmacro_rules! baz", + }, + CompletionItem { + label: "foo!", + source_range: [252; 252), + delete: [252; 252), + insert: "foo!($0)", + kind: Macro, + detail: "macro_rules! foo", + }, + CompletionItem { + label: "m1", + source_range: [252; 252), + delete: [252; 252), + insert: "m1", + kind: Module, + }, + CompletionItem { + label: "m2", + source_range: [252; 252), + delete: [252; 252), + insert: "m2", + kind: Module, + }, + CompletionItem { + label: "main(…)", + source_range: [252; 252), + delete: [252; 252), + insert: "main()$0", + kind: Function, + lookup: "main", + detail: "fn main()", + }, + ] + "### ); } @@ -672,24 +699,27 @@ mod tests { } " ), - @r##"[ - CompletionItem { - label: "foo", - source_range: [49; 49), - delete: [49; 49), - insert: "foo()$0", - kind: Function, - detail: "fn foo()", - }, - CompletionItem { - label: "foo!", - source_range: [49; 49), - delete: [49; 49), - insert: "foo!($0)", - kind: Macro, - detail: "macro_rules! foo", - }, -]"## + @r###" + [ + CompletionItem { + label: "foo!", + source_range: [49; 49), + delete: [49; 49), + insert: "foo!($0)", + kind: Macro, + detail: "macro_rules! foo", + }, + CompletionItem { + label: "foo(…)", + source_range: [49; 49), + delete: [49; 49), + insert: "foo()$0", + kind: Function, + lookup: "foo", + detail: "fn foo()", + }, + ] + "### ); } @@ -708,24 +738,27 @@ mod tests { } " ), - @r##"[ - CompletionItem { - label: "foo!", - source_range: [57; 57), - delete: [57; 57), - insert: "foo!($0)", - kind: Macro, - detail: "macro_rules! foo", - }, - CompletionItem { - label: "main", - source_range: [57; 57), - delete: [57; 57), - insert: "main()$0", - kind: Function, - detail: "fn main()", - }, -]"## + @r###" + [ + CompletionItem { + label: "foo!", + source_range: [57; 57), + delete: [57; 57), + insert: "foo!($0)", + kind: Macro, + detail: "macro_rules! foo", + }, + CompletionItem { + label: "main(…)", + source_range: [57; 57), + delete: [57; 57), + insert: "main()$0", + kind: Function, + lookup: "main", + detail: "fn main()", + }, + ] + "### ); } @@ -744,24 +777,27 @@ mod tests { } " ), - @r##"[ - CompletionItem { - label: "foo!", - source_range: [50; 50), - delete: [50; 50), - insert: "foo!($0)", - kind: Macro, - detail: "macro_rules! foo", - }, - CompletionItem { - label: "main", - source_range: [50; 50), - delete: [50; 50), - insert: "main()$0", - kind: Function, - detail: "fn main()", - }, -]"## + @r###" + [ + CompletionItem { + label: "foo!", + source_range: [50; 50), + delete: [50; 50), + insert: "foo!($0)", + kind: Macro, + detail: "macro_rules! foo", + }, + CompletionItem { + label: "main(…)", + source_range: [50; 50), + delete: [50; 50), + insert: "main()$0", + kind: Function, + lookup: "main", + detail: "fn main()", + }, + ] + "### ); } } diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index b1f0390ec..3e6933bc1 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs @@ -216,6 +216,10 @@ impl Builder { self.lookup = Some(lookup.into()); self } + pub(crate) fn label(mut self, label: impl Into) -> Builder { + self.label = label.into(); + self + } pub(crate) fn insert_text(mut self, insert_text: impl Into) -> Builder { self.insert_text = Some(insert_text.into()); self diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index b7807ef8e..175a27ba9 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -116,7 +116,10 @@ impl Completions { if let Some(def) = generic_def { if has_non_default_type_params(def, ctx.db) { tested_by!(inserts_angle_brackets_for_generics); - completion_item = completion_item.insert_snippet(format!("{}<$0>", local_name)); + completion_item = completion_item + .lookup_by(local_name.clone()) + .label(format!("{}<…>", local_name)) + .insert_snippet(format!("{}<$0>", local_name)); } } } @@ -169,14 +172,15 @@ impl Completions { let ast_node = func.source(ctx.db).ast; let detail = function_label(&ast_node); - let mut builder = CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name) - .kind(if data.has_self_param() { - CompletionItemKind::Method - } else { - CompletionItemKind::Function - }) - .set_documentation(func.docs(ctx.db)) - .detail(detail); + let mut builder = + CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.clone()) + .kind(if data.has_self_param() { + CompletionItemKind::Method + } else { + CompletionItemKind::Function + }) + .set_documentation(func.docs(ctx.db)) + .detail(detail); // Add `<>` for generic types if ctx.use_item_syntax.is_none() @@ -190,7 +194,10 @@ impl Completions { } else { format!("{}($0)", data.name()) }; - builder = builder.insert_snippet(snippet); + builder = builder + .lookup_by(name.clone()) + .label(format!("{}(…)", name)) + .insert_snippet(snippet); } self.add(builder) @@ -269,24 +276,28 @@ mod tests { fn main() { no_<|> } " ), - @r###"[ - CompletionItem { - label: "main", - source_range: [61; 64), - delete: [61; 64), - insert: "main()$0", - kind: Function, - detail: "fn main()", - }, - CompletionItem { - label: "no_args", - source_range: [61; 64), - delete: [61; 64), - insert: "no_args()$0", - kind: Function, - detail: "fn no_args()", - }, -]"### + @r###" + [ + CompletionItem { + label: "main(…)", + source_range: [61; 64), + delete: [61; 64), + insert: "main()$0", + kind: Function, + lookup: "main", + detail: "fn main()", + }, + CompletionItem { + label: "no_args(…)", + source_range: [61; 64), + delete: [61; 64), + insert: "no_args()$0", + kind: Function, + lookup: "no_args", + detail: "fn no_args()", + }, + ] + "### ); assert_debug_snapshot!( do_reference_completion( @@ -295,24 +306,28 @@ mod tests { fn main() { with_<|> } " ), - @r###"[ - CompletionItem { - label: "main", - source_range: [80; 85), - delete: [80; 85), - insert: "main()$0", - kind: Function, - detail: "fn main()", - }, - CompletionItem { - label: "with_args", - source_range: [80; 85), - delete: [80; 85), - insert: "with_args($0)", - kind: Function, - detail: "fn with_args(x: i32, y: String)", - }, -]"### + @r###" + [ + CompletionItem { + label: "main(…)", + source_range: [80; 85), + delete: [80; 85), + insert: "main()$0", + kind: Function, + lookup: "main", + detail: "fn main()", + }, + CompletionItem { + label: "with_args(…)", + source_range: [80; 85), + delete: [80; 85), + insert: "with_args($0)", + kind: Function, + lookup: "with_args", + detail: "fn with_args(x: i32, y: String)", + }, + ] + "### ); assert_debug_snapshot!( do_reference_completion( @@ -326,16 +341,19 @@ mod tests { } " ), - @r###"[ - CompletionItem { - label: "foo", - source_range: [163; 164), - delete: [163; 164), - insert: "foo()$0", - kind: Method, - detail: "fn foo(&self)", - }, -]"### + @r###" + [ + CompletionItem { + label: "foo(…)", + source_range: [163; 164), + delete: [163; 164), + insert: "foo()$0", + kind: Method, + lookup: "foo", + detail: "fn foo(&self)", + }, + ] + "### ); } @@ -430,18 +448,20 @@ mod tests { @r###" [ CompletionItem { - label: "Vec", + label: "Vec<…>", source_range: [61; 63), delete: [61; 63), insert: "Vec<$0>", kind: Struct, + lookup: "Vec", }, CompletionItem { - label: "foo", + label: "foo(…)", source_range: [61; 63), delete: [61; 63), insert: "foo($0)", kind: Function, + lookup: "foo", detail: "fn foo(xs: Ve)", }, ] @@ -457,18 +477,20 @@ mod tests { @r###" [ CompletionItem { - label: "Vec", + label: "Vec<…>", source_range: [64; 66), delete: [64; 66), insert: "Vec<$0>", kind: TypeAlias, + lookup: "Vec", }, CompletionItem { - label: "foo", + label: "foo(…)", source_range: [64; 66), delete: [64; 66), insert: "foo($0)", kind: Function, + lookup: "foo", detail: "fn foo(xs: Ve)", }, ] @@ -491,11 +513,12 @@ mod tests { kind: Struct, }, CompletionItem { - label: "foo", + label: "foo(…)", source_range: [68; 70), delete: [68; 70), insert: "foo($0)", kind: Function, + lookup: "foo", detail: "fn foo(xs: Ve)", }, ] @@ -518,11 +541,12 @@ mod tests { kind: Struct, }, CompletionItem { - label: "foo", + label: "foo(…)", source_range: [61; 63), delete: [61; 63), insert: "foo($0)", kind: Function, + lookup: "foo", detail: "fn foo(xs: Ve)", }, ] -- cgit v1.2.3