aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src/context.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-02-09 19:38:39 +0000
committerGitHub <[email protected]>2021-02-09 19:38:39 +0000
commit5d4ae1c8e3b76798fcb5eb656d886fe65a2c7277 (patch)
treed0387217488358ca8c9ba0776b641e41133c1761 /crates/completion/src/context.rs
parent4f9a5287bfea124b76571424ce3eb4a91aec337a (diff)
parente92180a1d8c964d386fc5ffb80bfb05abdb6c153 (diff)
Merge #7616
7616: Show `Self` pattern and Self-prefixed enum-variant completions r=Veykril a=Veykril ![jDfQXNE0qZ](https://user-images.githubusercontent.com/3757771/107413514-1ff99b00-6b11-11eb-88b3-126cd106b514.gif) ![JpogVIgloq](https://user-images.githubusercontent.com/3757771/107413519-212ac800-6b11-11eb-8282-51115468dccc.gif) Variant pattern completions are to be done still. Closes #6549, at least that should address all that's left from that issue from what I can see. Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/completion/src/context.rs')
-rw-r--r--crates/completion/src/context.rs16
1 files changed, 11 insertions, 5 deletions
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> {
276 }); 276 });
277 } 277 }
278 278
279 fn fill_impl_def(&mut self) {
280 self.impl_def = self
281 .sema
282 .ancestors_with_macros(self.token.parent())
283 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE)
284 .find_map(ast::Impl::cast);
285 }
286
279 fn fill( 287 fn fill(
280 &mut self, 288 &mut self,
281 original_file: &SyntaxNode, 289 original_file: &SyntaxNode,
@@ -345,6 +353,8 @@ impl<'a> CompletionContext<'a> {
345 self.is_irrefutable_pat_binding = true; 353 self.is_irrefutable_pat_binding = true;
346 } 354 }
347 } 355 }
356
357 self.fill_impl_def();
348 } 358 }
349 if is_node::<ast::Param>(name.syntax()) { 359 if is_node::<ast::Param>(name.syntax()) {
350 self.is_param = true; 360 self.is_param = true;
@@ -372,11 +382,7 @@ impl<'a> CompletionContext<'a> {
372 self.sema.find_node_at_offset_with_macros(&original_file, offset); 382 self.sema.find_node_at_offset_with_macros(&original_file, offset);
373 } 383 }
374 384
375 self.impl_def = self 385 self.fill_impl_def();
376 .sema
377 .ancestors_with_macros(self.token.parent())
378 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE)
379 .find_map(ast::Impl::cast);
380 386
381 let top_node = name_ref 387 let top_node = name_ref
382 .syntax() 388 .syntax()