aboutsummaryrefslogtreecommitdiff
path: root/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.rs')
-rw-r--r--src/ast.rs13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/ast.rs b/src/ast.rs
index 3a9287466..b513eb13e 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -1,5 +1,5 @@
1use std::sync::Arc; 1use std::sync::Arc;
2use {SyntaxNode, TreeRoot, SyntaxRoot, SyntaxNodeRef}; 2use {SyntaxNode, TreeRoot, SyntaxRoot};
3 3
4#[derive(Debug)] 4#[derive(Debug)]
5pub struct File<R: TreeRoot = Arc<SyntaxRoot>> { 5pub struct File<R: TreeRoot = Arc<SyntaxRoot>> {
@@ -16,15 +16,4 @@ impl<R: TreeRoot> File<R> {
16 pub fn syntax(&self) -> SyntaxNode<R> { 16 pub fn syntax(&self) -> SyntaxNode<R> {
17 self.syntax.clone() 17 self.syntax.clone()
18 } 18 }
19
20 pub fn for_each_node(&self, mut f: impl FnMut(SyntaxNodeRef)) {
21 let syntax = self.syntax();
22 let syntax = syntax.borrow();
23 go(syntax, &mut f);
24
25 fn go(syntax: SyntaxNodeRef, f: &mut FnMut(SyntaxNodeRef)) {
26 f(syntax);
27 syntax.children().into_iter().for_each(f)
28 }
29 }
30} 19}