Skip to content

Commit 53915ab

Browse files
committed
Indent and use predef_none (preferred)
1 parent 0520249 commit 53915ab

File tree

4 files changed

+95
-96
lines changed

4 files changed

+95
-96
lines changed

jscomp/syntax/ast_derive_js_mapper.ml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let js_field (o : Parsetree.expression) m =
3333
(Exp.ident m)
3434

3535

36-
36+
3737

3838
let handle_config (config : Parsetree.expression option) =
3939
match config with
@@ -152,7 +152,7 @@ let assertExp e =
152152
let derivingName = "jsConverter"
153153

154154
(* let notApplicable loc =
155-
Location.prerr_warning
155+
Location.prerr_warning
156156
loc
157157
(Warnings.Bs_derive_warning ( derivingName ^ " not applicable to this type")) *)
158158

@@ -194,8 +194,7 @@ let init () =
194194
let coerceResultToNewType e =
195195
if createType then
196196
e +> newType
197-
else e
198-
in
197+
else e in
199198
match tdcl.ptype_kind with
200199
| Ptype_record label_declarations ->
201200
let exp =
@@ -254,7 +253,7 @@ let init () =
254253
| Some name ->
255254
name
256255
| None ->
257-
Ast_compatible.const_exp_string(Ast_compatible.label_of_name label)
256+
Ast_compatible.const_exp_string(Ast_compatible.label_of_name label)
258257
)
259258
| _ -> assert false (* checked by [is_enum_polyvar] *)
260259
) in
@@ -270,7 +269,7 @@ let init () =
270269
Exp.tuple
271270
[
272271
Ast_compatible.const_exp_int i;
273-
str
272+
str
274273
]
275274
) ));
276275
(
@@ -390,11 +389,11 @@ let init () =
390389
+>
391390
core_type
392391
else
393-
(Exp.ifthenelse
394-
( (exp_param <=~ range_upper) &&~ (range_low <=~ exp_param))
395-
(Exp.construct {loc; txt = Lident "Some"}
396-
( Some (exp_param -~ Ast_compatible.const_exp_int offset)))
397-
(Some (Exp.construct {loc; txt = Lident "None"} None)))
392+
Exp.ifthenelse
393+
( (exp_param <=~ range_upper) &&~ (range_low <=~ exp_param))
394+
(Exp.construct {loc; txt = Ast_literal.predef_some}
395+
( Some (exp_param -~ Ast_compatible.const_exp_int offset)))
396+
(Some (Exp.construct {loc; txt = Ast_literal.predef_none} None))
398397
+>
399398
Ast_core_type.lift_option_type core_type
400399
)
@@ -404,13 +403,13 @@ let init () =
404403
else
405404
begin
406405
U.notApplicable
407-
tdcl.Parsetree.ptype_loc
408-
derivingName;
406+
tdcl.Parsetree.ptype_loc
407+
derivingName;
409408
[]
410409
end
411410
| Ptype_open ->
412411
U.notApplicable tdcl.Parsetree.ptype_loc
413-
derivingName;
412+
derivingName;
414413
[] in
415414
Ext_list.flat_map tdcls handle_tdcl
416415
);
@@ -467,19 +466,18 @@ let init () =
467466

468467
| None ->
469468
U.notApplicable tdcl.Parsetree.ptype_loc
470-
derivingName;
469+
derivingName;
471470
[])
472471

473472
| Ptype_variant ctors
474473
->
475-
476474
if Ast_polyvar.is_enum_constructors ctors then
477475
let ty1 =
478476
if createType then newType
479477
else Ast_literal.type_int() in
480478
let ty2 =
481479
if createType then core_type
482-
else Ast_core_type.lift_option_type core_type (*-FIXME**) in
480+
else Ast_core_type.lift_option_type core_type in
483481
newTypeStr +?
484482
[
485483
toJsType ty1;
@@ -489,19 +487,19 @@ let init () =
489487
]
490488

491489
else
492-
begin
493-
U.notApplicable tdcl.Parsetree.ptype_loc
494-
derivingName;
495-
[]
496-
end
490+
begin
491+
U.notApplicable tdcl.Parsetree.ptype_loc
492+
derivingName;
493+
[]
494+
end
497495
| Ptype_open ->
498496
U.notApplicable tdcl.Parsetree.ptype_loc
499-
derivingName;
497+
derivingName;
500498
[] in
501499
Ext_list.flat_map tdcls handle_tdcl
502500

503501
);
504502
expression_gen = None
505503
}
506504
)
507-
;
505+
;

lib/bsdep.ml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37064,7 +37064,7 @@ let js_field (o : Parsetree.expression) m =
3706437064
(Exp.ident m)
3706537065

3706637066

37067-
37067+
3706837068

