aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-09 15:12:53 +0100
committerAleksey Kladov <[email protected]>2020-07-09 15:12:53 +0100
commit65d9966a4f6c35b63f97c16f5f62f83a04574f3e (patch)
tree2e4d75008c01531075bced1596ec65047d74ca91 /crates/ra_ide/src/completion
parente075e6eef2c275d9b9b511b37dad478285aecb48 (diff)
Always put config first
Diffstat (limited to 'crates/ra_ide/src/completion')
-rw-r--r--crates/ra_ide/src/completion/presentation.rs4
-rw-r--r--crates/ra_ide/src/completion/test_utils.rs22
2 files changed, 13 insertions, 13 deletions
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 {
491 } 491 }
492 } 492 }
493 493
494 let mut completions = get_all_completion_items(ra_fixture, &CompletionConfig::default()); 494 let mut completions = get_all_completion_items(CompletionConfig::default(), ra_fixture);
495 completions.sort_by_key(|it| (Reverse(it.score()), it.label().to_string())); 495 completions.sort_by_key(|it| (Reverse(it.score()), it.label().to_string()));
496 let actual = completions 496 let actual = completions
497 .into_iter() 497 .into_iter()
@@ -835,6 +835,7 @@ fn bar(s: &S) {
835 fn suppress_arg_snippets() { 835 fn suppress_arg_snippets() {
836 mark::check!(suppress_arg_snippets); 836 mark::check!(suppress_arg_snippets);
837 check_edit_with_config( 837 check_edit_with_config(
838 CompletionConfig { add_call_argument_snippets: false, ..CompletionConfig::default() },
838 "with_args", 839 "with_args",
839 r#" 840 r#"
840fn with_args(x: i32, y: String) {} 841fn with_args(x: i32, y: String) {}
@@ -844,7 +845,6 @@ fn main() { with_<|> }
844fn with_args(x: i32, y: String) {} 845fn with_args(x: i32, y: String) {}
845fn main() { with_args($0) } 846fn main() { with_args($0) }
846"#, 847"#,
847 &CompletionConfig { add_call_argument_snippets: false, ..CompletionConfig::default() },
848 ); 848 );
849 } 849 }
850 850
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::{
13}; 13};
14 14
15pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { 15pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> {
16 do_completion_with_config(code, kind, &CompletionConfig::default()) 16 do_completion_with_config(CompletionConfig::default(), code, kind)
17} 17}
18 18
19pub(crate) fn do_completion_with_config( 19pub(crate) fn do_completion_with_config(
20 config: CompletionConfig,
20 code: &str, 21 code: &str,
21 kind: CompletionKind, 22 kind: CompletionKind,
22 config: &CompletionConfig,
23) -> Vec<CompletionItem> { 23) -> Vec<CompletionItem> {
24 let mut kind_completions: Vec<CompletionItem> = get_all_completion_items(code, config) 24 let mut kind_completions: Vec<CompletionItem> = get_all_completion_items(config, code)
25 .into_iter() 25 .into_iter()
26 .filter(|c| c.completion_kind == kind) 26 .filter(|c| c.completion_kind == kind)
27 .collect(); 27 .collect();
@@ -30,15 +30,15 @@ pub(crate) fn do_completion_with_config(
30} 30}
31 31
32pub(crate) fn completion_list(code: &str, kind: CompletionKind) -> String { 32pub(crate) fn completion_list(code: &str, kind: CompletionKind) -> String {
33 completion_list_with_config(code, kind, &CompletionConfig::default()) 33 completion_list_with_config(CompletionConfig::default(), code, kind)
34} 34}
35 35
36pub(crate) fn completion_list_with_config( 36pub(crate) fn completion_list_with_config(
37 config: CompletionConfig,
37 code: &str, 38 code: &str,
38 kind: CompletionKind, 39 kind: CompletionKind,
39 config: &CompletionConfig,
40) -> String { 40) -> String {
41 let mut kind_completions: Vec<CompletionItem> = get_all_completion_items(code, config) 41 let mut kind_completions: Vec<CompletionItem> = get_all_completion_items(config, code)
42 .into_iter() 42 .into_iter()
43 .filter(|c| c.completion_kind == kind) 43 .filter(|c| c.completion_kind == kind)
44 .collect(); 44 .collect();
@@ -70,19 +70,19 @@ fn monospace_width(s: &str) -> usize {
70} 70}
71 71
72pub(crate) fn check_edit(what: &str, ra_fixture_before: &str, ra_fixture_after: &str) { 72pub(crate) fn check_edit(what: &str, ra_fixture_before: &str, ra_fixture_after: &str) {
73 check_edit_with_config(what, ra_fixture_before, ra_fixture_after, &CompletionConfig::default()) 73 check_edit_with_config(CompletionConfig::default(), what, ra_fixture_before, ra_fixture_after)
74} 74}
75 75
76pub(crate) fn check_edit_with_config( 76pub(crate) fn check_edit_with_config(
77 config: CompletionConfig,
77 what: &str, 78 what: &str,
78 ra_fixture_before: &str, 79 ra_fixture_before: &str,
79 ra_fixture_after: &str, 80 ra_fixture_after: &str,
80 config: &CompletionConfig,
81) { 81) {
82 let ra_fixture_after = trim_indent(ra_fixture_after); 82 let ra_fixture_after = trim_indent(ra_fixture_after);
83 let (analysis, position) = analysis_and_position(ra_fixture_before); 83 let (analysis, position) = analysis_and_position(ra_fixture_before);
84 let completions: Vec<CompletionItem> = 84 let completions: Vec<CompletionItem> =
85 analysis.completions(config, position).unwrap().unwrap().into(); 85 analysis.completions(&config, position).unwrap().unwrap().into();
86 let (completion,) = completions 86 let (completion,) = completions
87 .iter() 87 .iter()
88 .filter(|it| it.lookup() == what) 88 .filter(|it| it.lookup() == what)
@@ -106,9 +106,9 @@ pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) -
106} 106}
107 107
108pub(crate) fn get_all_completion_items( 108pub(crate) fn get_all_completion_items(
109 config: CompletionConfig,
109 code: &str, 110 code: &str,
110 options: &CompletionConfig,
111) -> Vec<CompletionItem> { 111) -> Vec<CompletionItem> {
112 let (analysis, position) = analysis_and_position(code); 112 let (analysis, position) = analysis_and_position(code);
113 analysis.completions(options, position).unwrap().unwrap().into() 113 analysis.completions(&config, position).unwrap().unwrap().into()
114} 114}