pub struct Diff { /* private fields */ }
Implementations§
Source§impl Diff
impl Diff
pub fn postprocess_with( &mut self, before: &[Token], after: &[Token], heuristic: impl SliderHeuristic, )
pub fn postprocess_with_heuristic<T>( &mut self, input: &InternedInput<T>, heuristic: impl SliderHeuristic, )
Source§impl Diff
impl Diff
pub fn unified_diff<'a, P: UnifiedDiffPrinter, T: Hash + Eq>( &'a self, printer: &'a P, config: UnifiedDiffConfig, input: &'a InternedInput<T>, ) -> UnifiedDiff<'a, P>
pub fn unified_diff_with<'a, P: UnifiedDiffPrinter>( &'a self, printer: &'a P, config: UnifiedDiffConfig, before: &'a [Token], after: &'a [Token], ) -> UnifiedDiff<'a, P>
Source§impl Diff
impl Diff
Sourcepub fn compute<T>(algorithm: Algorithm, input: &InternedInput<T>) -> Diff
pub fn compute<T>(algorithm: Algorithm, input: &InternedInput<T>) -> Diff
Computes an edit-script that transforms input.before
into input.after
using
the specified algorithm
Sourcepub fn compute_with(
&mut self,
algorithm: Algorithm,
before: &[Token],
after: &[Token],
num_tokens: u32,
)
pub fn compute_with( &mut self, algorithm: Algorithm, before: &[Token], after: &[Token], num_tokens: u32, )
Computes an edit-script that transforms before
into after
using
the specified algorithm
.
pub fn count_additions(&self) -> u32
pub fn count_removals(&self) -> u32
pub fn is_removed(&self, token_idx: u32) -> bool
pub fn is_added(&self, token_idx: u32) -> bool
Sourcepub fn postprocess_no_heuristic<T>(&mut self, input: &InternedInput<T>)
pub fn postprocess_no_heuristic<T>(&mut self, input: &InternedInput<T>)
Postprocesses the diff to make it more human readable. Certain bvhunks have an amigous placement (event in a minimal diff) where they can move downward or upward by removing a token (line) at the start and adding one at the end (or the other way around). The postprocessing adjust these hunks according to a coulple rules:
- Always merge multiple hunks if possible.
- Always try to create a single MODIFY hunk instead of multiple disjoint ADDED/REMOVED hunks
- Move sliders as far down as possible.
Sourcepub fn postprocess_lines<T: AsRef<[u8]>>(&mut self, input: &InternedInput<T>)
pub fn postprocess_lines<T: AsRef<[u8]>>(&mut self, input: &InternedInput<T>)
Postprocesses the diff to make it more human readable. Certain bvhunks have an amigous placement (event in a minimal diff) where they can move downward or upward by removing a token (line) at the start and adding one at the end (or the other way around). The postprocessing adjust these hunks according to a coulple rules:
- Always merge multiple hunks if possible.
- Always try to create a single MODIFY hunk instead of multiple disjoint ADDED/REMOVED hunks
- based on a lines indentation level heuristically compute the most intutive location to split lines.
- Move sliders as far down as possible.