Move ParsedFile to top
This commit is contained in:
@@ -4,8 +4,7 @@ use itertools::Itertools;
|
||||
use smol_str::SmolStr;
|
||||
|
||||
use {
|
||||
SyntaxNode, SyntaxNodeRef, TreeRoot, SyntaxError,
|
||||
SyntaxKind::*,
|
||||
SyntaxNodeRef, SyntaxKind::*,
|
||||
};
|
||||
pub use self::generated::*;
|
||||
|
||||
@@ -37,28 +36,6 @@ pub trait AttrsOwner<'a>: AstNode<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ParsedFile {
|
||||
root: SyntaxNode
|
||||
}
|
||||
|
||||
impl ParsedFile {
|
||||
pub fn parse(text: &str) -> Self {
|
||||
let root = ::parse(text);
|
||||
ParsedFile { root }
|
||||
}
|
||||
pub fn ast(&self) -> File {
|
||||
File::cast(self.syntax()).unwrap()
|
||||
}
|
||||
pub fn syntax(&self) -> SyntaxNodeRef {
|
||||
self.root.borrowed()
|
||||
}
|
||||
pub fn errors(&self) -> Vec<SyntaxError> {
|
||||
self.syntax().root.syntax_root().errors.clone()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl<'a> FnDef<'a> {
|
||||
pub fn has_atom_attr(&self, atom: &str) -> bool {
|
||||
self.attrs()
|
||||
|
||||
Reference in New Issue
Block a user