aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs178
1 files changed, 76 insertions, 102 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index e3b3f44cc..e898c9181 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -502,6 +502,23 @@ impl ConstParam {
502 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } 502 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
503} 503}
504#[derive(Debug, Clone, PartialEq, Eq, Hash)] 504#[derive(Debug, Clone, PartialEq, Eq, Hash)]
505pub struct Literal {
506 pub(crate) syntax: SyntaxNode,
507}
508impl Literal {}
509#[derive(Debug, Clone, PartialEq, Eq, Hash)]
510pub struct TokenTree {
511 pub(crate) syntax: SyntaxNode,
512}
513impl TokenTree {
514 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
515 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
516 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
517 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
518 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
519 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
520}
521#[derive(Debug, Clone, PartialEq, Eq, Hash)]
505pub struct ParenType { 522pub struct ParenType {
506 pub(crate) syntax: SyntaxNode, 523 pub(crate) syntax: SyntaxNode,
507} 524}
@@ -908,11 +925,6 @@ pub struct BinExpr {
908impl ast::AttrsOwner for BinExpr {} 925impl ast::AttrsOwner for BinExpr {}
909impl BinExpr {} 926impl BinExpr {}
910#[derive(Debug, Clone, PartialEq, Eq, Hash)] 927#[derive(Debug, Clone, PartialEq, Eq, Hash)]
911pub struct Literal {
912 pub(crate) syntax: SyntaxNode,
913}
914impl Literal {}
915#[derive(Debug, Clone, PartialEq, Eq, Hash)]
916pub struct MatchExpr { 928pub struct MatchExpr {
917 pub(crate) syntax: SyntaxNode, 929 pub(crate) syntax: SyntaxNode,
918} 930}
@@ -1131,18 +1143,6 @@ impl TuplePat {
1131 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1143 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1132} 1144}
1133#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1145#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1134pub struct TokenTree {
1135 pub(crate) syntax: SyntaxNode,
1136}
1137impl TokenTree {
1138 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1139 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1140 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1141 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1142 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1143 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1144}
1145#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1146pub struct MacroDef { 1146pub struct MacroDef {
1147 pub(crate) syntax: SyntaxNode, 1147 pub(crate) syntax: SyntaxNode,
1148} 1148}
@@ -1263,16 +1263,6 @@ impl ConstArg {
1263 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 1263 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
1264} 1264}
1265#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1265#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1266pub struct MetaItem {
1267 pub(crate) syntax: SyntaxNode,
1268}
1269impl MetaItem {
1270 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1271 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1272 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
1273 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
1274}
1275#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1276pub enum Item { 1266pub enum Item {
1277 Const(Const), 1267 Const(Const),
1278 Enum(Enum), 1268 Enum(Enum),
@@ -1388,17 +1378,17 @@ pub enum GenericParam {
1388} 1378}
1389impl ast::AttrsOwner for GenericParam {} 1379impl ast::AttrsOwner for GenericParam {}
1390#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1380#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1381pub enum AttrInput {
1382 Literal(Literal),
1383 TokenTree(TokenTree),
1384}
1385#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1391pub enum Stmt { 1386pub enum Stmt {
1392 LetStmt(LetStmt), 1387 LetStmt(LetStmt),
1393 ExprStmt(ExprStmt), 1388 ExprStmt(ExprStmt),
1394} 1389}
1395impl ast::AttrsOwner for Stmt {} 1390impl ast::AttrsOwner for Stmt {}
1396#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1391#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1397pub enum AttrInput {
1398 Literal(Literal),
1399 TokenTree(TokenTree),
1400}
1401#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1402pub enum AdtDef { 1392pub enum AdtDef {
1403 Struct(Struct), 1393 Struct(Struct),
1404 Enum(Enum), 1394 Enum(Enum),
@@ -1892,6 +1882,28 @@ impl AstNode for ConstParam {
1892 } 1882 }
1893 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1883 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1894} 1884}
1885impl AstNode for Literal {
1886 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL }
1887 fn cast(syntax: SyntaxNode) -> Option<Self> {
1888 if Self::can_cast(syntax.kind()) {
1889 Some(Self { syntax })
1890 } else {
1891 None
1892 }
1893 }
1894 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1895}
1896impl AstNode for TokenTree {
1897 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE }
1898 fn cast(syntax: SyntaxNode) -> Option<Self> {
1899 if Self::can_cast(syntax.kind()) {
1900 Some(Self { syntax })
1901 } else {
1902 None
1903 }
1904 }
1905 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1906}
1895impl AstNode for ParenType { 1907impl AstNode for ParenType {
1896 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } 1908 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE }
1897 fn cast(syntax: SyntaxNode) -> Option<Self> { 1909 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2354,17 +2366,6 @@ impl AstNode for BinExpr {
2354 } 2366 }
2355 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2367 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2356} 2368}
2357impl AstNode for Literal {
2358 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL }
2359 fn cast(syntax: SyntaxNode) -> Option<Self> {
2360 if Self::can_cast(syntax.kind()) {
2361 Some(Self { syntax })
2362 } else {
2363 None
2364 }
2365 }
2366 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2367}
2368impl AstNode for MatchExpr { 2369impl AstNode for MatchExpr {
2369 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR } 2370 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR }
2370 fn cast(syntax: SyntaxNode) -> Option<Self> { 2371 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2629,17 +2630,6 @@ impl AstNode for TuplePat {
2629 } 2630 }
2630 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2631 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2631} 2632}
2632impl AstNode for TokenTree {
2633 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE }
2634 fn cast(syntax: SyntaxNode) -> Option<Self> {
2635 if Self::can_cast(syntax.kind()) {
2636 Some(Self { syntax })
2637 } else {
2638 None
2639 }
2640 }
2641 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2642}
2643impl AstNode for MacroDef { 2633impl AstNode for MacroDef {
2644 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF } 2634 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF }
2645 fn cast(syntax: SyntaxNode) -> Option<Self> { 2635 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2772,17 +2762,6 @@ impl AstNode for ConstArg {
2772 } 2762 }
2773 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2763 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2774} 2764}
2775impl AstNode for MetaItem {
2776 fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM }
2777 fn cast(syntax: SyntaxNode) -> Option<Self> {
2778 if Self::can_cast(syntax.kind()) {
2779 Some(Self { syntax })
2780 } else {
2781 None
2782 }
2783 }
2784 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2785}
2786impl From<Const> for Item { 2765impl From<Const> for Item {
2787 fn from(node: Const) -> Item { Item::Const(node) } 2766 fn from(node: Const) -> Item { Item::Const(node) }
2788} 2767}
@@ -3363,59 +3342,59 @@ impl AstNode for GenericParam {
3363 } 3342 }
3364 } 3343 }
3365} 3344}
3366impl From<LetStmt> for Stmt { 3345impl From<Literal> for AttrInput {
3367 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } 3346 fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) }
3368} 3347}
3369impl From<ExprStmt> for Stmt { 3348impl From<TokenTree> for AttrInput {
3370 fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) } 3349 fn from(node: TokenTree) -> AttrInput { AttrInput::TokenTree(node) }
3371} 3350}
3372impl AstNode for Stmt { 3351impl AstNode for AttrInput {
3373 fn can_cast(kind: SyntaxKind) -> bool { 3352 fn can_cast(kind: SyntaxKind) -> bool {
3374 match kind { 3353 match kind {
3375 LET_STMT | EXPR_STMT => true, 3354 LITERAL | TOKEN_TREE => true,
3376 _ => false, 3355 _ => false,
3377 } 3356 }
3378 } 3357 }
3379 fn cast(syntax: SyntaxNode) -> Option<Self> { 3358 fn cast(syntax: SyntaxNode) -> Option<Self> {
3380 let res = match syntax.kind() { 3359 let res = match syntax.kind() {
3381 LET_STMT => Stmt::LetStmt(LetStmt { syntax }), 3360 LITERAL => AttrInput::Literal(Literal { syntax }),
3382 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }), 3361 TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }),
3383 _ => return None, 3362 _ => return None,
3384 }; 3363 };
3385 Some(res) 3364 Some(res)
3386 } 3365 }
3387 fn syntax(&self) -> &SyntaxNode { 3366 fn syntax(&self) -> &SyntaxNode {
3388 match self { 3367 match self {
3389 Stmt::LetStmt(it) => &it.syntax, 3368 AttrInput::Literal(it) => &it.syntax,
3390 Stmt::ExprStmt(it) => &it.syntax, 3369 AttrInput::TokenTree(it) => &it.syntax,
3391 } 3370 }
3392 } 3371 }
3393} 3372}
3394impl From<Literal> for AttrInput { 3373impl From<LetStmt> for Stmt {
3395 fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) } 3374 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
3396} 3375}
3397impl From<TokenTree> for AttrInput { 3376impl From<ExprStmt> for Stmt {
3398 fn from(node: TokenTree) -> AttrInput { AttrInput::TokenTree(node) } 3377 fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) }
3399} 3378}
3400impl AstNode for AttrInput { 3379impl AstNode for Stmt {
3401 fn can_cast(kind: SyntaxKind) -> bool { 3380 fn can_cast(kind: SyntaxKind) -> bool {
3402 match kind { 3381 match kind {
3403 LITERAL | TOKEN_TREE => true, 3382 LET_STMT | EXPR_STMT => true,
3404 _ => false, 3383 _ => false,
3405 } 3384 }
3406 } 3385 }
3407 fn cast(syntax: SyntaxNode) -> Option<Self> { 3386 fn cast(syntax: SyntaxNode) -> Option<Self> {
3408 let res = match syntax.kind() { 3387 let res = match syntax.kind() {
3409 LITERAL => AttrInput::Literal(Literal { syntax }), 3388 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
3410 TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }), 3389 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
3411 _ => return None, 3390 _ => return None,
3412 }; 3391 };
3413 Some(res) 3392 Some(res)
3414 } 3393 }
3415 fn syntax(&self) -> &SyntaxNode { 3394 fn syntax(&self) -> &SyntaxNode {
3416 match self { 3395 match self {
3417 AttrInput::Literal(it) => &it.syntax, 3396 Stmt::LetStmt(it) => &it.syntax,
3418 AttrInput::TokenTree(it) => &it.syntax, 3397 Stmt::ExprStmt(it) => &it.syntax,
3419 } 3398 }
3420 } 3399 }
3421} 3400}
@@ -3492,12 +3471,12 @@ impl std::fmt::Display for GenericParam {
3492 std::fmt::Display::fmt(self.syntax(), f) 3471 std::fmt::Display::fmt(self.syntax(), f)
3493 } 3472 }
3494} 3473}
3495impl std::fmt::Display for Stmt { 3474impl std::fmt::Display for AttrInput {
3496 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3475 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3497 std::fmt::Display::fmt(self.syntax(), f) 3476 std::fmt::Display::fmt(self.syntax(), f)
3498 } 3477 }
3499} 3478}
3500impl std::fmt::Display for AttrInput { 3479impl std::fmt::Display for Stmt {
3501 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3480 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3502 std::fmt::Display::fmt(self.syntax(), f) 3481 std::fmt::Display::fmt(self.syntax(), f)
3503 } 3482 }
@@ -3727,6 +3706,16 @@ impl std::fmt::Display for ConstParam {
3727 std::fmt::Display::fmt(self.syntax(), f) 3706 std::fmt::Display::fmt(self.syntax(), f)
3728 } 3707 }
3729} 3708}
3709impl std::fmt::Display for Literal {
3710 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3711 std::fmt::Display::fmt(self.syntax(), f)
3712 }
3713}
3714impl std::fmt::Display for TokenTree {
3715 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3716 std::fmt::Display::fmt(self.syntax(), f)
3717 }
3718}
3730impl std::fmt::Display for ParenType { 3719impl std::fmt::Display for ParenType {
3731 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3720 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3732 std::fmt::Display::fmt(self.syntax(), f) 3721 std::fmt::Display::fmt(self.syntax(), f)
@@ -3937,11 +3926,6 @@ impl std::fmt::Display for BinExpr {
3937 std::fmt::Display::fmt(self.syntax(), f) 3926 std::fmt::Display::fmt(self.syntax(), f)
3938 } 3927 }
3939} 3928}
3940impl std::fmt::Display for Literal {
3941 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3942 std::fmt::Display::fmt(self.syntax(), f)
3943 }
3944}
3945impl std::fmt::Display for MatchExpr { 3929impl std::fmt::Display for MatchExpr {
3946 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3930 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3947 std::fmt::Display::fmt(self.syntax(), f) 3931 std::fmt::Display::fmt(self.syntax(), f)
@@ -4062,11 +4046,6 @@ impl std::fmt::Display for TuplePat {
4062 std::fmt::Display::fmt(self.syntax(), f) 4046 std::fmt::Display::fmt(self.syntax(), f)
4063 } 4047 }
4064} 4048}
4065impl std::fmt::Display for TokenTree {
4066 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4067 std::fmt::Display::fmt(self.syntax(), f)
4068 }
4069}
4070impl std::fmt::Display for MacroDef { 4049impl std::fmt::Display for MacroDef {
4071 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4050 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4072 std::fmt::Display::fmt(self.syntax(), f) 4051 std::fmt::Display::fmt(self.syntax(), f)
@@ -4127,8 +4106,3 @@ impl std::fmt::Display for ConstArg {
4127 std::fmt::Display::fmt(self.syntax(), f) 4106 std::fmt::Display::fmt(self.syntax(), f)
4128 } 4107 }
4129} 4108}
4130impl std::fmt::Display for MetaItem {
4131 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4132 std::fmt::Display::fmt(self.syntax(), f)
4133 }
4134}