forked from ocaml/ocaml-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsonrpc.mli
138 lines (107 loc) · 2.52 KB
/
jsonrpc.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
(** Jsonrpc implementation *)
module Json : sig
type t =
[ `Assoc of (string * t) list
| `Bool of bool
| `Float of float
| `Int of int
| `Intlit of string
| `List of t list
| `Null
| `String of string
| `Tuple of t list
| `Variant of string * t option
]
(** Raised when conversions from json fail *)
exception Of_json of (string * t)
module Jsonable : sig
module type S = sig
type json
type t
val yojson_of_t : t -> json
val t_of_yojson : json -> t
end
with type json := t
end
end
module Id : sig
type t =
[ `String of string
| `Int of int
]
include Json.Jsonable.S with type t := t
val hash : t -> int
val equal : t -> t -> bool
end
module Structured : sig
type t =
[ `Assoc of (string * Json.t) list
| `List of Json.t list
]
include Json.Jsonable.S with type t := t
end
module Notification : sig
type t =
{ method_ : string
; params : Structured.t option
}
val create : ?params:Structured.t -> method_:string -> unit -> t
val yojson_of_t : t -> Json.t
end
module Request : sig
type t =
{ id : Id.t
; method_ : string
; params : Structured.t option
}
val create : ?params:Structured.t -> id:Id.t -> method_:string -> unit -> t
val yojson_of_t : t -> Json.t
end
module Response : sig
module Error : sig
module Code : sig
type t =
| ParseError
| InvalidRequest
| MethodNotFound
| InvalidParams
| InternalError
| ServerErrorStart
| ServerErrorEnd
| ServerNotInitialized
| UnknownErrorCode
| RequestFailed
| ServerCancelled
| ContentModified
| RequestCancelled
| Other of int
end
type t =
{ code : Code.t
; message : string
; data : Json.t option
}
exception E of t
val make : ?data:Json.t -> code:Code.t -> message:string -> unit -> t
val raise : t -> 'a
val of_exn : exn -> t
val yojson_of_t : t -> Json.t
end
type t =
{ id : Id.t
; result : (Json.t, Error.t) Result.t
}
val ok : Id.t -> Json.t -> t
val error : Id.t -> Error.t -> t
include Json.Jsonable.S with type t := t
end
module Packet : sig
type t =
| Notification of Notification.t
| Request of Request.t
| Response of Response.t
| Batch_response of Response.t list
| Batch_call of
[ `Request of Request.t | `Notification of Notification.t ] list
include Json.Jsonable.S with type t := t
end