dead code - FileInfo.print_names
[hiphop-php.git] / hphp / hack / src / deps / fileInfo.mli
blob8b99e9e3c9f14c2eff8eccfa15792ed9e3aa5e7a
1 (*
2 * Copyright (c) 2015, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
8 *)
10 (*****************************************************************************)
11 (* This module defines the data structured used to describe the content of
12 * a file.
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 (*****************************************************************************)
20 open Prim_defs
22 (*****************************************************************************)
23 (* Parsing modes *)
24 (*****************************************************************************)
26 type mode =
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 (*****************************************************************************)
42 type name_type =
43 | Fun [@value 0]
44 | Class [@value 1]
45 | RecordDef [@value 2]
46 | Typedef [@value 3]
47 | Const [@value 4]
48 [@@deriving eq, show, enum, ord]
50 type pos =
51 | Full of Pos.t
52 | File of name_type * Relative_path.t
53 [@@deriving eq, show]
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)
69 type t = {
70 hash: hash_type;
71 file_mode: mode option;
72 funs: id list;
73 classes: id list;
74 record_defs: id list;
75 typedefs: id list;
76 consts: id list;
77 comments: (Pos.t * comment) list option;
79 [@@deriving show]
81 val empty_t : t
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. *)
89 type names = {
90 n_funs: SSet.t;
91 n_classes: SSet.t;
92 n_record_defs: SSet.t;
93 n_types: SSet.t;
94 n_consts: 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. *)
104 type saved
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
123 type diff = {
124 removed_funs: SSet.t;
125 added_funs: SSet.t;
126 removed_classes: SSet.t;
127 added_classes: SSet.t;
128 removed_types: SSet.t;
129 added_types: SSet.t;
130 removed_consts: SSet.t;
131 added_consts: SSet.t;
134 val diff : t -> t -> diff option