3706937069
let handle_config (config : Parsetree.expression option) =
3707037070
match config with
@@ -37183,7 +37183,7 @@ let assertExp e =
3718337183
let derivingName = "jsConverter"
3718437184

3718537185
(* let notApplicable loc =
37186-
Location.prerr_warning
37186+
Location.prerr_warning
3718737187
loc
3718837188
(Warnings.Bs_derive_warning ( derivingName ^ " not applicable to this type")) *)
3718937189

@@ -37225,8 +37225,7 @@ let init () =
3722537225
let coerceResultToNewType e =
3722637226
if createType then
3722737227
e +> newType
37228-
else e
37229-
in
37228+
else e in
3723037229
match tdcl.ptype_kind with
3723137230
| Ptype_record label_declarations ->
3723237231
let exp =
@@ -37285,7 +37284,7 @@ let init () =
3728537284
| Some name ->
3728637285
name
3728737286
| None ->
37288-
Ast_compatible.const_exp_string(Ast_compatible.label_of_name label)
37287+
Ast_compatible.const_exp_string(Ast_compatible.label_of_name label)
3728937288
)
3729037289
| _ -> assert false (* checked by [is_enum_polyvar] *)
3729137290
) in
@@ -37301,7 +37300,7 @@ let init () =
3730137300
Exp.tuple
3730237301
[
3730337302
Ast_compatible.const_exp_int i;
37304-
str
37303+
str
3730537304
]
3730637305
) ));
3730737306
(
@@ -37421,11 +37420,11 @@ let init () =
3742137420
+>
3742237421
core_type
3742337422
else
37424-
(Exp.ifthenelse
37425-
( (exp_param <=~ range_upper) &&~ (range_low <=~ exp_param))
37426-
(Exp.construct {loc; txt = Lident "Some"}
37427-
( Some (exp_param -~ Ast_compatible.const_exp_int offset)))
37428-
(Some (Exp.construct {loc; txt = Lident "None"} None)))
37423+
Exp.ifthenelse
37424+
( (exp_param <=~ range_upper) &&~ (range_low <=~ exp_param))
37425+
(Exp.construct {loc; txt = Ast_literal.predef_some}
37426+
( Some (exp_param -~ Ast_compatible.const_exp_int offset)))
37427+
(Some (Exp.construct {loc; txt = Ast_literal.predef_none} None))
3742937428
+>
3743037429
Ast_core_type.lift_option_type core_type
3743137430
)
@@ -37435,13 +37434,13 @@ let init () =
3743537434
else
3743637435
begin
3743737436
U.notApplicable
37438-
tdcl.Parsetree.ptype_loc
37439-
derivingName;
37437+
tdcl.Parsetree.ptype_loc
37438+
derivingName;
3744037439
[]
3744137440
end
3744237441
| Ptype_open ->
3744337442
U.notApplicable tdcl.Parsetree.ptype_loc
37444-
derivingName;
37443+
derivingName;
3744537444
[] in
3744637445
Ext_list.flat_map tdcls handle_tdcl
3744737446
);
@@ -37498,19 +37497,18 @@ let init () =
3749837497

3749937498
| None ->
3750037499
U.notApplicable tdcl.Parsetree.ptype_loc
37501-
derivingName;
37500+
derivingName;
3750237501
[])
3750337502

3750437503
| Ptype_variant ctors
3750537504
->
37506-
3750737505
if Ast_polyvar.is_enum_constructors ctors then
3750837506
let ty1 =
3750937507
if createType then newType
3751037508
else Ast_literal.type_int() in
3751137509
let ty2 =
3751237510
if createType then core_type
37513-
else Ast_core_type.lift_option_type core_type (*-FIXME**) in
37511+
else Ast_core_type.lift_option_type core_type in
3751437512
newTypeStr +?
3751537513
[
3751637514
toJsType ty1;
@@ -37520,22 +37518,22 @@ let init () =
3752037518
]
3752137519

3752237520
else
37523-
begin
37524-
U.notApplicable tdcl.Parsetree.ptype_loc
37525-
derivingName;
37526-
[]
37527-
end
37521+
begin
37522+
U.notApplicable tdcl.Parsetree.ptype_loc
37523+
derivingName;
37524+
[]
37525+
end
3752837526
| Ptype_open ->
3752937527
U.notApplicable tdcl.Parsetree.ptype_loc
37530-
derivingName;
37528+
derivingName;
3753137529
[] in
3753237530
Ext_list.flat_map tdcls handle_tdcl
3753337531

3753437532
);
3753537533
expression_gen = None
3753637534
}
3753737535
)
37538-
;
37536+
;
3753937537

3754037538
end
3754137539
module Ast_derive_projector : sig

lib/bsppx.ml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19068,7 +19068,7 @@ let js_field (o : Parsetree.expression) m =
1906819068
(Exp.ident m)
1906919069

