aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-01-12 23:19:20 +0000
committerFlorian Diebold <[email protected]>2019-01-19 15:02:06 +0000
commit5862542dedd5aca9bbdcba19c5f8cd895591005d (patch)
tree58fb630e97583db371eed1111d2c067bde2982b4 /crates/ra_syntax/src/ast
parent688a45e00b53412a7a16360c6d678a5d91a95789 (diff)
Add AST/HIR for type args in path segments
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs128
1 files changed, 128 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 271040bf4..9fe946172 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -105,6 +105,38 @@ impl ArrayType {
105 } 105 }
106} 106}
107 107
108// AssocTypeArg
109#[derive(Debug, PartialEq, Eq, Hash)]
110#[repr(transparent)]
111pub struct AssocTypeArg {
112 pub(crate) syntax: SyntaxNode,
113}
114unsafe impl TransparentNewType for AssocTypeArg {
115 type Repr = rowan::SyntaxNode<RaTypes>;
116}
117
118impl AstNode for AssocTypeArg {
119 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
120 match syntax.kind() {
121 ASSOC_TYPE_ARG => Some(AssocTypeArg::from_repr(syntax.into_repr())),
122 _ => None,
123 }
124 }
125 fn syntax(&self) -> &SyntaxNode { &self.syntax }
126 fn to_owned(&self) -> TreeArc<AssocTypeArg> { TreeArc::cast(self.syntax.to_owned()) }
127}
128
129
130impl AssocTypeArg {
131 pub fn name_ref(&self) -> Option<&NameRef> {
132 super::child_opt(self)
133 }
134
135 pub fn type_ref(&self) -> Option<&TypeRef> {
136 super::child_opt(self)
137 }
138}
139
108// Attr 140// Attr
109#[derive(Debug, PartialEq, Eq, Hash)] 141#[derive(Debug, PartialEq, Eq, Hash)]
110#[repr(transparent)] 142#[repr(transparent)]
@@ -1397,6 +1429,34 @@ impl AstNode for Lifetime {
1397impl ast::AstToken for Lifetime {} 1429impl ast::AstToken for Lifetime {}
1398impl Lifetime {} 1430impl Lifetime {}
1399 1431
1432// LifetimeArg
1433#[derive(Debug, PartialEq, Eq, Hash)]
1434#[repr(transparent)]
1435pub struct LifetimeArg {
1436 pub(crate) syntax: SyntaxNode,
1437}
1438unsafe impl TransparentNewType for LifetimeArg {
1439 type Repr = rowan::SyntaxNode<RaTypes>;
1440}
1441
1442impl AstNode for LifetimeArg {
1443 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1444 match syntax.kind() {
1445 LIFETIME_ARG => Some(LifetimeArg::from_repr(syntax.into_repr())),
1446 _ => None,
1447 }
1448 }
1449 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1450 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) }
1451}
1452
1453
1454impl LifetimeArg {
1455 pub fn lifetime(&self) -> Option<&Lifetime> {
1456 super::child_opt(self)
1457 }
1458}
1459
1400// LifetimeParam 1460// LifetimeParam
1401#[derive(Debug, PartialEq, Eq, Hash)] 1461#[derive(Debug, PartialEq, Eq, Hash)]
1402#[repr(transparent)] 1462#[repr(transparent)]
@@ -2355,6 +2415,10 @@ impl PathSegment {
2355 pub fn name_ref(&self) -> Option<&NameRef> { 2415 pub fn name_ref(&self) -> Option<&NameRef> {
2356 super::child_opt(self) 2416 super::child_opt(self)
2357 } 2417 }
2418
2419 pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2420 super::child_opt(self)
2421 }
2358} 2422}
2359 2423
2360// PathType 2424// PathType
@@ -3335,6 +3399,70 @@ impl TupleType {
3335 } 3399 }
3336} 3400}
3337 3401
3402// TypeArg
3403#[derive(Debug, PartialEq, Eq, Hash)]
3404#[repr(transparent)]
3405pub struct TypeArg {
3406 pub(crate) syntax: SyntaxNode,
3407}
3408unsafe impl TransparentNewType for TypeArg {
3409 type Repr = rowan::SyntaxNode<RaTypes>;
3410}
3411
3412impl AstNode for TypeArg {
3413 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3414 match syntax.kind() {
3415 TYPE_ARG => Some(TypeArg::from_repr(syntax.into_repr())),
3416 _ => None,
3417 }
3418 }
3419 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3420 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
3421}
3422
3423
3424impl TypeArg {
3425 pub fn type_ref(&self) -> Option<&TypeRef> {
3426 super::child_opt(self)
3427 }
3428}
3429
3430// TypeArgList
3431#[derive(Debug, PartialEq, Eq, Hash)]
3432#[repr(transparent)]
3433pub struct TypeArgList {
3434 pub(crate) syntax: SyntaxNode,
3435}
3436unsafe impl TransparentNewType for TypeArgList {
3437 type Repr = rowan::SyntaxNode<RaTypes>;
3438}
3439
3440impl AstNode for TypeArgList {
3441 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3442 match syntax.kind() {
3443 TYPE_ARG_LIST => Some(TypeArgList::from_repr(syntax.into_repr())),
3444 _ => None,
3445 }
3446 }
3447 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3448 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
3449}
3450
3451
3452impl TypeArgList {
3453 pub fn type_args(&self) -> impl Iterator<Item = &TypeArg> {
3454 super::children(self)
3455 }
3456
3457 pub fn lifetime_args(&self) -> impl Iterator<Item = &LifetimeArg> {
3458 super::children(self)
3459 }
3460
3461 pub fn assoc_type_args(&self) -> impl Iterator<Item = &AssocTypeArg> {
3462 super::children(self)
3463 }
3464}
3465
3338// TypeDef 3466// TypeDef
3339#[derive(Debug, PartialEq, Eq, Hash)] 3467#[derive(Debug, PartialEq, Eq, Hash)]
3340#[repr(transparent)] 3468#[repr(transparent)]