Skip to content

Commit 89f9f64

Browse files
committed
ocamlformat 0.27.0
1 parent 6c26560 commit 89f9f64

File tree

262 files changed

+1836
-2358
lines changed

Some content is hidden

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

262 files changed

+1836
-2358
lines changed

.ocamlformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
profile = default
2-
version = 0.26.2
2+
version = 0.27.0
33

44
field-space = tight-decl
55
break-cases = toplevel

analysis/reanalyze/src/DeadCommon.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ module Decl = struct
555555
let refIsBelow (pos : Lexing.position) =
556556
decl.pos.pos_fname <> pos.pos_fname
557557
|| decl.pos.pos_cnum < pos.pos_cnum
558-
&& (* not a function defined inside a function, e.g. not a callback *)
558+
&&
559+
(* not a function defined inside a function, e.g. not a callback *)
559560
decl.posEnd.pos_cnum < pos.pos_cnum
560561
in
561562
refs |> PosSet.exists refIsBelow

analysis/reanalyze/src/Paths.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ module Config = struct
110110
| None -> ())
111111
end
112112

113-
(**
114-
* Handle namespaces in cmt files.
115-
* E.g. src/Module-Project.cmt becomes src/Module
116-
*)
113+
(** * Handle namespaces in cmt files. * E.g. src/Module-Project.cmt becomes
114+
src/Module *)
117115
let handleNamespace cmt =
118116
let cutAfterDash s =
119117
match String.index s '-' with

analysis/src/CompletionJsx.ml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,15 @@ type jsxProps = {
286286
childrenStart: (int * int) option;
287287
}
288288

289-
(**
290-
<div muted= />
289+
(** <div muted= />
291290
292-
This is a special case for JSX props, where the above code is parsed
293-
as <div muted=//, a regexp literal. We leverage that fact to trigger completion
294-
for the JSX prop value.
291+
This is a special case for JSX props, where the above code is parsed as <div
292+
muted=//, a regexp literal. We leverage that fact to trigger completion for
293+
the JSX prop value.
295294
296-
This code is safe because we also check that the location of the expression is broken,
297-
which only happens when the expression is a parse error/not complete.
298-
*)
295+
This code is safe because we also check that the location of the expression
296+
is broken, which only happens when the expression is a parse error/not
297+
complete. *)
299298
let isRegexpJsxHeuristicExpr expr =
300299
match expr.Parsetree.pexp_desc with
301300
| Pexp_extension

analysis/src/Loc.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ let toString (loc : t) =
99

1010
let hasPos ~pos loc = start loc <= pos && pos < end_ loc
1111

12-
(** Allows the character after the end to be included. Ie when the cursor is at the
13-
end of the word, like `someIdentifier<cursor>`. Useful in some scenarios. *)
12+
(** Allows the character after the end to be included. Ie when the cursor is at
13+
the end of the word, like `someIdentifier<cursor>`. Useful in some
14+
scenarios. *)
1415
let hasPosInclusiveEnd ~pos loc = start loc <= pos && pos <= end_ loc
1516

1617
let mkPosition (pos : Pos.t) =

analysis/src/References.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ let definedForLoc ~file ~package locKind =
209209
maybeLog "Yes!! got it";
210210
Some res)))
211211

212-
(** Find alternative declaration: from res in case of interface, or from resi in case of implementation *)
212+
(** Find alternative declaration: from res in case of interface, or from resi in
213+
case of implementation *)
213214
let alternateDeclared ~(file : File.t) ~package (declared : _ Declared.t) tip =
214215
match Hashtbl.find_opt package.pathsForModule file.moduleName with
215216
| None -> None

