mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Refactor
This commit is contained in:
parent
a44428fc79
commit
87cd57d56a
3 changed files with 19 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
|||
use {
|
||||
parser_impl::Sink,
|
||||
yellow::{GreenNode, SyntaxError, SyntaxNode, SyntaxRoot},
|
||||
yellow::{GreenNode, SyntaxError},
|
||||
SyntaxKind, TextRange, TextUnit,
|
||||
};
|
||||
|
||||
|
@ -13,7 +13,7 @@ pub(crate) struct GreenBuilder<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Sink<'a> for GreenBuilder<'a> {
|
||||
type Tree = SyntaxNode;
|
||||
type Tree = (GreenNode, Vec<SyntaxError>);
|
||||
|
||||
fn new(text: &'a str) -> Self {
|
||||
GreenBuilder {
|
||||
|
@ -56,10 +56,9 @@ impl<'a> Sink<'a> for GreenBuilder<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn finish(mut self) -> SyntaxNode {
|
||||
fn finish(mut self) -> (GreenNode, Vec<SyntaxError>) {
|
||||
assert_eq!(self.children.len(), 1);
|
||||
let root = self.children.pop().unwrap();
|
||||
let root = SyntaxRoot::new(root, self.errors);
|
||||
SyntaxNode::new_owned(root)
|
||||
(root, self.errors)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue