Skip to content

Commit d48ee33

Browse files
committed
sync ocamlformat config with syntax
1 parent 981d861 commit d48ee33

37 files changed

+453
-254
lines changed

analysis/.ocamlformat

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
profile = default
2+
version = 0.22.4
3+
4+
field-space = tight-decl
5+
break-cases = toplevel
6+
module-item-spacing = preserve
17
cases-exp-indent = 2
28
space-around-arrays = false
39
space-around-lists = false

analysis/reanalyze/src/Arnold.ml

+50-28
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module FunctionName = struct
1313
end
1414

1515
module FunctionArgs = struct
16-
type arg = {label : string; functionName : FunctionName.t}
16+
type arg = {label: string; functionName: FunctionName.t}
1717
type t = arg list
1818

1919
let empty = []
@@ -45,7 +45,7 @@ module FunctionArgs = struct
4545
end
4646

4747
module FunctionCall = struct
48-
type t = {functionName : FunctionName.t; functionArgs : FunctionArgs.t}
48+
type t = {functionName: FunctionName.t; functionArgs: FunctionArgs.t}
4949

5050
let substituteName ~sub name =
5151
match sub |> FunctionArgs.find ~label:name with
@@ -117,7 +117,9 @@ module Stats = struct
117117
termination = TerminationAnalysisInternal;
118118
message =
119119
Format.asprintf "Cache %s for @{<info>%s@}"
120-
(match hit with true -> "hit" | false -> "miss")
120+
(match hit with
121+
| true -> "hit"
122+
| false -> "miss")
121123
(FunctionCall.toString functionCall);
122124
})
123125

@@ -195,7 +197,9 @@ module Progress = struct
195197
type t = Progress | NoProgress
196198

197199
let toString progress =
198-
match progress = Progress with true -> "Progress" | false -> "NoProgress"
200+
match progress = Progress with
201+
| true -> "Progress"
202+
| false -> "NoProgress"
199203
end
200204

201205
module Call = struct
@@ -240,7 +244,9 @@ module Trace = struct
240244
let none = Toption Rnone
241245

242246
let retOptionToString r =
243-
match r = Rsome with true -> "Some" | false -> "None"
247+
match r = Rsome with
248+
| true -> "Some"
249+
| false -> "None"
244250

245251
let rec toString trace =
246252
match trace with
@@ -269,7 +275,7 @@ module Values : sig
269275
val some : progress:Progress.t -> t
270276
val toString : t -> string
271277
end = struct
272-
type t = {none : Progress.t option; some : Progress.t option}
278+
type t = {none: Progress.t option; some: Progress.t option}
273279

274280
let getNone {none} = none
275281
let getSome {some} = some
@@ -279,7 +285,9 @@ end = struct
279285
| None -> []
280286
| Some p -> ["some: " ^ Progress.toString p])
281287
@
282-
match x.none with None -> [] | Some p -> ["none: " ^ Progress.toString p])
288+
match x.none with
289+
| None -> []
290+
| Some p -> ["none: " ^ Progress.toString p])
283291
|> String.concat ", "
284292

285293
let none ~progress = {none = Some progress; some = None}
@@ -301,7 +309,7 @@ end = struct
301309
end
302310

303311
module State = struct
304-
type t = {progress : Progress.t; trace : Trace.t; valuesOpt : Values.t option}
312+
type t = {progress: Progress.t; trace: Trace.t; valuesOpt: Values.t option}
305313

306314
let toString {progress; trace; valuesOpt} =
307315
let progressStr =
@@ -340,9 +348,13 @@ module State = struct
340348
let valuesOpt =
341349
match (s1.valuesOpt, s2.valuesOpt) with
342350
| None, valuesOpt -> (
343-
match s1.progress = Progress with true -> valuesOpt | false -> None)
351+
match s1.progress = Progress with
352+
| true -> valuesOpt
353+
| false -> None)
344354
| valuesOpt, None -> (
345-
match s2.progress = Progress with true -> valuesOpt | false -> None)
355+
match s2.progress = Progress with
356+
| true -> valuesOpt
357+
| false -> None)
346358
| Some values1, Some values2 -> Some (Values.nd values1 values2)
347359
in
348360
{progress; trace; valuesOpt}
@@ -376,10 +388,10 @@ module Command = struct
376388
| Nothing
377389
| Sequence of t list
378390
| SwitchOption of {
379-
functionCall : FunctionCall.t;
380-
loc : Location.t;
381-
some : t;
382-
none : t;
391+
functionCall: FunctionCall.t;
392+
loc: Location.t;
393+
some: t;
394+
none: t;
383395
}
384396
| UnorderedSequence of t list
385397

@@ -418,7 +430,9 @@ module Command = struct
418430
| Sequence cs1 :: cs2 -> loop acc (cs1 @ cs2)
419431
| c :: cs -> loop (c :: acc) cs
420432
in
421-
match loop [] commands with [c] -> c | cs -> Sequence cs
433+
match loop [] commands with
434+
| [c] -> c
435+
| cs -> Sequence cs
422436

