aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorMikhail Rakhmanov <[email protected]>2020-06-13 00:21:48 +0100
committerMikhail Rakhmanov <[email protected]>2020-06-13 00:21:48 +0100
commiteeb8b9e236796da8734ba81a49164864497f7226 (patch)
treedf5ba2ecd9b9a0cc7ed2d169ff29f183681cd230 /crates/ra_ide/src
parent6feb52c12accbf0ef54475cf66a03e035b922749 (diff)
Fix tests and remove unused methods
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/completion/complete_keyword.rs8
-rw-r--r--crates/ra_ide/src/completion/patterns.rs2
-rw-r--r--crates/ra_ide/src/completion/test_utils.rs9
3 files changed, 6 insertions, 13 deletions
diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs
index 79432113c..025097e49 100644
--- a/crates/ra_ide/src/completion/complete_keyword.rs
+++ b/crates/ra_ide/src/completion/complete_keyword.rs
@@ -159,6 +159,9 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
159 add_keyword(ctx, acc, "break", "break", ctx.in_loop_body && !ctx.can_be_stmt); 159 add_keyword(ctx, acc, "break", "break", ctx.in_loop_body && !ctx.can_be_stmt);
160 add_keyword(ctx, acc, "pub", "pub ", ctx.is_new_item && !ctx.has_trait_parent); 160 add_keyword(ctx, acc, "pub", "pub ", ctx.is_new_item && !ctx.has_trait_parent);
161 161
162 if !ctx.is_trivial_path {
163 return;
164 }
162 let fn_def = match &ctx.function_syntax { 165 let fn_def = match &ctx.function_syntax {
163 Some(it) => it, 166 Some(it) => it,
164 None => return, 167 None => return,
@@ -182,10 +185,7 @@ fn complete_return(
182 185
183#[cfg(test)] 186#[cfg(test)]
184mod tests { 187mod tests {
185 use crate::completion::{ 188 use crate::completion::{test_utils::get_completions, CompletionKind};
186 test_utils::get_completions,
187 CompletionKind,
188 };
189 use insta::assert_debug_snapshot; 189 use insta::assert_debug_snapshot;
190 190
191 fn get_keyword_completions(code: &str) -> Vec<String> { 191 fn get_keyword_completions(code: &str) -> Vec<String> {
diff --git a/crates/ra_ide/src/completion/patterns.rs b/crates/ra_ide/src/completion/patterns.rs
index bc37196d5..464032cb4 100644
--- a/crates/ra_ide/src/completion/patterns.rs
+++ b/crates/ra_ide/src/completion/patterns.rs
@@ -1,3 +1,5 @@
1//! Patterns telling us certain facts about current syntax element, they are used in completion context
2
1use ra_syntax::{ 3use ra_syntax::{
2 algo::non_trivia_sibling, 4 algo::non_trivia_sibling,
3 ast::{self, LoopBodyOwner}, 5 ast::{self, LoopBodyOwner},
diff --git a/crates/ra_ide/src/completion/test_utils.rs b/crates/ra_ide/src/completion/test_utils.rs
index c660de7b1..8b838a0a5 100644
--- a/crates/ra_ide/src/completion/test_utils.rs
+++ b/crates/ra_ide/src/completion/test_utils.rs
@@ -38,15 +38,6 @@ fn get_all_completion_items(code: &str, options: &CompletionConfig) -> Vec<Compl
38 analysis.completions(options, position).unwrap().unwrap().into() 38 analysis.completions(options, position).unwrap().unwrap().into()
39} 39}
40 40
41pub(crate) fn get_all_completions(code: &str, options: &CompletionConfig) -> Vec<String> {
42 let mut kind_completions = get_all_completion_items(code, options);
43 kind_completions.sort_by_key(|c| c.label().to_owned());
44 kind_completions
45 .into_iter()
46 .map(|it| format!("{} {}", it.kind().unwrap().tag(), it.label()))
47 .collect()
48}
49
50pub(crate) fn get_completions_with_options( 41pub(crate) fn get_completions_with_options(
51 code: &str, 42 code: &str,
52 kind: CompletionKind, 43 kind: CompletionKind,