mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
rename yellow -> syntax_node
why yellow in the first place? Its red + green.
This commit is contained in:
parent
72a122092b
commit
4e91c23c79
18 changed files with 20 additions and 20 deletions
41
crates/ra_syntax/src/syntax_node/builder.rs
Normal file
41
crates/ra_syntax/src/syntax_node/builder.rs
Normal file
|
@ -0,0 +1,41 @@
|
|||
use crate::{
|
||||
parser_impl::Sink,
|
||||
syntax_node::{GreenNode, RaTypes, SyntaxError},
|
||||
SmolStr, SyntaxKind,
|
||||
};
|
||||
use rowan::GreenNodeBuilder;
|
||||
|
||||
pub(crate) struct GreenBuilder {
|
||||
errors: Vec<SyntaxError>,
|
||||
inner: GreenNodeBuilder<RaTypes>,
|
||||
}
|
||||
|
||||
impl GreenBuilder {
|
||||
pub(crate) fn new() -> GreenBuilder {
|
||||
GreenBuilder { errors: Vec::new(), inner: GreenNodeBuilder::new() }
|
||||
}
|
||||
}
|
||||
|
||||
impl Sink for GreenBuilder {
|
||||
type Tree = (GreenNode, Vec<SyntaxError>);
|
||||
|
||||
fn leaf(&mut self, kind: SyntaxKind, text: SmolStr) {
|
||||
self.inner.leaf(kind, text);
|
||||
}
|
||||
|
||||
fn start_branch(&mut self, kind: SyntaxKind) {
|
||||
self.inner.start_internal(kind)
|
||||
}
|
||||
|
||||
fn finish_branch(&mut self) {
|
||||
self.inner.finish_internal();
|
||||
}
|
||||
|
||||
fn error(&mut self, error: SyntaxError) {
|
||||
self.errors.push(error)
|
||||
}
|
||||
|
||||
fn finish(self) -> (GreenNode, Vec<SyntaxError>) {
|
||||
(self.inner.finish(), self.errors)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue