diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/make.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 192c610f1..254a37fe3 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -17,7 +17,7 @@ pub fn name_ref(text: &str) -> ast::NameRef { | |||
17 | ast_from_text(&format!("fn f() {{ {}; }}", text)) | 17 | ast_from_text(&format!("fn f() {{ {}; }}", text)) |
18 | } | 18 | } |
19 | 19 | ||
20 | pub fn type_ref(text: &str) -> ast::TypeRef { | 20 | pub fn ty(text: &str) -> ast::Type { |
21 | ast_from_text(&format!("impl {} for D {{}};", text)) | 21 | ast_from_text(&format!("impl {} for D {{}};", text)) |
22 | } | 22 | } |
23 | 23 | ||
@@ -30,14 +30,14 @@ pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path { | |||
30 | pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { | 30 | pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { |
31 | path_from_text(&format!("{}::{}", qual, segment)) | 31 | path_from_text(&format!("{}::{}", qual, segment)) |
32 | } | 32 | } |
33 | fn path_from_text(text: &str) -> ast::Path { | 33 | pub fn path_from_text(text: &str) -> ast::Path { |
34 | ast_from_text(text) | 34 | ast_from_text(text) |
35 | } | 35 | } |
36 | 36 | ||
37 | pub fn use_tree( | 37 | pub fn use_tree( |
38 | path: ast::Path, | 38 | path: ast::Path, |
39 | use_tree_list: Option<ast::UseTreeList>, | 39 | use_tree_list: Option<ast::UseTreeList>, |
40 | alias: Option<ast::Alias>, | 40 | alias: Option<ast::Rename>, |
41 | add_star: bool, | 41 | add_star: bool, |
42 | ) -> ast::UseTree { | 42 | ) -> ast::UseTree { |
43 | let mut buf = "use ".to_string(); | 43 | let mut buf = "use ".to_string(); |
@@ -60,22 +60,22 @@ pub fn use_tree_list(use_trees: impl IntoIterator<Item = ast::UseTree>) -> ast:: | |||
60 | ast_from_text(&format!("use {{{}}};", use_trees)) | 60 | ast_from_text(&format!("use {{{}}};", use_trees)) |
61 | } | 61 | } |
62 | 62 | ||
63 | pub fn use_item(use_tree: ast::UseTree) -> ast::UseItem { | 63 | pub fn use_(use_tree: ast::UseTree) -> ast::Use { |
64 | ast_from_text(&format!("use {};", use_tree)) | 64 | ast_from_text(&format!("use {};", use_tree)) |
65 | } | 65 | } |
66 | 66 | ||
67 | pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField { | 67 | pub fn record_expr_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordExprField { |
68 | return match expr { | 68 | return match expr { |
69 | Some(expr) => from_text(&format!("{}: {}", name, expr)), | 69 | Some(expr) => from_text(&format!("{}: {}", name, expr)), |
70 | None => from_text(&name.to_string()), | 70 | None => from_text(&name.to_string()), |
71 | }; | 71 | }; |
72 | 72 | ||
73 | fn from_text(text: &str) -> ast::RecordField { | 73 | fn from_text(text: &str) -> ast::RecordExprField { |
74 | ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) | 74 | ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordFieldDef { | 78 | pub fn record_field(name: ast::NameRef, ty: ast::Type) -> ast::RecordField { |
79 | ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) | 79 | ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) |
80 | } | 80 | } |
81 | 81 | ||
@@ -148,18 +148,18 @@ pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition { | |||
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | pub fn bind_pat(name: ast::Name) -> ast::BindPat { | 151 | pub fn ident_pat(name: ast::Name) -> ast::IdentPat { |
152 | return from_text(name.text()); | 152 | return from_text(name.text()); |
153 | 153 | ||
154 | fn from_text(text: &str) -> ast::BindPat { | 154 | fn from_text(text: &str) -> ast::IdentPat { |
155 | ast_from_text(&format!("fn f({}: ())", text)) | 155 | ast_from_text(&format!("fn f({}: ())", text)) |
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | pub fn placeholder_pat() -> ast::PlaceholderPat { | 159 | pub fn wildcard_pat() -> ast::WildcardPat { |
160 | return from_text("_"); | 160 | return from_text("_"); |
161 | 161 | ||
162 | fn from_text(text: &str) -> ast::PlaceholderPat { | 162 | fn from_text(text: &str) -> ast::WildcardPat { |
163 | ast_from_text(&format!("fn f({}: ())", text)) | 163 | ast_from_text(&format!("fn f({}: ())", text)) |
164 | } | 164 | } |
165 | } | 165 | } |
@@ -288,13 +288,13 @@ pub fn visibility_pub_crate() -> ast::Visibility { | |||
288 | ast_from_text("pub(crate) struct S") | 288 | ast_from_text("pub(crate) struct S") |
289 | } | 289 | } |
290 | 290 | ||
291 | pub fn fn_def( | 291 | pub fn fn_( |
292 | visibility: Option<ast::Visibility>, | 292 | visibility: Option<ast::Visibility>, |
293 | fn_name: ast::Name, | 293 | fn_name: ast::Name, |
294 | type_params: Option<ast::TypeParamList>, | 294 | type_params: Option<ast::GenericParamList>, |
295 | params: ast::ParamList, | 295 | params: ast::ParamList, |
296 | body: ast::BlockExpr, | 296 | body: ast::BlockExpr, |
297 | ) -> ast::FnDef { | 297 | ) -> ast::Fn { |
298 | let type_params = | 298 | let type_params = |
299 | if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; | 299 | if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; |
300 | let visibility = match visibility { | 300 | let visibility = match visibility { |