diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-27 11:11:00 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-27 11:11:00 +0100 |
commit | b081018363a210ffa0b95a4d3350a0a3e9b0cd83 (patch) | |
tree | 93d3793a4de59a4a9c3cee39ace5ee45c0944ef5 /crates/ra_ide/src | |
parent | 18a6dd4635be18ebe73eb25ffa34a33f0ec8203f (diff) | |
parent | 4e3e8d1ab265e9d0024cd33f2f3b8c2a8b31265d (diff) |
Merge #5094
5094: cleanup r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/completion/test_utils.rs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/crates/ra_ide/src/completion/test_utils.rs b/crates/ra_ide/src/completion/test_utils.rs index a1b7c1193..5c01654cc 100644 --- a/crates/ra_ide/src/completion/test_utils.rs +++ b/crates/ra_ide/src/completion/test_utils.rs | |||
@@ -1,21 +1,18 @@ | |||
1 | //! Runs completion for testing purposes. | 1 | //! Runs completion for testing purposes. |
2 | 2 | ||
3 | use hir::Semantics; | ||
4 | use ra_syntax::{AstNode, NodeOrToken, SyntaxElement}; | ||
5 | |||
3 | use crate::{ | 6 | use crate::{ |
4 | completion::{completion_item::CompletionKind, CompletionConfig}, | 7 | completion::{completion_item::CompletionKind, CompletionConfig}, |
5 | mock_analysis::analysis_and_position, | 8 | mock_analysis::analysis_and_position, |
6 | CompletionItem, | 9 | CompletionItem, |
7 | }; | 10 | }; |
8 | use hir::Semantics; | ||
9 | use ra_syntax::{AstNode, NodeOrToken, SyntaxElement}; | ||
10 | 11 | ||
11 | pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { | 12 | pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { |
12 | do_completion_with_options(code, kind, &CompletionConfig::default()) | 13 | do_completion_with_options(code, kind, &CompletionConfig::default()) |
13 | } | 14 | } |
14 | 15 | ||
15 | pub(crate) fn completion_list(code: &str, kind: CompletionKind) -> String { | ||
16 | completion_list_with_options(code, kind, &CompletionConfig::default()) | ||
17 | } | ||
18 | |||
19 | pub(crate) fn do_completion_with_options( | 16 | pub(crate) fn do_completion_with_options( |
20 | code: &str, | 17 | code: &str, |
21 | kind: CompletionKind, | 18 | kind: CompletionKind, |
@@ -29,13 +26,8 @@ pub(crate) fn do_completion_with_options( | |||
29 | kind_completions | 26 | kind_completions |
30 | } | 27 | } |
31 | 28 | ||
32 | fn get_all_completion_items(code: &str, options: &CompletionConfig) -> Vec<CompletionItem> { | 29 | pub(crate) fn completion_list(code: &str, kind: CompletionKind) -> String { |
33 | let (analysis, position) = if code.contains("//-") { | 30 | completion_list_with_options(code, kind, &CompletionConfig::default()) |
34 | analysis_and_position(code) | ||
35 | } else { | ||
36 | analysis_and_position(code) | ||
37 | }; | ||
38 | analysis.completions(options, position).unwrap().unwrap().into() | ||
39 | } | 31 | } |
40 | 32 | ||
41 | pub(crate) fn completion_list_with_options( | 33 | pub(crate) fn completion_list_with_options( |
@@ -65,3 +57,8 @@ pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) - | |||
65 | }) | 57 | }) |
66 | .unwrap(); | 58 | .unwrap(); |
67 | } | 59 | } |
60 | |||
61 | fn get_all_completion_items(code: &str, options: &CompletionConfig) -> Vec<CompletionItem> { | ||
62 | let (analysis, position) = analysis_and_position(code); | ||
63 | analysis.completions(options, position).unwrap().unwrap().into() | ||
64 | } | ||