analysis/src/SharedTypes.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ and completionType =
356356
fields: field list;
357357
definition:
358358
[ `NameOnly of string
359-
(** When we only have the name, like when pulling the record from a declared type. *)
359+
(** When we only have the name, like when pulling the record from a
360+
declared type. *)
360361
| `TypeExpr of Types.type_expr
361362
(** When we have the full type expr from the compiler. *) ];
362363
}
@@ -573,7 +574,8 @@ module Completable = struct
573574
(** Additional context for nested completion where needed. *)
574575
type nestedContext =
575576
| RecordField of {seenFields: string list}
576-
(** Completing for a record field, and we already saw the following fields... *)
577+
(** Completing for a record field, and we already saw the following
578+
fields... *)
577579
| CameFromRecordField of string
578580
(** We just came from this field (we leverage use this for better
579581
completion names etc) *)
@@ -656,11 +658,13 @@ module Completable = struct
656658
| CdecoratorPayload of decoratorPayload
657659
| CextensionNode of string (** e.g. %todo *)
658660
| CnamedArg of contextPath * string * string list
659-
(** e.g. (..., "label", ["l1", "l2"]) for ...(...~l1...~l2...~label...) *)
661+
(** e.g. (..., "label", ["l1", "l2"]) for ...(...~l1...~l2...~label...)
662+
*)
660663
| Cnone (** e.g. don't complete inside strings *)
661664
| Cpath of contextPath
662665
| Cjsx of string list * string * string list
663-
(** E.g. (["M", "Comp"], "id", ["id1", "id2"]) for <M.Comp id1=... id2=... ... id *)
666+
(** E.g. (["M", "Comp"], "id", ["id1", "id2"]) for <M.Comp id1=...
667+
id2=... ... id *)
664668
| Cexpression of {
665669
contextPath: contextPath;
666670
nested: nestedPath list;

analysis/src/SignatureHelp.ml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -553,44 +553,44 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads =
553553
let offset = ref 0 in
554554
Some
555555
(`InlineRecord
556-
(fields
557-
|> List.map (fun (field : field) ->
558-
let startOffset = !offset in
559-
let argText =
560-
Printf.sprintf "%s%s: %s" field.fname.txt
561-
(if field.optional then "?" else "")
562-
(Shared.typeToString
563-
(if field.optional then
564-
Utils.unwrapIfOption field.typ
565-
else field.typ))
566-
in
567-
let endOffset =
568-
startOffset + String.length argText
569-
in
570-
offset := endOffset + String.length ", ";
571-
(argText, field, (startOffset, endOffset)))))
556+
(fields
557+
|> List.map (fun (field : field) ->
558+
let startOffset = !offset in
559+
let argText =
560+
Printf.sprintf "%s%s: %s" field.fname.txt
561+
(if field.optional then "?" else "")
562+
(Shared.typeToString
563+
(if field.optional then
564+
Utils.unwrapIfOption field.typ
565+
else field.typ))
566+
in
567+
let endOffset =
568+
startOffset + String.length argText
569+
in
570+
offset := endOffset + String.length ", ";
571+
(argText, field, (startOffset, endOffset)))))
572572
| Args [(typ, _)] ->
573573
Some
574574
(`SingleArg
575-
( typ |> Shared.typeToString,
576-
docsForLabel ~file:full.file ~package:full.package
577-
~supportsMarkdownLinks typ ))
575+
( typ |> Shared.typeToString,
576+
docsForLabel ~file:full.file ~package:full.package
577+
~supportsMarkdownLinks typ ))
578578
| Args args ->
579579
let offset = ref 0 in
580580
Some
581581
(`TupleArg
582-
(args
583-
|> List.map (fun (typ, _) ->
584-
let startOffset = !offset in
585-
let argText = typ |> Shared.typeToString in
586-
let endOffset =
587-
startOffset + String.length argText
588-
in
589-
offset := endOffset + String.length ", ";
590-
( argText,
591-
docsForLabel ~file:full.file ~package:full.package
592-
~supportsMarkdownLinks typ,
593-
(startOffset, endOffset) ))))
582+
(args
583+
|> List.map (fun (typ, _) ->
584+
let startOffset = !offset in
585+
let argText = typ |> Shared.typeToString in
586+
let endOffset =
587+
startOffset + String.length argText
588+
in
589+
offset := endOffset + String.length ", ";
590+
( argText,
591+
docsForLabel ~file:full.file ~package:full.package
592+
~supportsMarkdownLinks typ,
593+
(startOffset, endOffset) ))))
594594
in
595595
let label =
596596
constructor.name ^ "("

analysis/src/TypeUtils.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,10 +1165,11 @@ let transformCompletionToPipeCompletion ?(synthetic = false) ~env ?posOfDot
11651165
| Some posOfDot -> Some (makeAdditionalTextEditsForRemovingDot posOfDot));
11661166
}
11671167

1168-
(** This takes a type expr and the env that type expr was found in, and produces a globally unique
1169-
id for that specific type. The globally unique id is the full path to the type as seen from the root
1170-
of the project. Example: type x in module SomeModule in file SomeFile would get the globally
1171-
unique id `SomeFile.SomeModule.x`.*)
1168+
(** This takes a type expr and the env that type expr was found in, and produces
1169+
a globally unique id for that specific type. The globally unique id is the
1170+
full path to the type as seen from the root of the project. Example: type x
1171+
in module SomeModule in file SomeFile would get the globally unique id
1172+
`SomeFile.SomeModule.x`.*)
11721173
let rec findRootTypeId ~full ~env (t : Types.type_expr) =
11731174
let debug = false in
11741175
match t.desc with

analysis/src/Utils.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
(**
2-
* `startsWith(string, prefix)`
3-
* true if the string starts with the prefix
4-
*)
1+
(** * `startsWith(string, prefix)` * true if the string starts with the prefix
2+
*)
53
let startsWith s prefix =
64
if prefix = "" then true
75
else

compiler/bsb/bsb_build_util.ml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ let resolve_bsb_magic_file ~cwd ~desc p : result =
101101

102102
(** converting a file from Linux path format to Windows *)
103103

104-
(**
105-
{[
106-
mkp "a/b/c/d";;
107-
mkp "/a/b/c/d"
108-
]}
109-
*)
104+
(** {[
105+
mkp "a/b/c/d";;
106+
mkp "/a/b/c/d"
107+
]} *)
110108
let rec mkp dir =
111109
if not (Sys.file_exists dir) then
112110
let parent_dir = Filename.dirname dir in
@@ -134,16 +132,10 @@ type top = Expect_none | Expect_name of string
134132

135133
type package_context = {proj_dir: string; top: top; is_pinned: bool}
136134

137-
(**
138-
TODO: check duplicate package name
139-
?use path as identity?
140-
141-
Basic requirements
142-
1. cycle detection
143-
2. avoid duplication
144-
3. deterministic, since -make-world will also comes with -clean-world
135+
(** TODO: check duplicate package name ?use path as identity?
145136
146-
*)
137+
Basic requirements 1. cycle detection 2. avoid duplication 3. deterministic,
138+
since -make-world will also comes with -clean-world *)
147139

148140
let pp_packages_rev ppf lst =
149141
Ext_list.rev_iter lst (fun s -> Format.fprintf ppf "%s " s)

compiler/bsb/bsb_build_util.mli

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,28 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525
val flag_concat : string -> string list -> string
26-
(**
27-
Use:
28-
{[
29-
flag_concat "-ppx" [ppxs]
30-
]}
31-
*)
26+
(** Use:
27+
{[
28+
flag_concat "-ppx" [ppxs]
29+
]} *)
3230

3331
val ppx_flags : Bsb_config_types.ppx list -> string
34-
(**
35-
Build quoted commandline arguments for bsc.exe for the given ppx flags
32+
(** Build quoted commandline arguments for bsc.exe for the given ppx flags
3633
37-
Use:
38-
{[
39-
ppx_flags [ppxs]
40-
]}
41-
*)
34+
Use:
35+
{[
36+
ppx_flags [ppxs]
37+
]} *)
4238

4339
val pp_flag : string -> string
4440

4541
val include_dirs : string list -> string
46-
(**
47-
Build unquoted command line arguments for bsc.exe for the given include dirs
42+
(** Build unquoted command line arguments for bsc.exe for the given include dirs
4843
49-
Use:
50-
{[
51-
include_dirs [dirs]
52-
]}
53-
*)
44+
Use:
45+
{[
46+
include_dirs [dirs]
47+
]} *)
5448

5549
val include_dirs_by : 'a list -> ('a -> string) -> string
5650

compiler/bsb/bsb_clean.mli

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
(** clean bsc generated artifacts.
26-
TODO: clean stale in source js artifacts
27-
*)
25+
(** clean bsc generated artifacts. TODO: clean stale in source js artifacts *)
2826

2927
val clean_bs_deps : string -> unit
3028

compiler/bsb/bsb_config.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ let ocaml_bin_install_prefix p = lib_ocaml // p
6565

6666
let proj_rel path = rev_lib_bs // path
6767

68-
(** it may not be a bad idea to hard code the binary path
69-
of bsb in configuration time
70-
*)
68+
(** it may not be a bad idea to hard code the binary path of bsb in
69+
configuration time *)
7170

7271
(* let cmd_package_specs = ref None *)

compiler/bsb/bsb_config.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ val rev_lib_bs_prefix : string -> string
4646
val lib_bs_prefix_of_format : Ext_module_system.t -> string
4747

4848
val top_prefix_of_format : Ext_module_system.t -> string
49-
(** default not install, only when -make-world, its dependencies will be installed *)
49+
(** default not install, only when -make-world, its dependencies will be
50+
installed *)

compiler/bsb/bsb_config_parse.ml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,16 @@ let extract_package_name_and_namespace (map : json_map) : string * string option
6464
in
6565
(package_name, namespace)
6666

67-
(**
68-
There are two things to check:
69-
- the running bsb and vendoring bsb is the same
70-
- the running bsb need delete stale build artifacts
71-
(kinda check npm upgrade)
67+
(** There are two things to check:
68+
- the running bsb and vendoring bsb is the same
69+
- the running bsb need delete stale build artifacts (kinda check npm
70+
upgrade)
7271
73-
Note if the setup is correct:
74-
the running compiler and node_modules/rescript
75-
should be the same version,
76-
The exact check is that the running compiler should have a
77-
compatible runtime version installed, the location of the
78-
compiler is actually not relevant.
79-
We disable the check temporarily
80-
e.g,
81-
```
82-
bsc -runtime runtime_dir@version
83-
```
84-
*)
72+
Note if the setup is correct: the running compiler and node_modules/rescript
73+
should be the same version, The exact check is that the running compiler
74+
should have a compatible runtime version installed, the location of the
75+
compiler is actually not relevant. We disable the check temporarily e.g, ```
76+
bsc -runtime runtime_dir@version ``` *)
8577
let extract_gentype_config (map : json_map) : Bsb_config_types.gentype_config =
8678
match map.?(Bsb_build_schemas.gentypeconfig) with
8779
| None -> false
@@ -201,8 +193,8 @@ let extract_js_post_build (map : json_map) cwd : string option =
201193
|> ignore;
202194
!js_post_build_cmd
203195

204-
(** ATT: make sure such function is re-entrant.
205-
With a given [cwd] it works anywhere*)
196+
(** ATT: make sure such function is re-entrant. With a given [cwd] it works
197+
anywhere*)
206198
let interpret_json ~(filename : string) ~(json : Ext_json_types.t)
207199
~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string) :
208200
Bsb_config_types.t =

compiler/bsb/bsb_db_util.mli

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ val merge : Bsb_db.map -> Bsb_db.map -> Bsb_db.map
2929

3030
val sanity_check : Bsb_db.map -> unit
3131

32-
(**
33-
Currently it is okay to have duplicated module,
34-
In the future, we may emit a warning
35-
*)
32+
(** Currently it is okay to have duplicated module, In the future, we may emit a
33+
warning *)
3634

3735
val add_basename :
3836
dir:string ->

0 commit comments

Comments
 (0)