mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-04 07:35:49 +00:00
Move ParsedFile to top
This commit is contained in:
parent
f104458d45
commit
9fae494a8d
7 changed files with 39 additions and 39 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue