From 53bb46fa853bee99f673a0ed0a53798c46847d99 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Sat, 6 Mar 2021 16:56:07 -0800 Subject: show function params in completion detail --- crates/ide_completion/src/render.rs | 54 +++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'crates/ide_completion/src/render.rs') diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs index db31896e5..d9bf52582 100644 --- a/crates/ide_completion/src/render.rs +++ b/crates/ide_completion/src/render.rs @@ -424,6 +424,44 @@ fn main() { Foo::Fo$0 } ); } + #[test] + fn fn_detail_includes_args_and_return_type() { + check( + r#" +fn foo(a: u32, b: u32, t: T) -> (u32, T) { (a, t) } + +fn main() { fo$0 } +"#, + expect![[r#" + [ + CompletionItem { + label: "foo(…)", + source_range: 68..70, + delete: 68..70, + insert: "foo(${1:a}, ${2:b}, ${3:t})$0", + kind: SymbolKind( + Function, + ), + lookup: "foo", + detail: "fn(u32, u32, T) -> (u32, T)", + trigger_call_info: true, + }, + CompletionItem { + label: "main()", + source_range: 68..70, + delete: 68..70, + insert: "main()$0", + kind: SymbolKind( + Function, + ), + lookup: "main", + detail: "fn()", + }, + ] + "#]], + ); + } + #[test] fn enum_detail_just_parentheses_for_unit() { check( @@ -501,7 +539,7 @@ fn main() { let _: m::Spam = S$0 } Function, ), lookup: "main", - detail: "-> ()", + detail: "fn()", }, ] "#]], @@ -530,7 +568,7 @@ fn main() { som$0 } Function, ), lookup: "main", - detail: "-> ()", + detail: "fn()", }, CompletionItem { label: "something_deprecated()", @@ -541,7 +579,7 @@ fn main() { som$0 } Function, ), lookup: "something_deprecated", - detail: "-> ()", + detail: "fn()", deprecated: true, }, CompletionItem { @@ -553,7 +591,7 @@ fn main() { som$0 } Function, ), lookup: "something_else_deprecated", - detail: "-> ()", + detail: "fn()", deprecated: true, }, ] @@ -604,7 +642,7 @@ impl S { insert: "bar()$0", kind: Method, lookup: "bar", - detail: "-> ()", + detail: "fn(self)", documentation: Documentation( "Method docs", ), @@ -704,7 +742,7 @@ fn foo(s: S) { s.$0 } insert: "the_method()$0", kind: Method, lookup: "the_method", - detail: "-> ()", + detail: "fn(&self)", }, ] "#]], @@ -954,7 +992,7 @@ fn main() { Function, ), lookup: "foo", - detail: "-> ()", + detail: "fn(&mut S)", trigger_call_info: true, }, CompletionItem { @@ -966,7 +1004,7 @@ fn main() { Function, ), lookup: "main", - detail: "-> ()", + detail: "fn()", }, CompletionItem { label: "s", -- cgit v1.2.3