[][src]Struct rowan::GreenNodeBuilder

pub struct GreenNodeBuilder { /* fields omitted */ }

A builder for a green tree.

Methods

impl GreenNodeBuilder[src]

pub fn new() -> GreenNodeBuilder[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_node_at. Example:

let checkpoint = builder.checkpoint();
parser.parse_expr();
if parser.peek() == Some(PLUS) {
  // 1 + 2 = Add(1, 2)
  builder.start_node_at(checkpoint, OPERATION);
  parser.parse_expr();
  builder.finish_node();
}

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_node_at and finish_node calls are paired!

Trait Implementations

impl Default for GreenNodeBuilder[src]

impl Debug for GreenNodeBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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