aboutsummaryrefslogtreecommitdiff
path: root/src/ast.rs
blob: 48e1d23ac1e77d97804f3beb2cd6589be6fae0ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::sync::Arc;
use {SyntaxNode, SyntaxRoot, TreeRoot};

#[derive(Debug)]
pub struct File<R: TreeRoot = Arc<SyntaxRoot>> {
    syntax: SyntaxNode<R>,
}

impl File<Arc<SyntaxRoot>> {
    pub fn parse(text: &str) -> Self {
        File {
            syntax: ::parse(text.to_owned()),
        }
    }
}

impl<R: TreeRoot> File<R> {
    pub fn syntax(&self) -> SyntaxNode<R> {
        self.syntax.clone()
    }
}