@@ -257,7 +257,16 @@ module ValueChange = struct
257
257
| Modified of 'change
258
258
[@@ deriving eq , show { with_path = false }]
259
259
260
- let to_json x = Hh_json. string_ @@ show (fun _ _ -> () ) x
260
+ let to_json change_to_json = function
261
+ | Added -> Hh_json. string_ " Added"
262
+ | Removed -> Hh_json. string_ " Removed"
263
+ | Modified change ->
264
+ Hh_json. JSON_Object [(" Modified" , change_to_json change)]
265
+
266
+ let map ~f = function
267
+ | Added -> Added
268
+ | Removed -> Removed
269
+ | Modified x -> Modified (f x)
261
270
end
262
271
263
272
module NamedItemsListChange = struct
@@ -281,22 +290,15 @@ type parent_changes = {
281
290
}
282
291
[@@ deriving eq , show { with_path = false }]
283
292
293
+ let classish_kind_to_json kind =
294
+ Hh_json. string_ @@ Ast_defs. show_classish_kind kind
295
+
284
296
module KindChange = struct
285
- type t = {
286
- old_kind : Ast_defs .classish_kind ;
287
- new_kind : Ast_defs .classish_kind ;
288
- }
297
+ type t = { new_kind : Ast_defs .classish_kind }
289
298
[@@ deriving eq , show { with_path = false }]
290
299
291
- let classish_kind_to_json kind =
292
- Hh_json. string_ @@ Ast_defs. show_classish_kind kind
293
-
294
- let to_json { old_kind; new_kind } =
295
- Hh_json. JSON_Object
296
- [
297
- (" old_kind" , classish_kind_to_json old_kind);
298
- (" new_kind" , classish_kind_to_json new_kind);
299
- ]
300
+ let to_json { new_kind } =
301
+ Hh_json. JSON_Object [(" new_kind" , classish_kind_to_json new_kind)]
300
302
end
301
303
302
304
module BoolChange = struct
@@ -308,7 +310,23 @@ module BoolChange = struct
308
310
let to_json x = Hh_json. string_ @@ show x
309
311
end
310
312
313
+ module ValueDiff = struct
314
+ type 'value t = {
315
+ old_value : 'value ;
316
+ new_value : 'value ;
317
+ }
318
+ [@@ deriving eq , show { with_path = false }]
319
+ end
320
+
321
+ type enum_type_change = {
322
+ base_change : Typing_defs .decl_ty ValueDiff .t option ;
323
+ constraint_change : Typing_defs .decl_ty ValueDiff .t ValueChange .t option ;
324
+ includes_change : unit NamedItemsListChange .t NamedItemsListChange .t option ;
325
+ }
326
+ [@@ deriving eq , show { with_path = false }]
327
+
311
328
type class_shell_change = {
329
+ classish_kind : Ast_defs .classish_kind ;
312
330
parent_changes : parent_changes option ;
313
331
type_parameters_change : unit NamedItemsListChange .t option ;
314
332
kind_change : KindChange .t option ;
@@ -321,7 +339,7 @@ type class_shell_change = {
321
339
module_change : unit ValueChange .t option ;
322
340
xhp_enum_values_change : bool ;
323
341
user_attributes_changes : unit NamedItemsListChange .t option ;
324
- enum_type_change : unit ValueChange .t option ;
342
+ enum_type_change : enum_type_change ValueChange .t option ;
325
343
}
326
344
[@@ deriving eq , show { with_path = false }]
327
345
@@ -450,7 +468,45 @@ module ClassShellChangeCategory = struct
450
468
]
451
469
end
452
470
471
+ let unit_to_json () = Hh_json. JSON_Null
472
+
473
+ module EnumTypeChangeCategory = struct
474
+ type t = {
475
+ has_base_change : bool ;
476
+ constraint_change_category : unit ValueChange .t option ;
477
+ includes_change_category : ListChange .t option ;
478
+ }
479
+
480
+ let of_enum_type_change (change : enum_type_change ) : t =
481
+ let { base_change; constraint_change; includes_change } = change in
482
+ {
483
+ has_base_change = Option. is_some base_change;
484
+ constraint_change_category =
485
+ Option. map (ValueChange. map ~f: (fun _ -> () )) constraint_change;
486
+ includes_change_category =
487
+ Option. map ListChange. of_list_change_map includes_change;
488
+ }
489
+
490
+ let to_json
491
+ {
492
+ has_base_change;
493
+ constraint_change_category;
494
+ includes_change_category;
495
+ } =
496
+ Hh_json. JSON_Object
497
+ [
498
+ (" has_base_change" , Hh_json. bool_ has_base_change);
499
+ ( " constraint_change_category" ,
500
+ Hh_json. opt_
501
+ (ValueChange. to_json unit_to_json)
502
+ constraint_change_category );
503
+ ( " includes_change_category" ,
504
+ Hh_json. opt_ ListChange. to_json includes_change_category );
505
+ ]
506
+ end
507
+
453
508
type t = {
509
+ classish_kind : Ast_defs .classish_kind ;
454
510
parent_changes_category : ParentsChangeCategory .t option ;
455
511
type_parameters_change_category : ListChange .t option ;
456
512
kind_change_category : KindChange .t option ;
@@ -463,26 +519,29 @@ module ClassShellChangeCategory = struct
463
519
module_change_category : unit ValueChange .t option ;
464
520
xhp_enum_values_change_category : bool ;
465
521
user_attributes_changes_category : ListChange .t option ;
466
- enum_type_change_category : unit ValueChange .t option ;
522
+ enum_type_change_category : EnumTypeChangeCategory .t ValueChange .t option ;
467
523
}
468
524
469
525
let of_class_shell_change
470
- {
471
- parent_changes;
472
- type_parameters_change;
473
- kind_change;
474
- final_change;
475
- abstract_change;
476
- is_xhp_change;
477
- internal_change;
478
- has_xhp_keyword_change;
479
- support_dynamic_type_change;
480
- module_change;
481
- xhp_enum_values_change;
482
- user_attributes_changes;
483
- enum_type_change;
484
- } =
526
+ ({
527
+ classish_kind;
528
+ parent_changes;
529
+ type_parameters_change;
530
+ kind_change;
531
+ final_change;
532
+ abstract_change;
533
+ is_xhp_change;
534
+ internal_change;
535
+ has_xhp_keyword_change;
536
+ support_dynamic_type_change;
537
+ module_change;
538
+ xhp_enum_values_change;
539
+ user_attributes_changes;
540
+ enum_type_change;
541
+ } :
542
+ class_shell_change ) =
485
543
{
544
+ classish_kind;
486
545
parent_changes_category =
487
546
Option. map ParentsChangeCategory. of_parents_change parent_changes;
488
547
type_parameters_change_category =
@@ -498,11 +557,15 @@ module ClassShellChangeCategory = struct
498
557
xhp_enum_values_change_category = xhp_enum_values_change;
499
558
user_attributes_changes_category =
500
559
Option. map ListChange. of_list_change_map user_attributes_changes;
501
- enum_type_change_category = enum_type_change;
560
+ enum_type_change_category =
561
+ Option. map
562
+ (ValueChange. map ~f: EnumTypeChangeCategory. of_enum_type_change)
563
+ enum_type_change;
502
564
}
503
565
504
566
let to_json
505
567
{
568
+ classish_kind;
506
569
parent_changes_category;
507
570
type_parameters_change_category;
508
571
kind_change_category;
@@ -520,6 +583,7 @@ module ClassShellChangeCategory = struct
520
583
let open Hh_json in
521
584
JSON_Object
522
585
[
586
+ (" classish_kind" , classish_kind_to_json classish_kind);
523
587
( " parent_changes" ,
524
588
Hh_json. opt_ ParentsChangeCategory. to_json parent_changes_category );
525
589
( " type_parameters_change" ,
@@ -537,12 +601,15 @@ module ClassShellChangeCategory = struct
537
601
Hh_json. opt_ BoolChange. to_json support_dynamic_type_change_category
538
602
);
539
603
( " module_change" ,
540
- Hh_json. opt_ ValueChange. to_json module_change_category );
604
+ Hh_json. opt_ (ValueChange. to_json unit_to_json) module_change_category
605
+ );
541
606
(" xhp_enum_values_change" , Hh_json. bool_ xhp_enum_values_change_category);
542
607
( " user_attributes_changes" ,
543
608
Hh_json. opt_ ListChange. to_json user_attributes_changes_category );
544
609
( " enum_type_change" ,
545
- Hh_json. opt_ ValueChange. to_json enum_type_change_category );
610
+ Hh_json. opt_
611
+ (ValueChange. to_json EnumTypeChangeCategory. to_json)
612
+ enum_type_change_category );
546
613
]
547
614
end
548
615
0 commit comments