diff options
author | Kevin DeLorey <[email protected]> | 2020-02-08 17:28:39 +0000 |
---|---|---|
committer | Kevin DeLorey <[email protected]> | 2020-02-08 17:28:39 +0000 |
commit | f801723dd2e4a518c1608909509f47f03d75fe1a (patch) | |
tree | 202cfd56356ebf4a776eee84a7ee22c739ededcf /crates/ra_ide/src/completion/completion_context.rs | |
parent | 5216b09ed67b4d9ff57e3ffb7fec010e73832309 (diff) |
Got the magic completion working.
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() |