aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/completion_context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/completion/completion_context.rs')
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 41aec5686..2f96861ca 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -12,8 +12,9 @@ use ra_syntax::{
12use ra_text_edit::Indel; 12use ra_text_edit::Indel;
13 13
14use super::patterns::{ 14use super::patterns::{
15 has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_ref_pat_parent, 15 has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent,
16 has_trait_as_prev_sibling, if_is_prev, inside_trait, is_in_loop_body, unsafe_is_prev, 16 has_ref_parent, has_trait_as_prev_sibling, has_trait_parent, if_is_prev, is_in_loop_body,
17 is_match_arm, unsafe_is_prev,
17}; 18};
18use crate::{call_info::ActiveParameter, completion::CompletionConfig, FilePosition}; 19use crate::{call_info::ActiveParameter, completion::CompletionConfig, FilePosition};
19use test_utils::mark; 20use test_utils::mark;
@@ -70,9 +71,11 @@ pub(crate) struct CompletionContext<'a> {
70 pub(super) bind_pat_parent: bool, 71 pub(super) bind_pat_parent: bool,
71 pub(super) ref_pat_parent: bool, 72 pub(super) ref_pat_parent: bool,
72 pub(super) in_loop_body: bool, 73 pub(super) in_loop_body: bool,
73 pub(super) inside_trait: bool, 74 pub(super) has_trait_parent: bool,
75 pub(super) has_impl_parent: bool,
74 pub(super) trait_as_prev_sibling: bool, 76 pub(super) trait_as_prev_sibling: bool,
75 pub(super) impl_as_prev_sibling: bool, 77 pub(super) impl_as_prev_sibling: bool,
78 pub(super) is_match_arm: bool,
76} 79}
77 80
78impl<'a> CompletionContext<'a> { 81impl<'a> CompletionContext<'a> {
@@ -136,10 +139,12 @@ impl<'a> CompletionContext<'a> {
136 ref_pat_parent: false, 139 ref_pat_parent: false,
137 bind_pat_parent: false, 140 bind_pat_parent: false,
138 block_expr_parent: false, 141 block_expr_parent: false,
139 inside_trait: false, 142 has_trait_parent: false,
143 has_impl_parent: false,
140 trait_as_prev_sibling: false, 144 trait_as_prev_sibling: false,
141 impl_as_prev_sibling: false, 145 impl_as_prev_sibling: false,
142 if_is_prev: false, 146 if_is_prev: false,
147 is_match_arm: false,
143 }; 148 };
144 149
145 let mut original_file = original_file.syntax().clone(); 150 let mut original_file = original_file.syntax().clone();
@@ -217,11 +222,13 @@ impl<'a> CompletionContext<'a> {
217 self.unsafe_is_prev = unsafe_is_prev(syntax_element.clone()); 222 self.unsafe_is_prev = unsafe_is_prev(syntax_element.clone());
218 self.if_is_prev = if_is_prev(syntax_element.clone()); 223 self.if_is_prev = if_is_prev(syntax_element.clone());
219 self.bind_pat_parent = has_bind_pat_parent(syntax_element.clone()); 224 self.bind_pat_parent = has_bind_pat_parent(syntax_element.clone());
220 self.ref_pat_parent = has_ref_pat_parent(syntax_element.clone()); 225 self.ref_pat_parent = has_ref_parent(syntax_element.clone());
221 self.in_loop_body = is_in_loop_body(syntax_element.clone()); 226 self.in_loop_body = is_in_loop_body(syntax_element.clone());
222 self.inside_trait = inside_trait(syntax_element.clone()); 227 self.has_trait_parent = has_trait_parent(syntax_element.clone());
228 self.has_impl_parent = has_impl_parent(syntax_element.clone());
223 self.impl_as_prev_sibling = has_impl_as_prev_sibling(syntax_element.clone()); 229 self.impl_as_prev_sibling = has_impl_as_prev_sibling(syntax_element.clone());
224 self.trait_as_prev_sibling = has_trait_as_prev_sibling(syntax_element.clone()); 230 self.trait_as_prev_sibling = has_trait_as_prev_sibling(syntax_element.clone());
231 self.is_match_arm = is_match_arm(syntax_element.clone());
225 } 232 }
226 233
227 fn fill( 234 fn fill(