Multiply entities beyond necessity even more (force better build parallelism)
[hiphop-php.git] / hphp / hack / src / parser / full_fidelity_source_text.mli
bloba7a496becb83abb89577c4d034108f677267b885
1 (*
2 * Copyright (c) 2017, 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 type t = {
11 file_path: Relative_path.t;
12 length: int;
13 text: string;
14 offset_map: Line_break_map.t;
16 [@@deriving show]
18 type pos = t * int
20 val make : Relative_path.t -> string -> t
21 (** create a new source_text.t with a path and contents *)
23 val empty : t
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 *)
32 val length : t -> int
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 *)