MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / convert_diff

Method convert_diff

atomic-core/src/diff/semantic_to_crdt.rs:326–341  ·  view source on GitHub ↗

Convert a SemanticDiff to FileOps. # Arguments `diff` - The semantic diff to convert `path` - The file path # Returns A `FileOps` containing all the CRDT operations for this diff.

(
        &mut self,
        diff: &SemanticDiff<'a>,
        path: &str,
    )

Source from the content-addressed store, hash-verified

324 ///
325 /// A `FileOps` containing all the CRDT operations for this diff.
326 pub fn convert_diff<'a>(
327 &mut self,
328 diff: &SemanticDiff<'a>,
329 path: &str,
330 ) -> ConversionResult<FileOps> {
331 let mut file_ops = FileOps::edit(self.trunk_id, path.to_string());
332
333 for change in diff.changes() {
334 let line_ops = self.convert_line_change(change)?;
335 for op in line_ops {
336 file_ops.add_line_op(op);
337 }
338 }
339
340 Ok(file_ops)
341 }
342
343 /// Convert a single LineChange to LineOps.
344 fn convert_line_change<'a>(

Calls 3

convert_line_changeMethod · 0.80
changesMethod · 0.45
add_line_opMethod · 0.45