Skip to content

Commit

Permalink
[lang] [utf] Move UTF functions to lang.
Browse files Browse the repository at this point in the history
This is in anticipation of making Lang to use protocol-level
locations.
  • Loading branch information
ejgallego committed May 20, 2024
1 parent 2a4ba2d commit 3e4b126
Show file tree
Hide file tree
Showing 14 changed files with 419 additions and 416 deletions.
2 changes: 1 addition & 1 deletion controller/rq_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let get_id_at_point ~contents ~point =
let line = Array.get lines line in
(* XXX UTF this will fail on unicode chars that differ among UTF-8/16 (cc
#531) *)
match Coq.Utf8.utf8_offset_of_char ~line ~char:character with
match Lang.Utf.utf8_offset_of_char ~line ~char:character with
| None -> None
| Some character -> find_id line character
else None
2 changes: 1 addition & 1 deletion controller/rq_completion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ let validate_position ~doc ~point =
let line, char = point in
Option.map
(fun line ->
let char = Coq.Utf8.utf8_offset_of_utf16_offset ~line ~offset:char in
let char = Lang.Utf.utf8_offset_of_utf16_offset ~line ~offset:char in
String.get line char)
(validate_line ~doc ~line)

Expand Down
9 changes: 6 additions & 3 deletions controller/rq_hover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,15 @@ end
(* Register in-file hover plugins *)
let () = List.iter Register.add [ Loc_info.h; Stats.h; Type.h; Notation.h ]

let hover ~token ~doc ~point =
let point = lsp_point_to_doc_point ~doc point in
let hover ~token ~(doc : Fleche.Doc.t) ~point =
let node = Info.LC.node ~doc ~point Exact in
let range = Option.map Doc.Node.range node in
(* XXX: EJGA, ranges should be already converted, why is this needed? *)
let range = Option.map (doc_range_to_lsp_range ~doc) range in
let range =
let lines = doc.contents.lines in
(* EGJA: we will improve this soon to make it safer *)
Option.map (Lang.Utf.utf16_range_of_char_range ~lines) range
in
let hovers = Register.fire ~token ~doc ~point ~node in
match hovers with
| [] -> `Null
Expand Down
2 changes: 1 addition & 1 deletion coq/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
; depending on it, we should fix this upstream
(inline_tests)
(preprocess
(pps ppx_compare ppx_hash ppx_inline_test))
(pps ppx_compare ppx_hash))
(libraries
(select
limits_mp_impl.ml
Expand Down
295 changes: 0 additions & 295 deletions coq/utf8.ml

This file was deleted.

Loading

0 comments on commit 3e4b126

Please sign in to comment.