423437
let ( +++ ) c1 c2 = sequence [c1; c2]
424438

@@ -432,15 +446,17 @@ end
432446

433447
module Kind = struct
434448
type t = entry list
435-
and entry = {label : string; k : t}
449+
and entry = {label: string; k: t}
436450

437451
let empty = ([] : t)
438452

439453
let hasLabel ~label (k : t) =
440454
k |> List.exists (fun entry -> entry.label = label)
441455

442456
let rec entryToString {label; k} =
443-
match k = [] with true -> label | false -> label ^ ":" ^ (k |> toString)
457+
match k = [] with
458+
| true -> label
459+
| false -> label ^ ":" ^ (k |> toString)
444460

445461
and toString (kind : t) =
446462
match kind = [] with
@@ -456,8 +472,8 @@ end
456472

457473
module FunctionTable = struct
458474
type functionDefinition = {
459-
mutable body : Command.t option;
460-
mutable kind : Kind.t;
475+
mutable body: Command.t option;
476+
mutable kind: Kind.t;
461477
}
462478

463479
type t = (FunctionName.t, functionDefinition) Hashtbl.t
@@ -528,7 +544,9 @@ module FindFunctionsCalled = struct
528544

529545
let findCallees (expression : Typedtree.expression) =
530546
let isFunction =
531-
match expression.exp_desc with Texp_function _ -> true | _ -> false
547+
match expression.exp_desc with
548+
| Texp_function _ -> true
549+
| _ -> false
532550
in
533551
let callees = ref StringSet.empty in
534552
let traverseExpr = traverseExpr ~callees in
@@ -703,10 +721,10 @@ end
703721

704722
module Compile = struct
705723
type ctx = {
706-
currentFunctionName : FunctionName.t;
707-
functionTable : FunctionTable.t;
708-
innerRecursiveFunctions : (FunctionName.t, FunctionName.t) Hashtbl.t;
709-
isProgressFunction : Path.t -> bool;
724+
currentFunctionName: FunctionName.t;
725+
functionTable: FunctionTable.t;
726+
innerRecursiveFunctions: (FunctionName.t, FunctionName.t) Hashtbl.t;
727+
isProgressFunction: Path.t -> bool;
710728
}
711729

712730
let rec expression ~ctx (expr : Typedtree.expression) =
@@ -765,7 +783,9 @@ module Compile = struct
765783
| _ -> false)
766784
in
767785
let argOpt =
768-
match argOpt with Some (_, Some e) -> Some e | _ -> None
786+
match argOpt with
787+
| Some (_, Some e) -> Some e
788+
| _ -> None
769789
in
770790
let functionArg () =
771791
match
@@ -993,7 +1013,9 @@ module Compile = struct
9931013
assert false
9941014

9951015
and expressionOpt ~ctx eOpt =
996-
match eOpt with None -> Command.nothing | Some e -> e |> expression ~ctx
1016+
match eOpt with
1017+
| None -> Command.nothing
1018+
| Some e -> e |> expression ~ctx
9971019

