diff options
author | Aleksey Kladov <[email protected]> | 2018-08-31 13:10:37 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-31 13:10:37 +0100 |
commit | 78d60a549d0711ffea10e2898bff46ebc739f637 (patch) | |
tree | 6333fd564c04dab2b73f71761f1d26d040b5ed0e /crates/libsyntax2/src/ast | |
parent | 05a9d42f542c8eb876d06791579d948b2f571e04 (diff) |
default method name to type name
Diffstat (limited to 'crates/libsyntax2/src/ast')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 78 | ||||
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs.tera | 7 |
2 files changed, 33 insertions, 52 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 0668dbfa7..58dcf574e 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs | |||
@@ -78,8 +78,7 @@ impl<'a> AstNode<'a> for Attr<'a> { | |||
78 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 78 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
79 | } | 79 | } |
80 | 80 | ||
81 | impl<'a> Attr<'a> { | 81 | impl<'a> Attr<'a> {pub fn value(self) -> Option<TokenTree<'a>> { |
82 | pub fn value(self) -> Option<TokenTree<'a>> { | ||
83 | super::child_opt(self) | 82 | super::child_opt(self) |
84 | } | 83 | } |
85 | } | 84 | } |
@@ -141,8 +140,7 @@ impl<'a> Block<'a> { | |||
141 | pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { | 140 | pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { |
142 | super::children(self) | 141 | super::children(self) |
143 | } | 142 | } |
144 | 143 | pub fn expr(self) -> Option<Expr<'a>> { | |
145 | pub fn expr(self) -> Option<Expr<'a>> { | ||
146 | super::child_opt(self) | 144 | super::child_opt(self) |
147 | } | 145 | } |
148 | } | 146 | } |
@@ -163,8 +161,7 @@ impl<'a> AstNode<'a> for BlockExpr<'a> { | |||
163 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 161 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
164 | } | 162 | } |
165 | 163 | ||
166 | impl<'a> BlockExpr<'a> { | 164 | impl<'a> BlockExpr<'a> {pub fn block(self) -> Option<Block<'a>> { |
167 | pub fn block(self) -> Option<Block<'a>> { | ||
168 | super::child_opt(self) | 165 | super::child_opt(self) |
169 | } | 166 | } |
170 | } | 167 | } |
@@ -203,12 +200,10 @@ impl<'a> AstNode<'a> for CallExpr<'a> { | |||
203 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 200 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
204 | } | 201 | } |
205 | 202 | ||
206 | impl<'a> CallExpr<'a> { | 203 | impl<'a> CallExpr<'a> {pub fn expr(self) -> Option<Expr<'a>> { |
207 | pub fn expr(self) -> Option<Expr<'a>> { | ||
208 | super::child_opt(self) | 204 | super::child_opt(self) |
209 | } | 205 | } |
210 | 206 | pub fn arg_list(self) -> Option<ArgList<'a>> { | |
211 | pub fn arg_list(self) -> Option<ArgList<'a>> { | ||
212 | super::child_opt(self) | 207 | super::child_opt(self) |
213 | } | 208 | } |
214 | } | 209 | } |
@@ -247,12 +242,10 @@ impl<'a> AstNode<'a> for Condition<'a> { | |||
247 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 242 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
248 | } | 243 | } |
249 | 244 | ||
250 | impl<'a> Condition<'a> { | 245 | impl<'a> Condition<'a> {pub fn pat(self) -> Option<Pat<'a>> { |
251 | pub fn pat(self) -> Option<Pat<'a>> { | ||
252 | super::child_opt(self) | 246 | super::child_opt(self) |
253 | } | 247 | } |
254 | 248 | pub fn expr(self) -> Option<Expr<'a>> { | |
255 | pub fn expr(self) -> Option<Expr<'a>> { | ||
256 | super::child_opt(self) | 249 | super::child_opt(self) |
257 | } | 250 | } |
258 | } | 251 | } |
@@ -466,8 +459,7 @@ impl<'a> AstNode<'a> for ExprStmt<'a> { | |||
466 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 459 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
467 | } | 460 | } |
468 | 461 | ||
469 | impl<'a> ExprStmt<'a> { | 462 | impl<'a> ExprStmt<'a> {pub fn expr(self) -> Option<Expr<'a>> { |
470 | pub fn expr(self) -> Option<Expr<'a>> { | ||
471 | super::child_opt(self) | 463 | super::child_opt(self) |
472 | } | 464 | } |
473 | } | 465 | } |
@@ -545,16 +537,13 @@ impl<'a> AstNode<'a> for FnDef<'a> { | |||
545 | impl<'a> ast::NameOwner<'a> for FnDef<'a> {} | 537 | impl<'a> ast::NameOwner<'a> for FnDef<'a> {} |
546 | impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} | 538 | impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} |
547 | impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} | 539 | impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} |
548 | impl<'a> FnDef<'a> { | 540 | impl<'a> FnDef<'a> {pub fn param_list(self) -> Option<ParamList<'a>> { |
549 | pub fn param_list(self) -> Option<ParamList<'a>> { | ||
550 | super::child_opt(self) | 541 | super::child_opt(self) |
551 | } | 542 | } |
552 | 543 | pub fn body(self) -> Option<Block<'a>> { | |
553 | pub fn body(self) -> Option<Block<'a>> { | ||
554 | super::child_opt(self) | 544 | super::child_opt(self) |
555 | } | 545 | } |
556 | 546 | pub fn ret_type(self) -> Option<RetType<'a>> { | |
557 | pub fn ret_type(self) -> Option<RetType<'a>> { | ||
558 | super::child_opt(self) | 547 | super::child_opt(self) |
559 | } | 548 | } |
560 | } | 549 | } |
@@ -594,12 +583,10 @@ impl<'a> AstNode<'a> for ForExpr<'a> { | |||
594 | } | 583 | } |
595 | 584 | ||
596 | impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} | 585 | impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} |
597 | impl<'a> ForExpr<'a> { | 586 | impl<'a> ForExpr<'a> {pub fn pat(self) -> Option<Pat<'a>> { |
598 | pub fn pat(self) -> Option<Pat<'a>> { | ||
599 | super::child_opt(self) | 587 | super::child_opt(self) |
600 | } | 588 | } |
601 | 589 | pub fn iterable(self) -> Option<Expr<'a>> { | |
602 | pub fn iterable(self) -> Option<Expr<'a>> { | ||
603 | super::child_opt(self) | 590 | super::child_opt(self) |
604 | } | 591 | } |
605 | } | 592 | } |
@@ -638,8 +625,7 @@ impl<'a> AstNode<'a> for IfExpr<'a> { | |||
638 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 625 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
639 | } | 626 | } |
640 | 627 | ||
641 | impl<'a> IfExpr<'a> { | 628 | impl<'a> IfExpr<'a> {pub fn condition(self) -> Option<Condition<'a>> { |
642 | pub fn condition(self) -> Option<Condition<'a>> { | ||
643 | super::child_opt(self) | 629 | super::child_opt(self) |
644 | } | 630 | } |
645 | } | 631 | } |
@@ -732,12 +718,10 @@ impl<'a> AstNode<'a> for LambdaExpr<'a> { | |||
732 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 718 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
733 | } | 719 | } |
734 | 720 | ||
735 | impl<'a> LambdaExpr<'a> { | 721 | impl<'a> LambdaExpr<'a> {pub fn param_list(self) -> Option<ParamList<'a>> { |
736 | pub fn param_list(self) -> Option<ParamList<'a>> { | ||
737 | super::child_opt(self) | 722 | super::child_opt(self) |
738 | } | 723 | } |
739 | 724 | pub fn body(self) -> Option<Expr<'a>> { | |
740 | pub fn body(self) -> Option<Expr<'a>> { | ||
741 | super::child_opt(self) | 725 | super::child_opt(self) |
742 | } | 726 | } |
743 | } | 727 | } |
@@ -758,12 +742,10 @@ impl<'a> AstNode<'a> for LetStmt<'a> { | |||
758 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 742 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
759 | } | 743 | } |
760 | 744 | ||
761 | impl<'a> LetStmt<'a> { | 745 | impl<'a> LetStmt<'a> {pub fn pat(self) -> Option<Pat<'a>> { |
762 | pub fn pat(self) -> Option<Pat<'a>> { | ||
763 | super::child_opt(self) | 746 | super::child_opt(self) |
764 | } | 747 | } |
765 | 748 | pub fn initializer(self) -> Option<Expr<'a>> { | |
766 | pub fn initializer(self) -> Option<Expr<'a>> { | ||
767 | super::child_opt(self) | 749 | super::child_opt(self) |
768 | } | 750 | } |
769 | } | 751 | } |
@@ -802,8 +784,7 @@ impl<'a> AstNode<'a> for LifetimeParam<'a> { | |||
802 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 784 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
803 | } | 785 | } |
804 | 786 | ||
805 | impl<'a> LifetimeParam<'a> { | 787 | impl<'a> LifetimeParam<'a> {pub fn lifetime(self) -> Option<Lifetime<'a>> { |
806 | pub fn lifetime(self) -> Option<Lifetime<'a>> { | ||
807 | super::child_opt(self) | 788 | super::child_opt(self) |
808 | } | 789 | } |
809 | } | 790 | } |
@@ -1162,8 +1143,7 @@ impl<'a> AstNode<'a> for Param<'a> { | |||
1162 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1143 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1163 | } | 1144 | } |
1164 | 1145 | ||
1165 | impl<'a> Param<'a> { | 1146 | impl<'a> Param<'a> {pub fn pat(self) -> Option<Pat<'a>> { |
1166 | pub fn pat(self) -> Option<Pat<'a>> { | ||
1167 | super::child_opt(self) | 1147 | super::child_opt(self) |
1168 | } | 1148 | } |
1169 | } | 1149 | } |
@@ -1291,8 +1271,7 @@ impl<'a> AstNode<'a> for Path<'a> { | |||
1291 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1271 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1292 | } | 1272 | } |
1293 | 1273 | ||
1294 | impl<'a> Path<'a> { | 1274 | impl<'a> Path<'a> {pub fn segment(self) -> Option<PathSegment<'a>> { |
1295 | pub fn segment(self) -> Option<PathSegment<'a>> { | ||
1296 | super::child_opt(self) | 1275 | super::child_opt(self) |
1297 | } | 1276 | } |
1298 | } | 1277 | } |
@@ -1349,8 +1328,7 @@ impl<'a> AstNode<'a> for PathSegment<'a> { | |||
1349 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1328 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1350 | } | 1329 | } |
1351 | 1330 | ||
1352 | impl<'a> PathSegment<'a> { | 1331 | impl<'a> PathSegment<'a> {pub fn name_ref(self) -> Option<NameRef<'a>> { |
1353 | pub fn name_ref(self) -> Option<NameRef<'a>> { | ||
1354 | super::child_opt(self) | 1332 | super::child_opt(self) |
1355 | } | 1333 | } |
1356 | } | 1334 | } |
@@ -2012,8 +1990,7 @@ impl<'a> AstNode<'a> for UseItem<'a> { | |||
2012 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1990 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2013 | } | 1991 | } |
2014 | 1992 | ||
2015 | impl<'a> UseItem<'a> { | 1993 | impl<'a> UseItem<'a> {pub fn use_tree(self) -> Option<UseTree<'a>> { |
2016 | pub fn use_tree(self) -> Option<UseTree<'a>> { | ||
2017 | super::child_opt(self) | 1994 | super::child_opt(self) |
2018 | } | 1995 | } |
2019 | } | 1996 | } |
@@ -2034,12 +2011,10 @@ impl<'a> AstNode<'a> for UseTree<'a> { | |||
2034 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2011 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2035 | } | 2012 | } |
2036 | 2013 | ||
2037 | impl<'a> UseTree<'a> { | 2014 | impl<'a> UseTree<'a> {pub fn path(self) -> Option<Path<'a>> { |
2038 | pub fn path(self) -> Option<Path<'a>> { | ||
2039 | super::child_opt(self) | 2015 | super::child_opt(self) |
2040 | } | 2016 | } |
2041 | 2017 | pub fn use_tree_list(self) -> Option<UseTreeList<'a>> { | |
2042 | pub fn use_tree_list(self) -> Option<UseTreeList<'a>> { | ||
2043 | super::child_opt(self) | 2018 | super::child_opt(self) |
2044 | } | 2019 | } |
2045 | } | 2020 | } |
@@ -2101,8 +2076,7 @@ impl<'a> AstNode<'a> for WhileExpr<'a> { | |||
2101 | } | 2076 | } |
2102 | 2077 | ||
2103 | impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} | 2078 | impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} |
2104 | impl<'a> WhileExpr<'a> { | 2079 | impl<'a> WhileExpr<'a> {pub fn condition(self) -> Option<Condition<'a>> { |
2105 | pub fn condition(self) -> Option<Condition<'a>> { | ||
2106 | super::child_opt(self) | 2080 | super::child_opt(self) |
2107 | } | 2081 | } |
2108 | } | 2082 | } |
diff --git a/crates/libsyntax2/src/ast/generated.rs.tera b/crates/libsyntax2/src/ast/generated.rs.tera index 69f9236b7..a72e9b732 100644 --- a/crates/libsyntax2/src/ast/generated.rs.tera +++ b/crates/libsyntax2/src/ast/generated.rs.tera | |||
@@ -65,8 +65,15 @@ impl<'a> {{ node }}<'a> { | |||
65 | 65 | ||
66 | {%- if methods.options -%} | 66 | {%- if methods.options -%} |
67 | {%- for m in methods.options -%} | 67 | {%- for m in methods.options -%} |
68 | |||
69 | {%- if m is string -%} | ||
70 | {%- set method_name = m | snake -%} | ||
71 | {%- set ChildName = m %} | ||
72 | {%- else -%} | ||
68 | {%- set method_name = m.0 -%} | 73 | {%- set method_name = m.0 -%} |
69 | {%- set ChildName = m.1 %} | 74 | {%- set ChildName = m.1 %} |
75 | {%- endif -%} | ||
76 | |||
70 | pub fn {{ method_name }}(self) -> Option<{{ ChildName }}<'a>> { | 77 | pub fn {{ method_name }}(self) -> Option<{{ ChildName }}<'a>> { |
71 | super::child_opt(self) | 78 | super::child_opt(self) |
72 | } | 79 | } |