2 * Copyright (c) 2017, 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.
11 file_path
: Relative_path.t
;
14 offset_map
: Line_break_map.t
;
20 val make
: Relative_path.t
-> string -> t
21 (** create a new source_text.t with a path and contents *)
24 (** empty source_text.t located nowhere *)
26 val from_file
: Relative_path.t
-> t
27 (** read a relative path into a source_text.t with the contents at that path *)
29 val file_path
: t
-> Relative_path.t
30 (** get the relative path *)
33 (** get the length of the contents *)
35 val get
: t
-> int -> char
36 (** get the ith character *)
38 val text
: t
-> string
39 (** get the contents as a string *)
41 val line_text
: t
-> int -> string
42 (** get just one line as a string *)
44 val sub
: t
-> int -> int -> string
45 (** get a substring start at the ith char and continuing for length *)
47 val offset_to_position
: t
-> int -> int * int
48 (** convert an absolute offset into a (line number, column) pair *)
50 val position_to_offset
: t
-> int * int -> int
51 (** convert a (line number, column) pair into an absolute offset *)
53 val relative_pos
: Relative_path.t
-> t
-> int -> int -> Pos.t
54 (** construct a relative position associated with the source_text.t virtual file *)