nixpkgs/pkgs/development/tools/comby/comby.patch

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

959 lines
32 KiB
Diff
Raw Normal View History

diff --git a/comby-kernel.opam b/comby-kernel.opam
2022-07-29 04:12:29 +02:00
index 9db7cc5..a497bff 100644
--- a/comby-kernel.opam
+++ b/comby-kernel.opam
@@ -20,7 +20,7 @@ build: [
depends: [
"dune" {>= "2.8.0"}
"ocaml" {>= "4.08.1"}
- "core_kernel"
+ "core_kernel" {>= "v0.15.0"}
"mparser" {>= "1.3"}
"mparser-pcre"
"ppx_deriving"
diff --git a/comby-semantic.opam b/comby-semantic.opam
2022-07-29 04:12:29 +02:00
index 88563f6..fbbc122 100644
--- a/comby-semantic.opam
+++ b/comby-semantic.opam
@@ -20,7 +20,7 @@ build: [
depends: [
"dune" {>= "2.8.0"}
"ocaml" {>= "4.08.1"}
- "core_kernel"
+ "core_kernel" {>= "v0.15.0"}
"ppx_deriving"
"lwt"
"cohttp"
diff --git a/comby.opam b/comby.opam
2022-07-29 04:12:29 +02:00
index 9e5d96b..ecab789 100644
--- a/comby.opam
+++ b/comby.opam
@@ -31,7 +31,7 @@ depends: [
"cohttp-lwt-unix"
"comby-kernel" {= "1.7.0"}
"comby-semantic" {= "1.7.0"}
- "core"
+ "core" {>= "v0.15.0"}
"hack_parallel" {arch != "arm32" & arch != "arm64"}
"lwt"
"lwt_react"
diff --git a/lib/app/configuration/command_configuration.ml b/lib/app/configuration/command_configuration.ml
2022-07-29 04:12:29 +02:00
index 75c3107..418276e 100644
--- a/lib/app/configuration/command_configuration.ml
+++ b/lib/app/configuration/command_configuration.ml
@@ -16,21 +16,21 @@ type 'a next =
let fold_directory ?(sorted=false) root ~init ~f =
let rec aux acc absolute_path depth =
- if Sys.is_file absolute_path = `Yes then
+ if Sys_unix.is_file absolute_path = `Yes then
match f acc ~depth ~absolute_path ~is_file:true with
| Continue acc
| Skip acc -> acc
- else if Sys.is_directory absolute_path = `Yes then
+ else if Sys_unix.is_directory absolute_path = `Yes then
match f acc ~depth ~absolute_path ~is_file:false with
| Skip acc -> acc
| Continue acc ->
let dir_contents =
if Option.is_some (Sys.getenv "COMBY_TEST") || sorted then
- Sys.ls_dir absolute_path
+ Sys_unix.ls_dir absolute_path
|> List.sort ~compare:String.compare
|> List.rev
else
- Sys.ls_dir absolute_path
+ Sys_unix.ls_dir absolute_path
in
List.fold dir_contents ~init:acc ~f:(fun acc subdir ->
aux acc (Filename.concat absolute_path subdir) (depth + 1))
@@ -50,8 +50,8 @@ let parse_source_directories
let exact_file_paths, file_patterns =
List.partition_map file_filters ~f:(fun path ->
let is_exact path =
- (String.contains path '/' && Sys.is_file path = `Yes)
- || (Sys.is_file ("." ^/ path) = `Yes) (* See if it matches something in the current directory *)
+ (String.contains path '/' && Sys_unix.is_file path = `Yes)
+ || (Sys_unix.is_file ("." ^/ path) = `Yes) (* See if it matches something in the current directory *)
in
if is_exact path then Either.First path else Either.Second path)
in
@@ -167,8 +167,8 @@ let parse_templates ?metasyntax ?(warn_for_missing_file_in_dir = false) paths =
let f acc ~depth:_ ~absolute_path ~is_file =
let is_leaf_directory absolute_path =
not is_file &&
- Sys.ls_dir absolute_path
- |> List.for_all ~f:(fun path -> Sys.is_directory (absolute_path ^/ path) = `No)
+ Sys_unix.ls_dir absolute_path
+ |> List.for_all ~f:(fun path -> Sys_unix.is_directory (absolute_path ^/ path) = `No)
in
if is_leaf_directory absolute_path then
match parse_directory absolute_path with
@@ -178,7 +178,7 @@ let parse_templates ?metasyntax ?(warn_for_missing_file_in_dir = false) paths =
Continue acc
in
List.concat_map paths ~f:(fun path ->
- if Sys.is_directory path = `Yes then
+ if Sys_unix.is_directory path = `Yes then
fold_directory path ~sorted:true ~init:[] ~f
else
parse_toml ?metasyntax path)
2022-07-29 04:12:29 +02:00
@@ -428,7 +428,7 @@ let parse_metasyntax metasyntax_path =
match metasyntax_path with
| None -> Matchers.Metasyntax.default_metasyntax
| Some metasyntax_path ->
- match Sys.file_exists metasyntax_path with
+ match Sys_unix.file_exists metasyntax_path with
| `No | `Unknown ->
Format.eprintf "Could not open file: %s@." metasyntax_path;
exit 1
2022-07-29 04:12:29 +02:00
@@ -477,14 +477,14 @@ let emit_errors { input_options; output_options; _ } =
; Option.is_some input_options.directory_depth
&& Option.value_exn (input_options.directory_depth) < 0
, "-depth must be 0 or greater."
- ; Sys.is_directory input_options.target_directory = `No
+ ; Sys_unix.is_directory input_options.target_directory = `No
, "Directory specified with -d or -directory is not a directory."
; output_options.json_only_diff && not output_options.json_lines
, "-json-only-diff can only be supplied with -json-lines."
2022-07-29 04:12:29 +02:00
; (Option.is_some output_options.chunk_matches) && Option.is_some input_options.zip_file
, "chunk-matches output format is not supported for zip files."
; Option.is_some output_options.interactive_review &&
- (not (String.equal input_options.target_directory (Sys.getcwd ())))
+ (not (String.equal input_options.target_directory (Sys_unix.getcwd ())))
, "Please remove the -d option and `cd` to the directory where you want to \
review from. The -review, -editor, or -default-no options should only be run \
at the root directory of the project files to patch."
2022-07-29 04:12:29 +02:00
@@ -492,11 +492,11 @@ let emit_errors { input_options; output_options; _ } =
match input_options.templates with
| Some inputs ->
List.find_map inputs ~f:(fun input ->
- if Sys.is_file input = `Yes then
+ if Sys_unix.is_file input = `Yes then
(match Toml.Parser.from_filename input with
| `Error (s, _) -> Some s
| _ -> None)
- else if not (Sys.is_directory input = `Yes) then
+ else if not (Sys_unix.is_directory input = `Yes) then
Some (Format.sprintf "Directory %S specified with -templates is not a directory." input)
else
None)
2022-07-29 04:12:29 +02:00
@@ -611,7 +611,7 @@ let filter_zip_entries file_filters exclude_directory_prefix exclude_file_prefix
let syntax custom_matcher_path =
match
- Sys.file_exists custom_matcher_path with
+ Sys_unix.file_exists custom_matcher_path with
| `No | `Unknown ->
Format.eprintf "Could not open file: %s@." custom_matcher_path;
exit 1
2022-07-29 04:12:29 +02:00
@@ -795,7 +795,7 @@ let create
| Directory ->
let target_directory =
if target_directory = "." then
- Filename.realpath target_directory
+ Filename_unix.realpath target_directory
else
target_directory
in
diff --git a/lib/app/configuration/dune b/lib/app/configuration/dune
index e0f9748..e417cfe 100644
--- a/lib/app/configuration/dune
+++ b/lib/app/configuration/dune
@@ -1,6 +1,21 @@
(library
- (name configuration)
- (public_name comby.configuration)
- (instrumentation (backend bisect_ppx))
- (preprocess (pps ppx_deriving.show ppx_sexp_conv ppx_sexp_message ppx_deriving_yojson))
- (libraries comby-kernel comby-semantic comby.patdiff comby.camlzip core yojson ppx_deriving_yojson toml lwt lwt.unix tar tar-unix))
+ (name configuration)
+ (public_name comby.configuration)
+ (instrumentation
+ (backend bisect_ppx))
+ (preprocess
+ (pps ppx_deriving.show ppx_sexp_conv ppx_sexp_message ppx_deriving_yojson))
+ (libraries
+ comby-kernel
+ comby-semantic
+ comby.patdiff
+ comby.camlzip
+ core
+ core_unix.sys_unix
+ yojson
+ ppx_deriving_yojson
+ toml
+ lwt
+ lwt.unix
+ tar
+ tar-unix))
diff --git a/lib/app/configuration/external_semantic.ml b/lib/app/configuration/external_semantic.ml
index bdc7051..ac69b1b 100644
--- a/lib/app/configuration/external_semantic.ml
+++ b/lib/app/configuration/external_semantic.ml
@@ -2,13 +2,10 @@ open Core_kernel
open Comby_semantic
-let debug =
- match Sys.getenv "DEBUG_COMBY" with
- | exception Not_found -> false
- | _ -> true
+let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
let lsif_hover ~name:_ ~filepath ~line ~column =
- String.chop_prefix_if_exists filepath ~prefix:(Sys.getcwd ()) |> fun filepath_relative_root ->
+ String.chop_prefix_if_exists filepath ~prefix:(Sys_unix.getcwd ()) |> fun filepath_relative_root ->
if debug then Format.printf "File relative root: %s@." filepath;
if debug then Format.printf "Querying type at %d::%d@." line column;
let context =
diff --git a/lib/app/dune b/lib/app/dune
index 2ed553c..a91f826 100644
--- a/lib/app/dune
+++ b/lib/app/dune
@@ -1,9 +1,8 @@
(library
- (name comby)
- (public_name comby)
- (instrumentation (backend bisect_ppx))
- (preprocess (pps ppx_deriving.show ppx_deriving.eq ppx_sexp_conv))
- (libraries
- core
- comby-kernel
- comby.pipeline))
+ (name comby)
+ (public_name comby)
+ (instrumentation
+ (backend bisect_ppx))
+ (preprocess
+ (pps ppx_deriving.show ppx_deriving.eq ppx_sexp_conv))
+ (libraries core comby-kernel comby.pipeline))
diff --git a/lib/app/interactive/dune b/lib/app/interactive/dune
index 815aff5..63c1757 100644
--- a/lib/app/interactive/dune
+++ b/lib/app/interactive/dune
@@ -1,5 +1,12 @@
(library
- (name interactive)
- (public_name comby.interactive)
- (preprocess (pps ppx_sexp_conv))
- (libraries comby-kernel comby.configuration core shell.filename_extended lwt lwt.unix))
+ (name interactive)
+ (public_name comby.interactive)
+ (preprocess
+ (pps ppx_sexp_conv))
+ (libraries
+ comby-kernel
+ comby.configuration
+ core
+ shell.filename_extended
+ lwt
+ lwt.unix))
diff --git a/lib/app/interactive/interactive.ml b/lib/app/interactive/interactive.ml
index d4bf200..b27105a 100644
--- a/lib/app/interactive/interactive.ml
+++ b/lib/app/interactive/interactive.ml
@@ -1,5 +1,6 @@
open Core
open Lwt
+module Unix = Core_unix
open Configuration
@@ -37,6 +38,7 @@ module Diff = struct
~big_enough:line_big_enough
~prev
~next
+ ()
| Some prog ->
let compare x y =
let cmd = sprintf "%s %S %S" prog x y in
@@ -52,7 +54,7 @@ module Diff = struct
let compare = compare
end)
in
- P.get_hunks ~transform ~context ~big_enough:line_big_enough ~prev ~next
+ P.get_hunks ~transform ~context ~big_enough:line_big_enough ~prev ~next ()
in
match float_tolerance with
| None -> hunks
diff --git a/lib/app/pipeline/dune b/lib/app/pipeline/dune
index 3369b9e..e6ec880 100644
--- a/lib/app/pipeline/dune
+++ b/lib/app/pipeline/dune
@@ -1,11 +1,23 @@
(library
- (name pipeline)
- (public_name comby.pipeline)
- (instrumentation (backend bisect_ppx))
- (preprocess (pps ppx_sexp_conv ppx_deriving_yojson))
- (libraries comby-kernel comby.statistics comby.configuration comby.interactive comby.camlzip core core.uuid yojson ppx_deriving_yojson parany
- (select parallel_hack.ml from
- (hack_parallel -> parallel_hack.available.ml)
- (!hack_parallel -> parallel_hack.parany_fallback.ml))
- ))
-
+ (name pipeline)
+ (public_name comby.pipeline)
+ (instrumentation
+ (backend bisect_ppx))
+ (preprocess
+ (pps ppx_sexp_conv ppx_deriving_yojson))
+ (libraries
+ comby-kernel
+ comby.statistics
+ comby.configuration
+ comby.interactive
+ comby.camlzip
+ core
+ core_unix.uuid
+ yojson
+ ppx_deriving_yojson
+ parany
+ (select
+ parallel_hack.ml
+ from
+ (hack_parallel -> parallel_hack.available.ml)
+ (!hack_parallel -> parallel_hack.parany_fallback.ml))))
diff --git a/lib/app/pipeline/parallel_hack.available.ml b/lib/app/pipeline/parallel_hack.available.ml
index a901eea..ad33070 100644
--- a/lib/app/pipeline/parallel_hack.available.ml
+++ b/lib/app/pipeline/parallel_hack.available.ml
@@ -1,4 +1,5 @@
open Core
+module Unix = Core_unix
open Hack_parallel
diff --git a/lib/app/statistics/dune b/lib/app/statistics/dune
index b14d5b1..12aff7f 100644
--- a/lib/app/statistics/dune
+++ b/lib/app/statistics/dune
@@ -1,6 +1,8 @@
(library
- (name statistics)
- (public_name comby.statistics)
- (instrumentation (backend bisect_ppx))
- (preprocess (pps ppx_deriving_yojson))
- (libraries yojson ppx_deriving_yojson ppx_deriving_yojson.runtime))
+ (name statistics)
+ (public_name comby.statistics)
+ (instrumentation
+ (backend bisect_ppx))
+ (preprocess
+ (pps ppx_deriving_yojson))
+ (libraries yojson ppx_deriving_yojson ppx_deriving_yojson.runtime))
diff --git a/lib/app/vendored/patdiff/kernel/src/dune b/lib/app/vendored/patdiff/kernel/src/dune
index 7a6353d..b79cba2 100644
--- a/lib/app/vendored/patdiff/kernel/src/dune
+++ b/lib/app/vendored/patdiff/kernel/src/dune
@@ -1,3 +1,6 @@
-(library (name patdiff_kernel) (public_name comby.patdiff_kernel)
+(library
+ (name patdiff_kernel)
+ (public_name comby.patdiff_kernel)
(libraries core_kernel.composition_infix core_kernel patience_diff re)
- (preprocess (pps ppx_jane)))
+ (preprocess
+ (pps ppx_jane)))
diff --git a/lib/app/vendored/patdiff/kernel/src/patdiff_core.ml b/lib/app/vendored/patdiff/kernel/src/patdiff_core.ml
index 4f53a0b..88ee0e3 100644
--- a/lib/app/vendored/patdiff/kernel/src/patdiff_core.ml
+++ b/lib/app/vendored/patdiff/kernel/src/patdiff_core.ml
@@ -138,6 +138,7 @@ module Make (Output_impls : Output_impls) = struct
~big_enough:line_big_enough
~prev
~next
+ ()
;;
type word_or_newline =
@@ -345,6 +346,7 @@ module Make (Output_impls : Output_impls) = struct
~big_enough:word_big_enough
~prev:prev_pieces
~next:next_pieces
+ ()
;;
let ranges_are_just_whitespace (ranges : _ Patience_diff.Range.t list) =
diff --git a/lib/app/vendored/patdiff/lib/src/compare_core.ml b/lib/app/vendored/patdiff/lib/src/compare_core.ml
index fafb201..8b40d09 100644
--- a/lib/app/vendored/patdiff/lib/src/compare_core.ml
+++ b/lib/app/vendored/patdiff/lib/src/compare_core.ml
@@ -1,5 +1,6 @@
open! Core
open! Import
+module Unix = Core_unix
let lines_of_contents contents =
let lines = Array.of_list (String.split_lines contents) in
@@ -100,6 +101,7 @@ let compare_lines (config : Configuration.t) ?prev_diff ?next_diff ~prev ~next (
~big_enough:line_big_enough
~prev
~next
+ ()
| Some prog ->
let compare x y =
let cmd = sprintf "%s %S %S" prog x y in
@@ -116,7 +118,7 @@ let compare_lines (config : Configuration.t) ?prev_diff ?next_diff ~prev ~next (
let compare = compare
end)
in
- P.get_hunks ~transform ~context ~big_enough:line_big_enough ~prev ~next
+ P.get_hunks ~transform ~context ~big_enough:line_big_enough ~prev ~next ()
in
let hunks =
match config.float_tolerance with
@@ -361,7 +363,7 @@ let rec diff_dirs_internal (config : Configuration.t) ~prev_dir ~next_dir ~file_
| None -> Fn.const true
| Some file_filter -> file_filter
in
- Sys.ls_dir (File_name.real_name_exn dir)
+ Sys_unix.ls_dir (File_name.real_name_exn dir)
|> List.filter ~f:(fun x ->
let x = File_name.real_name_exn dir ^/ x in
match Unix.stat x with
diff --git a/lib/app/vendored/patdiff/lib/src/compare_core.mli b/lib/app/vendored/patdiff/lib/src/compare_core.mli
index e919512..caa8dcb 100644
--- a/lib/app/vendored/patdiff/lib/src/compare_core.mli
+++ b/lib/app/vendored/patdiff/lib/src/compare_core.mli
@@ -1,5 +1,6 @@
open! Core
open! Import
+module Unix = Core_unix
val diff_files
: Configuration.t
diff --git a/lib/app/vendored/patdiff/lib/src/configuration.ml b/lib/app/vendored/patdiff/lib/src/configuration.ml
index 6879daa..7d59706 100644
--- a/lib/app/vendored/patdiff/lib/src/configuration.ml
+++ b/lib/app/vendored/patdiff/lib/src/configuration.ml
@@ -481,7 +481,7 @@ let rec load_exn' ~set config_file =
| Error _another_exn -> raise exn
| Ok c ->
(let new_file = config_file ^ ".new" in
- match Sys.file_exists new_file with
+ match Sys_unix.file_exists new_file with
| `Yes | `Unknown -> ()
| `No ->
(try Sexp.save_hum new_file (On_disk.V1.sexp_of_t c) with
@@ -564,7 +564,7 @@ let get_config ?filename () =
(* ~/.patdiff exists *)
Option.bind (Sys.getenv "HOME") ~f:(fun home ->
let f = home ^/ ".patdiff" in
- match Sys.file_exists f with
+ match Sys_unix.file_exists f with
| `Yes -> Some f
| `No | `Unknown -> None)
in
diff --git a/lib/app/vendored/patdiff/lib/src/dune b/lib/app/vendored/patdiff/lib/src/dune
index 007acad..b6a0f80 100644
--- a/lib/app/vendored/patdiff/lib/src/dune
+++ b/lib/app/vendored/patdiff/lib/src/dune
@@ -1,4 +1,13 @@
-(library (name patdiff) (public_name comby.patdiff)
- (libraries core_kernel.composition_infix core core.linux_ext comby.patdiff_kernel
+(library
+ (name patdiff)
+ (public_name comby.patdiff)
+ (libraries
+ core_kernel.composition_infix
+ core
+ core_unix
+ core_unix.linux_ext
+ core_unix.sys_unix
+ comby.patdiff_kernel
patience_diff)
- (preprocess (pps ppx_jane)))
+ (preprocess
+ (pps ppx_jane)))
diff --git a/lib/app/vendored/patdiff/lib/src/html_output.ml b/lib/app/vendored/patdiff/lib/src/html_output.ml
index 3d08f91..93ae8af 100644
--- a/lib/app/vendored/patdiff/lib/src/html_output.ml
+++ b/lib/app/vendored/patdiff/lib/src/html_output.ml
@@ -1,5 +1,6 @@
open! Core
open! Import
+module Unix = Core_unix
include Patdiff_kernel.Html_output.Private.Make (struct
let mtime file =
diff --git a/lib/kernel/match/dune b/lib/kernel/match/dune
index 03b120a..4d48b61 100644
--- a/lib/kernel/match/dune
+++ b/lib/kernel/match/dune
@@ -1,6 +1,12 @@
(library
- (name match)
- (public_name comby-kernel.match)
- (instrumentation (backend bisect_ppx))
- (preprocess (pps ppx_deriving.eq ppx_sexp_conv ppx_deriving_yojson))
- (libraries core_kernel yojson ppx_deriving_yojson ppx_deriving_yojson.runtime))
+ (name match)
+ (public_name comby-kernel.match)
+ (instrumentation
+ (backend bisect_ppx))
+ (preprocess
+ (pps ppx_deriving.eq ppx_sexp_conv ppx_deriving_yojson))
+ (libraries
+ core_kernel
+ yojson
+ ppx_deriving_yojson
+ ppx_deriving_yojson.runtime))
diff --git a/lib/kernel/matchers/alpha.ml b/lib/kernel/matchers/alpha.ml
2022-07-29 04:12:29 +02:00
index d6116f7..993aafc 100644
--- a/lib/kernel/matchers/alpha.ml
+++ b/lib/kernel/matchers/alpha.ml
@@ -13,20 +13,11 @@ module R = MakeRegexp(Regexp)
let configuration_ref = ref (Configuration.create ())
let weaken_delimiter_hole_matching = false
-let debug =
- match Sys.getenv "DEBUG_COMBY" with
- | exception Not_found -> false
- | _ -> true
+let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
-let debug_hole =
- match Sys.getenv "DEBUG_COMBY_HOLE" with
- | exception Not_found -> false
- | _ -> true
+let debug_hole = Sys.getenv "DEBUG_COMBY_HOLE" |> Option.is_some
-let debug_position =
- match Sys.getenv "DEBUG_COMBY_POS" with
- | exception Not_found -> false
- | _ -> true
+let debug_position = Sys.getenv "DEBUG_COMBY_POS" |> Option.is_some
let f _ = return Types.Unit
@@ -147,7 +138,7 @@ module Make (Lang : Types.Language.S) (Meta : Types.Metasyntax.S) (Ext : Types.E
]
>>= fun _ -> f Types.Unit
- let sequence_chain (plist : ('c, Match.t) parser sexp_list) : ('c, Match.t) parser =
+ let sequence_chain (plist : ('c, Match.t) parser list) : ('c, Match.t) parser =
List.fold plist ~init:(return Types.Unit) ~f:(>>)
let with_debug_matcher s tag =
diff --git a/lib/kernel/matchers/dune b/lib/kernel/matchers/dune
index 12ed326..4625458 100644
--- a/lib/kernel/matchers/dune
+++ b/lib/kernel/matchers/dune
@@ -1,6 +1,18 @@
(library
- (name matchers)
- (public_name comby-kernel.matchers)
- (instrumentation (backend bisect_ppx))
- (preprocess (pps ppx_here ppx_sexp_conv ppx_sexp_message ppx_deriving_yojson))
- (libraries comby-kernel.replacement comby-kernel.parsers comby-kernel.match comby-kernel.vangstrom core_kernel mparser mparser-pcre re yojson ppx_deriving_yojson))
+ (name matchers)
+ (public_name comby-kernel.matchers)
+ (instrumentation
+ (backend bisect_ppx))
+ (preprocess
+ (pps ppx_here ppx_sexp_conv ppx_sexp_message ppx_deriving_yojson))
+ (libraries
+ comby-kernel.replacement
+ comby-kernel.parsers
+ comby-kernel.match
+ comby-kernel.vangstrom
+ core_kernel
+ mparser
+ mparser-pcre
+ re
+ yojson
+ ppx_deriving_yojson))
diff --git a/lib/kernel/matchers/evaluate.ml b/lib/kernel/matchers/evaluate.ml
index 9ea71a0..288f79a 100644
--- a/lib/kernel/matchers/evaluate.ml
+++ b/lib/kernel/matchers/evaluate.ml
@@ -3,10 +3,7 @@ open Core_kernel
open Match
open Types.Ast
-let debug =
- match Sys.getenv "DEBUG_COMBY" with
- | exception Not_found -> false
- | _ -> true
+let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
type result = bool * Match.environment option
diff --git a/lib/kernel/matchers/omega.ml b/lib/kernel/matchers/omega.ml
2022-07-29 04:12:29 +02:00
index 61cc69a..0bef682 100644
--- a/lib/kernel/matchers/omega.ml
+++ b/lib/kernel/matchers/omega.ml
@@ -32,15 +32,9 @@ let push_source_ref : string ref = ref ""
let filepath_ref : string option ref = ref None
-let debug =
- match Sys.getenv "DEBUG_COMBY" with
- | exception Not_found -> false
- | _ -> true
2022-07-29 04:12:29 +02:00
-
-let rewrite =
- match Sys.getenv "REWRITE" with
- | exception Not_found -> false
- | _ -> true
2022-07-29 04:12:29 +02:00
+let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
+
+let rewrite = Sys.getenv "REWRITE" |> Option.is_some
let actual = Buffer.create 10
diff --git a/lib/kernel/matchers/preprocess.ml b/lib/kernel/matchers/preprocess.ml
index 84f3ed0..b6d10e7 100644
--- a/lib/kernel/matchers/preprocess.ml
+++ b/lib/kernel/matchers/preprocess.ml
@@ -1,9 +1,6 @@
open Core_kernel
-let debug =
- match Sys.getenv "DEBUG_COMBY" with
- | exception Not_found -> false
- | _ -> true
+let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
let append_rule (module Parser : Types.Rule.S) rule parent_rule =
let open Option in
diff --git a/lib/kernel/matchers/regexp.ml b/lib/kernel/matchers/regexp.ml
index ef0bd59..906820b 100644
--- a/lib/kernel/matchers/regexp.ml
+++ b/lib/kernel/matchers/regexp.ml
@@ -3,7 +3,7 @@ open Vangstrom
let debug =
match Sys.getenv "DEBUG_COMBY" with
| exception Not_found -> false
- | _ -> true
+ | (_ : string) -> true
module type Regexp_engine_intf = sig
type t
diff --git a/lib/kernel/matchers/rewrite.ml b/lib/kernel/matchers/rewrite.ml
index 32c4740..2fc28db 100644
--- a/lib/kernel/matchers/rewrite.ml
+++ b/lib/kernel/matchers/rewrite.ml
@@ -4,10 +4,7 @@ open Core_kernel
open Match
open Replacement
-let debug =
- match Sys.getenv "DEBUG_COMBY" with
- | exception Not_found -> false
- | _ -> true
+let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
let counter =
let uuid_for_id_counter = ref 0 in
diff --git a/lib/kernel/matchers/template.ml b/lib/kernel/matchers/template.ml
index 423a07f..136236c 100644
--- a/lib/kernel/matchers/template.ml
+++ b/lib/kernel/matchers/template.ml
@@ -4,10 +4,7 @@ open Core_kernel
open Match
open Types.Template
-let debug =
- match Sys.getenv "DEBUG_COMBY" with
- | exception Not_found -> false
- | _ -> true
+let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
module Make (Metasyntax : Types.Metasyntax.S) (External : Types.External.S) : Types.Template.S = struct
diff --git a/lib/kernel/parsers/dune b/lib/kernel/parsers/dune
index 28b020c..0cc1fa5 100644
--- a/lib/kernel/parsers/dune
+++ b/lib/kernel/parsers/dune
@@ -1,6 +1,8 @@
(library
- (name parsers)
- (public_name comby-kernel.parsers)
- (instrumentation (backend bisect_ppx))
- (preprocess (pps ppx_sexp_conv))
- (libraries core_kernel comby-kernel.vangstrom mparser))
+ (name parsers)
+ (public_name comby-kernel.parsers)
+ (instrumentation
+ (backend bisect_ppx))
+ (preprocess
+ (pps ppx_sexp_conv))
+ (libraries core_kernel comby-kernel.vangstrom mparser))
diff --git a/lib/kernel/replacement/dune b/lib/kernel/replacement/dune
index 3e62de6..485b716 100644
--- a/lib/kernel/replacement/dune
+++ b/lib/kernel/replacement/dune
@@ -1,6 +1,13 @@
(library
- (name replacement)
- (public_name comby-kernel.replacement)
- (instrumentation (backend bisect_ppx))
- (preprocess (pps ppx_deriving_yojson))
- (libraries comby-kernel.match core_kernel yojson ppx_deriving_yojson ppx_deriving_yojson.runtime))
+ (name replacement)
+ (public_name comby-kernel.replacement)
+ (instrumentation
+ (backend bisect_ppx))
+ (preprocess
+ (pps ppx_deriving_yojson))
+ (libraries
+ comby-kernel.match
+ core_kernel
+ yojson
+ ppx_deriving_yojson
+ ppx_deriving_yojson.runtime))
diff --git a/lib/semantic/dune b/lib/semantic/dune
index 9a244d3..186a2ed 100644
--- a/lib/semantic/dune
+++ b/lib/semantic/dune
@@ -1,11 +1,8 @@
(library
- (name comby_semantic)
- (public_name comby-semantic)
- (instrumentation (backend bisect_ppx))
- (preprocess (pps ppx_deriving.show ppx_deriving.eq ppx_sexp_conv))
- (libraries
- core_kernel
- lwt
- cohttp
- cohttp-lwt-unix
- yojson))
+ (name comby_semantic)
+ (public_name comby-semantic)
+ (instrumentation
+ (backend bisect_ppx))
+ (preprocess
+ (pps ppx_deriving.show ppx_deriving.eq ppx_sexp_conv))
+ (libraries core_kernel lwt cohttp cohttp-lwt-unix yojson))
diff --git a/lib/semantic/lsif.ml b/lib/semantic/lsif.ml
index 49747bc..d6b3e19 100644
--- a/lib/semantic/lsif.ml
+++ b/lib/semantic/lsif.ml
@@ -3,10 +3,7 @@ open Lwt
open Cohttp
open Cohttp_lwt_unix
-let debug =
- match Sys.getenv "DEBUG_COMBY" with
- | exception Not_found -> false
- | _ -> true
+let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
module Formatting = struct
type t =
diff --git a/src/dune b/src/dune
index 444a5a3..f006195 100644
--- a/src/dune
+++ b/src/dune
@@ -1,10 +1,17 @@
(executables
- (libraries comby core ppx_deriving_yojson ppx_deriving_yojson.runtime
- (select if_hack_parallel.ml from
- (hack_parallel -> if_hack_parallel.available.ml)
- (!hack_parallel -> if_hack_parallel.unavailable.ml))
- )
- (preprocess (pps ppx_deriving_yojson ppx_let ppx_deriving.show ppx_sexp_conv))
+ (libraries
+ comby
+ core
+ core_unix.command_unix
+ ppx_deriving_yojson
+ ppx_deriving_yojson.runtime
+ (select
+ if_hack_parallel.ml
+ from
+ (hack_parallel -> if_hack_parallel.available.ml)
+ (!hack_parallel -> if_hack_parallel.unavailable.ml)))
+ (preprocess
+ (pps ppx_deriving_yojson ppx_let ppx_deriving.show ppx_sexp_conv))
(modules main if_hack_parallel)
(modes byte exe)
(names main))
@@ -20,4 +27,5 @@
(install
(package comby)
(section bin)
- (files (main.exe as comby)))
+ (files
+ (main.exe as comby)))
diff --git a/src/main.ml b/src/main.ml
2022-07-29 04:12:29 +02:00
index 1def81d..79af76b 100644
--- a/src/main.ml
+++ b/src/main.ml
@@ -1,4 +1,5 @@
open Core
+module Unix = Core_unix
open Command.Let_syntax
open Comby_kernel
@@ -47,7 +48,7 @@ let substitute_environment_only_and_exit metasyntax_path anonymous_arguments jso
match metasyntax_path with
| None -> Matchers.Metasyntax.default_metasyntax
| Some metasyntax_path ->
- match Sys.file_exists metasyntax_path with
+ match Sys_unix.file_exists metasyntax_path with
| `No | `Unknown ->
Format.eprintf "Could not open file: %s@." metasyntax_path;
exit 1
@@ -95,7 +96,7 @@ let base_command_parameters : (unit -> 'result) Command.Param.t =
and verbose = flag "verbose" no_arg ~doc:(Format.sprintf "Log to %s" verbose_out_file)
and rule = flag "rule" (optional_with_default "where true" string) ~doc:"rule Apply rules to matches."
and match_timeout = flag "timeout" (optional_with_default 3 int) ~doc:"seconds Set match timeout on a source. Default: 3 seconds"
- and target_directory = flag "directory" ~aliases:["d"] (optional_with_default (Sys.getcwd ()) string) ~doc:(Format.sprintf "path Run recursively on files in a directory relative to the root. Default is current directory: %s" @@ Sys.getcwd ())
+ and target_directory = flag "directory" ~aliases:["d"] (optional_with_default (Sys_unix.getcwd ()) string) ~doc:(Format.sprintf "path Run recursively on files in a directory relative to the root. Default is current directory: %s" @@ Sys_unix.getcwd ())
and directory_depth = flag "depth" (optional int) ~doc:"n Depth to recursively descend into directories"
and templates = flag "templates" ~aliases:["config"; "configuration"] (optional (Arg_type.comma_separated string)) ~doc:"paths CSV of directories containing templates, or TOML configuration files"
and file_filters = flag "extensions" ~aliases:["e"; "file-extensions"; "f"] (optional (Arg_type.comma_separated string)) ~doc:"extensions Comma-separated extensions to include, like \".go\" or \".c,.h\". It is just a file suffix, so you can use it to filter file names like \"main.go\". The extension will be used to infer a matcher, unless -custom-matcher or -matcher is specified"
2022-07-29 04:12:29 +02:00
@@ -147,7 +148,7 @@ let base_command_parameters : (unit -> 'result) Command.Param.t =
| l ->
List.map l ~f:(fun pattern ->
if String.contains pattern '/' then
- match Filename.realpath pattern with
+ match Filename_unix.realpath pattern with
| exception Unix.Unix_error _ ->
Format.eprintf
"No such file or directory: %s. Comby interprets \
2022-07-29 04:12:29 +02:00
@@ -204,7 +205,7 @@ let base_command_parameters : (unit -> 'result) Command.Param.t =
let omega = omega || omega_env in
let fast_offset_conversion_env = Option.is_some @@ Sys.getenv "FAST_OFFSET_CONVERSION_COMBY" in
let fast_offset_conversion = fast_offset_conversion_env || fast_offset_conversion in
- let arch = Unix.Utsname.machine (Core.Unix.uname ()) in
+ let arch = Unix.Utsname.machine (Unix.uname ()) in
let compute_mode = match sequential, parany, arch with
| true, _, _ -> `Sequential
| _, true, _
2022-07-29 04:12:29 +02:00
@@ -304,7 +305,7 @@ let parse_comby_dot_file () =
let () =
If_hack_parallel.check_entry_point ();
2022-07-29 04:12:29 +02:00
- Command.run default_command ~version:"1.8.1" ~extend:(fun _ ->
- match Sys.file_exists ".comby" with
2022-07-29 04:12:29 +02:00
+ Command_unix.run default_command ~version:"1.8.1" ~extend:(fun _ ->
+ match Sys_unix.file_exists ".comby" with
| `Yes -> parse_comby_dot_file ()
| _ -> [])
diff --git a/test/alpha/dune b/test/alpha/dune
index d7e5532..020677c 100644
--- a/test/alpha/dune
+++ b/test/alpha/dune
@@ -1,17 +1,14 @@
(library
(name alpha_test_integration)
(package comby)
- (modules
- test_special_matcher_cases
- test_substring_disabled)
+ (modules test_special_matcher_cases test_substring_disabled)
(inline_tests)
- (preprocess (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
- (libraries
- comby
- cohttp-lwt-unix
- core
- camlzip))
+ (preprocess
+ (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
+ (libraries comby cohttp-lwt-unix core camlzip))
(alias
-(name runtest)
-(deps (source_tree example) (source_tree example/src/.ignore-me)))
+ (name runtest)
+ (deps
+ (source_tree example)
+ (source_tree example/src/.ignore-me)))
diff --git a/test/common/dune b/test/common/dune
2022-07-29 04:12:29 +02:00
index 6851f2e..bc3c055 100644
--- a/test/common/dune
+++ b/test/common/dune
2022-07-29 04:12:29 +02:00
@@ -36,16 +36,14 @@
test_regex_holes
test_template_constraints
test_custom_metasyntax
- test_rewrite_attributes
- )
+ test_rewrite_attributes)
(inline_tests)
- (preprocess (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
- (libraries
- comby
- cohttp-lwt-unix
- core
- camlzip))
+ (preprocess
+ (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
+ (libraries comby cohttp-lwt-unix core camlzip))
(alias
-(name runtest)
-(deps (source_tree example) (source_tree example/src/.ignore-me)))
+ (name runtest)
+ (deps
+ (source_tree example)
+ (source_tree example/src/.ignore-me)))
diff --git a/test/common/test_cli.ml b/test/common/test_cli.ml
index 3606367..d5d0c0b 100644
--- a/test/common/test_cli.ml
+++ b/test/common/test_cli.ml
@@ -1,7 +1,10 @@
open Core
open Camlzip
+module Filename = Filename_unix
+module Sys = Sys_unix
module Time = Core_kernel.Time_ns.Span
+module Unix = Core_unix
let binary_path = "../../../../comby"
diff --git a/test/common/test_cli_helper.ml b/test/common/test_cli_helper.ml
index 5791ee6..18372ae 100644
--- a/test/common/test_cli_helper.ml
+++ b/test/common/test_cli_helper.ml
@@ -1,6 +1,7 @@
open Core
module Time = Core_kernel.Time_ns.Span
+module Unix = Core_unix
let binary_path = "../../../../comby"
diff --git a/test/omega/dune b/test/omega/dune
index 3b31a7e..bf68dcb 100644
--- a/test/omega/dune
+++ b/test/omega/dune
@@ -2,20 +2,19 @@
(name omega_test_integration)
(package comby)
(modules
-;
-; TODO
-;
+ ;
+ ; TODO
+ ;
test_optional_holes
test_special_matcher_cases
test_substring_disabled)
(inline_tests)
- (preprocess (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
- (libraries
- comby
- cohttp-lwt-unix
- core
- camlzip))
+ (preprocess
+ (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
+ (libraries comby cohttp-lwt-unix core camlzip))
(alias
-(name runtest)
-(deps (source_tree example) (source_tree example/src/.ignore-me)))
+ (name runtest)
+ (deps
+ (source_tree example)
+ (source_tree example/src/.ignore-me)))