aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/ast/generated.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/ast/generated.rs')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs
index 2f813050a..0767df334 100644
--- a/crates/libsyntax2/src/ast/generated.rs
+++ b/crates/libsyntax2/src/ast/generated.rs
@@ -20,6 +20,14 @@ impl<R: TreeRoot> AstNode<R> for File<R> {
20 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } 20 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
21} 21}
22 22
23impl<R: TreeRoot> File<R> {
24 pub fn functions<'a>(&'a self) -> impl Iterator<Item = Function<R>> + 'a {
25 self.syntax()
26 .children()
27 .filter_map(Function::cast)
28 }
29}
30
23 31
24#[derive(Debug, Clone, Copy)] 32#[derive(Debug, Clone, Copy)]
25pub struct Function<R: TreeRoot = Arc<SyntaxRoot>> { 33pub struct Function<R: TreeRoot = Arc<SyntaxRoot>> {
@@ -36,6 +44,15 @@ impl<R: TreeRoot> AstNode<R> for Function<R> {
36 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } 44 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
37} 45}
38 46
47impl<R: TreeRoot> Function<R> {
48 pub fn name(&self) -> Option<Name<R>> {
49 self.syntax()
50 .children()
51 .filter_map(Name::cast)
52 .next()
53 }
54}
55
39 56
40#[derive(Debug, Clone, Copy)] 57#[derive(Debug, Clone, Copy)]
41pub struct Name<R: TreeRoot = Arc<SyntaxRoot>> { 58pub struct Name<R: TreeRoot = Arc<SyntaxRoot>> {
@@ -52,3 +69,5 @@ impl<R: TreeRoot> AstNode<R> for Name<R> {
52 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } 69 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
53} 70}
54 71
72impl<R: TreeRoot> Name<R> {}
73