diff options
author | Aleksey Kladov <[email protected]> | 2020-07-30 11:26:57 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-30 11:31:07 +0100 |
commit | d032f872b619c651dc66bfd669ef783108fc122c (patch) | |
tree | cca9681e786c4fb1ef64b5b910abab47a7c83c6c /crates/ra_syntax | |
parent | 570fdf26c90758c04b90fadfe1b0e6ee684c6dbe (diff) |
Finish extern crates grammar
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 01e8111b0..3fd761367 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -65,12 +65,12 @@ impl ExternBlock { | |||
65 | pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) } | 65 | pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) } |
66 | } | 66 | } |
67 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 67 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
68 | pub struct ExternCrateItem { | 68 | pub struct ExternCrate { |
69 | pub(crate) syntax: SyntaxNode, | 69 | pub(crate) syntax: SyntaxNode, |
70 | } | 70 | } |
71 | impl ast::AttrsOwner for ExternCrateItem {} | 71 | impl ast::AttrsOwner for ExternCrate {} |
72 | impl ast::VisibilityOwner for ExternCrateItem {} | 72 | impl ast::VisibilityOwner for ExternCrate {} |
73 | impl ExternCrateItem { | 73 | impl ExternCrate { |
74 | pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) } | 74 | pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) } |
75 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | 75 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } |
76 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 76 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
@@ -255,6 +255,21 @@ impl ItemList { | |||
255 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 255 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
256 | } | 256 | } |
257 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 257 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
258 | pub struct NameRef { | ||
259 | pub(crate) syntax: SyntaxNode, | ||
260 | } | ||
261 | impl NameRef { | ||
262 | pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } | ||
263 | } | ||
264 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
265 | pub struct Rename { | ||
266 | pub(crate) syntax: SyntaxNode, | ||
267 | } | ||
268 | impl ast::NameOwner for Rename {} | ||
269 | impl Rename { | ||
270 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } | ||
271 | } | ||
272 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
258 | pub struct Abi { | 273 | pub struct Abi { |
259 | pub(crate) syntax: SyntaxNode, | 274 | pub(crate) syntax: SyntaxNode, |
260 | } | 275 | } |
@@ -699,13 +714,6 @@ impl MethodCallExpr { | |||
699 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } | 714 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } |
700 | } | 715 | } |
701 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 716 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
702 | pub struct NameRef { | ||
703 | pub(crate) syntax: SyntaxNode, | ||
704 | } | ||
705 | impl NameRef { | ||
706 | pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } | ||
707 | } | ||
708 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
709 | pub struct TypeArgList { | 717 | pub struct TypeArgList { |
710 | pub(crate) syntax: SyntaxNode, | 718 | pub(crate) syntax: SyntaxNode, |
711 | } | 719 | } |
@@ -1190,14 +1198,6 @@ impl UseTreeList { | |||
1190 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 1198 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
1191 | } | 1199 | } |
1192 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1200 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1193 | pub struct Rename { | ||
1194 | pub(crate) syntax: SyntaxNode, | ||
1195 | } | ||
1196 | impl ast::NameOwner for Rename {} | ||
1197 | impl Rename { | ||
1198 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } | ||
1199 | } | ||
1200 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1201 | pub struct PathSegment { | 1201 | pub struct PathSegment { |
1202 | pub(crate) syntax: SyntaxNode, | 1202 | pub(crate) syntax: SyntaxNode, |
1203 | } | 1203 | } |
@@ -1272,7 +1272,7 @@ pub enum Item { | |||
1272 | ConstDef(ConstDef), | 1272 | ConstDef(ConstDef), |
1273 | EnumDef(EnumDef), | 1273 | EnumDef(EnumDef), |
1274 | ExternBlock(ExternBlock), | 1274 | ExternBlock(ExternBlock), |
1275 | ExternCrateItem(ExternCrateItem), | 1275 | ExternCrate(ExternCrate), |
1276 | FnDef(FnDef), | 1276 | FnDef(FnDef), |
1277 | ImplDef(ImplDef), | 1277 | ImplDef(ImplDef), |
1278 | MacroCall(MacroCall), | 1278 | MacroCall(MacroCall), |
@@ -1451,8 +1451,8 @@ impl AstNode for ExternBlock { | |||
1451 | } | 1451 | } |
1452 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1452 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1453 | } | 1453 | } |
1454 | impl AstNode for ExternCrateItem { | 1454 | impl AstNode for ExternCrate { |
1455 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM } | 1455 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE } |
1456 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1456 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1457 | if Self::can_cast(syntax.kind()) { | 1457 | if Self::can_cast(syntax.kind()) { |
1458 | Some(Self { syntax }) | 1458 | Some(Self { syntax }) |
@@ -1605,6 +1605,28 @@ impl AstNode for ItemList { | |||
1605 | } | 1605 | } |
1606 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1606 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1607 | } | 1607 | } |
1608 | impl AstNode for NameRef { | ||
1609 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } | ||
1610 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1611 | if Self::can_cast(syntax.kind()) { | ||
1612 | Some(Self { syntax }) | ||
1613 | } else { | ||
1614 | None | ||
1615 | } | ||
1616 | } | ||
1617 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1618 | } | ||
1619 | impl AstNode for Rename { | ||
1620 | fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } | ||
1621 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1622 | if Self::can_cast(syntax.kind()) { | ||
1623 | Some(Self { syntax }) | ||
1624 | } else { | ||
1625 | None | ||
1626 | } | ||
1627 | } | ||
1628 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1629 | } | ||
1608 | impl AstNode for Abi { | 1630 | impl AstNode for Abi { |
1609 | fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } | 1631 | fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } |
1610 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1632 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2111,17 +2133,6 @@ impl AstNode for MethodCallExpr { | |||
2111 | } | 2133 | } |
2112 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2134 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2113 | } | 2135 | } |
2114 | impl AstNode for NameRef { | ||
2115 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } | ||
2116 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2117 | if Self::can_cast(syntax.kind()) { | ||
2118 | Some(Self { syntax }) | ||
2119 | } else { | ||
2120 | None | ||
2121 | } | ||
2122 | } | ||
2123 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2124 | } | ||
2125 | impl AstNode for TypeArgList { | 2136 | impl AstNode for TypeArgList { |
2126 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } | 2137 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } |
2127 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2138 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2683,17 +2694,6 @@ impl AstNode for UseTreeList { | |||
2683 | } | 2694 | } |
2684 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2695 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2685 | } | 2696 | } |
2686 | impl AstNode for Rename { | ||
2687 | fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } | ||
2688 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2689 | if Self::can_cast(syntax.kind()) { | ||
2690 | Some(Self { syntax }) | ||
2691 | } else { | ||
2692 | None | ||
2693 | } | ||
2694 | } | ||
2695 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2696 | } | ||
2697 | impl AstNode for PathSegment { | 2697 | impl AstNode for PathSegment { |
2698 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | 2698 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } |
2699 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2699 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2780,8 +2780,8 @@ impl From<EnumDef> for Item { | |||
2780 | impl From<ExternBlock> for Item { | 2780 | impl From<ExternBlock> for Item { |
2781 | fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } | 2781 | fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } |
2782 | } | 2782 | } |
2783 | impl From<ExternCrateItem> for Item { | 2783 | impl From<ExternCrate> for Item { |
2784 | fn from(node: ExternCrateItem) -> Item { Item::ExternCrateItem(node) } | 2784 | fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } |
2785 | } | 2785 | } |
2786 | impl From<FnDef> for Item { | 2786 | impl From<FnDef> for Item { |
2787 | fn from(node: FnDef) -> Item { Item::FnDef(node) } | 2787 | fn from(node: FnDef) -> Item { Item::FnDef(node) } |
@@ -2816,9 +2816,9 @@ impl From<UseItem> for Item { | |||
2816 | impl AstNode for Item { | 2816 | impl AstNode for Item { |
2817 | fn can_cast(kind: SyntaxKind) -> bool { | 2817 | fn can_cast(kind: SyntaxKind) -> bool { |
2818 | match kind { | 2818 | match kind { |
2819 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE_ITEM | FN_DEF | IMPL_DEF | 2819 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL |
2820 | | MACRO_CALL | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | 2820 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF |
2821 | | UNION_DEF | USE_ITEM => true, | 2821 | | USE_ITEM => true, |
2822 | _ => false, | 2822 | _ => false, |
2823 | } | 2823 | } |
2824 | } | 2824 | } |
@@ -2827,7 +2827,7 @@ impl AstNode for Item { | |||
2827 | CONST_DEF => Item::ConstDef(ConstDef { syntax }), | 2827 | CONST_DEF => Item::ConstDef(ConstDef { syntax }), |
2828 | ENUM_DEF => Item::EnumDef(EnumDef { syntax }), | 2828 | ENUM_DEF => Item::EnumDef(EnumDef { syntax }), |
2829 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), | 2829 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), |
2830 | EXTERN_CRATE_ITEM => Item::ExternCrateItem(ExternCrateItem { syntax }), | 2830 | EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), |
2831 | FN_DEF => Item::FnDef(FnDef { syntax }), | 2831 | FN_DEF => Item::FnDef(FnDef { syntax }), |
2832 | IMPL_DEF => Item::ImplDef(ImplDef { syntax }), | 2832 | IMPL_DEF => Item::ImplDef(ImplDef { syntax }), |
2833 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), | 2833 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), |
@@ -2847,7 +2847,7 @@ impl AstNode for Item { | |||
2847 | Item::ConstDef(it) => &it.syntax, | 2847 | Item::ConstDef(it) => &it.syntax, |
2848 | Item::EnumDef(it) => &it.syntax, | 2848 | Item::EnumDef(it) => &it.syntax, |
2849 | Item::ExternBlock(it) => &it.syntax, | 2849 | Item::ExternBlock(it) => &it.syntax, |
2850 | Item::ExternCrateItem(it) => &it.syntax, | 2850 | Item::ExternCrate(it) => &it.syntax, |
2851 | Item::FnDef(it) => &it.syntax, | 2851 | Item::FnDef(it) => &it.syntax, |
2852 | Item::ImplDef(it) => &it.syntax, | 2852 | Item::ImplDef(it) => &it.syntax, |
2853 | Item::MacroCall(it) => &it.syntax, | 2853 | Item::MacroCall(it) => &it.syntax, |
@@ -3480,7 +3480,7 @@ impl std::fmt::Display for ExternBlock { | |||
3480 | std::fmt::Display::fmt(self.syntax(), f) | 3480 | std::fmt::Display::fmt(self.syntax(), f) |
3481 | } | 3481 | } |
3482 | } | 3482 | } |
3483 | impl std::fmt::Display for ExternCrateItem { | 3483 | impl std::fmt::Display for ExternCrate { |
3484 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3484 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3485 | std::fmt::Display::fmt(self.syntax(), f) | 3485 | std::fmt::Display::fmt(self.syntax(), f) |
3486 | } | 3486 | } |
@@ -3550,6 +3550,16 @@ impl std::fmt::Display for ItemList { | |||
3550 | std::fmt::Display::fmt(self.syntax(), f) | 3550 | std::fmt::Display::fmt(self.syntax(), f) |
3551 | } | 3551 | } |
3552 | } | 3552 | } |
3553 | impl std::fmt::Display for NameRef { | ||
3554 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3555 | std::fmt::Display::fmt(self.syntax(), f) | ||
3556 | } | ||
3557 | } | ||
3558 | impl std::fmt::Display for Rename { | ||
3559 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3560 | std::fmt::Display::fmt(self.syntax(), f) | ||
3561 | } | ||
3562 | } | ||
3553 | impl std::fmt::Display for Abi { | 3563 | impl std::fmt::Display for Abi { |
3554 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3564 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3555 | std::fmt::Display::fmt(self.syntax(), f) | 3565 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3780,11 +3790,6 @@ impl std::fmt::Display for MethodCallExpr { | |||
3780 | std::fmt::Display::fmt(self.syntax(), f) | 3790 | std::fmt::Display::fmt(self.syntax(), f) |
3781 | } | 3791 | } |
3782 | } | 3792 | } |
3783 | impl std::fmt::Display for NameRef { | ||
3784 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3785 | std::fmt::Display::fmt(self.syntax(), f) | ||
3786 | } | ||
3787 | } | ||
3788 | impl std::fmt::Display for TypeArgList { | 3793 | impl std::fmt::Display for TypeArgList { |
3789 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3794 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3790 | std::fmt::Display::fmt(self.syntax(), f) | 3795 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4040,11 +4045,6 @@ impl std::fmt::Display for UseTreeList { | |||
4040 | std::fmt::Display::fmt(self.syntax(), f) | 4045 | std::fmt::Display::fmt(self.syntax(), f) |
4041 | } | 4046 | } |
4042 | } | 4047 | } |
4043 | impl std::fmt::Display for Rename { | ||
4044 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4045 | std::fmt::Display::fmt(self.syntax(), f) | ||
4046 | } | ||
4047 | } | ||
4048 | impl std::fmt::Display for PathSegment { | 4048 | impl std::fmt::Display for PathSegment { |
4049 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4049 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4050 | std::fmt::Display::fmt(self.syntax(), f) | 4050 | std::fmt::Display::fmt(self.syntax(), f) |