From 4f4f7f76d08dcde0ab22394327da84af5a13476e Mon Sep 17 00:00:00 2001 From: Carl Eastlund Date: Tue, 17 Jan 2023 20:44:56 -0500 Subject: [PATCH] Removed File_path exports. Signed-off-by: Carl Eastlund --- CHANGES.md | 1 + src/driver.ml | 27 +++++++++++++++++++++++---- src/file_path.ml | 20 -------------------- src/file_path.mli | 7 ------- src/ppxlib.ml | 1 - 5 files changed, 24 insertions(+), 32 deletions(-) delete mode 100644 src/file_path.ml delete mode 100644 src/file_path.mli diff --git a/CHANGES.md b/CHANGES.md index a9713208..806633f1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ unreleased ------------------ +- Remove `File_path` exports. (#381, @ceastlund) 0.28.0 (05/10/2022) ------------------- diff --git a/src/driver.ml b/src/driver.ml index cf4cc51b..77898d45 100644 --- a/src/driver.ml +++ b/src/driver.ml @@ -31,6 +31,25 @@ let ghost = method! location loc = { loc with loc_ghost = true } end +let chop_prefix ~prefix x = + if String.is_prefix ~prefix x then + Some (String.drop_prefix x (String.length prefix)) + else None + +let get_default_path (loc : Location.t) = + let fname = loc.loc_start.pos_fname in + match chop_prefix ~prefix:"./" fname with + | Some fname -> fname + | None -> fname + +let get_default_path_str : structure -> string = function + | [] -> "" + | { pstr_loc = loc; _ } :: _ -> get_default_path loc + +let get_default_path_sig : signature -> string = function + | [] -> "" + | { psig_loc = loc; _ } :: _ -> get_default_path loc + module Lint_error = struct type t = Location.t * string @@ -245,7 +264,7 @@ module Transform = struct | { pstr_desc = Pstr_attribute _; _ } -> true | _ -> false) in - let file_path = File_path.get_default_path_str st in + let file_path = get_default_path_str st in let base_ctxt = Expansion_context.Base.top_level ~tool_name ~file_path ~input_name in @@ -267,7 +286,7 @@ module Transform = struct | { psig_desc = Psig_attribute _; _ } -> true | _ -> false) in - let file_path = File_path.get_default_path_sig sg in + let file_path = get_default_path_sig sg in let base_ctxt = Expansion_context.Base.top_level ~tool_name ~file_path ~input_name in @@ -681,7 +700,7 @@ let map_structure_gen st ~tool_name ~hook ~expect_mismatch_handler ~input_name in with_errors errors st in - let file_path = File_path.get_default_path_str st in + let file_path = get_default_path_str st in match apply_transforms st ~tool_name ~file_path ~field:(fun (ct : Transform.t) -> ct.impl) @@ -761,7 +780,7 @@ let map_signature_gen sg ~tool_name ~hook ~expect_mismatch_handler ~input_name in with_errors errors sg in - let file_path = File_path.get_default_path_sig sg in + let file_path = get_default_path_sig sg in match apply_transforms sg ~tool_name ~file_path ~field:(fun (ct : Transform.t) -> ct.intf) diff --git a/src/file_path.ml b/src/file_path.ml deleted file mode 100644 index 9f199c79..00000000 --- a/src/file_path.ml +++ /dev/null @@ -1,20 +0,0 @@ -open! Import - -let chop_prefix ~prefix x = - if String.is_prefix ~prefix x then - Some (String.drop_prefix x (String.length prefix)) - else None - -let get_default_path (loc : Location.t) = - let fname = loc.loc_start.pos_fname in - match chop_prefix ~prefix:"./" fname with - | Some fname -> fname - | None -> fname - -let get_default_path_str : structure -> string = function - | [] -> "" - | { pstr_loc = loc; _ } :: _ -> get_default_path loc - -let get_default_path_sig : signature -> string = function - | [] -> "" - | { psig_loc = loc; _ } :: _ -> get_default_path loc diff --git a/src/file_path.mli b/src/file_path.mli deleted file mode 100644 index 8f64ced7..00000000 --- a/src/file_path.mli +++ /dev/null @@ -1,7 +0,0 @@ -open! Import - -(** Return the path used as root in a file *) - -val get_default_path : Location.t -> string -val get_default_path_str : structure -> string -val get_default_path_sig : signature -> string diff --git a/src/ppxlib.ml b/src/ppxlib.ml index 7923b17c..e8249986 100644 --- a/src/ppxlib.ml +++ b/src/ppxlib.ml @@ -55,7 +55,6 @@ module Driver = Driver module Expansion_context = Expansion_context module Expansion_helpers = Expansion_helpers module Extension = Extension -module File_path = File_path module Keyword = Keyword module Loc = Loc module Location = Location