aboutsummaryrefslogtreecommitdiff
path: root/src/ast.rs
blob: caf5fb7ef4fc28ccb0941c30bc7cc9cb4388457d (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),
        }
    }
}

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