From b8679d27911e04841e8c1693daa20e3a3be00cb2 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 11 Jul 2018 15:38:47 +0100 Subject: [PATCH] Simplify naming of reason ast files We don't need to preserve the .ml/.mli extension anymore. Signed-off-by: Jeremie Dimino --- src/module.ml | 17 ----------------- src/module.mli | 2 -- src/preprocessing.ml | 7 ++++++- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/module.ml b/src/module.ml index f72f7db5..01b18181 100644 --- a/src/module.ml +++ b/src/module.ml @@ -28,23 +28,6 @@ module File = struct { name : string ; syntax : Syntax.t } - - let to_ocaml t = - match t.syntax with - | OCaml -> Exn.code_error "to_ocaml: can only convert reason Files" - ["t.name", Sexp.To_sexp.string t.name] - | Reason -> - { syntax = OCaml - ; name = - let base, ext = Filename.split_extension t.name in - base ^ ".re" ^ - (match Filename.extension t.name with - | ".re" -> ".ml" - | ".rei" -> ".mli" - | _ -> Exn.code_error "to_ocaml: unrecognized extension" - [ "name", Sexp.To_sexp.string t.name - ; "ext", Sexp.To_sexp.string ext ]) - } end type t = diff --git a/src/module.mli b/src/module.mli index 5fcc90e0..c47c8335 100644 --- a/src/module.mli +++ b/src/module.mli @@ -28,8 +28,6 @@ module File : sig { name : string ; syntax: Syntax.t } - - val to_ocaml : t -> t end (** Representation of a module. It is guaranteed that at least one of diff --git a/src/preprocessing.ml b/src/preprocessing.ml index efabeb2c..4e8824aa 100644 --- a/src/preprocessing.ml +++ b/src/preprocessing.ml @@ -422,7 +422,12 @@ let setup_reason_rules sctx ~dir (m : Module.t) = match f.syntax with | OCaml -> f | Reason -> - let ml = Module.File.to_ocaml f in + let ml = + { Module.File. + syntax = OCaml + ; name = f.name ^ ".ast" + } + in SC.add_rule sctx (rule f.name ml.name); ml)