Skip to content

Commit f2ae500

Browse files
committed
clean up super_location
1 parent 58cde4d commit f2ae500

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

jscomp/super_errors/super_location.ml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
(* open Misc
2-
open Asttypes
3-
open Parsetree
4-
open Types
5-
open Typedtree
6-
open Btype
7-
open Ctype *)
81

9-
open Format
10-
(* open Printtyp *)
112

12-
open Location
3+
let fprintf = Format.fprintf
4+
5+
136

147
let file_lines filePath =
15-
(* open_in_bin works on windows, as opposed to open_in, afaik? *)
168
let chan = open_in_bin filePath in
179
let lines = ref [] in
1810
try
@@ -37,11 +29,11 @@ let print_filename ppf file =
3729
| "" -> Format.fprintf ppf "(No file name)"
3830
| real_file -> Format.fprintf ppf "%s" (Location.show_filename real_file)
3931

40-
let print_loc ~normalizedRange ppf loc =
32+
let print_loc ~normalizedRange ppf (loc : Location.t) =
4133
setup_colors ();
4234
let (file, _, _) = Location.get_pos_info loc.loc_start in
4335
if file = "//toplevel//" then begin
44-
if highlight_locations ppf [loc] then () else
36+
if Location.highlight_locations ppf [loc] then () else
4537
fprintf ppf "Characters %i-%i"
4638
loc.loc_start.pos_cnum loc.loc_end.pos_cnum
4739
end else
@@ -59,9 +51,9 @@ let print_loc ~normalizedRange ppf loc =
5951
fprintf ppf "@{<filename>%a@}%a" print_filename file dim_loc normalizedRange
6052
;;
6153

62-
let print ~message_kind intro ppf loc =
54+
let print ~message_kind intro ppf (loc : Location.t) =
6355
if loc.loc_start.pos_fname = "//toplevel//"
64-
&& highlight_locations ppf [loc] then ()
56+
&& Location.highlight_locations ppf [loc] then ()
6557
else
6658
begin match message_kind with
6759
| `warning -> fprintf ppf "@[@{<info>%s@}@]@," intro
@@ -155,17 +147,17 @@ let print_phanton_error_prefix ppf =
155147
(see super_error_reporter above) *)
156148
Format.pp_print_as ppf 2 ""
157149

158-
let errorf ?(loc = none) ?(sub = []) ?(if_highlight = "") fmt =
150+
let errorf ?(loc = Location.none) ?(sub = []) ?(if_highlight = "") fmt =
159151
Location.pp_ksprintf
160152
~before:print_phanton_error_prefix
161-
(fun msg -> {loc; msg; sub; if_highlight})
153+
(fun msg -> Location.{loc; msg; sub; if_highlight})
162154
fmt
163155

164156
let error_of_printer loc print x =
165157
errorf ~loc "%a@?" print x
166158

167159
let error_of_printer_file print x =
168-
error_of_printer (in_file !input_name) print x
160+
error_of_printer (Location.in_file !Location.input_name) print x
169161

170162
(* This will be called in super_main. This is how you override the default error and warning printers *)
171163
let setup () =

0 commit comments

Comments
 (0)