diff options
Diffstat (limited to 'crates/ra_assists')
-rw-r--r-- | crates/ra_assists/src/ast_builder.rs | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/crates/ra_assists/src/ast_builder.rs b/crates/ra_assists/src/ast_builder.rs index e4ea1fca9..9b9158ae2 100644 --- a/crates/ra_assists/src/ast_builder.rs +++ b/crates/ra_assists/src/ast_builder.rs | |||
@@ -1,6 +1,5 @@ | |||
1 | use itertools::Itertools; | 1 | use itertools::Itertools; |
2 | 2 | ||
3 | use hir::Name; | ||
4 | use ra_syntax::{ast, AstNode, SourceFile}; | 3 | use ra_syntax::{ast, AstNode, SourceFile}; |
5 | 4 | ||
6 | pub struct AstBuilder<N: AstNode> { | 5 | pub struct AstBuilder<N: AstNode> { |
@@ -8,15 +7,11 @@ pub struct AstBuilder<N: AstNode> { | |||
8 | } | 7 | } |
9 | 8 | ||
10 | impl AstBuilder<ast::RecordField> { | 9 | impl AstBuilder<ast::RecordField> { |
11 | pub fn from_name(name: &Name) -> ast::RecordField { | ||
12 | ast_node_from_file_text(&format!("fn f() {{ S {{ {}: (), }} }}", name)) | ||
13 | } | ||
14 | |||
15 | fn from_text(text: &str) -> ast::RecordField { | 10 | fn from_text(text: &str) -> ast::RecordField { |
16 | ast_node_from_file_text(&format!("fn f() {{ S {{ {}, }} }}", text)) | 11 | ast_node_from_file_text(&format!("fn f() {{ S {{ {}, }} }}", text)) |
17 | } | 12 | } |
18 | 13 | ||
19 | pub fn from_pieces(name: &ast::NameRef, expr: Option<&ast::Expr>) -> ast::RecordField { | 14 | pub fn from_pieces(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField { |
20 | match expr { | 15 | match expr { |
21 | Some(expr) => Self::from_text(&format!("{}: {}", name.syntax(), expr.syntax())), | 16 | Some(expr) => Self::from_text(&format!("{}: {}", name.syntax(), expr.syntax())), |
22 | None => Self::from_text(&name.syntax().to_string()), | 17 | None => Self::from_text(&name.syntax().to_string()), |