3434use hir:: { self , HasAttrs , HasSource } ;
3535use ide_db:: { traits:: get_missing_assoc_items, SymbolKind } ;
3636use syntax:: {
37- ast:: { self , edit, Impl } ,
37+ ast:: { self , edit} ,
3838 display:: function_declaration,
39- AstNode , SyntaxElement , SyntaxKind , SyntaxNode , TextRange , T ,
39+ AstNode , SyntaxElement , SyntaxKind , SyntaxNode , SyntaxToken , TextRange , T ,
4040} ;
4141use text_edit:: TextEdit ;
4242
43- use crate :: {
44- CompletionContext ,
45- CompletionItem ,
46- CompletionItemKind ,
47- CompletionKind ,
48- Completions ,
49- // display::function_declaration,
50- } ;
43+ use crate :: { CompletionContext , CompletionItem , CompletionItemKind , CompletionKind , Completions } ;
5144
5245#[ derive( Debug , PartialEq , Eq ) ]
5346enum ImplCompletionKind {
@@ -58,7 +51,7 @@ enum ImplCompletionKind {
5851}
5952
6053pub ( crate ) fn complete_trait_impl ( acc : & mut Completions , ctx : & CompletionContext ) {
61- if let Some ( ( kind, trigger, impl_def) ) = completion_match ( ctx) {
54+ if let Some ( ( kind, trigger, impl_def) ) = completion_match ( ctx. token . clone ( ) ) {
6255 get_missing_assoc_items ( & ctx. sema , & impl_def) . into_iter ( ) . for_each ( |item| match item {
6356 hir:: AssocItem :: Function ( fn_item)
6457 if kind == ImplCompletionKind :: All || kind == ImplCompletionKind :: Fn =>
@@ -80,8 +73,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
8073 }
8174}
8275
83- fn completion_match ( ctx : & CompletionContext ) -> Option < ( ImplCompletionKind , SyntaxNode , Impl ) > {
84- let mut token = ctx. token . clone ( ) ;
76+ fn completion_match ( mut token : SyntaxToken ) -> Option < ( ImplCompletionKind , SyntaxNode , ast:: Impl ) > {
8577 // For keyword without name like `impl .. { fn $0 }`, the current position is inside
8678 // the whitespace token, which is outside `FN` syntax node.
8779 // We need to follow the previous token in this case.
0 commit comments