diff options
author | Aleksey Kladov <[email protected]> | 2019-09-26 10:18:26 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-09-26 13:29:28 +0100 |
commit | 183a38fb50f284de1ca02c05ed945e240f3c0274 (patch) | |
tree | 6f318218b3a97c9a2dba3e8311de4fddbce23b27 /crates/ra_assists/src/assists/move_bounds.rs | |
parent | d6bbdfefa7ed4b2b567558e76d5adadda9d9b83f (diff) |
keep ast creation API simple
Diffstat (limited to 'crates/ra_assists/src/assists/move_bounds.rs')
-rw-r--r-- | crates/ra_assists/src/assists/move_bounds.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/move_bounds.rs b/crates/ra_assists/src/assists/move_bounds.rs index 671826013..fd4bdc55c 100644 --- a/crates/ra_assists/src/assists/move_bounds.rs +++ b/crates/ra_assists/src/assists/move_bounds.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{self, AstNode, NameOwner, TypeBoundsOwner}, | 3 | ast::{self, make, AstNode, NameOwner, TypeBoundsOwner}, |
4 | SyntaxElement, | 4 | SyntaxElement, |
5 | SyntaxKind::*, | 5 | SyntaxKind::*, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use crate::{ast_builder::Make, ast_editor::AstEditor, Assist, AssistCtx, AssistId}; | 8 | use crate::{ast_editor::AstEditor, Assist, AssistCtx, AssistId}; |
9 | 9 | ||
10 | pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 10 | pub(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>()?; | 11 | let type_param_list = ctx.node_at_offset::<ast::TypeParamList>()?; |
@@ -50,7 +50,7 @@ pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) | |||
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); |
53 | Make::<ast::WhereClause>::from_predicates(predicates) | 53 | make::where_clause(predicates) |
54 | }; | 54 | }; |
55 | 55 | ||
56 | let to_insert = match anchor.prev_sibling_or_token() { | 56 | let to_insert = match anchor.prev_sibling_or_token() { |
@@ -68,8 +68,8 @@ pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) | |||
68 | } | 68 | } |
69 | 69 | ||
70 | fn build_predicate(param: ast::TypeParam) -> Option<ast::WherePred> { | 70 | fn build_predicate(param: ast::TypeParam) -> Option<ast::WherePred> { |
71 | let path = Make::<ast::Path>::from_name(param.name()?); | 71 | let path = make::path_from_name_ref(make::name_ref(¶m.name()?.syntax().to_string())); |
72 | let predicate = Make::<ast::WherePred>::from(path, param.type_bound_list()?.bounds()); | 72 | let predicate = make::where_pred(path, param.type_bound_list()?.bounds()); |
73 | Some(predicate) | 73 | Some(predicate) |
74 | } | 74 | } |
75 | 75 | ||