You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: jscomp/super_errors/super_location.ml
+12-21Lines changed: 12 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -45,25 +45,30 @@ let print_loc ppf loc =
45
45
end
46
46
;;
47
47
48
-
letprintintroppfloc=
48
+
letprint~is_warningintroppfloc=
49
49
setup_colors ();
50
50
(* TODO: handle locations such as _none_ and "" *)
51
51
if loc.loc_start.pos_fname ="//toplevel//"
52
52
&& highlight_locations ppf [loc] then()
53
53
else
54
-
fprintf ppf "@[@{<intro>%s@}@]@," intro;
54
+
if is_warning then
55
+
fprintf ppf "@[@{<info>%s@}@]@," intro
56
+
elsebegin
57
+
fprintf ppf "@[@{<error>%s@}@]@," intro
58
+
end;
55
59
fprintf ppf "@[%a@]@,@," print_loc loc;
56
60
let (file, start_line, start_char) =Location.get_pos_info loc.loc_start in
57
61
let (_, end_line, end_char) =Location.get_pos_info loc.loc_end in
58
62
(* things to special-case: startchar & endchar2 both -1 *)
59
63
if start_char ==-1|| end_char ==-1then
60
64
(* happens sometimes. Syntax error for example *)
61
-
fprintf ppf "This is likely a syntax error. The more relevant message should be just above!@ If it's not, please file an issue here:@ github.com/facebook/reason/issues@,"
65
+
fprintf ppf "Is there an error before this one? If so, it's likely a syntax error. The more relevant message should be just above!@ If it's not, please file an issue here:@ github.com/facebook/reason/issues@,"
62
66
elsebegin
63
67
try
64
68
let lines = file_lines file in
65
69
fprintf ppf "%a"
66
70
(Super_misc.print_file
71
+
~is_warning
67
72
~lines
68
73
~range:(
69
74
(start_line, start_char +1), (* make everything 1-index based. See justifications in Super_mic.print_file *)
@@ -79,14 +84,6 @@ let print intro ppf loc =
79
84
(* taken from https://github.com/ocaml/ocaml/blob/4.02/parsing/location.ml#L337 *)
80
85
(* This is the error report entry point. We'll replace the default reporter with this one. *)
(* btw, these are unicode chars. They're not of length 1. Careful; we need to
63
63
explicitly tell Format to treat them as length 1 below *)
64
64
let separator =if columns_to_cut =0then"│"else"┆"in
65
+
(* coloring *)
66
+
let (highlighted_line_number, highlighted_content): (string -> string -> unit, Format.formatter, unit) format * (unit, Format.formatter, unit) format =
67
+
if is_warning then ("@{<info>%s@}@{<dim> @<1>%s @}", "@{<info>")
0 commit comments