@@ -10,7 +10,7 @@ use ra_syntax::{
10
10
11
11
use crate :: {
12
12
ast_transform:: { self , AstTransform , QualifyPaths , SubstituteTypeParams } ,
13
- utils:: { get_missing_impl_items , resolve_target_trait} ,
13
+ utils:: { get_missing_assoc_items , resolve_target_trait} ,
14
14
Assist , AssistCtx , AssistId ,
15
15
} ;
16
16
@@ -112,25 +112,25 @@ fn add_missing_impl_members_inner(
112
112
113
113
let trait_ = resolve_target_trait ( & ctx. sema , & impl_node) ?;
114
114
115
- let def_name = |item : & ast:: ImplItem | -> Option < SmolStr > {
115
+ let def_name = |item : & ast:: AssocItem | -> Option < SmolStr > {
116
116
match item {
117
- ast:: ImplItem :: FnDef ( def) => def. name ( ) ,
118
- ast:: ImplItem :: TypeAliasDef ( def) => def. name ( ) ,
119
- ast:: ImplItem :: ConstDef ( def) => def. name ( ) ,
117
+ ast:: AssocItem :: FnDef ( def) => def. name ( ) ,
118
+ ast:: AssocItem :: TypeAliasDef ( def) => def. name ( ) ,
119
+ ast:: AssocItem :: ConstDef ( def) => def. name ( ) ,
120
120
}
121
121
. map ( |it| it. text ( ) . clone ( ) )
122
122
} ;
123
123
124
- let missing_items = get_missing_impl_items ( & ctx. sema , & impl_node)
124
+ let missing_items = get_missing_assoc_items ( & ctx. sema , & impl_node)
125
125
. iter ( )
126
126
. map ( |i| match i {
127
- hir:: AssocItem :: Function ( i) => ast:: ImplItem :: FnDef ( i. source ( ctx. db ) . value ) ,
128
- hir:: AssocItem :: TypeAlias ( i) => ast:: ImplItem :: TypeAliasDef ( i. source ( ctx. db ) . value ) ,
129
- hir:: AssocItem :: Const ( i) => ast:: ImplItem :: ConstDef ( i. source ( ctx. db ) . value ) ,
127
+ hir:: AssocItem :: Function ( i) => ast:: AssocItem :: FnDef ( i. source ( ctx. db ) . value ) ,
128
+ hir:: AssocItem :: TypeAlias ( i) => ast:: AssocItem :: TypeAliasDef ( i. source ( ctx. db ) . value ) ,
129
+ hir:: AssocItem :: Const ( i) => ast:: AssocItem :: ConstDef ( i. source ( ctx. db ) . value ) ,
130
130
} )
131
131
. filter ( |t| def_name ( & t) . is_some ( ) )
132
132
. filter ( |t| match t {
133
- ast:: ImplItem :: FnDef ( def) => match mode {
133
+ ast:: AssocItem :: FnDef ( def) => match mode {
134
134
AddMissingImplMembersMode :: DefaultMethodsOnly => def. body ( ) . is_some ( ) ,
135
135
AddMissingImplMembersMode :: NoDefaultMethods => def. body ( ) . is_none ( ) ,
136
136
} ,
@@ -145,7 +145,7 @@ fn add_missing_impl_members_inner(
145
145
let sema = ctx. sema ;
146
146
147
147
ctx. add_assist ( AssistId ( assist_id) , label, |edit| {
148
- let n_existing_items = impl_item_list. impl_items ( ) . count ( ) ;
148
+ let n_existing_items = impl_item_list. assoc_items ( ) . count ( ) ;
149
149
let source_scope = sema. scope_for_def ( trait_) ;
150
150
let target_scope = sema. scope ( impl_item_list. syntax ( ) ) ;
151
151
let ast_transform = QualifyPaths :: new ( & target_scope, & source_scope)
@@ -154,13 +154,13 @@ fn add_missing_impl_members_inner(
154
154
. into_iter ( )
155
155
. map ( |it| ast_transform:: apply ( & * ast_transform, it) )
156
156
. map ( |it| match it {
157
- ast:: ImplItem :: FnDef ( def) => ast:: ImplItem :: FnDef ( add_body ( def) ) ,
157
+ ast:: AssocItem :: FnDef ( def) => ast:: AssocItem :: FnDef ( add_body ( def) ) ,
158
158
_ => it,
159
159
} )
160
160
. map ( |it| edit:: remove_attrs_and_docs ( & it) ) ;
161
161
let new_impl_item_list = impl_item_list. append_items ( items) ;
162
162
let cursor_position = {
163
- let first_new_item = new_impl_item_list. impl_items ( ) . nth ( n_existing_items) . unwrap ( ) ;
163
+ let first_new_item = new_impl_item_list. assoc_items ( ) . nth ( n_existing_items) . unwrap ( ) ;
164
164
first_new_item. syntax ( ) . text_range ( ) . start ( )
165
165
} ;
166
166
0 commit comments