diff options
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 92 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/node_ext.rs | 2 |
3 files changed, 48 insertions, 50 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 4a67fd44a..0110300af 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -192,9 +192,9 @@ impl ast::RecordFieldList { | |||
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | impl ast::TypeAliasDef { | 195 | impl ast::TypeAlias { |
196 | #[must_use] | 196 | #[must_use] |
197 | pub fn remove_bounds(&self) -> ast::TypeAliasDef { | 197 | pub fn remove_bounds(&self) -> ast::TypeAlias { |
198 | let colon = match self.colon_token() { | 198 | let colon = match self.colon_token() { |
199 | Some(it) => it, | 199 | Some(it) => it, |
200 | None => return self.clone(), | 200 | None => return self.clone(), |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 4fc35585d..ad8ccf1ce 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -183,15 +183,15 @@ impl TraitDef { | |||
183 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } | 183 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } |
184 | } | 184 | } |
185 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 185 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
186 | pub struct TypeAliasDef { | 186 | pub struct TypeAlias { |
187 | pub(crate) syntax: SyntaxNode, | 187 | pub(crate) syntax: SyntaxNode, |
188 | } | 188 | } |
189 | impl ast::AttrsOwner for TypeAliasDef {} | 189 | impl ast::AttrsOwner for TypeAlias {} |
190 | impl ast::NameOwner for TypeAliasDef {} | 190 | impl ast::NameOwner for TypeAlias {} |
191 | impl ast::VisibilityOwner for TypeAliasDef {} | 191 | impl ast::VisibilityOwner for TypeAlias {} |
192 | impl ast::TypeParamsOwner for TypeAliasDef {} | 192 | impl ast::TypeParamsOwner for TypeAlias {} |
193 | impl ast::TypeBoundsOwner for TypeAliasDef {} | 193 | impl ast::TypeBoundsOwner for TypeAlias {} |
194 | impl TypeAliasDef { | 194 | impl TypeAlias { |
195 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | 195 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } |
196 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } | 196 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } |
197 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 197 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
@@ -384,6 +384,13 @@ impl SelfParam { | |||
384 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 384 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
385 | } | 385 | } |
386 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 386 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
387 | pub struct TypeBoundList { | ||
388 | pub(crate) syntax: SyntaxNode, | ||
389 | } | ||
390 | impl TypeBoundList { | ||
391 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | ||
392 | } | ||
393 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
387 | pub struct RecordFieldDefList { | 394 | pub struct RecordFieldDefList { |
388 | pub(crate) syntax: SyntaxNode, | 395 | pub(crate) syntax: SyntaxNode, |
389 | } | 396 | } |
@@ -444,13 +451,6 @@ impl EnumVariant { | |||
444 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 451 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
445 | } | 452 | } |
446 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 453 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
447 | pub struct TypeBoundList { | ||
448 | pub(crate) syntax: SyntaxNode, | ||
449 | } | ||
450 | impl TypeBoundList { | ||
451 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | ||
452 | } | ||
453 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
454 | pub struct AssocItemList { | 454 | pub struct AssocItemList { |
455 | pub(crate) syntax: SyntaxNode, | 455 | pub(crate) syntax: SyntaxNode, |
456 | } | 456 | } |
@@ -1284,7 +1284,7 @@ pub enum Item { | |||
1284 | StaticDef(StaticDef), | 1284 | StaticDef(StaticDef), |
1285 | StructDef(StructDef), | 1285 | StructDef(StructDef), |
1286 | TraitDef(TraitDef), | 1286 | TraitDef(TraitDef), |
1287 | TypeAliasDef(TypeAliasDef), | 1287 | TypeAlias(TypeAlias), |
1288 | UnionDef(UnionDef), | 1288 | UnionDef(UnionDef), |
1289 | Use(Use), | 1289 | Use(Use), |
1290 | } | 1290 | } |
@@ -1365,7 +1365,7 @@ pub enum Expr { | |||
1365 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1365 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1366 | pub enum AssocItem { | 1366 | pub enum AssocItem { |
1367 | Fn(Fn), | 1367 | Fn(Fn), |
1368 | TypeAliasDef(TypeAliasDef), | 1368 | TypeAlias(TypeAlias), |
1369 | ConstDef(ConstDef), | 1369 | ConstDef(ConstDef), |
1370 | MacroCall(MacroCall), | 1370 | MacroCall(MacroCall), |
1371 | } | 1371 | } |
@@ -1543,8 +1543,8 @@ impl AstNode for TraitDef { | |||
1543 | } | 1543 | } |
1544 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1544 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1545 | } | 1545 | } |
1546 | impl AstNode for TypeAliasDef { | 1546 | impl AstNode for TypeAlias { |
1547 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } | 1547 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS } |
1548 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1548 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1549 | if Self::can_cast(syntax.kind()) { | 1549 | if Self::can_cast(syntax.kind()) { |
1550 | Some(Self { syntax }) | 1550 | Some(Self { syntax }) |
@@ -1752,6 +1752,17 @@ impl AstNode for SelfParam { | |||
1752 | } | 1752 | } |
1753 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1753 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1754 | } | 1754 | } |
1755 | impl AstNode for TypeBoundList { | ||
1756 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | ||
1757 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1758 | if Self::can_cast(syntax.kind()) { | ||
1759 | Some(Self { syntax }) | ||
1760 | } else { | ||
1761 | None | ||
1762 | } | ||
1763 | } | ||
1764 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1765 | } | ||
1755 | impl AstNode for RecordFieldDefList { | 1766 | impl AstNode for RecordFieldDefList { |
1756 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } | 1767 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } |
1757 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1768 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1818,17 +1829,6 @@ impl AstNode for EnumVariant { | |||
1818 | } | 1829 | } |
1819 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1830 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1820 | } | 1831 | } |
1821 | impl AstNode for TypeBoundList { | ||
1822 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | ||
1823 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1824 | if Self::can_cast(syntax.kind()) { | ||
1825 | Some(Self { syntax }) | ||
1826 | } else { | ||
1827 | None | ||
1828 | } | ||
1829 | } | ||
1830 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1831 | } | ||
1832 | impl AstNode for AssocItemList { | 1832 | impl AstNode for AssocItemList { |
1833 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_ITEM_LIST } | 1833 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_ITEM_LIST } |
1834 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1834 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2808,8 +2808,8 @@ impl From<StructDef> for Item { | |||
2808 | impl From<TraitDef> for Item { | 2808 | impl From<TraitDef> for Item { |
2809 | fn from(node: TraitDef) -> Item { Item::TraitDef(node) } | 2809 | fn from(node: TraitDef) -> Item { Item::TraitDef(node) } |
2810 | } | 2810 | } |
2811 | impl From<TypeAliasDef> for Item { | 2811 | impl From<TypeAlias> for Item { |
2812 | fn from(node: TypeAliasDef) -> Item { Item::TypeAliasDef(node) } | 2812 | fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } |
2813 | } | 2813 | } |
2814 | impl From<UnionDef> for Item { | 2814 | impl From<UnionDef> for Item { |
2815 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } | 2815 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } |
@@ -2821,9 +2821,7 @@ impl AstNode for Item { | |||
2821 | fn can_cast(kind: SyntaxKind) -> bool { | 2821 | fn can_cast(kind: SyntaxKind) -> bool { |
2822 | match kind { | 2822 | match kind { |
2823 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL | 2823 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL |
2824 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => { | 2824 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS | UNION_DEF | USE => true, |
2825 | true | ||
2826 | } | ||
2827 | _ => false, | 2825 | _ => false, |
2828 | } | 2826 | } |
2829 | } | 2827 | } |
@@ -2840,7 +2838,7 @@ impl AstNode for Item { | |||
2840 | STATIC_DEF => Item::StaticDef(StaticDef { syntax }), | 2838 | STATIC_DEF => Item::StaticDef(StaticDef { syntax }), |
2841 | STRUCT_DEF => Item::StructDef(StructDef { syntax }), | 2839 | STRUCT_DEF => Item::StructDef(StructDef { syntax }), |
2842 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), | 2840 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), |
2843 | TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), | 2841 | TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), |
2844 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), | 2842 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), |
2845 | USE => Item::Use(Use { syntax }), | 2843 | USE => Item::Use(Use { syntax }), |
2846 | _ => return None, | 2844 | _ => return None, |
@@ -2860,7 +2858,7 @@ impl AstNode for Item { | |||
2860 | Item::StaticDef(it) => &it.syntax, | 2858 | Item::StaticDef(it) => &it.syntax, |
2861 | Item::StructDef(it) => &it.syntax, | 2859 | Item::StructDef(it) => &it.syntax, |
2862 | Item::TraitDef(it) => &it.syntax, | 2860 | Item::TraitDef(it) => &it.syntax, |
2863 | Item::TypeAliasDef(it) => &it.syntax, | 2861 | Item::TypeAlias(it) => &it.syntax, |
2864 | Item::UnionDef(it) => &it.syntax, | 2862 | Item::UnionDef(it) => &it.syntax, |
2865 | Item::Use(it) => &it.syntax, | 2863 | Item::Use(it) => &it.syntax, |
2866 | } | 2864 | } |
@@ -3258,8 +3256,8 @@ impl AstNode for Expr { | |||
3258 | impl From<Fn> for AssocItem { | 3256 | impl From<Fn> for AssocItem { |
3259 | fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } | 3257 | fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } |
3260 | } | 3258 | } |
3261 | impl From<TypeAliasDef> for AssocItem { | 3259 | impl From<TypeAlias> for AssocItem { |
3262 | fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) } | 3260 | fn from(node: TypeAlias) -> AssocItem { AssocItem::TypeAlias(node) } |
3263 | } | 3261 | } |
3264 | impl From<ConstDef> for AssocItem { | 3262 | impl From<ConstDef> for AssocItem { |
3265 | fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) } | 3263 | fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) } |
@@ -3270,14 +3268,14 @@ impl From<MacroCall> for AssocItem { | |||
3270 | impl AstNode for AssocItem { | 3268 | impl AstNode for AssocItem { |
3271 | fn can_cast(kind: SyntaxKind) -> bool { | 3269 | fn can_cast(kind: SyntaxKind) -> bool { |
3272 | match kind { | 3270 | match kind { |
3273 | FN | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true, | 3271 | FN | TYPE_ALIAS | CONST_DEF | MACRO_CALL => true, |
3274 | _ => false, | 3272 | _ => false, |
3275 | } | 3273 | } |
3276 | } | 3274 | } |
3277 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3275 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3278 | let res = match syntax.kind() { | 3276 | let res = match syntax.kind() { |
3279 | FN => AssocItem::Fn(Fn { syntax }), | 3277 | FN => AssocItem::Fn(Fn { syntax }), |
3280 | TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }), | 3278 | TYPE_ALIAS => AssocItem::TypeAlias(TypeAlias { syntax }), |
3281 | CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }), | 3279 | CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }), |
3282 | MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), | 3280 | MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), |
3283 | _ => return None, | 3281 | _ => return None, |
@@ -3287,7 +3285,7 @@ impl AstNode for AssocItem { | |||
3287 | fn syntax(&self) -> &SyntaxNode { | 3285 | fn syntax(&self) -> &SyntaxNode { |
3288 | match self { | 3286 | match self { |
3289 | AssocItem::Fn(it) => &it.syntax, | 3287 | AssocItem::Fn(it) => &it.syntax, |
3290 | AssocItem::TypeAliasDef(it) => &it.syntax, | 3288 | AssocItem::TypeAlias(it) => &it.syntax, |
3291 | AssocItem::ConstDef(it) => &it.syntax, | 3289 | AssocItem::ConstDef(it) => &it.syntax, |
3292 | AssocItem::MacroCall(it) => &it.syntax, | 3290 | AssocItem::MacroCall(it) => &it.syntax, |
3293 | } | 3291 | } |
@@ -3525,7 +3523,7 @@ impl std::fmt::Display for TraitDef { | |||
3525 | std::fmt::Display::fmt(self.syntax(), f) | 3523 | std::fmt::Display::fmt(self.syntax(), f) |
3526 | } | 3524 | } |
3527 | } | 3525 | } |
3528 | impl std::fmt::Display for TypeAliasDef { | 3526 | impl std::fmt::Display for TypeAlias { |
3529 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3527 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3530 | std::fmt::Display::fmt(self.syntax(), f) | 3528 | std::fmt::Display::fmt(self.syntax(), f) |
3531 | } | 3529 | } |
@@ -3620,6 +3618,11 @@ impl std::fmt::Display for SelfParam { | |||
3620 | std::fmt::Display::fmt(self.syntax(), f) | 3618 | std::fmt::Display::fmt(self.syntax(), f) |
3621 | } | 3619 | } |
3622 | } | 3620 | } |
3621 | impl std::fmt::Display for TypeBoundList { | ||
3622 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3623 | std::fmt::Display::fmt(self.syntax(), f) | ||
3624 | } | ||
3625 | } | ||
3623 | impl std::fmt::Display for RecordFieldDefList { | 3626 | impl std::fmt::Display for RecordFieldDefList { |
3624 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3627 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3625 | std::fmt::Display::fmt(self.syntax(), f) | 3628 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3650,11 +3653,6 @@ impl std::fmt::Display for EnumVariant { | |||
3650 | std::fmt::Display::fmt(self.syntax(), f) | 3653 | std::fmt::Display::fmt(self.syntax(), f) |
3651 | } | 3654 | } |
3652 | } | 3655 | } |
3653 | impl std::fmt::Display for TypeBoundList { | ||
3654 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3655 | std::fmt::Display::fmt(self.syntax(), f) | ||
3656 | } | ||
3657 | } | ||
3658 | impl std::fmt::Display for AssocItemList { | 3656 | impl std::fmt::Display for AssocItemList { |
3659 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3657 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3660 | std::fmt::Display::fmt(self.syntax(), f) | 3658 | std::fmt::Display::fmt(self.syntax(), f) |
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 9fb6b7268..a7a301d6b 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs | |||
@@ -485,6 +485,6 @@ impl ast::DocCommentsOwner for ast::TraitDef {} | |||
485 | impl ast::DocCommentsOwner for ast::Module {} | 485 | impl ast::DocCommentsOwner for ast::Module {} |
486 | impl ast::DocCommentsOwner for ast::StaticDef {} | 486 | impl ast::DocCommentsOwner for ast::StaticDef {} |
487 | impl ast::DocCommentsOwner for ast::ConstDef {} | 487 | impl ast::DocCommentsOwner for ast::ConstDef {} |
488 | impl ast::DocCommentsOwner for ast::TypeAliasDef {} | 488 | impl ast::DocCommentsOwner for ast::TypeAlias {} |
489 | impl ast::DocCommentsOwner for ast::ImplDef {} | 489 | impl ast::DocCommentsOwner for ast::ImplDef {} |
490 | impl ast::DocCommentsOwner for ast::MacroCall {} | 490 | impl ast::DocCommentsOwner for ast::MacroCall {} |