[][src]Struct rowan::GreenNodeBuilder

pub struct GreenNodeBuilder<T: Types> { /* fields omitted */ }

A builder for a green tree.

Methods

impl<T: Types> GreenNodeBuilder<T>
[src]

pub fn new() -> Self
[src]

Creates new builder.

pub fn leaf(&mut self, kind: T::Kind, text: SmolStr)
[src]

Adds new leaf to the current branch.

pub fn start_internal(&mut self, kind: T::Kind)
[src]

Start new branch and make it current.

pub fn finish_internal(&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_internal_at(&mut self, checkpoint: Checkpoint, kind: T::Kind)
[src]

Wrap the previous branch marked by checkpoint in a new branch and make it current.

pub fn finish(self) -> GreenNode<T>
[src]

Complete tree building. Make sure that start_internal and finish_internal calls are paired!

Trait Implementations

impl<T: Debug + Types> Debug for GreenNodeBuilder<T> where
    T::Kind: Debug
[src]

Auto Trait Implementations

impl<T> Send for GreenNodeBuilder<T> where
    <T as Types>::Kind: Send + Sync

impl<T> Sync for GreenNodeBuilder<T> where
    <T as Types>::Kind: Send + Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Erased for T