[−][src]Struct rowan::GreenNodeBuilder
A builder for a green tree.
Implementations
impl<'_> GreenNodeBuilder<'_>
[src]
pub fn new() -> GreenNodeBuilder<'static>
[src]
Creates new builder.
pub fn with_cache(cache: &mut NodeCache) -> GreenNodeBuilder<'_>
[src]
Reusing NodeCache
between different GreenNodeBuilder
s saves memory.
It allows to structurally share underlying trees.
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<'cache> Debug for GreenNodeBuilder<'cache>
[src]
impl<'cache> Default for GreenNodeBuilder<'cache>
[src]
fn default() -> GreenNodeBuilder<'cache>
[src]
Auto Trait Implementations
impl<'cache> RefUnwindSafe for GreenNodeBuilder<'cache>
impl<'cache> Send for GreenNodeBuilder<'cache>
impl<'cache> Sync for GreenNodeBuilder<'cache>
impl<'cache> Unpin for GreenNodeBuilder<'cache>
impl<'cache> !UnwindSafe for GreenNodeBuilder<'cache>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
pub 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>,