()
| 11 | use atomic_core::diff::{compute_inline_diff, Algorithm, DiffOp, HunkKind, Line, Tokenizer}; |
| 12 | |
| 13 | fn main() { |
| 14 | println!("╔══════════════════════════════════════════════════════════════════╗"); |
| 15 | println!("║ Word-Level Diff Demo for Code Reviews ║"); |
| 16 | println!("╚══════════════════════════════════════════════════════════════════╝\n"); |
| 17 | |
| 18 | // Example 1: Function argument added |
| 19 | demo_inline_diff( |
| 20 | "Example 1: Function Argument Added", |
| 21 | b"const result = calculateSum(a, b);", |
| 22 | b"const result = calculateSum(a, b, c);", |
| 23 | ); |
| 24 | |
| 25 | // Example 2: Variable value changed |
| 26 | demo_inline_diff( |
| 27 | "Example 2: Variable Value Changed", |
| 28 | b"let timeout = 5000;", |
| 29 | b"let timeout = 10000;", |
| 30 | ); |
| 31 | |
| 32 | // Example 3: Operator changed |
| 33 | demo_inline_diff( |
| 34 | "Example 3: Operator Changed", |
| 35 | b"if (x == y) {", |
| 36 | b"if (x != y) {", |
| 37 | ); |
| 38 | |
| 39 | // Example 4: Variable renamed |
| 40 | demo_inline_diff( |
| 41 | "Example 4: Variable Renamed", |
| 42 | b"let foo = getValue();", |
| 43 | b"let bar = getValue();", |
| 44 | ); |
| 45 | |
| 46 | // Example 5: Type annotation added |
| 47 | demo_inline_diff( |
| 48 | "Example 5: Type Annotation Added", |
| 49 | b"let count = 0", |
| 50 | b"let count: i32 = 0", |
| 51 | ); |
| 52 | |
| 53 | // Example 6: String literal changed |
| 54 | demo_inline_diff( |
| 55 | "Example 6: String Literal Changed", |
| 56 | b"let message = \"Hello, World!\";", |
| 57 | b"let message = \"Goodbye, World!\";", |
| 58 | ); |
| 59 | |
| 60 | // Multi-line diff example |
| 61 | println!("\n======================================================================\n"); |
| 62 | demo_multiline_diff(); |
| 63 | |
| 64 | // Tokenizer demo |
| 65 | println!("\n======================================================================\n"); |
| 66 | demo_tokenizer(); |
| 67 | } |
| 68 | |
| 69 | /// Demonstrate inline diff between two lines |
| 70 | fn demo_inline_diff(title: &str, old: &[u8], new: &[u8]) { |
nothing calls this directly
no test coverage detected