aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--docs/user/generated_features.adoc2
4 files changed, 7 insertions, 14 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,
diff --git a/docs/user/generated_features.adoc b/docs/user/generated_features.adoc
index 12812fa0b..56538ca90 100644
--- a/docs/user/generated_features.adoc
+++ b/docs/user/generated_features.adoc
@@ -118,7 +118,7 @@ Join selected lines into one, smartly fixing up whitespace, trailing commas, and
118 118
119 119
120=== Magic Completions 120=== Magic Completions
121**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/completion.rs#L38[completion.rs] 121**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/completion.rs#L39[completion.rs]
122 122
123In addition to usual reference completion, rust-analyzer provides some ✨magic✨ 123In addition to usual reference completion, rust-analyzer provides some ✨magic✨
124completions as well: 124completions as well: