From 72ad995d148d0a89d143337dbda689a2cd0d6bbf Mon Sep 17 00:00:00 2001 From: Nicolas Berthier Date: Fri, 29 Sep 2023 15:36:58 +0200 Subject: [PATCH] Add some bits of documentation for `Cobol_common.Srcloc` --- src/lsp/cobol_common/srcloc.ml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lsp/cobol_common/srcloc.ml b/src/lsp/cobol_common/srcloc.ml index 2042b844b..7295f9d26 100644 --- a/src/lsp/cobol_common/srcloc.ml +++ b/src/lsp/cobol_common/srcloc.ml @@ -102,6 +102,9 @@ let rec start_pos: type t. t slt -> Lexing.position = function | Rpl { old; _ } -> start_pos old | Cat { left; _ } -> start_pos left +(** [shallow_multiline_lexloc_in ~filename loc] retrieves a lexical location in + [filename] from [loc], iff [loc] directly originates from [filename] and was + not subject to any replacement or copy. Returns [None] otherwise. *) let shallow_multiline_lexloc_in ~filename loc = let rec aux: type t. t slt -> lexloc option = function | Raw (s, e, _) when s.pos_fname = filename -> Some (s, e) @@ -114,6 +117,9 @@ let shallow_multiline_lexloc_in ~filename loc = in aux loc +(** [shallow_single_line_lexloc_in ~filename loc] is similar to + {!shallow_multiline_lexloc_in}, except that any returned lexical location is + guaranteed to span a single line. *) let shallow_single_line_lexloc_in ~filename = function | Raw (s, e, _) when s.pos_fname = filename -> Some (s, e) | Raw _ | Cpy _ | Rpl _ | Cat _ -> None