@@ -56,26 +56,25 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
5656 if let Some ( ( kind, replacement_range, impl_def) ) = completion_match ( ctx) {
5757 if let Some ( hir_impl) = ctx. sema . to_def ( & impl_def) {
5858 get_missing_assoc_items ( & ctx. sema , & impl_def) . into_iter ( ) . for_each ( |item| {
59+ use self :: ImplCompletionKind :: * ;
5960 match ( item, kind) {
60- (
61- hir:: AssocItem :: Function ( fn_item) ,
62- ImplCompletionKind :: All | ImplCompletionKind :: Fn ,
63- ) => add_function_impl ( acc, ctx, replacement_range, fn_item, hir_impl) ,
64- (
65- hir:: AssocItem :: TypeAlias ( type_item) ,
66- ImplCompletionKind :: All | ImplCompletionKind :: TypeAlias ,
67- ) => add_type_alias_impl ( acc, ctx, replacement_range, type_item) ,
68- (
69- hir:: AssocItem :: Const ( const_item) ,
70- ImplCompletionKind :: All | ImplCompletionKind :: Const ,
71- ) => add_const_impl ( acc, ctx, replacement_range, const_item, hir_impl) ,
61+ ( hir:: AssocItem :: Function ( func) , All | Fn ) => {
62+ add_function_impl ( acc, ctx, replacement_range, func, hir_impl)
63+ }
64+ ( hir:: AssocItem :: TypeAlias ( type_alias) , All | TypeAlias ) => {
65+ add_type_alias_impl ( acc, ctx, replacement_range, type_alias)
66+ }
67+ ( hir:: AssocItem :: Const ( const_) , All | Const ) => {
68+ add_const_impl ( acc, ctx, replacement_range, const_, hir_impl)
69+ }
7270 _ => { }
7371 }
7472 } ) ;
7573 }
7674 }
7775}
7876
77+ // FIXME: This should be lifted out so that we can do proper smart item keyword completions
7978fn completion_match ( ctx : & CompletionContext ) -> Option < ( ImplCompletionKind , TextRange , ast:: Impl ) > {
8079 let token = ctx. token . clone ( ) ;
8180
@@ -152,15 +151,15 @@ fn add_function_impl(
152151 func : hir:: Function ,
153152 impl_def : hir:: Impl ,
154153) {
155- let fn_name = func. name ( ctx. db ) . to_smol_str ( ) ;
154+ let fn_name = func. name ( ctx. db ) ;
156155
157- let label = if func . assoc_fn_params ( ctx . db ) . is_empty ( ) {
158- format ! ( "fn {}()" , fn_name )
159- } else {
160- format ! ( "fn {}(..)" , fn_name )
161- } ;
156+ let label = format ! (
157+ "fn {}({} )" ,
158+ fn_name ,
159+ if func . assoc_fn_params ( ctx . db ) . is_empty ( ) { "" } else { ".." }
160+ ) ;
162161
163- let completion_kind = if func. self_param ( ctx. db ) . is_some ( ) {
162+ let completion_kind = if func. has_self_param ( ctx. db ) {
164163 CompletionItemKind :: Method
165164 } else {
166165 CompletionItemKind :: SymbolKind ( SymbolKind :: Function )
0 commit comments