1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
(*
* An ExactCover.t represents an exact cover over 1 file.
*
* See https://en.wikipedia.org/wiki/Exact_cover; the short version is that an
* ExactCover.t represents a set of adjacent, nonoverlapping, nonempty,
* exhaustive ranges over 0 or more files.
*
* ExactCover.t is a read-only structure for efficient querying.
*
* ExactCover.builder is a write-only structure for efficient construction
* (under some assuptions) that can be baked into an ExactCover.t.
*)
of string
(* Supports O(log(n)) queries to get the value associated with a loc. *)
(* Given a filename and a value, generate a cover associating that value with that entire file. *)
(* Gets the value associated with a certain location in the code. To resolve
* ambiguity, this looks at the location of the first character in the provided
* location. Errors if queried for a file not contained in this cover. *)
(* Supports O(j*(j+k)) operations to modify a range of a cover being constructed,
* where j is the number of ranges in the builder intersecting the range being
* modified and k is the number of ranges in the builder after the range being
* modified. Note that this means that operations are O(1) in the case where
* ranges are modified in order from the beginning of the file to the end, which
* is how this builder is used. *)
(* Better complexity modifications are possible, but because the builder is only
* used to modify ranges in order, giving O(1) complexity, there was no reason
* to make them. *)
(* The builder structure is only intended to construct a cover for a single
* file. If a cover for multiple files is needed, construct and bake a cover for
* each file and use the union functions to combine them. *)
(* Create a new builder for the provided file. The resultant builder is an exact
* cover with a single range associating the whole file with the provided value. *)
(* Change the value in the provided range by applying the provided mapping
* function. Ranges in the builder that are completely contained in the provided
* range have their values replaced using the mapping function. Ranges in the
* builder that have no overlap with the provided range are left untouched.
* Ranges in the builder that intersect with the provided range are split into
* two ranges: one that is completely contained in the provided range and one
* that has no overlap with the provided range. If the provided range is
* completely contained within a range in the builder, the range in the builder
* is split into three ranges: one that matches the provided range and two that
* have no overlap wth the provided range. *)
(* Change the settings in the provided range by adding the provided settings list.
* In the settings list, the kind is the type of lint, the value is the value to set to,
* and the location is the position of the setting in the source code. *)
(* Resultant builder *)
(* Works similarly to update_settings, but takes two additional parameters: a running
* LintSettings object and an error handling function. The LintSettings object is updated with
* the new lint settings (in addition to the builder being updated), and if any redundant
* settings are encountered, the error function is called with an error message and the
* location of the error. Additionally, takes the lint settings in unflattened form so
* that errors can be properly reported. *)
(* This function only checks for settings that are redundant because they don't change
* anything. It doesn't check for settings that are redundant because they are
* immediately overwritten. (That's done elsewhere.) *)
(* Resultant running lint settings *)
(* `severity LintSettings.t`-specific functions *)
(* Given a filename, generate a cover that applies the default lint severities
* across the entire file. *)
(* Gets the severity of the provided lint kind at the provided location. Errors
* if queried for a file not contained in this cover. *)
(* True iff the provided lint kind has severity `Off` at the provided location.
* Errors if queried for a file not contained in this cover. *)
(* True iff the severity for the provided lint kind has been explicitly set at
* the provided location. Errors if queried for a file not contained in this
* cover. *)
(* Intended for debugging purposes. *)