aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assists/move_bounds.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/assists/move_bounds.rs')
-rw-r--r--crates/ra_assists/src/assists/move_bounds.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_assists/src/assists/move_bounds.rs b/crates/ra_assists/src/assists/move_bounds.rs
index fd4bdc55c..f791d22b0 100644
--- a/crates/ra_assists/src/assists/move_bounds.rs
+++ b/crates/ra_assists/src/assists/move_bounds.rs
@@ -1,11 +1,13 @@
1//! FIXME: write short doc here
2
1use hir::db::HirDatabase; 3use hir::db::HirDatabase;
2use ra_syntax::{ 4use ra_syntax::{
3 ast::{self, make, AstNode, NameOwner, TypeBoundsOwner}, 5 ast::{self, edit, make, AstNode, NameOwner, TypeBoundsOwner},
4 SyntaxElement, 6 SyntaxElement,
5 SyntaxKind::*, 7 SyntaxKind::*,
6}; 8};
7 9
8use crate::{ast_editor::AstEditor, Assist, AssistCtx, AssistId}; 10use crate::{Assist, AssistCtx, AssistId};
9 11
10pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 12pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
11 let type_param_list = ctx.node_at_offset::<ast::TypeParamList>()?; 13 let type_param_list = ctx.node_at_offset::<ast::TypeParamList>()?;
@@ -39,14 +41,12 @@ pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>)
39 .type_params() 41 .type_params()
40 .filter(|it| it.type_bound_list().is_some()) 42 .filter(|it| it.type_bound_list().is_some())
41 .map(|type_param| { 43 .map(|type_param| {
42 let without_bounds = 44 let without_bounds = type_param.remove_bounds();
43 AstEditor::new(type_param.clone()).remove_bounds().ast().clone();
44 (type_param, without_bounds) 45 (type_param, without_bounds)
45 }); 46 });
46 47
47 let mut ast_editor = AstEditor::new(type_param_list.clone()); 48 let new_type_param_list = edit::replace_descendants(&type_param_list, new_params);
48 ast_editor.replace_descendants(new_params); 49 edit.replace_ast(type_param_list.clone(), new_type_param_list);
49 ast_editor.into_text_edit(edit.text_edit_builder());
50 50
51 let where_clause = { 51 let where_clause = {
52 let predicates = type_param_list.type_params().filter_map(build_predicate); 52 let predicates = type_param_list.type_params().filter_map(build_predicate);