@@ -16,15 +16,10 @@ use ra_syntax::{
1616use ra_assists:: utils:: get_missing_impl_items;
1717
1818pub ( crate ) fn complete_trait_impl ( acc : & mut Completions , ctx : & CompletionContext ) {
19- let trigger = ctx. token
20- . ancestors ( )
21- . find ( |p| match p. kind ( ) {
22- SyntaxKind :: FN_DEF |
23- SyntaxKind :: TYPE_ALIAS_DEF |
24- SyntaxKind :: CONST_DEF |
25- SyntaxKind :: ITEM_LIST => true ,
26- _ => false
27- } ) ;
19+ let trigger = ctx. token . ancestors ( ) . find ( |p| match p. kind ( ) {
20+ SyntaxKind :: FN_DEF | SyntaxKind :: TYPE_ALIAS_DEF | SyntaxKind :: CONST_DEF => true ,
21+ _ => false ,
22+ } ) ;
2823
2924 let impl_block = trigger
3025 . as_ref ( )
@@ -37,40 +32,38 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
3732 SyntaxKind :: FN_DEF => {
3833 for missing_fn in get_missing_impl_items ( ctx. db , & ctx. analyzer , & impl_block)
3934 . iter ( )
40- . filter_map ( |item| {
41- match item {
42- hir:: AssocItem :: Function ( fn_item) => Some ( fn_item) ,
43- _ => None
44- }
45- } )
35+ . filter_map ( |item| match item {
36+ hir:: AssocItem :: Function ( fn_item) => Some ( fn_item) ,
37+ _ => None ,
38+ } )
4639 {
4740 add_function_impl ( acc, ctx, & missing_fn) ;
4841 }
49- } ,
42+ }
5043
5144 SyntaxKind :: TYPE_ALIAS_DEF => {
5245 for missing_fn in get_missing_impl_items ( ctx. db , & ctx. analyzer , & impl_block)
5346 . iter ( )
5447 . filter_map ( |item| match item {
5548 hir:: AssocItem :: TypeAlias ( type_item) => Some ( type_item) ,
56- _ => None
57- } )
49+ _ => None ,
50+ } )
5851 {
5952 add_type_alias_impl ( acc, ctx, & missing_fn) ;
6053 }
61- } ,
54+ }
6255
6356 SyntaxKind :: CONST_DEF => {
6457 for missing_fn in get_missing_impl_items ( ctx. db , & ctx. analyzer , & impl_block)
6558 . iter ( )
6659 . filter_map ( |item| match item {
6760 hir:: AssocItem :: Const ( const_item) => Some ( const_item) ,
68- _ => None
69- } )
61+ _ => None ,
62+ } )
7063 {
7164 add_const_impl ( acc, ctx, & missing_fn) ;
7265 }
73- } ,
66+ }
7467
7568 _ => { }
7669 }
@@ -309,16 +302,16 @@ mod tests {
309302 }
310303
311304 impl Test for () {
312- const<|>
305+ const S <|>
313306 }
314307 " ,
315308 ) ;
316309 assert_debug_snapshot ! ( completions, @r###"
317310 [
318311 CompletionItem {
319312 label: "const SOME_CONST: u16 = ",
320- source_range: [132; 132 ),
321- delete: [132; 132 ),
313+ source_range: [133; 134 ),
314+ delete: [133; 134 ),
322315 insert: "const SOME_CONST: u16 = ",
323316 kind: Const,
324317 },
@@ -335,16 +328,16 @@ mod tests {
335328 }
336329
337330 impl Test for () {
338- const<|>
331+ const S <|>
339332 }
340333 " ,
341334 ) ;
342335 assert_debug_snapshot ! ( completions, @r###"
343336 [
344337 CompletionItem {
345338 label: "const SOME_CONST: u16 = ",
346- source_range: [137; 137 ),
347- delete: [137; 137 ),
339+ source_range: [138; 139 ),
340+ delete: [138; 139 ),
348341 insert: "const SOME_CONST: u16 = ",
349342 kind: Const,
350343 },
0 commit comments