Skip to content

Commit 2837e08

Browse files
authored
Auto-format vendored OCaml sources like in compiler repo (#1053)
* Auto-format vendored OCaml sources like in compiler repo * CHANGELOG
1 parent 8849a58 commit 2837e08

File tree

209 files changed

+31097
-30987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+31097
-30987
lines changed

.ocamlformat-ignore

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
analysis/vendor/compiler-libs-406/*
2-
analysis/vendor/res_outcome_printer/*
1+
analysis/vendor/js_parser/**
2+
analysis/vendor/ml/cmt_format.ml
3+
analysis/vendor/ml/parser.ml
4+
analysis/vendor/ml/pprintast.ml
5+
analysis/vendor/ext/bs_hash_stubs.ml
6+
analysis/vendor/ext/js_reserved_map.ml
7+
analysis/vendor/ext/ext_string.ml
8+
analysis/vendor/ext/ext_string.mli
9+
analysis/vendor/ext/ext_sys.ml
10+
analysis/vendor/ext/hash.cppo.ml
11+
analysis/vendor/ext/hash_set.cppo.ml
12+
analysis/vendor/ext/map.cppo.ml
13+
analysis/vendor/ext/ordered_hash_map.cppo.ml
14+
analysis/vendor/ext/set.cppo.ml
15+
analysis/vendor/ext/vec.cppo.ml

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
- Enable incremental typechecking and project config cache by default. https://github.com/rescript-lang/rescript-vscode/pull/1047
1818

19+
#### :house: Internal
20+
21+
- Auto-format vendored OCaml sources like in compiler repo. https://github.com/rescript-lang/rescript-vscode/pull/1053
22+
1923
## 1.58.0
2024

2125
#### :bug: Bug fix

analysis/vendor/.ocamlformat

-1
This file was deleted.

analysis/vendor/ext/.ocamlformat

-1
This file was deleted.

analysis/vendor/ext/bsb_db.ml

+5-6
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,16 @@ type info =
3131
| Impl
3232
| Impl_intf
3333

34-
3534
type module_info = {
36-
mutable info : info;
37-
dir : string;
38-
case : bool;
39-
name_sans_extension : string;
35+
mutable info: info;
36+
dir: string;
37+
case: bool;
38+
name_sans_extension: string;
4039
}
4140

4241
type map = module_info Map_string.t
4342

44-
type 'a cat = { mutable lib : 'a; mutable dev : 'a }
43+
type 'a cat = {mutable lib: 'a; mutable dev: 'a}
4544

4645
type t = map cat
4746
(** indexed by the group *)

analysis/vendor/ext/bsb_db.mli

+5-6
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,16 @@ type info =
3737
| Impl
3838
| Impl_intf
3939

40-
4140
type module_info = {
42-
mutable info : info;
43-
dir : string;
44-
case : bool;
45-
name_sans_extension : string;
41+
mutable info: info;
42+
dir: string;
43+
case: bool;
44+
name_sans_extension: string;
4645
}
4746

4847
type map = module_info Map_string.t
4948

50-
type 'a cat = { mutable lib : 'a; mutable dev : 'a }
49+
type 'a cat = {mutable lib: 'a; mutable dev: 'a}
5150

5251
type t = map cat
5352

analysis/vendor/ext/bsc_args.ml

+38-38
Original file line numberDiff line numberDiff line change
@@ -64,35 +64,35 @@ let usage_b (buf : Ext_buffer.t) ~usage (speclist : t) =
6464
while !cur < doc_length do
6565
match String.index_from_opt doc !cur '\n' with
6666
| None ->
67-
if !cur <> 0 then (
68-
buf +> "\n";
69-
buf +> String.make (!max_col + 4) ' ');
70-
buf +> String.sub doc !cur (String.length doc - !cur);
71-
cur := doc_length
67+
if !cur <> 0 then (
68+
buf +> "\n";
69+
buf +> String.make (!max_col + 4) ' ');
70+
buf +> String.sub doc !cur (String.length doc - !cur);
71+
cur := doc_length
7272
| Some new_line_pos ->
73-
if !cur <> 0 then (
74-
buf +> "\n";
75-
buf +> String.make (!max_col + 4) ' ');
76-
buf +> String.sub doc !cur (new_line_pos - !cur);
77-
cur := new_line_pos + 1
73+
if !cur <> 0 then (
74+
buf +> "\n";
75+
buf +> String.make (!max_col + 4) ' ');
76+
buf +> String.sub doc !cur (new_line_pos - !cur);
77+
cur := new_line_pos + 1
7878
done;
7979
buf +> "\n"))
8080

8181
let stop_raise ~usage ~(error : error) (speclist : t) =
8282
let b = Ext_buffer.create 200 in
8383
(match error with
8484
| Unknown ("-help" | "--help" | "-h") ->
85-
usage_b b ~usage speclist;
86-
Ext_buffer.output_buffer stdout b;
87-
exit 0
85+
usage_b b ~usage speclist;
86+
Ext_buffer.output_buffer stdout b;
87+
exit 0
8888
| Unknown s ->
89-
b +> "Unknown option \"";
90-
b +> s;
91-
b +> "\".\n"
89+
b +> "Unknown option \"";
90+
b +> s;
91+
b +> "\".\n"
9292
| Missing s ->
93-
b +> "Option \"";
94-
b +> s;
95-
b +> "\" needs an argument.\n");
93+
b +> "Option \"";
94+
b +> s;
95+
b +> "\" needs an argument.\n");
9696
usage_b b ~usage speclist;
9797
bad_arg (Ext_buffer.contents b)
9898

@@ -106,25 +106,25 @@ let parse_exn ~usage ~argv ?(start = 1) ?(finish = Array.length argv)
106106
if s <> "" && s.[0] = '-' then
107107
match Ext_spec.assoc3 speclist s with
108108
| Some action -> (
109-
match action with
110-
| Unit_dummy -> ()
111-
| Unit r -> (
112-
match r with
113-
| Unit_set r -> r := true
114-
| Unit_clear r -> r := false
115-
| Unit_call f -> f ()
116-
| Unit_lazy f -> Lazy.force f)
117-
| String f -> (
118-
if !current >= finish then
119-
stop_raise ~usage ~error:(Missing s) speclist
120-
else
121-
let arg = argv.(!current) in
122-
incr current;
123-
match f with
124-
| String_call f -> f arg
125-
| String_set u -> u := arg
126-
| String_optional_set s -> s := Some arg
127-
| String_list_add s -> s := arg :: !s))
109+
match action with
110+
| Unit_dummy -> ()
111+
| Unit r -> (
112+
match r with
113+
| Unit_set r -> r := true
114+
| Unit_clear r -> r := false
115+
| Unit_call f -> f ()
116+
| Unit_lazy f -> Lazy.force f)
117+
| String f -> (
118+
if !current >= finish then
119+
stop_raise ~usage ~error:(Missing s) speclist
120+
else
121+
let arg = argv.(!current) in
122+
incr current;
123+
match f with
124+
| String_call f -> f arg
125+
| String_set u -> u := arg
126+
| String_optional_set s -> s := Some arg
127+
| String_list_add s -> s := arg :: !s))
128128
| None -> stop_raise ~usage ~error:(Unknown s) speclist
129129
else rev_list := s :: !rev_list
130130
done;

analysis/vendor/ext/config.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ val version : string
2121
val standard_library : string
2222
(* The directory containing the standard libraries *)
2323

24-
val syntax_kind : [ `ml | `rescript ] ref
24+
val syntax_kind : [`ml | `rescript] ref
2525

2626
val bs_only : bool ref
2727

@@ -48,4 +48,4 @@ val cmt_magic_number : string
4848
val print_config : out_channel -> unit
4949

5050
type uncurried = Legacy | Uncurried | Swap
51-
val uncurried : uncurried ref
51+
val uncurried : uncurried ref

analysis/vendor/ext/ext_array.ml

+58-54
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ let reverse a =
5050
let reverse_of_list = function
5151
| [] -> [||]
5252
| hd :: tl ->
53-
let len = List.length tl in
54-
let a = Array.make (len + 1) hd in
55-
let rec fill i = function
56-
| [] -> a
57-
| hd :: tl ->
58-
Array.unsafe_set a i hd;
59-
fill (i - 1) tl
60-
in
61-
fill (len - 1) tl
53+
let len = List.length tl in
54+
let a = Array.make (len + 1) hd in
55+
let rec fill i = function
56+
| [] -> a
57+
| hd :: tl ->
58+
Array.unsafe_set a i hd;
59+
fill (i - 1) tl
60+
in
61+
fill (len - 1) tl
6262

6363
let filter a f =
6464
let arr_len = Array.length a in
@@ -76,7 +76,9 @@ let filter_map a (f : _ -> _ option) =
7676
if i = arr_len then reverse_of_list acc
7777
else
7878
let v = Array.unsafe_get a i in
79-
match f v with Some v -> aux (v :: acc) (i + 1) | None -> aux acc (i + 1)
79+
match f v with
80+
| Some v -> aux (v :: acc) (i + 1)
81+
| None -> aux acc (i + 1)
8082
in
8183
aux [] 0
8284

@@ -101,7 +103,9 @@ let rec tolist_aux a f i res =
101103
if i < 0 then res
102104
else
103105
tolist_aux a f (i - 1)
104-
(match f a.!(i) with Some v -> v :: res | None -> res)
106+
(match f a.!(i) with
107+
| Some v -> v :: res
108+
| None -> res)
105109

106110
let to_list_map a f = tolist_aux a f (Array.length a - 1) []
107111

@@ -110,50 +114,50 @@ let to_list_map_acc a acc f = tolist_aux a f (Array.length a - 1) acc
110114
let of_list_map a f =
111115
match a with
112116
| [] -> [||]
113-
| [ a0 ] ->
114-
let b0 = f a0 in
115-
[| b0 |]
116-
| [ a0; a1 ] ->
117-
let b0 = f a0 in
118-
let b1 = f a1 in
119-
[| b0; b1 |]
120-
| [ a0; a1; a2 ] ->
121-
let b0 = f a0 in
122-
let b1 = f a1 in
123-
let b2 = f a2 in
124-
[| b0; b1; b2 |]
125-
| [ a0; a1; a2; a3 ] ->
126-
let b0 = f a0 in
127-
let b1 = f a1 in
128-
let b2 = f a2 in
129-
let b3 = f a3 in
130-
[| b0; b1; b2; b3 |]
131-
| [ a0; a1; a2; a3; a4 ] ->
132-
let b0 = f a0 in
133-
let b1 = f a1 in
134-
let b2 = f a2 in
135-
let b3 = f a3 in
136-
let b4 = f a4 in
137-
[| b0; b1; b2; b3; b4 |]
117+
| [a0] ->
118+
let b0 = f a0 in
119+
[|b0|]
120+
| [a0; a1] ->
121+
let b0 = f a0 in
122+
let b1 = f a1 in
123+
[|b0; b1|]
124+
| [a0; a1; a2] ->
125+
let b0 = f a0 in
126+
let b1 = f a1 in
127+
let b2 = f a2 in
128+
[|b0; b1; b2|]
129+
| [a0; a1; a2; a3] ->
130+
let b0 = f a0 in
131+
let b1 = f a1 in
132+
let b2 = f a2 in
133+
let b3 = f a3 in
134+
[|b0; b1; b2; b3|]
135+
| [a0; a1; a2; a3; a4] ->
136+
let b0 = f a0 in
137+
let b1 = f a1 in
138+
let b2 = f a2 in
139+
let b3 = f a3 in
140+
let b4 = f a4 in
141+
[|b0; b1; b2; b3; b4|]
138142
| a0 :: a1 :: a2 :: a3 :: a4 :: tl ->
139-
let b0 = f a0 in
140-
let b1 = f a1 in
141-
let b2 = f a2 in
142-
let b3 = f a3 in
143-
let b4 = f a4 in
144-
let len = List.length tl + 5 in
145-
let arr = Array.make len b0 in
146-
Array.unsafe_set arr 1 b1;
147-
Array.unsafe_set arr 2 b2;
148-
Array.unsafe_set arr 3 b3;
149-
Array.unsafe_set arr 4 b4;
150-
let rec fill i = function
151-
| [] -> arr
152-
| hd :: tl ->
153-
Array.unsafe_set arr i (f hd);
154-
fill (i + 1) tl
155-
in
156-
fill 5 tl
143+
let b0 = f a0 in
144+
let b1 = f a1 in
145+
let b2 = f a2 in
146+
let b3 = f a3 in
147+
let b4 = f a4 in
148+
let len = List.length tl + 5 in
149+
let arr = Array.make len b0 in
150+
Array.unsafe_set arr 1 b1;
151+
Array.unsafe_set arr 2 b2;
152+
Array.unsafe_set arr 3 b3;
153+
Array.unsafe_set arr 4 b4;
154+
let rec fill i = function
155+
| [] -> arr
156+
| hd :: tl ->
157+
Array.unsafe_set arr i (f hd);
158+
fill (i + 1) tl
159+
in
160+
fill 5 tl
157161

158162
(**
159163
{[

analysis/vendor/ext/ext_buffer.ml

+2-6
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@
1515

1616
(* Extensible buffers *)
1717

18-
type t = {
19-
mutable buffer : bytes;
20-
mutable position : int;
21-
mutable length : int;
22-
}
18+
type t = {mutable buffer: bytes; mutable position: int; mutable length: int}
2319

2420
let create n =
2521
let n = if n < 1 then 1 else n in
2622
let s = Bytes.create n in
27-
{ buffer = s; position = 0; length = n }
23+
{buffer = s; position = 0; length = n}
2824

2925
let contents b = Bytes.sub_string b.buffer 0 b.position
3026
(* let to_bytes b = Bytes.sub b.buffer 0 b.position *)

analysis/vendor/ext/ext_bytes.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424

2525
external unsafe_blit_string : string -> int -> bytes -> int -> int -> unit
2626
= "caml_blit_string"
27-
[@@noalloc]
27+
[@@noalloc]

analysis/vendor/ext/ext_bytes.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424

2525
external unsafe_blit_string : string -> int -> bytes -> int -> int -> unit
2626
= "caml_blit_string"
27-
[@@noalloc]
27+
[@@noalloc]

analysis/vendor/ext/ext_char.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
*)
2828

2929
let valid_hex x =
30-
match x with '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' -> true | _ -> false
30+
match x with
31+
| '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' -> true
32+
| _ -> false
3133

3234
let is_lower_case c =
3335
(c >= 'a' && c <= 'z')

analysis/vendor/ext/ext_color.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ let code_of_style = function
5959
(** TODO: add more styles later *)
6060
let style_of_tag s =
6161
match s with
62-
| Format.String_tag "error" -> [ Bold; FG Red ]
63-
| Format.String_tag "warning" -> [ Bold; FG Magenta ]
64-
| Format.String_tag "info" -> [ Bold; FG Yellow ]
65-
| Format.String_tag "dim" -> [ Dim ]
66-
| Format.String_tag "filename" -> [ FG Cyan ]
62+
| Format.String_tag "error" -> [Bold; FG Red]
63+
| Format.String_tag "warning" -> [Bold; FG Magenta]
64+
| Format.String_tag "info" -> [Bold; FG Yellow]
65+
| Format.String_tag "dim" -> [Dim]
66+
| Format.String_tag "filename" -> [FG Cyan]
6767
| _ -> []
6868

6969
let ansi_of_tag s =

0 commit comments

Comments
 (0)