aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/completion/complete_trait_impl.rs31
1 files changed, 18 insertions, 13 deletions
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs
index 8cb0c72bb..a4e1045fc 100644
--- a/crates/ra_ide/src/completion/complete_trait_impl.rs
+++ b/crates/ra_ide/src/completion/complete_trait_impl.rs
@@ -48,23 +48,28 @@ use crate::{
48 48
49pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext) { 49pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext) {
50 let mut tokens = ctx.token.ancestors(); 50 let mut tokens = ctx.token.ancestors();
51 let trigger = tokens.find(|p| match p.kind() { 51 let completion_match = tokens
52 SyntaxKind::FN_DEF
53 | SyntaxKind::TYPE_ALIAS_DEF
54 | SyntaxKind::CONST_DEF
55 | SyntaxKind::NAME_REF
56 | SyntaxKind::BLOCK_EXPR => true,
57 _ => false,
58 });
59
60 let impl_def = tokens
61 .find(|p| match p.kind() { 52 .find(|p| match p.kind() {
62 SyntaxKind::IMPL_DEF => true, 53 SyntaxKind::FN_DEF
54 | SyntaxKind::TYPE_ALIAS_DEF
55 | SyntaxKind::CONST_DEF
56 | SyntaxKind::NAME_REF
57 | SyntaxKind::BLOCK_EXPR => true,
63 _ => false, 58 _ => false,
64 }) 59 })
65 .and_then(|n| ast::ImplDef::cast(n)); 60 .and_then(|trigger| {
61 for p in tokens {
62 match p.kind() {
63 // No nested completions
64 SyntaxKind::FN_DEF | SyntaxKind::BLOCK => return None,
65 SyntaxKind::IMPL_DEF => return ast::ImplDef::cast(p).map(|p| (trigger, p)),
66 _ => {}
67 }
68 }
69 None
70 });
66 71
67 if let (Some(trigger), Some(impl_def)) = (trigger, impl_def) { 72 if let Some((trigger, impl_def)) = completion_match {
68 match trigger.kind() { 73 match trigger.kind() {
69 SyntaxKind::NAME_REF => { 74 SyntaxKind::NAME_REF => {
70 get_missing_impl_items(&ctx.sema, &impl_def).iter().for_each(|item| match item { 75 get_missing_impl_items(&ctx.sema, &impl_def).iter().for_each(|item| match item {