@@ -20,27 +20,19 @@ let iterator =
2020
2121let extractMessages = ast => iterator. structure(iterator, Obj . magic(ast));
2222
23- let readMessagesFromChannel = channel =>
24- switch (Ast_io . from_channel(channel)) {
25- | Result . Ok ((_ , Ast_io . Impl ((module Version ), ast))) =>
26- module Convert = Convert (Version , OCaml_406 );
27- let converted = Obj . magic(Convert . copy_structure(ast));
28- extractMessages(converted);
29- | Result . Ok ((_ , Ast_io . Intf (_ , _ ))) => Printf . eprintf("Interface AST not supported, only implementation AST\n " )
30- | Result . Error (Not_a_binary_ast (_ )) => Printf . eprintf("Error: input is not a binary AST\n " )
31- | Result . Error (Unknown_version (v )) => Printf . eprintf("Error: unknown AST version: % s \n " , v)
32- };
33-
3423let processReasonFile = filename => {
35- let channel = Unix . open_process_in("refmt -p binary " ++ filename);
36- readMessagesFromChannel(channel);
37- Unix . close_process_in(channel) |> ignore ;
24+ let channel = open_in_bin(filename);
25+ let lexbuf = Lexing . from_channel(channel);
26+ let ast = Reason_toolchain . RE . implementation(lexbuf);
27+ close_in(channel);
28+ extractMessages(ast);
3829};
3930
4031let rec processDirectory = dir =>
4132 Sys . readdir(dir)
4233 |> Array . iter(filename => {
4334 let path = Filename . concat(dir, filename);
35+
4436 if (Sys . is_directory(path)) {
4537 processDirectory(path);
4638 } else if (Filename . extension(filename) == ".re" ) {
@@ -55,6 +47,7 @@ let outputJson = () => {
5547 |> List . map(((_id, message)) => message)
5648 |> List . sort(Message . compare)
5749 |> List . map(Message . toJson);
50+
5851 Yojson . Basic . pretty_to_channel(stdout, ` List (sortedJsonObjects));
5952 print_newline() ;
6053};
0 commit comments