aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/generated
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-04-10 10:49:13 +0100
committerAleksey Kladov <[email protected]>2020-04-10 15:10:28 +0100
commit8d71a6bf0ca51ae099a5b470afdb957bca321441 (patch)
tree453aefb2a8fa3e554871f83b19b93017bf88b2ee /crates/ra_syntax/src/ast/generated
parent779f06ed77e868b9409a1724f736a045415d4922 (diff)
Scale token generation back
Diffstat (limited to 'crates/ra_syntax/src/ast/generated')
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs124
-rw-r--r--crates/ra_syntax/src/ast/generated/tokens.rs239
2 files changed, 65 insertions, 298 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 106a91c12..d67d733b1 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -1,6 +1,5 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen` 1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2 2
3use super::tokens::*;
4use crate::{ 3use crate::{
5 ast::{self, support, AstChildren, AstNode}, 4 ast::{self, support, AstChildren, AstNode},
6 SyntaxKind::{self, *}, 5 SyntaxKind::{self, *},
@@ -463,7 +462,7 @@ impl ImplDef {
463 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) } 462 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) }
464 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![unsafe]) } 463 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![unsafe]) }
465 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![impl]) } 464 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![impl]) }
466 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } 465 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![!]) }
467 pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![for]) } 466 pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![for]) }
468 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 467 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
469} 468}
@@ -523,7 +522,7 @@ impl AstNode for NeverType {
523 fn syntax(&self) -> &SyntaxNode { &self.syntax } 522 fn syntax(&self) -> &SyntaxNode { &self.syntax }
524} 523}
525impl NeverType { 524impl NeverType {
526 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } 525 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![!]) }
527} 526}
528#[derive(Debug, Clone, PartialEq, Eq, Hash)] 527#[derive(Debug, Clone, PartialEq, Eq, Hash)]
529pub struct PathType { 528pub struct PathType {
@@ -559,7 +558,7 @@ impl AstNode for PointerType {
559 fn syntax(&self) -> &SyntaxNode { &self.syntax } 558 fn syntax(&self) -> &SyntaxNode { &self.syntax }
560} 559}
561impl PointerType { 560impl PointerType {
562 pub fn star_token(&self) -> Option<Star> { support::token(&self.syntax) } 561 pub fn star_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![*]) }
563 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) } 562 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) }
564 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) } 563 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) }
565 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 564 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
@@ -622,8 +621,10 @@ impl AstNode for ReferenceType {
622 fn syntax(&self) -> &SyntaxNode { &self.syntax } 621 fn syntax(&self) -> &SyntaxNode { &self.syntax }
623} 622}
624impl ReferenceType { 623impl ReferenceType {
625 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } 624 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![&]) }
626 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 625 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
626 support::token2(&self.syntax, T![lifetime])
627 }
627 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) } 628 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) }
628 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 629 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
629} 630}
@@ -643,7 +644,7 @@ impl AstNode for PlaceholderType {
643 fn syntax(&self) -> &SyntaxNode { &self.syntax } 644 fn syntax(&self) -> &SyntaxNode { &self.syntax }
644} 645}
645impl PlaceholderType { 646impl PlaceholderType {
646 pub fn underscore_token(&self) -> Option<Underscore> { support::token(&self.syntax) } 647 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![_]) }
647} 648}
648#[derive(Debug, Clone, PartialEq, Eq, Hash)] 649#[derive(Debug, Clone, PartialEq, Eq, Hash)]
649pub struct FnPointerType { 650pub struct FnPointerType {
@@ -955,7 +956,9 @@ impl ContinueExpr {
955 pub fn continue_token(&self) -> Option<SyntaxToken> { 956 pub fn continue_token(&self) -> Option<SyntaxToken> {
956 support::token2(&self.syntax, T![continue]) 957 support::token2(&self.syntax, T![continue])
957 } 958 }
958 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 959 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
960 support::token2(&self.syntax, T![lifetime])
961 }
959} 962}
960#[derive(Debug, Clone, PartialEq, Eq, Hash)] 963#[derive(Debug, Clone, PartialEq, Eq, Hash)]
961pub struct BreakExpr { 964pub struct BreakExpr {
@@ -975,7 +978,9 @@ impl AstNode for BreakExpr {
975impl ast::AttrsOwner for BreakExpr {} 978impl ast::AttrsOwner for BreakExpr {}
976impl BreakExpr { 979impl BreakExpr {
977 pub fn break_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![break]) } 980 pub fn break_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![break]) }
978 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 981 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
982 support::token2(&self.syntax, T![lifetime])
983 }
979 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 984 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
980} 985}
981#[derive(Debug, Clone, PartialEq, Eq, Hash)] 986#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -994,7 +999,9 @@ impl AstNode for Label {
994 fn syntax(&self) -> &SyntaxNode { &self.syntax } 999 fn syntax(&self) -> &SyntaxNode { &self.syntax }
995} 1000}
996impl Label { 1001impl Label {
997 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 1002 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1003 support::token2(&self.syntax, T![lifetime])
1004 }
998} 1005}
999#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1006#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1000pub struct BlockExpr { 1007pub struct BlockExpr {
@@ -1074,7 +1081,7 @@ impl ast::AttrsOwner for MethodCallExpr {}
1074impl ast::ArgListOwner for MethodCallExpr {} 1081impl ast::ArgListOwner for MethodCallExpr {}
1075impl MethodCallExpr { 1082impl MethodCallExpr {
1076 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1083 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1077 pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) } 1084 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![.]) }
1078 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 1085 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1079 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } 1086 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
1080} 1087}
@@ -1116,7 +1123,7 @@ impl AstNode for FieldExpr {
1116impl ast::AttrsOwner for FieldExpr {} 1123impl ast::AttrsOwner for FieldExpr {}
1117impl FieldExpr { 1124impl FieldExpr {
1118 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1125 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1119 pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) } 1126 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![.]) }
1120 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 1127 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1121} 1128}
1122#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1129#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1137,7 +1144,7 @@ impl AstNode for AwaitExpr {
1137impl ast::AttrsOwner for AwaitExpr {} 1144impl ast::AttrsOwner for AwaitExpr {}
1138impl AwaitExpr { 1145impl AwaitExpr {
1139 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1146 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1140 pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) } 1147 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![.]) }
1141 pub fn await_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![await]) } 1148 pub fn await_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![await]) }
1142} 1149}
1143#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1150#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1198,7 +1205,7 @@ impl AstNode for RefExpr {
1198} 1205}
1199impl ast::AttrsOwner for RefExpr {} 1206impl ast::AttrsOwner for RefExpr {}
1200impl RefExpr { 1207impl RefExpr {
1201 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } 1208 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![&]) }
1202 pub fn raw_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![raw]) } 1209 pub fn raw_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![raw]) }
1203 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) } 1210 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) }
1204 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1211 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
@@ -1220,7 +1227,6 @@ impl AstNode for PrefixExpr {
1220} 1227}
1221impl ast::AttrsOwner for PrefixExpr {} 1228impl ast::AttrsOwner for PrefixExpr {}
1222impl PrefixExpr { 1229impl PrefixExpr {
1223 pub fn prefix_op_token(&self) -> Option<PrefixOp> { support::token(&self.syntax) }
1224 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1230 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1225} 1231}
1226#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1232#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1259,9 +1265,7 @@ impl AstNode for RangeExpr {
1259 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1265 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1260} 1266}
1261impl ast::AttrsOwner for RangeExpr {} 1267impl ast::AttrsOwner for RangeExpr {}
1262impl RangeExpr { 1268impl RangeExpr {}
1263 pub fn range_op_token(&self) -> Option<RangeOp> { support::token(&self.syntax) }
1264}
1265#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1269#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1266pub struct BinExpr { 1270pub struct BinExpr {
1267 pub(crate) syntax: SyntaxNode, 1271 pub(crate) syntax: SyntaxNode,
@@ -1294,9 +1298,7 @@ impl AstNode for Literal {
1294 } 1298 }
1295 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1299 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1296} 1300}
1297impl Literal { 1301impl Literal {}
1298 pub fn literal_token_token(&self) -> Option<LiteralToken> { support::token(&self.syntax) }
1299}
1300#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1302#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1301pub struct MatchExpr { 1303pub struct MatchExpr {
1302 pub(crate) syntax: SyntaxNode, 1304 pub(crate) syntax: SyntaxNode,
@@ -1358,7 +1360,7 @@ impl ast::AttrsOwner for MatchArm {}
1358impl MatchArm { 1360impl MatchArm {
1359 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1361 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1360 pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) } 1362 pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) }
1361 pub fn fat_arrow_token(&self) -> Option<FatArrow> { support::token(&self.syntax) } 1363 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=>]) }
1362 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1364 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1363} 1365}
1364#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1366#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1417,7 +1419,7 @@ impl AstNode for RecordFieldList {
1417impl RecordFieldList { 1419impl RecordFieldList {
1418 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['{']) } 1420 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['{']) }
1419 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } 1421 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) }
1420 pub fn dotdot_token(&self) -> Option<Dotdot> { support::token(&self.syntax) } 1422 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![..]) }
1421 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } 1423 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
1422 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['}']) } 1424 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['}']) }
1423} 1425}
@@ -1439,7 +1441,7 @@ impl AstNode for RecordField {
1439impl ast::AttrsOwner for RecordField {} 1441impl ast::AttrsOwner for RecordField {}
1440impl RecordField { 1442impl RecordField {
1441 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 1443 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1442 pub fn colon_token(&self) -> Option<Colon> { support::token(&self.syntax) } 1444 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![:]) }
1443 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1445 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1444} 1446}
1445#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1447#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1496,7 +1498,7 @@ impl AstNode for RefPat {
1496 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1498 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1497} 1499}
1498impl RefPat { 1500impl RefPat {
1499 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } 1501 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![&]) }
1500 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) } 1502 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) }
1501 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1503 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1502} 1504}
@@ -1539,7 +1541,7 @@ impl ast::NameOwner for BindPat {}
1539impl BindPat { 1541impl BindPat {
1540 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![ref]) } 1542 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![ref]) }
1541 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) } 1543 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) }
1542 pub fn at_token(&self) -> Option<At> { support::token(&self.syntax) } 1544 pub fn at_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![@]) }
1543 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1545 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1544} 1546}
1545#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1547#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1558,7 +1560,7 @@ impl AstNode for PlaceholderPat {
1558 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1560 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1559} 1561}
1560impl PlaceholderPat { 1562impl PlaceholderPat {
1561 pub fn underscore_token(&self) -> Option<Underscore> { support::token(&self.syntax) } 1563 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![_]) }
1562} 1564}
1563#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1565#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1564pub struct DotDotPat { 1566pub struct DotDotPat {
@@ -1576,7 +1578,7 @@ impl AstNode for DotDotPat {
1576 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1578 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1577} 1579}
1578impl DotDotPat { 1580impl DotDotPat {
1579 pub fn dotdot_token(&self) -> Option<Dotdot> { support::token(&self.syntax) } 1581 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![..]) }
1580} 1582}
1581#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1583#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1582pub struct PathPat { 1584pub struct PathPat {
@@ -1631,9 +1633,7 @@ impl AstNode for RangePat {
1631 } 1633 }
1632 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1634 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1633} 1635}
1634impl RangePat { 1636impl RangePat {}
1635 pub fn range_separator_token(&self) -> Option<RangeSeparator> { support::token(&self.syntax) }
1636}
1637#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1637#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1638pub struct LiteralPat { 1638pub struct LiteralPat {
1639 pub(crate) syntax: SyntaxNode, 1639 pub(crate) syntax: SyntaxNode,
@@ -1713,7 +1713,7 @@ impl RecordFieldPatList {
1713 support::children(&self.syntax) 1713 support::children(&self.syntax)
1714 } 1714 }
1715 pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) } 1715 pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) }
1716 pub fn dotdot_token(&self) -> Option<Dotdot> { support::token(&self.syntax) } 1716 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![..]) }
1717 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['}']) } 1717 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['}']) }
1718} 1718}
1719#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1719#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1734,7 +1734,7 @@ impl AstNode for RecordFieldPat {
1734impl ast::AttrsOwner for RecordFieldPat {} 1734impl ast::AttrsOwner for RecordFieldPat {}
1735impl ast::NameOwner for RecordFieldPat {} 1735impl ast::NameOwner for RecordFieldPat {}
1736impl RecordFieldPat { 1736impl RecordFieldPat {
1737 pub fn colon_token(&self) -> Option<Colon> { support::token(&self.syntax) } 1737 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![:]) }
1738 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1738 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1739} 1739}
1740#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1740#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1815,7 +1815,7 @@ impl AstNode for Name {
1815 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1815 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1816} 1816}
1817impl Name { 1817impl Name {
1818 pub fn ident_token(&self) -> Option<Ident> { support::token(&self.syntax) } 1818 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![ident]) }
1819} 1819}
1820#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1820#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1821pub struct NameRef { 1821pub struct NameRef {
@@ -1832,9 +1832,7 @@ impl AstNode for NameRef {
1832 } 1832 }
1833 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1833 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1834} 1834}
1835impl NameRef { 1835impl NameRef {}
1836 pub fn name_ref_token_token(&self) -> Option<NameRefToken> { support::token(&self.syntax) }
1837}
1838#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1836#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1839pub struct MacroCall { 1837pub struct MacroCall {
1840 pub(crate) syntax: SyntaxNode, 1838 pub(crate) syntax: SyntaxNode,
@@ -1855,7 +1853,7 @@ impl ast::AttrsOwner for MacroCall {}
1855impl ast::DocCommentsOwner for MacroCall {} 1853impl ast::DocCommentsOwner for MacroCall {}
1856impl MacroCall { 1854impl MacroCall {
1857 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1855 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1858 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } 1856 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![!]) }
1859 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } 1857 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1860 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) } 1858 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
1861} 1859}
@@ -1875,8 +1873,8 @@ impl AstNode for Attr {
1875 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1873 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1876} 1874}
1877impl Attr { 1875impl Attr {
1878 pub fn pound_token(&self) -> Option<Pound> { support::token(&self.syntax) } 1876 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![#]) }
1879 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } 1877 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![!]) }
1880 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['[']) } 1878 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['[']) }
1881 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1879 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1882 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) } 1880 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
@@ -1915,12 +1913,12 @@ impl AstNode for TypeParamList {
1915 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1913 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1916} 1914}
1917impl TypeParamList { 1915impl TypeParamList {
1918 pub fn l_angle_token(&self) -> Option<LAngle> { support::token(&self.syntax) } 1916 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![<]) }
1919 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) } 1917 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
1920 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) } 1918 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
1921 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) } 1919 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
1922 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) } 1920 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
1923 pub fn r_angle_token(&self) -> Option<RAngle> { support::token(&self.syntax) } 1921 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![>]) }
1924} 1922}
1925#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1923#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1926pub struct TypeParam { 1924pub struct TypeParam {
@@ -1983,7 +1981,9 @@ impl AstNode for LifetimeParam {
1983} 1981}
1984impl ast::AttrsOwner for LifetimeParam {} 1982impl ast::AttrsOwner for LifetimeParam {}
1985impl LifetimeParam { 1983impl LifetimeParam {
1986 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 1984 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1985 support::token2(&self.syntax, T![lifetime])
1986 }
1987} 1987}
1988#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1988#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1989pub struct TypeBound { 1989pub struct TypeBound {
@@ -2001,7 +2001,9 @@ impl AstNode for TypeBound {
2001 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2001 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2002} 2002}
2003impl TypeBound { 2003impl TypeBound {
2004 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 2004 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2005 support::token2(&self.syntax, T![lifetime])
2006 }
2005 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) } 2007 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) }
2006 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 2008 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2007} 2009}
@@ -2040,7 +2042,9 @@ impl AstNode for WherePred {
2040} 2042}
2041impl ast::TypeBoundsOwner for WherePred {} 2043impl ast::TypeBoundsOwner for WherePred {}
2042impl WherePred { 2044impl WherePred {
2043 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 2045 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2046 support::token2(&self.syntax, T![lifetime])
2047 }
2044 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 2048 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2045} 2049}
2046#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2050#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2077,9 +2081,7 @@ impl AstNode for Abi {
2077 } 2081 }
2078 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2082 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2079} 2083}
2080impl Abi { 2084impl Abi {}
2081 pub fn string_token(&self) -> Option<String> { support::token(&self.syntax) }
2082}
2083#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2085#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2084pub struct ExprStmt { 2086pub struct ExprStmt {
2085 pub(crate) syntax: SyntaxNode, 2087 pub(crate) syntax: SyntaxNode,
@@ -2207,8 +2209,10 @@ impl AstNode for SelfParam {
2207impl ast::TypeAscriptionOwner for SelfParam {} 2209impl ast::TypeAscriptionOwner for SelfParam {}
2208impl ast::AttrsOwner for SelfParam {} 2210impl ast::AttrsOwner for SelfParam {}
2209impl SelfParam { 2211impl SelfParam {
2210 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } 2212 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![&]) }
2211 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 2213 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2214 support::token2(&self.syntax, T![lifetime])
2215 }
2212 pub fn self_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![self]) } 2216 pub fn self_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![self]) }
2213} 2217}
2214#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2218#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2230,7 +2234,7 @@ impl ast::TypeAscriptionOwner for Param {}
2230impl ast::AttrsOwner for Param {} 2234impl ast::AttrsOwner for Param {}
2231impl Param { 2235impl Param {
2232 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 2236 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2233 pub fn dotdotdot_token(&self) -> Option<Dotdotdot> { support::token(&self.syntax) } 2237 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![...]) }
2234} 2238}
2235#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2239#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2236pub struct UseItem { 2240pub struct UseItem {
@@ -2270,7 +2274,7 @@ impl AstNode for UseTree {
2270} 2274}
2271impl UseTree { 2275impl UseTree {
2272 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 2276 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2273 pub fn star_token(&self) -> Option<Star> { support::token(&self.syntax) } 2277 pub fn star_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![*]) }
2274 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) } 2278 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
2275 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } 2279 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2276} 2280}
@@ -2391,14 +2395,14 @@ impl AstNode for PathSegment {
2391 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2395 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2392} 2396}
2393impl PathSegment { 2397impl PathSegment {
2394 pub fn coloncolon_token(&self) -> Option<Coloncolon> { support::token(&self.syntax) } 2398 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![::]) }
2395 pub fn l_angle_token(&self) -> Option<LAngle> { support::token(&self.syntax) } 2399 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![<]) }
2396 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 2400 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2397 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } 2401 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
2398 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 2402 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
2399 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 2403 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
2400 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } 2404 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
2401 pub fn r_angle_token(&self) -> Option<RAngle> { support::token(&self.syntax) } 2405 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![>]) }
2402} 2406}
2403#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2407#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2404pub struct TypeArgList { 2408pub struct TypeArgList {
@@ -2416,14 +2420,14 @@ impl AstNode for TypeArgList {
2416 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2420 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2417} 2421}
2418impl TypeArgList { 2422impl TypeArgList {
2419 pub fn coloncolon_token(&self) -> Option<Coloncolon> { support::token(&self.syntax) } 2423 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![::]) }
2420 pub fn l_angle_token(&self) -> Option<LAngle> { support::token(&self.syntax) } 2424 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![<]) }
2421 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) } 2425 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
2422 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) } 2426 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
2423 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) } 2427 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
2424 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) } 2428 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
2425 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) } 2429 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
2426 pub fn r_angle_token(&self) -> Option<RAngle> { support::token(&self.syntax) } 2430 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![>]) }
2427} 2431}
2428#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2432#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2429pub struct TypeArg { 2433pub struct TypeArg {
@@ -2480,7 +2484,9 @@ impl AstNode for LifetimeArg {
2480 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2484 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2481} 2485}
2482impl LifetimeArg { 2486impl LifetimeArg {
2483 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 2487 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2488 support::token2(&self.syntax, T![lifetime])
2489 }
2484} 2490}
2485#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2491#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2486pub struct ConstArg { 2492pub struct ConstArg {
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs
index 7611ce4cb..293f91c2e 100644
--- a/crates/ra_syntax/src/ast/generated/tokens.rs
+++ b/crates/ra_syntax/src/ast/generated/tokens.rs
@@ -1365,242 +1365,3 @@ impl AstToken for RDollar {
1365 } 1365 }
1366 fn syntax(&self) -> &SyntaxToken { &self.syntax } 1366 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1367} 1367}
1368#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1369pub enum RangeSeparator {
1370 Dotdot(Dotdot),
1371 Dotdotdot(Dotdotdot),
1372 Dotdoteq(Dotdoteq),
1373}
1374impl From<Dotdot> for RangeSeparator {
1375 fn from(node: Dotdot) -> RangeSeparator { RangeSeparator::Dotdot(node) }
1376}
1377impl From<Dotdotdot> for RangeSeparator {
1378 fn from(node: Dotdotdot) -> RangeSeparator { RangeSeparator::Dotdotdot(node) }
1379}
1380impl From<Dotdoteq> for RangeSeparator {
1381 fn from(node: Dotdoteq) -> RangeSeparator { RangeSeparator::Dotdoteq(node) }
1382}
1383impl std::fmt::Display for RangeSeparator {
1384 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1385 std::fmt::Display::fmt(self.syntax(), f)
1386 }
1387}
1388impl AstToken for RangeSeparator {
1389 fn can_cast(kind: SyntaxKind) -> bool {
1390 match kind {
1391 DOTDOT | DOTDOTDOT | DOTDOTEQ => true,
1392 _ => false,
1393 }
1394 }
1395 fn cast(syntax: SyntaxToken) -> Option<Self> {
1396 let res = match syntax.kind() {
1397 DOTDOT => RangeSeparator::Dotdot(Dotdot { syntax }),
1398 DOTDOTDOT => RangeSeparator::Dotdotdot(Dotdotdot { syntax }),
1399 DOTDOTEQ => RangeSeparator::Dotdoteq(Dotdoteq { syntax }),
1400 _ => return None,
1401 };
1402 Some(res)
1403 }
1404 fn syntax(&self) -> &SyntaxToken {
1405 match self {
1406 RangeSeparator::Dotdot(it) => &it.syntax,
1407 RangeSeparator::Dotdotdot(it) => &it.syntax,
1408 RangeSeparator::Dotdoteq(it) => &it.syntax,
1409 }
1410 }
1411}
1412#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1413pub enum PrefixOp {
1414 Minus(Minus),
1415 Excl(Excl),
1416 Star(Star),
1417}
1418impl From<Minus> for PrefixOp {
1419 fn from(node: Minus) -> PrefixOp { PrefixOp::Minus(node) }
1420}
1421impl From<Excl> for PrefixOp {
1422 fn from(node: Excl) -> PrefixOp { PrefixOp::Excl(node) }
1423}
1424impl From<Star> for PrefixOp {
1425 fn from(node: Star) -> PrefixOp { PrefixOp::Star(node) }
1426}
1427impl std::fmt::Display for PrefixOp {
1428 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1429 std::fmt::Display::fmt(self.syntax(), f)
1430 }
1431}
1432impl AstToken for PrefixOp {
1433 fn can_cast(kind: SyntaxKind) -> bool {
1434 match kind {
1435 MINUS | EXCL | STAR => true,
1436 _ => false,
1437 }
1438 }
1439 fn cast(syntax: SyntaxToken) -> Option<Self> {
1440 let res = match syntax.kind() {
1441 MINUS => PrefixOp::Minus(Minus { syntax }),
1442 EXCL => PrefixOp::Excl(Excl { syntax }),
1443 STAR => PrefixOp::Star(Star { syntax }),
1444 _ => return None,
1445 };
1446 Some(res)
1447 }
1448 fn syntax(&self) -> &SyntaxToken {
1449 match self {
1450 PrefixOp::Minus(it) => &it.syntax,
1451 PrefixOp::Excl(it) => &it.syntax,
1452 PrefixOp::Star(it) => &it.syntax,
1453 }
1454 }
1455}
1456#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1457pub enum RangeOp {
1458 Dotdot(Dotdot),
1459 Dotdoteq(Dotdoteq),
1460}
1461impl From<Dotdot> for RangeOp {
1462 fn from(node: Dotdot) -> RangeOp { RangeOp::Dotdot(node) }
1463}
1464impl From<Dotdoteq> for RangeOp {
1465 fn from(node: Dotdoteq) -> RangeOp { RangeOp::Dotdoteq(node) }
1466}
1467impl std::fmt::Display for RangeOp {
1468 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1469 std::fmt::Display::fmt(self.syntax(), f)
1470 }
1471}
1472impl AstToken for RangeOp {
1473 fn can_cast(kind: SyntaxKind) -> bool {
1474 match kind {
1475 DOTDOT | DOTDOTEQ => true,
1476 _ => false,
1477 }
1478 }
1479 fn cast(syntax: SyntaxToken) -> Option<Self> {
1480 let res = match syntax.kind() {
1481 DOTDOT => RangeOp::Dotdot(Dotdot { syntax }),
1482 DOTDOTEQ => RangeOp::Dotdoteq(Dotdoteq { syntax }),
1483 _ => return None,
1484 };
1485 Some(res)
1486 }
1487 fn syntax(&self) -> &SyntaxToken {
1488 match self {
1489 RangeOp::Dotdot(it) => &it.syntax,
1490 RangeOp::Dotdoteq(it) => &it.syntax,
1491 }
1492 }
1493}
1494#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1495pub enum LiteralToken {
1496 IntNumber(IntNumber),
1497 FloatNumber(FloatNumber),
1498 String(String),
1499 RawString(RawString),
1500 ByteString(ByteString),
1501 RawByteString(RawByteString),
1502 Char(Char),
1503 Byte(Byte),
1504}
1505impl From<IntNumber> for LiteralToken {
1506 fn from(node: IntNumber) -> LiteralToken { LiteralToken::IntNumber(node) }
1507}
1508impl From<FloatNumber> for LiteralToken {
1509 fn from(node: FloatNumber) -> LiteralToken { LiteralToken::FloatNumber(node) }
1510}
1511impl From<String> for LiteralToken {
1512 fn from(node: String) -> LiteralToken { LiteralToken::String(node) }
1513}
1514impl From<RawString> for LiteralToken {
1515 fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) }
1516}
1517impl From<ByteString> for LiteralToken {
1518 fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) }
1519}
1520impl From<RawByteString> for LiteralToken {
1521 fn from(node: RawByteString) -> LiteralToken { LiteralToken::RawByteString(node) }
1522}
1523impl From<Char> for LiteralToken {
1524 fn from(node: Char) -> LiteralToken { LiteralToken::Char(node) }
1525}
1526impl From<Byte> for LiteralToken {
1527 fn from(node: Byte) -> LiteralToken { LiteralToken::Byte(node) }
1528}
1529impl std::fmt::Display for LiteralToken {
1530 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1531 std::fmt::Display::fmt(self.syntax(), f)
1532 }
1533}
1534impl AstToken for LiteralToken {
1535 fn can_cast(kind: SyntaxKind) -> bool {
1536 match kind {
1537 INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | BYTE_STRING | RAW_BYTE_STRING
1538 | CHAR | BYTE => true,
1539 _ => false,
1540 }
1541 }
1542 fn cast(syntax: SyntaxToken) -> Option<Self> {
1543 let res = match syntax.kind() {
1544 INT_NUMBER => LiteralToken::IntNumber(IntNumber { syntax }),
1545 FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
1546 STRING => LiteralToken::String(String { syntax }),
1547 RAW_STRING => LiteralToken::RawString(RawString { syntax }),
1548 BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }),
1549 RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
1550 CHAR => LiteralToken::Char(Char { syntax }),
1551 BYTE => LiteralToken::Byte(Byte { syntax }),
1552 _ => return None,
1553 };
1554 Some(res)
1555 }
1556 fn syntax(&self) -> &SyntaxToken {
1557 match self {
1558 LiteralToken::IntNumber(it) => &it.syntax,
1559 LiteralToken::FloatNumber(it) => &it.syntax,
1560 LiteralToken::String(it) => &it.syntax,
1561 LiteralToken::RawString(it) => &it.syntax,
1562 LiteralToken::ByteString(it) => &it.syntax,
1563 LiteralToken::RawByteString(it) => &it.syntax,
1564 LiteralToken::Char(it) => &it.syntax,
1565 LiteralToken::Byte(it) => &it.syntax,
1566 }
1567 }
1568}
1569#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1570pub enum NameRefToken {
1571 Ident(Ident),
1572 IntNumber(IntNumber),
1573}
1574impl From<Ident> for NameRefToken {
1575 fn from(node: Ident) -> NameRefToken { NameRefToken::Ident(node) }
1576}
1577impl From<IntNumber> for NameRefToken {
1578 fn from(node: IntNumber) -> NameRefToken { NameRefToken::IntNumber(node) }
1579}
1580impl std::fmt::Display for NameRefToken {
1581 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1582 std::fmt::Display::fmt(self.syntax(), f)
1583 }
1584}
1585impl AstToken for NameRefToken {
1586 fn can_cast(kind: SyntaxKind) -> bool {
1587 match kind {
1588 IDENT | INT_NUMBER => true,
1589 _ => false,
1590 }
1591 }
1592 fn cast(syntax: SyntaxToken) -> Option<Self> {
1593 let res = match syntax.kind() {
1594 IDENT => NameRefToken::Ident(Ident { syntax }),
1595 INT_NUMBER => NameRefToken::IntNumber(IntNumber { syntax }),
1596 _ => return None,
1597 };
1598 Some(res)
1599 }
1600 fn syntax(&self) -> &SyntaxToken {
1601 match self {
1602 NameRefToken::Ident(it) => &it.syntax,
1603 NameRefToken::IntNumber(it) => &it.syntax,
1604 }
1605 }
1606}