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.
10 (*****************************************************************************)
11 (* This module defines the data structured used to describe the content of
13 * The parser constructs FileInfo.t structs, that contain names and positions
14 * plus some extra info required for the build.
15 * After the names have been checked (Naming.make_env), we "simplify" the
16 * struct and only keep the names defined in the files we know about.
18 (*****************************************************************************)
22 (*****************************************************************************)
24 (*****************************************************************************)
27 | Mhhi
(* just declare signatures, don't check anything *)
28 | Mstrict
(* check everything! *)
29 | Mpartial
(* Don't fail if you see a function/class you don't know *)
30 [@@deriving eq
, show
, enum
]
32 val is_strict
: mode
-> bool
34 val parse_mode
: string -> mode
option
36 val string_of_mode
: mode
-> string
38 (*****************************************************************************)
39 (* The record produced by the parsing phase. *)
40 (*****************************************************************************)
45 | RecordDef
[@value 2]
48 [@@deriving eq
, show
, enum
, ord
]
52 | File
of name_type
* Relative_path.t
55 type id
= pos
* string [@@deriving eq
, show
]
57 val pos_full
: Pos.t
* string -> id
59 val get_pos_filename
: pos
-> Relative_path.t
61 (** The hash value of a decl AST.
62 We use this to see if two versions of a file are "similar", i.e. their
63 declarations only differ by position information. *)
64 type hash_type
= Int64.t
option [@@deriving eq
]
66 (** [FileInfo.t] is (1) what we get out of the parser, with Full positions;
67 (2) the API for putting stuff into and taking stuff out of saved-state naming table (with File positions)
71 file_mode
: mode
option;
77 comments
: (Pos.t
* comment
) list
option;
83 (*****************************************************************************)
84 (* The simplified record used after parsing. *)
85 (*****************************************************************************)
87 (** [FileInfo.names] is a cut-down version of [FileInfo.t], one that we use internally
88 for decl-diffing and other fanout calculations. *)
92 n_record_defs
: SSet.t
;
97 (*****************************************************************************)
98 (* The record used in our saved state. *)
99 (*****************************************************************************)
101 (** Although [FileInfo.t] is the public API for storing/retrieving entries in the naming-table,
102 we actually store the naming-table on disk as [FileInfo.saved] - it's basically the same but
103 has a slightly more compact representation in order to save space. *)
106 val empty_names
: names
108 (*****************************************************************************)
109 (* Functions simplifying the file information. *)
110 (*****************************************************************************)
111 val simplify
: t
-> names
113 val merge_names
: names
-> names
-> names
115 val to_saved
: t
-> saved
117 val from_saved
: Relative_path.t
-> saved
-> t
119 val saved_to_names
: saved
-> names
121 val to_string
: t
-> string
124 removed_funs
: SSet.t
;
126 removed_classes
: SSet.t
;
127 added_classes
: SSet.t
;
128 removed_types
: SSet.t
;
130 removed_consts
: SSet.t
;
131 added_consts
: SSet.t
;
134 val diff
: t
-> t
-> diff
option