diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-30 17:39:40 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-30 17:39:40 +0100 |
commit | af8132e610d1e649e67ab797e372d1efcf106c48 (patch) | |
tree | b08fbc93e85f25301ad84a05a3f859ed3edfeb17 /crates/ra_syntax | |
parent | 0f5805541be90a2789b0bc34c5d829042ac3b0ad (diff) | |
parent | 917c89c103597d09e95bdee273633f79123dd19e (diff) |
Merge #5607
5607: Finaize item grammar r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 135 |
1 files changed, 71 insertions, 64 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index ba00742f0..9345a5e8f 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -453,12 +453,23 @@ impl Variant { | |||
453 | pub struct AssocItemList { | 453 | pub struct AssocItemList { |
454 | pub(crate) syntax: SyntaxNode, | 454 | pub(crate) syntax: SyntaxNode, |
455 | } | 455 | } |
456 | impl ast::AttrsOwner for AssocItemList {} | ||
456 | impl AssocItemList { | 457 | impl AssocItemList { |
457 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | 458 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } |
458 | pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } | 459 | pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } |
459 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 460 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
460 | } | 461 | } |
461 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 462 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
463 | pub struct ExternItemList { | ||
464 | pub(crate) syntax: SyntaxNode, | ||
465 | } | ||
466 | impl ast::AttrsOwner for ExternItemList {} | ||
467 | impl ExternItemList { | ||
468 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | ||
469 | pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) } | ||
470 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | ||
471 | } | ||
472 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
462 | pub struct ParenType { | 473 | pub struct ParenType { |
463 | pub(crate) syntax: SyntaxNode, | 474 | pub(crate) syntax: SyntaxNode, |
464 | } | 475 | } |
@@ -1254,15 +1265,6 @@ impl ConstArg { | |||
1254 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | 1265 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } |
1255 | } | 1266 | } |
1256 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1267 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1257 | pub struct ExternItemList { | ||
1258 | pub(crate) syntax: SyntaxNode, | ||
1259 | } | ||
1260 | impl ExternItemList { | ||
1261 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | ||
1262 | pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) } | ||
1263 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | ||
1264 | } | ||
1265 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1266 | pub struct MetaItem { | 1268 | pub struct MetaItem { |
1267 | pub(crate) syntax: SyntaxNode, | 1269 | pub(crate) syntax: SyntaxNode, |
1268 | } | 1270 | } |
@@ -1373,6 +1375,14 @@ pub enum AssocItem { | |||
1373 | impl ast::AttrsOwner for AssocItem {} | 1375 | impl ast::AttrsOwner for AssocItem {} |
1374 | impl ast::NameOwner for AssocItem {} | 1376 | impl ast::NameOwner for AssocItem {} |
1375 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1377 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1378 | pub enum ExternItem { | ||
1379 | Fn(Fn), | ||
1380 | Static(Static), | ||
1381 | MacroCall(MacroCall), | ||
1382 | } | ||
1383 | impl ast::AttrsOwner for ExternItem {} | ||
1384 | impl ast::NameOwner for ExternItem {} | ||
1385 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1376 | pub enum Stmt { | 1386 | pub enum Stmt { |
1377 | LetStmt(LetStmt), | 1387 | LetStmt(LetStmt), |
1378 | ExprStmt(ExprStmt), | 1388 | ExprStmt(ExprStmt), |
@@ -1384,14 +1394,6 @@ pub enum AttrInput { | |||
1384 | TokenTree(TokenTree), | 1394 | TokenTree(TokenTree), |
1385 | } | 1395 | } |
1386 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1396 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1387 | pub enum ExternItem { | ||
1388 | Fn(Fn), | ||
1389 | Static(Static), | ||
1390 | } | ||
1391 | impl ast::AttrsOwner for ExternItem {} | ||
1392 | impl ast::NameOwner for ExternItem {} | ||
1393 | impl ast::VisibilityOwner for ExternItem {} | ||
1394 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1395 | pub enum AdtDef { | 1397 | pub enum AdtDef { |
1396 | Struct(Struct), | 1398 | Struct(Struct), |
1397 | Enum(Enum), | 1399 | Enum(Enum), |
@@ -1841,6 +1843,17 @@ impl AstNode for AssocItemList { | |||
1841 | } | 1843 | } |
1842 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1844 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1843 | } | 1845 | } |
1846 | impl AstNode for ExternItemList { | ||
1847 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } | ||
1848 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1849 | if Self::can_cast(syntax.kind()) { | ||
1850 | Some(Self { syntax }) | ||
1851 | } else { | ||
1852 | None | ||
1853 | } | ||
1854 | } | ||
1855 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1856 | } | ||
1844 | impl AstNode for ParenType { | 1857 | impl AstNode for ParenType { |
1845 | fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } | 1858 | fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } |
1846 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1859 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2754,17 +2767,6 @@ impl AstNode for ConstArg { | |||
2754 | } | 2767 | } |
2755 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2768 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2756 | } | 2769 | } |
2757 | impl AstNode for ExternItemList { | ||
2758 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } | ||
2759 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2760 | if Self::can_cast(syntax.kind()) { | ||
2761 | Some(Self { syntax }) | ||
2762 | } else { | ||
2763 | None | ||
2764 | } | ||
2765 | } | ||
2766 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2767 | } | ||
2768 | impl AstNode for MetaItem { | 2770 | impl AstNode for MetaItem { |
2769 | fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM } | 2771 | fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM } |
2770 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2772 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -3290,6 +3292,39 @@ impl AstNode for AssocItem { | |||
3290 | } | 3292 | } |
3291 | } | 3293 | } |
3292 | } | 3294 | } |
3295 | impl From<Fn> for ExternItem { | ||
3296 | fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) } | ||
3297 | } | ||
3298 | impl From<Static> for ExternItem { | ||
3299 | fn from(node: Static) -> ExternItem { ExternItem::Static(node) } | ||
3300 | } | ||
3301 | impl From<MacroCall> for ExternItem { | ||
3302 | fn from(node: MacroCall) -> ExternItem { ExternItem::MacroCall(node) } | ||
3303 | } | ||
3304 | impl AstNode for ExternItem { | ||
3305 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3306 | match kind { | ||
3307 | FN | STATIC | MACRO_CALL => true, | ||
3308 | _ => false, | ||
3309 | } | ||
3310 | } | ||
3311 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3312 | let res = match syntax.kind() { | ||
3313 | FN => ExternItem::Fn(Fn { syntax }), | ||
3314 | STATIC => ExternItem::Static(Static { syntax }), | ||
3315 | MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }), | ||
3316 | _ => return None, | ||
3317 | }; | ||
3318 | Some(res) | ||
3319 | } | ||
3320 | fn syntax(&self) -> &SyntaxNode { | ||
3321 | match self { | ||
3322 | ExternItem::Fn(it) => &it.syntax, | ||
3323 | ExternItem::Static(it) => &it.syntax, | ||
3324 | ExternItem::MacroCall(it) => &it.syntax, | ||
3325 | } | ||
3326 | } | ||
3327 | } | ||
3293 | impl From<LetStmt> for Stmt { | 3328 | impl From<LetStmt> for Stmt { |
3294 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } | 3329 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } |
3295 | } | 3330 | } |
@@ -3346,34 +3381,6 @@ impl AstNode for AttrInput { | |||
3346 | } | 3381 | } |
3347 | } | 3382 | } |
3348 | } | 3383 | } |
3349 | impl From<Fn> for ExternItem { | ||
3350 | fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) } | ||
3351 | } | ||
3352 | impl From<Static> for ExternItem { | ||
3353 | fn from(node: Static) -> ExternItem { ExternItem::Static(node) } | ||
3354 | } | ||
3355 | impl AstNode for ExternItem { | ||
3356 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3357 | match kind { | ||
3358 | FN | STATIC => true, | ||
3359 | _ => false, | ||
3360 | } | ||
3361 | } | ||
3362 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3363 | let res = match syntax.kind() { | ||
3364 | FN => ExternItem::Fn(Fn { syntax }), | ||
3365 | STATIC => ExternItem::Static(Static { syntax }), | ||
3366 | _ => return None, | ||
3367 | }; | ||
3368 | Some(res) | ||
3369 | } | ||
3370 | fn syntax(&self) -> &SyntaxNode { | ||
3371 | match self { | ||
3372 | ExternItem::Fn(it) => &it.syntax, | ||
3373 | ExternItem::Static(it) => &it.syntax, | ||
3374 | } | ||
3375 | } | ||
3376 | } | ||
3377 | impl From<Struct> for AdtDef { | 3384 | impl From<Struct> for AdtDef { |
3378 | fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } | 3385 | fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } |
3379 | } | 3386 | } |
@@ -3437,17 +3444,17 @@ impl std::fmt::Display for AssocItem { | |||
3437 | std::fmt::Display::fmt(self.syntax(), f) | 3444 | std::fmt::Display::fmt(self.syntax(), f) |
3438 | } | 3445 | } |
3439 | } | 3446 | } |
3440 | impl std::fmt::Display for Stmt { | 3447 | impl std::fmt::Display for ExternItem { |
3441 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3448 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3442 | std::fmt::Display::fmt(self.syntax(), f) | 3449 | std::fmt::Display::fmt(self.syntax(), f) |
3443 | } | 3450 | } |
3444 | } | 3451 | } |
3445 | impl std::fmt::Display for AttrInput { | 3452 | impl std::fmt::Display for Stmt { |
3446 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3453 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3447 | std::fmt::Display::fmt(self.syntax(), f) | 3454 | std::fmt::Display::fmt(self.syntax(), f) |
3448 | } | 3455 | } |
3449 | } | 3456 | } |
3450 | impl std::fmt::Display for ExternItem { | 3457 | impl std::fmt::Display for AttrInput { |
3451 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3458 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3452 | std::fmt::Display::fmt(self.syntax(), f) | 3459 | std::fmt::Display::fmt(self.syntax(), f) |
3453 | } | 3460 | } |
@@ -3657,6 +3664,11 @@ impl std::fmt::Display for AssocItemList { | |||
3657 | std::fmt::Display::fmt(self.syntax(), f) | 3664 | std::fmt::Display::fmt(self.syntax(), f) |
3658 | } | 3665 | } |
3659 | } | 3666 | } |
3667 | impl std::fmt::Display for ExternItemList { | ||
3668 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3669 | std::fmt::Display::fmt(self.syntax(), f) | ||
3670 | } | ||
3671 | } | ||
3660 | impl std::fmt::Display for ParenType { | 3672 | impl std::fmt::Display for ParenType { |
3661 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3673 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3662 | std::fmt::Display::fmt(self.syntax(), f) | 3674 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4072,11 +4084,6 @@ impl std::fmt::Display for ConstArg { | |||
4072 | std::fmt::Display::fmt(self.syntax(), f) | 4084 | std::fmt::Display::fmt(self.syntax(), f) |
4073 | } | 4085 | } |
4074 | } | 4086 | } |
4075 | impl std::fmt::Display for ExternItemList { | ||
4076 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4077 | std::fmt::Display::fmt(self.syntax(), f) | ||
4078 | } | ||
4079 | } | ||
4080 | impl std::fmt::Display for MetaItem { | 4087 | impl std::fmt::Display for MetaItem { |
4081 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4088 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4082 | std::fmt::Display::fmt(self.syntax(), f) | 4089 | std::fmt::Display::fmt(self.syntax(), f) |