Basillsp.TokensThe lexer gives us character token ranges (start_pos: int, end_pos: int) as an absolute offset from the beginning of the document, while LSP works over (line, column) positions.
This module handles converting between and query across position representations.
LineCol.t represents a line-column character position, while Token.t represents a (LineCol.t, size) token character interval.
We use an IntMap.t inverse map from <begin line character offset> -> <line number> to convert between these.
type linebreaks = int Common.Util.IntMap.tmap from character beginning a line to the line number it begins.
val linebreaks : string -> linebreaksval get_begin_line : linebreaks -> int -> Common.Util.IntMap.keyval get_linenum : linebreaks -> int -> intmodule LineCol : sig ... endmodule Token : sig ... endmodule TokenMap : sig ... endval loc_of_char_pos : linebreaks -> int -> LineCol.tval range_of_position :
linebreaks ->
Stdlib.Lexing.position ->
Stdlib.Lexing.position ->
Linol_lsp.Types.Range.tval token_of_char_range : linebreaks -> int -> int -> Token.tval token_of_lexer_token : linebreaks -> ((int * int) * string) -> Token.tval find_token_opt : 'a TokenMap.t -> LineCol.t -> 'a option