Editor

Trait Editor 

Source
pub trait Editor {
    // Required methods
    fn has_edit(&self, tree: &Tree, node: &Node<'_>) -> bool;
    fn edit(&self, source: &[u8], tree: &Tree, node: &Node<'_>) -> Vec<u8> ;

    // Provided method
    fn in_order_edits<'a>(
        &'a self,
        source: &'a [u8],
        tree: &'a Tree,
    ) -> Box<dyn Iterator<Item = Edit> + 'a> { ... }
}
Expand description

Modify a tree-sitter parse tree when printing.

Required Methods§

Source

fn has_edit(&self, tree: &Tree, node: &Node<'_>) -> bool

Does this editor have an edit for this node?

Source

fn edit(&self, source: &[u8], tree: &Tree, node: &Node<'_>) -> Vec<u8>

Edit this node (precondition: Editor::has_edit).

Provided Methods§

Source

fn in_order_edits<'a>( &'a self, source: &'a [u8], tree: &'a Tree, ) -> Box<dyn Iterator<Item = Edit> + 'a>

Get all edits to this tree, in order.

Edits must be ordered by start byte and must not overlap.

[default_in_order] does an in-order traversal of the tree.

Implementors§