aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/trait_impl.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-01-30 15:19:21 +0000
committerAleksey Kladov <[email protected]>2021-03-16 13:10:49 +0000
commitf5a81ec4683613bd62624811733345d627f2127b (patch)
tree54490888591ddc005d510695787308b78739ef05 /crates/ide_completion/src/completions/trait_impl.rs
parent62ec04bbd53ba50e21a7b8f23d46958d322640eb (diff)
Upgrade rowan
Notably, new rowan comes with support for mutable syntax trees.
Diffstat (limited to 'crates/ide_completion/src/completions/trait_impl.rs')
-rw-r--r--crates/ide_completion/src/completions/trait_impl.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ide_completion/src/completions/trait_impl.rs b/crates/ide_completion/src/completions/trait_impl.rs
index 5a7361f8e..a26fe7c6c 100644
--- a/crates/ide_completion/src/completions/trait_impl.rs
+++ b/crates/ide_completion/src/completions/trait_impl.rs
@@ -82,13 +82,14 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
82 82
83fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, SyntaxNode, Impl)> { 83fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, SyntaxNode, Impl)> {
84 let mut token = ctx.token.clone(); 84 let mut token = ctx.token.clone();
85 // For keywork without name like `impl .. { fn $0 }`, the current position is inside 85 // For keyword without name like `impl .. { fn $0 }`, the current position is inside
86 // the whitespace token, which is outside `FN` syntax node. 86 // the whitespace token, which is outside `FN` syntax node.
87 // We need to follow the previous token in this case. 87 // We need to follow the previous token in this case.
88 if token.kind() == SyntaxKind::WHITESPACE { 88 if token.kind() == SyntaxKind::WHITESPACE {
89 token = token.prev_token()?; 89 token = token.prev_token()?;
90 } 90 }
91 91
92 let parent_kind = token.parent().map_or(SyntaxKind::EOF, |it| it.kind());
92 let impl_item_offset = match token.kind() { 93 let impl_item_offset = match token.kind() {
93 // `impl .. { const $0 }` 94 // `impl .. { const $0 }`
94 // ERROR 0 95 // ERROR 0
@@ -102,14 +103,14 @@ fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, Synt
102 // FN/TYPE_ALIAS/CONST 1 103 // FN/TYPE_ALIAS/CONST 1
103 // NAME 0 104 // NAME 0
104 // IDENT <- * 105 // IDENT <- *
105 SyntaxKind::IDENT if token.parent().kind() == SyntaxKind::NAME => 1, 106 SyntaxKind::IDENT if parent_kind == SyntaxKind::NAME => 1,
106 // `impl .. { foo$0 }` 107 // `impl .. { foo$0 }`
107 // MACRO_CALL 3 108 // MACRO_CALL 3
108 // PATH 2 109 // PATH 2
109 // PATH_SEGMENT 1 110 // PATH_SEGMENT 1
110 // NAME_REF 0 111 // NAME_REF 0
111 // IDENT <- * 112 // IDENT <- *
112 SyntaxKind::IDENT if token.parent().kind() == SyntaxKind::NAME_REF => 3, 113 SyntaxKind::IDENT if parent_kind == SyntaxKind::NAME_REF => 3,
113 _ => return None, 114 _ => return None,
114 }; 115 };
115 116