Convert the line's tokens into `LeafOp::Insert` ops, allocating fresh leaf IDs via `alloc_leaf`.
(&self, next_leaf_idx: &mut u32, placeholder_change: NodeId)
| 72 | /// Convert the line's tokens into `LeafOp::Insert` ops, allocating |
| 73 | /// fresh leaf IDs via `alloc_leaf`. |
| 74 | pub fn to_leaf_ops(&self, next_leaf_idx: &mut u32, placeholder_change: NodeId) -> Vec<LeafOp> { |
| 75 | let tokenizer = ContentTokenizer::new(self.bytes); |
| 76 | let mut leaf_ops = Vec::new(); |
| 77 | let mut prev_leaf: Option<LeafId> = None; |
| 78 | for tokenized in tokenizer.lines() { |
| 79 | for token in tokenized.tokens() { |
| 80 | let leaf_id = LeafId::new(placeholder_change, *next_leaf_idx); |
| 81 | *next_leaf_idx += 1; |
| 82 | leaf_ops.push(LeafOp::Insert { |
| 83 | after: prev_leaf, |
| 84 | kind: token.kind(), |
| 85 | content: token.content().to_vec(), |
| 86 | }); |
| 87 | prev_leaf = Some(leaf_id); |
| 88 | } |
| 89 | } |
| 90 | leaf_ops |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /// One translation rule. |