package comby

  1. Overview
  2. Docs
A tool for structural code search and replace that supports ~every language

Install

Dune Dependency

Authors

Maintainers

Sources

comby-kernel.1.7.0.tar.gz
md5=ee6556d8bd9b25ed0445ebe23862e48a
sha512=e6386c8ce5ef14bbcab2b0ead5b1edc39375438f56330d5f02e81e467afe6623a7e299f97f26008d77bbc62850c6dc63a7cbe5b81671b5183ff3adeee5946bb3

doc/src/comby.patdiff_kernel/comparison_result.ml.html

Source file comparison_result.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
open! Core_kernel
open! Import

type t =
  | Binary_same
  | Binary_different of
      { prev_is_binary : bool
      ; next_is_binary : bool
      }
  | Hunks of Hunks.t

let update_config_infer_keep_ws config ~prev ~next =
  let keep_ws =
    config.Configuration.keep_ws || Should_keep_whitespace.for_diff ~prev ~next
  in
  Configuration.override ~keep_ws config
;;

let create
      (config : Configuration.t)
      ~(prev : Diff_input.t)
      ~(next : Diff_input.t)
      ~compare_assuming_text
  =
  let prev_is_binary, next_is_binary =
    match config.assume_text with
    | true -> false, false
    | false -> Is_binary.string prev.text, Is_binary.string next.text
  in
  if prev_is_binary || next_is_binary
  then
    if String.( = ) prev.text next.text
    then Binary_same
    else Binary_different { prev_is_binary; next_is_binary }
  else
    Hunks
      (compare_assuming_text (update_config_infer_keep_ws config ~prev ~next) ~prev ~next)
;;

let has_no_diff t =
  match t with
  | Binary_same -> true
  | Binary_different _ -> false
  | Hunks hunks -> List.for_all hunks ~f:Patience_diff.Hunk.all_same
;;
OCaml

Innovation. Community. Security.