@@ -25,12 +25,8 @@ let print_loc ~normalizedRange ppf (loc : Location.t) =
25
25
fprintf ppf " @{<filename>%a@}%a" print_filename loc.loc_start.pos_fname dim_loc normalizedRange
26
26
;;
27
27
28
- let print ~message_kind intro ppf (loc : Location.t ) =
29
- begin match message_kind with
30
- | `warning -> fprintf ppf " @[@{<info>%s@}@]@," intro
31
- | `warning_as_error -> fprintf ppf " @[@{<error>%s@} (configured as error) @]@," intro
32
- | `error -> fprintf ppf " @[@{<error>%s@}@]@," intro
33
- end ;
28
+ let print intro ppf (loc : Location.t ) =
29
+ fprintf ppf " @[@{<error>%s@}@]@," intro;
34
30
(* ocaml's reported line/col numbering is horrible and super error-prone
35
31
when being handled programmatically (or humanly for that matter. If you're
36
32
an ocaml contributor reading this: who the heck reads the character count
@@ -64,7 +60,7 @@ let print ~message_kind intro ppf (loc : Location.t) =
64
60
branch might not be reached (aka no inline file content display) so
65
61
we don't wanna end up with two line breaks in the the consequent *)
66
62
fprintf ppf " @,%a"
67
- (Super_misc. print_file ~is_warning: (message_kind = `warning ) ~lines ~range )
63
+ (Super_misc. print_file ~lines ~range )
68
64
()
69
65
with
70
66
(* this might happen if the file is e.g. "", "_none_" or any of the fake file name placeholders.
@@ -75,37 +71,23 @@ let print ~message_kind intro ppf (loc : Location.t) =
75
71
76
72
(* taken from https://github.com/rescript-lang/ocaml/blob/d4144647d1bf9bc7dc3aadc24c25a7efa3a67915/parsing/location.ml#L380 *)
77
73
(* This is the error report entry point. We'll replace the default reporter with this one. *)
78
- let rec super_error_reporter ppf ({Location. loc; msg; sub; if_highlight} as err ) =
79
- let highlighted =
80
- if if_highlight <> " " then
81
- let rec collect_locs locs {Location. loc; sub; if_highlight = _ ; _} =
82
- List. fold_left collect_locs (loc :: locs) sub
83
- in
84
- let locs = collect_locs [] err in
85
- Location. highlight_locations ppf locs
86
- else
87
- false
88
- in
89
- if highlighted then
90
- Format. pp_print_string ppf if_highlight
91
- else begin
92
- setup_colors () ;
93
- (* open a vertical box. Everything in our message is indented 2 spaces *)
94
- Format. fprintf ppf " @[<v 2>@,%a@,%s@,@]" (print ~message_kind: `error " We've found a bug for you!" ) loc msg;
95
- List. iter (Format. fprintf ppf " @,@[%a@]" super_error_reporter) sub;
74
+ let rec super_error_reporter ppf ({loc; msg; sub} : Location.error ) =
75
+ setup_colors () ;
76
+ (* open a vertical box. Everything in our message is indented 2 spaces *)
77
+ Format. fprintf ppf " @[<v 2>@,%a@,%s@,@]" (print " We've found a bug for you!" ) loc msg;
78
+ List. iter (Format. fprintf ppf " @,@[%a@]" super_error_reporter) sub
96
79
(* no need to flush here; location's report_exception (which uses this ultimately) flushes *)
97
- end
80
+
98
81
99
82
(* extracted from https://github.com/rescript-lang/ocaml/blob/d4144647d1bf9bc7dc3aadc24c25a7efa3a67915/parsing/location.ml#L299 *)
100
83
(* This is the warning report entry point. We'll replace the default printer with this one *)
101
84
let super_warning_printer loc ppf w =
102
85
match Warnings. report w with
103
86
| `Inactive -> ()
104
- | `Active { Warnings. number = _ ; message = _ ; is_error; sub_locs = _ } ->
105
- setup_colors () ;
106
- let message_kind = if is_error then `warning_as_error else `warning in
107
- Format. fprintf ppf " @[<v 2>@,%a@,%s@,@]"
108
- (print ~message_kind (" Warning number " ^ (Warnings. number w |> string_of_int)))
87
+ | `Active { Warnings. number = _ ; message = _ ; sub_locs = _ } ->
88
+ setup_colors () ;
89
+ Format. fprintf ppf " @[<v 2>@,%a@,%s@,@]@."
90
+ (print (" Warning number " ^ (Warnings. number w |> string_of_int)))
109
91
loc
110
92
(Super_warnings. message w);
111
93
(* at this point, you can display sub_locs too, from e.g. https://github.com/ocaml/ocaml/commit/f6d53cc38f87c67fbf49109f5fb79a0334bab17a
0 commit comments