From e92180a1d8c964d386fc5ffb80bfb05abdb6c153 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 9 Feb 2021 19:47:21 +0100 Subject: Show Self pattern completions for Adts if inside impls --- crates/completion/src/context.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'crates/completion/src/context.rs') diff --git a/crates/completion/src/context.rs b/crates/completion/src/context.rs index b1e8eba85..3db357855 100644 --- a/crates/completion/src/context.rs +++ b/crates/completion/src/context.rs @@ -276,6 +276,14 @@ impl<'a> CompletionContext<'a> { }); } + fn fill_impl_def(&mut self) { + self.impl_def = self + .sema + .ancestors_with_macros(self.token.parent()) + .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) + .find_map(ast::Impl::cast); + } + fn fill( &mut self, original_file: &SyntaxNode, @@ -345,6 +353,8 @@ impl<'a> CompletionContext<'a> { self.is_irrefutable_pat_binding = true; } } + + self.fill_impl_def(); } if is_node::(name.syntax()) { self.is_param = true; @@ -372,11 +382,7 @@ impl<'a> CompletionContext<'a> { self.sema.find_node_at_offset_with_macros(&original_file, offset); } - self.impl_def = self - .sema - .ancestors_with_macros(self.token.parent()) - .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) - .find_map(ast::Impl::cast); + self.fill_impl_def(); let top_node = name_ref .syntax() -- cgit v1.2.3