2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
12 let check_cache_consistency x expected_kind expected_result
=
14 Relative_path.equal expected_result
Relative_path.default
15 && (not
@@ Naming_heap.has_local_changes
())
17 Hh_logger.log
"WARNING: found dummy path in shared heap for %s" x
;
18 match Naming_heap.Types.get_pos ~bypass_cache
:true x
with
20 when Naming_types.equal_kind_of_type kind expected_kind
21 && Relative_path.equal
22 (FileInfo.get_pos_filename pos
)
26 Hh_logger.log
"WARNING: get and get_no_cache returned different results"
29 let get_type_id_filename x expected_kind
=
30 Counters.count_decl_accessor
@@ fun () ->
31 match Naming_heap.Types.get_filename_and_kind x
with
32 | Some
(fn
, kind
) when Naming_types.equal_kind_of_type kind expected_kind
->
33 check_cache_consistency x expected_kind fn
;
37 let get_class = Typing_classes_heap.Classes.get
40 Counters.count_decl_accessor
@@ fun () ->
41 match Typing_heap.Funs.get x
with
44 (match Naming_heap.Funs.get_filename x
with
47 Errors.run_in_decl_mode filename
(fun () ->
48 Decl.declare_fun_in_file ctx filename x
)
53 let get_gconst ctx cst_name
=
54 Counters.count_decl_accessor
@@ fun () ->
55 match Typing_heap.GConsts.get cst_name
with
58 (match Naming_provider.get_const_path cst_name
with
61 Errors.run_in_decl_mode filename
(fun () ->
62 Decl.declare_const_in_file ctx filename cst_name
)
67 let get_record_def ctx x
=
68 Counters.count_decl_accessor
@@ fun () ->
69 match Typing_heap.RecordDefs.get x
with
72 (match get_type_id_filename x
Naming_types.TRecordDef
with
75 Errors.run_in_decl_mode filename
(fun () ->
76 Decl.declare_record_def_in_file ctx filename x
)
81 let get_typedef ctx x
=
82 Counters.count_decl_accessor
@@ fun () ->
83 match Typing_heap.Typedefs.get x
with
86 (match get_type_id_filename x
Naming_types.TTypedef
with
89 Errors.run_in_decl_mode filename
(fun () ->
90 Decl.declare_typedef_in_file ctx filename x
)