Skip to content

Commit ce94e15

Browse files
Yojson 3 compat (#1534)
* Update Yojson constraint * Make jsonrpc compatible with both Yojson 2 and 3. This patch has a drawback: now jsonrpc also depends on yojson. --------- Co-authored-by: Ulysse Gérard <[email protected]>
1 parent 4483b5b commit ce94e15

File tree

10 files changed

+17
-35
lines changed

10 files changed

+17
-35
lines changed

.github/workflows/build-and-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949

5050
# Remove this pin once a compatible version of Merlin has been released
5151
- name: Pin dev Merlin
52-
run: opam --cli=2.1 pin --with-version=5.4-503 https://github.com/ocaml/merlin.git#main
52+
run: opam --cli=2.1 pin --with-version=5.5-503 https://github.com/ocaml/merlin.git#main
5353

5454
- name: Build and install dependencies
5555
run: opam install .
@@ -90,7 +90,7 @@ jobs:
9090
9191
# Remove this pin once a compatible version of Merlin has been released
9292
- name: Pin dev Merlin
93-
run: opam --cli=2.1 pin --with-version=5.4-503 https://github.com/ocaml/merlin.git#main
93+
run: opam --cli=2.1 pin --with-version=5.5-503 https://github.com/ocaml/merlin.git#main
9494

9595
- name: Install dependencies
9696
run: |

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Fix `inlay-hint` for function parameters (#1515)
1515
- More precise diagnostics in the event of a failed identifier search (`Definition_query`) (#1518)
1616
- Remove `ocamlformat` application after `destruct` (that remove some useful parenthesis) (#1519)
17+
- Make compatible with Yojson 3.x by removing `Tuple` and `Variant` (#1534)
1718

1819
# 1.22.0
1920

dune-project

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ possible and does not make any assumptions about IO.
3131
")
3232
(depends
3333
(jsonrpc (= :version))
34-
(yojson (< 3.0.0))
34+
yojson
3535
(ppx_yojson_conv_lib (>= "v0.14"))
3636
(cinaps :with-test)
3737
(ppx_expect (and (>= v0.17.0) :with-test))
@@ -45,7 +45,7 @@ possible and does not make any assumptions about IO.
4545
(synopsis "LSP Server for OCaml")
4646
(description "An LSP server for OCaml.")
4747
(depends
48-
(yojson (< 3.0.0))
48+
yojson
4949
(base (>= v0.16.0))
5050
(lsp (= :version))
5151
(jsonrpc (= :version))
@@ -75,8 +75,9 @@ possible and does not make any assumptions about IO.
7575

7676
(package
7777
(name jsonrpc)
78-
(synopsis "Jsonrpc protocol implemenation")
78+
(synopsis "Jsonrpc protocol implementation")
7979
(description "See https://www.jsonrpc.org/specification")
8080
(depends
81+
yojson
8182
(ocaml (>= 4.08))
8283
(odoc :with-doc)))

jsonrpc.opam

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is generated by dune, edit dune-project instead
22
opam-version: "2.0"
3-
synopsis: "Jsonrpc protocol implemenation"
3+
synopsis: "Jsonrpc protocol implementation"
44
description: "See https://www.jsonrpc.org/specification"
55
maintainer: ["Rudi Grinberg <[email protected]>"]
66
authors: [
@@ -20,6 +20,7 @@ homepage: "https://github.com/ocaml/ocaml-lsp"
2020
bug-reports: "https://github.com/ocaml/ocaml-lsp/issues"
2121
depends: [
2222
"dune" {>= "3.0"}
23+
"yojson"
2324
"ocaml" {>= "4.08"}
2425
"odoc" {with-doc}
2526
]

jsonrpc/src/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(library
22
(public_name jsonrpc)
3+
(libraries yojson)
34
(instrumentation
45
(backend bisect_ppx)))

jsonrpc/src/import.ml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,7 @@ module Option = struct
99
end
1010

1111
module Json = struct
12-
type t =
13-
[ `Assoc of (string * t) list
14-
| `Bool of bool
15-
| `Float of float
16-
| `Int of int
17-
| `Intlit of string
18-
| `List of t list
19-
| `Null
20-
| `String of string
21-
| `Tuple of t list
22-
| `Variant of string * t option
23-
]
12+
type t = Yojson.Safe.t
2413

2514
exception Of_json of (string * t)
2615

jsonrpc/src/jsonrpc.mli

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
(** Jsonrpc implementation *)
22

33
module Json : sig
4-
type t =
5-
[ `Assoc of (string * t) list
6-
| `Bool of bool
7-
| `Float of float
8-
| `Int of int
9-
| `Intlit of string
10-
| `List of t list
11-
| `Null
12-
| `String of string
13-
| `Tuple of t list
14-
| `Variant of string * t option
15-
]
4+
type t = Yojson.Safe.t
165

176
(** Raised when conversions from json fail *)
187
exception Of_json of (string * t)

lsp-fiber/src/import.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ module Json = struct
6464
| `Bool f -> Bool f
6565
| `Assoc o -> Record (List.map o ~f:(fun (k, v) -> k, to_dyn v))
6666
| `List l -> List (List.map l ~f:to_dyn)
67-
| `Tuple args -> Tuple (List.map args ~f:to_dyn)
6867
| `Null -> Dyn.Variant ("Null", [])
69-
| `Variant (name, Some arg) -> Variant (name, [ to_dyn arg ])
70-
| `Variant (name, None) -> Variant (name, [])
7168
| `Intlit s -> String s
69+
| _ -> Dyn.Variant ("Unsupported", [])
70+
(* This last case is unused with Yojson >= 3 *)
71+
[@@warning "-11"]
7272
;;
7373
end
7474

lsp.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bug-reports: "https://github.com/ocaml/ocaml-lsp/issues"
2525
depends: [
2626
"dune" {>= "3.0"}
2727
"jsonrpc" {= version}
28-
"yojson" {< "3.0.0"}
28+
"yojson"
2929
"ppx_yojson_conv_lib" {>= "v0.14"}
3030
"cinaps" {with-test}
3131
"ppx_expect" {>= "v0.17.0" & with-test}

ocaml-lsp-server.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ homepage: "https://github.com/ocaml/ocaml-lsp"
2020
bug-reports: "https://github.com/ocaml/ocaml-lsp/issues"
2121
depends: [
2222
"dune" {>= "3.0"}
23-
"yojson" {< "3.0.0"}
23+
"yojson"
2424
"base" {>= "v0.16.0"}
2525
"lsp" {= version}
2626
"jsonrpc" {= version}

0 commit comments

Comments
 (0)