[−][src]Struct rowan::GreenNodeBuilder
A builder for a green tree.
Methods
impl GreenNodeBuilder
[src]
pub fn new() -> Self
[src]
Creates new builder.
pub fn token(&mut self, kind: SyntaxKind, text: SmolStr)
[src]
Adds new token to the current branch.
pub fn start_node(&mut self, kind: SyntaxKind)
[src]
Start new node and make it current.
pub fn finish_node(&mut self)
[src]
Finish current branch and restore previous branch as current.
pub fn checkpoint(&self) -> Checkpoint
[src]
Prepare for maybe wrapping the next node. The way wrapping works is that you first of all get a checkpoint, then you place all tokens you want to wrap, and then maybe call start_internal_at. Example:
ⓘThis example is not tested
let checkpoint = builder.checkpoint(); self.parse_expr(); if self.peek() == Some(Token::Plus) { // 1 + 2 = Add(1, 2) builder.start_internal_at(checkpoint, Token::Operation); self.parse_expr(); builder.finish_internal(); }
pub fn start_node_at(&mut self, checkpoint: Checkpoint, kind: SyntaxKind)
[src]
Wrap the previous branch marked by checkpoint
in a new branch and
make it current.
pub fn finish(self) -> GreenNode
[src]
Complete tree building. Make sure that
start_internal
and finish_internal
calls
are paired!
Trait Implementations
Auto Trait Implementations
impl Send for GreenNodeBuilder
impl Sync for GreenNodeBuilder
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,