From 4d13691ad192c20b2fb0f349582622cb5230da99 Mon Sep 17 00:00:00 2001 From: Yuki Kodama Date: Sun, 24 May 2020 22:39:09 +0900 Subject: Reflect test case --- crates/ra_ide/src/completion/presentation.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide/src/completion/presentation.rs') diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 440ffa31d..6b29f58d5 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -641,7 +641,7 @@ mod tests { assert_debug_snapshot!( do_reference_completion( r" - fn with_args(x: i32, y: String) {} + fn with_args(x: i32, y: String, _z: bool) {} fn main() { with_<|> } " ), @@ -649,8 +649,8 @@ mod tests { [ CompletionItem { label: "main()", - source_range: 80..85, - delete: 80..85, + source_range: 90..95, + delete: 90..95, insert: "main()$0", kind: Function, lookup: "main", @@ -658,12 +658,12 @@ mod tests { }, CompletionItem { label: "with_args(…)", - source_range: 80..85, - delete: 80..85, - insert: "with_args(${1:x}, ${2:y})$0", + source_range: 90..95, + delete: 90..95, + insert: "with_args(${1:x}, ${2:y}, ${3:z})$0", kind: Function, lookup: "with_args", - detail: "fn with_args(x: i32, y: String)", + detail: "fn with_args(x: i32, y: String, _z: bool)", trigger_call_info: true, }, ] -- cgit v1.2.3 From 378bfc3c8f1c63f44f972e11c9de00f9733b13c0 Mon Sep 17 00:00:00 2001 From: Yuki Kodama Date: Sun, 24 May 2020 23:01:26 +0900 Subject: Separate assertions --- crates/ra_ide/src/completion/presentation.rs | 72 +++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide/src/completion/presentation.rs') diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 6b29f58d5..5708ff291 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -641,7 +641,7 @@ mod tests { assert_debug_snapshot!( do_reference_completion( r" - fn with_args(x: i32, y: String, _z: bool) {} + fn with_args(x: i32, y: String) {} fn main() { with_<|> } " ), @@ -649,8 +649,8 @@ mod tests { [ CompletionItem { label: "main()", - source_range: 90..95, - delete: 90..95, + source_range: 80..85, + delete: 80..85, insert: "main()$0", kind: Function, lookup: "main", @@ -658,12 +658,43 @@ mod tests { }, CompletionItem { label: "with_args(…)", - source_range: 90..95, - delete: 90..95, - insert: "with_args(${1:x}, ${2:y}, ${3:z})$0", + source_range: 80..85, + delete: 80..85, + insert: "with_args(${1:x}, ${2:y})$0", kind: Function, lookup: "with_args", - detail: "fn with_args(x: i32, y: String, _z: bool)", + detail: "fn with_args(x: i32, y: String)", + trigger_call_info: true, + }, + ] + "### + ); + assert_debug_snapshot!( + do_reference_completion( + r" + fn with_ignored_args(_foo: i32, b_a_r_: bool) {} + fn main() { with_<|> } + " + ), + @r###" + [ + CompletionItem { + label: "main()", + source_range: 94..99, + delete: 94..99, + insert: "main()$0", + kind: Function, + lookup: "main", + detail: "fn main()", + }, + CompletionItem { + label: "with_ignored_args(…)", + source_range: 94..99, + delete: 94..99, + insert: "with_ignored_args(${1:foo}, ${2:b_a_r_})$0", + kind: Function, + lookup: "with_ignored_args", + detail: "fn with_ignored_args(_foo: i32, b_a_r_: bool)", trigger_call_info: true, }, ] @@ -695,6 +726,33 @@ mod tests { ] "### ); + assert_debug_snapshot!( + do_reference_completion( + r" + struct S {} + impl S { + fn foo_ignored_args(&self, _a: bool, b: i32) {} + } + fn bar(s: &S) { + s.f<|> + } + " + ), + @r###" + [ + CompletionItem { + label: "foo_ignored_args(…)", + source_range: 194..195, + delete: 194..195, + insert: "foo_ignored_args(${1:a}, ${2:b})$0", + kind: Method, + lookup: "foo_ignored_args", + detail: "fn foo_ignored_args(&self, _a: bool, b: i32)", + trigger_call_info: true, + }, + ] + "### + ); } #[test] -- cgit v1.2.3 From 41d0f7f24ef924440ee710e134c01d6e47056c3f Mon Sep 17 00:00:00 2001 From: Yuki Kodama Date: Mon, 25 May 2020 00:14:56 +0900 Subject: Fix test to consider multiple underscores --- crates/ra_ide/src/completion/presentation.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide/src/completion/presentation.rs') diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 5708ff291..e59f730ff 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -672,7 +672,7 @@ mod tests { assert_debug_snapshot!( do_reference_completion( r" - fn with_ignored_args(_foo: i32, b_a_r_: bool) {} + fn with_ignored_args(_foo: i32, ___bar: bool, ho_ge_: String) {} fn main() { with_<|> } " ), @@ -680,8 +680,8 @@ mod tests { [ CompletionItem { label: "main()", - source_range: 94..99, - delete: 94..99, + source_range: 110..115, + delete: 110..115, insert: "main()$0", kind: Function, lookup: "main", @@ -689,12 +689,12 @@ mod tests { }, CompletionItem { label: "with_ignored_args(…)", - source_range: 94..99, - delete: 94..99, - insert: "with_ignored_args(${1:foo}, ${2:b_a_r_})$0", + source_range: 110..115, + delete: 110..115, + insert: "with_ignored_args(${1:foo}, ${2:bar}, ${3:ho_ge_})$0", kind: Function, lookup: "with_ignored_args", - detail: "fn with_ignored_args(_foo: i32, b_a_r_: bool)", + detail: "fn with_ignored_args(_foo: i32, ___bar: bool, ho_ge_: String)", trigger_call_info: true, }, ] -- cgit v1.2.3 From fd83f469e9643c7a9da2d9e4c796bd89c441458d Mon Sep 17 00:00:00 2001 From: Yuki Kodama Date: Tue, 26 May 2020 01:05:50 +0900 Subject: Trim at presentation layer --- crates/ra_ide/src/completion/presentation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide/src/completion/presentation.rs') diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index e59f730ff..61565c84f 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -211,7 +211,7 @@ impl Completions { .parameter_names .iter() .skip(if function_signature.has_self_param { 1 } else { 0 }) - .cloned() + .map(|name| name.trim_start_matches('_').into()) .collect(); builder = builder.add_call_parens(ctx, name, Params::Named(params)); -- cgit v1.2.3