rust-analyzer/src/ast.rs

22 lines
402 B
Rust
Raw Normal View History

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