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

#[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()
    }
}