aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/test_utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/completion/test_utils.rs')
-rw-r--r--crates/ra_ide/src/completion/test_utils.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_ide/src/completion/test_utils.rs b/crates/ra_ide/src/completion/test_utils.rs
index 145d36c98..cbae1da85 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_options(code, kind, &CompletionConfig::default()) 16 do_completion_with_config(code, kind, &CompletionConfig::default())
17} 17}
18 18
19pub(crate) fn do_completion_with_options( 19pub(crate) fn do_completion_with_config(
20 code: &str, 20 code: &str,
21 kind: CompletionKind, 21 kind: CompletionKind,
22 options: &CompletionConfig, 22 config: &CompletionConfig,
23) -> Vec<CompletionItem> { 23) -> Vec<CompletionItem> {
24 let mut kind_completions: Vec<CompletionItem> = get_all_completion_items(code, options) 24 let mut kind_completions: Vec<CompletionItem> = get_all_completion_items(code, config)
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_options(
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_options(code, kind, &CompletionConfig::default()) 33 completion_list_with_config(code, kind, &CompletionConfig::default())
34} 34}
35 35
36pub(crate) fn completion_list_with_options( 36pub(crate) fn completion_list_with_config(
37 code: &str, 37 code: &str,
38 kind: CompletionKind, 38 kind: CompletionKind,
39 options: &CompletionConfig, 39 config: &CompletionConfig,
40) -> String { 40) -> String {
41 let mut kind_completions: Vec<CompletionItem> = get_all_completion_items(code, options) 41 let mut kind_completions: Vec<CompletionItem> = get_all_completion_items(code, config)
42 .into_iter() 42 .into_iter()
43 .filter(|c| c.completion_kind == kind) 43 .filter(|c| c.completion_kind == kind)
44 .collect(); 44 .collect();
@@ -92,7 +92,10 @@ pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) -
92 .unwrap(); 92 .unwrap();
93} 93}
94 94
95fn get_all_completion_items(code: &str, options: &CompletionConfig) -> Vec<CompletionItem> { 95pub(crate) fn get_all_completion_items(
96 code: &str,
97 options: &CompletionConfig,
98) -> Vec<CompletionItem> {
96 let (analysis, position) = analysis_and_position(code); 99 let (analysis, position) = analysis_and_position(code);
97 analysis.completions(options, position).unwrap().unwrap().into() 100 analysis.completions(options, position).unwrap().unwrap().into()
98} 101}