aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-27 11:11:00 +0100
committerGitHub <[email protected]>2020-06-27 11:11:00 +0100
commitb081018363a210ffa0b95a4d3350a0a3e9b0cd83 (patch)
tree93d3793a4de59a4a9c3cee39ace5ee45c0944ef5 /crates/ra_ide/src
parent18a6dd4635be18ebe73eb25ffa34a33f0ec8203f (diff)
parent4e3e8d1ab265e9d0024cd33f2f3b8c2a8b31265d (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.rs23
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
3use hir::Semantics;
4use ra_syntax::{AstNode, NodeOrToken, SyntaxElement};
5
3use crate::{ 6use 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};
8use hir::Semantics;
9use ra_syntax::{AstNode, NodeOrToken, SyntaxElement};
10 11
11pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { 12pub(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
15pub(crate) fn completion_list(code: &str, kind: CompletionKind) -> String {
16 completion_list_with_options(code, kind, &CompletionConfig::default())
17}
18
19pub(crate) fn do_completion_with_options( 16pub(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
32fn get_all_completion_items(code: &str, options: &CompletionConfig) -> Vec<CompletionItem> { 29pub(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
41pub(crate) fn completion_list_with_options( 33pub(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
61fn 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}