9981020
and evalArgs ~args ~ctx command =
9991021
(* Don't assume any evaluation order on the arguments *)
@@ -1013,8 +1035,8 @@ module Compile = struct
10131035
end
10141036

10151037
module CallStack = struct
1016-
type frame = {frameNumber : int; pos : Lexing.position}
1017-
type t = {tbl : (FunctionCall.t, frame) Hashtbl.t; mutable size : int}
1038+
type frame = {frameNumber: int; pos: Lexing.position}
1039+
type t = {tbl: (FunctionCall.t, frame) Hashtbl.t; mutable size: int}
10181040

10191041
let create () = {tbl = Hashtbl.create 1; size = 0}
10201042

analysis/reanalyze/src/Common.ml

+35-35
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ end
128128

129129
module OptionalArgs = struct
130130
type t = {
131-
mutable count : int;
132-
mutable unused : StringSet.t;
133-
mutable alwaysUsed : StringSet.t;
131+
mutable count: int;
132+
mutable unused: StringSet.t;
133+
mutable alwaysUsed: StringSet.t;
134134
}
135135

136136
let empty =
@@ -169,9 +169,9 @@ module DeclKind = struct
169169
| RecordLabel
170170
| VariantCase
171171
| Value of {
172-
isToplevel : bool;
173-
mutable optionalArgs : OptionalArgs.t;
174-
sideEffects : bool;
172+
isToplevel: bool;
173+
mutable optionalArgs: OptionalArgs.t;
174+
sideEffects: bool;
175175
}
176176

177177
let isType dk =
@@ -190,27 +190,27 @@ end
190190
type posAdjustment = FirstVariant | OtherVariant | Nothing
191191

192192
type decl = {
193-
declKind : DeclKind.t;
194-
moduleLoc : Location.t;
195-
posAdjustment : posAdjustment;
196-
path : Path.t;
197-
pos : Lexing.position;
198-
posEnd : Lexing.position;
199-
posStart : Lexing.position;
200-
mutable resolved : bool;
201-
mutable report : bool;
193+
declKind: DeclKind.t;
194+
moduleLoc: Location.t;
195+
posAdjustment: posAdjustment;
196+
path: Path.t;
197+
pos: Lexing.position;
198+
posEnd: Lexing.position;
199+
posStart: Lexing.position;
200+
mutable resolved: bool;
201+
mutable report: bool;
202202
}
203203

204-
type line = {mutable declarations : decl list; original : string}
204+
type line = {mutable declarations: decl list; original: string}
205205

206206
module ExnSet = Set.Make (Exn)
207207

208208
type missingRaiseInfo = {
209-
exnName : string;
210-
exnTable : (Exn.t, LocSet.t) Hashtbl.t;
211-
locFull : Location.t;
212-
missingAnnotations : ExnSet.t;
213-
raiseSet : ExnSet.t;
209+
exnName: string;
210+
exnTable: (Exn.t, LocSet.t) Hashtbl.t;
211+
locFull: Location.t;
212+
missingAnnotations: ExnSet.t;
213+
raiseSet: ExnSet.t;
214214
}
215215

216216
type severity = Warning | Error
@@ -232,23 +232,23 @@ type deadWarning =
232232
type lineAnnotation = (decl * line) option
233233

234234
type description =
235-
| Circular of {message : string}
236-
| ExceptionAnalysis of {message : string}
235+
| Circular of {message: string}
236+
| ExceptionAnalysis of {message: string}
237237
| ExceptionAnalysisMissing of missingRaiseInfo
238-
| DeadModule of {message : string}
239-
| DeadOptional of {deadOptional : deadOptional; message : string}
238+
| DeadModule of {message: string}
239+
| DeadOptional of {deadOptional: deadOptional; message: string}
240240
| DeadWarning of {
241-
deadWarning : deadWarning;
242-
path : string;
243-
message : string;
244-
shouldWriteLineAnnotation : bool;
245-
lineAnnotation : lineAnnotation;
241+
deadWarning: deadWarning;
242+
path: string;
243+
message: string;
244+
shouldWriteLineAnnotation: bool;
245+
lineAnnotation: lineAnnotation;
246246
}
247-
| Termination of {termination : termination; message : string}
247+
| Termination of {termination: termination; message: string}
248248

249249
type issue = {
250-
name : string;
251-
severity : severity;
252-
loc : Location.t;
253-
description : description;
250+
name: string;
251+
severity: severity;
252+
loc: Location.t;
253+
description: description;
254254
}

analysis/reanalyze/src/DeadCommon.ml

+12-4
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,14 @@ let addDeclaration_ ?posEnd ?posStart ~declKind ~path ~(loc : Location.t)
344344
?(posAdjustment = Nothing) ~moduleLoc (name : Name.t) =
345345
let pos = loc.loc_start in
346346
let posStart =
347-
match posStart with Some posStart -> posStart | None -> pos
347+
match posStart with
348+
| Some posStart -> posStart
349+
| None -> pos
348350
in
349351
let posEnd =
350-
match posEnd with Some posEnd -> posEnd | None -> loc.loc_end
352+
match posEnd with
353+
| Some posEnd -> posEnd
354+
| None -> loc.loc_end
351355
in
352356
(* a .cmi file can contain locations from other files.
353357
For instance:
@@ -416,7 +420,9 @@ let emitWarning ~decl ~message deadWarning =
416420

417421
module Decl = struct
418422
let isValue decl =
419-
match decl.declKind with Value _ (* | Exception *) -> true | _ -> false
423+
match decl.declKind with
424+
| Value _ (* | Exception *) -> true
425+
| _ -> false
420426

421427
let isToplevelValueWithSideEffects decl =
422428
match decl.declKind with
@@ -634,7 +640,9 @@ let rec resolveRecursiveRefs ~checkOptionalArg ~deadDeclarations ~level
634640
|> String.concat ", "
635641
in
636642
Log_.item "%s %s %s: %d references (%s) [%d]@."
637-
(match isDead with true -> "Dead" | false -> "Live")
643+
(match isDead with
644+
| true -> "Dead"
645+
| false -> "Live")
638646
(decl.declKind |> DeclKind.toString)
639647
(decl.path |> Path.toString)
640648
(newRefs |> PosSet.cardinal)

analysis/reanalyze/src/DeadException.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
open DeadCommon
22
open Common
33

4-
type item = {exceptionPath : Path.t; locFrom : Location.t}
4+
type item = {exceptionPath: Path.t; locFrom: Location.t}
55

66
let delayedItems = ref []
77
let declarations = Hashtbl.create 1

analysis/reanalyze/src/DeadOptionalArgs.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ open Common
44
let active () = true
55

66
type item = {
7-
posTo : Lexing.position;
8-
argNames : string list;
9-
argNamesMaybe : string list;
7+
posTo: Lexing.position;
8+
argNames: string list;
9+
argNamesMaybe: string list;
1010
}
1111

1212
let delayedItems = (ref [] : item list ref)

0 commit comments

Comments
 (0)