2018-07-30 13:58:49 -05:00
|
|
|
use std::sync::Arc;
|
2018-07-31 07:40:40 -05:00
|
|
|
use {SyntaxNode, SyntaxRoot, TreeRoot};
|
2018-07-30 13:58:49 -05:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct File<R: TreeRoot = Arc<SyntaxRoot>> {
|
2018-07-31 07:40:40 -05:00
|
|
|
syntax: SyntaxNode<R>,
|
2018-07-30 13:58:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl File<Arc<SyntaxRoot>> {
|
|
|
|
pub fn parse(text: &str) -> Self {
|
2018-07-31 07:40:40 -05:00
|
|
|
File {
|
|
|
|
syntax: ::parse(text.to_owned()),
|
|
|
|
}
|
2018-07-30 13:58:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<R: TreeRoot> File<R> {
|
|
|
|
pub fn syntax(&self) -> SyntaxNode<R> {
|
|
|
|
self.syntax.clone()
|
|
|
|
}
|
|
|
|
}
|