forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloc.mli
77 lines (53 loc) · 1.87 KB
/
loc.mli
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
(*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
type position = {
line: int;
column: int;
}
[@@deriving_inline equal]
include
sig
[@@@ocaml.warning "-32"]
val equal_position : position -> position -> bool
end[@@ocaml.doc "@inline"]
[@@@end]
type t = {
source: File_key.t option;
start: position;
_end: position;
}
val none : t
val is_none : t -> bool
val is_none_ignore_source : t -> bool
val btwn : t -> t -> t
val char_before : t -> t
val first_char : t -> t
(** [contains loc1 loc2] returns true if [loc1] entirely overlaps [loc2] *)
val contains : t -> t -> bool
(** [intersects loc1 loc2] returns true if [loc1] intersects [loc2] at all *)
val intersects : t -> t -> bool
(** [lines_intersect loc1 loc2] returns true if [loc1] and [loc2] cover any part of
the same line, even if they don't actually intersect.
For example, if [loc1] ends and then [loc2] begins later on the same line,
[intersects loc1 loc2] is false, but [lines_intersect loc1 loc2] is true. *)
val lines_intersect : t -> t -> bool
val pos_cmp : position -> position -> int
val span_compare : t -> t -> int
val compare_ignore_source : t -> t -> int
val compare : t -> t -> int
val equal : t -> t -> bool
val debug_to_string : ?include_source:bool -> t -> string
(* Relatively compact; suitable for use as a unique string identifier *)
val to_string_no_source : t -> string
val mk_loc : ?source:File_key.t -> int * int -> int * int -> t
val source : t -> File_key.t option
(** Produces a zero-width Loc.t, where start = end *)
val cursor : File_key.t option -> int -> int -> t
(* Produces a location at the start of the input location *)
val start_loc : t -> t
(* Produces a location at the end of the input location *)
val end_loc : t -> t