diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/generated')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 519 |
1 files changed, 259 insertions, 260 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 132c2ae8c..97a882bf0 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -106,8 +106,7 @@ pub struct ConstArg { | |||
106 | pub(crate) syntax: SyntaxNode, | 106 | pub(crate) syntax: SyntaxNode, |
107 | } | 107 | } |
108 | impl ConstArg { | 108 | impl ConstArg { |
109 | pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } | 109 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
110 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | ||
111 | } | 110 | } |
112 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 111 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
113 | pub struct TypeBoundList { | 112 | pub struct TypeBoundList { |
@@ -117,23 +116,6 @@ impl TypeBoundList { | |||
117 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | 116 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } |
118 | } | 117 | } |
119 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 118 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
120 | pub struct Literal { | ||
121 | pub(crate) syntax: SyntaxNode, | ||
122 | } | ||
123 | impl ast::AttrsOwner for Literal {} | ||
124 | impl Literal {} | ||
125 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
126 | pub struct BlockExpr { | ||
127 | pub(crate) syntax: SyntaxNode, | ||
128 | } | ||
129 | impl ast::AttrsOwner for BlockExpr {} | ||
130 | impl BlockExpr { | ||
131 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | ||
132 | pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } | ||
133 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
134 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | ||
135 | } | ||
136 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
137 | pub struct SourceFile { | 119 | pub struct SourceFile { |
138 | pub(crate) syntax: SyntaxNode, | 120 | pub(crate) syntax: SyntaxNode, |
139 | } | 121 | } |
@@ -437,6 +419,17 @@ impl WhereClause { | |||
437 | pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } | 419 | pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } |
438 | } | 420 | } |
439 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 421 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
422 | pub struct BlockExpr { | ||
423 | pub(crate) syntax: SyntaxNode, | ||
424 | } | ||
425 | impl ast::AttrsOwner for BlockExpr {} | ||
426 | impl BlockExpr { | ||
427 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | ||
428 | pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } | ||
429 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
430 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | ||
431 | } | ||
432 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
440 | pub struct SelfParam { | 433 | pub struct SelfParam { |
441 | pub(crate) syntax: SyntaxNode, | 434 | pub(crate) syntax: SyntaxNode, |
442 | } | 435 | } |
@@ -590,6 +583,12 @@ impl WherePred { | |||
590 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | 583 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
591 | } | 584 | } |
592 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 585 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
586 | pub struct Literal { | ||
587 | pub(crate) syntax: SyntaxNode, | ||
588 | } | ||
589 | impl ast::AttrsOwner for Literal {} | ||
590 | impl Literal {} | ||
591 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
593 | pub struct TokenTree { | 592 | pub struct TokenTree { |
594 | pub(crate) syntax: SyntaxNode, | 593 | pub(crate) syntax: SyntaxNode, |
595 | } | 594 | } |
@@ -1292,6 +1291,39 @@ pub enum Type { | |||
1292 | TupleType(TupleType), | 1291 | TupleType(TupleType), |
1293 | } | 1292 | } |
1294 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1293 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1294 | pub enum Expr { | ||
1295 | ArrayExpr(ArrayExpr), | ||
1296 | AwaitExpr(AwaitExpr), | ||
1297 | BinExpr(BinExpr), | ||
1298 | BlockExpr(BlockExpr), | ||
1299 | BoxExpr(BoxExpr), | ||
1300 | BreakExpr(BreakExpr), | ||
1301 | CallExpr(CallExpr), | ||
1302 | CastExpr(CastExpr), | ||
1303 | ClosureExpr(ClosureExpr), | ||
1304 | ContinueExpr(ContinueExpr), | ||
1305 | EffectExpr(EffectExpr), | ||
1306 | FieldExpr(FieldExpr), | ||
1307 | ForExpr(ForExpr), | ||
1308 | IfExpr(IfExpr), | ||
1309 | IndexExpr(IndexExpr), | ||
1310 | Literal(Literal), | ||
1311 | LoopExpr(LoopExpr), | ||
1312 | MacroCall(MacroCall), | ||
1313 | MatchExpr(MatchExpr), | ||
1314 | MethodCallExpr(MethodCallExpr), | ||
1315 | ParenExpr(ParenExpr), | ||
1316 | PathExpr(PathExpr), | ||
1317 | PrefixExpr(PrefixExpr), | ||
1318 | RangeExpr(RangeExpr), | ||
1319 | RecordExpr(RecordExpr), | ||
1320 | RefExpr(RefExpr), | ||
1321 | ReturnExpr(ReturnExpr), | ||
1322 | TryExpr(TryExpr), | ||
1323 | TupleExpr(TupleExpr), | ||
1324 | WhileExpr(WhileExpr), | ||
1325 | } | ||
1326 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1295 | pub enum Item { | 1327 | pub enum Item { |
1296 | Const(Const), | 1328 | Const(Const), |
1297 | Enum(Enum), | 1329 | Enum(Enum), |
@@ -1333,39 +1365,6 @@ pub enum FieldList { | |||
1333 | TupleFieldList(TupleFieldList), | 1365 | TupleFieldList(TupleFieldList), |
1334 | } | 1366 | } |
1335 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1367 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1336 | pub enum Expr { | ||
1337 | ArrayExpr(ArrayExpr), | ||
1338 | AwaitExpr(AwaitExpr), | ||
1339 | BinExpr(BinExpr), | ||
1340 | BlockExpr(BlockExpr), | ||
1341 | BoxExpr(BoxExpr), | ||
1342 | BreakExpr(BreakExpr), | ||
1343 | CallExpr(CallExpr), | ||
1344 | CastExpr(CastExpr), | ||
1345 | ClosureExpr(ClosureExpr), | ||
1346 | ContinueExpr(ContinueExpr), | ||
1347 | EffectExpr(EffectExpr), | ||
1348 | FieldExpr(FieldExpr), | ||
1349 | ForExpr(ForExpr), | ||
1350 | IfExpr(IfExpr), | ||
1351 | IndexExpr(IndexExpr), | ||
1352 | Literal(Literal), | ||
1353 | LoopExpr(LoopExpr), | ||
1354 | MacroCall(MacroCall), | ||
1355 | MatchExpr(MatchExpr), | ||
1356 | MethodCallExpr(MethodCallExpr), | ||
1357 | ParenExpr(ParenExpr), | ||
1358 | PathExpr(PathExpr), | ||
1359 | PrefixExpr(PrefixExpr), | ||
1360 | RangeExpr(RangeExpr), | ||
1361 | RecordExpr(RecordExpr), | ||
1362 | RefExpr(RefExpr), | ||
1363 | ReturnExpr(ReturnExpr), | ||
1364 | TryExpr(TryExpr), | ||
1365 | TupleExpr(TupleExpr), | ||
1366 | WhileExpr(WhileExpr), | ||
1367 | } | ||
1368 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1369 | pub enum AdtDef { | 1368 | pub enum AdtDef { |
1370 | Enum(Enum), | 1369 | Enum(Enum), |
1371 | Struct(Struct), | 1370 | Struct(Struct), |
@@ -1537,28 +1536,6 @@ impl AstNode for TypeBoundList { | |||
1537 | } | 1536 | } |
1538 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1537 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1539 | } | 1538 | } |
1540 | impl AstNode for Literal { | ||
1541 | fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } | ||
1542 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1543 | if Self::can_cast(syntax.kind()) { | ||
1544 | Some(Self { syntax }) | ||
1545 | } else { | ||
1546 | None | ||
1547 | } | ||
1548 | } | ||
1549 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1550 | } | ||
1551 | impl AstNode for BlockExpr { | ||
1552 | fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } | ||
1553 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1554 | if Self::can_cast(syntax.kind()) { | ||
1555 | Some(Self { syntax }) | ||
1556 | } else { | ||
1557 | None | ||
1558 | } | ||
1559 | } | ||
1560 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1561 | } | ||
1562 | impl AstNode for SourceFile { | 1539 | impl AstNode for SourceFile { |
1563 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } | 1540 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } |
1564 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1541 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1834,6 +1811,17 @@ impl AstNode for WhereClause { | |||
1834 | } | 1811 | } |
1835 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1812 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1836 | } | 1813 | } |
1814 | impl AstNode for BlockExpr { | ||
1815 | fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } | ||
1816 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1817 | if Self::can_cast(syntax.kind()) { | ||
1818 | Some(Self { syntax }) | ||
1819 | } else { | ||
1820 | None | ||
1821 | } | ||
1822 | } | ||
1823 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1824 | } | ||
1837 | impl AstNode for SelfParam { | 1825 | impl AstNode for SelfParam { |
1838 | fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } | 1826 | fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } |
1839 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1827 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1988,6 +1976,17 @@ impl AstNode for WherePred { | |||
1988 | } | 1976 | } |
1989 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1977 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1990 | } | 1978 | } |
1979 | impl AstNode for Literal { | ||
1980 | fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } | ||
1981 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1982 | if Self::can_cast(syntax.kind()) { | ||
1983 | Some(Self { syntax }) | ||
1984 | } else { | ||
1985 | None | ||
1986 | } | ||
1987 | } | ||
1988 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1989 | } | ||
1991 | impl AstNode for TokenTree { | 1990 | impl AstNode for TokenTree { |
1992 | fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } | 1991 | fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } |
1993 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1992 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2892,6 +2891,178 @@ impl AstNode for Type { | |||
2892 | } | 2891 | } |
2893 | } | 2892 | } |
2894 | } | 2893 | } |
2894 | impl From<ArrayExpr> for Expr { | ||
2895 | fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } | ||
2896 | } | ||
2897 | impl From<AwaitExpr> for Expr { | ||
2898 | fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) } | ||
2899 | } | ||
2900 | impl From<BinExpr> for Expr { | ||
2901 | fn from(node: BinExpr) -> Expr { Expr::BinExpr(node) } | ||
2902 | } | ||
2903 | impl From<BlockExpr> for Expr { | ||
2904 | fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) } | ||
2905 | } | ||
2906 | impl From<BoxExpr> for Expr { | ||
2907 | fn from(node: BoxExpr) -> Expr { Expr::BoxExpr(node) } | ||
2908 | } | ||
2909 | impl From<BreakExpr> for Expr { | ||
2910 | fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) } | ||
2911 | } | ||
2912 | impl From<CallExpr> for Expr { | ||
2913 | fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } | ||
2914 | } | ||
2915 | impl From<CastExpr> for Expr { | ||
2916 | fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) } | ||
2917 | } | ||
2918 | impl From<ClosureExpr> for Expr { | ||
2919 | fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) } | ||
2920 | } | ||
2921 | impl From<ContinueExpr> for Expr { | ||
2922 | fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } | ||
2923 | } | ||
2924 | impl From<EffectExpr> for Expr { | ||
2925 | fn from(node: EffectExpr) -> Expr { Expr::EffectExpr(node) } | ||
2926 | } | ||
2927 | impl From<FieldExpr> for Expr { | ||
2928 | fn from(node: FieldExpr) -> Expr { Expr::FieldExpr(node) } | ||
2929 | } | ||
2930 | impl From<ForExpr> for Expr { | ||
2931 | fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) } | ||
2932 | } | ||
2933 | impl From<IfExpr> for Expr { | ||
2934 | fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) } | ||
2935 | } | ||
2936 | impl From<IndexExpr> for Expr { | ||
2937 | fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) } | ||
2938 | } | ||
2939 | impl From<Literal> for Expr { | ||
2940 | fn from(node: Literal) -> Expr { Expr::Literal(node) } | ||
2941 | } | ||
2942 | impl From<LoopExpr> for Expr { | ||
2943 | fn from(node: LoopExpr) -> Expr { Expr::LoopExpr(node) } | ||
2944 | } | ||
2945 | impl From<MacroCall> for Expr { | ||
2946 | fn from(node: MacroCall) -> Expr { Expr::MacroCall(node) } | ||
2947 | } | ||
2948 | impl From<MatchExpr> for Expr { | ||
2949 | fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } | ||
2950 | } | ||
2951 | impl From<MethodCallExpr> for Expr { | ||
2952 | fn from(node: MethodCallExpr) -> Expr { Expr::MethodCallExpr(node) } | ||
2953 | } | ||
2954 | impl From<ParenExpr> for Expr { | ||
2955 | fn from(node: ParenExpr) -> Expr { Expr::ParenExpr(node) } | ||
2956 | } | ||
2957 | impl From<PathExpr> for Expr { | ||
2958 | fn from(node: PathExpr) -> Expr { Expr::PathExpr(node) } | ||
2959 | } | ||
2960 | impl From<PrefixExpr> for Expr { | ||
2961 | fn from(node: PrefixExpr) -> Expr { Expr::PrefixExpr(node) } | ||
2962 | } | ||
2963 | impl From<RangeExpr> for Expr { | ||
2964 | fn from(node: RangeExpr) -> Expr { Expr::RangeExpr(node) } | ||
2965 | } | ||
2966 | impl From<RecordExpr> for Expr { | ||
2967 | fn from(node: RecordExpr) -> Expr { Expr::RecordExpr(node) } | ||
2968 | } | ||
2969 | impl From<RefExpr> for Expr { | ||
2970 | fn from(node: RefExpr) -> Expr { Expr::RefExpr(node) } | ||
2971 | } | ||
2972 | impl From<ReturnExpr> for Expr { | ||
2973 | fn from(node: ReturnExpr) -> Expr { Expr::ReturnExpr(node) } | ||
2974 | } | ||
2975 | impl From<TryExpr> for Expr { | ||
2976 | fn from(node: TryExpr) -> Expr { Expr::TryExpr(node) } | ||
2977 | } | ||
2978 | impl From<TupleExpr> for Expr { | ||
2979 | fn from(node: TupleExpr) -> Expr { Expr::TupleExpr(node) } | ||
2980 | } | ||
2981 | impl From<WhileExpr> for Expr { | ||
2982 | fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) } | ||
2983 | } | ||
2984 | impl AstNode for Expr { | ||
2985 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2986 | match kind { | ||
2987 | ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR | ||
2988 | | CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR | ||
2989 | | IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR | ||
2990 | | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR | ||
2991 | | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true, | ||
2992 | _ => false, | ||
2993 | } | ||
2994 | } | ||
2995 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2996 | let res = match syntax.kind() { | ||
2997 | ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }), | ||
2998 | AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }), | ||
2999 | BIN_EXPR => Expr::BinExpr(BinExpr { syntax }), | ||
3000 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), | ||
3001 | BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }), | ||
3002 | BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }), | ||
3003 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), | ||
3004 | CAST_EXPR => Expr::CastExpr(CastExpr { syntax }), | ||
3005 | CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }), | ||
3006 | CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }), | ||
3007 | EFFECT_EXPR => Expr::EffectExpr(EffectExpr { syntax }), | ||
3008 | FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }), | ||
3009 | FOR_EXPR => Expr::ForExpr(ForExpr { syntax }), | ||
3010 | IF_EXPR => Expr::IfExpr(IfExpr { syntax }), | ||
3011 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), | ||
3012 | LITERAL => Expr::Literal(Literal { syntax }), | ||
3013 | LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }), | ||
3014 | MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), | ||
3015 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), | ||
3016 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), | ||
3017 | PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }), | ||
3018 | PATH_EXPR => Expr::PathExpr(PathExpr { syntax }), | ||
3019 | PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }), | ||
3020 | RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }), | ||
3021 | RECORD_EXPR => Expr::RecordExpr(RecordExpr { syntax }), | ||
3022 | REF_EXPR => Expr::RefExpr(RefExpr { syntax }), | ||
3023 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), | ||
3024 | TRY_EXPR => Expr::TryExpr(TryExpr { syntax }), | ||
3025 | TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }), | ||
3026 | WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }), | ||
3027 | _ => return None, | ||
3028 | }; | ||
3029 | Some(res) | ||
3030 | } | ||
3031 | fn syntax(&self) -> &SyntaxNode { | ||
3032 | match self { | ||
3033 | Expr::ArrayExpr(it) => &it.syntax, | ||
3034 | Expr::AwaitExpr(it) => &it.syntax, | ||
3035 | Expr::BinExpr(it) => &it.syntax, | ||
3036 | Expr::BlockExpr(it) => &it.syntax, | ||
3037 | Expr::BoxExpr(it) => &it.syntax, | ||
3038 | Expr::BreakExpr(it) => &it.syntax, | ||
3039 | Expr::CallExpr(it) => &it.syntax, | ||
3040 | Expr::CastExpr(it) => &it.syntax, | ||
3041 | Expr::ClosureExpr(it) => &it.syntax, | ||
3042 | Expr::ContinueExpr(it) => &it.syntax, | ||
3043 | Expr::EffectExpr(it) => &it.syntax, | ||
3044 | Expr::FieldExpr(it) => &it.syntax, | ||
3045 | Expr::ForExpr(it) => &it.syntax, | ||
3046 | Expr::IfExpr(it) => &it.syntax, | ||
3047 | Expr::IndexExpr(it) => &it.syntax, | ||
3048 | Expr::Literal(it) => &it.syntax, | ||
3049 | Expr::LoopExpr(it) => &it.syntax, | ||
3050 | Expr::MacroCall(it) => &it.syntax, | ||
3051 | Expr::MatchExpr(it) => &it.syntax, | ||
3052 | Expr::MethodCallExpr(it) => &it.syntax, | ||
3053 | Expr::ParenExpr(it) => &it.syntax, | ||
3054 | Expr::PathExpr(it) => &it.syntax, | ||
3055 | Expr::PrefixExpr(it) => &it.syntax, | ||
3056 | Expr::RangeExpr(it) => &it.syntax, | ||
3057 | Expr::RecordExpr(it) => &it.syntax, | ||
3058 | Expr::RefExpr(it) => &it.syntax, | ||
3059 | Expr::ReturnExpr(it) => &it.syntax, | ||
3060 | Expr::TryExpr(it) => &it.syntax, | ||
3061 | Expr::TupleExpr(it) => &it.syntax, | ||
3062 | Expr::WhileExpr(it) => &it.syntax, | ||
3063 | } | ||
3064 | } | ||
3065 | } | ||
2895 | impl From<Const> for Item { | 3066 | impl From<Const> for Item { |
2896 | fn from(node: Const) -> Item { Item::Const(node) } | 3067 | fn from(node: Const) -> Item { Item::Const(node) } |
2897 | } | 3068 | } |
@@ -3104,178 +3275,6 @@ impl AstNode for FieldList { | |||
3104 | } | 3275 | } |
3105 | } | 3276 | } |
3106 | } | 3277 | } |
3107 | impl From<ArrayExpr> for Expr { | ||
3108 | fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } | ||
3109 | } | ||
3110 | impl From<AwaitExpr> for Expr { | ||
3111 | fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) } | ||
3112 | } | ||
3113 | impl From<BinExpr> for Expr { | ||
3114 | fn from(node: BinExpr) -> Expr { Expr::BinExpr(node) } | ||
3115 | } | ||
3116 | impl From<BlockExpr> for Expr { | ||
3117 | fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) } | ||
3118 | } | ||
3119 | impl From<BoxExpr> for Expr { | ||
3120 | fn from(node: BoxExpr) -> Expr { Expr::BoxExpr(node) } | ||
3121 | } | ||
3122 | impl From<BreakExpr> for Expr { | ||
3123 | fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) } | ||
3124 | } | ||
3125 | impl From<CallExpr> for Expr { | ||
3126 | fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } | ||
3127 | } | ||
3128 | impl From<CastExpr> for Expr { | ||
3129 | fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) } | ||
3130 | } | ||
3131 | impl From<ClosureExpr> for Expr { | ||
3132 | fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) } | ||
3133 | } | ||
3134 | impl From<ContinueExpr> for Expr { | ||
3135 | fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } | ||
3136 | } | ||
3137 | impl From<EffectExpr> for Expr { | ||
3138 | fn from(node: EffectExpr) -> Expr { Expr::EffectExpr(node) } | ||
3139 | } | ||
3140 | impl From<FieldExpr> for Expr { | ||
3141 | fn from(node: FieldExpr) -> Expr { Expr::FieldExpr(node) } | ||
3142 | } | ||
3143 | impl From<ForExpr> for Expr { | ||
3144 | fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) } | ||
3145 | } | ||
3146 | impl From<IfExpr> for Expr { | ||
3147 | fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) } | ||
3148 | } | ||
3149 | impl From<IndexExpr> for Expr { | ||
3150 | fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) } | ||
3151 | } | ||
3152 | impl From<Literal> for Expr { | ||
3153 | fn from(node: Literal) -> Expr { Expr::Literal(node) } | ||
3154 | } | ||
3155 | impl From<LoopExpr> for Expr { | ||
3156 | fn from(node: LoopExpr) -> Expr { Expr::LoopExpr(node) } | ||
3157 | } | ||
3158 | impl From<MacroCall> for Expr { | ||
3159 | fn from(node: MacroCall) -> Expr { Expr::MacroCall(node) } | ||
3160 | } | ||
3161 | impl From<MatchExpr> for Expr { | ||
3162 | fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } | ||
3163 | } | ||
3164 | impl From<MethodCallExpr> for Expr { | ||
3165 | fn from(node: MethodCallExpr) -> Expr { Expr::MethodCallExpr(node) } | ||
3166 | } | ||
3167 | impl From<ParenExpr> for Expr { | ||
3168 | fn from(node: ParenExpr) -> Expr { Expr::ParenExpr(node) } | ||
3169 | } | ||
3170 | impl From<PathExpr> for Expr { | ||
3171 | fn from(node: PathExpr) -> Expr { Expr::PathExpr(node) } | ||
3172 | } | ||
3173 | impl From<PrefixExpr> for Expr { | ||
3174 | fn from(node: PrefixExpr) -> Expr { Expr::PrefixExpr(node) } | ||
3175 | } | ||
3176 | impl From<RangeExpr> for Expr { | ||
3177 | fn from(node: RangeExpr) -> Expr { Expr::RangeExpr(node) } | ||
3178 | } | ||
3179 | impl From<RecordExpr> for Expr { | ||
3180 | fn from(node: RecordExpr) -> Expr { Expr::RecordExpr(node) } | ||
3181 | } | ||
3182 | impl From<RefExpr> for Expr { | ||
3183 | fn from(node: RefExpr) -> Expr { Expr::RefExpr(node) } | ||
3184 | } | ||
3185 | impl From<ReturnExpr> for Expr { | ||
3186 | fn from(node: ReturnExpr) -> Expr { Expr::ReturnExpr(node) } | ||
3187 | } | ||
3188 | impl From<TryExpr> for Expr { | ||
3189 | fn from(node: TryExpr) -> Expr { Expr::TryExpr(node) } | ||
3190 | } | ||
3191 | impl From<TupleExpr> for Expr { | ||
3192 | fn from(node: TupleExpr) -> Expr { Expr::TupleExpr(node) } | ||
3193 | } | ||
3194 | impl From<WhileExpr> for Expr { | ||
3195 | fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) } | ||
3196 | } | ||
3197 | impl AstNode for Expr { | ||
3198 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3199 | match kind { | ||
3200 | ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR | ||
3201 | | CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR | ||
3202 | | IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR | ||
3203 | | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR | ||
3204 | | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true, | ||
3205 | _ => false, | ||
3206 | } | ||
3207 | } | ||
3208 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3209 | let res = match syntax.kind() { | ||
3210 | ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }), | ||
3211 | AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }), | ||
3212 | BIN_EXPR => Expr::BinExpr(BinExpr { syntax }), | ||
3213 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), | ||
3214 | BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }), | ||
3215 | BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }), | ||
3216 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), | ||
3217 | CAST_EXPR => Expr::CastExpr(CastExpr { syntax }), | ||
3218 | CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }), | ||
3219 | CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }), | ||
3220 | EFFECT_EXPR => Expr::EffectExpr(EffectExpr { syntax }), | ||
3221 | FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }), | ||
3222 | FOR_EXPR => Expr::ForExpr(ForExpr { syntax }), | ||
3223 | IF_EXPR => Expr::IfExpr(IfExpr { syntax }), | ||
3224 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), | ||
3225 | LITERAL => Expr::Literal(Literal { syntax }), | ||
3226 | LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }), | ||
3227 | MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), | ||
3228 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), | ||
3229 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), | ||
3230 | PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }), | ||
3231 | PATH_EXPR => Expr::PathExpr(PathExpr { syntax }), | ||
3232 | PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }), | ||
3233 | RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }), | ||
3234 | RECORD_EXPR => Expr::RecordExpr(RecordExpr { syntax }), | ||
3235 | REF_EXPR => Expr::RefExpr(RefExpr { syntax }), | ||
3236 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), | ||
3237 | TRY_EXPR => Expr::TryExpr(TryExpr { syntax }), | ||
3238 | TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }), | ||
3239 | WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }), | ||
3240 | _ => return None, | ||
3241 | }; | ||
3242 | Some(res) | ||
3243 | } | ||
3244 | fn syntax(&self) -> &SyntaxNode { | ||
3245 | match self { | ||
3246 | Expr::ArrayExpr(it) => &it.syntax, | ||
3247 | Expr::AwaitExpr(it) => &it.syntax, | ||
3248 | Expr::BinExpr(it) => &it.syntax, | ||
3249 | Expr::BlockExpr(it) => &it.syntax, | ||
3250 | Expr::BoxExpr(it) => &it.syntax, | ||
3251 | Expr::BreakExpr(it) => &it.syntax, | ||
3252 | Expr::CallExpr(it) => &it.syntax, | ||
3253 | Expr::CastExpr(it) => &it.syntax, | ||
3254 | Expr::ClosureExpr(it) => &it.syntax, | ||
3255 | Expr::ContinueExpr(it) => &it.syntax, | ||
3256 | Expr::EffectExpr(it) => &it.syntax, | ||
3257 | Expr::FieldExpr(it) => &it.syntax, | ||
3258 | Expr::ForExpr(it) => &it.syntax, | ||
3259 | Expr::IfExpr(it) => &it.syntax, | ||
3260 | Expr::IndexExpr(it) => &it.syntax, | ||
3261 | Expr::Literal(it) => &it.syntax, | ||
3262 | Expr::LoopExpr(it) => &it.syntax, | ||
3263 | Expr::MacroCall(it) => &it.syntax, | ||
3264 | Expr::MatchExpr(it) => &it.syntax, | ||
3265 | Expr::MethodCallExpr(it) => &it.syntax, | ||
3266 | Expr::ParenExpr(it) => &it.syntax, | ||
3267 | Expr::PathExpr(it) => &it.syntax, | ||
3268 | Expr::PrefixExpr(it) => &it.syntax, | ||
3269 | Expr::RangeExpr(it) => &it.syntax, | ||
3270 | Expr::RecordExpr(it) => &it.syntax, | ||
3271 | Expr::RefExpr(it) => &it.syntax, | ||
3272 | Expr::ReturnExpr(it) => &it.syntax, | ||
3273 | Expr::TryExpr(it) => &it.syntax, | ||
3274 | Expr::TupleExpr(it) => &it.syntax, | ||
3275 | Expr::WhileExpr(it) => &it.syntax, | ||
3276 | } | ||
3277 | } | ||
3278 | } | ||
3279 | impl From<Enum> for AdtDef { | 3278 | impl From<Enum> for AdtDef { |
3280 | fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } | 3279 | fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } |
3281 | } | 3280 | } |
@@ -3432,22 +3431,22 @@ impl std::fmt::Display for Type { | |||
3432 | std::fmt::Display::fmt(self.syntax(), f) | 3431 | std::fmt::Display::fmt(self.syntax(), f) |
3433 | } | 3432 | } |
3434 | } | 3433 | } |
3435 | impl std::fmt::Display for Item { | 3434 | impl std::fmt::Display for Expr { |
3436 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3435 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3437 | std::fmt::Display::fmt(self.syntax(), f) | 3436 | std::fmt::Display::fmt(self.syntax(), f) |
3438 | } | 3437 | } |
3439 | } | 3438 | } |
3440 | impl std::fmt::Display for Pat { | 3439 | impl std::fmt::Display for Item { |
3441 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3440 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3442 | std::fmt::Display::fmt(self.syntax(), f) | 3441 | std::fmt::Display::fmt(self.syntax(), f) |
3443 | } | 3442 | } |
3444 | } | 3443 | } |
3445 | impl std::fmt::Display for FieldList { | 3444 | impl std::fmt::Display for Pat { |
3446 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3445 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3447 | std::fmt::Display::fmt(self.syntax(), f) | 3446 | std::fmt::Display::fmt(self.syntax(), f) |
3448 | } | 3447 | } |
3449 | } | 3448 | } |
3450 | impl std::fmt::Display for Expr { | 3449 | impl std::fmt::Display for FieldList { |
3451 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3450 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3452 | std::fmt::Display::fmt(self.syntax(), f) | 3451 | std::fmt::Display::fmt(self.syntax(), f) |
3453 | } | 3452 | } |
@@ -3537,16 +3536,6 @@ impl std::fmt::Display for TypeBoundList { | |||
3537 | std::fmt::Display::fmt(self.syntax(), f) | 3536 | std::fmt::Display::fmt(self.syntax(), f) |
3538 | } | 3537 | } |
3539 | } | 3538 | } |
3540 | impl std::fmt::Display for Literal { | ||
3541 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3542 | std::fmt::Display::fmt(self.syntax(), f) | ||
3543 | } | ||
3544 | } | ||
3545 | impl std::fmt::Display for BlockExpr { | ||
3546 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3547 | std::fmt::Display::fmt(self.syntax(), f) | ||
3548 | } | ||
3549 | } | ||
3550 | impl std::fmt::Display for SourceFile { | 3539 | impl std::fmt::Display for SourceFile { |
3551 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3540 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3552 | std::fmt::Display::fmt(self.syntax(), f) | 3541 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3672,6 +3661,11 @@ impl std::fmt::Display for WhereClause { | |||
3672 | std::fmt::Display::fmt(self.syntax(), f) | 3661 | std::fmt::Display::fmt(self.syntax(), f) |
3673 | } | 3662 | } |
3674 | } | 3663 | } |
3664 | impl std::fmt::Display for BlockExpr { | ||
3665 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3666 | std::fmt::Display::fmt(self.syntax(), f) | ||
3667 | } | ||
3668 | } | ||
3675 | impl std::fmt::Display for SelfParam { | 3669 | impl std::fmt::Display for SelfParam { |
3676 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3670 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3677 | std::fmt::Display::fmt(self.syntax(), f) | 3671 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3742,6 +3736,11 @@ impl std::fmt::Display for WherePred { | |||
3742 | std::fmt::Display::fmt(self.syntax(), f) | 3736 | std::fmt::Display::fmt(self.syntax(), f) |
3743 | } | 3737 | } |
3744 | } | 3738 | } |
3739 | impl std::fmt::Display for Literal { | ||
3740 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3741 | std::fmt::Display::fmt(self.syntax(), f) | ||
3742 | } | ||
3743 | } | ||
3745 | impl std::fmt::Display for TokenTree { | 3744 | impl std::fmt::Display for TokenTree { |
3746 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3745 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3747 | std::fmt::Display::fmt(self.syntax(), f) | 3746 | std::fmt::Display::fmt(self.syntax(), f) |