diff options
author | Alexander Andreev <[email protected]> | 2019-09-30 10:07:26 +0100 |
---|---|---|
committer | Alexander Andreev <[email protected]> | 2019-09-30 10:07:26 +0100 |
commit | 81efd696ccb369d6c4813bad1107bfd9e270385b (patch) | |
tree | f91b652c3ee8e4503c146bf4f76f129fb9ef1428 /crates/ra_assists/src/assists/move_bounds.rs | |
parent | fdbd6bb11a0c47bf9ba1428e6bd432cd2ce72045 (diff) | |
parent | 733f1d8b709788225bd06f8c0aee1819db92620b (diff) |
Merge branch 'master' into feature/issue/1856
# Conflicts:
# crates/ra_assists/src/ast_editor.rs
Diffstat (limited to 'crates/ra_assists/src/assists/move_bounds.rs')
-rw-r--r-- | crates/ra_assists/src/assists/move_bounds.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ra_assists/src/assists/move_bounds.rs b/crates/ra_assists/src/assists/move_bounds.rs index 32fab03c9..f791d22b0 100644 --- a/crates/ra_assists/src/assists/move_bounds.rs +++ b/crates/ra_assists/src/assists/move_bounds.rs | |||
@@ -2,12 +2,12 @@ | |||
2 | 2 | ||
3 | use hir::db::HirDatabase; | 3 | use hir::db::HirDatabase; |
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | ast::{self, make, AstNode, NameOwner, TypeBoundsOwner}, | 5 | ast::{self, edit, make, AstNode, NameOwner, TypeBoundsOwner}, |
6 | SyntaxElement, | 6 | SyntaxElement, |
7 | SyntaxKind::*, | 7 | SyntaxKind::*, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | use crate::{ast_editor::AstEditor, Assist, AssistCtx, AssistId}; | 10 | use crate::{Assist, AssistCtx, AssistId}; |
11 | 11 | ||
12 | pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 12 | pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
13 | let type_param_list = ctx.node_at_offset::<ast::TypeParamList>()?; | 13 | let type_param_list = ctx.node_at_offset::<ast::TypeParamList>()?; |
@@ -41,14 +41,12 @@ pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) | |||
41 | .type_params() | 41 | .type_params() |
42 | .filter(|it| it.type_bound_list().is_some()) | 42 | .filter(|it| it.type_bound_list().is_some()) |
43 | .map(|type_param| { | 43 | .map(|type_param| { |
44 | let without_bounds = | 44 | let without_bounds = type_param.remove_bounds(); |
45 | AstEditor::new(type_param.clone()).remove_bounds().ast().clone(); | ||
46 | (type_param, without_bounds) | 45 | (type_param, without_bounds) |
47 | }); | 46 | }); |
48 | 47 | ||
49 | let mut ast_editor = AstEditor::new(type_param_list.clone()); | 48 | let new_type_param_list = edit::replace_descendants(&type_param_list, new_params); |
50 | ast_editor.replace_descendants(new_params); | 49 | edit.replace_ast(type_param_list.clone(), new_type_param_list); |
51 | ast_editor.into_text_edit(edit.text_edit_builder()); | ||
52 | 50 | ||
53 | let where_clause = { | 51 | let where_clause = { |
54 | let predicates = type_param_list.type_params().filter_map(build_predicate); | 52 | let predicates = type_param_list.type_params().filter_map(build_predicate); |