From 65d9966a4f6c35b63f97c16f5f62f83a04574f3e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Jul 2020 16:12:53 +0200 Subject: Always put config first --- crates/ra_ide/src/completion/presentation.rs | 4 ++-- crates/ra_ide/src/completion/test_utils.rs | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'crates/ra_ide/src/completion') diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index e4c57e41a..48afee5fb 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -491,7 +491,7 @@ mod tests { } } - let mut completions = get_all_completion_items(ra_fixture, &CompletionConfig::default()); + let mut completions = get_all_completion_items(CompletionConfig::default(), ra_fixture); completions.sort_by_key(|it| (Reverse(it.score()), it.label().to_string())); let actual = completions .into_iter() @@ -835,6 +835,7 @@ fn bar(s: &S) { fn suppress_arg_snippets() { mark::check!(suppress_arg_snippets); check_edit_with_config( + CompletionConfig { add_call_argument_snippets: false, ..CompletionConfig::default() }, "with_args", r#" fn with_args(x: i32, y: String) {} @@ -844,7 +845,6 @@ fn main() { with_<|> } fn with_args(x: i32, y: String) {} fn main() { with_args($0) } "#, - &CompletionConfig { add_call_argument_snippets: false, ..CompletionConfig::default() }, ); } diff --git a/crates/ra_ide/src/completion/test_utils.rs b/crates/ra_ide/src/completion/test_utils.rs index c2be23697..919177745 100644 --- a/crates/ra_ide/src/completion/test_utils.rs +++ b/crates/ra_ide/src/completion/test_utils.rs @@ -13,15 +13,15 @@ use crate::{ }; pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec { - do_completion_with_config(code, kind, &CompletionConfig::default()) + do_completion_with_config(CompletionConfig::default(), code, kind) } pub(crate) fn do_completion_with_config( + config: CompletionConfig, code: &str, kind: CompletionKind, - config: &CompletionConfig, ) -> Vec { - let mut kind_completions: Vec = get_all_completion_items(code, config) + let mut kind_completions: Vec = get_all_completion_items(config, code) .into_iter() .filter(|c| c.completion_kind == kind) .collect(); @@ -30,15 +30,15 @@ pub(crate) fn do_completion_with_config( } pub(crate) fn completion_list(code: &str, kind: CompletionKind) -> String { - completion_list_with_config(code, kind, &CompletionConfig::default()) + completion_list_with_config(CompletionConfig::default(), code, kind) } pub(crate) fn completion_list_with_config( + config: CompletionConfig, code: &str, kind: CompletionKind, - config: &CompletionConfig, ) -> String { - let mut kind_completions: Vec = get_all_completion_items(code, config) + let mut kind_completions: Vec = get_all_completion_items(config, code) .into_iter() .filter(|c| c.completion_kind == kind) .collect(); @@ -70,19 +70,19 @@ fn monospace_width(s: &str) -> usize { } pub(crate) fn check_edit(what: &str, ra_fixture_before: &str, ra_fixture_after: &str) { - check_edit_with_config(what, ra_fixture_before, ra_fixture_after, &CompletionConfig::default()) + check_edit_with_config(CompletionConfig::default(), what, ra_fixture_before, ra_fixture_after) } pub(crate) fn check_edit_with_config( + config: CompletionConfig, what: &str, ra_fixture_before: &str, ra_fixture_after: &str, - config: &CompletionConfig, ) { let ra_fixture_after = trim_indent(ra_fixture_after); let (analysis, position) = analysis_and_position(ra_fixture_before); let completions: Vec = - analysis.completions(config, position).unwrap().unwrap().into(); + analysis.completions(&config, position).unwrap().unwrap().into(); let (completion,) = completions .iter() .filter(|it| it.lookup() == what) @@ -106,9 +106,9 @@ pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) - } pub(crate) fn get_all_completion_items( + config: CompletionConfig, code: &str, - options: &CompletionConfig, ) -> Vec { let (analysis, position) = analysis_and_position(code); - analysis.completions(options, position).unwrap().unwrap().into() + analysis.completions(&config, position).unwrap().unwrap().into() } -- cgit v1.2.3