Convert a modified line to LineOps. Modified lines are more complex - we need to generate token-level operations based on what changed.
(
&mut self,
old_line_num: usize,
new_line_num: usize,
_before: &SemanticLine<'a>,
_after: &SemanticLine<'a>,
token_changes: &[TokenChange<'a>],
)
| 418 | /// Modified lines are more complex - we need to generate token-level |
| 419 | /// operations based on what changed. |
| 420 | fn convert_modified_line<'a>( |
| 421 | &mut self, |
| 422 | old_line_num: usize, |
| 423 | new_line_num: usize, |
| 424 | _before: &SemanticLine<'a>, |
| 425 | _after: &SemanticLine<'a>, |
| 426 | token_changes: &[TokenChange<'a>], |
| 427 | ) -> ConversionResult<Vec<LineOps>> { |
| 428 | let branch_id = self.allocator.alloc_branch(); |
| 429 | |
| 430 | // Convert token changes to LeafOps |
| 431 | let leaf_ops = self.convert_token_changes(token_changes)?; |
| 432 | |
| 433 | // For a modified line, we emit the new content with the leaf ops |
| 434 | // that describe how it was constructed |
| 435 | let line_ops = LineOps::insert(branch_id, None, leaf_ops) |
| 436 | .with_old_line_num(old_line_num) |
| 437 | .with_new_line_num(new_line_num); |
| 438 | |
| 439 | // Modified lines count as both delete and insert at the line level |
| 440 | // but we only emit one operation with the final content |
| 441 | self.stats.lines_inserted += 1; |
| 442 | |
| 443 | Ok(vec![line_ops]) |
| 444 | } |
| 445 | |
| 446 | /// Convert token changes to LeafOps. |
| 447 | fn convert_token_changes<'a>( |
no test coverage detected