Skip to content

Commit 897ecfa

Browse files
Andrew Kennedyfacebook-github-bot
Andrew Kennedy
authored andcommitted
Split JSON code into its own module
Summary: As title says. Reviewed By: viratyosin Differential Revision: D71116587 fbshipit-source-id: 20db8ee36880ccdacf665c529ec7173141eaae2c
1 parent 5158e48 commit 897ecfa

File tree

8 files changed

+834
-813
lines changed

8 files changed

+834
-813
lines changed

hphp/hack/src/client_and_server/cstSearchService.ml

+1-4
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,7 @@ let compile_pattern (ctx : Provider_context.t) (json : Hh_json.json) :
491491
get_obj "subtype_of" (json, keytrace)
492492
>>= fun (subtype_of_json, subtype_of_keytrace) ->
493493
let locl_ty =
494-
Typing_print.json_to_locl_ty
495-
~keytrace:subtype_of_keytrace
496-
ctx
497-
subtype_of_json
494+
Typing_json.to_locl_ty ~keytrace:subtype_of_keytrace ctx subtype_of_json
498495
in
499496
match locl_ty with
500497
| Ok locl_ty -> Ok (TypePattern { subtype_of = locl_ty })

hphp/hack/src/server/serverIsSubtype.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ let rec validate_free_type env locl_ty =
9090
in
9191
validate_l env field_tys
9292
| Tnewtype (_name, tyargs, as_ty) ->
93-
(* Typing_print.json_to_locl_ty already validates the name
93+
(* Typing_json.to_locl_ty already validates the name
9494
Interestingly it doesn't validate that the given "as" matches
9595
the defined one *)
9696
validate_l env tyargs @ validate_free_type env as_ty
9797
| Tclass_ptr ty -> validate_free_type env ty
98-
(* These aren't even created by Typing_print.json_to_locl_ty *)
98+
(* These aren't even created by Typing_json.to_locl_ty *)
9999
| Tneg _
100100
| Tvar _
101101
| Taccess _
@@ -113,7 +113,7 @@ and validate_l env locl_tyl =
113113
List.concat_map locl_tyl ~f:(validate_free_type env)
114114

115115
let get_type_from_json ctx json : (locl_ty, string list) result =
116-
let locl_ty = Typing_print.json_to_locl_ty ~keytrace:[] ctx json in
116+
let locl_ty = Typing_json.to_locl_ty ~keytrace:[] ctx json in
117117
match locl_ty with
118118
| Ok locl_ty ->
119119
let env = Typing_env_types.empty ctx Relative_path.default ~droot:None in

hphp/hack/src/typing/dune

+10
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@
281281
typing_common
282282
typing_error_utils
283283
type_mapper
284+
typing_json
284285
typing_modules)
285286
(preprocess
286287
(pps
@@ -457,6 +458,15 @@
457458
(preprocess
458459
(pps ppx_deriving.std)))
459460

461+
(library
462+
(name typing_json)
463+
(wrapped false)
464+
(modules
465+
typing_json)
466+
(libraries decl_provider hackfmt typing_env_types)
467+
(preprocess
468+
(pps ppx_deriving.std)))
469+
460470
(library
461471
(name typing_log)
462472
(wrapped false)

hphp/hack/src/typing/tast_env.ml

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ let print_decl_ty_with_identity env ty sym_occurrence sym_definition =
5858
sym_occurrence
5959
sym_definition
6060

61-
let ty_to_json env ?show_like_ty ty = Typing_print.to_json env ?show_like_ty ty
61+
let ty_to_json env ?show_like_ty ty =
62+
Typing_json.from_locl_ty env ?show_like_ty ty
6263

63-
let json_to_locl_ty = Typing_print.json_to_locl_ty
64+
let json_to_locl_ty = Typing_json.to_locl_ty
6465

6566
let get_self_id = Typing_env.get_self_id
6667

0 commit comments

Comments
 (0)