1234567891011121314151617181920212223242526272829303132333435363738394041424344(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)(* <O___,, * (see CREDITS file for the list of authors) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)(************************************************************************)(* Coq Language Server Protocol *)(* Copyright 2022-2023 Inria -- Dual License LGPL 2.1 / GPL3+ *)(* Written by: Emilio J. Gallego Arias *)(************************************************************************)(* We convert in case of failure to some default values *)letchar_of_index~lines~line~byte=ifline<Array.lengthlinesthenletline=Array.getlineslineinmatchUtf8.char_of_index~line~bytewith|Somechar->char|None->Utf8.lengthlineelse0letto_range~lines(p:Loc.t):Lang.Range.t=letLoc.{line_nb;line_nb_last;bol_pos;bol_pos_last;bp;ep;_}=pinletstart_line=line_nb-1inletend_line=line_nb_last-1in(* cols *)letstart_col=bp-bol_posinletend_col=ep-bol_pos_lastinletstart_col=char_of_index~lines~line:start_line~byte:start_colinletend_col=char_of_index~lines~line:end_line~byte:end_colinLang.Range.{start={line=start_line;character=start_col;offset=bp};end_={line=end_line;character=end_col;offset=ep}}letto_orange~lines=Option.map(to_range~lines)