aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/generated.rs
diff options
context:
space:
mode:
authorMarcus Klaas de Vries <[email protected]>2019-01-14 18:30:21 +0000
committerMarcus Klaas de Vries <[email protected]>2019-01-14 18:30:21 +0000
commita9a6a50c759302e8a8d59bf6c53c72ec804324b3 (patch)
treeecd22d01bca8bfb2419732621140c3271277973d /crates/ra_syntax/src/ast/generated.rs
parent606d66a714bb8fe07f35a6af83d04ab576b9a0e1 (diff)
Fixup tests
Diffstat (limited to 'crates/ra_syntax/src/ast/generated.rs')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs132
1 files changed, 94 insertions, 38 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 442659aee..cad845ec0 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -664,7 +664,7 @@ pub enum ExprKind<'a> {
664 PrefixExpr(&'a PrefixExpr), 664 PrefixExpr(&'a PrefixExpr),
665 RangeExpr(&'a RangeExpr), 665 RangeExpr(&'a RangeExpr),
666 BinExpr(&'a BinExpr), 666 BinExpr(&'a BinExpr),
667 LiteralExpr(&'a LiteralExpr), 667 Literal(&'a Literal),
668} 668}
669 669
670impl AstNode for Expr { 670impl AstNode for Expr {
@@ -696,7 +696,7 @@ impl AstNode for Expr {
696 | PREFIX_EXPR 696 | PREFIX_EXPR
697 | RANGE_EXPR 697 | RANGE_EXPR
698 | BIN_EXPR 698 | BIN_EXPR
699 | LITERAL_EXPR => Some(Expr::from_repr(syntax.into_repr())), 699 | LITERAL => Some(Expr::from_repr(syntax.into_repr())),
700 _ => None, 700 _ => None,
701 } 701 }
702 } 702 }
@@ -733,7 +733,7 @@ impl Expr {
733 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(&self.syntax).unwrap()), 733 PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(&self.syntax).unwrap()),
734 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()), 734 RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()),
735 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()), 735 BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()),
736 LITERAL_EXPR => ExprKind::LiteralExpr(LiteralExpr::cast(&self.syntax).unwrap()), 736 LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()),
737 _ => unreachable!(), 737 _ => unreachable!(),
738 } 738 }
739 } 739 }
@@ -793,6 +793,31 @@ impl AstNode for ExternCrateItem {
793 793
794impl ExternCrateItem {} 794impl ExternCrateItem {}
795 795
796// FalseKw
797#[derive(Debug, PartialEq, Eq, Hash)]
798#[repr(transparent)]
799pub struct FalseKw {
800 pub(crate) syntax: SyntaxNode,
801}
802unsafe impl TransparentNewType for FalseKw {
803 type Repr = rowan::SyntaxNode<RaTypes>;
804}
805
806impl AstNode for FalseKw {
807 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
808 match syntax.kind() {
809 FALSE_KW => Some(FalseKw::from_repr(syntax.into_repr())),
810 _ => None,
811 }
812 }
813 fn syntax(&self) -> &SyntaxNode { &self.syntax }
814 fn to_owned(&self) -> TreeArc<FalseKw> { TreeArc::cast(self.syntax.to_owned()) }
815}
816
817
818impl ast::AstToken for FalseKw {}
819impl FalseKw {}
820
796// FieldExpr 821// FieldExpr
797#[derive(Debug, PartialEq, Eq, Hash)] 822#[derive(Debug, PartialEq, Eq, Hash)]
798#[repr(transparent)] 823#[repr(transparent)]
@@ -867,7 +892,7 @@ impl AstNode for FloatNumber {
867 } 892 }
868 } 893 }
869 fn syntax(&self) -> &SyntaxNode { &self.syntax } 894 fn syntax(&self) -> &SyntaxNode { &self.syntax }
870 fn to_owned(&self) -> TreePtr<FloatNumber> { TreePtr::cast(self.syntax.to_owned()) } 895 fn to_owned(&self) -> TreeArc<FloatNumber> { TreeArc::cast(self.syntax.to_owned()) }
871} 896}
872 897
873 898
@@ -1173,7 +1198,7 @@ impl AstNode for IntNumber {
1173 } 1198 }
1174 } 1199 }
1175 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1200 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1176 fn to_owned(&self) -> TreePtr<IntNumber> { TreePtr::cast(self.syntax.to_owned()) } 1201 fn to_owned(&self) -> TreeArc<IntNumber> { TreeArc::cast(self.syntax.to_owned()) }
1177} 1202}
1178 1203
1179 1204
@@ -1365,25 +1390,10 @@ unsafe impl TransparentNewType for Literal {
1365 type Repr = rowan::SyntaxNode<RaTypes>; 1390 type Repr = rowan::SyntaxNode<RaTypes>;
1366} 1391}
1367 1392
1368#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1369pub enum LiteralKind<'a> {
1370 String(&'a String),
1371 ByteString(&'a ByteString),
1372 Char(&'a Char),
1373 Byte(&'a Byte),
1374 IntNumber(&'a IntNumber),
1375 FloatNumber(&'a FloatNumber),
1376}
1377
1378impl AstNode for Literal { 1393impl AstNode for Literal {
1379 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 1394 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1380 match syntax.kind() { 1395 match syntax.kind() {
1381 | STRING 1396 LITERAL => Some(Literal::from_repr(syntax.into_repr())),
1382 | BYTE_STRING
1383 | CHAR
1384 | BYTE
1385 | INT_NUMBER
1386 | FLOAT_NUMBER => Some(Literal::from_repr(syntax.into_repr())),
1387 _ => None, 1397 _ => None,
1388 } 1398 }
1389 } 1399 }
@@ -1391,22 +1401,13 @@ impl AstNode for Literal {
1391 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) } 1401 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
1392} 1402}
1393 1403
1404
1394impl Literal { 1405impl Literal {
1395 pub fn kind(&self) -> LiteralKind { 1406 pub fn literal_expr(&self) -> Option<&LiteralExpr> {
1396 match self.syntax.kind() { 1407 super::child_opt(self)
1397 STRING => LiteralKind::String(String::cast(&self.syntax).unwrap()),
1398 BYTE_STRING => LiteralKind::ByteString(ByteString::cast(&self.syntax).unwrap()),
1399 CHAR => LiteralKind::Char(Char::cast(&self.syntax).unwrap()),
1400 BYTE => LiteralKind::Byte(Byte::cast(&self.syntax).unwrap()),
1401 INT_NUMBER => LiteralKind::IntNumber(IntNumber::cast(&self.syntax).unwrap()),
1402 FLOAT_NUMBER => LiteralKind::FloatNumber(FloatNumber::cast(&self.syntax).unwrap()),
1403 _ => unreachable!(),
1404 }
1405 } 1408 }
1406} 1409}
1407 1410
1408impl Literal {}
1409
1410// LiteralExpr 1411// LiteralExpr
1411#[derive(Debug, PartialEq, Eq, Hash)] 1412#[derive(Debug, PartialEq, Eq, Hash)]
1412#[repr(transparent)] 1413#[repr(transparent)]
@@ -1417,24 +1418,54 @@ unsafe impl TransparentNewType for LiteralExpr {
1417 type Repr = rowan::SyntaxNode<RaTypes>; 1418 type Repr = rowan::SyntaxNode<RaTypes>;
1418} 1419}
1419 1420
1421#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1422pub enum LiteralExprKind<'a> {
1423 String(&'a String),
1424 ByteString(&'a ByteString),
1425 Char(&'a Char),
1426 Byte(&'a Byte),
1427 IntNumber(&'a IntNumber),
1428 FloatNumber(&'a FloatNumber),
1429 TrueKw(&'a TrueKw),
1430 FalseKw(&'a FalseKw),
1431}
1432
1420impl AstNode for LiteralExpr { 1433impl AstNode for LiteralExpr {
1421 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 1434 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1422 match syntax.kind() { 1435 match syntax.kind() {
1423 LITERAL_EXPR => Some(LiteralExpr::from_repr(syntax.into_repr())), 1436 | STRING
1437 | BYTE_STRING
1438 | CHAR
1439 | BYTE
1440 | INT_NUMBER
1441 | FLOAT_NUMBER
1442 | TRUE_KW
1443 | FALSE_KW => Some(LiteralExpr::from_repr(syntax.into_repr())),
1424 _ => None, 1444 _ => None,
1425 } 1445 }
1426 } 1446 }
1427 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1447 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1428 fn to_owned(&self) -> TreePtr<LiteralExpr> { TreePtr::cast(self.syntax.to_owned()) } 1448 fn to_owned(&self) -> TreeArc<LiteralExpr> { TreeArc::cast(self.syntax.to_owned()) }
1429} 1449}
1430 1450
1431
1432impl LiteralExpr { 1451impl LiteralExpr {
1433 pub fn literal(&self) -> Option<&Literal> { 1452 pub fn kind(&self) -> LiteralExprKind {
1434 super::child_opt(self) 1453 match self.syntax.kind() {
1454 STRING => LiteralExprKind::String(String::cast(&self.syntax).unwrap()),
1455 BYTE_STRING => LiteralExprKind::ByteString(ByteString::cast(&self.syntax).unwrap()),
1456 CHAR => LiteralExprKind::Char(Char::cast(&self.syntax).unwrap()),
1457 BYTE => LiteralExprKind::Byte(Byte::cast(&self.syntax).unwrap()),
1458 INT_NUMBER => LiteralExprKind::IntNumber(IntNumber::cast(&self.syntax).unwrap()),
1459 FLOAT_NUMBER => LiteralExprKind::FloatNumber(FloatNumber::cast(&self.syntax).unwrap()),
1460 TRUE_KW => LiteralExprKind::TrueKw(TrueKw::cast(&self.syntax).unwrap()),
1461 FALSE_KW => LiteralExprKind::FalseKw(FalseKw::cast(&self.syntax).unwrap()),
1462 _ => unreachable!(),
1463 }
1435 } 1464 }
1436} 1465}
1437 1466
1467impl LiteralExpr {}
1468
1438// LoopExpr 1469// LoopExpr
1439#[derive(Debug, PartialEq, Eq, Hash)] 1470#[derive(Debug, PartialEq, Eq, Hash)]
1440#[repr(transparent)] 1471#[repr(transparent)]
@@ -3025,6 +3056,31 @@ impl ast::AttrsOwner for TraitDef {}
3025impl ast::DocCommentsOwner for TraitDef {} 3056impl ast::DocCommentsOwner for TraitDef {}
3026impl TraitDef {} 3057impl TraitDef {}
3027 3058
3059// TrueKw
3060#[derive(Debug, PartialEq, Eq, Hash)]
3061#[repr(transparent)]
3062pub struct TrueKw {
3063 pub(crate) syntax: SyntaxNode,
3064}
3065unsafe impl TransparentNewType for TrueKw {
3066 type Repr = rowan::SyntaxNode<RaTypes>;
3067}
3068
3069impl AstNode for TrueKw {
3070 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3071 match syntax.kind() {
3072 TRUE_KW => Some(TrueKw::from_repr(syntax.into_repr())),
3073 _ => None,
3074 }
3075 }
3076 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3077 fn to_owned(&self) -> TreeArc<TrueKw> { TreeArc::cast(self.syntax.to_owned()) }
3078}
3079
3080
3081impl ast::AstToken for TrueKw {}
3082impl TrueKw {}
3083
3028// TryExpr 3084// TryExpr
3029#[derive(Debug, PartialEq, Eq, Hash)] 3085#[derive(Debug, PartialEq, Eq, Hash)]
3030#[repr(transparent)] 3086#[repr(transparent)]