diff options
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 46 | ||||
-rw-r--r-- | xtask/src/ast_src.rs | 2 | ||||
-rw-r--r-- | xtask/src/codegen/gen_syntax.rs | 4 |
3 files changed, 17 insertions, 35 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 214e12918..fae76a7a8 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -58,9 +58,7 @@ impl FnDef { | |||
58 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | 58 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } |
59 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | 59 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } |
60 | pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | 60 | pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } |
61 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 61 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
62 | support::token2(&self.syntax, T ! [ ; ]) | ||
63 | } | ||
64 | } | 62 | } |
65 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 63 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
66 | pub struct RetType { | 64 | pub struct RetType { |
@@ -78,7 +76,7 @@ impl AstNode for RetType { | |||
78 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 76 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
79 | } | 77 | } |
80 | impl RetType { | 78 | impl RetType { |
81 | pub fn thin_arrow_token(&self) -> Option<ThinArrow> { support::token(&self.syntax) } | 79 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![->]) } |
82 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 80 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
83 | } | 81 | } |
84 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 82 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -104,9 +102,7 @@ impl ast::DocCommentsOwner for StructDef {} | |||
104 | impl StructDef { | 102 | impl StructDef { |
105 | pub fn struct_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![struct]) } | 103 | pub fn struct_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![struct]) } |
106 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } | 104 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } |
107 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 105 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
108 | support::token2(&self.syntax, T ! [ ; ]) | ||
109 | } | ||
110 | } | 106 | } |
111 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 107 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
112 | pub struct UnionDef { | 108 | pub struct UnionDef { |
@@ -332,9 +328,7 @@ impl ast::DocCommentsOwner for Module {} | |||
332 | impl Module { | 328 | impl Module { |
333 | pub fn mod_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mod]) } | 329 | pub fn mod_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mod]) } |
334 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | 330 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } |
335 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 331 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
336 | support::token2(&self.syntax, T ! [ ; ]) | ||
337 | } | ||
338 | } | 332 | } |
339 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 333 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
340 | pub struct ItemList { | 334 | pub struct ItemList { |
@@ -385,9 +379,7 @@ impl ConstDef { | |||
385 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) } | 379 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) } |
386 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } | 380 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } |
387 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 381 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
388 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 382 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
389 | support::token2(&self.syntax, T ! [ ; ]) | ||
390 | } | ||
391 | } | 383 | } |
392 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 384 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
393 | pub struct StaticDef { | 385 | pub struct StaticDef { |
@@ -415,9 +407,7 @@ impl StaticDef { | |||
415 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) } | 407 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) } |
416 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } | 408 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } |
417 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 409 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
418 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 410 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
419 | support::token2(&self.syntax, T ! [ ; ]) | ||
420 | } | ||
421 | } | 411 | } |
422 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 412 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
423 | pub struct TypeAliasDef { | 413 | pub struct TypeAliasDef { |
@@ -447,9 +437,7 @@ impl TypeAliasDef { | |||
447 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![type]) } | 437 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![type]) } |
448 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } | 438 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } |
449 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 439 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
450 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 440 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
451 | support::token2(&self.syntax, T ! [ ; ]) | ||
452 | } | ||
453 | } | 441 | } |
454 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 442 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
455 | pub struct ImplDef { | 443 | pub struct ImplDef { |
@@ -594,9 +582,7 @@ impl AstNode for ArrayType { | |||
594 | impl ArrayType { | 582 | impl ArrayType { |
595 | pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) } | 583 | pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) } |
596 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 584 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
597 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 585 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
598 | support::token2(&self.syntax, T ! [ ; ]) | ||
599 | } | ||
600 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 586 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
601 | pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) } | 587 | pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) } |
602 | } | 588 | } |
@@ -779,9 +765,7 @@ impl ast::AttrsOwner for ArrayExpr {} | |||
779 | impl ArrayExpr { | 765 | impl ArrayExpr { |
780 | pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) } | 766 | pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) } |
781 | pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } | 767 | pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } |
782 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 768 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
783 | support::token2(&self.syntax, T ! [ ; ]) | ||
784 | } | ||
785 | pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) } | 769 | pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) } |
786 | } | 770 | } |
787 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 771 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1875,9 +1859,7 @@ impl MacroCall { | |||
1875 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | 1859 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } |
1876 | pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } | 1860 | pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } |
1877 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } | 1861 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } |
1878 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 1862 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
1879 | support::token2(&self.syntax, T ! [ ; ]) | ||
1880 | } | ||
1881 | } | 1863 | } |
1882 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1864 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1883 | pub struct Attr { | 1865 | pub struct Attr { |
@@ -2118,9 +2100,7 @@ impl AstNode for ExprStmt { | |||
2118 | impl ast::AttrsOwner for ExprStmt {} | 2100 | impl ast::AttrsOwner for ExprStmt {} |
2119 | impl ExprStmt { | 2101 | impl ExprStmt { |
2120 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 2102 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
2121 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 2103 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
2122 | support::token2(&self.syntax, T ! [ ; ]) | ||
2123 | } | ||
2124 | } | 2104 | } |
2125 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2105 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2126 | pub struct LetStmt { | 2106 | pub struct LetStmt { |
@@ -2144,9 +2124,7 @@ impl LetStmt { | |||
2144 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 2124 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
2145 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } | 2125 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } |
2146 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } | 2126 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } |
2147 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { | 2127 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } |
2148 | support::token2(&self.syntax, T ! [ ; ]) | ||
2149 | } | ||
2150 | } | 2128 | } |
2151 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2129 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2152 | pub struct Condition { | 2130 | pub struct Condition { |
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index 1a6ee935f..8c83450e6 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs | |||
@@ -322,7 +322,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
322 | T![;] | 322 | T![;] |
323 | } | 323 | } |
324 | 324 | ||
325 | struct RetType { ThinArrow, TypeRef } | 325 | struct RetType { T![->], TypeRef } |
326 | 326 | ||
327 | struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { | 327 | struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { |
328 | T![struct], | 328 | T![struct], |
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 26f541da1..b7698ee6e 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs | |||
@@ -345,6 +345,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> { | |||
345 | #(#displays)* | 345 | #(#displays)* |
346 | }; | 346 | }; |
347 | 347 | ||
348 | let ast = ast.to_string().replace("T ! [ ", "T![").replace(" ] )", "])"); | ||
348 | let pretty = crate::reformat(ast)?; | 349 | let pretty = crate::reformat(ast)?; |
349 | Ok(pretty) | 350 | Ok(pretty) |
350 | } | 351 | } |
@@ -527,6 +528,9 @@ impl Field<'_> { | |||
527 | Field::Token(name) => { | 528 | Field::Token(name) => { |
528 | let name = match *name { | 529 | let name = match *name { |
529 | ";" => "semicolon", | 530 | ";" => "semicolon", |
531 | "->" => "thin_arrow", | ||
532 | "'{'" => "l_curly", | ||
533 | "'}'" => "r_curly", | ||
530 | _ => name, | 534 | _ => name, |
531 | }; | 535 | }; |
532 | format_ident!("{}_token", name) | 536 | format_ident!("{}_token", name) |