diff options
author | Aleksey Kladov <[email protected]> | 2020-05-06 11:51:28 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-06 11:51:28 +0100 |
commit | 233f01c9ba555e5d06f336cb0ff64e7a83e4a23a (patch) | |
tree | 7922dca3f7c4133e2616257be537428337e479d6 /crates/ra_assists/src/handlers/add_missing_impl_members.rs | |
parent | ede8906844e206f252810d58533538cf1fb326d4 (diff) |
Move target to AssistLabel
Target is used for assists sorting, so we need it before we compute
the action.
Diffstat (limited to 'crates/ra_assists/src/handlers/add_missing_impl_members.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/add_missing_impl_members.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index f7a101503..7df786590 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs | |||
@@ -107,10 +107,10 @@ fn add_missing_impl_members_inner( | |||
107 | label: &'static str, | 107 | label: &'static str, |
108 | ) -> Option<Assist> { | 108 | ) -> Option<Assist> { |
109 | let _p = ra_prof::profile("add_missing_impl_members_inner"); | 109 | let _p = ra_prof::profile("add_missing_impl_members_inner"); |
110 | let impl_node = ctx.find_node_at_offset::<ast::ImplDef>()?; | 110 | let impl_def = ctx.find_node_at_offset::<ast::ImplDef>()?; |
111 | let impl_item_list = impl_node.item_list()?; | 111 | let impl_item_list = impl_def.item_list()?; |
112 | 112 | ||
113 | let trait_ = resolve_target_trait(&ctx.sema, &impl_node)?; | 113 | let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; |
114 | 114 | ||
115 | let def_name = |item: &ast::AssocItem| -> Option<SmolStr> { | 115 | let def_name = |item: &ast::AssocItem| -> Option<SmolStr> { |
116 | match item { | 116 | match item { |
@@ -121,7 +121,7 @@ fn add_missing_impl_members_inner( | |||
121 | .map(|it| it.text().clone()) | 121 | .map(|it| it.text().clone()) |
122 | }; | 122 | }; |
123 | 123 | ||
124 | let missing_items = get_missing_assoc_items(&ctx.sema, &impl_node) | 124 | let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) |
125 | .iter() | 125 | .iter() |
126 | .map(|i| match i { | 126 | .map(|i| match i { |
127 | hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db).value), | 127 | hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db).value), |
@@ -143,13 +143,13 @@ fn add_missing_impl_members_inner( | |||
143 | } | 143 | } |
144 | 144 | ||
145 | let sema = ctx.sema; | 145 | let sema = ctx.sema; |
146 | 146 | let target = impl_def.syntax().text_range(); | |
147 | ctx.add_assist(AssistId(assist_id), label, |edit| { | 147 | ctx.add_assist(AssistId(assist_id), label, target, |edit| { |
148 | let n_existing_items = impl_item_list.assoc_items().count(); | 148 | let n_existing_items = impl_item_list.assoc_items().count(); |
149 | let source_scope = sema.scope_for_def(trait_); | 149 | let source_scope = sema.scope_for_def(trait_); |
150 | let target_scope = sema.scope(impl_item_list.syntax()); | 150 | let target_scope = sema.scope(impl_item_list.syntax()); |
151 | let ast_transform = QualifyPaths::new(&target_scope, &source_scope) | 151 | let ast_transform = QualifyPaths::new(&target_scope, &source_scope) |
152 | .or(SubstituteTypeParams::for_trait_impl(&source_scope, trait_, impl_node)); | 152 | .or(SubstituteTypeParams::for_trait_impl(&source_scope, trait_, impl_def)); |
153 | let items = missing_items | 153 | let items = missing_items |
154 | .into_iter() | 154 | .into_iter() |
155 | .map(|it| ast_transform::apply(&*ast_transform, it)) | 155 | .map(|it| ast_transform::apply(&*ast_transform, it)) |