diff options
Diffstat (limited to 'crates/libsyntax2/src/ast/generated.rs')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 1ec05c950..c575e15df 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs | |||
@@ -23,6 +23,31 @@ impl<R: TreeRoot> AstNode<R> for ArrayType<R> { | |||
23 | 23 | ||
24 | impl<R: TreeRoot> ArrayType<R> {} | 24 | impl<R: TreeRoot> ArrayType<R> {} |
25 | 25 | ||
26 | // Attr | ||
27 | #[derive(Debug, Clone, Copy)] | ||
28 | pub struct Attr<R: TreeRoot = Arc<SyntaxRoot>> { | ||
29 | syntax: SyntaxNode<R>, | ||
30 | } | ||
31 | |||
32 | impl<R: TreeRoot> AstNode<R> for Attr<R> { | ||
33 | fn cast(syntax: SyntaxNode<R>) -> Option<Self> { | ||
34 | match syntax.kind() { | ||
35 | ATTR => Some(Attr { syntax }), | ||
36 | _ => None, | ||
37 | } | ||
38 | } | ||
39 | fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } | ||
40 | } | ||
41 | |||
42 | impl<R: TreeRoot> Attr<R> { | ||
43 | pub fn value(&self) -> Option<TokenTree<R>> { | ||
44 | self.syntax() | ||
45 | .children() | ||
46 | .filter_map(TokenTree::cast) | ||
47 | .next() | ||
48 | } | ||
49 | } | ||
50 | |||
26 | // ConstDef | 51 | // ConstDef |
27 | #[derive(Debug, Clone, Copy)] | 52 | #[derive(Debug, Clone, Copy)] |
28 | pub struct ConstDef<R: TreeRoot = Arc<SyntaxRoot>> { | 53 | pub struct ConstDef<R: TreeRoot = Arc<SyntaxRoot>> { |
@@ -40,6 +65,7 @@ impl<R: TreeRoot> AstNode<R> for ConstDef<R> { | |||
40 | } | 65 | } |
41 | 66 | ||
42 | impl<R: TreeRoot> ast::NameOwner<R> for ConstDef<R> {} | 67 | impl<R: TreeRoot> ast::NameOwner<R> for ConstDef<R> {} |
68 | impl<R: TreeRoot> ast::AttrsOwner<R> for ConstDef<R> {} | ||
43 | impl<R: TreeRoot> ConstDef<R> {} | 69 | impl<R: TreeRoot> ConstDef<R> {} |
44 | 70 | ||
45 | // DynTraitType | 71 | // DynTraitType |
@@ -77,6 +103,7 @@ impl<R: TreeRoot> AstNode<R> for EnumDef<R> { | |||
77 | } | 103 | } |
78 | 104 | ||
79 | impl<R: TreeRoot> ast::NameOwner<R> for EnumDef<R> {} | 105 | impl<R: TreeRoot> ast::NameOwner<R> for EnumDef<R> {} |
106 | impl<R: TreeRoot> ast::AttrsOwner<R> for EnumDef<R> {} | ||
80 | impl<R: TreeRoot> EnumDef<R> {} | 107 | impl<R: TreeRoot> EnumDef<R> {} |
81 | 108 | ||
82 | // File | 109 | // File |
@@ -120,6 +147,7 @@ impl<R: TreeRoot> AstNode<R> for FnDef<R> { | |||
120 | } | 147 | } |
121 | 148 | ||
122 | impl<R: TreeRoot> ast::NameOwner<R> for FnDef<R> {} | 149 | impl<R: TreeRoot> ast::NameOwner<R> for FnDef<R> {} |
150 | impl<R: TreeRoot> ast::AttrsOwner<R> for FnDef<R> {} | ||
123 | impl<R: TreeRoot> FnDef<R> {} | 151 | impl<R: TreeRoot> FnDef<R> {} |
124 | 152 | ||
125 | // FnPointerType | 153 | // FnPointerType |
@@ -211,6 +239,7 @@ impl<R: TreeRoot> AstNode<R> for Module<R> { | |||
211 | } | 239 | } |
212 | 240 | ||
213 | impl<R: TreeRoot> ast::NameOwner<R> for Module<R> {} | 241 | impl<R: TreeRoot> ast::NameOwner<R> for Module<R> {} |
242 | impl<R: TreeRoot> ast::AttrsOwner<R> for Module<R> {} | ||
214 | impl<R: TreeRoot> Module<R> {} | 243 | impl<R: TreeRoot> Module<R> {} |
215 | 244 | ||
216 | // Name | 245 | // Name |
@@ -266,6 +295,7 @@ impl<R: TreeRoot> AstNode<R> for NamedField<R> { | |||
266 | } | 295 | } |
267 | 296 | ||
268 | impl<R: TreeRoot> ast::NameOwner<R> for NamedField<R> {} | 297 | impl<R: TreeRoot> ast::NameOwner<R> for NamedField<R> {} |
298 | impl<R: TreeRoot> ast::AttrsOwner<R> for NamedField<R> {} | ||
269 | impl<R: TreeRoot> NamedField<R> {} | 299 | impl<R: TreeRoot> NamedField<R> {} |
270 | 300 | ||
271 | // NeverType | 301 | // NeverType |
@@ -436,6 +466,7 @@ impl<R: TreeRoot> AstNode<R> for StaticDef<R> { | |||
436 | } | 466 | } |
437 | 467 | ||
438 | impl<R: TreeRoot> ast::NameOwner<R> for StaticDef<R> {} | 468 | impl<R: TreeRoot> ast::NameOwner<R> for StaticDef<R> {} |
469 | impl<R: TreeRoot> ast::AttrsOwner<R> for StaticDef<R> {} | ||
439 | impl<R: TreeRoot> StaticDef<R> {} | 470 | impl<R: TreeRoot> StaticDef<R> {} |
440 | 471 | ||
441 | // StructDef | 472 | // StructDef |
@@ -455,6 +486,7 @@ impl<R: TreeRoot> AstNode<R> for StructDef<R> { | |||
455 | } | 486 | } |
456 | 487 | ||
457 | impl<R: TreeRoot> ast::NameOwner<R> for StructDef<R> {} | 488 | impl<R: TreeRoot> ast::NameOwner<R> for StructDef<R> {} |
489 | impl<R: TreeRoot> ast::AttrsOwner<R> for StructDef<R> {} | ||
458 | impl<R: TreeRoot> StructDef<R> { | 490 | impl<R: TreeRoot> StructDef<R> { |
459 | pub fn fields<'a>(&'a self) -> impl Iterator<Item = NamedField<R>> + 'a { | 491 | pub fn fields<'a>(&'a self) -> impl Iterator<Item = NamedField<R>> + 'a { |
460 | self.syntax() | 492 | self.syntax() |
@@ -463,6 +495,24 @@ impl<R: TreeRoot> StructDef<R> { | |||
463 | } | 495 | } |
464 | } | 496 | } |
465 | 497 | ||
498 | // TokenTree | ||
499 | #[derive(Debug, Clone, Copy)] | ||
500 | pub struct TokenTree<R: TreeRoot = Arc<SyntaxRoot>> { | ||
501 | syntax: SyntaxNode<R>, | ||
502 | } | ||
503 | |||
504 | impl<R: TreeRoot> AstNode<R> for TokenTree<R> { | ||
505 | fn cast(syntax: SyntaxNode<R>) -> Option<Self> { | ||
506 | match syntax.kind() { | ||
507 | TOKEN_TREE => Some(TokenTree { syntax }), | ||
508 | _ => None, | ||
509 | } | ||
510 | } | ||
511 | fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } | ||
512 | } | ||
513 | |||
514 | impl<R: TreeRoot> TokenTree<R> {} | ||
515 | |||
466 | // TraitDef | 516 | // TraitDef |
467 | #[derive(Debug, Clone, Copy)] | 517 | #[derive(Debug, Clone, Copy)] |
468 | pub struct TraitDef<R: TreeRoot = Arc<SyntaxRoot>> { | 518 | pub struct TraitDef<R: TreeRoot = Arc<SyntaxRoot>> { |
@@ -480,6 +530,7 @@ impl<R: TreeRoot> AstNode<R> for TraitDef<R> { | |||
480 | } | 530 | } |
481 | 531 | ||
482 | impl<R: TreeRoot> ast::NameOwner<R> for TraitDef<R> {} | 532 | impl<R: TreeRoot> ast::NameOwner<R> for TraitDef<R> {} |
533 | impl<R: TreeRoot> ast::AttrsOwner<R> for TraitDef<R> {} | ||
483 | impl<R: TreeRoot> TraitDef<R> {} | 534 | impl<R: TreeRoot> TraitDef<R> {} |
484 | 535 | ||
485 | // TupleType | 536 | // TupleType |
@@ -517,6 +568,7 @@ impl<R: TreeRoot> AstNode<R> for TypeDef<R> { | |||
517 | } | 568 | } |
518 | 569 | ||
519 | impl<R: TreeRoot> ast::NameOwner<R> for TypeDef<R> {} | 570 | impl<R: TreeRoot> ast::NameOwner<R> for TypeDef<R> {} |
571 | impl<R: TreeRoot> ast::AttrsOwner<R> for TypeDef<R> {} | ||
520 | impl<R: TreeRoot> TypeDef<R> {} | 572 | impl<R: TreeRoot> TypeDef<R> {} |
521 | 573 | ||
522 | // TypeRef | 574 | // TypeRef |