diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-29 20:40:29 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-29 20:40:29 +0000 |
commit | 5e78036e6c8752fda350818afdd411ab25f405ce (patch) | |
tree | e099bb9e9c04392dcb7fed54200a989f663f3659 /crates/ra_ide/src/completion/complete_trait_impl.rs | |
parent | e91320632a9dfee937c3c2ba3ffafd3f5ffb22dc (diff) | |
parent | a1e18695548b5cd6661f26a985b34c8b105e1896 (diff) |
Merge #3379
3379: Rename ast::ImplBlock -> ast::ImplDef r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/completion/complete_trait_impl.rs')
-rw-r--r-- | crates/ra_ide/src/completion/complete_trait_impl.rs | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index 9a27c164b..18a1d2995 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | //! This module adds the completion items related to implementing associated | 3 | //! This module adds the completion items related to implementing associated |
4 | //! items within a `impl Trait for Struct` block. The current context node | 4 | //! items within a `impl Trait for Struct` block. The current context node |
5 | //! must be within either a `FN_DEF`, `TYPE_ALIAS_DEF`, or `CONST_DEF` node | 5 | //! must be within either a `FN_DEF`, `TYPE_ALIAS_DEF`, or `CONST_DEF` node |
6 | //! and an direct child of an `IMPL_BLOCK`. | 6 | //! and an direct child of an `IMPL_DEF`. |
7 | //! | 7 | //! |
8 | //! # Examples | 8 | //! # Examples |
9 | //! | 9 | //! |
@@ -55,49 +55,43 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext | |||
55 | _ => false, | 55 | _ => false, |
56 | }); | 56 | }); |
57 | 57 | ||
58 | let impl_block = trigger | 58 | let impl_def = trigger |
59 | .as_ref() | 59 | .as_ref() |
60 | .and_then(|node| node.parent()) | 60 | .and_then(|node| node.parent()) |
61 | .and_then(|node| node.parent()) | 61 | .and_then(|node| node.parent()) |
62 | .and_then(ast::ImplBlock::cast); | 62 | .and_then(ast::ImplDef::cast); |
63 | 63 | ||
64 | if let (Some(trigger), Some(impl_block)) = (trigger, impl_block) { | 64 | if let (Some(trigger), Some(impl_def)) = (trigger, impl_def) { |
65 | match trigger.kind() { | 65 | match trigger.kind() { |
66 | SyntaxKind::FN_DEF => { | 66 | SyntaxKind::FN_DEF => { |
67 | for missing_fn in | 67 | for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map( |
68 | get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { | 68 | |item| match item { |
69 | match item { | 69 | hir::AssocItem::Function(fn_item) => Some(fn_item), |
70 | hir::AssocItem::Function(fn_item) => Some(fn_item), | 70 | _ => None, |
71 | _ => None, | 71 | }, |
72 | } | 72 | ) { |
73 | }) | ||
74 | { | ||
75 | add_function_impl(&trigger, acc, ctx, &missing_fn); | 73 | add_function_impl(&trigger, acc, ctx, &missing_fn); |
76 | } | 74 | } |
77 | } | 75 | } |
78 | 76 | ||
79 | SyntaxKind::TYPE_ALIAS_DEF => { | 77 | SyntaxKind::TYPE_ALIAS_DEF => { |
80 | for missing_fn in | 78 | for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map( |
81 | get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { | 79 | |item| match item { |
82 | match item { | 80 | hir::AssocItem::TypeAlias(type_item) => Some(type_item), |
83 | hir::AssocItem::TypeAlias(type_item) => Some(type_item), | 81 | _ => None, |
84 | _ => None, | 82 | }, |
85 | } | 83 | ) { |
86 | }) | ||
87 | { | ||
88 | add_type_alias_impl(&trigger, acc, ctx, &missing_fn); | 84 | add_type_alias_impl(&trigger, acc, ctx, &missing_fn); |
89 | } | 85 | } |
90 | } | 86 | } |
91 | 87 | ||
92 | SyntaxKind::CONST_DEF => { | 88 | SyntaxKind::CONST_DEF => { |
93 | for missing_fn in | 89 | for missing_fn in get_missing_impl_items(&ctx.sema, &impl_def).iter().filter_map( |
94 | get_missing_impl_items(&ctx.sema, &impl_block).iter().filter_map(|item| { | 90 | |item| match item { |
95 | match item { | 91 | hir::AssocItem::Const(const_item) => Some(const_item), |
96 | hir::AssocItem::Const(const_item) => Some(const_item), | 92 | _ => None, |
97 | _ => None, | 93 | }, |
98 | } | 94 | ) { |
99 | }) | ||
100 | { | ||
101 | add_const_impl(&trigger, acc, ctx, &missing_fn); | 95 | add_const_impl(&trigger, acc, ctx, &missing_fn); |
102 | } | 96 | } |
103 | } | 97 | } |