tree_sitter_edit/editors/
id.rs

1use tree_sitter::{Node, Tree};
2
3use crate::editor::{Edit, Editor};
4
5/// The [Editor] that makes no changes.
6#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub struct Id {}
8
9impl Id {
10    #[must_use]
11    pub fn new() -> Self {
12        Self::default()
13    }
14}
15
16impl Editor for Id {
17    fn has_edit(&self, _tree: &Tree, _node: &Node<'_>) -> bool {
18        false
19    }
20
21    fn edit(&self, _source: &[u8], _tree: &Tree, _node: &Node<'_>) -> Vec<u8> {
22        debug_assert!(false);
23        Vec::new()
24    }
25
26    fn in_order_edits(&self, _source: &[u8], _tree: &Tree) -> Box<dyn Iterator<Item = Edit>> {
27        Box::new(std::iter::empty())
28    }
29}