@@ -5,21 +5,23 @@ use itertools::Itertools;
55use syntax:: SmolStr ;
66
77use crate :: {
8- context:: { CompletionContext , PathCompletionCtx , PathKind , PathQualifierCtx , Qualified } ,
8+ context:: { CompletionContext , PathCompletionCtx , PathKind , Qualified } ,
99 item:: CompletionItem ,
1010 Completions ,
1111} ;
1212
1313pub ( crate ) fn complete_derive ( acc : & mut Completions , ctx : & CompletionContext ) {
14- let qualified = match ctx. path_context ( ) {
15- Some ( & PathCompletionCtx { kind : PathKind :: Derive , ref qualified, .. } ) => qualified,
14+ let ( qualified, existing_derives) = match ctx. path_context ( ) {
15+ Some ( PathCompletionCtx {
16+ kind : PathKind :: Derive { existing_derives } , qualified, ..
17+ } ) => ( qualified, existing_derives) ,
1618 _ => return ,
1719 } ;
1820
1921 let core = ctx. famous_defs ( ) . core ( ) ;
2022
2123 match qualified {
22- Qualified :: With ( PathQualifierCtx { resolution, is_super_chain, .. } ) => {
24+ Qualified :: With { resolution, is_super_chain, .. } => {
2325 if * is_super_chain {
2426 acc. add_keyword ( ctx, "super::" ) ;
2527 }
@@ -32,7 +34,7 @@ pub(crate) fn complete_derive(acc: &mut Completions, ctx: &CompletionContext) {
3234 for ( name, def) in module. scope ( ctx. db , Some ( ctx. module ) ) {
3335 let add_def = match def {
3436 ScopeDef :: ModuleDef ( hir:: ModuleDef :: Macro ( mac) ) => {
35- !ctx . existing_derives . contains ( & mac) && mac. is_derive ( ctx. db )
37+ !existing_derives. contains ( & mac) && mac. is_derive ( ctx. db )
3638 }
3739 ScopeDef :: ModuleDef ( hir:: ModuleDef :: Module ( _) ) => true ,
3840 _ => false ,
@@ -48,7 +50,7 @@ pub(crate) fn complete_derive(acc: &mut Completions, ctx: &CompletionContext) {
4850 ctx. process_all_names ( & mut |name, def| {
4951 let mac = match def {
5052 ScopeDef :: ModuleDef ( hir:: ModuleDef :: Macro ( mac) )
51- if !ctx . existing_derives . contains ( & mac) && mac. is_derive ( ctx. db ) =>
53+ if !existing_derives. contains ( & mac) && mac. is_derive ( ctx. db ) =>
5254 {
5355 mac
5456 }
@@ -74,7 +76,7 @@ pub(crate) fn complete_derive(acc: &mut Completions, ctx: &CompletionContext) {
7476 let mut components = vec ! [ derive_completion. label] ;
7577 components. extend ( derive_completion. dependencies . iter ( ) . filter (
7678 |& & dependency| {
77- !ctx . existing_derives
79+ !existing_derives
7880 . iter ( )
7981 . map ( |it| it. name ( ctx. db ) )
8082 . any ( |it| it. to_smol_str ( ) == dependency)
@@ -99,6 +101,7 @@ pub(crate) fn complete_derive(acc: &mut Completions, ctx: &CompletionContext) {
99101 } ) ;
100102 acc. add_nameref_keywords_with_colon ( ctx) ;
101103 }
104+ Qualified :: Infer => { }
102105 }
103106}
104107
0 commit comments