diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-11 23:01:22 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-11 23:01:22 +0100 |
commit | a8e032820f14cad3630299a1ae16c62dcf59f358 (patch) | |
tree | 4438f81bdbf88d694b14c3c448c5bb21c8541091 /crates/ra_ide/src/completion/completion_context.rs | |
parent | f13da3f895d9d401ff467a6c1fa33a4adf09fe2c (diff) | |
parent | 5e5eb6a108b00c573455d8d088742592012707be (diff) |
Merge #3955
3955: Align grammar for record patterns and literals r=matklad a=matklad
The grammar now looks like this
[name_ref :] pat
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/completion/completion_context.rs')
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 14a4a14d7..8b3401595 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -30,7 +30,7 @@ pub(crate) struct CompletionContext<'a> { | |||
30 | pub(super) function_syntax: Option<ast::FnDef>, | 30 | pub(super) function_syntax: Option<ast::FnDef>, |
31 | pub(super) use_item_syntax: Option<ast::UseItem>, | 31 | pub(super) use_item_syntax: Option<ast::UseItem>, |
32 | pub(super) record_lit_syntax: Option<ast::RecordLit>, | 32 | pub(super) record_lit_syntax: Option<ast::RecordLit>, |
33 | pub(super) record_lit_pat: Option<ast::RecordPat>, | 33 | pub(super) record_pat_syntax: Option<ast::RecordPat>, |
34 | pub(super) impl_def: Option<ast::ImplDef>, | 34 | pub(super) impl_def: Option<ast::ImplDef>, |
35 | pub(super) is_param: bool, | 35 | pub(super) is_param: bool, |
36 | /// If a name-binding or reference to a const in a pattern. | 36 | /// If a name-binding or reference to a const in a pattern. |
@@ -93,7 +93,7 @@ impl<'a> CompletionContext<'a> { | |||
93 | function_syntax: None, | 93 | function_syntax: None, |
94 | use_item_syntax: None, | 94 | use_item_syntax: None, |
95 | record_lit_syntax: None, | 95 | record_lit_syntax: None, |
96 | record_lit_pat: None, | 96 | record_pat_syntax: None, |
97 | impl_def: None, | 97 | impl_def: None, |
98 | is_param: false, | 98 | is_param: false, |
99 | is_pat_binding_or_const: false, | 99 | is_pat_binding_or_const: false, |
@@ -182,6 +182,11 @@ impl<'a> CompletionContext<'a> { | |||
182 | self.is_param = true; | 182 | self.is_param = true; |
183 | return; | 183 | return; |
184 | } | 184 | } |
185 | // FIXME: remove this (V) duplication and make the check more precise | ||
186 | if name_ref.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() { | ||
187 | self.record_pat_syntax = | ||
188 | self.sema.find_node_at_offset_with_macros(&original_file, offset); | ||
189 | } | ||
185 | self.classify_name_ref(original_file, name_ref, offset); | 190 | self.classify_name_ref(original_file, name_ref, offset); |
186 | } | 191 | } |
187 | 192 | ||
@@ -211,8 +216,9 @@ impl<'a> CompletionContext<'a> { | |||
211 | self.is_param = true; | 216 | self.is_param = true; |
212 | return; | 217 | return; |
213 | } | 218 | } |
219 | // FIXME: remove this (^) duplication and make the check more precise | ||
214 | if name.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() { | 220 | if name.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() { |
215 | self.record_lit_pat = | 221 | self.record_pat_syntax = |
216 | self.sema.find_node_at_offset_with_macros(&original_file, offset); | 222 | self.sema.find_node_at_offset_with_macros(&original_file, offset); |
217 | } | 223 | } |
218 | } | 224 | } |