aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs85
1 files changed, 66 insertions, 19 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 903646149..132c2ae8c 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -46,10 +46,7 @@ pub struct GenericArgList {
46impl GenericArgList { 46impl GenericArgList {
47 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } 47 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
48 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } 48 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
49 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) } 49 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
50 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
51 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
52 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
53 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } 50 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
54} 51}
55#[derive(Debug, Clone, PartialEq, Eq, Hash)] 52#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -86,15 +83,6 @@ impl TypeArg {
86 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } 83 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
87} 84}
88#[derive(Debug, Clone, PartialEq, Eq, Hash)] 85#[derive(Debug, Clone, PartialEq, Eq, Hash)]
89pub struct LifetimeArg {
90 pub(crate) syntax: SyntaxNode,
91}
92impl LifetimeArg {
93 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
94 support::token(&self.syntax, T![lifetime])
95 }
96}
97#[derive(Debug, Clone, PartialEq, Eq, Hash)]
98pub struct AssocTypeArg { 86pub struct AssocTypeArg {
99 pub(crate) syntax: SyntaxNode, 87 pub(crate) syntax: SyntaxNode,
100} 88}
@@ -105,6 +93,15 @@ impl AssocTypeArg {
105 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } 93 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
106} 94}
107#[derive(Debug, Clone, PartialEq, Eq, Hash)] 95#[derive(Debug, Clone, PartialEq, Eq, Hash)]
96pub struct LifetimeArg {
97 pub(crate) syntax: SyntaxNode,
98}
99impl LifetimeArg {
100 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
101 support::token(&self.syntax, T![lifetime])
102 }
103}
104#[derive(Debug, Clone, PartialEq, Eq, Hash)]
108pub struct ConstArg { 105pub struct ConstArg {
109 pub(crate) syntax: SyntaxNode, 106 pub(crate) syntax: SyntaxNode,
110} 107}
@@ -1272,6 +1269,13 @@ impl MacroStmts {
1272 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1269 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1273} 1270}
1274#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1271#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1272pub enum GenericArg {
1273 TypeArg(TypeArg),
1274 AssocTypeArg(AssocTypeArg),
1275 LifetimeArg(LifetimeArg),
1276 ConstArg(ConstArg),
1277}
1278#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1275pub enum Type { 1279pub enum Type {
1276 ArrayType(ArrayType), 1280 ArrayType(ArrayType),
1277 DynTraitType(DynTraitType), 1281 DynTraitType(DynTraitType),
@@ -1489,8 +1493,8 @@ impl AstNode for TypeArg {
1489 } 1493 }
1490 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1494 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1491} 1495}
1492impl AstNode for LifetimeArg { 1496impl AstNode for AssocTypeArg {
1493 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } 1497 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG }
1494 fn cast(syntax: SyntaxNode) -> Option<Self> { 1498 fn cast(syntax: SyntaxNode) -> Option<Self> {
1495 if Self::can_cast(syntax.kind()) { 1499 if Self::can_cast(syntax.kind()) {
1496 Some(Self { syntax }) 1500 Some(Self { syntax })
@@ -1500,8 +1504,8 @@ impl AstNode for LifetimeArg {
1500 } 1504 }
1501 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1505 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1502} 1506}
1503impl AstNode for AssocTypeArg { 1507impl AstNode for LifetimeArg {
1504 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } 1508 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG }
1505 fn cast(syntax: SyntaxNode) -> Option<Self> { 1509 fn cast(syntax: SyntaxNode) -> Option<Self> {
1506 if Self::can_cast(syntax.kind()) { 1510 if Self::can_cast(syntax.kind()) {
1507 Some(Self { syntax }) 1511 Some(Self { syntax })
@@ -2765,6 +2769,44 @@ impl AstNode for MacroStmts {
2765 } 2769 }
2766 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2770 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2767} 2771}
2772impl From<TypeArg> for GenericArg {
2773 fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) }
2774}
2775impl From<AssocTypeArg> for GenericArg {
2776 fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) }
2777}
2778impl From<LifetimeArg> for GenericArg {
2779 fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) }
2780}
2781impl From<ConstArg> for GenericArg {
2782 fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) }
2783}
2784impl AstNode for GenericArg {
2785 fn can_cast(kind: SyntaxKind) -> bool {
2786 match kind {
2787 TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG => true,
2788 _ => false,
2789 }
2790 }
2791 fn cast(syntax: SyntaxNode) -> Option<Self> {
2792 let res = match syntax.kind() {
2793 TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }),
2794 ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }),
2795 LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
2796 CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
2797 _ => return None,
2798 };
2799 Some(res)
2800 }
2801 fn syntax(&self) -> &SyntaxNode {
2802 match self {
2803 GenericArg::TypeArg(it) => &it.syntax,
2804 GenericArg::AssocTypeArg(it) => &it.syntax,
2805 GenericArg::LifetimeArg(it) => &it.syntax,
2806 GenericArg::ConstArg(it) => &it.syntax,
2807 }
2808 }
2809}
2768impl From<ArrayType> for Type { 2810impl From<ArrayType> for Type {
2769 fn from(node: ArrayType) -> Type { Type::ArrayType(node) } 2811 fn from(node: ArrayType) -> Type { Type::ArrayType(node) }
2770} 2812}
@@ -3380,6 +3422,11 @@ impl From<Item> for Stmt {
3380impl From<LetStmt> for Stmt { 3422impl From<LetStmt> for Stmt {
3381 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } 3423 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
3382} 3424}
3425impl std::fmt::Display for GenericArg {
3426 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3427 std::fmt::Display::fmt(self.syntax(), f)
3428 }
3429}
3383impl std::fmt::Display for Type { 3430impl std::fmt::Display for Type {
3384 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3431 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3385 std::fmt::Display::fmt(self.syntax(), f) 3432 std::fmt::Display::fmt(self.syntax(), f)
@@ -3470,12 +3517,12 @@ impl std::fmt::Display for TypeArg {
3470 std::fmt::Display::fmt(self.syntax(), f) 3517 std::fmt::Display::fmt(self.syntax(), f)
3471 } 3518 }
3472} 3519}
3473impl std::fmt::Display for LifetimeArg { 3520impl std::fmt::Display for AssocTypeArg {
3474 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3521 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3475 std::fmt::Display::fmt(self.syntax(), f) 3522 std::fmt::Display::fmt(self.syntax(), f)
3476 } 3523 }
3477} 3524}
3478impl std::fmt::Display for AssocTypeArg { 3525impl std::fmt::Display for LifetimeArg {
3479 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3526 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3480 std::fmt::Display::fmt(self.syntax(), f) 3527 std::fmt::Display::fmt(self.syntax(), f)
3481 } 3528 }