Struct rowan::GreenNodeBuilder
source · pub struct GreenNodeBuilder<T: Types> { /* private fields */ }
Expand description
A builder for a green tree.
Implementations
sourceimpl<T: Types> GreenNodeBuilder<T>
impl<T: Types> GreenNodeBuilder<T>
sourcepub fn start_internal(&mut self, kind: T::Kind)
pub fn start_internal(&mut self, kind: T::Kind)
Start new branch and make it current.
sourcepub fn finish_internal(&mut self)
pub fn finish_internal(&mut self)
Finish current branch and restore previous branch as current.
sourcepub fn checkpoint(&self) -> Checkpoint
pub fn checkpoint(&self) -> Checkpoint
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:
ⓘ
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();
}
sourcepub fn start_internal_at(&mut self, checkpoint: Checkpoint, kind: T::Kind)
pub fn start_internal_at(&mut self, checkpoint: Checkpoint, kind: T::Kind)
Wrap the previous branch marked by checkpoint
in a new branch and
make it current.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for GreenNodeBuilder<T>where
<T as Types>::Kind: RefUnwindSafe,
impl<T> Send for GreenNodeBuilder<T>
impl<T> Sync for GreenNodeBuilder<T>
impl<T> Unpin for GreenNodeBuilder<T>where
<T as Types>::Kind: Unpin,
impl<T> UnwindSafe for GreenNodeBuilder<T>where
<T as Types>::Kind: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more