Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Remove JsonShort #110

Merged
merged 1 commit into from
Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/EditorSupportCommands.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module J = JsonShort

let dumpLocations state ~package ~file ~extra ~selectPos uri =
let locations =
extra.SharedTypes.locations
Expand All @@ -19,11 +17,11 @@ let dumpLocations state ~package ~file ~extra ~selectPos uri =
let isCandidate = String.length hover > 10 in
if isCandidate then (
match Hashtbl.find_opt dedupTable hover with
| Some n -> J.s ("#" ^ string_of_int n)
| Some n -> Json.String ("#" ^ string_of_int n)
| None ->
Hashtbl.replace dedupTable hover i;
J.s hover )
else J.s hover
Json.String hover )
else Json.String hover
in
let locationsInfo =
locations
Expand Down Expand Up @@ -66,7 +64,7 @@ let dumpLocations state ~package ~file ~extra ~selectPos uri =
(
[
("definition",
J.o
Json.Object
(match uriIsCurrentFile with
| true -> [range]
| false -> [("uri", Json.String (Uri2.toString uri2)); range])
Expand All @@ -78,10 +76,9 @@ let dumpLocations state ~package ~file ~extra ~selectPos uri =
let skip = skipZero || (hover = [] && def = []) in
match skip with
| true -> None
| false -> Some (J.o ([("range", Protocol.rangeOfLoc location)] @ hover @ def)))
|> J.l
| false -> Some (Json.Object ([("range", Protocol.rangeOfLoc location)] @ hover @ def)))
in
Json.stringify locationsInfo
Json.stringify (Json.Array locationsInfo)

(* Split (line,char) from filepath:line:char *)
let splitLineChar pathWithPos =
Expand Down
6 changes: 0 additions & 6 deletions src/JsonShort.ml

This file was deleted.

6 changes: 2 additions & 4 deletions src/Protocol.ml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
module J = JsonShort

let posOfLexing {Lexing.pos_lnum; pos_cnum; pos_bol} =
J.o [("line", J.i (pos_lnum - 1)); ("character", J.i (pos_cnum - pos_bol))]
Json.Object [("line", Json.Number (float_of_int (pos_lnum - 1))); ("character", Json.Number (float_of_int (pos_cnum - pos_bol)))]

let rangeOfLoc {Location.loc_start; loc_end} =
J.o [("start", posOfLexing loc_start); ("end", posOfLexing loc_end)]
Json.Object [("start", posOfLexing loc_start); ("end", posOfLexing loc_end)]

let array l = "[" ^ (String.concat ", " l) ^ "]"

Expand Down