diff --git a/src/EditorSupportCommands.ml b/src/EditorSupportCommands.ml index 4ac078df..e11480d2 100644 --- a/src/EditorSupportCommands.ml +++ b/src/EditorSupportCommands.ml @@ -1,5 +1,3 @@ -module J = JsonShort - let dumpLocations state ~package ~file ~extra ~selectPos uri = let locations = extra.SharedTypes.locations @@ -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 @@ -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]) @@ -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 = diff --git a/src/JsonShort.ml b/src/JsonShort.ml deleted file mode 100644 index 193a3f74..00000000 --- a/src/JsonShort.ml +++ /dev/null @@ -1,6 +0,0 @@ -open Json - -let o o = Object o -let s s = String s -let i i = Number (float_of_int i) -let l l = Array l diff --git a/src/Protocol.ml b/src/Protocol.ml index f24a5e6c..253e992d 100644 --- a/src/Protocol.ml +++ b/src/Protocol.ml @@ -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) ^ "]"