1907019070

19071-
19071+
1907219072

1907319073
let handle_config (config : Parsetree.expression option) =
1907419074
match config with
@@ -19187,7 +19187,7 @@ let assertExp e =
1918719187
let derivingName = "jsConverter"
1918819188

1918919189
(* let notApplicable loc =
19190-
Location.prerr_warning
19190+
Location.prerr_warning
1919119191
loc
1919219192
(Warnings.Bs_derive_warning ( derivingName ^ " not applicable to this type")) *)
1919319193

@@ -19229,8 +19229,7 @@ let init () =
1922919229
let coerceResultToNewType e =
1923019230
if createType then
1923119231
e +> newType
19232-
else e
19233-
in
19232+
else e in
1923419233
match tdcl.ptype_kind with
1923519234
| Ptype_record label_declarations ->
1923619235
let exp =
@@ -19289,7 +19288,7 @@ let init () =
1928919288
| Some name ->
1929019289
name
1929119290
| None ->
19292-
Ast_compatible.const_exp_string(Ast_compatible.label_of_name label)
19291+
Ast_compatible.const_exp_string(Ast_compatible.label_of_name label)
1929319292
)
1929419293
| _ -> assert false (* checked by [is_enum_polyvar] *)
1929519294
) in
@@ -19305,7 +19304,7 @@ let init () =
1930519304
Exp.tuple
1930619305
[
1930719306
Ast_compatible.const_exp_int i;
19308-
str
19307+
str
1930919308
]
1931019309
) ));
1931119310
(
@@ -19425,11 +19424,11 @@ let init () =
1942519424
+>
1942619425
core_type
1942719426
else
19428-
(Exp.ifthenelse
19429-
( (exp_param <=~ range_upper) &&~ (range_low <=~ exp_param))
19430-
(Exp.construct {loc; txt = Lident "Some"}
19431-
( Some (exp_param -~ Ast_compatible.const_exp_int offset)))
19432-
(Some (Exp.construct {loc; txt = Lident "None"} None)))
19427+
Exp.ifthenelse
19428+
( (exp_param <=~ range_upper) &&~ (range_low <=~ exp_param))
19429+
(Exp.construct {loc; txt = Ast_literal.predef_some}
19430+
( Some (exp_param -~ Ast_compatible.const_exp_int offset)))
19431+
(Some (Exp.construct {loc; txt = Ast_literal.predef_none} None))
1943319432
+>
1943419433
Ast_core_type.lift_option_type core_type
1943519434
)
@@ -19439,13 +19438,13 @@ let init () =
1943919438
else
1944019439
begin
1944119440
U.notApplicable
19442-
tdcl.Parsetree.ptype_loc
19443-
derivingName;
19441+
tdcl.Parsetree.ptype_loc
19442+
derivingName;
1944419443
[]
1944519444
end
1944619445
| Ptype_open ->
1944719446
U.notApplicable tdcl.Parsetree.ptype_loc
19448-
derivingName;
19447+
derivingName;
1944919448
[] in
1945019449
Ext_list.flat_map tdcls handle_tdcl
1945119450
);
@@ -19502,19 +19501,18 @@ let init () =
1950219501

1950319502
| None ->
1950419503
U.notApplicable tdcl.Parsetree.ptype_loc
19505-
derivingName;
19504+
derivingName;
1950619505
[])
1950719506

1950819507
| Ptype_variant ctors
1950919508
->
19510-
1951119509
if Ast_polyvar.is_enum_constructors ctors then
1951219510
let ty1 =
1951319511
if createType then newType
1951419512
else Ast_literal.type_int() in
1951519513
let ty2 =
1951619514
if createType then core_type
19517-
else Ast_core_type.lift_option_type core_type (*-FIXME**) in
19515+
else Ast_core_type.lift_option_type core_type in
1951819516
newTypeStr +?
1951919517
[
1952019518
toJsType ty1;
@@ -19524,22 +19522,22 @@ let init () =
1952419522
]
1952519523

1952619524
else
19527-
begin
19528-
U.notApplicable tdcl.Parsetree.ptype_loc
19529-
derivingName;
19530-
[]
19531-
end
19525+
begin
19526+
U.notApplicable tdcl.Parsetree.ptype_loc
19527+
derivingName;
19528+
[]
19529+
end
1953219530
| Ptype_open ->
1953319531
U.notApplicable tdcl.Parsetree.ptype_loc
19534-
derivingName;
19532+
derivingName;
1953519533
[] in
1953619534
Ext_list.flat_map tdcls handle_tdcl
1953719535

1953819536
);
1953919537
expression_gen = None
1954019538
}
1954119539
)
19542-
;
19540+
;
1954319541

1954419542
end
1954519543
module Ast_derive_projector : sig

0 commit comments

Comments
 (0)