diff options
Diffstat (limited to 'crates/ra_ide/src/completion/completion_context.rs')
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index deaacda6c..18c91a840 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -24,6 +24,7 @@ pub(crate) struct CompletionContext<'a> { | |||
24 | pub(super) use_item_syntax: Option<ast::UseItem>, | 24 | pub(super) use_item_syntax: Option<ast::UseItem>, |
25 | pub(super) record_lit_syntax: Option<ast::RecordLit>, | 25 | pub(super) record_lit_syntax: Option<ast::RecordLit>, |
26 | pub(super) record_lit_pat: Option<ast::RecordPat>, | 26 | pub(super) record_lit_pat: Option<ast::RecordPat>, |
27 | pub(super) impl_block: Option<ast::ImplBlock>, | ||
27 | pub(super) is_param: bool, | 28 | pub(super) is_param: bool, |
28 | /// If a name-binding or reference to a const in a pattern. | 29 | /// If a name-binding or reference to a const in a pattern. |
29 | /// Irrefutable patterns (like let) are excluded. | 30 | /// Irrefutable patterns (like let) are excluded. |
@@ -71,6 +72,7 @@ impl<'a> CompletionContext<'a> { | |||
71 | use_item_syntax: None, | 72 | use_item_syntax: None, |
72 | record_lit_syntax: None, | 73 | record_lit_syntax: None, |
73 | record_lit_pat: None, | 74 | record_lit_pat: None, |
75 | impl_block: None, | ||
74 | is_param: false, | 76 | is_param: false, |
75 | is_pat_binding: false, | 77 | is_pat_binding: false, |
76 | is_trivial_path: false, | 78 | is_trivial_path: false, |
@@ -147,6 +149,13 @@ impl<'a> CompletionContext<'a> { | |||
147 | self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset); | 149 | self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset); |
148 | } | 150 | } |
149 | 151 | ||
152 | self.impl_block = self | ||
153 | .token | ||
154 | .parent() | ||
155 | .ancestors() | ||
156 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) | ||
157 | .find_map(ast::ImplBlock::cast); | ||
158 | |||
150 | let top_node = name_ref | 159 | let top_node = name_ref |
151 | .syntax() | 160 | .syntax() |
152 | .ancestors() | 161 | .ancestors() |