diff --git a/dune-project b/dune-project index 8c1d67e8e..3df3b740f 100644 --- a/dune-project +++ b/dune-project @@ -1,6 +1,7 @@ (lang dune 3.0) (using cinaps 1.0) (name lsp) +(version "1.19.0+ox") (implicit_transitive_deps false) @@ -38,7 +39,7 @@ possible and does not make any assumptions about IO. (uutf (>= 1.0.2)) (odoc :with-doc) (ocaml (>= 4.14)) - (ppx_yojson_conv :with-dev-setup))) + ppx_yojson_conv)) (package (name ocaml-lsp-server) @@ -56,7 +57,7 @@ possible and does not make any assumptions about IO. dyn stdune (fiber (and (>= 3.1.1) (< 4.0.0))) - (ocaml (and (>= 5.3) (< 5.4))) + ocaml xdg ordering dune-build-info @@ -70,8 +71,12 @@ possible and does not make any assumptions about IO. (csexp (>= 1.5)) (ocamlformat-rpc-lib (>= 0.21.0)) (odoc :with-doc) - (merlin-lib (and (>= 5.4) (< 6.0))) - (ppx_yojson_conv :with-dev-setup))) + (odoc-parser (= "3.1.0+ox")) + (merlin-lib (= "5.2.1-502+ox")) + ppx_yojson_conv + core_unix + async + cmarkit)) (package (name jsonrpc) @@ -79,4 +84,5 @@ possible and does not make any assumptions about IO. (description "See https://www.jsonrpc.org/specification") (depends (ocaml (>= 4.08)) - (odoc :with-doc))) + (odoc :with-doc) + (yojson (and (>= 2.0.0) (< 3.0.0))))) diff --git a/fiber-async/src/dune b/fiber-async/src/dune new file mode 100644 index 000000000..41b42b53c --- /dev/null +++ b/fiber-async/src/dune @@ -0,0 +1,6 @@ +(library + (name fiber_async) + (inline_tests) + (libraries async async_kernel base core fiber stdune) + (preprocess + (pps ppx_jane))) diff --git a/fiber-async/src/fiber_async.ml b/fiber-async/src/fiber_async.ml new file mode 100644 index 000000000..5e7ba3b26 --- /dev/null +++ b/fiber-async/src/fiber_async.ml @@ -0,0 +1,55 @@ +open Core +open Async + +module Fiber = struct + include Fiber + + include Monad.Make (struct + include Fiber + + let map = `Custom map + end) +end + +(* Fiber-local storage. [Univ_map.Key] behind the scenes. *) +let (key : (Fiber.fill -> unit) option Fiber.Var.t) = Fiber.Var.create () + +(* This solution is adapted from the [Fiber_lwt] module in Dune. When the fiber scheduler + reaches a [Fiber.Ivar.read] for an unfilled [Fiber.Ivar.t], it stalls, and when resumed + it must be give a [Fiber.Fill (ivar, value)] for that ivar so it can enqueue jobs + waiting on its result. If the [Fiber.Ivar.t] is filled but the fill is not communicated + to the scheduler, the scheduler will not know the jobs waiting on it are now ready to + run. Therefore, when we create a [Fiber.Ivar.t] inside [fiber_of_deferred] to hold the + value when the deferred is filled, we also need some way to communicate with the + fiber's scheduler. We do this via a pipe that the scheduler provides in fiber-local + storage, but for that to work the fiber's scheduler must be the one produced by the + complementary [deferred_of_fiber]. *) + +let fiber_of_deferred (type a) (deferred : a Deferred.t) : a Fiber.t = + let ivar = Fiber.Ivar.create () in + match%bind.Fiber Fiber.Var.get key with + | None -> failwith "[fiber_of_deferred] invoked outside of [deferred_of_fiber]" + | Some fill -> + match fill with + | None -> failwith "[fiber_of_deferred] invoked outside of [deferred_of_fiber]" + | Some fill -> + upon deferred (fun value -> fill (Fiber.Fill (ivar, value))); + Fiber.Ivar.read ivar +;; + +let deferred_of_fiber fiber () = + let reader, writer = Pipe.create () in + let fiber = + Fiber.Var.set key (Some (Pipe.write_without_pushback writer)) (fun () -> fiber) + in + let rec loop witness = function + | Fiber.Scheduler.Done x -> return x + | Fiber.Scheduler.Stalled _ -> + let%bind fill = Pipe.read_exn reader in + loop witness (Fiber.Scheduler.advance witness [ fill ]) + in + let step = Fiber.Scheduler.start fiber in + match step with + | Done x -> return x + | Stalled witness -> loop witness step +;; diff --git a/fiber-async/src/fiber_async.mli b/fiber-async/src/fiber_async.mli new file mode 100644 index 000000000..cf0733b25 --- /dev/null +++ b/fiber-async/src/fiber_async.mli @@ -0,0 +1,26 @@ +open Core +open Async + +(** Interoperation between fibers and Async. This library assumes that the outer program + is running with Async and that the fibers will be interpreted by [deferred_of_fiber]. + + The most important difference between fibers and deferreds is that fibers are just + continuations and do not store the value they compute, so if you bind twice on a given + fiber the computation will be run twice. A [Fiber.Ivar.t] can be used to save the + result of a computation. *) + +module Fiber : sig + include module type of struct + include Fiber + end + + include Monad.S with type 'a t := 'a t +end + +(** Convert a fiber to a computation that returns a deferred when run. *) +val deferred_of_fiber : 'a Fiber.t -> (unit -> 'a Deferred.t) + +(** Convert a deferred to a fiber that stores the result in a [Fiber.Ivar.t]. This fiber + can only be interpreted by [deferred_of_fiber] - using a different scheduler to run it + will fail. *) +val fiber_of_deferred : 'a Deferred.t -> 'a Fiber.t diff --git a/jsonrpc-fiber/src/import.ml b/jsonrpc-fiber/src/import.ml index 92a498edc..8d923d3d1 100644 --- a/jsonrpc-fiber/src/import.ml +++ b/jsonrpc-fiber/src/import.ml @@ -77,7 +77,7 @@ end let sprintf = Printf.sprintf let () = - Printexc.register_printer (function + (Printexc.register_printer [@ocaml.alert "-unsafe_multidomain"]) (function | Jsonrpc.Response.Error.E t -> let json = Jsonrpc.Response.Error.yojson_of_t t in Some ("jsonrpc response error " ^ Json.to_pretty_string (json :> Json.t)) diff --git a/jsonrpc-fiber/src/jsonrpc_fiber.ml b/jsonrpc-fiber/src/jsonrpc_fiber.ml index 5d0df8c11..a2cd8a1db 100644 --- a/jsonrpc-fiber/src/jsonrpc_fiber.ml +++ b/jsonrpc-fiber/src/jsonrpc_fiber.ml @@ -35,7 +35,7 @@ end exception Stopped of Request.t let () = - Printexc.register_printer (function + (Printexc.register_printer [@ocaml.alert "-unsafe_multidomain"]) (function | Stopped req -> let json = Request.yojson_of_t req in Some ("Session closed. Request will not be answered. " ^ Json.to_pretty_string json) @@ -137,11 +137,11 @@ struct ;; let create - ?(on_request = on_request_fail) - ?(on_notification = on_notification_fail) - ~name - chan - state + ?(on_request = on_request_fail) + ?(on_notification = on_notification_fail) + ~name + chan + state = let pending = Id.Table.create 10 in { chan @@ -274,8 +274,8 @@ struct let* () = Fiber.fork_and_join_unit (fun () -> - let* () = loop () in - Fiber.Pool.stop later) + let* () = loop () in + Fiber.Pool.stop later) (fun () -> Fiber.Pool.run later) in close t) diff --git a/jsonrpc-fiber/src/jsonrpc_fiber.mli b/jsonrpc-fiber/src/jsonrpc_fiber.mli index 2c480148c..016b006cd 100644 --- a/jsonrpc-fiber/src/jsonrpc_fiber.mli +++ b/jsonrpc-fiber/src/jsonrpc_fiber.mli @@ -14,8 +14,8 @@ end (** Raised when the server is shutdown and a pending request will not complete. *) exception Stopped of Jsonrpc.Request.t -(** IO free implementation of the jsonrpc protocol. We stay completely agnostic - of transport by only dealing with abstract jsonrpc packets *) +(** IO free implementation of the jsonrpc protocol. We stay completely agnostic of + transport by only dealing with abstract jsonrpc packets *) module Make (Chan : sig type t diff --git a/jsonrpc-fiber/test/dune b/jsonrpc-fiber/test/dune index e360e22df..958adbe96 100644 --- a/jsonrpc-fiber/test/dune +++ b/jsonrpc-fiber/test/dune @@ -12,10 +12,10 @@ jsonrpc_fiber ;; This is because of the (implicit_transitive_deps false) ;; in dune-project - ppx_expect ppx_expect.config ppx_expect.config_types ppx_inline_test.config + ppx_expect.runtime_types stdune yojson) (preprocess diff --git a/jsonrpc-fiber/test/jsonrpc_fiber_tests.ml b/jsonrpc-fiber/test/jsonrpc_fiber_tests.ml index c4602a8ab..ad4202ad1 100644 --- a/jsonrpc-fiber/test/jsonrpc_fiber_tests.ml +++ b/jsonrpc-fiber/test/jsonrpc_fiber_tests.ml @@ -41,9 +41,7 @@ let%expect_test "start and stop server" = Fiber.fork_and_join_unit (fun () -> run) (fun () -> Jrpc.stop jrpc) in let () = Fiber_test.test Dyn.opaque run in - [%expect - {| - |}] + [%expect {| |}] ;; let%expect_test "server accepts notifications" = @@ -66,7 +64,8 @@ let%expect_test "server accepts notifications" = [%expect {| received notification - |}] + + |}] ;; let of_ref ref = @@ -104,7 +103,8 @@ let%expect_test "serving requests" = [%expect {| { "id": 1, "jsonrpc": "2.0", "result": "response" } - |}] + + |}] ;; (* The current client/server implement has no concurrent handling of requests. @@ -191,7 +191,8 @@ let%expect_test "concurrent requests" = { "id": "initial", "jsonrpc": "2.0", "result": null } waiter: received response: { "id": 100, "jsonrpc": "2.0", "result": 42 } - [FAIL] unexpected Never raised |}] + [FAIL] unexpected Never raised + |}] ;; let%expect_test "test from jsonrpc_test.ml" = @@ -260,7 +261,8 @@ let%expect_test "test from jsonrpc_test.ml" = [ { exn = "Failure(\"special failure\")"; backtrace = "" } ] { "id": 10, "jsonrpc": "2.0", "result": 1 } - { "id": "testing", "jsonrpc": "2.0", "result": 2 } |}] + { "id": "testing", "jsonrpc": "2.0", "result": 2 } + |}] ;; let%expect_test "cancellation" = @@ -338,5 +340,6 @@ let%expect_test "cancellation" = client: got server ack, cancelling request request has been cancelled server: got client ack, sending response - |}] + + |}] ;; diff --git a/jsonrpc.opam b/jsonrpc.opam index a0c16048f..c9ff4962a 100644 --- a/jsonrpc.opam +++ b/jsonrpc.opam @@ -1,5 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" +version: "1.19.0+ox" synopsis: "Jsonrpc protocol implemenation" description: "See https://www.jsonrpc.org/specification" maintainer: ["Rudi Grinberg "] @@ -22,6 +23,7 @@ depends: [ "dune" {>= "3.0"} "ocaml" {>= "4.08"} "odoc" {with-doc} + "yojson" {>= "2.0.0" & < "3.0.0"} ] dev-repo: "git+https://github.com/ocaml/ocaml-lsp.git" build: [ diff --git a/jsonrpc/src/dune b/jsonrpc/src/dune index 4d270c2dd..15f08b825 100644 --- a/jsonrpc/src/dune +++ b/jsonrpc/src/dune @@ -1,4 +1,5 @@ (library (public_name jsonrpc) + (libraries yojson) (instrumentation (backend bisect_ppx))) diff --git a/jsonrpc/src/import.ml b/jsonrpc/src/import.ml index 1f6bd09ee..caeb3e470 100644 --- a/jsonrpc/src/import.ml +++ b/jsonrpc/src/import.ml @@ -25,7 +25,7 @@ module Json = struct exception Of_json of (string * t) let () = - Printexc.register_printer (function + (Printexc.register_printer [@ocaml.alert "-unsafe_multidomain"]) (function | Of_json (msg, _) -> Some ("Jsonrpc: json conversion failed: " ^ msg) | _ -> None) ;; diff --git a/jsonrpc/src/jsonrpc.ml b/jsonrpc/src/jsonrpc.ml index 02be3a6bc..bc683fc2b 100644 --- a/jsonrpc/src/jsonrpc.ml +++ b/jsonrpc/src/jsonrpc.ml @@ -146,6 +146,23 @@ module Response = struct | Other code -> code ;; + let to_string = function + | ParseError -> "ParseError" + | InvalidRequest -> "InvalidRequest" + | MethodNotFound -> "MethodNotFound" + | InvalidParams -> "InvalidParams" + | InternalError -> "InternalError" + | ServerErrorStart -> "ServerErrorStart" + | ServerErrorEnd -> "ServerErrorEnd" + | ServerNotInitialized -> "ServerNotInitialized" + | UnknownErrorCode -> "UnknownErrorCode" + | RequestCancelled -> "RequestCancelled" + | ContentModified -> "ContentModified" + | ServerCancelled -> "ServerCancelled" + | RequestFailed -> "RequestFailed" + | Other _ -> "Other" + ;; + let t_of_yojson json = match json with | `Int i -> of_int i @@ -183,6 +200,24 @@ module Response = struct exception E of t + let () = + (Printexc.register_printer [@ocaml.alert "-unsafe_multidomain"]) (function + | E { code; message; data } -> + let data = + match data with + | None -> "" + | Some data -> "\n" ^ Yojson.Safe.pretty_to_string data + in + Some + (Printf.sprintf + "%s(%d): %s%s" + (Code.to_string code) + (Code.to_int code) + message + data) + | _ -> None) + ;; + let raise t = raise (E t) let make ?data ~code ~message () = { data; code; message } @@ -247,8 +282,8 @@ module Packet = struct | Batch_call r -> `List (List.map r ~f:(function - | `Request r -> Request.yojson_of_t r - | `Notification r -> Notification.yojson_of_t r)) + | `Request r -> Request.yojson_of_t r + | `Notification r -> Notification.yojson_of_t r)) ;; let t_of_fields (fields : (string * Json.t) list) = diff --git a/lev-fiber-async/.fe.sexp b/lev-fiber-async/.fe.sexp new file mode 100644 index 000000000..eaa579041 --- /dev/null +++ b/lev-fiber-async/.fe.sexp @@ -0,0 +1,5 @@ +(Scrutiny normal) +(Owner ddickstein) +(Reviewed_by (All_of (Users ddickstein troeder))) +(Apply_to All_files) +Used_in_subdirectory diff --git a/lev-fiber-async/src/dune b/lev-fiber-async/src/dune new file mode 100644 index 000000000..7f70918b3 --- /dev/null +++ b/lev-fiber-async/src/dune @@ -0,0 +1,18 @@ +(library + (name lev_fiber_async) + (libraries + async + async_kernel + async_unix + base + core + core_unix + core_unix.signal_unix + csexp + fiber + fiber_async + ppx_expect + stdune + unix) + (preprocess + (pps ppx_jane))) diff --git a/lev-fiber-async/src/lev_fiber_async.ml b/lev-fiber-async/src/lev_fiber_async.ml new file mode 100644 index 000000000..48dfb69fa --- /dev/null +++ b/lev-fiber-async/src/lev_fiber_async.ml @@ -0,0 +1,487 @@ +open Core +open Async +open Fiber_async +open Lev_fiber_async_intf + +let default_backtrace = + (* If you get a backtrace to this point, interpret it as a missing backtrace. Base's + exception-handling logic deliberately models backtraces as optional because + [Printexc.get_raw_backtrace] may return a backtrace for a different exn, so there's a + [phys_equal] test to guard returning the backtrace for the wrong exception. However, + to conform to the [Thread] API, we always need to return a backtrace with an + exception so we return this default one in the would-be [None] case. *) + Backtrace.get ~at_most_num_frames:2 () +;; + +module Types = struct + module Fd = struct + type t = Fd.t Deferred.t + end + + module Io = struct + type input = Input + type output = Output + + type 'a mode = + | Input : input mode + | Output : output mode + + type 'a t = + | Reader : Reader.t -> input t + | Writer : Writer.t -> output t + end +end + +module Lev_fiber = struct + module type S = + Lev_fiber.S + with type Fd.t = Types.Fd.t + and type Io.input = Types.Io.input + and type Io.output = Types.Io.output + and type 'a Io.t = 'a Types.Io.t + + let make ~time_source = + (module struct + module Timer = struct + let sleepf span = + Fiber.of_thunk (fun () -> + Time_source.after time_source (Time_ns.Span.of_sec span) |> fiber_of_deferred) + ;; + + module Wheel = struct + type t = + { mutable timeout : Time_ns.Span.t + ; tasks : (unit, unit) Time_source.Event.t Bag.t + } + + let create ~delay = + Fiber.of_thunk (fun () -> + Fiber.return { timeout = Time_ns.Span.of_sec delay; tasks = Bag.create () }) + ;; + + let delay t = Time_ns.Span.to_sec t.timeout + + let set_delay t ~delay = + Fiber.of_thunk (fun () -> + Fiber.return (t.timeout <- Time_ns.Span.of_sec delay)) + ;; + + type task = + { wheel : t + ; mutable event : (unit, unit) Time_source.Event.t + } + + let new_event t = + Fiber.of_thunk (fun () -> + let event = Time_source.Event.run_after time_source t.timeout Fn.id () in + let key = Bag.add t.tasks event in + upon (Time_source.Event.fired event) (fun _ -> Bag.remove t.tasks key); + Fiber.return event) + ;; + + let task t = + let%map.Fiber event = new_event t in + { wheel = t; event } + ;; + + let await task = + Fiber.of_thunk (fun () -> + match%map.Fiber Time_source.Event.fired task.event |> fiber_of_deferred with + | Happened () -> `Ok + | Aborted () -> `Cancelled) + ;; + + let reset task = + Fiber.of_thunk (fun () -> + let timeout = task.wheel.timeout in + match Time_source.Event.reschedule_after task.event timeout with + | Ok -> Fiber.return () + | Previously_aborted _ | Previously_happened _ -> + let%map.Fiber event = new_event task.wheel in + task.event <- event) + ;; + + let cancel task = + Fiber.of_thunk (fun () -> + Time_source.Event.abort_if_possible task.event (); + Fiber.return ()) + ;; + + let run (_ : t) = Fiber.return () + + let stop t = + Fiber.of_thunk (fun () -> + Bag.iter_elt t.tasks ~f:(fun elt -> + let event = Bag.Elt.value elt in + Time_source.Event.abort_if_possible event ()); + Fiber.return ()) + ;; + end + end + + let waitpid ~pid = + Fiber.of_thunk (fun () -> + match%map.Fiber Unix.waitpid (Pid.of_int pid) |> fiber_of_deferred with + | Ok () -> UnixLabels.WEXITED 0 + | Error (`Exit_non_zero i) -> WEXITED i + | Error (`Signal signal) -> WSIGNALED (Signal.to_caml_int signal)) + ;; + + let signal ~signal = + Fiber.of_thunk (fun () -> + let received = Ivar.create () in + Signal.handle + ~stop:(Ivar.read received) + [ Signal.of_caml_int signal ] + ~f:(fun (_ : Signal.t) -> + (* ddickstein: The implementation of [Signal.handle] doesn't convince me + that this can't be called again after [stop] is filled before the [upon] + callback removes the registered handler, so I'm using + [Ivar.fill_if_empty] to be safe. *) + Ivar.fill_if_empty received ()); + Ivar.read received |> fiber_of_deferred) + ;; + + module Thread = struct + module Exn_with_backtrace = Stdune.Exn_with_backtrace + + type 'a task = + { f : unit -> 'a + ; ivar : ('a, [ `Exn of Exn_with_backtrace.t | `Cancelled ]) Result.t Ivar.t + } + + type packed_task = Task : 'a task -> packed_task + + type t = + { writer : packed_task Pipe.Writer.t + ; stop : unit -> unit + } + + let create () = + Fiber.of_thunk (fun () -> + let reader, writer = Pipe.create () in + let stopped = Ivar.create () in + don't_wait_for + (let%bind thread = In_thread.Helper_thread.create () in + let%bind () = + Deferred.repeat_until_finished () (fun () -> + match%bind + choose + [ choice (Ivar.read stopped) (fun () -> `Stopped) + ; choice (Pipe.values_available reader) (function + | `Eof -> `Eof + | `Ok -> `Ok) + ] + with + | `Stopped | `Eof -> return (`Finished ()) + | `Ok -> + (match Ivar.is_full stopped with + | true -> return (`Finished ()) + | false -> + let (Task { f; ivar }) = Pipe.read_now_exn reader in + (match Ivar.is_full ivar with + | true -> return (`Repeat ()) + | false -> + let%map result = + Monitor.try_with (fun () -> In_thread.run ~thread f) + >>| function + | Ok _ as ok -> ok + | Error (Monitor.Monitor_exn exn) -> + let backtrace = + Monitor.Monitor_exn.backtrace exn + |> Option.value ~default:default_backtrace + in + let exn = Monitor.Monitor_exn.extract_exn exn in + Error (`Exn { Exn_with_backtrace.exn; backtrace }) + | Error exn -> + (* ddickstein: I don't think we will hit this case, but + I've implemented it in case we do. *) + let backtrace = + Backtrace.Exn.most_recent_for_exn exn + |> Option.value ~default:default_backtrace + in + Error (`Exn { exn; backtrace }) + in + Ivar.fill_if_empty ivar result; + `Repeat ()))) + in + Pipe.iter_without_pushback reader ~f:(fun (Task { f = _; ivar }) -> + Ivar.fill_if_empty ivar (Error `Cancelled))); + Fiber.return { writer; stop = Ivar.fill_if_empty stopped }) + ;; + + let task t ~f = + match Pipe.is_closed t.writer with + | true -> Error `Stopped + | false -> + let task = { f; ivar = Ivar.create () } in + Pipe.write_without_pushback t.writer (Task task); + Ok task + ;; + + let cancel task = + Fiber.of_thunk (fun () -> + let { f = _; ivar } = task in + Ivar.fill_if_empty ivar (Error `Cancelled); + Fiber.return ()) + ;; + + let await task = + Fiber.of_thunk (fun () -> + let { f = _; ivar } = task in + Ivar.read ivar |> fiber_of_deferred) + ;; + + let close t = + t.stop (); + Pipe.close t.writer + ;; + end + + module Fd = struct + include Types.Fd + + let create file_descr blocking = + let () = + match blocking with + | `Blocking -> () + | `Non_blocking already_set -> + (match already_set with + | true -> () + | false -> Core_unix.set_nonblock file_descr) + in + let%map kind = Fd.Kind.infer_using_stat file_descr in + Fd.create + ~avoid_setting_nonblock:true + kind + file_descr + (Info.of_string "Lev_fiber_async.Fd.t") + ;; + + let close t = don't_wait_for (t >>= Fd.close) + end + + module Io = struct + include Types.Io + + let fd (type a) : a t -> Fd.t = function + | Reader reader -> return (Reader.fd reader) + | Writer writer -> return (Writer.fd writer) + ;; + + let create (type a) fd mode = + let%map.Fiber fd = fiber_of_deferred fd in + match (mode : a mode) with + | Input -> (Reader (Reader.create fd) : a t) + | Output -> (Writer (Writer.create fd) : a t) + ;; + + let create_rw fd = + let%map.Fiber input = create fd Input + and output = create fd Output in + input, output + ;; + + let with_read (Reader reader) ~f = Fiber.of_thunk (fun () -> f reader) + let with_write (Writer writer) ~f = Fiber.of_thunk (fun () -> f writer) + + let close (type a) : a t -> unit = function + | Reader reader -> don't_wait_for (Reader.close reader) + | Writer writer -> don't_wait_for (Writer.close writer) + ;; + + let pipe ?(cloexec = true) () = + Fiber.of_thunk (fun () -> + let%map.Fiber `Reader reader_fd, `Writer writer_fd = + Unix.pipe (Info.of_string "Lev_fiber_async.Io.pipe") |> fiber_of_deferred + in + let () = + match cloexec with + | true -> () + | false -> + Unix.clear_close_on_exec reader_fd; + Unix.clear_close_on_exec writer_fd + in + Reader (Reader.create reader_fd), Writer (Writer.create writer_fd)) + ;; + + let stdin = + Fiber.of_thunk (fun () -> + let reader = force Reader.stdin in + Fiber.return (Reader reader)) + ;; + + let stdout = + Fiber.of_thunk (fun () -> + let writer = force Writer.stdout in + Fiber.return (Writer writer)) + ;; + + let stderr = + Fiber.of_thunk (fun () -> + let writer = force Writer.stderr in + Fiber.return (Writer writer)) + ;; + + module Reader = struct + type t = Reader.t + + let byte = Bytes.create 1 + + let read_char_exn t = + match Reader.read_available t byte with + | 0 -> raise_s [%message "read_char_exn: Nothing available on the reader."] + | 1 -> Bytes.unsafe_get byte 0 + | n -> raise_s [%message "BUG: Read impossible number of bytes" (n : int)] + ;; + + let read_line t = + Fiber.of_thunk (fun () -> + match Reader.is_closed t with + | true -> Fiber.return (Error (`Partial_eof "")) + | false -> + let strip_trailing_carriage_return line = + let length = String.length line in + match length >= 1 && Char.equal line.[length - 1] '\r' with + | true -> String.sub line ~pos:0 ~len:(length - 1) + | false -> line + in + (* [Reader.read_line] collapses the [`Ok] and [`Eof_without_delim] cases, + so it doesn't provide enough information to satisfy the interface. *) + (match%map.Fiber + Reader.read_until t (`Char '\n') ~keep_delim:false |> fiber_of_deferred + with + | `Ok line -> Ok (strip_trailing_carriage_return line) + | `Eof -> Error (`Partial_eof "") + | `Eof_without_delim line -> + Error (`Partial_eof (strip_trailing_carriage_return line)))) + ;; + + let read_exactly t n = + Fiber.of_thunk (fun () -> + match Reader.is_closed t with + | true -> Fiber.return (Error (`Partial_eof "")) + | false -> + let bytes = Bytes.create n in + (match%map.Fiber Reader.really_read t bytes |> fiber_of_deferred with + | `Ok -> Ok (Bytes.to_string bytes) + | `Eof n_read -> + Error (`Partial_eof (Bytes.To_string.sub bytes ~pos:0 ~len:n_read)))) + ;; + + let to_string t = + Fiber.of_thunk (fun () -> + (* Copy of [Reader.contents] without closing the reader at the end. *) + let buf = Buffer.create 1024 in + let sbuf = Bytes.create 1024 in + Deferred.repeat_until_finished () (fun () -> + match Reader.is_closed t with + | true -> return (`Finished (Buffer.contents buf)) + | false -> + (match%map Reader.read t sbuf with + | `Eof -> `Finished (Buffer.contents buf) + | `Ok l -> + Buffer.add_subbytes buf sbuf ~pos:0 ~len:l; + `Repeat ())) + |> fiber_of_deferred) + ;; + end + + module Writer = struct + type t = Writer.t + + let flush t = + Fiber.of_thunk (fun () -> + Writer.flushed_or_failed_unit t |> fiber_of_deferred) + ;; + + let add_string t s = Writer.write t s + let add_substring t s ~pos ~len = Writer.write ~pos ~len t s + end + end + + module Socket = struct + let connect fd sockaddr = + let%bind.Fiber fd = fiber_of_deferred fd in + let connect socket_type where_to_connect = + let socket = Socket.of_fd fd socket_type in + where_to_connect + |> Tcp.connect_sock ~socket + |> Deferred.ignore_m + |> fiber_of_deferred + in + match (sockaddr : Unix.sockaddr) with + | ADDR_UNIX unix -> connect Socket.Type.unix (Tcp.Where_to_connect.of_file unix) + | ADDR_INET (addr, port) -> + connect + Socket.Type.tcp + (Tcp.Where_to_connect.of_inet_address (`Inet (addr, port))) + ;; + end + + let yield () = Fiber.of_thunk (fun () -> Scheduler.yield () |> fiber_of_deferred) + end : S) + ;; + + include (val make ~time_source:(Time_source.wall_clock ())) +end + +module Lev_fiber_csexp = struct + (* CR-someday ddickstein: Once https://github.com/ocaml-dune/csexp/issues/19 is + resolved, remove this module. *) + module Conv = struct + (* We use a copy of [Csexp.Sexp] here to avoid relying on it - it's worth taking extra + precautions around [Obj.magic]. *) + module type Sexp = sig + type t = + | Atom of string + | List of t list + end + + module Make (M : Sexp) = struct + let to_csexp (sexp : M.t) : Csexp.t = Obj.magic sexp + let of_csexp (csexp : Csexp.t) : M.t = Obj.magic csexp + end + + (* Prove that [Csexp] itself satisfies [Sexp]. *) + module _ = Make (Csexp) + include Make (Sexp) + end + + module Session = struct + type t = + { reader : Reader.t + ; writer : Writer.t + } + + let create ~socket:_ (Types.Io.Reader reader) (Types.Io.Writer writer) = + { reader; writer } + ;; + + let close { reader; writer } = + don't_wait_for (Writer.close writer); + don't_wait_for (Reader.close reader) + ;; + + let write t csexps = + Fiber.of_thunk (fun () -> + List.iter csexps ~f:(fun csexp -> + let sexp = Conv.of_csexp csexp in + Writer.write_sexp ~hum:false ~terminate_with:Space_if_needed t.writer sexp); + Fiber.return ()) + ;; + + let read t = + Fiber.of_thunk (fun () -> + match%map.Fiber Reader.read_sexp t.reader |> fiber_of_deferred with + | `Eof -> None + | `Ok sexp -> Some (Conv.to_csexp sexp)) + ;; + end + + let connect fd sockaddr = + let%bind.Fiber () = Lev_fiber.Socket.connect fd sockaddr in + let%map.Fiber input, output = Lev_fiber.Io.create_rw fd in + Session.create ~socket:true input output + ;; +end diff --git a/lev-fiber-async/src/lev_fiber_async.mli b/lev-fiber-async/src/lev_fiber_async.mli new file mode 100644 index 000000000..e1b5e2ad7 --- /dev/null +++ b/lev-fiber-async/src/lev_fiber_async.mli @@ -0,0 +1 @@ +include Lev_fiber_async_intf.Lev_fiber_async diff --git a/lev-fiber-async/src/lev_fiber_async_intf.ml b/lev-fiber-async/src/lev_fiber_async_intf.ml new file mode 100644 index 000000000..db1ff8481 --- /dev/null +++ b/lev-fiber-async/src/lev_fiber_async_intf.ml @@ -0,0 +1,236 @@ +(** This library provides drop-in Async replacement for [Lev_fiber] and [Lev_fiber_csexp] + from ocaml-lsp. We build ocaml-lsp with [-open Lev_fiber_async] to make it magically + use Async as its scheduler instead of Lev. *) + +(* Do not open anything here, as it can change the meaning of the signatures. *) + +module Lev_fiber = struct + module type S = sig + module Timer : sig + (** Return after [sec] seconds. *) + val sleepf : float -> unit Fiber.t + + module Wheel : sig + (** An interface for scheduling, rescheduling, and cancelling events. *) + type t + + (** Create a [t] that can be used to schedule cancellable / reschedulable events + that will happen after [delay] seconds. *) + val create : delay:float -> t Fiber.t + + (** Change the [delay] value used for scheduling events. *) + val set_delay : t -> delay:float -> unit Fiber.t + + (** Get the [delay] value. *) + val delay : t -> float + + (* Event is a better name, but we keep [task] because it's what Lev uses. *) + type task + type event := task + + (** Create a new event that will happen in [delay] seconds. Better names for this + function would be [schedule] or [create_event]. *) + val task : t -> event Fiber.t + + (** Wait for event to happen or be cancelled. *) + val await : event -> [ `Ok | `Cancelled ] Fiber.t + + (** Reschedule [event]. If it already happened, schedule a new one. *) + val reset : event -> unit Fiber.t + + (** Cancel the event. *) + val cancel : event -> unit Fiber.t + + (** In the Async implementation this is a no-op since [t] is implemented with a + time source that is always available. *) + val run : t -> unit Fiber.t + + (** Cancel all events. In the Lev implementation, this also stops running the + wheel and makes scheduling new events with [task t] an error. In the Async + implementation, scheduling more events is fine since the wheel is a + [Time_source.t]. *) + val stop : t -> unit Fiber.t + end + end + + val waitpid : pid:int -> Unix.process_status Fiber.t + + (** Register a signal handler for [signal]. When [signal] is received, unregister the + handler and return. *) + val signal : signal:int -> unit Fiber.t + + module Thread : sig + type t + + (** Create a new system thread and a queue of jobs it will run. *) + val create : unit -> t Fiber.t + + type 'a task + + (** Enqueue a job to the thread. *) + val task : t -> f:(unit -> 'a) -> ('a task, [ `Stopped ]) result + + (** Cancel a job if it has not run yet. *) + val cancel : 'a task -> unit Fiber.t + + (** Wait for a job to finish. *) + val await + : 'a task + -> ('a, [ `Exn of Stdune.Exn_with_backtrace.t | `Cancelled ]) result Fiber.t + + (** Close the queue for the thread and return the thread to Async's thread pool. + After [close] is called, calls to [task] will return [Error `Stopped]. *) + val close : t -> unit + end + + module Fd : sig + type t + + val close : t -> unit + + (** Create a new [Fd.t]. The boolean argument of [`Non_blocking] indicates whether + [Unix.set_nonblock] has already been invoked on this file descriptor - if it + hasn't, it will be set during [create]. *) + val create : Unix.file_descr -> [ `Blocking | `Non_blocking of bool ] -> t + end + + module Io : sig + type input = Input + type output = Output + + type 'a mode = + | Input : input mode + | Output : output mode + + type 'a t + + val fd : _ t -> Fd.t + + (** Create a reader or writer for reading from / writing to [Fd.t] *) + val create : Fd.t -> 'a mode -> 'a t Fiber.t + + (** Create a reader to read from [fd] and writer to write to [fd]. *) + val create_rw : Fd.t -> (input t * output t) Fiber.t + + module Reader : sig + type t + + val read_char_exn : t -> char + val read_line : t -> (string, [ `Partial_eof of string ]) result Fiber.t + val read_exactly : t -> int -> (string, [ `Partial_eof of string ]) result Fiber.t + + (** Read until EOF. *) + val to_string : t -> string Fiber.t + end + + module Writer : sig + type t + + val flush : t -> unit Fiber.t + val add_substring : t -> string -> pos:int -> len:int -> unit + val add_string : t -> string -> unit + end + + val with_read : input t -> f:(Reader.t -> 'a Fiber.t) -> 'a Fiber.t + val with_write : output t -> f:(Writer.t -> 'a Fiber.t) -> 'a Fiber.t + + (* CR-someday ddickstein: When https://github.com/ocaml/ocaml-lsp/issues/1158 is + resolved, update the comment below and update the logic in the read functions for + handling closed readers. *) + + (** Close the reader / writer. Reading from a closed reader will result in EOF. *) + val close : 'a t -> unit + + (** Create a unix pipe. Only pass [cloexec = false] if you are creating this pipe + for the purpose of passing file descriptors to a child process. If this is not + your intention, you risk leaking file descriptors, which is a security risk. *) + val pipe : ?cloexec:bool -> unit -> (input t * output t) Fiber.t + + (** [Unix.stdin] wrapped with [Io.t] *) + val stdin : input t Fiber.t + + (** [Unix.stderr] wrapped with [Io.t] *) + val stderr : output t Fiber.t + + (** [Unix.stdout] wrapped with [Io.t] *) + val stdout : output t Fiber.t + end + + module Socket : sig + (** Create a socket from [fd] and connect it to the given address. *) + val connect : Fd.t -> Unix.sockaddr -> unit Fiber.t + end + + (** Yield to the event loop. In the Lev implementation, this just yields once to the + event loop (equivalent of binding on [return]). In the Async implementation, we + use [Scheduler.yield ()], which waits until the next cycle, improving fairness. *) + val yield : unit -> unit Fiber.t + end +end + +module Lev_fiber_csexp = struct + module type Lev_fiber_types = sig + module Io : sig + type 'a t + type input + type output + end + + module Fd : sig + type t + end + end + + module Make (Lev_fiber : Lev_fiber_types) = struct + module type S = sig + (** Canonical S-expression RPC. + + This module implements a RPC mechanism for exchanging canonical S-expressions + over unix or internet sockets. It allows a server to accept connections and a + client to connect to a server. + + However, it doesn't explain how to encode queries, responses or generally any + kind of messages as Canonical S-expressions. That part should be built on top of + this module. *) + + module Session : sig + (** Rpc session backed by an input & output stream. *) + type t + + val create + : socket:bool + -> Lev_fiber.Io.input Lev_fiber.Io.t + -> Lev_fiber.Io.output Lev_fiber.Io.t + -> t + + val close : t -> unit + + (* [write t sexps] writes the S-expressions [sexps]. *) + val write : t -> Csexp.t list -> unit Fiber.t + + (** If [read] returns [None], the session is closed and all subsequent reads will + return [None]. *) + val read : t -> Csexp.t option Fiber.t + end + + val connect : Lev_fiber.Fd.t -> Unix.sockaddr -> Session.t Fiber.t + end + end +end + +module type Lev_fiber_async = sig + module Lev_fiber : sig + include Lev_fiber.S + + module type S = + Lev_fiber.S + with type Fd.t = Fd.t + and type Io.input = Io.input + and type Io.output = Io.output + and type 'a Io.t = 'a Io.t + + val make : time_source:Async.Time_source.t -> (module S) + end + + module Lev_fiber_csexp : Lev_fiber_csexp.Make(Lev_fiber).S +end diff --git a/lsp-fiber/src/dune b/lsp-fiber/src/dune index c5ce6a141..3f9a272e8 100644 --- a/lsp-fiber/src/dune +++ b/lsp-fiber/src/dune @@ -3,7 +3,7 @@ (libraries dyn fiber - lev_fiber + lev_fiber_async jsonrpc jsonrpc_fiber lsp @@ -11,4 +11,8 @@ stdune yojson) (instrumentation - (backend bisect_ppx))) + (backend bisect_ppx)) + (flags ( + :standard + -open + Lev_fiber_async))) diff --git a/lsp-fiber/src/import.ml b/lsp-fiber/src/import.ml index da49c436b..d2c5d4b04 100644 --- a/lsp-fiber/src/import.ml +++ b/lsp-fiber/src/import.ml @@ -1,32 +1,9 @@ module List = Stdlib.ListLabels module Code_error = Stdune.Code_error +module Fdecl = Stdune.Fdecl module Header = Lsp.Header module Io = Lsp.Io -module Fdecl : sig - type 'a t - - val get : 'a t -> 'a - val set : 'a t -> 'a -> unit - val create : unit -> 'a t -end = struct - type 'a t = 'a option ref - - let create () = ref None - - let set t x = - match !t with - | Some _ -> invalid_arg "Fdecl.create: already set" - | None -> t := Some x - ;; - - let get t = - match !t with - | None -> invalid_arg "Fdecl.get: not set" - | Some t -> t - ;; -end - module Json = struct include Lsp.Import.Json @@ -97,7 +74,7 @@ module Log = struct ;; end -let sprintf = Printf.sprintf +let sprintf = Stdune.sprintf module Types = Lsp.Types module Client_request = Lsp.Client_request diff --git a/lsp-fiber/src/lsp_fiber.ml b/lsp-fiber/src/lsp_fiber.ml index b5830ed8f..1c69bd587 100644 --- a/lsp-fiber/src/lsp_fiber.ml +++ b/lsp-fiber/src/lsp_fiber.ml @@ -7,5 +7,4 @@ module Json = Import.Json module Private = struct module Log = Import.Log - module Fdecl = Import.Fdecl end diff --git a/lsp-fiber/src/rpc.ml b/lsp-fiber/src/rpc.ml index 740d6a46b..34c2004e9 100644 --- a/lsp-fiber/src/rpc.ml +++ b/lsp-fiber/src/rpc.ml @@ -147,9 +147,9 @@ struct ;; let make - ?(on_request = on_request_default) - ?(on_notification = on_notification_default) - () + ?(on_request = on_request_default) + ?(on_notification = on_notification_default) + () = { h_on_request = on_request; h_on_notification = on_notification } ;; @@ -176,9 +176,9 @@ struct Lazy.force remove; exn)) (fun () -> - Fiber.Var.set cancel_token cancel (fun () -> - Table.replace t.pending req.id cancel; - h_on_request.on_request t r)) + Fiber.Var.set cancel_token cancel (fun () -> + Table.replace t.pending req.id cancel; + h_on_request.on_request t r)) in let to_response x = Jsonrpc.Response.ok req.id (In_request.yojson_of_result r x) @@ -192,8 +192,8 @@ struct let f send = Fiber.finalize (fun () -> - Fiber.Var.set cancel_token cancel (fun () -> - k (fun r -> send (to_response r)))) + Fiber.Var.set cancel_token cancel (fun () -> + k (fun r -> send (to_response r)))) ~finally:(fun () -> Lazy.force remove; Fiber.return ()) @@ -219,7 +219,7 @@ struct let t = { io ; state = Waiting_for_init - ; session = Fdecl.create () + ; session = Fdecl.create Dyn.opaque ; initialized = Fiber.Ivar.create () ; req_id = 1 ; pending = Table.create 32 @@ -265,12 +265,12 @@ struct cancel ~on_cancel:(fun () -> on_cancel jsonrpc_req.id) (fun () -> - let+ resp = Session.request (Fdecl.get t.session) jsonrpc_req in - match resp.result with - | Error { code = RequestCancelled; _ } -> `Cancelled - | Ok _ when Fiber.Cancel.fired cancel -> `Cancelled - | Ok s -> `Ok (Out_request.response_of_json req s) - | Error e -> raise (Jsonrpc.Response.Error.E e)) + let+ resp = Session.request (Fdecl.get t.session) jsonrpc_req in + match resp.result with + | Error { code = RequestCancelled; _ } -> `Cancelled + | Ok _ when Fiber.Cancel.fired cancel -> `Cancelled + | Ok s -> `Ok (Out_request.response_of_json req s) + | Error e -> raise (Jsonrpc.Response.Error.E e)) in match cancel_status with | Cancelled () -> `Cancelled @@ -331,8 +331,8 @@ struct let start_loop t = Fiber.fork_and_join_unit (fun () -> - let* () = Session.run (Fdecl.get t.session) in - Fiber.Pool.stop t.detached) + let* () = Session.run (Fdecl.get t.session) in + Fiber.Pool.stop t.detached) (fun () -> Fiber.Pool.run t.detached) ;; diff --git a/lsp-fiber/test/dune b/lsp-fiber/test/dune index 150c99bb4..192923c11 100644 --- a/lsp-fiber/test/dune +++ b/lsp-fiber/test/dune @@ -4,26 +4,32 @@ (name lsp_fiber_tests) (inline_tests) (preprocess - (pps ppx_expect)) + (pps ppx_let ppx_expect)) (enabled_if (>= %{ocaml_version} 4.08)) (libraries + async + async_kernel base fiber + fiber_async fiber_test - lev - lev_fiber + lev_fiber_async jsonrpc jsonrpc_fiber lsp lsp_fiber ;; This is because of the (implicit_transitive_deps false) ;; in dune-project - ppx_expect ppx_expect.config ppx_expect.config_types + ppx_expect.runtime_types ppx_inline_test.config ppx_yojson_conv_lib stdune threads.posix - yojson)) + yojson) + (flags ( + :standard + -open + Lev_fiber_async))) diff --git a/lsp-fiber/test/lsp_fiber_test.ml b/lsp-fiber/test/lsp_fiber_test.ml index a775968c8..d16a1eca9 100644 --- a/lsp-fiber/test/lsp_fiber_test.ml +++ b/lsp-fiber/test/lsp_fiber_test.ml @@ -1,3 +1,4 @@ +open Async open Fiber.O open Lsp open Lsp.Types @@ -6,11 +7,11 @@ open Lsp_fiber module Test = struct module Client = struct let run - ?(capabilities = ClientCapabilities.create ()) - ?on_request - ?on_notification - state - (in_, out) + ?(capabilities = ClientCapabilities.create ()) + ?on_request + ?on_notification + state + (in_, out) = let initialize = InitializeParams.create ~capabilities () in let client = @@ -38,7 +39,7 @@ let pipe () = Lev_fiber.Io.pipe ~cloexec:true () let test make_client make_server = Printexc.record_backtrace false; - let run () = + let fiber = let* client_in, server_out = pipe () in let* server_in, client_out = pipe () in let server () = make_server (server_in, server_out) in @@ -46,7 +47,7 @@ let test make_client make_server = let+ () = Fiber.fork_and_join_unit server client in print_endline "Successful termination of test" in - Lev_fiber.run run |> Lev_fiber.Error.ok_exn; + let%map () = Fiber_async.deferred_of_fiber fiber () in print_endline "[TEST] finished" ;; @@ -193,7 +194,7 @@ module End_to_end_server = struct end let%expect_test "end to end run of lsp tests" = - test End_to_end_client.run End_to_end_server.run; + let%map.Deferred () = test End_to_end_client.run End_to_end_server.run in [%expect {| client: waiting for initialization @@ -219,5 +220,6 @@ let%expect_test "end to end run of lsp tests" = "successful execution" client: sending request to shutdown Successful termination of test - [TEST] finished |}] + [TEST] finished + |}] ;; diff --git a/lsp.opam b/lsp.opam index 2ae4b8101..7ece8be9f 100644 --- a/lsp.opam +++ b/lsp.opam @@ -1,5 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" +version: "1.19.0+ox" synopsis: "LSP protocol implementation in OCaml" description: """ @@ -32,7 +33,7 @@ depends: [ "uutf" {>= "1.0.2"} "odoc" {with-doc} "ocaml" {>= "4.14"} - "ppx_yojson_conv" {with-dev-setup} + "ppx_yojson_conv" ] dev-repo: "git+https://github.com/ocaml/ocaml-lsp.git" build: [ diff --git a/lsp/bin/cinaps.ml b/lsp/bin/cinaps.ml deleted file mode 100644 index c07c121b5..000000000 --- a/lsp/bin/cinaps.ml +++ /dev/null @@ -1,178 +0,0 @@ -open Import - -let preprocess_metamodel = - object (self) - inherit Metamodel.map as super - - method! or_ path (types : Metamodel.type_ list) = - match - List.filter_map types ~f:(function - | Literal (Record []) -> None - | _ as t -> Some (self#type_ path t)) - with - | [] -> assert false - | [ t ] -> t - | [ Metamodel.Literal (Record f1); Literal (Record f2) ] as ts -> - (match path with - | Top (Alias s) when s.name = "TextDocumentContentChangeEvent" -> - let t = - let union_fields l1 l2 ~f = - let of_map = - String.Map.of_list_map_exn ~f:(fun (x : Metamodel.property) -> x.name, x) - in - String.Map.merge (of_map l1) (of_map l2) ~f |> String.Map.values - in - union_fields f1 f2 ~f:(fun k t1 t2 -> - if k = "text" - then t1 - else if k = "range" - then ( - match t1, t2 with - | None, Some s | Some s, None -> - assert (not s.optional); - Some { s with optional = true } - | None, None | Some _, Some _ -> assert false) - else ( - match t1, t2 with - | None, None -> assert false - | Some s, None | None, Some s -> Some s - | Some _, Some _ -> assert false)) - in - self#type_ path (Metamodel.Literal (Record t)) - | _ -> super#or_ path ts) - | ts -> super#or_ path ts - - method! property path (p : Metamodel.property) = - let update_type type_ = - let type_ = self#type_ path type_ in - super#property path { p with type_ } - in - let open Metamodel.Path in - match path with - | Top (Structure s) - when p.name = "trace" - && (s.name = "_InitializeParams" || s.name = "InitializeParams") -> - update_type (Reference "TraceValues") - | Top (Structure s) when p.name = "location" && s.name = "WorkspaceSymbol" -> - (match p.type_ with - | Or [ type_; _ ] -> update_type type_ - | _ -> assert false) - | _ -> super#property path p - - method! enumeration m = - match m.name = "TraceValues" with - | false -> super#enumeration m - | true -> - super#enumeration - (let values = - let compact : Metamodel.enumerationEntry = - { name = "Compact" - ; value = `String "compact" - ; doc = { since = None; documentation = None } - } - in - compact :: m.values - in - { m with values }) - end -;; - -let expand_superclasses db (m : Metamodel.t) = - let structures = - let uniquify_fields fields = - List.fold_left fields ~init:String.Map.empty ~f:(fun acc (f : Metamodel.property) -> - String.Map.set acc f.name f) - |> String.Map.values - in - let rec fields_of_type (t : Metamodel.type_) = - match t with - | Reference s -> - (match Metamodel.Entity.DB.find db s with - | Structure s -> fields_of_structure s - | Enumeration _ -> assert false - | Alias a -> fields_of_type a.type_) - | _ -> assert false - and fields_of_structure (s : Metamodel.structure) = - let fields = List.map (s.extends @ s.mixins) ~f:fields_of_type @ [ s.properties ] in - List.concat fields - in - List.map m.structures ~f:(fun s -> - let properties = fields_of_structure s |> uniquify_fields in - { s with properties }) - in - { m with structures } -;; - -let ocaml = - lazy - (Metamodel_lsp.t () - |> preprocess_metamodel#t - |> (fun metamodel -> - let db = Metamodel.Entity.DB.create metamodel in - expand_superclasses db metamodel) - |> Typescript.of_metamodel - |> Ocaml.of_typescript) -;; - -module Output = struct - open Ocaml - - type t = - { mutable modules : Module.t list - ; kind : Ml.Kind.t - ; out : out_channel - } - - let create modules kind out_channel = { modules; out = out_channel; kind } - - let module_name (t : t) (m : Module.t) = - match t.kind with - | Intf -> (m.intf.name :> string) - | Impl -> (m.impl.name :> string) - ;; - - let _skip (t : t) name = - match t.modules with - | [] -> failwith "non left to skip" - | m :: modules -> - let name' = module_name t m in - assert (String.equal name name'); - t.modules <- modules - ;; - - let pp_file pp ch = - let fmt = Format.formatter_of_out_channel ch in - Pp.to_fmt fmt pp; - Format.pp_print_flush fmt () - ;; - - let write t cmd = - let to_write, modules = - match cmd with - | `Finish -> t.modules, [] - | `Until m -> - let rec loop xs acc = - match xs with - | [] -> List.rev acc, [] - | x :: xs -> - if module_name t x = m then List.rev acc, x :: xs else loop xs (x :: acc) - in - loop t.modules [] - in - t.modules <- modules; - List.iter to_write ~f:(fun m -> - let pp = Module.pp m in - let pp = Ml.Kind.Map.get pp t.kind in - pp_file pp t.out) - ;; -end - -let print_ml () = - let output = Output.create (Lazy.force ocaml) Ml.Kind.Impl stdout in - Output.write output `Finish -;; - -let print_mli () = - let output = Output.create (Lazy.force ocaml) Ml.Kind.Intf stdout in - Output.write output `Finish -;; diff --git a/lsp/bin/cinaps.mli b/lsp/bin/cinaps.mli deleted file mode 100644 index 6d5c4bc36..000000000 --- a/lsp/bin/cinaps.mli +++ /dev/null @@ -1,2 +0,0 @@ -val print_ml : unit -> unit -val print_mli : unit -> unit diff --git a/lsp/bin/dune b/lsp/bin/dune deleted file mode 100644 index 6c2b237e6..000000000 --- a/lsp/bin/dune +++ /dev/null @@ -1,16 +0,0 @@ -(include_subdirs unqualified) - -(test - (name test_metamodel) - (modules test_metamodel) - (libraries stdune yojson lsp_gen) - (deps metamodel/metaModel.json) - (action - (run ./test_metamodel.exe %{deps}))) - -(library - (name lsp_gen) - (instrumentation - (backend bisect_ppx)) - (modules :standard \ test_metamodel) - (libraries stdune dyn pp yojson)) diff --git a/lsp/bin/import.ml b/lsp/bin/import.ml deleted file mode 100644 index c1b414f8f..000000000 --- a/lsp/bin/import.ml +++ /dev/null @@ -1,13 +0,0 @@ -include struct - open Stdune - module List = List - module Id = Id - module String = String - module Code_error = Code_error - module Comparable = Comparable - module Top_closure = Top_closure - module Poly = Poly - module Option = Option - - let sprintf = sprintf -end diff --git a/lsp/bin/lsp_gen.ml b/lsp/bin/lsp_gen.ml deleted file mode 100644 index 61bc5b654..000000000 --- a/lsp/bin/lsp_gen.ml +++ /dev/null @@ -1,7 +0,0 @@ -module Typescript = Typescript -module Ocaml = Ocaml -module Cinaps = Cinaps -module Metamodel = Metamodel - -let print_ml = Cinaps.print_ml -let print_mli = Cinaps.print_mli diff --git a/lsp/bin/metamodel/dune b/lsp/bin/metamodel/dune deleted file mode 100644 index 0a412d407..000000000 --- a/lsp/bin/metamodel/dune +++ /dev/null @@ -1,9 +0,0 @@ -; get rid of this gross hack once dune has proper crunch support - -(rule - (with-stdout-to - metamodel_lsp.ml - (progn - (echo "let t () = Metamodel.t @@ Yojson.Safe.from_string {json|") - (echo "%{read:metaModel.json}") - (echo "|json}")))) diff --git a/lsp/bin/metamodel/metaModel.json b/lsp/bin/metamodel/metaModel.json deleted file mode 100644 index 2ee608d22..000000000 --- a/lsp/bin/metamodel/metaModel.json +++ /dev/null @@ -1,14920 +0,0 @@ -{ - "metaData": { - "version": "3.17.0" - }, - "requests": [ - { - "method": "textDocument/implementation", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Definition" - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DefinitionLink" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "ImplementationParams" - }, - "partialResult": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "Location" - } - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DefinitionLink" - } - } - ] - }, - "registrationOptions": { - "kind": "reference", - "name": "ImplementationRegistrationOptions" - }, - "documentation": "A request to resolve the implementation locations of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPositionParams}\nthe response is of type {@link Definition} or a Thenable that resolves to such." - }, - { - "method": "textDocument/typeDefinition", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Definition" - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DefinitionLink" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "TypeDefinitionParams" - }, - "partialResult": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "Location" - } - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DefinitionLink" - } - } - ] - }, - "registrationOptions": { - "kind": "reference", - "name": "TypeDefinitionRegistrationOptions" - }, - "documentation": "A request to resolve the type definition locations of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPositionParams}\nthe response is of type {@link Definition} or a Thenable that resolves to such." - }, - { - "method": "workspace/workspaceFolders", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "WorkspaceFolder" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "serverToClient", - "documentation": "The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders." - }, - { - "method": "workspace/configuration", - "result": { - "kind": "array", - "element": { - "kind": "reference", - "name": "LSPAny" - } - }, - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "ConfigurationParams" - }, - "documentation": "The 'workspace/configuration' request is sent from the server to the client to fetch a certain\nconfiguration setting.\n\nThis pull model replaces the old push model where the client signaled configuration change via an\nevent. If the server still needs to react to configuration changes (since the server caches the\nresult of `workspace/configuration` requests) the server should register for an empty configuration\nchange event and empty the cache if such an event is received." - }, - { - "method": "textDocument/documentColor", - "result": { - "kind": "array", - "element": { - "kind": "reference", - "name": "ColorInformation" - } - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DocumentColorParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "ColorInformation" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "DocumentColorRegistrationOptions" - }, - "documentation": "A request to list all color symbols found in a given text document. The request's\nparameter is of type {@link DocumentColorParams} the\nresponse is of type {@link ColorInformation ColorInformation[]} or a Thenable\nthat resolves to such." - }, - { - "method": "textDocument/colorPresentation", - "result": { - "kind": "array", - "element": { - "kind": "reference", - "name": "ColorPresentation" - } - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "ColorPresentationParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "ColorPresentation" - } - }, - "registrationOptions": { - "kind": "and", - "items": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - }, - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - } - ] - }, - "documentation": "A request to list all presentation for a color. The request's\nparameter is of type {@link ColorPresentationParams} the\nresponse is of type {@link ColorInformation ColorInformation[]} or a Thenable\nthat resolves to such." - }, - { - "method": "textDocument/foldingRange", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "FoldingRange" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "FoldingRangeParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "FoldingRange" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "FoldingRangeRegistrationOptions" - }, - "documentation": "A request to provide folding ranges in a document. The request's\nparameter is of type {@link FoldingRangeParams}, the\nresponse is of type {@link FoldingRangeList} or a Thenable\nthat resolves to such." - }, - { - "method": "workspace/foldingRange/refresh", - "result": { - "kind": "base", - "name": "null" - }, - "messageDirection": "serverToClient", - "documentation": "@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "method": "textDocument/declaration", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Declaration" - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DeclarationLink" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DeclarationParams" - }, - "partialResult": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "Location" - } - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DeclarationLink" - } - } - ] - }, - "registrationOptions": { - "kind": "reference", - "name": "DeclarationRegistrationOptions" - }, - "documentation": "A request to resolve the type definition locations of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPositionParams}\nthe response is of type {@link Declaration} or a typed array of {@link DeclarationLink}\nor a Thenable that resolves to such." - }, - { - "method": "textDocument/selectionRange", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "SelectionRange" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "SelectionRangeParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SelectionRange" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "SelectionRangeRegistrationOptions" - }, - "documentation": "A request to provide selection ranges in a document. The request's\nparameter is of type {@link SelectionRangeParams}, the\nresponse is of type {@link SelectionRange SelectionRange[]} or a Thenable\nthat resolves to such." - }, - { - "method": "window/workDoneProgress/create", - "result": { - "kind": "base", - "name": "null" - }, - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "WorkDoneProgressCreateParams" - }, - "documentation": "The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress\nreporting from the server." - }, - { - "method": "textDocument/prepareCallHierarchy", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "CallHierarchyItem" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CallHierarchyPrepareParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "CallHierarchyRegistrationOptions" - }, - "documentation": "A request to result a `CallHierarchyItem` in a document at a given position.\nCan be used as an input to an incoming or outgoing call hierarchy.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "callHierarchy/incomingCalls", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "CallHierarchyIncomingCall" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CallHierarchyIncomingCallsParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CallHierarchyIncomingCall" - } - }, - "documentation": "A request to resolve the incoming calls for a given `CallHierarchyItem`.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "callHierarchy/outgoingCalls", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "CallHierarchyOutgoingCall" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CallHierarchyOutgoingCallsParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CallHierarchyOutgoingCall" - } - }, - "documentation": "A request to resolve the outgoing calls for a given `CallHierarchyItem`.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "textDocument/semanticTokens/full", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "SemanticTokens" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "SemanticTokensParams" - }, - "partialResult": { - "kind": "reference", - "name": "SemanticTokensPartialResult" - }, - "registrationMethod": "textDocument/semanticTokens", - "registrationOptions": { - "kind": "reference", - "name": "SemanticTokensRegistrationOptions" - }, - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "textDocument/semanticTokens/full/delta", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "SemanticTokens" - }, - { - "kind": "reference", - "name": "SemanticTokensDelta" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "SemanticTokensDeltaParams" - }, - "partialResult": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "SemanticTokensPartialResult" - }, - { - "kind": "reference", - "name": "SemanticTokensDeltaPartialResult" - } - ] - }, - "registrationMethod": "textDocument/semanticTokens", - "registrationOptions": { - "kind": "reference", - "name": "SemanticTokensRegistrationOptions" - }, - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "textDocument/semanticTokens/range", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "SemanticTokens" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "SemanticTokensRangeParams" - }, - "partialResult": { - "kind": "reference", - "name": "SemanticTokensPartialResult" - }, - "registrationMethod": "textDocument/semanticTokens", - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "workspace/semanticTokens/refresh", - "result": { - "kind": "base", - "name": "null" - }, - "messageDirection": "serverToClient", - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "window/showDocument", - "result": { - "kind": "reference", - "name": "ShowDocumentResult" - }, - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "ShowDocumentParams" - }, - "documentation": "A request to show a document. This request might open an\nexternal program depending on the value of the URI to open.\nFor example a request to open `https://code.visualstudio.com/`\nwill very likely open the URI in a WEB browser.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "textDocument/linkedEditingRange", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "LinkedEditingRanges" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "LinkedEditingRangeParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "LinkedEditingRangeRegistrationOptions" - }, - "documentation": "A request to provide ranges that can be edited together.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "workspace/willCreateFiles", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "WorkspaceEdit" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CreateFilesParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "documentation": "The will create files request is sent from the client to the server before files are actually\ncreated as long as the creation is triggered from within the client.\n\nThe request can return a `WorkspaceEdit` which will be applied to workspace before the\nfiles are created. Hence the `WorkspaceEdit` can not manipulate the content of the file\nto be created.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "workspace/willRenameFiles", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "WorkspaceEdit" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "RenameFilesParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "documentation": "The will rename files request is sent from the client to the server before files are actually\nrenamed as long as the rename is triggered from within the client.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "workspace/willDeleteFiles", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "WorkspaceEdit" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DeleteFilesParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "documentation": "The did delete files notification is sent from the client to the server when\nfiles were deleted from within the client.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "textDocument/moniker", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "Moniker" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "MonikerParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Moniker" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "MonikerRegistrationOptions" - }, - "documentation": "A request to get the moniker of a symbol at a given text document position.\nThe request parameter is of type {@link TextDocumentPositionParams}.\nThe response is of type {@link Moniker Moniker[]} or `null`." - }, - { - "method": "textDocument/prepareTypeHierarchy", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "TypeHierarchyItem" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "TypeHierarchyPrepareParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "TypeHierarchyRegistrationOptions" - }, - "documentation": "A request to result a `TypeHierarchyItem` in a document at a given position.\nCan be used as an input to a subtypes or supertypes type hierarchy.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "typeHierarchy/supertypes", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "TypeHierarchyItem" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "TypeHierarchySupertypesParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TypeHierarchyItem" - } - }, - "documentation": "A request to resolve the supertypes for a given `TypeHierarchyItem`.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "typeHierarchy/subtypes", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "TypeHierarchyItem" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "TypeHierarchySubtypesParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TypeHierarchyItem" - } - }, - "documentation": "A request to resolve the subtypes for a given `TypeHierarchyItem`.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "textDocument/inlineValue", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlineValue" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "InlineValueParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlineValue" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "InlineValueRegistrationOptions" - }, - "documentation": "A request to provide inline values in a document. The request's parameter is of\ntype {@link InlineValueParams}, the response is of type\n{@link InlineValue InlineValue[]} or a Thenable that resolves to such.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "workspace/inlineValue/refresh", - "result": { - "kind": "base", - "name": "null" - }, - "messageDirection": "serverToClient", - "documentation": "@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "textDocument/inlayHint", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlayHint" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "InlayHintParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlayHint" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "InlayHintRegistrationOptions" - }, - "documentation": "A request to provide inlay hints in a document. The request's parameter is of\ntype {@link InlayHintsParams}, the response is of type\n{@link InlayHint InlayHint[]} or a Thenable that resolves to such.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "inlayHint/resolve", - "result": { - "kind": "reference", - "name": "InlayHint" - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "InlayHint" - }, - "documentation": "A request to resolve additional properties for an inlay hint.\nThe request's parameter is of type {@link InlayHint}, the response is\nof type {@link InlayHint} or a Thenable that resolves to such.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "workspace/inlayHint/refresh", - "result": { - "kind": "base", - "name": "null" - }, - "messageDirection": "serverToClient", - "documentation": "@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "textDocument/diagnostic", - "result": { - "kind": "reference", - "name": "DocumentDiagnosticReport" - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DocumentDiagnosticParams" - }, - "partialResult": { - "kind": "reference", - "name": "DocumentDiagnosticReportPartialResult" - }, - "errorData": { - "kind": "reference", - "name": "DiagnosticServerCancellationData" - }, - "registrationOptions": { - "kind": "reference", - "name": "DiagnosticRegistrationOptions" - }, - "documentation": "The document diagnostic request definition.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "workspace/diagnostic", - "result": { - "kind": "reference", - "name": "WorkspaceDiagnosticReport" - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "WorkspaceDiagnosticParams" - }, - "partialResult": { - "kind": "reference", - "name": "WorkspaceDiagnosticReportPartialResult" - }, - "errorData": { - "kind": "reference", - "name": "DiagnosticServerCancellationData" - }, - "documentation": "The workspace diagnostic request definition.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "workspace/diagnostic/refresh", - "result": { - "kind": "base", - "name": "null" - }, - "messageDirection": "serverToClient", - "documentation": "The diagnostic refresh request definition.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "textDocument/inlineCompletion", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "InlineCompletionList" - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlineCompletionItem" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "InlineCompletionParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlineCompletionItem" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "InlineCompletionRegistrationOptions" - }, - "documentation": "A request to provide inline completions in a document. The request's parameter is of\ntype {@link InlineCompletionParams}, the response is of type\n{@link InlineCompletion InlineCompletion[]} or a Thenable that resolves to such.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "method": "client/registerCapability", - "result": { - "kind": "base", - "name": "null" - }, - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "RegistrationParams" - }, - "documentation": "The `client/registerCapability` request is sent from the server to the client to register a new capability\nhandler on the client side." - }, - { - "method": "client/unregisterCapability", - "result": { - "kind": "base", - "name": "null" - }, - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "UnregistrationParams" - }, - "documentation": "The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability\nhandler on the client side." - }, - { - "method": "initialize", - "result": { - "kind": "reference", - "name": "InitializeResult" - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "InitializeParams" - }, - "errorData": { - "kind": "reference", - "name": "InitializeError" - }, - "documentation": "The initialize request is sent from the client to the server.\nIt is sent once as the request after starting up the server.\nThe requests parameter is of type {@link InitializeParams}\nthe response if of type {@link InitializeResult} of a Thenable that\nresolves to such." - }, - { - "method": "shutdown", - "result": { - "kind": "base", - "name": "null" - }, - "messageDirection": "clientToServer", - "documentation": "A shutdown request is sent from the client to the server.\nIt is sent once when the client decides to shutdown the\nserver. The only notification that is sent after a shutdown request\nis the exit event." - }, - { - "method": "window/showMessageRequest", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "MessageActionItem" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "ShowMessageRequestParams" - }, - "documentation": "The show message request is sent from the server to the client to show a message\nand a set of options actions to the user." - }, - { - "method": "textDocument/willSaveWaitUntil", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextEdit" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "WillSaveTextDocumentParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - "documentation": "A document will save request is sent from the client to the server before\nthe document is actually saved. The request can return an array of TextEdits\nwhich will be applied to the text document before it is saved. Please note that\nclients might drop results if computing the text edits took too long or if a\nserver constantly fails on this request. This is done to keep the save fast and\nreliable." - }, - { - "method": "textDocument/completion", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "CompletionItem" - } - }, - { - "kind": "reference", - "name": "CompletionList" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CompletionParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CompletionItem" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "CompletionRegistrationOptions" - }, - "documentation": "Request to request completion at a given text document position. The request's\nparameter is of type {@link TextDocumentPosition} the response\nis of type {@link CompletionItem CompletionItem[]} or {@link CompletionList}\nor a Thenable that resolves to such.\n\nThe request can delay the computation of the {@link CompletionItem.detail `detail`}\nand {@link CompletionItem.documentation `documentation`} properties to the `completionItem/resolve`\nrequest. However, properties that are needed for the initial sorting and filtering, like `sortText`,\n`filterText`, `insertText`, and `textEdit`, must not be changed during resolve." - }, - { - "method": "completionItem/resolve", - "result": { - "kind": "reference", - "name": "CompletionItem" - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CompletionItem" - }, - "documentation": "Request to resolve additional information for a given completion item.The request's\nparameter is of type {@link CompletionItem} the response\nis of type {@link CompletionItem} or a Thenable that resolves to such." - }, - { - "method": "textDocument/hover", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Hover" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "HoverParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "HoverRegistrationOptions" - }, - "documentation": "Request to request hover information at a given text document position. The request's\nparameter is of type {@link TextDocumentPosition} the response is of\ntype {@link Hover} or a Thenable that resolves to such." - }, - { - "method": "textDocument/signatureHelp", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "SignatureHelp" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "SignatureHelpParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "SignatureHelpRegistrationOptions" - } - }, - { - "method": "textDocument/definition", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Definition" - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DefinitionLink" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DefinitionParams" - }, - "partialResult": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "Location" - } - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DefinitionLink" - } - } - ] - }, - "registrationOptions": { - "kind": "reference", - "name": "DefinitionRegistrationOptions" - }, - "documentation": "A request to resolve the definition location of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPosition}\nthe response is of either type {@link Definition} or a typed array of\n{@link DefinitionLink} or a Thenable that resolves to such." - }, - { - "method": "textDocument/references", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "Location" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "ReferenceParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Location" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "ReferenceRegistrationOptions" - }, - "documentation": "A request to resolve project-wide references for the symbol denoted\nby the given text document position. The request's parameter is of\ntype {@link ReferenceParams} the response is of type\n{@link Location Location[]} or a Thenable that resolves to such." - }, - { - "method": "textDocument/documentHighlight", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DocumentHighlight" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DocumentHighlightParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "DocumentHighlight" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "DocumentHighlightRegistrationOptions" - }, - "documentation": "Request to resolve a {@link DocumentHighlight} for a given\ntext document position. The request's parameter is of type {@link TextDocumentPosition}\nthe request response is an array of type {@link DocumentHighlight}\nor a Thenable that resolves to such." - }, - { - "method": "textDocument/documentSymbol", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolInformation" - } - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DocumentSymbol" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DocumentSymbolParams" - }, - "partialResult": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolInformation" - } - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DocumentSymbol" - } - } - ] - }, - "registrationOptions": { - "kind": "reference", - "name": "DocumentSymbolRegistrationOptions" - }, - "documentation": "A request to list all symbols found in a given text document. The request's\nparameter is of type {@link TextDocumentIdentifier} the\nresponse is of type {@link SymbolInformation SymbolInformation[]} or a Thenable\nthat resolves to such." - }, - { - "method": "textDocument/codeAction", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Command" - }, - { - "kind": "reference", - "name": "CodeAction" - } - ] - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CodeActionParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Command" - }, - { - "kind": "reference", - "name": "CodeAction" - } - ] - } - }, - "registrationOptions": { - "kind": "reference", - "name": "CodeActionRegistrationOptions" - }, - "documentation": "A request to provide commands for the given text document and range." - }, - { - "method": "codeAction/resolve", - "result": { - "kind": "reference", - "name": "CodeAction" - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CodeAction" - }, - "documentation": "Request to resolve additional information for a given code action.The request's\nparameter is of type {@link CodeAction} the response\nis of type {@link CodeAction} or a Thenable that resolves to such." - }, - { - "method": "workspace/symbol", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolInformation" - } - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "WorkspaceSymbol" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "WorkspaceSymbolParams" - }, - "partialResult": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolInformation" - } - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "WorkspaceSymbol" - } - } - ] - }, - "registrationOptions": { - "kind": "reference", - "name": "WorkspaceSymbolRegistrationOptions" - }, - "documentation": "A request to list project-wide symbols matching the query string given\nby the {@link WorkspaceSymbolParams}. The response is\nof type {@link SymbolInformation SymbolInformation[]} or a Thenable that\nresolves to such.\n\n@since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients\n need to advertise support for WorkspaceSymbols via the client capability\n `workspace.symbol.resolveSupport`.\n", - "since": "3.17.0 - support for WorkspaceSymbol in the returned data. Clients\nneed to advertise support for WorkspaceSymbols via the client capability\n`workspace.symbol.resolveSupport`." - }, - { - "method": "workspaceSymbol/resolve", - "result": { - "kind": "reference", - "name": "WorkspaceSymbol" - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "WorkspaceSymbol" - }, - "documentation": "A request to resolve the range inside the workspace\nsymbol's location.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "textDocument/codeLens", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "CodeLens" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CodeLensParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CodeLens" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "CodeLensRegistrationOptions" - }, - "documentation": "A request to provide code lens for the given text document." - }, - { - "method": "codeLens/resolve", - "result": { - "kind": "reference", - "name": "CodeLens" - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CodeLens" - }, - "documentation": "A request to resolve a command for a given code lens." - }, - { - "method": "workspace/codeLens/refresh", - "result": { - "kind": "base", - "name": "null" - }, - "messageDirection": "serverToClient", - "documentation": "A request to refresh all code actions\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "textDocument/documentLink", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "DocumentLink" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DocumentLinkParams" - }, - "partialResult": { - "kind": "array", - "element": { - "kind": "reference", - "name": "DocumentLink" - } - }, - "registrationOptions": { - "kind": "reference", - "name": "DocumentLinkRegistrationOptions" - }, - "documentation": "A request to provide document links" - }, - { - "method": "documentLink/resolve", - "result": { - "kind": "reference", - "name": "DocumentLink" - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DocumentLink" - }, - "documentation": "Request to resolve additional information for a given document link. The request's\nparameter is of type {@link DocumentLink} the response\nis of type {@link DocumentLink} or a Thenable that resolves to such." - }, - { - "method": "textDocument/formatting", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextEdit" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DocumentFormattingParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "DocumentFormattingRegistrationOptions" - }, - "documentation": "A request to format a whole document." - }, - { - "method": "textDocument/rangeFormatting", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextEdit" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DocumentRangeFormattingParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "DocumentRangeFormattingRegistrationOptions" - }, - "documentation": "A request to format a range in a document." - }, - { - "method": "textDocument/rangesFormatting", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextEdit" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DocumentRangesFormattingParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "DocumentRangeFormattingRegistrationOptions" - }, - "documentation": "A request to format ranges in a document.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "method": "textDocument/onTypeFormatting", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextEdit" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DocumentOnTypeFormattingParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "DocumentOnTypeFormattingRegistrationOptions" - }, - "documentation": "A request to format a document on type." - }, - { - "method": "textDocument/rename", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "WorkspaceEdit" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "RenameParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "RenameRegistrationOptions" - }, - "documentation": "A request to rename a symbol." - }, - { - "method": "textDocument/prepareRename", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "PrepareRenameResult" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "PrepareRenameParams" - }, - "documentation": "A request to test and perform the setup necessary for a rename.\n\n@since 3.16 - support for default behavior", - "since": "3.16 - support for default behavior" - }, - { - "method": "workspace/executeCommand", - "result": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "LSPAny" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "ExecuteCommandParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "ExecuteCommandRegistrationOptions" - }, - "documentation": "A request sent from the client to the server to execute a command. The request might return\na workspace edit which the client will apply to the workspace." - }, - { - "method": "workspace/applyEdit", - "result": { - "kind": "reference", - "name": "ApplyWorkspaceEditResult" - }, - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "ApplyWorkspaceEditParams" - }, - "documentation": "A request sent from the server to the client to modify certain resources." - } - ], - "notifications": [ - { - "method": "workspace/didChangeWorkspaceFolders", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidChangeWorkspaceFoldersParams" - }, - "documentation": "The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace\nfolder configuration changes." - }, - { - "method": "window/workDoneProgress/cancel", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "WorkDoneProgressCancelParams" - }, - "documentation": "The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress\ninitiated on the server side." - }, - { - "method": "workspace/didCreateFiles", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "CreateFilesParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "documentation": "The did create files notification is sent from the client to the server when\nfiles were created from within the client.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "workspace/didRenameFiles", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "RenameFilesParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "documentation": "The did rename files notification is sent from the client to the server when\nfiles were renamed from within the client.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "workspace/didDeleteFiles", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DeleteFilesParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "documentation": "The will delete files request is sent from the client to the server before files are actually\ndeleted as long as the deletion is triggered from within the client.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "method": "notebookDocument/didOpen", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidOpenNotebookDocumentParams" - }, - "registrationMethod": "notebookDocument/sync", - "documentation": "A notification sent when a notebook opens.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "notebookDocument/didChange", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidChangeNotebookDocumentParams" - }, - "registrationMethod": "notebookDocument/sync" - }, - { - "method": "notebookDocument/didSave", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidSaveNotebookDocumentParams" - }, - "registrationMethod": "notebookDocument/sync", - "documentation": "A notification sent when a notebook document is saved.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "notebookDocument/didClose", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidCloseNotebookDocumentParams" - }, - "registrationMethod": "notebookDocument/sync", - "documentation": "A notification sent when a notebook closes.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "method": "initialized", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "InitializedParams" - }, - "documentation": "The initialized notification is sent from the client to the\nserver after the client is fully initialized and the server\nis allowed to send requests from the server to the client." - }, - { - "method": "exit", - "messageDirection": "clientToServer", - "documentation": "The exit event is sent from the client to the server to\nask the server to exit its process." - }, - { - "method": "workspace/didChangeConfiguration", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidChangeConfigurationParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "DidChangeConfigurationRegistrationOptions" - }, - "documentation": "The configuration change notification is sent from the client to the server\nwhen the client's configuration has changed. The notification contains\nthe changed configuration as defined by the language client." - }, - { - "method": "window/showMessage", - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "ShowMessageParams" - }, - "documentation": "The show message notification is sent from a server to a client to ask\nthe client to display a particular message in the user interface." - }, - { - "method": "window/logMessage", - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "LogMessageParams" - }, - "documentation": "The log message notification is sent from the server to the client to ask\nthe client to log a particular message." - }, - { - "method": "telemetry/event", - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "LSPAny" - }, - "documentation": "The telemetry event notification is sent from the server to the client to ask\nthe client to log telemetry data." - }, - { - "method": "textDocument/didOpen", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidOpenTextDocumentParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - "documentation": "The document open notification is sent from the client to the server to signal\nnewly opened text documents. The document's truth is now managed by the client\nand the server must not try to read the document's truth using the document's\nuri. Open in this sense means it is managed by the client. It doesn't necessarily\nmean that its content is presented in an editor. An open notification must not\nbe sent more than once without a corresponding close notification send before.\nThis means open and close notification must be balanced and the max open count\nis one." - }, - { - "method": "textDocument/didChange", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidChangeTextDocumentParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "TextDocumentChangeRegistrationOptions" - }, - "documentation": "The document change notification is sent from the client to the server to signal\nchanges to a text document." - }, - { - "method": "textDocument/didClose", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidCloseTextDocumentParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - "documentation": "The document close notification is sent from the client to the server when\nthe document got closed in the client. The document's truth now exists where\nthe document's uri points to (e.g. if the document's uri is a file uri the\ntruth now exists on disk). As with the open notification the close notification\nis about managing the document's content. Receiving a close notification\ndoesn't mean that the document was open in an editor before. A close\nnotification requires a previous open notification to be sent." - }, - { - "method": "textDocument/didSave", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidSaveTextDocumentParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "TextDocumentSaveRegistrationOptions" - }, - "documentation": "The document save notification is sent from the client to the server when\nthe document got saved in the client." - }, - { - "method": "textDocument/willSave", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "WillSaveTextDocumentParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - "documentation": "A document will save notification is sent from the client to the server before\nthe document is actually saved." - }, - { - "method": "workspace/didChangeWatchedFiles", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "DidChangeWatchedFilesParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "DidChangeWatchedFilesRegistrationOptions" - }, - "documentation": "The watched files notification is sent from the client to the server when\nthe client detects changes to file watched by the language client." - }, - { - "method": "textDocument/publishDiagnostics", - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "PublishDiagnosticsParams" - }, - "documentation": "Diagnostics notification are sent from the server to the client to signal\nresults of validation runs." - }, - { - "method": "$/setTrace", - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "SetTraceParams" - } - }, - { - "method": "$/logTrace", - "messageDirection": "serverToClient", - "params": { - "kind": "reference", - "name": "LogTraceParams" - } - }, - { - "method": "$/cancelRequest", - "messageDirection": "both", - "params": { - "kind": "reference", - "name": "CancelParams" - } - }, - { - "method": "$/progress", - "messageDirection": "both", - "params": { - "kind": "reference", - "name": "ProgressParams" - } - } - ], - "structures": [ - { - "name": "ImplementationParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ] - }, - { - "name": "Location", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - } - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - } - } - ], - "documentation": "Represents a location inside a resource, such as a line\ninside a text file." - }, - { - "name": "ImplementationRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "ImplementationOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ] - }, - { - "name": "TypeDefinitionParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ] - }, - { - "name": "TypeDefinitionRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "TypeDefinitionOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ] - }, - { - "name": "WorkspaceFolder", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "URI" - }, - "documentation": "The associated URI for this workspace folder." - }, - { - "name": "name", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The name of the workspace folder. Used to refer to this\nworkspace folder in the user interface." - } - ], - "documentation": "A workspace folder inside a client." - }, - { - "name": "DidChangeWorkspaceFoldersParams", - "properties": [ - { - "name": "event", - "type": { - "kind": "reference", - "name": "WorkspaceFoldersChangeEvent" - }, - "documentation": "The actual workspace folder change event." - } - ], - "documentation": "The parameters of a `workspace/didChangeWorkspaceFolders` notification." - }, - { - "name": "ConfigurationParams", - "properties": [ - { - "name": "items", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "ConfigurationItem" - } - } - } - ], - "documentation": "The parameters of a configuration request." - }, - { - "name": "DocumentColorParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "Parameters for a {@link DocumentColorRequest}." - }, - { - "name": "ColorInformation", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range in the document where this color appears." - }, - { - "name": "color", - "type": { - "kind": "reference", - "name": "Color" - }, - "documentation": "The actual color value for this color range." - } - ], - "documentation": "Represents a color range from a document." - }, - { - "name": "DocumentColorRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "DocumentColorOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ] - }, - { - "name": "ColorPresentationParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - }, - { - "name": "color", - "type": { - "kind": "reference", - "name": "Color" - }, - "documentation": "The color to request presentations for." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range where the color would be inserted. Serves as a context." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "Parameters for a {@link ColorPresentationRequest}." - }, - { - "name": "ColorPresentation", - "properties": [ - { - "name": "label", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The label of this color presentation. It will be shown on the color\npicker header. By default this is also the text that is inserted when selecting\nthis color presentation." - }, - { - "name": "textEdit", - "type": { - "kind": "reference", - "name": "TextEdit" - }, - "optional": true, - "documentation": "An {@link TextEdit edit} which is applied to a document when selecting\nthis presentation for the color. When `falsy` the {@link ColorPresentation.label label}\nis used." - }, - { - "name": "additionalTextEdits", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextEdit" - } - }, - "optional": true, - "documentation": "An optional array of additional {@link TextEdit text edits} that are applied when\nselecting this color presentation. Edits must not overlap with the main {@link ColorPresentation.textEdit edit} nor with themselves." - } - ] - }, - { - "name": "WorkDoneProgressOptions", - "properties": [ - { - "name": "workDoneProgress", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true - } - ] - }, - { - "name": "TextDocumentRegistrationOptions", - "properties": [ - { - "name": "documentSelector", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "DocumentSelector" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "documentation": "A document selector to identify the scope of the registration. If set to null\nthe document selector provided on the client side will be used." - } - ], - "documentation": "General text document registration options." - }, - { - "name": "FoldingRangeParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "Parameters for a {@link FoldingRangeRequest}." - }, - { - "name": "FoldingRange", - "properties": [ - { - "name": "startLine", - "type": { - "kind": "base", - "name": "uinteger" - }, - "documentation": "The zero-based start line of the range to fold. The folded area starts after the line's last character.\nTo be valid, the end must be zero or larger and smaller than the number of lines in the document." - }, - { - "name": "startCharacter", - "type": { - "kind": "base", - "name": "uinteger" - }, - "optional": true, - "documentation": "The zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line." - }, - { - "name": "endLine", - "type": { - "kind": "base", - "name": "uinteger" - }, - "documentation": "The zero-based end line of the range to fold. The folded area ends with the line's last character.\nTo be valid, the end must be zero or larger and smaller than the number of lines in the document." - }, - { - "name": "endCharacter", - "type": { - "kind": "base", - "name": "uinteger" - }, - "optional": true, - "documentation": "The zero-based character offset before the folded range ends. If not defined, defaults to the length of the end line." - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "FoldingRangeKind" - }, - "optional": true, - "documentation": "Describes the kind of the folding range such as `comment' or 'region'. The kind\nis used to categorize folding ranges and used by commands like 'Fold all comments'.\nSee {@link FoldingRangeKind} for an enumeration of standardized kinds." - }, - { - "name": "collapsedText", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The text that the client should show when the specified range is\ncollapsed. If not defined or not supported by the client, a default\nwill be chosen by the client.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "documentation": "Represents a folding range. To be valid, start and end line must be bigger than zero and smaller\nthan the number of lines in the document. Clients are free to ignore invalid ranges." - }, - { - "name": "FoldingRangeRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "FoldingRangeOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ] - }, - { - "name": "DeclarationParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ] - }, - { - "name": "DeclarationRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "DeclarationOptions" - }, - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ] - }, - { - "name": "SelectionRangeParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - }, - { - "name": "positions", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Position" - } - }, - "documentation": "The positions inside the text document." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "A parameter literal used in selection range requests." - }, - { - "name": "SelectionRange", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The {@link Range range} of this selection range." - }, - { - "name": "parent", - "type": { - "kind": "reference", - "name": "SelectionRange" - }, - "optional": true, - "documentation": "The parent selection range containing this range. Therefore `parent.range` must contain `this.range`." - } - ], - "documentation": "A selection range represents a part of a selection hierarchy. A selection range\nmay have a parent selection range that contains it." - }, - { - "name": "SelectionRangeRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "SelectionRangeOptions" - }, - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ] - }, - { - "name": "WorkDoneProgressCreateParams", - "properties": [ - { - "name": "token", - "type": { - "kind": "reference", - "name": "ProgressToken" - }, - "documentation": "The token to be used to report progress." - } - ] - }, - { - "name": "WorkDoneProgressCancelParams", - "properties": [ - { - "name": "token", - "type": { - "kind": "reference", - "name": "ProgressToken" - }, - "documentation": "The token to be used to report progress." - } - ] - }, - { - "name": "CallHierarchyPrepareParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "The parameter of a `textDocument/prepareCallHierarchy` request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "CallHierarchyItem", - "properties": [ - { - "name": "name", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The name of this item." - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "SymbolKind" - }, - "documentation": "The kind of this item." - }, - { - "name": "tags", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolTag" - } - }, - "optional": true, - "documentation": "Tags for this item." - }, - { - "name": "detail", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "More detail for this item, e.g. the signature of a function." - }, - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The resource identifier of this item." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code." - }, - { - "name": "selectionRange", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range that should be selected and revealed when this symbol is being picked, e.g. the name of a function.\nMust be contained by the {@link CallHierarchyItem.range `range`}." - }, - { - "name": "data", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "A data entry field that is preserved between a call hierarchy prepare and\nincoming calls or outgoing calls requests." - } - ], - "documentation": "Represents programming constructs like functions or constructors in the context\nof call hierarchy.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "CallHierarchyRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "CallHierarchyOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ], - "documentation": "Call hierarchy options used during static or dynamic registration.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "CallHierarchyIncomingCallsParams", - "properties": [ - { - "name": "item", - "type": { - "kind": "reference", - "name": "CallHierarchyItem" - } - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "The parameter of a `callHierarchy/incomingCalls` request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "CallHierarchyIncomingCall", - "properties": [ - { - "name": "from", - "type": { - "kind": "reference", - "name": "CallHierarchyItem" - }, - "documentation": "The item that makes the call." - }, - { - "name": "fromRanges", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Range" - } - }, - "documentation": "The ranges at which the calls appear. This is relative to the caller\ndenoted by {@link CallHierarchyIncomingCall.from `this.from`}." - } - ], - "documentation": "Represents an incoming call, e.g. a caller of a method or constructor.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "CallHierarchyOutgoingCallsParams", - "properties": [ - { - "name": "item", - "type": { - "kind": "reference", - "name": "CallHierarchyItem" - } - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "The parameter of a `callHierarchy/outgoingCalls` request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "CallHierarchyOutgoingCall", - "properties": [ - { - "name": "to", - "type": { - "kind": "reference", - "name": "CallHierarchyItem" - }, - "documentation": "The item that is called." - }, - { - "name": "fromRanges", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Range" - } - }, - "documentation": "The range at which this item is called. This is the range relative to the caller, e.g the item\npassed to {@link CallHierarchyItemProvider.provideCallHierarchyOutgoingCalls `provideCallHierarchyOutgoingCalls`}\nand not {@link CallHierarchyOutgoingCall.to `this.to`}." - } - ], - "documentation": "Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokensParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokens", - "properties": [ - { - "name": "resultId", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "An optional result id. If provided and clients support delta updating\nthe client will include the result id in the next semantic token request.\nA server can then instead of computing all semantic tokens again simply\nsend a delta." - }, - { - "name": "data", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "uinteger" - } - }, - "documentation": "The actual tokens." - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokensPartialResult", - "properties": [ - { - "name": "data", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "uinteger" - } - } - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokensRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "SemanticTokensOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokensDeltaParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - }, - { - "name": "previousResultId", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The result id of a previous response. The result Id can either point to a full response\nor a delta response depending on what was received last." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokensDelta", - "properties": [ - { - "name": "resultId", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true - }, - { - "name": "edits", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SemanticTokensEdit" - } - }, - "documentation": "The semantic token edits to transform a previous result into a new result." - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokensDeltaPartialResult", - "properties": [ - { - "name": "edits", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SemanticTokensEdit" - } - } - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokensRangeParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range the semantic tokens are requested for." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "ShowDocumentParams", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "URI" - }, - "documentation": "The uri to show." - }, - { - "name": "external", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Indicates to show the resource in an external program.\nTo show, for example, `https://code.visualstudio.com/`\nin the default WEB browser set `external` to `true`." - }, - { - "name": "takeFocus", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "An optional property to indicate whether the editor\nshowing the document should take focus or not.\nClients might ignore this property if an external\nprogram is started." - }, - { - "name": "selection", - "type": { - "kind": "reference", - "name": "Range" - }, - "optional": true, - "documentation": "An optional selection range if the document is a text\ndocument. Clients might ignore the property if an\nexternal program is started or the file is not a text\nfile." - } - ], - "documentation": "Params to show a resource in the UI.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "ShowDocumentResult", - "properties": [ - { - "name": "success", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "A boolean indicating if the show was successful." - } - ], - "documentation": "The result of a showDocument request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "LinkedEditingRangeParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ] - }, - { - "name": "LinkedEditingRanges", - "properties": [ - { - "name": "ranges", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Range" - } - }, - "documentation": "A list of ranges that can be edited together. The ranges must have\nidentical length and contain identical text content. The ranges cannot overlap." - }, - { - "name": "wordPattern", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "An optional word pattern (regular expression) that describes valid contents for\nthe given ranges. If no pattern is provided, the client configuration's word\npattern will be used." - } - ], - "documentation": "The result of a linked editing range request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "LinkedEditingRangeRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "LinkedEditingRangeOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ] - }, - { - "name": "CreateFilesParams", - "properties": [ - { - "name": "files", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "FileCreate" - } - }, - "documentation": "An array of all files/folders created in this operation." - } - ], - "documentation": "The parameters sent in notifications/requests for user-initiated creation of\nfiles.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "WorkspaceEdit", - "properties": [ - { - "name": "changes", - "type": { - "kind": "map", - "key": { - "kind": "base", - "name": "DocumentUri" - }, - "value": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextEdit" - } - } - }, - "optional": true, - "documentation": "Holds changes to existing resources." - }, - { - "name": "documentChanges", - "type": { - "kind": "array", - "element": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "TextDocumentEdit" - }, - { - "kind": "reference", - "name": "CreateFile" - }, - { - "kind": "reference", - "name": "RenameFile" - }, - { - "kind": "reference", - "name": "DeleteFile" - } - ] - } - }, - "optional": true, - "documentation": "Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes\nare either an array of `TextDocumentEdit`s to express changes to n different text documents\nwhere each text document edit addresses a specific version of a text document. Or it can contain\nabove `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.\n\nWhether a client supports versioned document edits is expressed via\n`workspace.workspaceEdit.documentChanges` client capability.\n\nIf a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then\nonly plain `TextEdit`s using the `changes` property are supported." - }, - { - "name": "changeAnnotations", - "type": { - "kind": "map", - "key": { - "kind": "reference", - "name": "ChangeAnnotationIdentifier" - }, - "value": { - "kind": "reference", - "name": "ChangeAnnotation" - } - }, - "optional": true, - "documentation": "A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and\ndelete file / folder operations.\n\nWhether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "documentation": "A workspace edit represents changes to many resources managed in the workspace. The edit\nshould either provide `changes` or `documentChanges`. If documentChanges are present\nthey are preferred over `changes` if the client can handle versioned document edits.\n\nSince version 3.13.0 a workspace edit can contain resource operations as well. If resource\noperations are present clients need to execute the operations in the order in which they\nare provided. So a workspace edit for example can consist of the following two changes:\n(1) a create file a.txt and (2) a text document edit which insert text into file a.txt.\n\nAn invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will\ncause failure of the operation. How the client recovers from the failure is described by\nthe client capability: `workspace.workspaceEdit.failureHandling`" - }, - { - "name": "FileOperationRegistrationOptions", - "properties": [ - { - "name": "filters", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "FileOperationFilter" - } - }, - "documentation": "The actual filters." - } - ], - "documentation": "The options to register for file operations.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "RenameFilesParams", - "properties": [ - { - "name": "files", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "FileRename" - } - }, - "documentation": "An array of all files/folders renamed in this operation. When a folder is renamed, only\nthe folder will be included, and not its children." - } - ], - "documentation": "The parameters sent in notifications/requests for user-initiated renames of\nfiles.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "DeleteFilesParams", - "properties": [ - { - "name": "files", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "FileDelete" - } - }, - "documentation": "An array of all files/folders deleted in this operation." - } - ], - "documentation": "The parameters sent in notifications/requests for user-initiated deletes of\nfiles.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "MonikerParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ] - }, - { - "name": "Moniker", - "properties": [ - { - "name": "scheme", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The scheme of the moniker. For example tsc or .Net" - }, - { - "name": "identifier", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The identifier of the moniker. The value is opaque in LSIF however\nschema owners are allowed to define the structure if they want." - }, - { - "name": "unique", - "type": { - "kind": "reference", - "name": "UniquenessLevel" - }, - "documentation": "The scope in which the moniker is unique" - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "MonikerKind" - }, - "optional": true, - "documentation": "The moniker kind if known." - } - ], - "documentation": "Moniker definition to match LSIF 0.5 moniker definition.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "MonikerRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "MonikerOptions" - } - ] - }, - { - "name": "TypeHierarchyPrepareParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "The parameter of a `textDocument/prepareTypeHierarchy` request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "TypeHierarchyItem", - "properties": [ - { - "name": "name", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The name of this item." - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "SymbolKind" - }, - "documentation": "The kind of this item." - }, - { - "name": "tags", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolTag" - } - }, - "optional": true, - "documentation": "Tags for this item." - }, - { - "name": "detail", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "More detail for this item, e.g. the signature of a function." - }, - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The resource identifier of this item." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range enclosing this symbol not including leading/trailing whitespace\nbut everything else, e.g. comments and code." - }, - { - "name": "selectionRange", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range that should be selected and revealed when this symbol is being\npicked, e.g. the name of a function. Must be contained by the\n{@link TypeHierarchyItem.range `range`}." - }, - { - "name": "data", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "A data entry field that is preserved between a type hierarchy prepare and\nsupertypes or subtypes requests. It could also be used to identify the\ntype hierarchy in the server, helping improve the performance on\nresolving supertypes and subtypes." - } - ], - "documentation": "@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "TypeHierarchyRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "TypeHierarchyOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ], - "documentation": "Type hierarchy options used during static or dynamic registration.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "TypeHierarchySupertypesParams", - "properties": [ - { - "name": "item", - "type": { - "kind": "reference", - "name": "TypeHierarchyItem" - } - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "The parameter of a `typeHierarchy/supertypes` request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "TypeHierarchySubtypesParams", - "properties": [ - { - "name": "item", - "type": { - "kind": "reference", - "name": "TypeHierarchyItem" - } - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "The parameter of a `typeHierarchy/subtypes` request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineValueParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The document range for which inline values should be computed." - }, - { - "name": "context", - "type": { - "kind": "reference", - "name": "InlineValueContext" - }, - "documentation": "Additional information about the context in which inline values were\nrequested." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "A parameter literal used in inline value requests.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineValueRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "InlineValueOptions" - }, - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ], - "documentation": "Inline value options used during static or dynamic registration.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlayHintParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The document range for which inlay hints should be computed." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "A parameter literal used in inlay hint requests.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlayHint", - "properties": [ - { - "name": "position", - "type": { - "kind": "reference", - "name": "Position" - }, - "documentation": "The position of this hint.\n\nIf multiple hints have the same position, they will be shown in the order\nthey appear in the response." - }, - { - "name": "label", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlayHintLabelPart" - } - } - ] - }, - "documentation": "The label of this hint. A human readable string or an array of\nInlayHintLabelPart label parts.\n\n*Note* that neither the string nor the label part can be empty." - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "InlayHintKind" - }, - "optional": true, - "documentation": "The kind of this hint. Can be omitted in which case the client\nshould fall back to a reasonable default." - }, - { - "name": "textEdits", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextEdit" - } - }, - "optional": true, - "documentation": "Optional text edits that are performed when accepting this inlay hint.\n\n*Note* that edits are expected to change the document so that the inlay\nhint (or its nearest variant) is now part of the document and the inlay\nhint itself is now obsolete." - }, - { - "name": "tooltip", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "reference", - "name": "MarkupContent" - } - ] - }, - "optional": true, - "documentation": "The tooltip text when you hover over this item." - }, - { - "name": "paddingLeft", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Render padding before the hint.\n\nNote: Padding should use the editor's background color, not the\nbackground color of the hint itself. That means padding can be used\nto visually align/separate an inlay hint." - }, - { - "name": "paddingRight", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Render padding after the hint.\n\nNote: Padding should use the editor's background color, not the\nbackground color of the hint itself. That means padding can be used\nto visually align/separate an inlay hint." - }, - { - "name": "data", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "A data entry field that is preserved on an inlay hint between\na `textDocument/inlayHint` and a `inlayHint/resolve` request." - } - ], - "documentation": "Inlay hint information.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlayHintRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "InlayHintOptions" - }, - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ], - "documentation": "Inlay hint options used during static or dynamic registration.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DocumentDiagnosticParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - }, - { - "name": "identifier", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The additional identifier provided during registration." - }, - { - "name": "previousResultId", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The result id of a previous response if provided." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "Parameters of the document diagnostic request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DocumentDiagnosticReportPartialResult", - "properties": [ - { - "name": "relatedDocuments", - "type": { - "kind": "map", - "key": { - "kind": "base", - "name": "DocumentUri" - }, - "value": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "FullDocumentDiagnosticReport" - }, - { - "kind": "reference", - "name": "UnchangedDocumentDiagnosticReport" - } - ] - } - } - } - ], - "documentation": "A partial result for a document diagnostic report.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DiagnosticServerCancellationData", - "properties": [ - { - "name": "retriggerRequest", - "type": { - "kind": "base", - "name": "boolean" - } - } - ], - "documentation": "Cancellation data returned from a diagnostic request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DiagnosticRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "DiagnosticOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ], - "documentation": "Diagnostic registration options.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "WorkspaceDiagnosticParams", - "properties": [ - { - "name": "identifier", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The additional identifier provided during registration." - }, - { - "name": "previousResultIds", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "PreviousResultId" - } - }, - "documentation": "The currently known diagnostic reports with their\nprevious result ids." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "Parameters of the workspace diagnostic request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "WorkspaceDiagnosticReport", - "properties": [ - { - "name": "items", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "WorkspaceDocumentDiagnosticReport" - } - } - } - ], - "documentation": "A workspace diagnostic report.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "WorkspaceDiagnosticReportPartialResult", - "properties": [ - { - "name": "items", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "WorkspaceDocumentDiagnosticReport" - } - } - } - ], - "documentation": "A partial result for a workspace diagnostic report.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DidOpenNotebookDocumentParams", - "properties": [ - { - "name": "notebookDocument", - "type": { - "kind": "reference", - "name": "NotebookDocument" - }, - "documentation": "The notebook document that got opened." - }, - { - "name": "cellTextDocuments", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextDocumentItem" - } - }, - "documentation": "The text documents that represent the content\nof a notebook cell." - } - ], - "documentation": "The params sent in an open notebook document notification.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DidChangeNotebookDocumentParams", - "properties": [ - { - "name": "notebookDocument", - "type": { - "kind": "reference", - "name": "VersionedNotebookDocumentIdentifier" - }, - "documentation": "The notebook document that did change. The version number points\nto the version after all provided changes have been applied. If\nonly the text document content of a cell changes the notebook version\ndoesn't necessarily have to change." - }, - { - "name": "change", - "type": { - "kind": "reference", - "name": "NotebookDocumentChangeEvent" - }, - "documentation": "The actual changes to the notebook document.\n\nThe changes describe single state changes to the notebook document.\nSo if there are two changes c1 (at array index 0) and c2 (at array\nindex 1) for a notebook in state S then c1 moves the notebook from\nS to S' and c2 from S' to S''. So c1 is computed on the state S and\nc2 is computed on the state S'.\n\nTo mirror the content of a notebook using change events use the following approach:\n- start with the same initial content\n- apply the 'notebookDocument/didChange' notifications in the order you receive them.\n- apply the `NotebookChangeEvent`s in a single notification in the order\n you receive them." - } - ], - "documentation": "The params sent in a change notebook document notification.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DidSaveNotebookDocumentParams", - "properties": [ - { - "name": "notebookDocument", - "type": { - "kind": "reference", - "name": "NotebookDocumentIdentifier" - }, - "documentation": "The notebook document that got saved." - } - ], - "documentation": "The params sent in a save notebook document notification.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DidCloseNotebookDocumentParams", - "properties": [ - { - "name": "notebookDocument", - "type": { - "kind": "reference", - "name": "NotebookDocumentIdentifier" - }, - "documentation": "The notebook document that got closed." - }, - { - "name": "cellTextDocuments", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextDocumentIdentifier" - } - }, - "documentation": "The text documents that represent the content\nof a notebook cell that got closed." - } - ], - "documentation": "The params sent in a close notebook document notification.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineCompletionParams", - "properties": [ - { - "name": "context", - "type": { - "kind": "reference", - "name": "InlineCompletionContext" - }, - "documentation": "Additional information about the context in which inline completions were\nrequested." - } - ], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "A parameter literal used in inline completion requests.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "InlineCompletionList", - "properties": [ - { - "name": "items", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlineCompletionItem" - } - }, - "documentation": "The inline completion items" - } - ], - "documentation": "Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "InlineCompletionItem", - "properties": [ - { - "name": "insertText", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "reference", - "name": "StringValue" - } - ] - }, - "documentation": "The text to replace the range with. Must be set." - }, - { - "name": "filterText", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "optional": true, - "documentation": "The range to replace. Must begin and end on the same line." - }, - { - "name": "command", - "type": { - "kind": "reference", - "name": "Command" - }, - "optional": true, - "documentation": "An optional {@link Command} that is executed *after* inserting this completion." - } - ], - "documentation": "An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "InlineCompletionRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "InlineCompletionOptions" - }, - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ], - "documentation": "Inline completion options used during static or dynamic registration.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "RegistrationParams", - "properties": [ - { - "name": "registrations", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Registration" - } - } - } - ] - }, - { - "name": "UnregistrationParams", - "properties": [ - { - "name": "unregisterations", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Unregistration" - } - } - } - ] - }, - { - "name": "InitializeParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "_InitializeParams" - }, - { - "kind": "reference", - "name": "WorkspaceFoldersInitializeParams" - } - ] - }, - { - "name": "InitializeResult", - "properties": [ - { - "name": "capabilities", - "type": { - "kind": "reference", - "name": "ServerCapabilities" - }, - "documentation": "The capabilities the language server provides." - }, - { - "name": "serverInfo", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "name", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The name of the server as defined by the server." - }, - { - "name": "version", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The server's version as defined by the server." - } - ] - } - }, - "optional": true, - "documentation": "Information about the server.\n\n@since 3.15.0", - "since": "3.15.0" - } - ], - "documentation": "The result returned from an initialize request." - }, - { - "name": "InitializeError", - "properties": [ - { - "name": "retry", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "Indicates whether the client execute the following retry logic:\n(1) show the message provided by the ResponseError to the user\n(2) user selects retry or cancel\n(3) if user selected retry the initialize method is sent again." - } - ], - "documentation": "The data type of the ResponseError if the\ninitialize request fails." - }, - { - "name": "InitializedParams", - "properties": [] - }, - { - "name": "DidChangeConfigurationParams", - "properties": [ - { - "name": "settings", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "documentation": "The actual changed settings" - } - ], - "documentation": "The parameters of a change configuration notification." - }, - { - "name": "DidChangeConfigurationRegistrationOptions", - "properties": [ - { - "name": "section", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - } - ] - }, - "optional": true - } - ] - }, - { - "name": "ShowMessageParams", - "properties": [ - { - "name": "type", - "type": { - "kind": "reference", - "name": "MessageType" - }, - "documentation": "The message type. See {@link MessageType}" - }, - { - "name": "message", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The actual message." - } - ], - "documentation": "The parameters of a notification message." - }, - { - "name": "ShowMessageRequestParams", - "properties": [ - { - "name": "type", - "type": { - "kind": "reference", - "name": "MessageType" - }, - "documentation": "The message type. See {@link MessageType}" - }, - { - "name": "message", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The actual message." - }, - { - "name": "actions", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "MessageActionItem" - } - }, - "optional": true, - "documentation": "The message action items to present." - } - ] - }, - { - "name": "MessageActionItem", - "properties": [ - { - "name": "title", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A short title like 'Retry', 'Open Log' etc." - } - ] - }, - { - "name": "LogMessageParams", - "properties": [ - { - "name": "type", - "type": { - "kind": "reference", - "name": "MessageType" - }, - "documentation": "The message type. See {@link MessageType}" - }, - { - "name": "message", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The actual message." - } - ], - "documentation": "The log message parameters." - }, - { - "name": "DidOpenTextDocumentParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentItem" - }, - "documentation": "The document that was opened." - } - ], - "documentation": "The parameters sent in an open text document notification" - }, - { - "name": "DidChangeTextDocumentParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "VersionedTextDocumentIdentifier" - }, - "documentation": "The document that did change. The version number points\nto the version after all provided content changes have\nbeen applied." - }, - { - "name": "contentChanges", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextDocumentContentChangeEvent" - } - }, - "documentation": "The actual content changes. The content changes describe single state changes\nto the document. So if there are two content changes c1 (at array index 0) and\nc2 (at array index 1) for a document in state S then c1 moves the document from\nS to S' and c2 from S' to S''. So c1 is computed on the state S and c2 is computed\non the state S'.\n\nTo mirror the content of a document using change events use the following approach:\n- start with the same initial content\n- apply the 'textDocument/didChange' notifications in the order you receive them.\n- apply the `TextDocumentContentChangeEvent`s in a single notification in the order\n you receive them." - } - ], - "documentation": "The change text document notification's parameters." - }, - { - "name": "TextDocumentChangeRegistrationOptions", - "properties": [ - { - "name": "syncKind", - "type": { - "kind": "reference", - "name": "TextDocumentSyncKind" - }, - "documentation": "How documents are synced to the server." - } - ], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - } - ], - "documentation": "Describe options to be used when registered for text document change events." - }, - { - "name": "DidCloseTextDocumentParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document that was closed." - } - ], - "documentation": "The parameters sent in a close text document notification" - }, - { - "name": "DidSaveTextDocumentParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document that was saved." - }, - { - "name": "text", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "Optional the content when saved. Depends on the includeText value\nwhen the save notification was requested." - } - ], - "documentation": "The parameters sent in a save text document notification" - }, - { - "name": "TextDocumentSaveRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "SaveOptions" - } - ], - "documentation": "Save registration options." - }, - { - "name": "WillSaveTextDocumentParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document that will be saved." - }, - { - "name": "reason", - "type": { - "kind": "reference", - "name": "TextDocumentSaveReason" - }, - "documentation": "The 'TextDocumentSaveReason'." - } - ], - "documentation": "The parameters sent in a will save text document notification." - }, - { - "name": "TextEdit", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range of the text document to be manipulated. To insert\ntext into a document create a range where start === end." - }, - { - "name": "newText", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The string to be inserted. For delete operations use an\nempty string." - } - ], - "documentation": "A text edit applicable to a text document." - }, - { - "name": "DidChangeWatchedFilesParams", - "properties": [ - { - "name": "changes", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "FileEvent" - } - }, - "documentation": "The actual file events." - } - ], - "documentation": "The watched files change notification's parameters." - }, - { - "name": "DidChangeWatchedFilesRegistrationOptions", - "properties": [ - { - "name": "watchers", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "FileSystemWatcher" - } - }, - "documentation": "The watchers to register." - } - ], - "documentation": "Describe options to be used when registered for text document change events." - }, - { - "name": "PublishDiagnosticsParams", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The URI for which diagnostic information is reported." - }, - { - "name": "version", - "type": { - "kind": "base", - "name": "integer" - }, - "optional": true, - "documentation": "Optional the version number of the document the diagnostics are published for.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "diagnostics", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Diagnostic" - } - }, - "documentation": "An array of diagnostic information items." - } - ], - "documentation": "The publish diagnostic notification's parameters." - }, - { - "name": "CompletionParams", - "properties": [ - { - "name": "context", - "type": { - "kind": "reference", - "name": "CompletionContext" - }, - "optional": true, - "documentation": "The completion context. This is only available it the client specifies\nto send this using the client capability `textDocument.completion.contextSupport === true`" - } - ], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "Completion parameters" - }, - { - "name": "CompletionItem", - "properties": [ - { - "name": "label", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The label of this completion item.\n\nThe label property is also by default the text that\nis inserted when selecting this completion.\n\nIf label details are provided the label itself should\nbe an unqualified name of the completion item." - }, - { - "name": "labelDetails", - "type": { - "kind": "reference", - "name": "CompletionItemLabelDetails" - }, - "optional": true, - "documentation": "Additional details for the label\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "CompletionItemKind" - }, - "optional": true, - "documentation": "The kind of this completion item. Based of the kind\nan icon is chosen by the editor." - }, - { - "name": "tags", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CompletionItemTag" - } - }, - "optional": true, - "documentation": "Tags for this completion item.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "detail", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A human-readable string with additional information\nabout this item, like type or symbol information." - }, - { - "name": "documentation", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "reference", - "name": "MarkupContent" - } - ] - }, - "optional": true, - "documentation": "A human-readable string that represents a doc-comment." - }, - { - "name": "deprecated", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Indicates if this item is deprecated.\n@deprecated Use `tags` instead.", - "deprecated": "Use `tags` instead." - }, - { - "name": "preselect", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Select this item when showing.\n\n*Note* that only one completion item can be selected and that the\ntool / client decides which item that is. The rule is that the *first*\nitem of those that match best is selected." - }, - { - "name": "sortText", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A string that should be used when comparing this item\nwith other items. When `falsy` the {@link CompletionItem.label label}\nis used." - }, - { - "name": "filterText", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A string that should be used when filtering a set of\ncompletion items. When `falsy` the {@link CompletionItem.label label}\nis used." - }, - { - "name": "insertText", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A string that should be inserted into a document when selecting\nthis completion. When `falsy` the {@link CompletionItem.label label}\nis used.\n\nThe `insertText` is subject to interpretation by the client side.\nSome tools might not take the string literally. For example\nVS Code when code complete is requested in this example\n`con` and a completion item with an `insertText` of\n`console` is provided it will only insert `sole`. Therefore it is\nrecommended to use `textEdit` instead since it avoids additional client\nside interpretation." - }, - { - "name": "insertTextFormat", - "type": { - "kind": "reference", - "name": "InsertTextFormat" - }, - "optional": true, - "documentation": "The format of the insert text. The format applies to both the\n`insertText` property and the `newText` property of a provided\n`textEdit`. If omitted defaults to `InsertTextFormat.PlainText`.\n\nPlease note that the insertTextFormat doesn't apply to\n`additionalTextEdits`." - }, - { - "name": "insertTextMode", - "type": { - "kind": "reference", - "name": "InsertTextMode" - }, - "optional": true, - "documentation": "How whitespace and indentation is handled during completion\nitem insertion. If not provided the clients default value depends on\nthe `textDocument.completion.insertTextMode` client capability.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "textEdit", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "TextEdit" - }, - { - "kind": "reference", - "name": "InsertReplaceEdit" - } - ] - }, - "optional": true, - "documentation": "An {@link TextEdit edit} which is applied to a document when selecting\nthis completion. When an edit is provided the value of\n{@link CompletionItem.insertText insertText} is ignored.\n\nMost editors support two different operations when accepting a completion\nitem. One is to insert a completion text and the other is to replace an\nexisting text with a completion text. Since this can usually not be\npredetermined by a server it can report both ranges. Clients need to\nsignal support for `InsertReplaceEdits` via the\n`textDocument.completion.insertReplaceSupport` client capability\nproperty.\n\n*Note 1:* The text edit's range as well as both ranges from an insert\nreplace edit must be a [single line] and they must contain the position\nat which completion has been requested.\n*Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range\nmust be a prefix of the edit's replace range, that means it must be\ncontained and starting at the same position.\n\n@since 3.16.0 additional type `InsertReplaceEdit`", - "since": "3.16.0 additional type `InsertReplaceEdit`" - }, - { - "name": "textEditText", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The edit text used if the completion item is part of a CompletionList and\nCompletionList defines an item default for the text edit range.\n\nClients will only honor this property if they opt into completion list\nitem defaults using the capability `completionList.itemDefaults`.\n\nIf not provided and a list's default range is provided the label\nproperty is used as a text.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "additionalTextEdits", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextEdit" - } - }, - "optional": true, - "documentation": "An optional array of additional {@link TextEdit text edits} that are applied when\nselecting this completion. Edits must not overlap (including the same insert position)\nwith the main {@link CompletionItem.textEdit edit} nor with themselves.\n\nAdditional text edits should be used to change text unrelated to the current cursor position\n(for example adding an import statement at the top of the file if the completion item will\ninsert an unqualified type)." - }, - { - "name": "commitCharacters", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "optional": true, - "documentation": "An optional set of characters that when pressed while this completion is active will accept it first and\nthen type that character. *Note* that all commit characters should have `length=1` and that superfluous\ncharacters will be ignored." - }, - { - "name": "command", - "type": { - "kind": "reference", - "name": "Command" - }, - "optional": true, - "documentation": "An optional {@link Command command} that is executed *after* inserting this completion. *Note* that\nadditional modifications to the current document should be described with the\n{@link CompletionItem.additionalTextEdits additionalTextEdits}-property." - }, - { - "name": "data", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "A data entry field that is preserved on a completion item between a\n{@link CompletionRequest} and a {@link CompletionResolveRequest}." - } - ], - "documentation": "A completion item represents a text snippet that is\nproposed to complete text that is being typed." - }, - { - "name": "CompletionList", - "properties": [ - { - "name": "isIncomplete", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "This list it not complete. Further typing results in recomputing this list.\n\nRecomputed lists have all their items replaced (not appended) in the\nincomplete completion sessions." - }, - { - "name": "itemDefaults", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "commitCharacters", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "optional": true, - "documentation": "A default commit character set.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "editRange", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Range" - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "insert", - "type": { - "kind": "reference", - "name": "Range" - } - }, - { - "name": "replace", - "type": { - "kind": "reference", - "name": "Range" - } - } - ] - } - } - ] - }, - "optional": true, - "documentation": "A default edit range.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "insertTextFormat", - "type": { - "kind": "reference", - "name": "InsertTextFormat" - }, - "optional": true, - "documentation": "A default insert text format.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "insertTextMode", - "type": { - "kind": "reference", - "name": "InsertTextMode" - }, - "optional": true, - "documentation": "A default insert text mode.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "data", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "A default data value.\n\n@since 3.17.0", - "since": "3.17.0" - } - ] - } - }, - "optional": true, - "documentation": "In many cases the items of an actual completion result share the same\nvalue for properties like `commitCharacters` or the range of a text\nedit. A completion list can therefore define item defaults which will\nbe used if a completion item itself doesn't specify the value.\n\nIf a completion list specifies a default value and a completion item\nalso specifies a corresponding value the one from the item is used.\n\nServers are only allowed to return default values if the client\nsignals support for this via the `completionList.itemDefaults`\ncapability.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "items", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CompletionItem" - } - }, - "documentation": "The completion items." - } - ], - "documentation": "Represents a collection of {@link CompletionItem completion items} to be presented\nin the editor." - }, - { - "name": "CompletionRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "CompletionOptions" - } - ], - "documentation": "Registration options for a {@link CompletionRequest}." - }, - { - "name": "HoverParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "Parameters for a {@link HoverRequest}." - }, - { - "name": "Hover", - "properties": [ - { - "name": "contents", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "MarkupContent" - }, - { - "kind": "reference", - "name": "MarkedString" - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "MarkedString" - } - } - ] - }, - "documentation": "The hover's content" - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "optional": true, - "documentation": "An optional range inside the text document that is used to\nvisualize the hover, e.g. by changing the background color." - } - ], - "documentation": "The result of a hover request." - }, - { - "name": "HoverRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "HoverOptions" - } - ], - "documentation": "Registration options for a {@link HoverRequest}." - }, - { - "name": "SignatureHelpParams", - "properties": [ - { - "name": "context", - "type": { - "kind": "reference", - "name": "SignatureHelpContext" - }, - "optional": true, - "documentation": "The signature help context. This is only available if the client specifies\nto send this using the client capability `textDocument.signatureHelp.contextSupport === true`\n\n@since 3.15.0", - "since": "3.15.0" - } - ], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "Parameters for a {@link SignatureHelpRequest}." - }, - { - "name": "SignatureHelp", - "properties": [ - { - "name": "signatures", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SignatureInformation" - } - }, - "documentation": "One or more signatures." - }, - { - "name": "activeSignature", - "type": { - "kind": "base", - "name": "uinteger" - }, - "optional": true, - "documentation": "The active signature. If omitted or the value lies outside the\nrange of `signatures` the value defaults to zero or is ignored if\nthe `SignatureHelp` has no signatures.\n\nWhenever possible implementors should make an active decision about\nthe active signature and shouldn't rely on a default value.\n\nIn future version of the protocol this property might become\nmandatory to better express this." - }, - { - "name": "activeParameter", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "uinteger" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "optional": true, - "documentation": "The active parameter of the active signature.\n\nIf `null`, no parameter of the signature is active (for example a named\nargument that does not match any declared parameters). This is only valid\nsince 3.18.0 and if the client specifies the client capability\n`textDocument.signatureHelp.noActiveParameterSupport === true`\n\nIf omitted or the value lies outside the range of\n`signatures[activeSignature].parameters` defaults to 0 if the active\nsignature has parameters.\n\nIf the active signature has no parameters it is ignored.\n\nIn future version of the protocol this property might become\nmandatory (but still nullable) to better express the active parameter if\nthe active signature does have any." - } - ], - "documentation": "Signature help represents the signature of something\ncallable. There can be multiple signature but only one\nactive and only one active parameter." - }, - { - "name": "SignatureHelpRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "SignatureHelpOptions" - } - ], - "documentation": "Registration options for a {@link SignatureHelpRequest}." - }, - { - "name": "DefinitionParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "Parameters for a {@link DefinitionRequest}." - }, - { - "name": "DefinitionRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "DefinitionOptions" - } - ], - "documentation": "Registration options for a {@link DefinitionRequest}." - }, - { - "name": "ReferenceParams", - "properties": [ - { - "name": "context", - "type": { - "kind": "reference", - "name": "ReferenceContext" - } - } - ], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "Parameters for a {@link ReferencesRequest}." - }, - { - "name": "ReferenceRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "ReferenceOptions" - } - ], - "documentation": "Registration options for a {@link ReferencesRequest}." - }, - { - "name": "DocumentHighlightParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "Parameters for a {@link DocumentHighlightRequest}." - }, - { - "name": "DocumentHighlight", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range this highlight applies to." - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "DocumentHighlightKind" - }, - "optional": true, - "documentation": "The highlight kind, default is {@link DocumentHighlightKind.Text text}." - } - ], - "documentation": "A document highlight is a range inside a text document which deserves\nspecial attention. Usually a document highlight is visualized by changing\nthe background color of its range." - }, - { - "name": "DocumentHighlightRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "DocumentHighlightOptions" - } - ], - "documentation": "Registration options for a {@link DocumentHighlightRequest}." - }, - { - "name": "DocumentSymbolParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "Parameters for a {@link DocumentSymbolRequest}." - }, - { - "name": "SymbolInformation", - "properties": [ - { - "name": "deprecated", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Indicates if this symbol is deprecated.\n\n@deprecated Use tags instead", - "deprecated": "Use tags instead" - }, - { - "name": "location", - "type": { - "kind": "reference", - "name": "Location" - }, - "documentation": "The location of this symbol. The location's range is used by a tool\nto reveal the location in the editor. If the symbol is selected in the\ntool the range's start information is used to position the cursor. So\nthe range usually spans more than the actual symbol's name and does\nnormally include things like visibility modifiers.\n\nThe range doesn't have to denote a node range in the sense of an abstract\nsyntax tree. It can therefore not be used to re-construct a hierarchy of\nthe symbols." - } - ], - "extends": [ - { - "kind": "reference", - "name": "BaseSymbolInformation" - } - ], - "documentation": "Represents information about programming constructs like variables, classes,\ninterfaces etc." - }, - { - "name": "DocumentSymbol", - "properties": [ - { - "name": "name", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The name of this symbol. Will be displayed in the user interface and therefore must not be\nan empty string or a string only consisting of white spaces." - }, - { - "name": "detail", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "More detail for this symbol, e.g the signature of a function." - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "SymbolKind" - }, - "documentation": "The kind of this symbol." - }, - { - "name": "tags", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolTag" - } - }, - "optional": true, - "documentation": "Tags for this document symbol.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "deprecated", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Indicates if this symbol is deprecated.\n\n@deprecated Use tags instead", - "deprecated": "Use tags instead" - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range enclosing this symbol not including leading/trailing whitespace but everything else\nlike comments. This information is typically used to determine if the clients cursor is\ninside the symbol to reveal in the symbol in the UI." - }, - { - "name": "selectionRange", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.\nMust be contained by the `range`." - }, - { - "name": "children", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "DocumentSymbol" - } - }, - "optional": true, - "documentation": "Children of this symbol, e.g. properties of a class." - } - ], - "documentation": "Represents programming constructs like variables, classes, interfaces etc.\nthat appear in a document. Document symbols can be hierarchical and they\nhave two ranges: one that encloses its definition and one that points to\nits most interesting range, e.g. the range of an identifier." - }, - { - "name": "DocumentSymbolRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "DocumentSymbolOptions" - } - ], - "documentation": "Registration options for a {@link DocumentSymbolRequest}." - }, - { - "name": "CodeActionParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document in which the command was invoked." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range for which the command was invoked." - }, - { - "name": "context", - "type": { - "kind": "reference", - "name": "CodeActionContext" - }, - "documentation": "Context carrying additional information." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "The parameters of a {@link CodeActionRequest}." - }, - { - "name": "Command", - "properties": [ - { - "name": "title", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "Title of the command, like `save`." - }, - { - "name": "command", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The identifier of the actual command handler." - }, - { - "name": "arguments", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "LSPAny" - } - }, - "optional": true, - "documentation": "Arguments that the command handler should be\ninvoked with." - } - ], - "documentation": "Represents a reference to a command. Provides a title which\nwill be used to represent a command in the UI and, optionally,\nan array of arguments which will be passed to the command handler\nfunction when invoked." - }, - { - "name": "CodeAction", - "properties": [ - { - "name": "title", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A short, human-readable, title for this code action." - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "CodeActionKind" - }, - "optional": true, - "documentation": "The kind of the code action.\n\nUsed to filter code actions." - }, - { - "name": "diagnostics", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Diagnostic" - } - }, - "optional": true, - "documentation": "The diagnostics that this code action resolves." - }, - { - "name": "isPreferred", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted\nby keybindings.\n\nA quick fix should be marked preferred if it properly addresses the underlying error.\nA refactoring should be marked preferred if it is the most reasonable choice of actions to take.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "disabled", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "reason", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "Human readable description of why the code action is currently disabled.\n\nThis is displayed in the code actions UI." - } - ] - } - }, - "optional": true, - "documentation": "Marks that the code action cannot currently be applied.\n\nClients should follow the following guidelines regarding disabled code actions:\n\n - Disabled code actions are not shown in automatic [lightbulbs](https://code.visualstudio.com/docs/editor/editingevolved#_code-action)\n code action menus.\n\n - Disabled actions are shown as faded out in the code action menu when the user requests a more specific type\n of code action, such as refactorings.\n\n - If the user has a [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions)\n that auto applies a code action and only disabled code actions are returned, the client should show the user an\n error message with `reason` in the editor.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "edit", - "type": { - "kind": "reference", - "name": "WorkspaceEdit" - }, - "optional": true, - "documentation": "The workspace edit this code action performs." - }, - { - "name": "command", - "type": { - "kind": "reference", - "name": "Command" - }, - "optional": true, - "documentation": "A command this code action executes. If a code action\nprovides an edit and a command, first the edit is\nexecuted and then the command." - }, - { - "name": "data", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "A data entry field that is preserved on a code action between\na `textDocument/codeAction` and a `codeAction/resolve` request.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "documentation": "A code action represents a change that can be performed in code, e.g. to fix a problem or\nto refactor code.\n\nA CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed." - }, - { - "name": "CodeActionRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "CodeActionOptions" - } - ], - "documentation": "Registration options for a {@link CodeActionRequest}." - }, - { - "name": "WorkspaceSymbolParams", - "properties": [ - { - "name": "query", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A query string to filter symbols by. Clients may send an empty\nstring here to request all symbols." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "The parameters of a {@link WorkspaceSymbolRequest}." - }, - { - "name": "WorkspaceSymbol", - "properties": [ - { - "name": "location", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Location" - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - } - } - ] - } - } - ] - }, - "documentation": "The location of the symbol. Whether a server is allowed to\nreturn a location without a range depends on the client\ncapability `workspace.symbol.resolveSupport`.\n\nSee SymbolInformation#location for more details." - }, - { - "name": "data", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "A data entry field that is preserved on a workspace symbol between a\nworkspace symbol request and a workspace symbol resolve request." - } - ], - "extends": [ - { - "kind": "reference", - "name": "BaseSymbolInformation" - } - ], - "documentation": "A special workspace symbol that supports locations without a range.\n\nSee also SymbolInformation.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "WorkspaceSymbolRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "WorkspaceSymbolOptions" - } - ], - "documentation": "Registration options for a {@link WorkspaceSymbolRequest}." - }, - { - "name": "CodeLensParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document to request code lens for." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "The parameters of a {@link CodeLensRequest}." - }, - { - "name": "CodeLens", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range in which this code lens is valid. Should only span a single line." - }, - { - "name": "command", - "type": { - "kind": "reference", - "name": "Command" - }, - "optional": true, - "documentation": "The command this code lens represents." - }, - { - "name": "data", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "A data entry field that is preserved on a code lens item between\na {@link CodeLensRequest} and a {@link CodeLensResolveRequest}" - } - ], - "documentation": "A code lens represents a {@link Command command} that should be shown along with\nsource text, like the number of references, a way to run tests, etc.\n\nA code lens is _unresolved_ when no command is associated to it. For performance\nreasons the creation of a code lens and resolving should be done in two stages." - }, - { - "name": "CodeLensRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "CodeLensOptions" - } - ], - "documentation": "Registration options for a {@link CodeLensRequest}." - }, - { - "name": "DocumentLinkParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document to provide document links for." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - }, - { - "kind": "reference", - "name": "PartialResultParams" - } - ], - "documentation": "The parameters of a {@link DocumentLinkRequest}." - }, - { - "name": "DocumentLink", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range this link applies to." - }, - { - "name": "target", - "type": { - "kind": "base", - "name": "URI" - }, - "optional": true, - "documentation": "The uri this link points to. If missing a resolve request is sent later." - }, - { - "name": "tooltip", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The tooltip text when you hover over this link.\n\nIf a tooltip is provided, is will be displayed in a string that includes instructions on how to\ntrigger the link, such as `{0} (ctrl + click)`. The specific instructions vary depending on OS,\nuser settings, and localization.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "data", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "A data entry field that is preserved on a document link between a\nDocumentLinkRequest and a DocumentLinkResolveRequest." - } - ], - "documentation": "A document link is a range in a text document that links to an internal or external resource, like another\ntext document or a web site." - }, - { - "name": "DocumentLinkRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "DocumentLinkOptions" - } - ], - "documentation": "Registration options for a {@link DocumentLinkRequest}." - }, - { - "name": "DocumentFormattingParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document to format." - }, - { - "name": "options", - "type": { - "kind": "reference", - "name": "FormattingOptions" - }, - "documentation": "The format options." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "The parameters of a {@link DocumentFormattingRequest}." - }, - { - "name": "DocumentFormattingRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "DocumentFormattingOptions" - } - ], - "documentation": "Registration options for a {@link DocumentFormattingRequest}." - }, - { - "name": "DocumentRangeFormattingParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document to format." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range to format" - }, - { - "name": "options", - "type": { - "kind": "reference", - "name": "FormattingOptions" - }, - "documentation": "The format options" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "The parameters of a {@link DocumentRangeFormattingRequest}." - }, - { - "name": "DocumentRangeFormattingRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "DocumentRangeFormattingOptions" - } - ], - "documentation": "Registration options for a {@link DocumentRangeFormattingRequest}." - }, - { - "name": "DocumentRangesFormattingParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document to format." - }, - { - "name": "ranges", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Range" - } - }, - "documentation": "The ranges to format" - }, - { - "name": "options", - "type": { - "kind": "reference", - "name": "FormattingOptions" - }, - "documentation": "The format options" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "The parameters of a {@link DocumentRangesFormattingRequest}.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "DocumentOnTypeFormattingParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document to format." - }, - { - "name": "position", - "type": { - "kind": "reference", - "name": "Position" - }, - "documentation": "The position around which the on type formatting should happen.\nThis is not necessarily the exact position where the character denoted\nby the property `ch` got typed." - }, - { - "name": "ch", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The character that has been typed that triggered the formatting\non type request. That is not necessarily the last character that\ngot inserted into the document since the client could auto insert\ncharacters as well (e.g. like automatic brace completion)." - }, - { - "name": "options", - "type": { - "kind": "reference", - "name": "FormattingOptions" - }, - "documentation": "The formatting options." - } - ], - "documentation": "The parameters of a {@link DocumentOnTypeFormattingRequest}." - }, - { - "name": "DocumentOnTypeFormattingRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "DocumentOnTypeFormattingOptions" - } - ], - "documentation": "Registration options for a {@link DocumentOnTypeFormattingRequest}." - }, - { - "name": "RenameParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The document to rename." - }, - { - "name": "position", - "type": { - "kind": "reference", - "name": "Position" - }, - "documentation": "The position at which this request was sent." - }, - { - "name": "newName", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The new name of the symbol. If the given name is not valid the\nrequest must return a {@link ResponseError} with an\nappropriate message set." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "The parameters of a {@link RenameRequest}." - }, - { - "name": "RenameRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "RenameOptions" - } - ], - "documentation": "Registration options for a {@link RenameRequest}." - }, - { - "name": "PrepareRenameParams", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ] - }, - { - "name": "ExecuteCommandParams", - "properties": [ - { - "name": "command", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The identifier of the actual command handler." - }, - { - "name": "arguments", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "LSPAny" - } - }, - "optional": true, - "documentation": "Arguments that the command should be invoked with." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "The parameters of a {@link ExecuteCommandRequest}." - }, - { - "name": "ExecuteCommandRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "ExecuteCommandOptions" - } - ], - "documentation": "Registration options for a {@link ExecuteCommandRequest}." - }, - { - "name": "ApplyWorkspaceEditParams", - "properties": [ - { - "name": "label", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "An optional label of the workspace edit. This label is\npresented in the user interface for example on an undo\nstack to undo the workspace edit." - }, - { - "name": "edit", - "type": { - "kind": "reference", - "name": "WorkspaceEdit" - }, - "documentation": "The edits to apply." - } - ], - "documentation": "The parameters passed via an apply workspace edit request." - }, - { - "name": "ApplyWorkspaceEditResult", - "properties": [ - { - "name": "applied", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "Indicates whether the edit was applied or not." - }, - { - "name": "failureReason", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "An optional textual description for why the edit was not applied.\nThis may be used by the server for diagnostic logging or to provide\na suitable error for a request that triggered the edit." - }, - { - "name": "failedChange", - "type": { - "kind": "base", - "name": "uinteger" - }, - "optional": true, - "documentation": "Depending on the client's failure handling strategy `failedChange` might\ncontain the index of the change that failed. This property is only available\nif the client signals a `failureHandlingStrategy` in its client capabilities." - } - ], - "documentation": "The result returned from the apply workspace edit request.\n\n@since 3.17 renamed from ApplyWorkspaceEditResponse", - "since": "3.17 renamed from ApplyWorkspaceEditResponse" - }, - { - "name": "WorkDoneProgressBegin", - "properties": [ - { - "name": "kind", - "type": { - "kind": "stringLiteral", - "value": "begin" - } - }, - { - "name": "title", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "Mandatory title of the progress operation. Used to briefly inform about\nthe kind of operation being performed.\n\nExamples: \"Indexing\" or \"Linking dependencies\"." - }, - { - "name": "cancellable", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Controls if a cancel button should show to allow the user to cancel the\nlong running operation. Clients that don't support cancellation are allowed\nto ignore the setting." - }, - { - "name": "message", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "Optional, more detailed associated progress message. Contains\ncomplementary information to the `title`.\n\nExamples: \"3/25 files\", \"project/src/module2\", \"node_modules/some_dep\".\nIf unset, the previous progress message (if any) is still valid." - }, - { - "name": "percentage", - "type": { - "kind": "base", - "name": "uinteger" - }, - "optional": true, - "documentation": "Optional progress percentage to display (value 100 is considered 100%).\nIf not provided infinite progress is assumed and clients are allowed\nto ignore the `percentage` value in subsequent in report notifications.\n\nThe value should be steadily rising. Clients are free to ignore values\nthat are not following this rule. The value range is [0, 100]." - } - ] - }, - { - "name": "WorkDoneProgressReport", - "properties": [ - { - "name": "kind", - "type": { - "kind": "stringLiteral", - "value": "report" - } - }, - { - "name": "cancellable", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Controls enablement state of a cancel button.\n\nClients that don't support cancellation or don't support controlling the button's\nenablement state are allowed to ignore the property." - }, - { - "name": "message", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "Optional, more detailed associated progress message. Contains\ncomplementary information to the `title`.\n\nExamples: \"3/25 files\", \"project/src/module2\", \"node_modules/some_dep\".\nIf unset, the previous progress message (if any) is still valid." - }, - { - "name": "percentage", - "type": { - "kind": "base", - "name": "uinteger" - }, - "optional": true, - "documentation": "Optional progress percentage to display (value 100 is considered 100%).\nIf not provided infinite progress is assumed and clients are allowed\nto ignore the `percentage` value in subsequent in report notifications.\n\nThe value should be steadily rising. Clients are free to ignore values\nthat are not following this rule. The value range is [0, 100]" - } - ] - }, - { - "name": "WorkDoneProgressEnd", - "properties": [ - { - "name": "kind", - "type": { - "kind": "stringLiteral", - "value": "end" - } - }, - { - "name": "message", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "Optional, a final message indicating to for example indicate the outcome\nof the operation." - } - ] - }, - { - "name": "SetTraceParams", - "properties": [ - { - "name": "value", - "type": { - "kind": "reference", - "name": "TraceValues" - } - } - ] - }, - { - "name": "LogTraceParams", - "properties": [ - { - "name": "message", - "type": { - "kind": "base", - "name": "string" - } - }, - { - "name": "verbose", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true - } - ] - }, - { - "name": "CancelParams", - "properties": [ - { - "name": "id", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "integer" - }, - { - "kind": "base", - "name": "string" - } - ] - }, - "documentation": "The request id to cancel." - } - ] - }, - { - "name": "ProgressParams", - "properties": [ - { - "name": "token", - "type": { - "kind": "reference", - "name": "ProgressToken" - }, - "documentation": "The progress token provided by the client or server." - }, - { - "name": "value", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "documentation": "The progress data." - } - ] - }, - { - "name": "TextDocumentPositionParams", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentIdentifier" - }, - "documentation": "The text document." - }, - { - "name": "position", - "type": { - "kind": "reference", - "name": "Position" - }, - "documentation": "The position inside the text document." - } - ], - "documentation": "A parameter literal used in requests to pass a text document and a position inside that\ndocument." - }, - { - "name": "WorkDoneProgressParams", - "properties": [ - { - "name": "workDoneToken", - "type": { - "kind": "reference", - "name": "ProgressToken" - }, - "optional": true, - "documentation": "An optional token that a server can use to report work done progress." - } - ] - }, - { - "name": "PartialResultParams", - "properties": [ - { - "name": "partialResultToken", - "type": { - "kind": "reference", - "name": "ProgressToken" - }, - "optional": true, - "documentation": "An optional token that a server can use to report partial results (e.g. streaming) to\nthe client." - } - ] - }, - { - "name": "LocationLink", - "properties": [ - { - "name": "originSelectionRange", - "type": { - "kind": "reference", - "name": "Range" - }, - "optional": true, - "documentation": "Span of the origin of this link.\n\nUsed as the underlined span for mouse interaction. Defaults to the word range at\nthe definition position." - }, - { - "name": "targetUri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The target resource identifier of this link." - }, - { - "name": "targetRange", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The full target range of this link. If the target for example is a symbol then target range is the\nrange enclosing this symbol not including leading/trailing whitespace but everything else\nlike comments. This information is typically used to highlight the range in the editor." - }, - { - "name": "targetSelectionRange", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range that should be selected and revealed when this link is being followed, e.g the name of a function.\nMust be contained by the `targetRange`. See also `DocumentSymbol#range`" - } - ], - "documentation": "Represents the connection of two locations. Provides additional metadata over normal {@link Location locations},\nincluding an origin range." - }, - { - "name": "Range", - "properties": [ - { - "name": "start", - "type": { - "kind": "reference", - "name": "Position" - }, - "documentation": "The range's start position." - }, - { - "name": "end", - "type": { - "kind": "reference", - "name": "Position" - }, - "documentation": "The range's end position." - } - ], - "documentation": "A range in a text document expressed as (zero-based) start and end positions.\n\nIf you want to specify a range that contains a line including the line ending\ncharacter(s) then use an end position denoting the start of the next line.\nFor example:\n```ts\n{\n start: { line: 5, character: 23 }\n end : { line 6, character : 0 }\n}\n```" - }, - { - "name": "ImplementationOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ] - }, - { - "name": "StaticRegistrationOptions", - "properties": [ - { - "name": "id", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The id used to register the request. The id can be used to deregister\nthe request again. See also Registration#id." - } - ], - "documentation": "Static registration options to be returned in the initialize\nrequest." - }, - { - "name": "TypeDefinitionOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ] - }, - { - "name": "WorkspaceFoldersChangeEvent", - "properties": [ - { - "name": "added", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "WorkspaceFolder" - } - }, - "documentation": "The array of added workspace folders" - }, - { - "name": "removed", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "WorkspaceFolder" - } - }, - "documentation": "The array of the removed workspace folders" - } - ], - "documentation": "The workspace folder change event." - }, - { - "name": "ConfigurationItem", - "properties": [ - { - "name": "scopeUri", - "type": { - "kind": "base", - "name": "URI" - }, - "optional": true, - "documentation": "The scope to get the configuration section for." - }, - { - "name": "section", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The configuration section asked for." - } - ] - }, - { - "name": "TextDocumentIdentifier", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The text document's uri." - } - ], - "documentation": "A literal to identify a text document in the client." - }, - { - "name": "Color", - "properties": [ - { - "name": "red", - "type": { - "kind": "base", - "name": "decimal" - }, - "documentation": "The red component of this color in the range [0-1]." - }, - { - "name": "green", - "type": { - "kind": "base", - "name": "decimal" - }, - "documentation": "The green component of this color in the range [0-1]." - }, - { - "name": "blue", - "type": { - "kind": "base", - "name": "decimal" - }, - "documentation": "The blue component of this color in the range [0-1]." - }, - { - "name": "alpha", - "type": { - "kind": "base", - "name": "decimal" - }, - "documentation": "The alpha component of this color in the range [0-1]." - } - ], - "documentation": "Represents a color in RGBA space." - }, - { - "name": "DocumentColorOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ] - }, - { - "name": "FoldingRangeOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ] - }, - { - "name": "DeclarationOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ] - }, - { - "name": "Position", - "properties": [ - { - "name": "line", - "type": { - "kind": "base", - "name": "uinteger" - }, - "documentation": "Line position in a document (zero-based).\n\nIf a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document.\nIf a line number is negative, it defaults to 0." - }, - { - "name": "character", - "type": { - "kind": "base", - "name": "uinteger" - }, - "documentation": "Character offset on a line in a document (zero-based).\n\nThe meaning of this offset is determined by the negotiated\n`PositionEncodingKind`.\n\nIf the character value is greater than the line length it defaults back to the\nline length." - } - ], - "documentation": "Position in a text document expressed as zero-based line and character\noffset. Prior to 3.17 the offsets were always based on a UTF-16 string\nrepresentation. So a string of the form `a𐐀b` the character offset of the\ncharacter `a` is 0, the character offset of `𐐀` is 1 and the character\noffset of b is 3 since `𐐀` is represented using two code units in UTF-16.\nSince 3.17 clients and servers can agree on a different string encoding\nrepresentation (e.g. UTF-8). The client announces it's supported encoding\nvia the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities).\nThe value is an array of position encodings the client supports, with\ndecreasing preference (e.g. the encoding at index `0` is the most preferred\none). To stay backwards compatible the only mandatory encoding is UTF-16\nrepresented via the string `utf-16`. The server can pick one of the\nencodings offered by the client and signals that encoding back to the\nclient via the initialize result's property\n[`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value\n`utf-16` is missing from the client's capability `general.positionEncodings`\nservers can safely assume that the client supports UTF-16. If the server\nomits the position encoding in its initialize result the encoding defaults\nto the string value `utf-16`. Implementation considerations: since the\nconversion from one encoding into another requires the content of the\nfile / line the conversion is best done where the file is read which is\nusually on the server side.\n\nPositions are line end character agnostic. So you can not specify a position\nthat denotes `\\r|\\n` or `\\n|` where `|` represents the character offset.\n\n@since 3.17.0 - support for negotiated position encoding.", - "since": "3.17.0 - support for negotiated position encoding." - }, - { - "name": "SelectionRangeOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ] - }, - { - "name": "CallHierarchyOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Call hierarchy options used during static registration.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokensOptions", - "properties": [ - { - "name": "legend", - "type": { - "kind": "reference", - "name": "SemanticTokensLegend" - }, - "documentation": "The legend used by the server" - }, - { - "name": "range", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "literal", - "value": { - "properties": [] - } - } - ] - }, - "optional": true, - "documentation": "Server supports providing semantic tokens for a specific range\nof a document." - }, - { - "name": "full", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "delta", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The server supports deltas for full documents." - } - ] - } - } - ] - }, - "optional": true, - "documentation": "Server supports providing semantic tokens for a full document." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokensEdit", - "properties": [ - { - "name": "start", - "type": { - "kind": "base", - "name": "uinteger" - }, - "documentation": "The start offset of the edit." - }, - { - "name": "deleteCount", - "type": { - "kind": "base", - "name": "uinteger" - }, - "documentation": "The count of elements to remove." - }, - { - "name": "data", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "uinteger" - } - }, - "optional": true, - "documentation": "The elements to insert." - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "LinkedEditingRangeOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ] - }, - { - "name": "FileCreate", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A file:// URI for the location of the file/folder being created." - } - ], - "documentation": "Represents information on a file/folder create.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "TextDocumentEdit", - "properties": [ - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "OptionalVersionedTextDocumentIdentifier" - }, - "documentation": "The text document to change." - }, - { - "name": "edits", - "type": { - "kind": "array", - "element": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "TextEdit" - }, - { - "kind": "reference", - "name": "AnnotatedTextEdit" - } - ] - } - }, - "documentation": "The edits to be applied.\n\n@since 3.16.0 - support for AnnotatedTextEdit. This is guarded using a\nclient capability.", - "since": "3.16.0 - support for AnnotatedTextEdit. This is guarded using a\nclient capability." - } - ], - "documentation": "Describes textual changes on a text document. A TextDocumentEdit describes all changes\non a document version Si and after they are applied move the document to version Si+1.\nSo the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any\nkind of ordering. However the edits must be non overlapping." - }, - { - "name": "CreateFile", - "properties": [ - { - "name": "kind", - "type": { - "kind": "stringLiteral", - "value": "create" - }, - "documentation": "A create" - }, - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The resource to create." - }, - { - "name": "options", - "type": { - "kind": "reference", - "name": "CreateFileOptions" - }, - "optional": true, - "documentation": "Additional options" - } - ], - "extends": [ - { - "kind": "reference", - "name": "ResourceOperation" - } - ], - "documentation": "Create file operation." - }, - { - "name": "RenameFile", - "properties": [ - { - "name": "kind", - "type": { - "kind": "stringLiteral", - "value": "rename" - }, - "documentation": "A rename" - }, - { - "name": "oldUri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The old (existing) location." - }, - { - "name": "newUri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The new location." - }, - { - "name": "options", - "type": { - "kind": "reference", - "name": "RenameFileOptions" - }, - "optional": true, - "documentation": "Rename options." - } - ], - "extends": [ - { - "kind": "reference", - "name": "ResourceOperation" - } - ], - "documentation": "Rename file operation" - }, - { - "name": "DeleteFile", - "properties": [ - { - "name": "kind", - "type": { - "kind": "stringLiteral", - "value": "delete" - }, - "documentation": "A delete" - }, - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The file to delete." - }, - { - "name": "options", - "type": { - "kind": "reference", - "name": "DeleteFileOptions" - }, - "optional": true, - "documentation": "Delete options." - } - ], - "extends": [ - { - "kind": "reference", - "name": "ResourceOperation" - } - ], - "documentation": "Delete file operation" - }, - { - "name": "ChangeAnnotation", - "properties": [ - { - "name": "label", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A human-readable string describing the actual change. The string\nis rendered prominent in the user interface." - }, - { - "name": "needsConfirmation", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "A flag which indicates that user confirmation is needed\nbefore applying the change." - }, - { - "name": "description", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A human-readable string which is rendered less prominent in\nthe user interface." - } - ], - "documentation": "Additional information that describes document changes.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "FileOperationFilter", - "properties": [ - { - "name": "scheme", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A Uri scheme like `file` or `untitled`." - }, - { - "name": "pattern", - "type": { - "kind": "reference", - "name": "FileOperationPattern" - }, - "documentation": "The actual file operation pattern." - } - ], - "documentation": "A filter to describe in which file operation requests or notifications\nthe server is interested in receiving.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "FileRename", - "properties": [ - { - "name": "oldUri", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A file:// URI for the original location of the file/folder being renamed." - }, - { - "name": "newUri", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A file:// URI for the new location of the file/folder being renamed." - } - ], - "documentation": "Represents information on a file/folder rename.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "FileDelete", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A file:// URI for the location of the file/folder being deleted." - } - ], - "documentation": "Represents information on a file/folder delete.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "MonikerOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ] - }, - { - "name": "TypeHierarchyOptions", - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "properties": [], - "documentation": "Type hierarchy options used during static registration.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineValueContext", - "properties": [ - { - "name": "frameId", - "type": { - "kind": "base", - "name": "integer" - }, - "documentation": "The stack frame (as a DAP Id) where the execution has stopped." - }, - { - "name": "stoppedLocation", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The document range where execution has stopped.\nTypically the end position of the range denotes the line where the inline values are shown." - } - ], - "documentation": "@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineValueText", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The document range for which the inline value applies." - }, - { - "name": "text", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The text of the inline value." - } - ], - "documentation": "Provide inline value as text.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineValueVariableLookup", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The document range for which the inline value applies.\nThe range is used to extract the variable name from the underlying document." - }, - { - "name": "variableName", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "If specified the name of the variable to look up." - }, - { - "name": "caseSensitiveLookup", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "How to perform the lookup." - } - ], - "documentation": "Provide inline value through a variable lookup.\nIf only a range is specified, the variable name will be extracted from the underlying document.\nAn optional variable name can be used to override the extracted name.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineValueEvaluatableExpression", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The document range for which the inline value applies.\nThe range is used to extract the evaluatable expression from the underlying document." - }, - { - "name": "expression", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "If specified the expression overrides the extracted expression." - } - ], - "documentation": "Provide an inline value through an expression evaluation.\nIf only a range is specified, the expression will be extracted from the underlying document.\nAn optional expression can be used to override the extracted expression.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineValueOptions", - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "properties": [], - "documentation": "Inline value options used during static registration.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlayHintLabelPart", - "properties": [ - { - "name": "value", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The value of this label part." - }, - { - "name": "tooltip", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "reference", - "name": "MarkupContent" - } - ] - }, - "optional": true, - "documentation": "The tooltip text when you hover over this label part. Depending on\nthe client capability `inlayHint.resolveSupport` clients might resolve\nthis property late using the resolve request." - }, - { - "name": "location", - "type": { - "kind": "reference", - "name": "Location" - }, - "optional": true, - "documentation": "An optional source code location that represents this\nlabel part.\n\nThe editor will use this location for the hover and for code navigation\nfeatures: This part will become a clickable link that resolves to the\ndefinition of the symbol at the given location (not necessarily the\nlocation itself), it shows the hover that shows at the given location,\nand it shows a context menu with further code navigation commands.\n\nDepending on the client capability `inlayHint.resolveSupport` clients\nmight resolve this property late using the resolve request." - }, - { - "name": "command", - "type": { - "kind": "reference", - "name": "Command" - }, - "optional": true, - "documentation": "An optional command for this label part.\n\nDepending on the client capability `inlayHint.resolveSupport` clients\nmight resolve this property late using the resolve request." - } - ], - "documentation": "An inlay hint label part allows for interactive and composite labels\nof inlay hints.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "MarkupContent", - "properties": [ - { - "name": "kind", - "type": { - "kind": "reference", - "name": "MarkupKind" - }, - "documentation": "The type of the Markup" - }, - { - "name": "value", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The content itself" - } - ], - "documentation": "A `MarkupContent` literal represents a string value which content is interpreted base on its\nkind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds.\n\nIf the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues.\nSee https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting\n\nHere is an example how such a string can be constructed using JavaScript / TypeScript:\n```ts\nlet markdown: MarkdownContent = {\n kind: MarkupKind.Markdown,\n value: [\n '# Header',\n 'Some text',\n '```typescript',\n 'someCode();',\n '```'\n ].join('\\n')\n};\n```\n\n*Please Note* that clients might sanitize the return markdown. A client could decide to\nremove HTML from the markdown to avoid script execution." - }, - { - "name": "InlayHintOptions", - "properties": [ - { - "name": "resolveProvider", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The server provides support to resolve additional\ninformation for an inlay hint item." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Inlay hint options used during static registration.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "RelatedFullDocumentDiagnosticReport", - "properties": [ - { - "name": "relatedDocuments", - "type": { - "kind": "map", - "key": { - "kind": "base", - "name": "DocumentUri" - }, - "value": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "FullDocumentDiagnosticReport" - }, - { - "kind": "reference", - "name": "UnchangedDocumentDiagnosticReport" - } - ] - } - }, - "optional": true, - "documentation": "Diagnostics of related documents. This information is useful\nin programming languages where code in a file A can generate\ndiagnostics in a file B which A depends on. An example of\nsuch a language is C/C++ where marco definitions in a file\na.cpp and result in errors in a header file b.hpp.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "extends": [ - { - "kind": "reference", - "name": "FullDocumentDiagnosticReport" - } - ], - "documentation": "A full diagnostic report with a set of related documents.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "RelatedUnchangedDocumentDiagnosticReport", - "properties": [ - { - "name": "relatedDocuments", - "type": { - "kind": "map", - "key": { - "kind": "base", - "name": "DocumentUri" - }, - "value": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "FullDocumentDiagnosticReport" - }, - { - "kind": "reference", - "name": "UnchangedDocumentDiagnosticReport" - } - ] - } - }, - "optional": true, - "documentation": "Diagnostics of related documents. This information is useful\nin programming languages where code in a file A can generate\ndiagnostics in a file B which A depends on. An example of\nsuch a language is C/C++ where marco definitions in a file\na.cpp and result in errors in a header file b.hpp.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "extends": [ - { - "kind": "reference", - "name": "UnchangedDocumentDiagnosticReport" - } - ], - "documentation": "An unchanged diagnostic report with a set of related documents.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "FullDocumentDiagnosticReport", - "properties": [ - { - "name": "kind", - "type": { - "kind": "stringLiteral", - "value": "full" - }, - "documentation": "A full document diagnostic report." - }, - { - "name": "resultId", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "An optional result id. If provided it will\nbe sent on the next diagnostic request for the\nsame document." - }, - { - "name": "items", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Diagnostic" - } - }, - "documentation": "The actual items." - } - ], - "documentation": "A diagnostic report with a full set of problems.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "UnchangedDocumentDiagnosticReport", - "properties": [ - { - "name": "kind", - "type": { - "kind": "stringLiteral", - "value": "unchanged" - }, - "documentation": "A document diagnostic report indicating\nno changes to the last result. A server can\nonly return `unchanged` if result ids are\nprovided." - }, - { - "name": "resultId", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A result id which will be sent on the next\ndiagnostic request for the same document." - } - ], - "documentation": "A diagnostic report indicating that the last returned\nreport is still accurate.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DiagnosticOptions", - "properties": [ - { - "name": "identifier", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "An optional identifier under which the diagnostics are\nmanaged by the client." - }, - { - "name": "interFileDependencies", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "Whether the language has inter file dependencies meaning that\nediting code in one file can result in a different diagnostic\nset in another file. Inter file dependencies are common for\nmost programming languages and typically uncommon for linters." - }, - { - "name": "workspaceDiagnostics", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "The server provides support for workspace diagnostics as well." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Diagnostic options.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "PreviousResultId", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The URI for which the client knowns a\nresult id." - }, - { - "name": "value", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The value of the previous result id." - } - ], - "documentation": "A previous result id in a workspace pull request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "NotebookDocument", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "URI" - }, - "documentation": "The notebook document's uri." - }, - { - "name": "notebookType", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The type of the notebook." - }, - { - "name": "version", - "type": { - "kind": "base", - "name": "integer" - }, - "documentation": "The version number of this document (it will increase after each\nchange, including undo/redo)." - }, - { - "name": "metadata", - "type": { - "kind": "reference", - "name": "LSPObject" - }, - "optional": true, - "documentation": "Additional metadata stored with the notebook\ndocument.\n\nNote: should always be an object literal (e.g. LSPObject)" - }, - { - "name": "cells", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "NotebookCell" - } - }, - "documentation": "The cells of a notebook." - } - ], - "documentation": "A notebook document.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "TextDocumentItem", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The text document's uri." - }, - { - "name": "languageId", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The text document's language identifier." - }, - { - "name": "version", - "type": { - "kind": "base", - "name": "integer" - }, - "documentation": "The version number of this document (it will increase after each\nchange, including undo/redo)." - }, - { - "name": "text", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The content of the opened text document." - } - ], - "documentation": "An item to transfer a text document from the client to the\nserver." - }, - { - "name": "VersionedNotebookDocumentIdentifier", - "properties": [ - { - "name": "version", - "type": { - "kind": "base", - "name": "integer" - }, - "documentation": "The version number of this notebook document." - }, - { - "name": "uri", - "type": { - "kind": "base", - "name": "URI" - }, - "documentation": "The notebook document's uri." - } - ], - "documentation": "A versioned notebook document identifier.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "NotebookDocumentChangeEvent", - "properties": [ - { - "name": "metadata", - "type": { - "kind": "reference", - "name": "LSPObject" - }, - "optional": true, - "documentation": "The changed meta data if any.\n\nNote: should always be an object literal (e.g. LSPObject)" - }, - { - "name": "cells", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "structure", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "array", - "type": { - "kind": "reference", - "name": "NotebookCellArrayChange" - }, - "documentation": "The change to the cell array." - }, - { - "name": "didOpen", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextDocumentItem" - } - }, - "optional": true, - "documentation": "Additional opened cell text documents." - }, - { - "name": "didClose", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextDocumentIdentifier" - } - }, - "optional": true, - "documentation": "Additional closed cell text documents." - } - ] - } - }, - "optional": true, - "documentation": "Changes to the cell structure to add or\nremove cells." - }, - { - "name": "data", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "NotebookCell" - } - }, - "optional": true, - "documentation": "Changes to notebook cells properties like its\nkind, execution summary or metadata." - }, - { - "name": "textContent", - "type": { - "kind": "array", - "element": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "document", - "type": { - "kind": "reference", - "name": "VersionedTextDocumentIdentifier" - } - }, - { - "name": "changes", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TextDocumentContentChangeEvent" - } - } - } - ] - } - } - }, - "optional": true, - "documentation": "Changes to the text content of notebook cells." - } - ] - } - }, - "optional": true, - "documentation": "Changes to cells" - } - ], - "documentation": "A change event for a notebook document.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "NotebookDocumentIdentifier", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "URI" - }, - "documentation": "The notebook document's uri." - } - ], - "documentation": "A literal to identify a notebook document in the client.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineCompletionContext", - "properties": [ - { - "name": "triggerKind", - "type": { - "kind": "reference", - "name": "InlineCompletionTriggerKind" - }, - "documentation": "Describes how the inline completion was triggered." - }, - { - "name": "selectedCompletionInfo", - "type": { - "kind": "reference", - "name": "SelectedCompletionInfo" - }, - "optional": true, - "documentation": "Provides information about the currently selected item in the autocomplete widget if it is visible." - } - ], - "documentation": "Provides information about the context in which an inline completion was requested.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "StringValue", - "properties": [ - { - "name": "kind", - "type": { - "kind": "stringLiteral", - "value": "snippet" - }, - "documentation": "The kind of string value." - }, - { - "name": "value", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The snippet string." - } - ], - "documentation": "A string value used as a snippet is a template which allows to insert text\nand to control the editor cursor when insertion happens.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Variables are defined with `$name` and\n`${name:default value}`.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "InlineCompletionOptions", - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "properties": [], - "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "Registration", - "properties": [ - { - "name": "id", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The id used to register the request. The id can be used to deregister\nthe request again." - }, - { - "name": "method", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The method / capability to register for." - }, - { - "name": "registerOptions", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "Options necessary for the registration." - } - ], - "documentation": "General parameters to register for a notification or to register a provider." - }, - { - "name": "Unregistration", - "properties": [ - { - "name": "id", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The id used to unregister the request or notification. Usually an id\nprovided during the register request." - }, - { - "name": "method", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The method to unregister for." - } - ], - "documentation": "General parameters to unregister a request or notification." - }, - { - "name": "_InitializeParams", - "properties": [ - { - "name": "processId", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "integer" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "documentation": "The process Id of the parent process that started\nthe server.\n\nIs `null` if the process has not been started by another process.\nIf the parent process is not alive then the server should exit." - }, - { - "name": "clientInfo", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "name", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The name of the client as defined by the client." - }, - { - "name": "version", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The client's version as defined by the client." - } - ] - } - }, - "optional": true, - "documentation": "Information about the client\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "locale", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The locale the client is currently showing the user interface\nin. This must not necessarily be the locale of the operating\nsystem.\n\nUses IETF language tags as the value's syntax\n(See https://en.wikipedia.org/wiki/IETF_language_tag)\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "rootPath", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "optional": true, - "documentation": "The rootPath of the workspace. Is null\nif no folder is open.\n\n@deprecated in favour of rootUri.", - "deprecated": "in favour of rootUri." - }, - { - "name": "rootUri", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "DocumentUri" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "documentation": "The rootUri of the workspace. Is null if no\nfolder is open. If both `rootPath` and `rootUri` are set\n`rootUri` wins.\n\n@deprecated in favour of workspaceFolders.", - "deprecated": "in favour of workspaceFolders." - }, - { - "name": "capabilities", - "type": { - "kind": "reference", - "name": "ClientCapabilities" - }, - "documentation": "The capabilities provided by the client (editor or tool)" - }, - { - "name": "initializationOptions", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "User provided initialization options." - }, - { - "name": "trace", - "type": { - "kind": "reference", - "name": "TraceValues" - }, - "optional": true, - "documentation": "The initial trace setting. If omitted trace is disabled ('off')." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "The initialize parameters" - }, - { - "name": "WorkspaceFoldersInitializeParams", - "properties": [ - { - "name": "workspaceFolders", - "type": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "WorkspaceFolder" - } - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "optional": true, - "documentation": "The workspace folders configured in the client when the server starts.\n\nThis property is only available if the client supports workspace folders.\nIt can be `null` if the client supports workspace folders but none are\nconfigured.\n\n@since 3.6.0", - "since": "3.6.0" - } - ] - }, - { - "name": "ServerCapabilities", - "properties": [ - { - "name": "positionEncoding", - "type": { - "kind": "reference", - "name": "PositionEncodingKind" - }, - "optional": true, - "documentation": "The position encoding the server picked from the encodings offered\nby the client via the client capability `general.positionEncodings`.\n\nIf the client didn't provide any position encodings the only valid\nvalue that a server can return is 'utf-16'.\n\nIf omitted it defaults to 'utf-16'.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "textDocumentSync", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "TextDocumentSyncOptions" - }, - { - "kind": "reference", - "name": "TextDocumentSyncKind" - } - ] - }, - "optional": true, - "documentation": "Defines how text documents are synced. Is either a detailed structure\ndefining each notification or for backwards compatibility the\nTextDocumentSyncKind number." - }, - { - "name": "notebookDocumentSync", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "NotebookDocumentSyncOptions" - }, - { - "kind": "reference", - "name": "NotebookDocumentSyncRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "Defines how notebook documents are synced.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "completionProvider", - "type": { - "kind": "reference", - "name": "CompletionOptions" - }, - "optional": true, - "documentation": "The server provides completion support." - }, - { - "name": "hoverProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "HoverOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides hover support." - }, - { - "name": "signatureHelpProvider", - "type": { - "kind": "reference", - "name": "SignatureHelpOptions" - }, - "optional": true, - "documentation": "The server provides signature help support." - }, - { - "name": "declarationProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "DeclarationOptions" - }, - { - "kind": "reference", - "name": "DeclarationRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides Goto Declaration support." - }, - { - "name": "definitionProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "DefinitionOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides goto definition support." - }, - { - "name": "typeDefinitionProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "TypeDefinitionOptions" - }, - { - "kind": "reference", - "name": "TypeDefinitionRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides Goto Type Definition support." - }, - { - "name": "implementationProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "ImplementationOptions" - }, - { - "kind": "reference", - "name": "ImplementationRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides Goto Implementation support." - }, - { - "name": "referencesProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "ReferenceOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides find references support." - }, - { - "name": "documentHighlightProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "DocumentHighlightOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides document highlight support." - }, - { - "name": "documentSymbolProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "DocumentSymbolOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides document symbol support." - }, - { - "name": "codeActionProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "CodeActionOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides code actions. CodeActionOptions may only be\nspecified if the client states that it supports\n`codeActionLiteralSupport` in its initial `initialize` request." - }, - { - "name": "codeLensProvider", - "type": { - "kind": "reference", - "name": "CodeLensOptions" - }, - "optional": true, - "documentation": "The server provides code lens." - }, - { - "name": "documentLinkProvider", - "type": { - "kind": "reference", - "name": "DocumentLinkOptions" - }, - "optional": true, - "documentation": "The server provides document link support." - }, - { - "name": "colorProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "DocumentColorOptions" - }, - { - "kind": "reference", - "name": "DocumentColorRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides color provider support." - }, - { - "name": "workspaceSymbolProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "WorkspaceSymbolOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides workspace symbol support." - }, - { - "name": "documentFormattingProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "DocumentFormattingOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides document formatting." - }, - { - "name": "documentRangeFormattingProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "DocumentRangeFormattingOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides document range formatting." - }, - { - "name": "documentOnTypeFormattingProvider", - "type": { - "kind": "reference", - "name": "DocumentOnTypeFormattingOptions" - }, - "optional": true, - "documentation": "The server provides document formatting on typing." - }, - { - "name": "renameProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "RenameOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides rename support. RenameOptions may only be\nspecified if the client states that it supports\n`prepareSupport` in its initial `initialize` request." - }, - { - "name": "foldingRangeProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "FoldingRangeOptions" - }, - { - "kind": "reference", - "name": "FoldingRangeRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides folding provider support." - }, - { - "name": "selectionRangeProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "SelectionRangeOptions" - }, - { - "kind": "reference", - "name": "SelectionRangeRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides selection range support." - }, - { - "name": "executeCommandProvider", - "type": { - "kind": "reference", - "name": "ExecuteCommandOptions" - }, - "optional": true, - "documentation": "The server provides execute command support." - }, - { - "name": "callHierarchyProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "CallHierarchyOptions" - }, - { - "kind": "reference", - "name": "CallHierarchyRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides call hierarchy support.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "linkedEditingRangeProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "LinkedEditingRangeOptions" - }, - { - "kind": "reference", - "name": "LinkedEditingRangeRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides linked editing range support.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "semanticTokensProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "SemanticTokensOptions" - }, - { - "kind": "reference", - "name": "SemanticTokensRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides semantic tokens support.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "monikerProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "MonikerOptions" - }, - { - "kind": "reference", - "name": "MonikerRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides moniker support.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "typeHierarchyProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "TypeHierarchyOptions" - }, - { - "kind": "reference", - "name": "TypeHierarchyRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides type hierarchy support.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "inlineValueProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "InlineValueOptions" - }, - { - "kind": "reference", - "name": "InlineValueRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides inline values.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "inlayHintProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "InlayHintOptions" - }, - { - "kind": "reference", - "name": "InlayHintRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides inlay hints.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "diagnosticProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "DiagnosticOptions" - }, - { - "kind": "reference", - "name": "DiagnosticRegistrationOptions" - } - ] - }, - "optional": true, - "documentation": "The server has support for pull model diagnostics.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "inlineCompletionProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "InlineCompletionOptions" - } - ] - }, - "optional": true, - "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "textDocument", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "diagnostic", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "markupMessageSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the server supports `MarkupContent` in diagnostic messages.", - "since": "3.18.0", - "proposed": true - } - ] - } - }, - "optional": true, - "documentation": "Capabilities specific to the diagnostic pull model.\n\n@since 3.18.0", - "since": "3.18.0" - } - ] - } - }, - "optional": true, - "documentation": "Text document specific server capabilities.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0" - }, - { - "name": "workspace", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "workspaceFolders", - "type": { - "kind": "reference", - "name": "WorkspaceFoldersServerCapabilities" - }, - "optional": true, - "documentation": "The server supports workspace folder.\n\n@since 3.6.0", - "since": "3.6.0" - }, - { - "name": "fileOperations", - "type": { - "kind": "reference", - "name": "FileOperationOptions" - }, - "optional": true, - "documentation": "The server is interested in notifications/requests for operations on files.\n\n@since 3.16.0", - "since": "3.16.0" - } - ] - } - }, - "optional": true, - "documentation": "Workspace specific server capabilities." - }, - { - "name": "experimental", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "Experimental server capabilities." - } - ], - "documentation": "Defines the capabilities provided by a language\nserver." - }, - { - "name": "VersionedTextDocumentIdentifier", - "properties": [ - { - "name": "version", - "type": { - "kind": "base", - "name": "integer" - }, - "documentation": "The version number of this document." - } - ], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentIdentifier" - } - ], - "documentation": "A text document identifier to denote a specific version of a text document." - }, - { - "name": "SaveOptions", - "properties": [ - { - "name": "includeText", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client is supposed to include the content on save." - } - ], - "documentation": "Save options." - }, - { - "name": "FileEvent", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The file's uri." - }, - { - "name": "type", - "type": { - "kind": "reference", - "name": "FileChangeType" - }, - "documentation": "The change type." - } - ], - "documentation": "An event describing a file change." - }, - { - "name": "FileSystemWatcher", - "properties": [ - { - "name": "globPattern", - "type": { - "kind": "reference", - "name": "GlobPattern" - }, - "documentation": "The glob pattern to watch. See {@link GlobPattern glob pattern} for more detail.\n\n@since 3.17.0 support for relative patterns.", - "since": "3.17.0 support for relative patterns." - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "WatchKind" - }, - "optional": true, - "documentation": "The kind of events of interest. If omitted it defaults\nto WatchKind.Create | WatchKind.Change | WatchKind.Delete\nwhich is 7." - } - ] - }, - { - "name": "Diagnostic", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range at which the message applies" - }, - { - "name": "severity", - "type": { - "kind": "reference", - "name": "DiagnosticSeverity" - }, - "optional": true, - "documentation": "The diagnostic's severity. Can be omitted. If omitted it is up to the\nclient to interpret diagnostics as error, warning, info or hint." - }, - { - "name": "code", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "integer" - }, - { - "kind": "base", - "name": "string" - } - ] - }, - "optional": true, - "documentation": "The diagnostic's code, which usually appear in the user interface." - }, - { - "name": "codeDescription", - "type": { - "kind": "reference", - "name": "CodeDescription" - }, - "optional": true, - "documentation": "An optional property to describe the error code.\nRequires the code field (above) to be present/not null.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "source", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A human-readable string describing the source of this\ndiagnostic, e.g. 'typescript' or 'super lint'. It usually\nappears in the user interface." - }, - { - "name": "message", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "reference", - "name": "MarkupContent" - } - ] - }, - "documentation": "The diagnostic's message. It usually appears in the user interface.\n\n@since 3.18.0 - support for `MarkupContent`. This is guarded by the client capability `textDocument.diagnostic.markupMessageSupport`." - }, - { - "name": "tags", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "DiagnosticTag" - } - }, - "optional": true, - "documentation": "Additional metadata about the diagnostic.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "relatedInformation", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "DiagnosticRelatedInformation" - } - }, - "optional": true, - "documentation": "An array of related diagnostic information, e.g. when symbol-names within\na scope collide all definitions can be marked via this property." - }, - { - "name": "data", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "A data entry field that is preserved between a `textDocument/publishDiagnostics`\nnotification and `textDocument/codeAction` request.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "documentation": "Represents a diagnostic, such as a compiler error or warning. Diagnostic objects\nare only valid in the scope of a resource." - }, - { - "name": "CompletionContext", - "properties": [ - { - "name": "triggerKind", - "type": { - "kind": "reference", - "name": "CompletionTriggerKind" - }, - "documentation": "How the completion was triggered." - }, - { - "name": "triggerCharacter", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The trigger character (a single character) that has trigger code complete.\nIs undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`" - } - ], - "documentation": "Contains additional information about the context in which a completion request is triggered." - }, - { - "name": "CompletionItemLabelDetails", - "properties": [ - { - "name": "detail", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "An optional string which is rendered less prominently directly after {@link CompletionItem.label label},\nwithout any spacing. Should be used for function signatures and type annotations." - }, - { - "name": "description", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "An optional string which is rendered less prominently after {@link CompletionItem.detail}. Should be used\nfor fully qualified names and file paths." - } - ], - "documentation": "Additional details for a completion item label.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InsertReplaceEdit", - "properties": [ - { - "name": "newText", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The string to be inserted." - }, - { - "name": "insert", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range if the insert is requested" - }, - { - "name": "replace", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range if the replace is requested." - } - ], - "documentation": "A special text edit to provide an insert and a replace operation.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "CompletionOptions", - "properties": [ - { - "name": "triggerCharacters", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "optional": true, - "documentation": "Most tools trigger completion request automatically without explicitly requesting\nit using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user\nstarts to type an identifier. For example if the user types `c` in a JavaScript file\ncode complete will automatically pop up present `console` besides others as a\ncompletion item. Characters that make up identifiers don't need to be listed here.\n\nIf code complete should automatically be trigger on characters not being valid inside\nan identifier (for example `.` in JavaScript) list them in `triggerCharacters`." - }, - { - "name": "allCommitCharacters", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "optional": true, - "documentation": "The list of all possible characters that commit a completion. This field can be used\nif clients don't support individual commit characters per completion item. See\n`ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport`\n\nIf a server provides both `allCommitCharacters` and commit characters on an individual\ncompletion item the ones on the completion item win.\n\n@since 3.2.0", - "since": "3.2.0" - }, - { - "name": "resolveProvider", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The server provides support to resolve additional\ninformation for a completion item." - }, - { - "name": "completionItem", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "labelDetailsSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The server has support for completion item label\ndetails (see also `CompletionItemLabelDetails`) when\nreceiving a completion item in a resolve call.\n\n@since 3.17.0", - "since": "3.17.0" - } - ] - } - }, - "optional": true, - "documentation": "The server supports the following `CompletionItem` specific\ncapabilities.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Completion options." - }, - { - "name": "HoverOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Hover options." - }, - { - "name": "SignatureHelpContext", - "properties": [ - { - "name": "triggerKind", - "type": { - "kind": "reference", - "name": "SignatureHelpTriggerKind" - }, - "documentation": "Action that caused signature help to be triggered." - }, - { - "name": "triggerCharacter", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "Character that caused signature help to be triggered.\n\nThis is undefined when `triggerKind !== SignatureHelpTriggerKind.TriggerCharacter`" - }, - { - "name": "isRetrigger", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "`true` if signature help was already showing when it was triggered.\n\nRetriggers occurs when the signature help is already active and can be caused by actions such as\ntyping a trigger character, a cursor move, or document content changes." - }, - { - "name": "activeSignatureHelp", - "type": { - "kind": "reference", - "name": "SignatureHelp" - }, - "optional": true, - "documentation": "The currently active `SignatureHelp`.\n\nThe `activeSignatureHelp` has its `SignatureHelp.activeSignature` field updated based on\nthe user navigating through available signatures." - } - ], - "documentation": "Additional information about the context in which a signature help request was triggered.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "SignatureInformation", - "properties": [ - { - "name": "label", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The label of this signature. Will be shown in\nthe UI." - }, - { - "name": "documentation", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "reference", - "name": "MarkupContent" - } - ] - }, - "optional": true, - "documentation": "The human-readable doc-comment of this signature. Will be shown\nin the UI but can be omitted." - }, - { - "name": "parameters", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "ParameterInformation" - } - }, - "optional": true, - "documentation": "The parameters of this signature." - }, - { - "name": "activeParameter", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "uinteger" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "optional": true, - "documentation": "The index of the active parameter.\n\nIf `null`, no parameter of the signature is active (for example a named\nargument that does not match any declared parameters). This is only valid\nsince 3.18.0 and if the client specifies the client capability\n`textDocument.signatureHelp.noActiveParameterSupport === true`\n\nIf provided (or `null`), this is used in place of\n`SignatureHelp.activeParameter`.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "documentation": "Represents the signature of something callable. A signature\ncan have a label, like a function-name, a doc-comment, and\na set of parameters." - }, - { - "name": "SignatureHelpOptions", - "properties": [ - { - "name": "triggerCharacters", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "optional": true, - "documentation": "List of characters that trigger signature help automatically." - }, - { - "name": "retriggerCharacters", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "optional": true, - "documentation": "List of characters that re-trigger signature help.\n\nThese trigger characters are only active when signature help is already showing. All trigger characters\nare also counted as re-trigger characters.\n\n@since 3.15.0", - "since": "3.15.0" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Server Capabilities for a {@link SignatureHelpRequest}." - }, - { - "name": "DefinitionOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Server Capabilities for a {@link DefinitionRequest}." - }, - { - "name": "ReferenceContext", - "properties": [ - { - "name": "includeDeclaration", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "Include the declaration of the current symbol." - } - ], - "documentation": "Value-object that contains additional information when\nrequesting references." - }, - { - "name": "ReferenceOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Reference options." - }, - { - "name": "DocumentHighlightOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Provider options for a {@link DocumentHighlightRequest}." - }, - { - "name": "BaseSymbolInformation", - "properties": [ - { - "name": "name", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The name of this symbol." - }, - { - "name": "kind", - "type": { - "kind": "reference", - "name": "SymbolKind" - }, - "documentation": "The kind of this symbol." - }, - { - "name": "tags", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolTag" - } - }, - "optional": true, - "documentation": "Tags for this symbol.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "containerName", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The name of the symbol containing this symbol. This information is for\nuser interface purposes (e.g. to render a qualifier in the user interface\nif necessary). It can't be used to re-infer a hierarchy for the document\nsymbols." - } - ], - "documentation": "A base for all symbol information." - }, - { - "name": "DocumentSymbolOptions", - "properties": [ - { - "name": "label", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A human-readable string that is shown when multiple outlines trees\nare shown for the same document.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Provider options for a {@link DocumentSymbolRequest}." - }, - { - "name": "CodeActionContext", - "properties": [ - { - "name": "diagnostics", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "Diagnostic" - } - }, - "documentation": "An array of diagnostics known on the client side overlapping the range provided to the\n`textDocument/codeAction` request. They are provided so that the server knows which\nerrors are currently presented to the user for the given range. There is no guarantee\nthat these accurately reflect the error state of the resource. The primary parameter\nto compute code actions is the provided range.\n\nNote that the client should check the `textDocument.diagnostic.markupMessageSupport` server capability before sending diagnostics with markup messages to a server." - }, - { - "name": "only", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CodeActionKind" - } - }, - "optional": true, - "documentation": "Requested kind of actions to return.\n\nActions not of this kind are filtered out by the client before being shown. So servers\ncan omit computing them." - }, - { - "name": "triggerKind", - "type": { - "kind": "reference", - "name": "CodeActionTriggerKind" - }, - "optional": true, - "documentation": "The reason why code actions were requested.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "documentation": "Contains additional diagnostic information about the context in which\na {@link CodeActionProvider.provideCodeActions code action} is run." - }, - { - "name": "CodeActionOptions", - "properties": [ - { - "name": "codeActionKinds", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CodeActionKind" - } - }, - "optional": true, - "documentation": "CodeActionKinds that this server may return.\n\nThe list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server\nmay list out every specific kind they provide." - }, - { - "name": "resolveProvider", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The server provides support to resolve additional\ninformation for a code action.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Provider options for a {@link CodeActionRequest}." - }, - { - "name": "WorkspaceSymbolOptions", - "properties": [ - { - "name": "resolveProvider", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The server provides support to resolve additional\ninformation for a workspace symbol.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Server capabilities for a {@link WorkspaceSymbolRequest}." - }, - { - "name": "CodeLensOptions", - "properties": [ - { - "name": "resolveProvider", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Code lens has a resolve provider as well." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Code Lens provider options of a {@link CodeLensRequest}." - }, - { - "name": "DocumentLinkOptions", - "properties": [ - { - "name": "resolveProvider", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Document links have a resolve provider as well." - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Provider options for a {@link DocumentLinkRequest}." - }, - { - "name": "FormattingOptions", - "properties": [ - { - "name": "tabSize", - "type": { - "kind": "base", - "name": "uinteger" - }, - "documentation": "Size of a tab in spaces." - }, - { - "name": "insertSpaces", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "Prefer spaces over tabs." - }, - { - "name": "trimTrailingWhitespace", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Trim trailing whitespace on a line.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "insertFinalNewline", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Insert a newline character at the end of the file if one does not exist.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "trimFinalNewlines", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Trim all newlines after the final newline at the end of the file.\n\n@since 3.15.0", - "since": "3.15.0" - } - ], - "documentation": "Value-object describing what options formatting should use." - }, - { - "name": "DocumentFormattingOptions", - "properties": [], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Provider options for a {@link DocumentFormattingRequest}." - }, - { - "name": "DocumentRangeFormattingOptions", - "properties": [ - { - "name": "rangesSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the server supports formatting multiple ranges at once.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Provider options for a {@link DocumentRangeFormattingRequest}." - }, - { - "name": "DocumentOnTypeFormattingOptions", - "properties": [ - { - "name": "firstTriggerCharacter", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A character on which formatting should be triggered, like `{`." - }, - { - "name": "moreTriggerCharacter", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "optional": true, - "documentation": "More trigger characters." - } - ], - "documentation": "Provider options for a {@link DocumentOnTypeFormattingRequest}." - }, - { - "name": "RenameOptions", - "properties": [ - { - "name": "prepareProvider", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Renames should be checked and tested before being executed.\n\n@since version 3.12.0", - "since": "version 3.12.0" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Provider options for a {@link RenameRequest}." - }, - { - "name": "ExecuteCommandOptions", - "properties": [ - { - "name": "commands", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "documentation": "The commands to be executed on the server" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "The server capabilities of a {@link ExecuteCommandRequest}." - }, - { - "name": "SemanticTokensLegend", - "properties": [ - { - "name": "tokenTypes", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "documentation": "The token types a server uses." - }, - { - "name": "tokenModifiers", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "documentation": "The token modifiers a server uses." - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "OptionalVersionedTextDocumentIdentifier", - "properties": [ - { - "name": "version", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "integer" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "documentation": "The version number of this document. If a versioned text document identifier\nis sent from the server to the client and the file is not open in the editor\n(the server has not received an open notification before) the server can send\n`null` to indicate that the version is unknown and the content on disk is the\ntruth (as specified with document content ownership)." - } - ], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentIdentifier" - } - ], - "documentation": "A text document identifier to optionally denote a specific version of a text document." - }, - { - "name": "AnnotatedTextEdit", - "properties": [ - { - "name": "annotationId", - "type": { - "kind": "reference", - "name": "ChangeAnnotationIdentifier" - }, - "documentation": "The actual identifier of the change annotation" - } - ], - "extends": [ - { - "kind": "reference", - "name": "TextEdit" - } - ], - "documentation": "A special text edit with an additional change annotation.\n\n@since 3.16.0.", - "since": "3.16.0." - }, - { - "name": "ResourceOperation", - "properties": [ - { - "name": "kind", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The resource operation kind." - }, - { - "name": "annotationId", - "type": { - "kind": "reference", - "name": "ChangeAnnotationIdentifier" - }, - "optional": true, - "documentation": "An optional annotation identifier describing the operation.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "documentation": "A generic resource operation." - }, - { - "name": "CreateFileOptions", - "properties": [ - { - "name": "overwrite", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Overwrite existing file. Overwrite wins over `ignoreIfExists`" - }, - { - "name": "ignoreIfExists", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Ignore if exists." - } - ], - "documentation": "Options to create a file." - }, - { - "name": "RenameFileOptions", - "properties": [ - { - "name": "overwrite", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Overwrite target if existing. Overwrite wins over `ignoreIfExists`" - }, - { - "name": "ignoreIfExists", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Ignores if target exists." - } - ], - "documentation": "Rename file options" - }, - { - "name": "DeleteFileOptions", - "properties": [ - { - "name": "recursive", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Delete the content recursively if a folder is denoted." - }, - { - "name": "ignoreIfNotExists", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Ignore the operation if the file doesn't exist." - } - ], - "documentation": "Delete file options" - }, - { - "name": "FileOperationPattern", - "properties": [ - { - "name": "glob", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The glob pattern to match. Glob patterns can have the following syntax:\n- `*` to match one or more characters in a path segment\n- `?` to match on one character in a path segment\n- `**` to match any number of path segments, including none\n- `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)\n- `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)\n- `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)" - }, - { - "name": "matches", - "type": { - "kind": "reference", - "name": "FileOperationPatternKind" - }, - "optional": true, - "documentation": "Whether to match files or folders with this pattern.\n\nMatches both if undefined." - }, - { - "name": "options", - "type": { - "kind": "reference", - "name": "FileOperationPatternOptions" - }, - "optional": true, - "documentation": "Additional options used during matching." - } - ], - "documentation": "A pattern to describe in which file operation requests or notifications\nthe server is interested in receiving.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "WorkspaceFullDocumentDiagnosticReport", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The URI for which diagnostic information is reported." - }, - { - "name": "version", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "integer" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "documentation": "The version number for which the diagnostics are reported.\nIf the document is not marked as open `null` can be provided." - } - ], - "extends": [ - { - "kind": "reference", - "name": "FullDocumentDiagnosticReport" - } - ], - "documentation": "A full document diagnostic report for a workspace diagnostic result.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "WorkspaceUnchangedDocumentDiagnosticReport", - "properties": [ - { - "name": "uri", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The URI for which diagnostic information is reported." - }, - { - "name": "version", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "integer" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "documentation": "The version number for which the diagnostics are reported.\nIf the document is not marked as open `null` can be provided." - } - ], - "extends": [ - { - "kind": "reference", - "name": "UnchangedDocumentDiagnosticReport" - } - ], - "documentation": "An unchanged document diagnostic report for a workspace diagnostic result.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "NotebookCell", - "properties": [ - { - "name": "kind", - "type": { - "kind": "reference", - "name": "NotebookCellKind" - }, - "documentation": "The cell's kind" - }, - { - "name": "document", - "type": { - "kind": "base", - "name": "DocumentUri" - }, - "documentation": "The URI of the cell's text document\ncontent." - }, - { - "name": "metadata", - "type": { - "kind": "reference", - "name": "LSPObject" - }, - "optional": true, - "documentation": "Additional metadata stored with the cell.\n\nNote: should always be an object literal (e.g. LSPObject)" - }, - { - "name": "executionSummary", - "type": { - "kind": "reference", - "name": "ExecutionSummary" - }, - "optional": true, - "documentation": "Additional execution summary information\nif supported by the client." - } - ], - "documentation": "A notebook cell.\n\nA cell's document URI must be unique across ALL notebook\ncells and can therefore be used to uniquely identify a\nnotebook cell or the cell's text document.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "NotebookCellArrayChange", - "properties": [ - { - "name": "start", - "type": { - "kind": "base", - "name": "uinteger" - }, - "documentation": "The start oftest of the cell that changed." - }, - { - "name": "deleteCount", - "type": { - "kind": "base", - "name": "uinteger" - }, - "documentation": "The deleted cells" - }, - { - "name": "cells", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "NotebookCell" - } - }, - "optional": true, - "documentation": "The new cells, if any" - } - ], - "documentation": "A change describing how to move a `NotebookCell`\narray from state S to S'.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "SelectedCompletionInfo", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range that will be replaced if this completion item is accepted." - }, - { - "name": "text", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The text the range will be replaced with if this completion is accepted." - } - ], - "documentation": "Describes the currently selected completion item.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "ClientCapabilities", - "properties": [ - { - "name": "workspace", - "type": { - "kind": "reference", - "name": "WorkspaceClientCapabilities" - }, - "optional": true, - "documentation": "Workspace specific client capabilities." - }, - { - "name": "textDocument", - "type": { - "kind": "reference", - "name": "TextDocumentClientCapabilities" - }, - "optional": true, - "documentation": "Text document specific client capabilities." - }, - { - "name": "notebookDocument", - "type": { - "kind": "reference", - "name": "NotebookDocumentClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the notebook document support.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "window", - "type": { - "kind": "reference", - "name": "WindowClientCapabilities" - }, - "optional": true, - "documentation": "Window specific client capabilities." - }, - { - "name": "general", - "type": { - "kind": "reference", - "name": "GeneralClientCapabilities" - }, - "optional": true, - "documentation": "General client capabilities.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "experimental", - "type": { - "kind": "reference", - "name": "LSPAny" - }, - "optional": true, - "documentation": "Experimental client capabilities." - } - ], - "documentation": "Defines the capabilities provided by the client." - }, - { - "name": "TextDocumentSyncOptions", - "properties": [ - { - "name": "openClose", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Open and close notifications are sent to the server. If omitted open close notification should not\nbe sent." - }, - { - "name": "change", - "type": { - "kind": "reference", - "name": "TextDocumentSyncKind" - }, - "optional": true, - "documentation": "Change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full\nand TextDocumentSyncKind.Incremental. If omitted it defaults to TextDocumentSyncKind.None." - }, - { - "name": "willSave", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "If present will save notifications are sent to the server. If omitted the notification should not be\nsent." - }, - { - "name": "willSaveWaitUntil", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "If present will save wait until requests are sent to the server. If omitted the request should not be\nsent." - }, - { - "name": "save", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "SaveOptions" - } - ] - }, - "optional": true, - "documentation": "If present save notifications are sent to the server. If omitted the notification should not be\nsent." - } - ] - }, - { - "name": "NotebookDocumentSyncOptions", - "properties": [ - { - "name": "notebookSelector", - "type": { - "kind": "array", - "element": { - "kind": "or", - "items": [ - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "notebook", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "reference", - "name": "NotebookDocumentFilter" - } - ] - }, - "documentation": "The notebook to be synced If a string\nvalue is provided it matches against the\nnotebook type. '*' matches every notebook." - }, - { - "name": "cells", - "type": { - "kind": "array", - "element": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "language", - "type": { - "kind": "base", - "name": "string" - } - } - ] - } - } - }, - "optional": true, - "documentation": "The cells of the matching notebook to be synced." - } - ] - } - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "notebook", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "reference", - "name": "NotebookDocumentFilter" - } - ] - }, - "optional": true, - "documentation": "The notebook to be synced If a string\nvalue is provided it matches against the\nnotebook type. '*' matches every notebook." - }, - { - "name": "cells", - "type": { - "kind": "array", - "element": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "language", - "type": { - "kind": "base", - "name": "string" - } - } - ] - } - } - }, - "documentation": "The cells of the matching notebook to be synced." - } - ] - } - } - ] - } - }, - "documentation": "The notebooks to be synced" - }, - { - "name": "save", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether save notification should be forwarded to\nthe server. Will only be honored if mode === `notebook`." - } - ], - "documentation": "Options specific to a notebook plus its cells\nto be synced to the server.\n\nIf a selector provides a notebook document\nfilter but no cell selector all cells of a\nmatching notebook document will be synced.\n\nIf a selector provides no notebook document\nfilter but only a cell selector all notebook\ndocument that contain at least one matching\ncell will be synced.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "NotebookDocumentSyncRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "NotebookDocumentSyncOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ], - "documentation": "Registration options specific to a notebook.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "WorkspaceFoldersServerCapabilities", - "properties": [ - { - "name": "supported", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The server has support for workspace folders" - }, - { - "name": "changeNotifications", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "base", - "name": "boolean" - } - ] - }, - "optional": true, - "documentation": "Whether the server wants to receive workspace folder\nchange notifications.\n\nIf a string is provided the string is treated as an ID\nunder which the notification is registered on the client\nside. The ID can be used to unregister for these events\nusing the `client/unregisterCapability` request." - } - ] - }, - { - "name": "FileOperationOptions", - "properties": [ - { - "name": "didCreate", - "type": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "optional": true, - "documentation": "The server is interested in receiving didCreateFiles notifications." - }, - { - "name": "willCreate", - "type": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "optional": true, - "documentation": "The server is interested in receiving willCreateFiles requests." - }, - { - "name": "didRename", - "type": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "optional": true, - "documentation": "The server is interested in receiving didRenameFiles notifications." - }, - { - "name": "willRename", - "type": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "optional": true, - "documentation": "The server is interested in receiving willRenameFiles requests." - }, - { - "name": "didDelete", - "type": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "optional": true, - "documentation": "The server is interested in receiving didDeleteFiles file notifications." - }, - { - "name": "willDelete", - "type": { - "kind": "reference", - "name": "FileOperationRegistrationOptions" - }, - "optional": true, - "documentation": "The server is interested in receiving willDeleteFiles file requests." - } - ], - "documentation": "Options for notifications/requests for user operations on files.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "CodeDescription", - "properties": [ - { - "name": "href", - "type": { - "kind": "base", - "name": "URI" - }, - "documentation": "An URI to open with more information about the diagnostic error." - } - ], - "documentation": "Structure to capture a description for an error code.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "DiagnosticRelatedInformation", - "properties": [ - { - "name": "location", - "type": { - "kind": "reference", - "name": "Location" - }, - "documentation": "The location of this related diagnostic information." - }, - { - "name": "message", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The message of this related diagnostic information." - } - ], - "documentation": "Represents a related message and source code location for a diagnostic. This should be\nused to point to code locations that cause or related to a diagnostics, e.g when duplicating\na symbol in a scope." - }, - { - "name": "ParameterInformation", - "properties": [ - { - "name": "label", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "tuple", - "items": [ - { - "kind": "base", - "name": "uinteger" - }, - { - "kind": "base", - "name": "uinteger" - } - ] - } - ] - }, - "documentation": "The label of this parameter information.\n\nEither a string or an inclusive start and exclusive end offsets within its containing\nsignature label. (see SignatureInformation.label). The offsets are based on a UTF-16\nstring representation as `Position` and `Range` does.\n\n*Note*: a label of type string should be a substring of its containing signature label.\nIts intended use case is to highlight the parameter label part in the `SignatureInformation.label`." - }, - { - "name": "documentation", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "reference", - "name": "MarkupContent" - } - ] - }, - "optional": true, - "documentation": "The human-readable doc-comment of this parameter. Will be shown\nin the UI but can be omitted." - } - ], - "documentation": "Represents a parameter of a callable-signature. A parameter can\nhave a label and a doc-comment." - }, - { - "name": "NotebookCellTextDocumentFilter", - "properties": [ - { - "name": "notebook", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "reference", - "name": "NotebookDocumentFilter" - } - ] - }, - "documentation": "A filter that matches against the notebook\ncontaining the notebook cell. If a string\nvalue is provided it matches against the\nnotebook type. '*' matches every notebook." - }, - { - "name": "language", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A language id like `python`.\n\nWill be matched against the language id of the\nnotebook cell document. '*' matches every language." - } - ], - "documentation": "A notebook cell text document filter denotes a cell text\ndocument by different properties.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "FileOperationPatternOptions", - "properties": [ - { - "name": "ignoreCase", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The pattern should be matched ignoring casing." - } - ], - "documentation": "Matching options for the file operation pattern.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "ExecutionSummary", - "properties": [ - { - "name": "executionOrder", - "type": { - "kind": "base", - "name": "uinteger" - }, - "documentation": "A strict monotonically increasing value\nindicating the execution order of a cell\ninside a notebook." - }, - { - "name": "success", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the execution was successful or\nnot if known by the client." - } - ] - }, - { - "name": "WorkspaceClientCapabilities", - "properties": [ - { - "name": "applyEdit", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports applying batch edits\nto the workspace by supporting the request\n'workspace/applyEdit'" - }, - { - "name": "workspaceEdit", - "type": { - "kind": "reference", - "name": "WorkspaceEditClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to `WorkspaceEdit`s." - }, - { - "name": "didChangeConfiguration", - "type": { - "kind": "reference", - "name": "DidChangeConfigurationClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `workspace/didChangeConfiguration` notification." - }, - { - "name": "didChangeWatchedFiles", - "type": { - "kind": "reference", - "name": "DidChangeWatchedFilesClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `workspace/didChangeWatchedFiles` notification." - }, - { - "name": "symbol", - "type": { - "kind": "reference", - "name": "WorkspaceSymbolClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `workspace/symbol` request." - }, - { - "name": "executeCommand", - "type": { - "kind": "reference", - "name": "ExecuteCommandClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `workspace/executeCommand` request." - }, - { - "name": "workspaceFolders", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client has support for workspace folders.\n\n@since 3.6.0", - "since": "3.6.0" - }, - { - "name": "configuration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports `workspace/configuration` requests.\n\n@since 3.6.0", - "since": "3.6.0" - }, - { - "name": "semanticTokens", - "type": { - "kind": "reference", - "name": "SemanticTokensWorkspaceClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the semantic token requests scoped to the\nworkspace.\n\n@since 3.16.0.", - "since": "3.16.0." - }, - { - "name": "codeLens", - "type": { - "kind": "reference", - "name": "CodeLensWorkspaceClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the code lens requests scoped to the\nworkspace.\n\n@since 3.16.0.", - "since": "3.16.0." - }, - { - "name": "fileOperations", - "type": { - "kind": "reference", - "name": "FileOperationClientCapabilities" - }, - "optional": true, - "documentation": "The client has support for file notifications/requests for user operations on files.\n\nSince 3.16.0" - }, - { - "name": "inlineValue", - "type": { - "kind": "reference", - "name": "InlineValueWorkspaceClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the inline values requests scoped to the\nworkspace.\n\n@since 3.17.0.", - "since": "3.17.0." - }, - { - "name": "inlayHint", - "type": { - "kind": "reference", - "name": "InlayHintWorkspaceClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the inlay hint requests scoped to the\nworkspace.\n\n@since 3.17.0.", - "since": "3.17.0." - }, - { - "name": "diagnostics", - "type": { - "kind": "reference", - "name": "DiagnosticWorkspaceClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the diagnostic requests scoped to the\nworkspace.\n\n@since 3.17.0.", - "since": "3.17.0." - }, - { - "name": "foldingRange", - "type": { - "kind": "reference", - "name": "FoldingRangeWorkspaceClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the folding range requests scoped to the workspace.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - } - ], - "documentation": "Workspace specific client capabilities." - }, - { - "name": "TextDocumentClientCapabilities", - "properties": [ - { - "name": "synchronization", - "type": { - "kind": "reference", - "name": "TextDocumentSyncClientCapabilities" - }, - "optional": true, - "documentation": "Defines which synchronization capabilities the client supports." - }, - { - "name": "completion", - "type": { - "kind": "reference", - "name": "CompletionClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/completion` request." - }, - { - "name": "hover", - "type": { - "kind": "reference", - "name": "HoverClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/hover` request." - }, - { - "name": "signatureHelp", - "type": { - "kind": "reference", - "name": "SignatureHelpClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/signatureHelp` request." - }, - { - "name": "declaration", - "type": { - "kind": "reference", - "name": "DeclarationClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/declaration` request.\n\n@since 3.14.0", - "since": "3.14.0" - }, - { - "name": "definition", - "type": { - "kind": "reference", - "name": "DefinitionClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/definition` request." - }, - { - "name": "typeDefinition", - "type": { - "kind": "reference", - "name": "TypeDefinitionClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/typeDefinition` request.\n\n@since 3.6.0", - "since": "3.6.0" - }, - { - "name": "implementation", - "type": { - "kind": "reference", - "name": "ImplementationClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/implementation` request.\n\n@since 3.6.0", - "since": "3.6.0" - }, - { - "name": "references", - "type": { - "kind": "reference", - "name": "ReferenceClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/references` request." - }, - { - "name": "documentHighlight", - "type": { - "kind": "reference", - "name": "DocumentHighlightClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/documentHighlight` request." - }, - { - "name": "documentSymbol", - "type": { - "kind": "reference", - "name": "DocumentSymbolClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/documentSymbol` request." - }, - { - "name": "codeAction", - "type": { - "kind": "reference", - "name": "CodeActionClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/codeAction` request." - }, - { - "name": "codeLens", - "type": { - "kind": "reference", - "name": "CodeLensClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/codeLens` request." - }, - { - "name": "documentLink", - "type": { - "kind": "reference", - "name": "DocumentLinkClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/documentLink` request." - }, - { - "name": "colorProvider", - "type": { - "kind": "reference", - "name": "DocumentColorClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/documentColor` and the\n`textDocument/colorPresentation` request.\n\n@since 3.6.0", - "since": "3.6.0" - }, - { - "name": "formatting", - "type": { - "kind": "reference", - "name": "DocumentFormattingClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/formatting` request." - }, - { - "name": "rangeFormatting", - "type": { - "kind": "reference", - "name": "DocumentRangeFormattingClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/rangeFormatting` request." - }, - { - "name": "onTypeFormatting", - "type": { - "kind": "reference", - "name": "DocumentOnTypeFormattingClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/onTypeFormatting` request." - }, - { - "name": "rename", - "type": { - "kind": "reference", - "name": "RenameClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/rename` request." - }, - { - "name": "foldingRange", - "type": { - "kind": "reference", - "name": "FoldingRangeClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/foldingRange` request.\n\n@since 3.10.0", - "since": "3.10.0" - }, - { - "name": "selectionRange", - "type": { - "kind": "reference", - "name": "SelectionRangeClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/selectionRange` request.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "publishDiagnostics", - "type": { - "kind": "reference", - "name": "PublishDiagnosticsClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/publishDiagnostics` notification." - }, - { - "name": "callHierarchy", - "type": { - "kind": "reference", - "name": "CallHierarchyClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the various call hierarchy requests.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "semanticTokens", - "type": { - "kind": "reference", - "name": "SemanticTokensClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the various semantic token request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "linkedEditingRange", - "type": { - "kind": "reference", - "name": "LinkedEditingRangeClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/linkedEditingRange` request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "moniker", - "type": { - "kind": "reference", - "name": "MonikerClientCapabilities" - }, - "optional": true, - "documentation": "Client capabilities specific to the `textDocument/moniker` request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "typeHierarchy", - "type": { - "kind": "reference", - "name": "TypeHierarchyClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the various type hierarchy requests.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "inlineValue", - "type": { - "kind": "reference", - "name": "InlineValueClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/inlineValue` request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "inlayHint", - "type": { - "kind": "reference", - "name": "InlayHintClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the `textDocument/inlayHint` request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "diagnostic", - "type": { - "kind": "reference", - "name": "DiagnosticClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the diagnostic pull model.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "inlineCompletion", - "type": { - "kind": "reference", - "name": "InlineCompletionClientCapabilities" - }, - "optional": true, - "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - } - ], - "documentation": "Text document specific client capabilities." - }, - { - "name": "NotebookDocumentClientCapabilities", - "properties": [ - { - "name": "synchronization", - "type": { - "kind": "reference", - "name": "NotebookDocumentSyncClientCapabilities" - }, - "documentation": "Capabilities specific to notebook document synchronization\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "documentation": "Capabilities specific to the notebook document support.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "WindowClientCapabilities", - "properties": [ - { - "name": "workDoneProgress", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "It indicates whether the client supports server initiated\nprogress using the `window/workDoneProgress/create` request.\n\nThe capability also controls Whether client supports handling\nof progress notifications. If set servers are allowed to report a\n`workDoneProgress` property in the request specific server\ncapabilities.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "showMessage", - "type": { - "kind": "reference", - "name": "ShowMessageRequestClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the showMessage request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "showDocument", - "type": { - "kind": "reference", - "name": "ShowDocumentClientCapabilities" - }, - "optional": true, - "documentation": "Capabilities specific to the showDocument request.\n\n@since 3.16.0", - "since": "3.16.0" - } - ] - }, - { - "name": "GeneralClientCapabilities", - "properties": [ - { - "name": "staleRequestSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "cancel", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "The client will actively cancel the request." - }, - { - "name": "retryOnContentModified", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "documentation": "The list of requests for which the client\nwill retry the request if it receives a\nresponse with error code `ContentModified`" - } - ] - } - }, - "optional": true, - "documentation": "Client capability that signals how the client\nhandles stale requests (e.g. a request\nfor which the client will not process the response\nanymore since the information is outdated).\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "regularExpressions", - "type": { - "kind": "reference", - "name": "RegularExpressionsClientCapabilities" - }, - "optional": true, - "documentation": "Client capabilities specific to regular expressions.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "markdown", - "type": { - "kind": "reference", - "name": "MarkdownClientCapabilities" - }, - "optional": true, - "documentation": "Client capabilities specific to the client's markdown parser.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "positionEncodings", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "PositionEncodingKind" - } - }, - "optional": true, - "documentation": "The position encodings supported by the client. Client and server\nhave to agree on the same position encoding to ensure that offsets\n(e.g. character position in a line) are interpreted the same on both\nsides.\n\nTo keep the protocol backwards compatible the following applies: if\nthe value 'utf-16' is missing from the array of position encodings\nservers can assume that the client supports UTF-16. UTF-16 is\ntherefore a mandatory encoding.\n\nIf omitted it defaults to ['utf-16'].\n\nImplementation considerations: since the conversion from one encoding\ninto another requires the content of the file / line the conversion\nis best done where the file is read which is usually on the server\nside.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "documentation": "General client capabilities.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "RelativePattern", - "properties": [ - { - "name": "baseUri", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "WorkspaceFolder" - }, - { - "kind": "base", - "name": "URI" - } - ] - }, - "documentation": "A workspace folder or a base URI to which this pattern will be matched\nagainst relatively." - }, - { - "name": "pattern", - "type": { - "kind": "reference", - "name": "Pattern" - }, - "documentation": "The actual glob pattern;" - } - ], - "documentation": "A relative pattern is a helper to construct glob patterns that are matched\nrelatively to a base URI. The common value for a `baseUri` is a workspace\nfolder root, but it can be another absolute URI as well.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "WorkspaceEditClientCapabilities", - "properties": [ - { - "name": "documentChanges", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports versioned document changes in `WorkspaceEdit`s" - }, - { - "name": "resourceOperations", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "ResourceOperationKind" - } - }, - "optional": true, - "documentation": "The resource operations the client supports. Clients should at least\nsupport 'create', 'rename' and 'delete' files and folders.\n\n@since 3.13.0", - "since": "3.13.0" - }, - { - "name": "failureHandling", - "type": { - "kind": "reference", - "name": "FailureHandlingKind" - }, - "optional": true, - "documentation": "The failure handling strategy of a client if applying the workspace edit\nfails.\n\n@since 3.13.0", - "since": "3.13.0" - }, - { - "name": "normalizesLineEndings", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client normalizes line endings to the client specific\nsetting.\nIf set to `true` the client will normalize line ending characters\nin a workspace edit to the client-specified new line\ncharacter.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "changeAnnotationSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "groupsOnLabel", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client groups edits with equal labels into tree nodes,\nfor instance all edits labelled with \"Changes in Strings\" would\nbe a tree node." - } - ] - } - }, - "optional": true, - "documentation": "Whether the client in general supports change annotations on text edits,\ncreate file, rename file and delete file changes.\n\n@since 3.16.0", - "since": "3.16.0" - } - ] - }, - { - "name": "DidChangeConfigurationClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Did change configuration notification supports dynamic registration." - } - ] - }, - { - "name": "DidChangeWatchedFilesClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Did change watched files notification supports dynamic registration. Please note\nthat the current protocol doesn't support static configuration for file changes\nfrom the server side." - }, - { - "name": "relativePatternSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client has support for {@link RelativePattern relative pattern}\nor not.\n\n@since 3.17.0", - "since": "3.17.0" - } - ] - }, - { - "name": "WorkspaceSymbolClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Symbol request supports dynamic registration." - }, - { - "name": "symbolKind", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "valueSet", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolKind" - } - }, - "optional": true, - "documentation": "The symbol kind values the client supports. When this\nproperty exists the client also guarantees that it will\nhandle values outside its set gracefully and falls back\nto a default value when unknown.\n\nIf this property is not present the client only supports\nthe symbol kinds from `File` to `Array` as defined in\nthe initial version of the protocol." - } - ] - } - }, - "optional": true, - "documentation": "Specific capabilities for the `SymbolKind` in the `workspace/symbol` request." - }, - { - "name": "tagSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "valueSet", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolTag" - } - }, - "documentation": "The tags supported by the client." - } - ] - } - }, - "optional": true, - "documentation": "The client supports tags on `SymbolInformation`.\nClients supporting tags have to handle unknown tags gracefully.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "resolveSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "properties", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "documentation": "The properties that a client can resolve lazily. Usually\n`location.range`" - } - ] - } - }, - "optional": true, - "documentation": "The client support partial workspace symbols. The client will send the\nrequest `workspaceSymbol/resolve` to the server to resolve additional\nproperties.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "documentation": "Client capabilities for a {@link WorkspaceSymbolRequest}." - }, - { - "name": "ExecuteCommandClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Execute command supports dynamic registration." - } - ], - "documentation": "The client capabilities of a {@link ExecuteCommandRequest}." - }, - { - "name": "SemanticTokensWorkspaceClientCapabilities", - "properties": [ - { - "name": "refreshSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\nsemantic tokens currently shown. It should be used with absolute care\nand is useful for situation where a server for example detects a project\nwide change that requires such a calculation." - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "CodeLensWorkspaceClientCapabilities", - "properties": [ - { - "name": "refreshSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ncode lenses currently shown. It should be used with absolute care and is\nuseful for situation where a server for example detect a project wide\nchange that requires such a calculation." - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "FileOperationClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client supports dynamic registration for file requests/notifications." - }, - { - "name": "didCreate", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client has support for sending didCreateFiles notifications." - }, - { - "name": "willCreate", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client has support for sending willCreateFiles requests." - }, - { - "name": "didRename", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client has support for sending didRenameFiles notifications." - }, - { - "name": "willRename", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client has support for sending willRenameFiles requests." - }, - { - "name": "didDelete", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client has support for sending didDeleteFiles notifications." - }, - { - "name": "willDelete", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client has support for sending willDeleteFiles requests." - } - ], - "documentation": "Capabilities relating to events from file operations by the user in the client.\n\nThese events do not come from the file system, they come from user operations\nlike renaming a file in the UI.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "InlineValueWorkspaceClientCapabilities", - "properties": [ - { - "name": "refreshSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ninline values currently shown. It should be used with absolute care and is\nuseful for situation where a server for example detects a project wide\nchange that requires such a calculation." - } - ], - "documentation": "Client workspace capabilities specific to inline values.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlayHintWorkspaceClientCapabilities", - "properties": [ - { - "name": "refreshSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\ninlay hints currently shown. It should be used with absolute care and\nis useful for situation where a server for example detects a project wide\nchange that requires such a calculation." - } - ], - "documentation": "Client workspace capabilities specific to inlay hints.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DiagnosticWorkspaceClientCapabilities", - "properties": [ - { - "name": "refreshSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\npulled diagnostics currently shown. It should be used with absolute care and\nis useful for situation where a server for example detects a project wide\nchange that requires such a calculation." - } - ], - "documentation": "Workspace client capabilities specific to diagnostic pull requests.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "FoldingRangeWorkspaceClientCapabilities", - "properties": [ - { - "name": "refreshSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\nfolding ranges currently shown. It should be used with absolute care and is\nuseful for situation where a server for example detects a project wide\nchange that requires such a calculation.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - } - ], - "documentation": "Client workspace capabilities specific to folding ranges\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "TextDocumentSyncClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether text document synchronization supports dynamic registration." - }, - { - "name": "willSave", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports sending will save notifications." - }, - { - "name": "willSaveWaitUntil", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports sending a will save request and\nwaits for a response providing text edits which will\nbe applied to the document before it is saved." - }, - { - "name": "didSave", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports did save notifications." - } - ] - }, - { - "name": "CompletionClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether completion supports dynamic registration." - }, - { - "name": "completionItem", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "snippetSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Client supports snippets as insert text.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Placeholders with equal identifiers are linked,\nthat is typing in one will update others too." - }, - { - "name": "commitCharactersSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Client supports commit characters on a completion item." - }, - { - "name": "documentationFormat", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "MarkupKind" - } - }, - "optional": true, - "documentation": "Client supports the following content formats for the documentation\nproperty. The order describes the preferred format of the client." - }, - { - "name": "deprecatedSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Client supports the deprecated property on a completion item." - }, - { - "name": "preselectSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Client supports the preselect property on a completion item." - }, - { - "name": "tagSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "valueSet", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CompletionItemTag" - } - }, - "documentation": "The tags supported by the client." - } - ] - } - }, - "optional": true, - "documentation": "Client supports the tag property on a completion item. Clients supporting\ntags have to handle unknown tags gracefully. Clients especially need to\npreserve unknown tags when sending a completion item back to the server in\na resolve call.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "insertReplaceSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Client support insert replace edit to control different behavior if a\ncompletion item is inserted in the text or should replace text.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "resolveSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "properties", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "documentation": "The properties that a client can resolve lazily." - } - ] - } - }, - "optional": true, - "documentation": "Indicates which properties a client can resolve lazily on a completion\nitem. Before version 3.16.0 only the predefined properties `documentation`\nand `details` could be resolved lazily.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "insertTextModeSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "valueSet", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "InsertTextMode" - } - } - } - ] - } - }, - "optional": true, - "documentation": "The client supports the `insertTextMode` property on\na completion item to override the whitespace handling mode\nas defined by the client (see `insertTextMode`).\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "labelDetailsSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client has support for completion item label\ndetails (see also `CompletionItemLabelDetails`).\n\n@since 3.17.0", - "since": "3.17.0" - } - ] - } - }, - "optional": true, - "documentation": "The client supports the following `CompletionItem` specific\ncapabilities." - }, - { - "name": "completionItemKind", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "valueSet", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CompletionItemKind" - } - }, - "optional": true, - "documentation": "The completion item kind values the client supports. When this\nproperty exists the client also guarantees that it will\nhandle values outside its set gracefully and falls back\nto a default value when unknown.\n\nIf this property is not present the client only supports\nthe completion items kinds from `Text` to `Reference` as defined in\nthe initial version of the protocol." - } - ] - } - }, - "optional": true - }, - { - "name": "insertTextMode", - "type": { - "kind": "reference", - "name": "InsertTextMode" - }, - "optional": true, - "documentation": "Defines how the client handles whitespace and indentation\nwhen accepting a completion item that uses multi line\ntext in either `insertText` or `textEdit`.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "contextSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports to send additional context information for a\n`textDocument/completion` request." - }, - { - "name": "completionList", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "itemDefaults", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "optional": true, - "documentation": "The client supports the following itemDefaults on\na completion list.\n\nThe value lists the supported property names of the\n`CompletionList.itemDefaults` object. If omitted\nno properties are supported.\n\n@since 3.17.0", - "since": "3.17.0" - } - ] - } - }, - "optional": true, - "documentation": "The client supports the following `CompletionList` specific\ncapabilities.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "documentation": "Completion client capabilities" - }, - { - "name": "HoverClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether hover supports dynamic registration." - }, - { - "name": "contentFormat", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "MarkupKind" - } - }, - "optional": true, - "documentation": "Client supports the following content formats for the content\nproperty. The order describes the preferred format of the client." - } - ] - }, - { - "name": "SignatureHelpClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether signature help supports dynamic registration." - }, - { - "name": "signatureInformation", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "documentationFormat", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "MarkupKind" - } - }, - "optional": true, - "documentation": "Client supports the following content formats for the documentation\nproperty. The order describes the preferred format of the client." - }, - { - "name": "parameterInformation", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "labelOffsetSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports processing label offsets instead of a\nsimple label string.\n\n@since 3.14.0", - "since": "3.14.0" - } - ] - } - }, - "optional": true, - "documentation": "Client capabilities specific to parameter information." - }, - { - "name": "activeParameterSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports the `activeParameter` property on `SignatureInformation`\nliteral.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "noActiveParameterSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports the `activeParameter` property on\n`SignatureInformation` being set to `null` to indicate that no\nparameter should be active.\n\n@since 3.18.0", - "since": "3.18.0" - } - ] - } - }, - "optional": true, - "documentation": "The client supports the following `SignatureInformation`\nspecific properties." - }, - { - "name": "contextSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports to send additional context information for a\n`textDocument/signatureHelp` request. A client that opts into\ncontextSupport will also support the `retriggerCharacters` on\n`SignatureHelpOptions`.\n\n@since 3.15.0", - "since": "3.15.0" - } - ], - "documentation": "Client Capabilities for a {@link SignatureHelpRequest}." - }, - { - "name": "DeclarationClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether declaration supports dynamic registration. If this is set to `true`\nthe client supports the new `DeclarationRegistrationOptions` return value\nfor the corresponding server capability as well." - }, - { - "name": "linkSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports additional metadata in the form of declaration links." - } - ], - "documentation": "@since 3.14.0", - "since": "3.14.0" - }, - { - "name": "DefinitionClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether definition supports dynamic registration." - }, - { - "name": "linkSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports additional metadata in the form of definition links.\n\n@since 3.14.0", - "since": "3.14.0" - } - ], - "documentation": "Client Capabilities for a {@link DefinitionRequest}." - }, - { - "name": "TypeDefinitionClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `TypeDefinitionRegistrationOptions` return value\nfor the corresponding server capability as well." - }, - { - "name": "linkSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports additional metadata in the form of definition links.\n\nSince 3.14.0" - } - ], - "documentation": "Since 3.6.0" - }, - { - "name": "ImplementationClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `ImplementationRegistrationOptions` return value\nfor the corresponding server capability as well." - }, - { - "name": "linkSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports additional metadata in the form of definition links.\n\n@since 3.14.0", - "since": "3.14.0" - } - ], - "documentation": "@since 3.6.0", - "since": "3.6.0" - }, - { - "name": "ReferenceClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether references supports dynamic registration." - } - ], - "documentation": "Client Capabilities for a {@link ReferencesRequest}." - }, - { - "name": "DocumentHighlightClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether document highlight supports dynamic registration." - } - ], - "documentation": "Client Capabilities for a {@link DocumentHighlightRequest}." - }, - { - "name": "DocumentSymbolClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether document symbol supports dynamic registration." - }, - { - "name": "symbolKind", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "valueSet", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolKind" - } - }, - "optional": true, - "documentation": "The symbol kind values the client supports. When this\nproperty exists the client also guarantees that it will\nhandle values outside its set gracefully and falls back\nto a default value when unknown.\n\nIf this property is not present the client only supports\nthe symbol kinds from `File` to `Array` as defined in\nthe initial version of the protocol." - } - ] - } - }, - "optional": true, - "documentation": "Specific capabilities for the `SymbolKind` in the\n`textDocument/documentSymbol` request." - }, - { - "name": "hierarchicalDocumentSymbolSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports hierarchical document symbols." - }, - { - "name": "tagSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "valueSet", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "SymbolTag" - } - }, - "documentation": "The tags supported by the client." - } - ] - } - }, - "optional": true, - "documentation": "The client supports tags on `SymbolInformation`. Tags are supported on\n`DocumentSymbol` if `hierarchicalDocumentSymbolSupport` is set to true.\nClients supporting tags have to handle unknown tags gracefully.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "labelSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports an additional label presented in the UI when\nregistering a document symbol provider.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "documentation": "Client Capabilities for a {@link DocumentSymbolRequest}." - }, - { - "name": "CodeActionClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether code action supports dynamic registration." - }, - { - "name": "codeActionLiteralSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "codeActionKind", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "valueSet", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "CodeActionKind" - } - }, - "documentation": "The code action kind values the client supports. When this\nproperty exists the client also guarantees that it will\nhandle values outside its set gracefully and falls back\nto a default value when unknown." - } - ] - } - }, - "documentation": "The code action kind is support with the following value\nset." - } - ] - } - }, - "optional": true, - "documentation": "The client support code action literals of type `CodeAction` as a valid\nresponse of the `textDocument/codeAction` request. If the property is not\nset the request can only return `Command` literals.\n\n@since 3.8.0", - "since": "3.8.0" - }, - { - "name": "isPreferredSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether code action supports the `isPreferred` property.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "disabledSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether code action supports the `disabled` property.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "dataSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether code action supports the `data` property which is\npreserved between a `textDocument/codeAction` and a\n`codeAction/resolve` request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "resolveSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "properties", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "documentation": "The properties that a client can resolve lazily." - } - ] - } - }, - "optional": true, - "documentation": "Whether the client supports resolving additional code action\nproperties via a separate `codeAction/resolve` request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "honorsChangeAnnotations", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\n`CodeAction#edit` property by for example presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "documentation": "The Client Capabilities of a {@link CodeActionRequest}." - }, - { - "name": "CodeLensClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether code lens supports dynamic registration." - } - ], - "documentation": "The client capabilities of a {@link CodeLensRequest}." - }, - { - "name": "DocumentLinkClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether document link supports dynamic registration." - }, - { - "name": "tooltipSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client supports the `tooltip` property on `DocumentLink`.\n\n@since 3.15.0", - "since": "3.15.0" - } - ], - "documentation": "The client capabilities of a {@link DocumentLinkRequest}." - }, - { - "name": "DocumentColorClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `DocumentColorRegistrationOptions` return value\nfor the corresponding server capability as well." - } - ] - }, - { - "name": "DocumentFormattingClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether formatting supports dynamic registration." - } - ], - "documentation": "Client capabilities of a {@link DocumentFormattingRequest}." - }, - { - "name": "DocumentRangeFormattingClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether range formatting supports dynamic registration." - }, - { - "name": "rangesSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client supports formatting multiple ranges at once.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - } - ], - "documentation": "Client capabilities of a {@link DocumentRangeFormattingRequest}." - }, - { - "name": "DocumentOnTypeFormattingClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether on type formatting supports dynamic registration." - } - ], - "documentation": "Client capabilities of a {@link DocumentOnTypeFormattingRequest}." - }, - { - "name": "RenameClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether rename supports dynamic registration." - }, - { - "name": "prepareSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Client supports testing for validity of rename operations\nbefore execution.\n\n@since 3.12.0", - "since": "3.12.0" - }, - { - "name": "prepareSupportDefaultBehavior", - "type": { - "kind": "reference", - "name": "PrepareSupportDefaultBehavior" - }, - "optional": true, - "documentation": "Client supports the default behavior result.\n\nThe value indicates the default behavior used by the\nclient.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "honorsChangeAnnotations", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\nrename request's workspace edit by for example presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", - "since": "3.16.0" - } - ] - }, - { - "name": "FoldingRangeClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration for folding range\nproviders. If this is set to `true` the client supports the new\n`FoldingRangeRegistrationOptions` return value for the corresponding\nserver capability as well." - }, - { - "name": "rangeLimit", - "type": { - "kind": "base", - "name": "uinteger" - }, - "optional": true, - "documentation": "The maximum number of folding ranges that the client prefers to receive\nper document. The value serves as a hint, servers are free to follow the\nlimit." - }, - { - "name": "lineFoldingOnly", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "If set, the client signals that it only supports folding complete lines.\nIf set, client will ignore specified `startCharacter` and `endCharacter`\nproperties in a FoldingRange." - }, - { - "name": "foldingRangeKind", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "valueSet", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "FoldingRangeKind" - } - }, - "optional": true, - "documentation": "The folding range kind values the client supports. When this\nproperty exists the client also guarantees that it will\nhandle values outside its set gracefully and falls back\nto a default value when unknown." - } - ] - } - }, - "optional": true, - "documentation": "Specific options for the folding range kind.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "foldingRange", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "collapsedText", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "If set, the client signals that it supports setting collapsedText on\nfolding ranges to display custom labels instead of the default text.\n\n@since 3.17.0", - "since": "3.17.0" - } - ] - } - }, - "optional": true, - "documentation": "Specific options for the folding range.\n\n@since 3.17.0", - "since": "3.17.0" - } - ] - }, - { - "name": "SelectionRangeClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration for selection range providers. If this is set to `true`\nthe client supports the new `SelectionRangeRegistrationOptions` return value for the corresponding server\ncapability as well." - } - ] - }, - { - "name": "PublishDiagnosticsClientCapabilities", - "properties": [ - { - "name": "relatedInformation", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the clients accepts diagnostics with related information." - }, - { - "name": "tagSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "valueSet", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "DiagnosticTag" - } - }, - "documentation": "The tags supported by the client." - } - ] - } - }, - "optional": true, - "documentation": "Client supports the tag property to provide meta data about a diagnostic.\nClients supporting tags have to handle unknown tags gracefully.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "versionSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client interprets the version property of the\n`textDocument/publishDiagnostics` notification's parameter.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "codeDescriptionSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Client supports a codeDescription property\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "dataSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether code action supports the `data` property which is\npreserved between a `textDocument/publishDiagnostics` and\n`textDocument/codeAction` request.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "documentation": "The publish diagnostic client capabilities." - }, - { - "name": "CallHierarchyClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokensClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." - }, - { - "name": "requests", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "range", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "literal", - "value": { - "properties": [] - } - } - ] - }, - "optional": true, - "documentation": "The client will send the `textDocument/semanticTokens/range` request if\nthe server provides a corresponding handler." - }, - { - "name": "full", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "delta", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client will send the `textDocument/semanticTokens/full/delta` request if\nthe server provides a corresponding handler." - } - ] - } - } - ] - }, - "optional": true, - "documentation": "The client will send the `textDocument/semanticTokens/full` request if\nthe server provides a corresponding handler." - } - ] - } - }, - "documentation": "Which requests the client supports and might send to the server\ndepending on the server's capability. Please note that clients might not\nshow semantic tokens or degrade some of the user experience if a range\nor full request is advertised by the client but not provided by the\nserver. If for example the client capability `requests.full` and\n`request.range` are both set to true but the server only provides a\nrange provider the client might not render a minimap correctly or might\neven decide to not show any semantic tokens at all." - }, - { - "name": "tokenTypes", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "documentation": "The token types that the client supports." - }, - { - "name": "tokenModifiers", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "documentation": "The token modifiers that the client supports." - }, - { - "name": "formats", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "TokenFormat" - } - }, - "documentation": "The token formats the clients supports." - }, - { - "name": "overlappingTokenSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client supports tokens that can overlap each other." - }, - { - "name": "multilineTokenSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client supports tokens that can span multiple lines." - }, - { - "name": "serverCancelSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client allows the server to actively cancel a\nsemantic token request, e.g. supports returning\nLSPErrorCodes.ServerCancelled. If a server does the client\nneeds to retrigger the request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "augmentsSyntaxTokens", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client uses semantic tokens to augment existing\nsyntax tokens. If set to `true` client side created syntax\ntokens and semantic tokens are both used for colorization. If\nset to `false` the client only uses the returned semantic tokens\nfor colorization.\n\nIf the value is `undefined` then the client behavior is not\nspecified.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "documentation": "@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "LinkedEditingRangeClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." - } - ], - "documentation": "Client capabilities for the linked editing range request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "MonikerClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether moniker supports dynamic registration. If this is set to `true`\nthe client supports the new `MonikerRegistrationOptions` return value\nfor the corresponding server capability as well." - } - ], - "documentation": "Client capabilities specific to the moniker request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "TypeHierarchyClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." - } - ], - "documentation": "@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineValueClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration for inline value providers." - } - ], - "documentation": "Client capabilities specific to inline values.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlayHintClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether inlay hints support dynamic registration." - }, - { - "name": "resolveSupport", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "properties", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "documentation": "The properties that a client can resolve lazily." - } - ] - } - }, - "optional": true, - "documentation": "Indicates which properties a client can resolve lazily on an inlay\nhint." - } - ], - "documentation": "Inlay hint client capabilities.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DiagnosticClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." - }, - { - "name": "relatedDocumentSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the clients supports related documents for document diagnostic pulls." - }, - { - "name": "markupMessageSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client supports `MarkupContent` in diagnostic messages.", - "since": "3.18.0", - "proposed": true - } - ], - "documentation": "Client capabilities specific to diagnostic pull requests.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "InlineCompletionClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration for inline completion providers." - } - ], - "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "NotebookDocumentSyncClientCapabilities", - "properties": [ - { - "name": "dynamicRegistration", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether implementation supports dynamic registration. If this is\nset to `true` the client supports the new\n`(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." - }, - { - "name": "executionSummarySupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "The client supports sending execution summary data per cell." - } - ], - "documentation": "Notebook specific client capabilities.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "ShowMessageRequestClientCapabilities", - "properties": [ - { - "name": "messageActionItem", - "type": { - "kind": "literal", - "value": { - "properties": [ - { - "name": "additionalPropertiesSupport", - "type": { - "kind": "base", - "name": "boolean" - }, - "optional": true, - "documentation": "Whether the client supports additional attributes which\nare preserved and send back to the server in the\nrequest's response." - } - ] - } - }, - "optional": true, - "documentation": "Capabilities specific to the `MessageActionItem` type." - } - ], - "documentation": "Show message request client capabilities" - }, - { - "name": "ShowDocumentClientCapabilities", - "properties": [ - { - "name": "support", - "type": { - "kind": "base", - "name": "boolean" - }, - "documentation": "The client has support for the showDocument\nrequest." - } - ], - "documentation": "Client capabilities for the showDocument request.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "RegularExpressionsClientCapabilities", - "properties": [ - { - "name": "engine", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The engine's name." - }, - { - "name": "version", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The engine's version." - } - ], - "documentation": "Client capabilities specific to regular expressions.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "MarkdownClientCapabilities", - "properties": [ - { - "name": "parser", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The name of the parser." - }, - { - "name": "version", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The version of the parser." - }, - { - "name": "allowedTags", - "type": { - "kind": "array", - "element": { - "kind": "base", - "name": "string" - } - }, - "optional": true, - "documentation": "A list of HTML tags that the client allows / supports in\nMarkdown.\n\n@since 3.17.0", - "since": "3.17.0" - } - ], - "documentation": "Client capabilities specific to the used markdown parser.\n\n@since 3.16.0", - "since": "3.16.0" - } - ], - "enumerations": [ - { - "name": "SemanticTokenTypes", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "namespace", - "value": "namespace" - }, - { - "name": "type", - "value": "type", - "documentation": "Represents a generic type. Acts as a fallback for types which can't be mapped to\na specific type like class or enum." - }, - { - "name": "class", - "value": "class" - }, - { - "name": "enum", - "value": "enum" - }, - { - "name": "interface", - "value": "interface" - }, - { - "name": "struct", - "value": "struct" - }, - { - "name": "typeParameter", - "value": "typeParameter" - }, - { - "name": "parameter", - "value": "parameter" - }, - { - "name": "variable", - "value": "variable" - }, - { - "name": "property", - "value": "property" - }, - { - "name": "enumMember", - "value": "enumMember" - }, - { - "name": "event", - "value": "event" - }, - { - "name": "function", - "value": "function" - }, - { - "name": "method", - "value": "method" - }, - { - "name": "macro", - "value": "macro" - }, - { - "name": "keyword", - "value": "keyword" - }, - { - "name": "modifier", - "value": "modifier" - }, - { - "name": "comment", - "value": "comment" - }, - { - "name": "string", - "value": "string" - }, - { - "name": "number", - "value": "number" - }, - { - "name": "regexp", - "value": "regexp" - }, - { - "name": "operator", - "value": "operator" - }, - { - "name": "decorator", - "value": "decorator", - "documentation": "@since 3.17.0", - "since": "3.17.0" - } - ], - "supportsCustomValues": true, - "documentation": "A set of predefined token types. This set is not fixed\nan clients can specify additional token types via the\ncorresponding client capabilities.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "SemanticTokenModifiers", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "declaration", - "value": "declaration" - }, - { - "name": "definition", - "value": "definition" - }, - { - "name": "readonly", - "value": "readonly" - }, - { - "name": "static", - "value": "static" - }, - { - "name": "deprecated", - "value": "deprecated" - }, - { - "name": "abstract", - "value": "abstract" - }, - { - "name": "async", - "value": "async" - }, - { - "name": "modification", - "value": "modification" - }, - { - "name": "documentation", - "value": "documentation" - }, - { - "name": "defaultLibrary", - "value": "defaultLibrary" - } - ], - "supportsCustomValues": true, - "documentation": "A set of predefined token modifiers. This set is not fixed\nan clients can specify additional token types via the\ncorresponding client capabilities.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "DocumentDiagnosticReportKind", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "Full", - "value": "full", - "documentation": "A diagnostic report with a full\nset of problems." - }, - { - "name": "Unchanged", - "value": "unchanged", - "documentation": "A report indicating that the last\nreturned report is still accurate." - } - ], - "documentation": "The document diagnostic report kinds.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "ErrorCodes", - "type": { - "kind": "base", - "name": "integer" - }, - "values": [ - { - "name": "ParseError", - "value": -32700 - }, - { - "name": "InvalidRequest", - "value": -32600 - }, - { - "name": "MethodNotFound", - "value": -32601 - }, - { - "name": "InvalidParams", - "value": -32602 - }, - { - "name": "InternalError", - "value": -32603 - }, - { - "name": "ServerNotInitialized", - "value": -32002, - "documentation": "Error code indicating that a server received a notification or\nrequest before the server has received the `initialize` request." - }, - { - "name": "UnknownErrorCode", - "value": -32001 - } - ], - "supportsCustomValues": true, - "documentation": "Predefined error codes." - }, - { - "name": "LSPErrorCodes", - "type": { - "kind": "base", - "name": "integer" - }, - "values": [ - { - "name": "RequestFailed", - "value": -32803, - "documentation": "A request failed but it was syntactically correct, e.g the\nmethod name was known and the parameters were valid. The error\nmessage should contain human readable information about why\nthe request failed.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "ServerCancelled", - "value": -32802, - "documentation": "The server cancelled the request. This error code should\nonly be used for requests that explicitly support being\nserver cancellable.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "ContentModified", - "value": -32801, - "documentation": "The server detected that the content of a document got\nmodified outside normal conditions. A server should\nNOT send this error code if it detects a content change\nin it unprocessed messages. The result even computed\non an older state might still be useful for the client.\n\nIf a client decides that a result is not of any use anymore\nthe client should cancel the request." - }, - { - "name": "RequestCancelled", - "value": -32800, - "documentation": "The client has canceled a request and a server has detected\nthe cancel." - } - ], - "supportsCustomValues": true - }, - { - "name": "FoldingRangeKind", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "Comment", - "value": "comment", - "documentation": "Folding range for a comment" - }, - { - "name": "Imports", - "value": "imports", - "documentation": "Folding range for an import or include" - }, - { - "name": "Region", - "value": "region", - "documentation": "Folding range for a region (e.g. `#region`)" - } - ], - "supportsCustomValues": true, - "documentation": "A set of predefined range kinds." - }, - { - "name": "SymbolKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "File", - "value": 1 - }, - { - "name": "Module", - "value": 2 - }, - { - "name": "Namespace", - "value": 3 - }, - { - "name": "Package", - "value": 4 - }, - { - "name": "Class", - "value": 5 - }, - { - "name": "Method", - "value": 6 - }, - { - "name": "Property", - "value": 7 - }, - { - "name": "Field", - "value": 8 - }, - { - "name": "Constructor", - "value": 9 - }, - { - "name": "Enum", - "value": 10 - }, - { - "name": "Interface", - "value": 11 - }, - { - "name": "Function", - "value": 12 - }, - { - "name": "Variable", - "value": 13 - }, - { - "name": "Constant", - "value": 14 - }, - { - "name": "String", - "value": 15 - }, - { - "name": "Number", - "value": 16 - }, - { - "name": "Boolean", - "value": 17 - }, - { - "name": "Array", - "value": 18 - }, - { - "name": "Object", - "value": 19 - }, - { - "name": "Key", - "value": 20 - }, - { - "name": "Null", - "value": 21 - }, - { - "name": "EnumMember", - "value": 22 - }, - { - "name": "Struct", - "value": 23 - }, - { - "name": "Event", - "value": 24 - }, - { - "name": "Operator", - "value": 25 - }, - { - "name": "TypeParameter", - "value": 26 - } - ], - "documentation": "A symbol kind." - }, - { - "name": "SymbolTag", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Deprecated", - "value": 1, - "documentation": "Render a symbol as obsolete, usually using a strike-out." - } - ], - "documentation": "Symbol tags are extra annotations that tweak the rendering of a symbol.\n\n@since 3.16", - "since": "3.16" - }, - { - "name": "UniquenessLevel", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "document", - "value": "document", - "documentation": "The moniker is only unique inside a document" - }, - { - "name": "project", - "value": "project", - "documentation": "The moniker is unique inside a project for which a dump got created" - }, - { - "name": "group", - "value": "group", - "documentation": "The moniker is unique inside the group to which a project belongs" - }, - { - "name": "scheme", - "value": "scheme", - "documentation": "The moniker is unique inside the moniker scheme." - }, - { - "name": "global", - "value": "global", - "documentation": "The moniker is globally unique" - } - ], - "documentation": "Moniker uniqueness level to define scope of the moniker.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "MonikerKind", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "import", - "value": "import", - "documentation": "The moniker represent a symbol that is imported into a project" - }, - { - "name": "export", - "value": "export", - "documentation": "The moniker represents a symbol that is exported from a project" - }, - { - "name": "local", - "value": "local", - "documentation": "The moniker represents a symbol that is local to a project (e.g. a local\nvariable of a function, a class not visible outside the project, ...)" - } - ], - "documentation": "The moniker kind.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "InlayHintKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Type", - "value": 1, - "documentation": "An inlay hint that for a type annotation." - }, - { - "name": "Parameter", - "value": 2, - "documentation": "An inlay hint that is for a parameter." - } - ], - "documentation": "Inlay hint kinds.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "MessageType", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Error", - "value": 1, - "documentation": "An error message." - }, - { - "name": "Warning", - "value": 2, - "documentation": "A warning message." - }, - { - "name": "Info", - "value": 3, - "documentation": "An information message." - }, - { - "name": "Log", - "value": 4, - "documentation": "A log message." - }, - { - "name": "Debug", - "value": 5, - "documentation": "A debug message.\n\n@since 3.18.0", - "since": "3.18.0" - } - ], - "documentation": "The message type" - }, - { - "name": "TextDocumentSyncKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "None", - "value": 0, - "documentation": "Documents should not be synced at all." - }, - { - "name": "Full", - "value": 1, - "documentation": "Documents are synced by always sending the full content\nof the document." - }, - { - "name": "Incremental", - "value": 2, - "documentation": "Documents are synced by sending the full content on open.\nAfter that only incremental updates to the document are\nsend." - } - ], - "documentation": "Defines how the host (editor) should sync\ndocument changes to the language server." - }, - { - "name": "TextDocumentSaveReason", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Manual", - "value": 1, - "documentation": "Manually triggered, e.g. by the user pressing save, by starting debugging,\nor by an API call." - }, - { - "name": "AfterDelay", - "value": 2, - "documentation": "Automatic after a delay." - }, - { - "name": "FocusOut", - "value": 3, - "documentation": "When the editor lost focus." - } - ], - "documentation": "Represents reasons why a text document is saved." - }, - { - "name": "CompletionItemKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Text", - "value": 1 - }, - { - "name": "Method", - "value": 2 - }, - { - "name": "Function", - "value": 3 - }, - { - "name": "Constructor", - "value": 4 - }, - { - "name": "Field", - "value": 5 - }, - { - "name": "Variable", - "value": 6 - }, - { - "name": "Class", - "value": 7 - }, - { - "name": "Interface", - "value": 8 - }, - { - "name": "Module", - "value": 9 - }, - { - "name": "Property", - "value": 10 - }, - { - "name": "Unit", - "value": 11 - }, - { - "name": "Value", - "value": 12 - }, - { - "name": "Enum", - "value": 13 - }, - { - "name": "Keyword", - "value": 14 - }, - { - "name": "Snippet", - "value": 15 - }, - { - "name": "Color", - "value": 16 - }, - { - "name": "File", - "value": 17 - }, - { - "name": "Reference", - "value": 18 - }, - { - "name": "Folder", - "value": 19 - }, - { - "name": "EnumMember", - "value": 20 - }, - { - "name": "Constant", - "value": 21 - }, - { - "name": "Struct", - "value": 22 - }, - { - "name": "Event", - "value": 23 - }, - { - "name": "Operator", - "value": 24 - }, - { - "name": "TypeParameter", - "value": 25 - } - ], - "documentation": "The kind of a completion entry." - }, - { - "name": "CompletionItemTag", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Deprecated", - "value": 1, - "documentation": "Render a completion as obsolete, usually using a strike-out." - } - ], - "documentation": "Completion item tags are extra annotations that tweak the rendering of a completion\nitem.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "InsertTextFormat", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "PlainText", - "value": 1, - "documentation": "The primary text to be inserted is treated as a plain string." - }, - { - "name": "Snippet", - "value": 2, - "documentation": "The primary text to be inserted is treated as a snippet.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Placeholders with equal identifiers are linked,\nthat is typing in one will update others too.\n\nSee also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax" - } - ], - "documentation": "Defines whether the insert text in a completion item should be interpreted as\nplain text or a snippet." - }, - { - "name": "InsertTextMode", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "asIs", - "value": 1, - "documentation": "The insertion or replace strings is taken as it is. If the\nvalue is multi line the lines below the cursor will be\ninserted using the indentation defined in the string value.\nThe client will not apply any kind of adjustments to the\nstring." - }, - { - "name": "adjustIndentation", - "value": 2, - "documentation": "The editor adjusts leading whitespace of new lines so that\nthey match the indentation up to the cursor of the line for\nwhich the item is accepted.\n\nConsider a line like this: <2tabs><3tabs>foo. Accepting a\nmulti line completion item is indented using 2 tabs and all\nfollowing lines inserted will be indented using 2 tabs as well." - } - ], - "documentation": "How whitespace and indentation is handled during completion\nitem insertion.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "DocumentHighlightKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Text", - "value": 1, - "documentation": "A textual occurrence." - }, - { - "name": "Read", - "value": 2, - "documentation": "Read-access of a symbol, like reading a variable." - }, - { - "name": "Write", - "value": 3, - "documentation": "Write-access of a symbol, like writing to a variable." - } - ], - "documentation": "A document highlight kind." - }, - { - "name": "CodeActionKind", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "Empty", - "value": "", - "documentation": "Empty kind." - }, - { - "name": "QuickFix", - "value": "quickfix", - "documentation": "Base kind for quickfix actions: 'quickfix'" - }, - { - "name": "Refactor", - "value": "refactor", - "documentation": "Base kind for refactoring actions: 'refactor'" - }, - { - "name": "RefactorExtract", - "value": "refactor.extract", - "documentation": "Base kind for refactoring extraction actions: 'refactor.extract'\n\nExample extract actions:\n\n- Extract method\n- Extract function\n- Extract variable\n- Extract interface from class\n- ..." - }, - { - "name": "RefactorInline", - "value": "refactor.inline", - "documentation": "Base kind for refactoring inline actions: 'refactor.inline'\n\nExample inline actions:\n\n- Inline function\n- Inline variable\n- Inline constant\n- ..." - }, - { - "name": "RefactorRewrite", - "value": "refactor.rewrite", - "documentation": "Base kind for refactoring rewrite actions: 'refactor.rewrite'\n\nExample rewrite actions:\n\n- Convert JavaScript function to class\n- Add or remove parameter\n- Encapsulate field\n- Make method static\n- Move method to base class\n- ..." - }, - { - "name": "Source", - "value": "source", - "documentation": "Base kind for source actions: `source`\n\nSource code actions apply to the entire file." - }, - { - "name": "SourceOrganizeImports", - "value": "source.organizeImports", - "documentation": "Base kind for an organize imports source action: `source.organizeImports`" - }, - { - "name": "SourceFixAll", - "value": "source.fixAll", - "documentation": "Base kind for auto-fix source actions: `source.fixAll`.\n\nFix all actions automatically fix errors that have a clear fix that do not require user input.\nThey should not suppress errors or perform unsafe fixes such as generating new types or classes.\n\n@since 3.15.0", - "since": "3.15.0" - } - ], - "supportsCustomValues": true, - "documentation": "A set of predefined code action kinds" - }, - { - "name": "TraceValues", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "Off", - "value": "off", - "documentation": "Turn tracing off." - }, - { - "name": "Messages", - "value": "messages", - "documentation": "Trace messages only." - }, - { - "name": "Verbose", - "value": "verbose", - "documentation": "Verbose message tracing." - } - ] - }, - { - "name": "MarkupKind", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "PlainText", - "value": "plaintext", - "documentation": "Plain text is supported as a content format" - }, - { - "name": "Markdown", - "value": "markdown", - "documentation": "Markdown is supported as a content format" - } - ], - "documentation": "Describes the content type that a client supports in various\nresult literals like `Hover`, `ParameterInfo` or `CompletionItem`.\n\nPlease note that `MarkupKinds` must not start with a `$`. This kinds\nare reserved for internal usage." - }, - { - "name": "InlineCompletionTriggerKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Invoked", - "value": 0, - "documentation": "Completion was triggered explicitly by a user gesture." - }, - { - "name": "Automatic", - "value": 1, - "documentation": "Completion was triggered automatically while editing." - } - ], - "documentation": "Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.\n\n@since 3.18.0\n@proposed", - "since": "3.18.0", - "proposed": true - }, - { - "name": "PositionEncodingKind", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "UTF8", - "value": "utf-8", - "documentation": "Character offsets count UTF-8 code units (e.g. bytes)." - }, - { - "name": "UTF16", - "value": "utf-16", - "documentation": "Character offsets count UTF-16 code units.\n\nThis is the default and must always be supported\nby servers" - }, - { - "name": "UTF32", - "value": "utf-32", - "documentation": "Character offsets count UTF-32 code units.\n\nImplementation note: these are the same as Unicode codepoints,\nso this `PositionEncodingKind` may also be used for an\nencoding-agnostic representation of character offsets." - } - ], - "supportsCustomValues": true, - "documentation": "A set of predefined position encoding kinds.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "FileChangeType", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Created", - "value": 1, - "documentation": "The file got created." - }, - { - "name": "Changed", - "value": 2, - "documentation": "The file got changed." - }, - { - "name": "Deleted", - "value": 3, - "documentation": "The file got deleted." - } - ], - "documentation": "The file event type" - }, - { - "name": "WatchKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Create", - "value": 1, - "documentation": "Interested in create events." - }, - { - "name": "Change", - "value": 2, - "documentation": "Interested in change events" - }, - { - "name": "Delete", - "value": 4, - "documentation": "Interested in delete events" - } - ], - "supportsCustomValues": true - }, - { - "name": "DiagnosticSeverity", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Error", - "value": 1, - "documentation": "Reports an error." - }, - { - "name": "Warning", - "value": 2, - "documentation": "Reports a warning." - }, - { - "name": "Information", - "value": 3, - "documentation": "Reports an information." - }, - { - "name": "Hint", - "value": 4, - "documentation": "Reports a hint." - } - ], - "documentation": "The diagnostic's severity." - }, - { - "name": "DiagnosticTag", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Unnecessary", - "value": 1, - "documentation": "Unused or unnecessary code.\n\nClients are allowed to render diagnostics with this tag faded out instead of having\nan error squiggle." - }, - { - "name": "Deprecated", - "value": 2, - "documentation": "Deprecated or obsolete code.\n\nClients are allowed to rendered diagnostics with this tag strike through." - } - ], - "documentation": "The diagnostic tags.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "CompletionTriggerKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Invoked", - "value": 1, - "documentation": "Completion was triggered by typing an identifier (24x7 code\ncomplete), manual invocation (e.g Ctrl+Space) or via API." - }, - { - "name": "TriggerCharacter", - "value": 2, - "documentation": "Completion was triggered by a trigger character specified by\nthe `triggerCharacters` properties of the `CompletionRegistrationOptions`." - }, - { - "name": "TriggerForIncompleteCompletions", - "value": 3, - "documentation": "Completion was re-triggered as current completion list is incomplete" - } - ], - "documentation": "How a completion was triggered" - }, - { - "name": "SignatureHelpTriggerKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Invoked", - "value": 1, - "documentation": "Signature help was invoked manually by the user or by a command." - }, - { - "name": "TriggerCharacter", - "value": 2, - "documentation": "Signature help was triggered by a trigger character." - }, - { - "name": "ContentChange", - "value": 3, - "documentation": "Signature help was triggered by the cursor moving or by the document content changing." - } - ], - "documentation": "How a signature help was triggered.\n\n@since 3.15.0", - "since": "3.15.0" - }, - { - "name": "CodeActionTriggerKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Invoked", - "value": 1, - "documentation": "Code actions were explicitly requested by the user or by an extension." - }, - { - "name": "Automatic", - "value": 2, - "documentation": "Code actions were requested automatically.\n\nThis typically happens when current selection in a file changes, but can\nalso be triggered when file content changes." - } - ], - "documentation": "The reason why code actions were requested.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "FileOperationPatternKind", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "file", - "value": "file", - "documentation": "The pattern matches a file only." - }, - { - "name": "folder", - "value": "folder", - "documentation": "The pattern matches a folder only." - } - ], - "documentation": "A pattern kind describing if a glob pattern matches a file a folder or\nboth.\n\n@since 3.16.0", - "since": "3.16.0" - }, - { - "name": "NotebookCellKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Markup", - "value": 1, - "documentation": "A markup-cell is formatted source that is used for display." - }, - { - "name": "Code", - "value": 2, - "documentation": "A code-cell is source code." - } - ], - "documentation": "A notebook cell kind.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "ResourceOperationKind", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "Create", - "value": "create", - "documentation": "Supports creating new files and folders." - }, - { - "name": "Rename", - "value": "rename", - "documentation": "Supports renaming existing files and folders." - }, - { - "name": "Delete", - "value": "delete", - "documentation": "Supports deleting existing files and folders." - } - ] - }, - { - "name": "FailureHandlingKind", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "Abort", - "value": "abort", - "documentation": "Applying the workspace change is simply aborted if one of the changes provided\nfails. All operations executed before the failing operation stay executed." - }, - { - "name": "Transactional", - "value": "transactional", - "documentation": "All operations are executed transactional. That means they either all\nsucceed or no changes at all are applied to the workspace." - }, - { - "name": "TextOnlyTransactional", - "value": "textOnlyTransactional", - "documentation": "If the workspace edit contains only textual file changes they are executed transactional.\nIf resource changes (create, rename or delete file) are part of the change the failure\nhandling strategy is abort." - }, - { - "name": "Undo", - "value": "undo", - "documentation": "The client tries to undo the operations already executed. But there is no\nguarantee that this is succeeding." - } - ] - }, - { - "name": "PrepareSupportDefaultBehavior", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Identifier", - "value": 1, - "documentation": "The client's default behavior is to select the identifier\naccording the to language's syntax rule." - } - ] - }, - { - "name": "TokenFormat", - "type": { - "kind": "base", - "name": "string" - }, - "values": [ - { - "name": "Relative", - "value": "relative" - } - ] - } - ], - "typeAliases": [ - { - "name": "Definition", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Location" - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "Location" - } - } - ] - }, - "documentation": "The definition of a symbol represented as one or many {@link Location locations}.\nFor most programming languages there is only one location at which a symbol is\ndefined.\n\nServers should prefer returning `DefinitionLink` over `Definition` if supported\nby the client." - }, - { - "name": "DefinitionLink", - "type": { - "kind": "reference", - "name": "LocationLink" - }, - "documentation": "Information about where a symbol is defined.\n\nProvides additional metadata over normal {@link Location location} definitions, including the range of\nthe defining symbol" - }, - { - "name": "LSPArray", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "LSPAny" - } - }, - "documentation": "LSP arrays.\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "LSPAny", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "LSPObject" - }, - { - "kind": "reference", - "name": "LSPArray" - }, - { - "kind": "base", - "name": "string" - }, - { - "kind": "base", - "name": "integer" - }, - { - "kind": "base", - "name": "uinteger" - }, - { - "kind": "base", - "name": "decimal" - }, - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "documentation": "The LSP any type.\nPlease note that strictly speaking a property with the value `undefined`\ncan't be converted into JSON preserving the property name. However for\nconvenience it is allowed and assumed that all these properties are\noptional as well.\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "Declaration", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Location" - }, - { - "kind": "array", - "element": { - "kind": "reference", - "name": "Location" - } - } - ] - }, - "documentation": "The declaration of a symbol representation as one or many {@link Location locations}." - }, - { - "name": "DeclarationLink", - "type": { - "kind": "reference", - "name": "LocationLink" - }, - "documentation": "Information about where a symbol is declared.\n\nProvides additional metadata over normal {@link Location location} declarations, including the range of\nthe declaring symbol.\n\nServers should prefer returning `DeclarationLink` over `Declaration` if supported\nby the client." - }, - { - "name": "InlineValue", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "InlineValueText" - }, - { - "kind": "reference", - "name": "InlineValueVariableLookup" - }, - { - "kind": "reference", - "name": "InlineValueEvaluatableExpression" - } - ] - }, - "documentation": "Inline value information can be provided by different means:\n- directly as a text value (class InlineValueText).\n- as a name to use for a variable lookup (class InlineValueVariableLookup)\n- as an evaluatable expression (class InlineValueEvaluatableExpression)\nThe InlineValue types combines all inline value types into one type.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "DocumentDiagnosticReport", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "RelatedFullDocumentDiagnosticReport" - }, - { - "kind": "reference", - "name": "RelatedUnchangedDocumentDiagnosticReport" - } - ] - }, - "documentation": "The result of a document diagnostic pull request. A report can\neither be a full report containing all diagnostics for the\nrequested document or an unchanged report indicating that nothing\nhas changed in terms of diagnostics in comparison to the last\npull request.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "PrepareRenameResult", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Range" - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - } - }, - { - "name": "placeholder", - "type": { - "kind": "base", - "name": "string" - } - } - ] - } - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "defaultBehavior", - "type": { - "kind": "base", - "name": "boolean" - } - } - ] - } - } - ] - } - }, - { - "name": "DocumentSelector", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "DocumentFilter" - } - }, - "documentation": "A document selector is the combination of one or many document filters.\n\n@sample `let sel:DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**∕tsconfig.json' }]`;\n\nThe use of a string as a document filter is deprecated @since 3.16.0.", - "since": "3.16.0." - }, - { - "name": "ProgressToken", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "integer" - }, - { - "kind": "base", - "name": "string" - } - ] - } - }, - { - "name": "ChangeAnnotationIdentifier", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "An identifier to refer to a change annotation stored with a workspace edit." - }, - { - "name": "WorkspaceDocumentDiagnosticReport", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "WorkspaceFullDocumentDiagnosticReport" - }, - { - "kind": "reference", - "name": "WorkspaceUnchangedDocumentDiagnosticReport" - } - ] - }, - "documentation": "A workspace diagnostic document report.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "TextDocumentContentChangeEvent", - "type": { - "kind": "or", - "items": [ - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range of the document that changed." - }, - { - "name": "rangeLength", - "type": { - "kind": "base", - "name": "uinteger" - }, - "optional": true, - "documentation": "The optional length of the range that got replaced.\n\n@deprecated use range instead." - }, - { - "name": "text", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The new text for the provided range." - } - ] - } - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "text", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The new text of the whole document." - } - ] - } - } - ] - }, - "documentation": "An event describing a change to a text document. If only a text is provided\nit is considered to be the full content of the document." - }, - { - "name": "MarkedString", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "string" - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "language", - "type": { - "kind": "base", - "name": "string" - } - }, - { - "name": "value", - "type": { - "kind": "base", - "name": "string" - } - } - ] - } - } - ] - }, - "documentation": "MarkedString can be used to render human readable text. It is either a markdown string\nor a code-block that provides a language and a code snippet. The language identifier\nis semantically equal to the optional language identifier in fenced code blocks in GitHub\nissues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting\n\nThe pair of a language and a value is an equivalent to markdown:\n```${language}\n${value}\n```\n\nNote that markdown strings will be sanitized - that means html will be escaped.\n@deprecated use MarkupContent instead.", - "deprecated": "use MarkupContent instead." - }, - { - "name": "DocumentFilter", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "TextDocumentFilter" - }, - { - "kind": "reference", - "name": "NotebookCellTextDocumentFilter" - } - ] - }, - "documentation": "A document filter describes a top level text document or\na notebook cell document.\n\n@since 3.17.0 - proposed support for NotebookCellTextDocumentFilter.", - "since": "3.17.0 - proposed support for NotebookCellTextDocumentFilter." - }, - { - "name": "LSPObject", - "type": { - "kind": "map", - "key": { - "kind": "base", - "name": "string" - }, - "value": { - "kind": "reference", - "name": "LSPAny" - } - }, - "documentation": "LSP object definition.\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "GlobPattern", - "type": { - "kind": "or", - "items": [ - { - "kind": "reference", - "name": "Pattern" - }, - { - "kind": "reference", - "name": "RelativePattern" - } - ] - }, - "documentation": "The glob pattern. Either a string pattern or a relative pattern.\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "TextDocumentFilter", - "type": { - "kind": "or", - "items": [ - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "language", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A language id, like `typescript`." - }, - { - "name": "scheme", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." - }, - { - "name": "pattern", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples." - } - ] - } - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "language", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A language id, like `typescript`." - }, - { - "name": "scheme", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." - }, - { - "name": "pattern", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples." - } - ] - } - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "language", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A language id, like `typescript`." - }, - { - "name": "scheme", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." - }, - { - "name": "pattern", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples." - } - ] - } - } - ] - }, - "documentation": "A document filter denotes a document by different properties like\nthe {@link TextDocument.languageId language}, the {@link Uri.scheme scheme} of\nits resource, or a glob-pattern that is applied to the {@link TextDocument.fileName path}.\n\nGlob patterns can have the following syntax:\n- `*` to match one or more characters in a path segment\n- `?` to match on one character in a path segment\n- `**` to match any number of path segments, including none\n- `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)\n- `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)\n- `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)\n\n@sample A language filter that applies to typescript files on disk: `{ language: 'typescript', scheme: 'file' }`\n@sample A language filter that applies to all package.json paths: `{ language: 'json', pattern: '**package.json' }`\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "NotebookDocumentFilter", - "type": { - "kind": "or", - "items": [ - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "notebookType", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The type of the enclosing notebook." - }, - { - "name": "scheme", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." - }, - { - "name": "pattern", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A glob pattern." - } - ] - } - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "notebookType", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The type of the enclosing notebook." - }, - { - "name": "scheme", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." - }, - { - "name": "pattern", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A glob pattern." - } - ] - } - }, - { - "kind": "literal", - "value": { - "properties": [ - { - "name": "notebookType", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "The type of the enclosing notebook." - }, - { - "name": "scheme", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." - }, - { - "name": "pattern", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "A glob pattern." - } - ] - } - } - ] - }, - "documentation": "A notebook document filter denotes a notebook document by\ndifferent properties. The properties will be match\nagainst the notebook's URI (same as with documents)\n\n@since 3.17.0", - "since": "3.17.0" - }, - { - "name": "Pattern", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The glob pattern to watch relative to the base path. Glob patterns can have the following syntax:\n- `*` to match one or more characters in a path segment\n- `?` to match on one character in a path segment\n- `**` to match any number of path segments, including none\n- `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)\n- `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)\n- `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)\n\n@since 3.17.0", - "since": "3.17.0" - } - ] -} diff --git a/lsp/bin/metamodel/metamodel.ml b/lsp/bin/metamodel/metamodel.ml deleted file mode 100644 index 7164d35bc..000000000 --- a/lsp/bin/metamodel/metamodel.ml +++ /dev/null @@ -1,458 +0,0 @@ -open Stdune - -type doc = - { since : string option - ; documentation : string option - } - -type baseType = - | Uri - | DocumentUri - | Integer - | Uinteger - | Decimal - | RegExp - | String - | Boolean - | Null - -type mapKeyType = - | Uri - | DocumentUri - | String - | Integer - | Reference of string - -type literalType = - | String of string - | Boolean of bool - | Integer of int - | Record of property list - -and property = - { doc : doc - ; name : string - ; optional : bool - ; type_ : type_ - } - -and mapType = - { key : mapKeyType - ; value : type_ - } - -and type_ = - | Base of baseType - | Reference of string - | Array of type_ - | Or of type_ list - | And of type_ list - | Tuple of type_ list - | Literal of literalType - | Map of mapType - -type typeAlias = - { name : string - ; type_ : type_ - ; doc : doc - } - -type enumerationEntry = - { name : string - ; value : [ `String of string | `Int of int ] - ; doc : doc - } - -type enumerationType = { name : [ `String | `Integer | `Uinteger ] } - -type enumeration = - { doc : doc - ; name : string - ; supportsCustomValues : bool - ; type_ : enumerationType - ; values : enumerationEntry list - } - -type structure = - { doc : doc - ; extends : type_ list - ; mixins : type_ list - ; name : string - ; properties : property list - } - -type call = - { method_ : string - ; params : [ `Param of type_ | `Params of type_ list ] option - ; registrationOptions : type_ option - ; doc : doc - } - -type request = - { call : call - ; errorData : type_ option - ; partialResult : type_ option - ; result : type_ - } - -type notification = { call : call } - -type t = - { requests : request list - ; notifications : notification list - ; structures : structure list - ; enumerations : enumeration list - ; typeAliases : typeAlias list - } - -let error msg json = failwith (msg ^ "\n" ^ Yojson.Safe.pretty_to_string ~std:false json) - -let fields = function - | `Assoc xs -> xs - | xs -> error "expected fields" xs -;; - -let field ?default (name : string) p fields = - match List.assoc fields name with - | Some f -> p f - | None -> - (match default with - | None -> error ("field not found " ^ name) (`Assoc fields) - | Some x -> x) -;; - -let field_o name p fields = - match List.assoc fields name with - | None -> None - | Some f -> Some (p f) -;; - -let bool = function - | `Bool b -> b - | json -> error "boolean expected" json -;; - -let literal lit json = if not (Poly.equal json lit) then error "unexpected literal" json - -let enum variants json = - match json with - | `String s -> - (match List.assoc variants s with - | None -> error "not a valid enum value" json - | Some v -> v) - | _ -> error "not a valid enum value" json -;; - -let string = function - | `String s -> s - | json -> error "expected string" json -;; - -let string_or_number = function - | `String s -> `String s - | `Int i -> `Int i - | json -> error "expected string or number" json -;; - -let name fields = field "name" string fields - -let list conv = function - | `List xs -> List.map xs ~f:conv - | json -> error "expected list" json -;; - -let baseType json : baseType = - match json with - | `String s -> - (match s with - | "URI" | "Uri" -> Uri - | "DocumentUri" -> DocumentUri - | "integer" -> Integer - | "uinteger" -> Uinteger - | "decimal" -> Decimal - | "RegExp" -> RegExp - | "string" -> String - | "boolean" -> Boolean - | "null" -> Null - | _ -> error "unknown base type" json) - | _ -> error "unknown base type" json -;; - -let mapKeyType json : mapKeyType = - let fields = fields json in - let kind = field "kind" string fields in - match kind with - | "reference" -> Reference (name fields) - | "base" -> - field - "name" - (enum - [ "Uri", Uri - ; "URI", Uri - ; "DocumentUri", DocumentUri - ; "string", String - ; "integer", Integer - ]) - fields - | kind -> error ("invalid kind for map key type: " ^ kind) json -;; - -let doc fields = - let since = field_o "since" string fields in - let documentation = field_o "documentation" string fields in - { since; documentation } -;; - -let rec type_ json = - let fields_conv = fields in - let fields = fields json in - let kind = field "kind" string fields in - match kind with - | "reference" -> Reference (name fields) - | "array" -> - let element = field "element" type_ fields in - Array element - | "base" -> - let b = field "name" baseType fields in - Base b - | "or" -> - let items = field "items" (list type_) fields in - Or items - | "and" -> - let items = field "items" (list type_) fields in - And items - | "tuple" -> - let items = field "items" (list type_) fields in - Tuple items - | "stringLiteral" -> - let value = field "value" string fields in - Literal (String value) - | "map" -> - let key = field "key" mapKeyType fields in - let value = field "value" type_ fields in - Map { key; value } - | "literal" -> - let fields = - field - "value" - (fun json -> - let fields = fields_conv json in - properties fields) - fields - in - Literal (Record fields) - | kind -> error "unrecognized kind" (`String kind) - -and properties fields : property list = field "properties" (list property) fields - -and property json : property = - let fields = fields json in - let name = name fields in - let doc = doc fields in - let type_ = type_field fields in - let optional = field ~default:false "optional" bool fields in - { name; type_; optional; doc } - -and type_field fields = field "type" type_ fields - -let params = function - | `List l -> `Params (List.map l ~f:type_) - | `Assoc _ as json -> `Param (type_ json) - | json -> error "list or object expected" json -;; - -let call fields = - let method_ = field "method" string fields in - let params = field_o "params" params fields in - let doc = doc fields in - let registrationOptions = field_o "registrationOptions" type_ fields in - { registrationOptions; doc; method_; params } -;; - -let notification json = - let fields = fields json in - let call = call fields in - { call } -;; - -let request json = - let fields = fields json in - let call = call fields in - let errorData = field_o "errorData" type_ fields in - let partialResult = field_o "partialResult" type_ fields in - let result = field "result" type_ fields in - { call; errorData; partialResult; result } -;; - -let enumerationEntry json : enumerationEntry = - let fields = fields json in - let name = name fields in - let doc = doc fields in - let value = field "value" string_or_number fields in - { name; value; doc } -;; - -let enumerationType json = - let fields = fields json in - let () = field "kind" (literal (`String "base")) fields in - let name = - field - "name" - (enum [ "integer", `Integer; "string", `String; "uinteger", `Uinteger ]) - fields - in - { name } -;; - -let enumeration json = - let fields = fields json in - let name = name fields in - let doc = doc fields in - let values = field "values" (list enumerationEntry) fields in - let type_ = field "type" enumerationType fields in - let supportsCustomValues = field ~default:false "supportsCustomValues" bool fields in - { supportsCustomValues; type_; values; name; doc } -;; - -let structure json = - let fields = fields json in - let doc = doc fields in - let name = name fields in - let extends = field ~default:[] "extends" (list type_) fields in - let mixins = field ~default:[] "mixins" (list type_) fields in - let properties = properties fields in - { doc; name; extends; mixins; properties } -;; - -let typeAlias json : typeAlias = - let fields = fields json in - let name = name fields in - let type_ = type_field fields in - let doc = doc fields in - { doc; name; type_ } -;; - -let t json = - let fields = fields json in - let requests = field "requests" (list request) fields in - let notifications = field "notifications" (list notification) fields in - let structures = field "structures" (list structure) fields in - let enumerations = field "enumerations" (list enumeration) fields in - let typeAliases = field "typeAliases" (list typeAlias) fields in - { requests; notifications; structures; enumerations; typeAliases } -;; - -type metamodel = t - -module Entity = struct - type t = - | Structure of structure - | Enumeration of enumeration - | Alias of typeAlias - - module DB = struct - type nonrec t = t String.Map.t - - let create - ({ structures; requests = _; notifications = _; enumerations; typeAliases } : - metamodel) - : t - = - let structures = - String.Map.of_list_map_exn structures ~f:(fun s -> s.name, Structure s) - in - let enumerations = - String.Map.of_list_map_exn enumerations ~f:(fun s -> s.name, Enumeration s) - in - let typeAliases = - String.Map.of_list_map_exn typeAliases ~f:(fun a -> a.name, Alias a) - in - String.Map.union_exn structures enumerations |> String.Map.union_exn typeAliases - ;; - - let find t x = String.Map.find_exn t x - end -end - -module Path = struct - type top = - | Request of request - | Notification of notification - | Structure of structure - | Enumeration of enumeration - | Alias of typeAlias - - type t = - | Top of top - | Property of property * t -end - -class map = - let open Path in - object (self) - method property path (p : property) = - let path = Property (p, path) in - { p with type_ = self#type_ path p.type_ } - - method literal path t = - match (t : literalType) with - | Record ps -> Record (List.map ps ~f:(self#property path)) - | _ -> t - - method or_ path types = Or (List.map types ~f:(self#type_ path)) - - method type_ path t : type_ = - match t with - | Base _ as t -> t - | Reference _ -> t - | Array t -> Array (self#type_ path t) - | Or types -> self#or_ path types - | And ts -> And (List.map ts ~f:(self#type_ path)) - | Tuple ts -> Tuple (List.map ts ~f:(self#type_ path)) - | Literal lt -> Literal (self#literal path lt) - | Map mt -> Map { mt with value = self#type_ path mt.value } - - method private call path (c : call) = - let params = - let params = function - | `Param t -> `Param (self#type_ path t) - | `Params ts -> `Params (List.map ts ~f:(self#type_ path)) - in - Option.map ~f:params c.params - in - let registrationOptions = Option.map ~f:(self#type_ path) c.registrationOptions in - { c with params; registrationOptions } - - method request (r : request) = - let path = Top (Request r) in - let call = self#call path r.call in - let errorData = Option.map ~f:(self#type_ path) r.errorData in - let partialResult = Option.map ~f:(self#type_ path) r.partialResult in - let result = self#type_ path r.result in - { call; errorData; partialResult; result } - - method notification { call } = - let path = Top (Notification { call }) in - { call = self#call path call } - - method structure s = - let path = Top (Structure s) in - let extends = List.map s.extends ~f:(self#type_ path) in - let mixins = List.map s.mixins ~f:(self#type_ path) in - let properties = List.map s.properties ~f:(self#property path) in - { s with extends; mixins; properties } - - method typeAlias (a : typeAlias) = - let path = Top (Alias a) in - { a with type_ = self#type_ path a.type_ } - - method enumeration (e : enumeration) : enumeration = e - - method t { requests; notifications; structures; enumerations; typeAliases } = - let requests = List.map requests ~f:self#request in - let notifications = List.map notifications ~f:self#notification in - let structures = List.map structures ~f:self#structure in - let typeAliases = List.map typeAliases ~f:self#typeAlias in - let enumerations = List.map enumerations ~f:self#enumeration in - { enumerations; requests; notifications; structures; typeAliases } - end diff --git a/lsp/bin/metamodel/metamodel.mli b/lsp/bin/metamodel/metamodel.mli deleted file mode 100644 index a53c768e8..000000000 --- a/lsp/bin/metamodel/metamodel.mli +++ /dev/null @@ -1,149 +0,0 @@ -type doc = - { since : string option - ; documentation : string option - } - -type baseType = - | Uri - | DocumentUri - | Integer - | Uinteger - | Decimal - | RegExp - | String - | Boolean - | Null - -type mapKeyType = - | Uri - | DocumentUri - | String - | Integer - | Reference of string - -type literalType = - | String of string - | Boolean of bool - | Integer of int - | Record of property list - -and property = - { doc : doc - ; name : string - ; optional : bool - ; type_ : type_ - } - -and mapType = - { key : mapKeyType - ; value : type_ - } - -and type_ = - | Base of baseType - | Reference of string - | Array of type_ - | Or of type_ list - | And of type_ list - | Tuple of type_ list - | Literal of literalType - | Map of mapType - -type typeAlias = - { name : string - ; type_ : type_ - ; doc : doc - } - -type enumerationEntry = - { name : string - ; value : [ `Int of int | `String of string ] - ; doc : doc - } - -type enumerationType = { name : [ `Integer | `String | `Uinteger ] } - -type enumeration = - { doc : doc - ; name : string - ; supportsCustomValues : bool - ; type_ : enumerationType - ; values : enumerationEntry list - } - -type structure = - { doc : doc - ; extends : type_ list - ; mixins : type_ list - ; name : string - ; properties : property list - } - -type call = - { method_ : string - ; params : [ `Param of type_ | `Params of type_ list ] option - ; registrationOptions : type_ option - ; doc : doc - } - -type request = - { call : call - ; errorData : type_ option - ; partialResult : type_ option - ; result : type_ - } - -type notification = { call : call } - -type t = - { requests : request list - ; notifications : notification list - ; structures : structure list - ; enumerations : enumeration list - ; typeAliases : typeAlias list - } - -val t : Yojson.Safe.t -> t - -module Entity : sig - type metamodel := t - - type t = - | Structure of structure - | Enumeration of enumeration - | Alias of typeAlias - - module DB : sig - type entity := t - type t - - val create : metamodel -> t - val find : t -> string -> entity - end -end - -module Path : sig - type top = - | Request of request - | Notification of notification - | Structure of structure - | Enumeration of enumeration - | Alias of typeAlias - - type t = - | Top of top - | Property of property * t -end - -class map : object - method literal : Path.t -> literalType -> literalType - method property : Path.t -> property -> property - method or_ : Path.t -> type_ list -> type_ - method type_ : Path.t -> type_ -> type_ - method t : t -> t - method request : request -> request - method structure : structure -> structure - method notification : notification -> notification - method typeAlias : typeAlias -> typeAlias - method enumeration : enumeration -> enumeration -end diff --git a/lsp/bin/named.ml b/lsp/bin/named.ml deleted file mode 100644 index 5f7a75876..000000000 --- a/lsp/bin/named.ml +++ /dev/null @@ -1,15 +0,0 @@ -type 'a t = - { name : string - ; data : 'a - } - -let make ~name data = { name; data } -let data t = t.data -let name t = t.name -let map t ~f = { t with data = f t.data } -let set_data t data = { t with data } - -let to_dyn f { name; data } = - let open Dyn in - record [ "name", String name; "data", f data ] -;; diff --git a/lsp/bin/ocaml/json_gen.ml b/lsp/bin/ocaml/json_gen.ml deleted file mode 100644 index 44af31da8..000000000 --- a/lsp/bin/ocaml/json_gen.ml +++ /dev/null @@ -1,273 +0,0 @@ -open! Import -open Ml - -let json_t = Type.Path (Dot (Ident "Json", "t")) - -let pat_of_literal (t : Ts_types.Literal.t) : Expr.pat = - let open Expr in - let tag, args = - match t with - | Ts_types.Literal.String s -> "String", Pat (Expr.String s) - | Int i -> "Int", Pat (Expr.Int i) - | Float _ -> assert false - in - Pat (Constr { poly = true; tag; args = [ args ] }) -;; - -let constr_of_literal (t : Ts_types.Literal.t) : Expr.t = - let open Expr in - let tag, args = - match t with - | Ts_types.Literal.String s -> "String", Create (Expr.String s) - | Int i -> "Int", Create (Expr.Int i) - | Float _ -> assert false - in - Create (Constr { poly = true; tag; args = [ args ] }) -;; - -let json_error_pat msg = - let open Expr in - ( Wildcard - , App - ( Create (Ident "Json.error") - , [ Unnamed (Create (String msg)); Unnamed (Create (Ident "json")) ] ) ) -;; - -let is_json_constr (constr : Type.constr) = - List.mem [ "String"; "Int"; "Bool" ] constr.name ~equal:String.equal -;; - -module Name = struct - let of_ = sprintf "%s_of_yojson" - let to_ = sprintf "yojson_of_%s" - - let conv = function - | `To -> to_ - | `Of -> of_ - ;; -end - -open Arg - -let of_json ~name expr = - let pat = [ Unnamed "json", Type.json ] in - let data = { Expr.pat; type_ = Type.name name; body = expr } in - let name = Name.of_ name in - { Named.name; data } -;; - -let to_json ~name expr = - let pat = [ Unnamed name, Type.name name ] in - let data = { Expr.pat; type_ = Type.json; body = expr } in - let name = Name.to_ name in - { Named.name; data } -;; - -let add_json_conv_for_t (sig_ : Module.sig_ Module.t) = - let conv_t = - { Named.name = "t" - ; data = - (let t = Type.Path (Path.Ident "t") in - Module.Include (Module.Name.of_string "Json.Jsonable.S", [ t, t ])) - } - in - { sig_ with bindings = sig_.bindings @ [ conv_t ] } -;; - -module Enum = struct - let of_json ~allow_other ~poly { Named.name; data = constrs } = - let open Ml.Expr in - let body = - let clauses = - List.map constrs ~f:(fun (constr, literal) -> - let pat = pat_of_literal literal in - let tag = constr in - pat, Create (Constr { tag; poly; args = [] })) - in - let clauses = - if allow_other - then ( - let s = Ident "s" in - let pat = Pat (Constr { tag = "String"; poly = true; args = [ Pat s ] }) in - let make = Create (Constr { tag = "Other"; poly; args = [ Create s ] }) in - clauses @ [ pat, make ]) - else clauses - in - let msg = - sprintf - "Invalid value. Expected one of: %s" - (List.map constrs ~f:(fun (_, literal) -> - Ts_types.Literal.to_maybe_quoted_string literal) - |> String.concat ~sep:", ") - in - Match (Create (Ident "json"), clauses @ [ json_error_pat msg ]) - in - of_json ~name body - ;; - - let to_json ~allow_other ~poly { Named.name; data = constrs } = - let open Ml.Expr in - let body = - let clauses = - List.map constrs ~f:(fun (constr, literal) -> - let pat = Pat (Constr { tag = constr; poly; args = [] }) in - pat, constr_of_literal literal) - in - let clauses = - if allow_other - then ( - let s = Ident "s" in - let pat = Pat (Constr { tag = "Other"; poly; args = [ Pat s ] }) in - let make = - Create (Constr { tag = "String"; poly = true; args = [ Create s ] }) - in - clauses @ [ pat, make ]) - else clauses - in - Match (Create (Ident name), clauses) - in - to_json ~name body - ;; - - let conv ~allow_other ~poly t = - let to_json = to_json ~allow_other ~poly t in - let of_json = of_json ~allow_other ~poly t in - [ to_json; of_json ] - ;; -end - -module Poly_variant = struct - type constrs = - { json_constrs : Ml.Type.constr list - ; untagged_constrs : Ml.Type.constr list - } - - let split_clauses constrs = - let json_constrs, untagged_constrs = - List.partition_map constrs ~f:(fun x -> - if is_json_constr x then Left x else Right x) - in - { json_constrs; untagged_constrs } - ;; - - let conv_of_constr target (utc : Ml.Type.constr) = - let rec conv (p : Ml.Path.t) : Ml.Path.t = - match p with - | Ident name -> Ident (Name.conv target name) - | Dot (s, name) -> Dot (s, Name.conv target name) - | Apply (s, y) -> Apply (s, conv y) - in - let conv p = Ml.Path.to_string (conv p) in - let open Ml.Expr in - let json_mod n = - match target with - | `To -> Ident ("Json.To." ^ n) - | `Of -> Ident ("Json.Of." ^ n) - in - let conv t = Create (Ident (conv t)) in - match (utc.args : Ml.Type.t list) with - | [ Path p ] -> conv p - | [ List (Prim p) ] -> - let ident = - match p with - | String -> "string" - | _ -> assert false - in - App (Create (json_mod "list"), [ Unnamed (conv (Ident ident)) ]) - | [ List (Path p) ] -> App (Create (json_mod "list"), [ Unnamed (conv p) ]) - | [ Tuple [ Prim Int; Prim Int ] ] -> Create (json_mod "int_pair") - | [] -> assert false - | _ -> Code_error.raise "untagged" [ "utc", Ml.Type.dyn_of_constr utc ] - ;; - - let json_clauses json_constrs = - List.map json_constrs ~f:(fun (c : Ml.Type.constr) -> - let open Ml.Expr in - let constr arg = Constr { tag = c.name; poly = true; args = [ arg ] } in - let pat = Pat (constr (Pat (Ident "j"))) in - let expr : t = Create (constr (Create (Ident "j"))) in - pat, expr) - ;; - - let to_json { Named.name; data = constrs } = - let { json_constrs; untagged_constrs } = split_clauses constrs in - let open Ml.Expr in - let json_clauses = json_clauses json_constrs in - let untagged_clauses = - List.map untagged_constrs ~f:(fun (utc : Ml.Type.constr) -> - let constr arg = Constr { tag = utc.name; poly = true; args = [ arg ] } in - let pat = Pat (constr (Pat (Ident "s"))) in - let expr = App (conv_of_constr `To utc, [ Unnamed (Create (Ident "s")) ]) in - pat, expr) - in - let expr = Match (Create (Ident name), json_clauses @ untagged_clauses) in - to_json ~name expr - ;; - - let of_json { Named.name; data = constrs } = - let { json_constrs; untagged_constrs } = split_clauses constrs in - let open Ml.Expr in - let clauses = json_clauses json_constrs in - let untagged = - let args = - let constrs = - List.map untagged_constrs ~f:(fun (utc : Ml.Type.constr) -> - let create = - let of_json = - App (conv_of_constr `Of utc, [ Unnamed (Create (Ident "json")) ]) - in - Create (Constr { tag = utc.name; poly = true; args = [ of_json ] }) - in - Fun ([ Unnamed (Pat (Ident "json")) ], create)) - in - Create (List constrs) - in - App - ( Create (Ident "Json.Of.untagged_union") - , [ Unnamed (Create (String name)) - ; Unnamed args - ; Unnamed (Create (Ident "json")) - ] ) - in - let expr = - match json_constrs, untagged_constrs with - | [], [] -> assert false - | [], _ -> untagged - | _, [] -> Match (Create (Ident "json"), clauses @ [ json_error_pat name ]) - | _ :: _, _ :: _ -> Match (Create (Ident "json"), clauses @ [ Wildcard, untagged ]) - in - of_json ~name expr - ;; -end - -(* [name] is used as the pattern in the "to" converter. In the "of" converter, - it's used to generate better error messages. *) -let make_literal_wrapper_conv ~field_name ~literal_value ~type_name = - (* Some json representations require an extra "kind" field set to some string - constant *) - let open Ml.Expr in - let args = List.map ~f:(fun x -> Ml.Arg.Unnamed (Create x)) in - let to_ = - let a = - [ String field_name - ; String literal_value - ; Ident (Name.conv `To type_name) - ; Ident type_name - ] - in - App (Create (Ident "Json.To.literal_field"), args a) - in - let of_ = - let a = - [ String type_name - ; String field_name - ; String literal_value - ; Ident (Name.conv `Of type_name) - ; Ident "json" - ] - in - App (Create (Ident "Json.Of.literal_field"), args a) - in - [ to_json ~name:type_name to_; of_json ~name:type_name of_ ] - |> List.map ~f:(Named.map ~f:(fun v -> Ml.Module.Value v)) -;; diff --git a/lsp/bin/ocaml/json_gen.mli b/lsp/bin/ocaml/json_gen.mli deleted file mode 100644 index 1af2d63ff..000000000 --- a/lsp/bin/ocaml/json_gen.mli +++ /dev/null @@ -1,21 +0,0 @@ -val json_t : Ml.Type.t -val add_json_conv_for_t : Ml.Module.sig_ Ml.Module.t -> Ml.Module.sig_ Ml.Module.t - -module Enum : sig - val conv - : allow_other:bool - -> poly:bool - -> (string * Ts_types.Literal.t) list Named.t - -> Ml.Expr.toplevel Named.t list -end - -module Poly_variant : sig - val of_json : Ml.Type.constr list Named.t -> Ml.Expr.toplevel Named.t - val to_json : Ml.Type.constr list Named.t -> Ml.Expr.toplevel Named.t -end - -val make_literal_wrapper_conv - : field_name:string - -> literal_value:string - -> type_name:string - -> Ml.Module.impl Named.t list diff --git a/lsp/bin/ocaml/ml.ml b/lsp/bin/ocaml/ml.ml deleted file mode 100644 index 4973e02e2..000000000 --- a/lsp/bin/ocaml/ml.ml +++ /dev/null @@ -1,598 +0,0 @@ -open Import - -module Kind = struct - type t = - | Intf - | Impl - - type ('intf, 'impl) pair = - { intf : 'intf - ; impl : 'impl - } - - module Map = struct - type 'a t = ('a, 'a) pair - - let get { intf; impl } = function - | Impl -> impl - | Intf -> intf - ;; - - let make_both a = { intf = a; impl = a } - - let iter { intf; impl } ~f = - f intf; - f impl - ;; - - let map { intf; impl } ~f = { intf = f intf; impl = f impl } - - let both (type a b) (x : a t) (y : b t) : (a * b) t = - { intf = x.intf, y.intf; impl = x.impl, y.impl } - ;; - end -end - -let is_kw = function - | "type" | "method" | "end" | "to" | "external" -> true - | _ -> false -;; - -module Arg = struct - type 'e t = - | Unnamed of 'e - | Labeled of string * 'e - | Optional of string * 'e - - let to_dyn f = - let open Dyn in - function - | Unnamed a -> Dyn.variant "Unnamed" [ f a ] - | Labeled (s, a) -> Dyn.variant "Labeled" [ string s; f a ] - | Optional (s, a) -> Dyn.variant "Optional" [ string s; f a ] - ;; -end - -module Path = struct - type t = - | Ident of string - | Dot of t * string - | Apply of t * t - - let rec to_string = function - | Ident s -> s - | Dot (t, s) -> to_string t ^ "." ^ s - | Apply (f, x) -> to_string f ^ "(" ^ to_string x ^ ")" - ;; - - let rec pp = function - | Ident s -> Pp.verbatim s - | Dot (s, p) -> Pp.concat [ pp s; Pp.verbatim "."; Pp.verbatim p ] - | Apply (s, p) -> Pp.concat [ pp s; W.surround `Paren (pp p) ] - ;; -end - -module Type = struct - [@@@warning "-30"] - - type prim = - | Unit - | String - | Int - | Bool - - let dyn_of_prim : prim -> Dyn.t = - let open Dyn in - function - | Unit -> variant "Unit" [] - | String -> variant "String" [] - | Int -> variant "Int" [] - | Bool -> variant "Bool" [] - ;; - - type t = - | Path of Path.t - | Var of string - | Prim of prim - | Tuple of t list - | Optional of t - | List of t - | Poly_variant of constr list - | Assoc of t * t - | App of t * t list - | Fun of t Arg.t * t - - and constr = - { name : string - ; args : t list - } - - and field = - { name : string - ; typ : t - ; attrs : (string * string list) list - } - - let rec to_dyn = - let open Dyn in - function - | Var v -> variant "Var" [ string v ] - | List v -> variant "List" [ to_dyn v ] - | Assoc (x, y) -> variant "Assoc" [ to_dyn x; to_dyn y ] - | Tuple xs -> variant "Tuple" (List.map ~f:to_dyn xs) - | Optional t -> variant "Optional" [ to_dyn t ] - | Path p -> variant "Path" [ string @@ Path.to_string p ] - | Poly_variant xs -> variant "Poly_variant" (List.map ~f:dyn_of_constr xs) - | App (x, y) -> variant "App" (to_dyn x :: List.map y ~f:to_dyn) - | Prim p -> variant "Prim" [ dyn_of_prim p ] - | Fun (arg, t) -> variant "Fun" [ Arg.to_dyn to_dyn arg; to_dyn t ] - - and dyn_of_constr { name; args } = - Dyn.(record [ "name", string name; "args", (list to_dyn) args ]) - - and dyn_of_field { name; typ; attrs } = - let open Dyn in - record - [ "name", string name - ; "typ", to_dyn typ - ; "attrs", list (pair string (list string)) attrs - ] - ;; - - type decl = - | Alias of t - | Record of field list - | Variant of constr list - - let dyn_of_decl = - let open Dyn in - function - | Alias a -> variant "Alias" [ to_dyn a ] - | Record fs -> variant "Record" (List.map ~f:dyn_of_field fs) - | Variant cs -> variant "Variant" (List.map ~f:dyn_of_constr cs) - ;; - - class virtual ['env, 'm] mapreduce = - object (self : 'self) - method virtual empty : 'm - method virtual plus : 'm -> 'm -> 'm - - method poly_variant env constrs = - let r, s = self#fold_left_map constrs ~f:(fun c -> self#constr env c) in - Poly_variant r, s - - method tuple (env : 'env) t = - let (r : t list), s = self#fold_left_map t ~f:(fun (t : t) -> self#t env t) in - Tuple r, s - - method path _ p = Path p, self#empty - method var _ n = Var n, self#empty - method prim _ p = Prim p, self#empty - - method optional env p = - let t, s = self#t env p in - Optional t, s - - method list env t = - let t, s = self#t env t in - List t, s - - method assoc env k v = - let k, s1 = self#t env k in - let v, s2 = self#t env v in - Assoc (k, v), self#plus s1 s2 - - method app env f xs = - let f, s1 = self#t env f in - let xs, s2 = self#fold_left_map xs ~f:(fun x -> self#t env x) in - App (f, xs), self#plus s1 s2 - - method t env this = - match (this : t) with - | Path p -> self#path env p - | Var v -> self#var env v - | Prim p -> self#prim env p - | Tuple t -> self#tuple env t - | Optional t -> self#optional env t - | List t -> self#list env t - | Poly_variant t -> self#poly_variant env t - | Assoc (k, v) -> self#assoc env k v - | App (f, xs) -> self#app env f xs - | Fun (_, _) -> assert false - - method alias env t = - let r0, s0 = self#t env t in - Alias r0, s0 - - method constr env (constr : constr) = - let args, s = self#fold_left_map constr.args ~f:(fun t -> self#t env t) in - { constr with args }, s - - method private fold_left_map : 'a. f:('a -> 'a * 'm) -> 'a list -> 'a list * 'm = - fun ~f xs -> - let accf, accm = - List.fold_left xs ~init:([], self#empty) ~f:(fun (accf, accm) x -> - let r, s = f x in - r :: accf, self#plus accm s) - in - List.rev accf, accm - - method field env f = - let typ, s = self#t env f.typ in - { f with typ }, s - - method record env fields = - let r, s = self#fold_left_map fields ~f:(fun f -> self#field env f) in - Record r, s - - method variant env constrs = - let v, s = self#fold_left_map constrs ~f:(fun f -> self#constr env f) in - Variant v, s - - method decl env decl = - match decl with - | Alias a -> self#alias env a - | Record fs -> self#record env fs - | Variant v -> self#variant env v - end - - let field typ ~name = { name; typ; attrs = [] } - let fun_ args t = List.fold_right args ~init:t ~f:(fun arg acc -> Fun (arg, acc)) - let constr args ~name = { name; args } - let list t = List t - let assoc_list ~key ~data = Assoc (key, data) - let t = Path (Ident "t") - let module_t m = Path (Dot (Ident (String.capitalize_ascii m), "t")) - let string = Prim String - let name s = Path (Ident s) - let int = Prim Int - let bool = Prim Bool - let alpha = Var "a" - - let enum constrs = - Variant (List.map constrs ~f:(fun constr -> { name = constr; args = [] })) - ;; - - let poly_enum constrs = - Poly_variant (List.map constrs ~f:(fun constr -> { name = constr; args = [] })) - ;; - - let json = Path (Dot (Ident "Json", "t")) - let unit = Prim Unit - let array t = App (Path (Ident "array"), [ t ]) - - let void = - let void = Path.Dot (Ident "Json", "Void") in - Path (Dot (void, "t")) - ;; - - let json_object = - let obj = Path.Dot (Ident "Json", "Object") in - Path (Dot (obj, "t")) - ;; - - module Type = W.Type - - let pp_prim (p : prim) : W.t = - match p with - | String -> Pp.verbatim "string" - | Int -> Pp.verbatim "int" - | Bool -> Pp.verbatim "bool" - | Unit -> Pp.verbatim "unit" - ;; - - let rec pp (a : t) ~(kind : Kind.t) : W.t = - match a with - | Prim p -> pp_prim p - | Var v -> Type.var v - | Path p -> Path.pp p - | App (f, xs) -> Type.app (pp ~kind f) (List.map ~f:(pp ~kind) xs) - | Tuple t -> Type.tuple (List.map ~f:(pp ~kind) t) - | Optional t -> pp ~kind (App (Path (Ident "option"), [ t ])) - | List t -> pp ~kind (App (Path (Ident "list"), [ t ])) - | Poly_variant constrs -> - List.map constrs ~f:(fun { name; args } -> name, List.map args ~f:(pp ~kind)) - |> Type.poly - | Assoc (k, v) -> - let t = List (Tuple [ k; v ]) in - pp t ~kind - | Fun (a, r) -> - (match a with - | Arg.Unnamed t -> - Pp.concat [ pp t ~kind; Pp.space; Pp.verbatim "->"; Pp.space; pp ~kind r ] - | Arg.Labeled (l, t) -> - Pp.concat - [ Pp.textf "%s:" l - ; pp t ~kind - ; Pp.space - ; Pp.verbatim "->" - ; Pp.space - ; pp ~kind r - ] - | Arg.Optional (l, t) -> - Pp.concat - [ Pp.textf "?%s:" l - ; pp t ~kind - ; Pp.space - ; Pp.verbatim "->" - ; Pp.space - ; pp ~kind r - ]) - ;; - - let pp_decl' ~(kind : Kind.t) (a : decl) = - match a with - | Alias a -> - let pp = pp ~kind a in - (match a, kind with - | (List _ | Path _ | Prim _), Impl -> W.Type.deriving ~record:false pp - | _, _ -> pp) - | Variant v -> - List.map v ~f:(fun { name; args } -> name, List.map ~f:(pp ~kind) args) - |> Type.variant - | Record r -> - let r = - List.map r ~f:(fun { name; typ; attrs } -> - let def = - let field = pp ~kind typ in - let attrs = - let attrs = - match kind with - | Intf -> [] - | Impl -> attrs - in - List.concat_map attrs ~f:(fun (a, r) -> - [ W.Attr.make a (List.map ~f:Pp.verbatim r) ]) - in - Type.field_attrs ~field ~attrs - in - name, def) - |> Type.record - in - (match kind with - | Intf -> r - | Impl -> W.Type.deriving r ~record:true) - ;; - - let pp_decl ~name ~kind (a : decl) : W.t = - let body = pp_decl' ~kind a in - Type.decl name body - ;; -end - -module Expr = struct - [@@@ocaml.warning "-30-32-37"] - - type expr = - | Let of pat * expr * expr (** let pat = e1 in e2 *) - | Match of expr * (pat * expr) list (** match e1 with [p -> e]* *) - | Fun of pat Arg.t list * expr (** fun p2 p2 .. -> e *) - | App of expr * expr Arg.t list (** f e1 e2 .. *) - | Create of expr prim (** Literal/Primitive *) - | Assert_false (** assert false *) - - and 'e prim = - | Unit - | Bool of bool - | Int of int - | String of string - | Ident of string - | Cons of 'e * 'e prim - | List of 'e list - | Tuple of 'e list - | Record of 'e record_ - | Constr of 'e constr - - and pat = - | Wildcard - | Pat of pat prim - - and 'e record_ = (string * 'e) list - - and 'e constr = - { tag : string - ; poly : bool - ; args : 'e list - } - - type t = expr - - let assert_false_clause = Wildcard, Assert_false - - type toplevel = - { pat : (string Arg.t * Type.t) list - ; type_ : Type.t - ; body : t - } - - let constr ?(poly = false) ?(args = []) tag = { poly; args; tag } - - let pp_constr f { tag; poly; args } = - let tag = - let tag = String.capitalize tag in - Pp.verbatim (if poly then "`" ^ tag else tag) - in - match args with - | [] -> tag - | args -> - let sep = Pp.verbatim "," in - let args = W.surround `Paren (Pp.concat_map ~sep ~f args) in - Pp.concat [ tag; Pp.space; args ] - ;; - - let rec pp_pat = function - | Wildcard -> Pp.verbatim "_" - | Pat pat -> - (match pat with - | Unit -> Pp.verbatim "()" - | Bool b -> Pp.textf "%b" b - | Int i -> Pp.textf "%i" i - | String s -> Pp.textf "%S" s - | Ident s -> Pp.verbatim s - | Cons _ -> assert false - | List _ -> assert false - | Tuple _ -> assert false - | Record _ -> assert false - | Constr c -> pp_constr pp_pat c) - ;; - - let rec pp_create : expr prim -> _ Pp.t = function - | Unit -> Pp.verbatim "()" - | Bool b -> Pp.textf "%b" b - | Int i -> - let pp = Pp.textf "%i" i in - if i < 0 then W.surround `Paren pp else pp - | String s -> Pp.textf "%S" s - | Ident s -> Pp.verbatim s - | Cons _ -> assert false - | List xs -> - let xs = Pp.concat_map xs ~sep:(Pp.verbatim ";") ~f:pp in - W.surround `Square xs - | Tuple _ -> assert false - | Record fields -> - let record = - let open Pp.O in - Pp.concat_map - fields - ~sep:(Pp.verbatim ";" ++ Pp.space) - ~f:(fun (name, expr) -> - if expr = Create (Ident name) - then pp expr - else Pp.verbatim name ++ Pp.space ++ Pp.verbatim "=" ++ pp expr) - in - W.surround `Curly record - | Constr c -> pp_constr pp c - - and pp = function - | Assert_false -> Pp.verbatim "assert false" - | Match (expr, patterns) -> - let with_ = - Pp.concat [ Pp.verbatim "match"; Pp.space; pp expr; Pp.space; Pp.verbatim "with" ] - in - let clauses = - Pp.concat_map patterns ~f:(fun (pat, expr) -> - Pp.concat - [ Pp.verbatim "| " - ; pp_pat pat - ; Pp.space - ; Pp.verbatim "->" - ; Pp.space - ; Pp.verbatim "(" - ; pp expr - ; Pp.verbatim ")" - ]) - in - Pp.concat [ with_; Pp.newline; clauses ] - | Create c -> pp_create c - | App (x, args) -> - let args = - Pp.concat_map args ~sep:Pp.space ~f:(fun arg -> - match arg with - | Unnamed e -> pp e - | _ -> assert false) - in - Pp.concat [ pp x; Pp.space; args ] - | Fun (pats, expr) -> - W.surround - `Paren - (Pp.concat - [ Pp.verbatim "fun" - ; Pp.space - ; Pp.concat_map pats ~sep:Pp.space ~f:(fun arg -> - match arg with - | Unnamed e -> pp_pat e - | _ -> assert false) - ; Pp.space - ; Pp.verbatim "->" - ; pp expr - ]) - | _ -> assert false - ;; - - let pp_toplevel ~kind name { pat; type_; body } = - let pat = - Pp.concat_map pat ~f:(fun (pat, typ) -> - let typ = Type.pp ~kind typ in - match pat with - | Unnamed s -> - Pp.concat - [ Pp.verbatim "("; Pp.verbatim s; Pp.verbatim " : "; typ; Pp.verbatim ")" ] - | Labeled (l, r) -> - if l = r - then Pp.concat [ Pp.textf "~(%s :" l; typ; Pp.verbatim ")" ] - else assert false - | Optional (l, r) -> - if l = r - then Pp.concat [ Pp.textf "?(%s :" l; typ; Pp.space; Pp.verbatim "option)" ] - else assert false) - in - let body = pp body in - let type_ = Type.pp type_ ~kind in - Pp.concat - [ Pp.textf "let %s" name - ; pat - ; Pp.textf " : " - ; type_ - ; Pp.textf "=" - ; Pp.newline - ; body - ] - ;; -end - -module Module = struct - module Name : sig - type t = private string - - val of_string : string -> t - end = struct - type t = string - - let of_string s = - match s.[0] with - | 'a' .. 'z' -> Code_error.raise "invalid module name" [ "s", Dyn.string s ] - | _ -> s - ;; - end - - type 'a t = - { name : Name.t - ; bindings : 'a Named.t list - } - - let empty name = { name; bindings = [] } - - type sig_ = - | Value of Type.t - | Type_decl of Type.decl - | Include of Name.t * (Type.t * Type.t) list - - type impl = - | Type_decl of Type.decl - | Value of Expr.toplevel - - let pp_sig { name; bindings } = - let bindings = - Pp.concat_map bindings ~sep:Pp.newline ~f:(fun { name; data } -> - match (data : sig_) with - | Value t -> W.Sig.val_ name [ Type.pp ~kind:Intf t ] - | Type_decl t -> W.Type.decl name (Type.pp_decl' ~kind:Intf t) - | Include (mod_, destructive_subs) -> - List.map destructive_subs ~f:(fun (l, r) -> - let f = Type.pp ~kind:Intf in - f l, f r) - |> W.Sig.include_ (mod_ :> string)) - in - W.Sig.module_ (name :> string) bindings - ;; - - let pp_impl { name; bindings } = - let bindings = - Pp.concat_map bindings ~sep:Pp.newline ~f:(fun { name; data = v } -> - match v with - | Value decl -> Expr.pp_toplevel ~kind:Impl name decl - | Type_decl t -> W.Type.decl name (Type.pp_decl' ~kind:Impl t)) - in - W.module_ (name :> string) bindings - ;; -end diff --git a/lsp/bin/ocaml/ml.mli b/lsp/bin/ocaml/ml.mli deleted file mode 100644 index d6d28a1b2..000000000 --- a/lsp/bin/ocaml/ml.mli +++ /dev/null @@ -1,227 +0,0 @@ -(** Representation of OCaml code used for generation *) - -val is_kw : string -> bool - -module Kind : sig - type t = - | Intf - | Impl - - type ('intf, 'impl) pair = - { intf : 'intf - ; impl : 'impl - } - - module Map : sig - type 'a t = ('a, 'a) pair - type kind - - val get : 'a t -> kind -> 'a - val iter : 'a t -> f:('a -> unit) -> unit - val map : 'a t -> f:('a -> 'b) -> 'b t - val both : 'a t -> 'b t -> ('a * 'b) t - val make_both : 'a -> 'a t - end - with type kind := t -end - -module Arg : sig - (** Represent arrow types and argument patterns *) - - type 'e t = - | Unnamed of 'e - | Labeled of string * 'e - | Optional of string * 'e -end - -module Path : sig - type t = - | Ident of string - | Dot of t * string - | Apply of t * t - - val to_string : t -> string -end - -module Type : sig - [@@@warning "-30"] - - type prim = - | Unit - | String - | Int - | Bool - - type t = - | Path of Path.t - | Var of string - | Prim of prim - | Tuple of t list - | Optional of t - | List of t - | Poly_variant of constr list - | Assoc of t * t - | App of t * t list - | Fun of t Arg.t * t - - and field = - { name : string - ; typ : t - ; attrs : (string * string list) list - } - - and constr = - { name : string - ; args : t list - } - - val to_dyn : t -> Dyn.t - val dyn_of_constr : constr -> Dyn.t - - type decl = - | Alias of t - | Record of field list - | Variant of constr list - - val dyn_of_decl : decl -> Dyn.t - val fun_ : t Arg.t list -> t -> t - - (* This is for lists where the keys are equal to strings *) - val assoc_list : key:t -> data:t -> t - val pp_decl : name:string -> kind:Kind.t -> decl -> unit Pp.t - val pp : t -> kind:Kind.t -> unit Pp.t - val field : t -> name:string -> field - val constr : t list -> name:string -> constr - - (** Simplified sum types*) - val enum : string list -> decl - - (** Polymorphic variant form *) - val poly_enum : string list -> t - - val list : t -> t - val module_t : string -> t - val t : t - val string : t - val name : string -> t - val int : t - val bool : t - val alpha : t - val json : t - val json_object : t - val unit : t - val void : t - val array : t -> t - - (** Fold and map over a type expression. - - ['m] is the type of monoid summarized. - - ['env] is a custom value threaded through the path. Parent nodes can use - this to give child nodes context *) - class virtual ['env, 'm] mapreduce : object ('self) - method virtual empty : 'm - method virtual plus : 'm -> 'm -> 'm - - (** doesn't really to be here, but putting it here avoids passing [empty] - and [plus] to a general purpose [fold_left_map]*) - method private fold_left_map : 'a. f:('a -> 'a * 'm) -> 'a list -> 'a list * 'm - - method alias : 'env -> t -> decl * 'm - method app : 'env -> t -> t list -> t * 'm - method assoc : 'env -> t -> t -> t * 'm - method constr : 'env -> constr -> constr * 'm - method field : 'env -> field -> field * 'm - method list : 'env -> t -> t * 'm - method path : 'env -> Path.t -> t * 'm - method optional : 'env -> t -> t * 'm - method poly_variant : 'env -> constr list -> t * 'm - method prim : 'env -> prim -> t * 'm - method record : 'env -> field list -> decl * 'm - method t : 'env -> t -> t * 'm - method decl : 'env -> decl -> decl * 'm - method tuple : 'env -> t list -> t * 'm - method var : 'env -> string -> t * 'm - method variant : 'env -> constr list -> decl * 'm - end -end - -module Expr : sig - (** An (untyped) ocaml expression. It is the responsibility of the generator - to create well typed expressions *) - type expr = - | Let of pat * expr * expr - | Match of expr * (pat * expr) list - | Fun of pat Arg.t list * expr - | App of expr * expr Arg.t list - | Create of expr prim - | Assert_false - - (* patterns or constructors, depending on ['e] *) - and 'e prim = - | Unit - | Bool of bool - | Int of int - | String of string - (* This should be Path.t as well *) - | Ident of string - | Cons of 'e * 'e prim - | List of 'e list - | Tuple of 'e list - | Record of 'e record_ - | Constr of 'e constr - - and pat = - | Wildcard (** [_ -> ] *) - | Pat of pat prim - - and 'e record_ = (string * 'e) list - - and 'e constr = - { tag : string (** the tag in a tagged union *) - ; poly : bool (** polymorphic variant? *) - ; args : 'e list - } - - type t = expr - - (** [ _ -> assert false ] *) - val assert_false_clause : pat * expr - - (** toplevel declartion (without the name) *) - type toplevel = - { pat : (string Arg.t * Type.t) list - (** paterns and their types. types should be optional but they really - help the error messages if the generated code is incorrect *) - ; type_ : Type.t (** useful to annotate the return types *) - ; body : t - } -end - -module Module : sig - (** Generate OCaml modules with JS converters *) - module Name : sig - type t = private string - - val of_string : string -> t - end - - type 'a t = - { name : Name.t - ; bindings : 'a Named.t list - } - - val empty : Name.t -> 'a t - - type sig_ = - | Value of Type.t - | Type_decl of Type.decl - | Include of Name.t * (Type.t * Type.t) list - - type impl = - | Type_decl of Type.decl - | Value of Expr.toplevel - - val pp_sig : sig_ t -> unit Pp.t - val pp_impl : impl t -> unit Pp.t -end diff --git a/lsp/bin/ocaml/ml_create.ml b/lsp/bin/ocaml/ml_create.ml deleted file mode 100644 index c11f266c7..000000000 --- a/lsp/bin/ocaml/ml_create.ml +++ /dev/null @@ -1,78 +0,0 @@ -open Import - -let f_name name = if name = "t" then "create" else sprintf "create_%s" name - -let need_unit = - List.exists ~f:(fun (f : Ml.Type.field) -> - match f.typ with - | Optional _ -> true - | _ -> false) -;; - -let intf { Named.name; data = fields } = - let type_ = - let need_unit = need_unit fields in - let fields : Ml.Type.t Ml.Arg.t list = - List.map fields ~f:(fun (field : Ml.Type.field) -> - match field.typ with - | Optional t -> Ml.Arg.Optional (field.name, t) - | t -> Labeled (field.name, t)) - in - let args : Ml.Type.t Ml.Arg.t list = - if need_unit - then - (* Gross hack because I was too lazy to allow patterns in toplevel - exprs *) - fields @ [ Ml.Arg.Unnamed Ml.Type.unit ] - else fields - in - Ml.Type.fun_ args (Ml.Type.name name) - in - let f_name = f_name name in - { Named.name = f_name; data = type_ } -;; - -let impl { Named.name; data = fields } = - let make = - let fields = - List.map fields ~f:(fun (field : Ml.Type.field) -> - let open Ml.Expr in - field.name, Create (Ident field.name)) - in - Ml.Expr.Create (Record fields) - in - let pat = - let need_unit = need_unit fields in - let fields = - List.map fields ~f:(fun (field : Ml.Type.field) -> - match field.typ with - | Optional t -> Ml.Arg.Optional (field.name, field.name), t - | t -> Ml.Arg.Labeled (field.name, field.name), t) - in - if need_unit - then - (* Gross hack because I was too lazy to allow patterns in toplevel - exprs *) - fields @ [ Unnamed "()", Ml.Type.unit ] - else fields - in - let body = { Ml.Expr.pat; type_ = Ml.Type.name name; body = make } in - let f_name = f_name name in - { Named.name = f_name; data = body } -;; - -let impl_of_type (t : Ml.Type.decl Named.t) = - match (t.data : Ml.Type.decl) with - | Record fields -> - let create = impl { t with data = fields } in - [ { create with data = Ml.Module.Value create.data } ] - | _ -> [] -;; - -let intf_of_type (t : Ml.Type.decl Named.t) : Ml.Module.sig_ Named.t list = - match (t.data : Ml.Type.decl) with - | Record fields -> - let create = intf { t with data = fields } in - [ { create with data = Ml.Module.Value create.data } ] - | _ -> [] -;; diff --git a/lsp/bin/ocaml/ml_create.mli b/lsp/bin/ocaml/ml_create.mli deleted file mode 100644 index 630776028..000000000 --- a/lsp/bin/ocaml/ml_create.mli +++ /dev/null @@ -1,3 +0,0 @@ -(* Generate create functions with optional/labeled arguments *) -val intf_of_type : Ml.Type.decl Named.t -> Ml.Module.sig_ Named.t list -val impl_of_type : Ml.Type.decl Named.t -> Ml.Module.impl Named.t list diff --git a/lsp/bin/ocaml/ml_kind.ml b/lsp/bin/ocaml/ml_kind.ml deleted file mode 100644 index d37d8c7fa..000000000 --- a/lsp/bin/ocaml/ml_kind.ml +++ /dev/null @@ -1,28 +0,0 @@ -open! Import - -type 'a t = - { intf : 'a - ; impl : 'a - } - -type kind = - | Impl - | Intf - -let get { intf; impl } = function - | Impl -> impl - | Intf -> intf -;; - -let make_both a = { intf = a; impl = a } - -let iter { intf; impl } ~f = - f intf; - f impl -;; - -let map { intf; impl } ~f = { intf = f intf; impl = f impl } - -let both (type a b) (x : a t) (y : b t) : (a * b) t = - { intf = x.intf, y.intf; impl = x.impl, y.impl } -;; diff --git a/lsp/bin/ocaml/ocaml.ml b/lsp/bin/ocaml/ocaml.ml deleted file mode 100644 index fe20955fc..000000000 --- a/lsp/bin/ocaml/ocaml.ml +++ /dev/null @@ -1,681 +0,0 @@ -open! Import -open! Ts_types - -(* TypeScript to OCaml conversion pipeline. The goal of this pipeline is to do - the conversion in logical stages. Unfortunately, this doesn't quite work *) - -(* These declarations are all excluded because we don't support them or their - definitions are hand written *) -let skipped_ts_decls = - [ "InitializedParams" - ; "NotificationMessage" - ; "RequestMessage" - ; "ResponseError" - ; "DocumentUri" - ; "ResponseMessage" - ; "Message" - ; "ErrorCodes" - ; "MarkedString" - ; "ProgressToken" - ; "ProgressParams" - ; "TextDocumentFilter" - ; "PrepareRenameResult" - ; "LSPAny" - ; "LSPObject" - ; "LSPArray" - ; "LSPErrorCodes" - ; "NotebookDocumentSyncOptions" - ; "NotebookDocumentFilter" - ; "NotebookDocumentSyncRegistrationOptions" - ; "URI" - ] -;; - -(* XXX this is temporary until we support the [supportsCustomValues] field *) -let with_custom_values = - [ "FoldingRangeKind"; "CodeActionKind"; "PositionEncodingKind"; "WatchKind" ] -;; - -module Expanded = struct - (** The expanded form is still working with typescript types. However, all - "anonymous" records and sums have been hoisted to the toplevel. So there - is a 1-1 correspondence to the OCaml typse we are going to generate *) - - [@@@ocaml.warning "-37"] - - type binding = - | Record of Resolved.field list - | Interface of Resolved.interface - | Poly_enum of Resolved.typ list - | Alias of Resolved.typ - - type t = binding Ml.Module.t - - (** Every anonymous record *) - let new_binding_of_typ (x : Resolved.typ) : binding option = - let record = function - | [ { Named.name = _; data = Resolved.Pattern _ } ] -> None - | f -> Some (Record f) - in - match x with - | List (Record d) | Record d -> record d - | Sum [ _; Record d ] -> record d - | _ -> None - ;; - - class discovered_types = - object - inherit [binding Named.t list] Resolved.fold as super - - (** Every record valued field introduces a new type - - TODO handle the case where two fields share a type *) - method! field f ~init = - let init = - match f.data with - | Pattern _ -> init - | Single { optional = _; typ } -> - (match new_binding_of_typ typ with - | None -> init - | Some data -> - let new_record = { f with data } in - if List.mem ~equal:Poly.equal init new_record - then init - else new_record :: init) - in - super#field f ~init - end - - let bindings (r : Resolved.t) = - let t : binding Named.t = - let data = - match r.data with - | Enum_anon _ -> assert false - | Interface i -> Interface i - | Type typ -> - (match new_binding_of_typ typ with - | Some data -> data - | None -> Alias typ) - in - { data; name = "t" } - in - let init = [ t ] in - match r.data with - | Enum_anon _ -> assert false - | Type typ -> (new discovered_types)#typ typ ~init - | Interface intf -> (new discovered_types)#typ (Record intf.fields) ~init - ;; - - let of_ts (r : Resolved.t) : t = - let name = Ml.Module.Name.of_string (String.capitalize_ascii r.name) in - { Ml.Module.name; bindings = bindings r } - ;; -end - -module Json = Json_gen - -module Module : sig - open Ml - - type t = (Module.sig_ Module.t, Module.impl Module.t) Kind.pair - - val add_private_values : t -> Expr.toplevel Named.t list -> t - val type_decls : Module.Name.t -> Type.decl Named.t list Kind.Map.t -> t - - (** Use Json.Nullable_option or Json.Assoc.t where appropriate *) - val use_json_conv_types : t -> t - - (** Rename fields that are also OCaml keywords *) - val rename_invalid_fields : Ml.Kind.t -> Type.decl -> Type.decl - - val pp : t -> unit Pp.t Kind.Map.t -end = struct - module Module = Ml.Module - - type t = (Module.sig_ Module.t, Module.impl Module.t) Ml.Kind.pair - - let type_decls name (type_decls : Ml.Type.decl Named.t list Ml.Kind.Map.t) : t = - let module_ bindings = { Ml.Module.name; bindings } in - let intf : Module.sig_ Module.t = - List.map type_decls.intf ~f:(fun (td : Ml.Type.decl Named.t) -> - { td with Named.data = (Ml.Module.Type_decl td.data : Ml.Module.sig_) }) - |> module_ - in - let impl = - List.map type_decls.impl ~f:(fun (td : Ml.Type.decl Named.t) -> - { td with Named.data = Ml.Module.Type_decl td.data }) - |> module_ - in - { Ml.Kind.intf; impl } - ;; - - let add_private_values (t : t) bindings : t = - let bindings = - List.map bindings ~f:(fun (v : _ Named.t) -> - { v with Named.data = Ml.Module.Value v.data }) - in - let impl = { t.impl with bindings = t.impl.bindings @ bindings } in - { t with impl } - ;; - - let json_assoc_t = Ml.Path.Dot (Dot (Ident "Json", "Assoc"), "t") - - let rename_invalid_fields = - let map (kind : Ml.Kind.t) = - let open Ml.Type in - object (self) - inherit [unit, unit] Ml.Type.mapreduce as super - method empty = () - method plus () () = () - - method! field x f = - let f = - if Ml.is_kw f.name - then ( - let attrs = - match kind with - | Impl -> ("key", [ sprintf "%S" f.name ]) :: f.attrs - | Intf -> f.attrs - in - { f with name = f.name ^ "_"; attrs }) - else f - in - super#field x f - - method! assoc x k v = self#t x (App (Path json_assoc_t, [ k; v ])) - end - in - fun kind t -> (map kind)#decl () t |> fst - ;; - - let use_json_conv_types = - let map = - let open Ml.Type in - object (self) - inherit [unit, unit] Ml.Type.mapreduce as super - method empty = () - method plus () () = () - - method! optional x t = - if t = Json_gen.json_t - then super#optional x t - else ( - let opt = Ml.Path.Dot (Dot (Ident "Json", "Nullable_option"), "t") in - self#t x (App (Path opt, [ t ]))) - - method! field x f = - let f = - match f.typ with - | Optional t -> - if t = Json_gen.json_t - then { f with attrs = ("yojson.option", []) :: f.attrs } - else - { f with - attrs = - ("default", [ "None" ]) - :: ("yojson_drop_default", [ "( = )" ]) - :: f.attrs - } - | _ -> f - in - super#field x f - - method! assoc x k v = self#t x (App (Path json_assoc_t, [ k; v ])) - end - in - fun (t : t) -> - let impl = - let bindings = - List.map t.impl.bindings ~f:(fun (x : _ Named.t) -> - let data = - match (x.data : Module.impl) with - | Type_decl decl -> Ml.Module.Type_decl (map#decl () decl |> fst) - | x -> x - in - { x with data }) - in - { t.impl with bindings } - in - { t with impl } - ;; - - let pp (t : t) ~kind = - match (kind : Ml.Kind.t) with - | Intf -> Ml.Module.pp_sig t.intf - | Impl -> Ml.Module.pp_impl t.impl - ;; - - let pp t = { Ml.Kind.intf = pp t ~kind:Intf; impl = pp t ~kind:Impl } -end - -let enum_module ~allow_other ({ Named.name; data = constrs } as t) = - let json_bindings = Json_gen.Enum.conv ~allow_other ~poly:false { t with name = "t" } in - let t = - let data = - let constrs = List.map constrs ~f:(fun (name, _) -> Ml.Type.constr ~name []) in - let constrs = - if allow_other - then - (* [String] is a hack. It could be a differnt type, but it isn't in - practice *) - constrs @ [ Ml.Type.constr ~name:"Other" [ Ml.Type.Prim String ] ] - else constrs - in - Ml.Type.Variant constrs - in - { Named.name = "t"; data } - in - let type_decls = Ml.Kind.Map.make_both [ t ] in - let module_ = Module.type_decls (Ml.Module.Name.of_string name) type_decls in - Module.add_private_values module_ json_bindings -;; - -module Entities = struct - type t = (Ident.t * Resolved.t) list - - let find db e : _ Named.t = - match List.assoc db e with - | Some s -> s - | None -> Code_error.raise "Entities.find: unable to find" [ "e", Ident.to_dyn e ] - ;; - - let of_map map ts = - List.map ts ~f:(fun (r : Resolved.t) -> String.Map.find_exn map r.name, r) - ;; - - let rev_find (db : t) (resolved : Resolved.t) : Ident.t = - match - List.filter_map db ~f:(fun (id, r) -> - if r.name = resolved.name then Some id else None) - with - | [] -> Code_error.raise "rev_find: resolved not found" [] - | [ x ] -> x - | _ :: _ -> Code_error.raise "re_vind: duplicate entries" [] - ;; -end - -module Mapper : sig - (* Convert typescript types to OCaml types *) - - val make_typ : Entities.t -> Resolved.typ Named.t -> Ml.Type.t - - type literal_field = - { field_name : string - ; literal_value : string - } - - (** Map a TS record into an OCaml record. Literal valued fields such as kind: - 'foo' are extracted into a separate list *) - val record_ - : Entities.t - -> Resolved.field list Named.t - -> Ml.Type.decl Named.t * literal_field list - - (** Extract all untagged unions in field position. These will be turned into - polymorphic variants using a naming scheme for the tags. *) - val extract_poly_vars : Ml.Type.decl -> Ml.Type.decl * Ml.Type.constr list Named.t list -end = struct - type literal_field = - { field_name : string - ; literal_value : string - } - - module Type = Ml.Type - - let is_same_as_json = - let constrs = - [ Prim.Null; String; Bool; Number; Object; List ] - |> List.map ~f:(fun s -> Resolved.Ident s) - in - fun set -> List.for_all constrs ~f:(fun e -> List.mem set e ~equal:Poly.equal) - ;; - - let id = Type.name "Jsonrpc.Id.t" - - let is_same_as_id = - let sort = List.sort ~compare:Poly.compare in - let constrs = - [ Prim.String; Number ] |> List.map ~f:(fun s -> Resolved.Ident s) |> sort - in - fun cs -> List.equal ( = ) constrs (sort cs) - ;; - - (* Any type that includes null needs to be extracted to be converted to an - option *) - let remove_null cs = - let is_null x = - match x with - | Resolved.Ident Prim.Null -> Either.Left x - | _ -> Right x - in - let nulls, non_nulls = List.partition_map ~f:is_null cs in - match nulls with - | [] -> `No_null_present - | _ :: _ :: _ -> assert false - | [ _ ] -> `Null_removed non_nulls - ;; - - let make_typ db { Named.name; data = t } = - let rec type_ topmost_field_name (t : Resolved.typ) = - match t with - | Ident Uinteger -> Type.int (* XXX shall we use a dedicated uinteger eventually? *) - | Ident Number -> Type.int - | Ident String -> Type.string - | Ident Bool -> Type.bool - | Ident Object -> Type.json_object - | Ident Self -> Type.t (* XXX wrong *) - | Ident Any -> Type.json - | Ident Null -> assert false - | Ident List -> Type.list Type.json - | Ident Uri | Ident (Resolved { id = _; name = "URI" }) -> - Type.module_t "DocumentUri" - | Ident (Resolved { id = _; name = "LSPAny" }) -> Type.json - | Ident (Resolved { id = _; name = "LSPObject" }) -> Type.json_object - | Ident (Resolved r) -> - let entity = Entities.find db r in - Type.module_t entity.name - | List (Ident (Uinteger | Number)) when topmost_field_name = Some "data" -> - Type.array Type.int - | List t -> Type.list (type_ topmost_field_name t) - | Tuple ts -> Type.Tuple (List.map ~f:(type_ topmost_field_name) ts) - | Sum s -> sum topmost_field_name s - | App _ | Literal _ -> Type.void - | Record r -> record r - and sum topmost_field_name s = - if is_same_as_json s - then Type.json - else ( - match remove_null s with - | `No_null_present -> if is_same_as_id s then id else poly topmost_field_name s - | `Null_removed [ s ] -> Type.Optional (type_ topmost_field_name s) - | `Null_removed [] -> assert false - | `Null_removed cs -> Type.Optional (sum topmost_field_name cs)) - and simplify_record (fields : Resolved.field list) = - (* A record with only a pattern field is simplified to an association - list *) - match fields with - | [ { Named.name; data = Pattern { pat; typ } } ] -> - let topmost_field_name = Some name in - let key = type_ topmost_field_name pat in - let data = type_ topmost_field_name typ in - Some (Type.assoc_list ~key ~data) - | [] -> Some Type.json_object - | _ -> None - and record fields = - match simplify_record fields with - | None -> Type.name name - | Some a -> a - and poly topmost_field_name s : Ml.Type.t = - let type_ = type_ topmost_field_name in - try - Poly_variant - (List.map s ~f:(fun t -> - let name, constrs = - match (t : Resolved.typ) with - | Ident Self | Ident Null -> assert false - | Ident String -> "String", [ type_ t ] - | Ident Number -> "Int", [ type_ t ] - | Ident Object -> "Assoc", [ type_ t ] - | Ident Bool -> "Bool", [ type_ t ] - | List _ | Ident List -> "List", [ type_ t ] - | Ident (Resolved r) -> (Entities.find db r).name, [ type_ t ] - | Tuple [ Ident Uinteger; Ident Uinteger ] -> "Offset", [ type_ t ] - | Literal (String x) -> x, [] - | Record _ -> - let topmost_field_name = Option.value_exn topmost_field_name in - topmost_field_name, [ type_ t ] - | _ -> raise Exit - in - Type.constr ~name constrs)) - with - | Exit -> Type.unit - in - type_ (Some name) t - ;; - - let make_field db (field : Resolved.field) = - match field.data with - | Pattern { pat; typ } -> - let key = make_typ db { Named.name = field.name; data = pat } in - let data = make_typ db { Named.name = field.name; data = typ } in - let typ = Type.assoc_list ~key ~data in - Either.Left (Ml.Type.field typ ~name:field.name) - | Single { typ = Literal s; optional = false } -> - let literal_value = - match s with - | String s -> s - | _ -> assert false - in - Right { literal_value; field_name = field.name } - | Single { typ; optional } -> - let typ = make_typ db { Named.name = field.name; data = typ } in - let typ = if optional then Type.Optional typ else typ in - Left (Ml.Type.field typ ~name:field.name) - ;; - - let record_ db { Named.name; data = (fields : Resolved.field list) } = - let data, literals = - match fields with - | [ { Named.name; data = Pattern { pat; typ } } ] -> - let key = make_typ db { Named.name; data = pat } in - let data = make_typ db { Named.name; data = typ } in - Type.Alias (Type.assoc_list ~key ~data), [] - | [] -> Type.Alias Type.json_object, [] - | _ -> - let fields, literals = List.partition_map fields ~f:(make_field db) in - Type.Record fields, literals - in - { Named.name; data }, literals - ;; - - let extract_poly_vars s = - let extract = - object (self) - inherit - [string option, Ml.Type.constr list Named.t list] Ml.Type.mapreduce as super - - method empty = [] - - (* TODO grossly slow *) - method plus x y = x @ y - - method! field _ (f : Ml.Type.field) = - let env = Some f.name in - super#field env f - - method! poly_variant env constrs = - match env with - | None -> super#poly_variant env constrs - | Some name -> - (* This hack is needed to avoid collision with user visible types - that we might introduce *) - let name = name ^ "_pvar" in - let replacement = Ml.Type.name name in - let constrs, m = self#fold_left_map ~f:(self#constr env) constrs in - replacement, self#plus m [ { Named.name; data = constrs } ] - end - in - extract#decl None s - ;; -end - -module Gen : sig - val module_ : Entities.t -> Expanded.binding Ml.Module.t -> Module.t -end = struct - module Type = Ml.Type - - let type_ db ({ Named.name; data = _ } as t) = - let main_type = - let typ = Mapper.make_typ db t in - { Named.name; data = Type.Alias typ } - in - [ main_type ] - ;; - - let record db ({ Named.name = _; data = _ } as t) = - let main_type, literals = Mapper.record_ db t in - Some (main_type, literals) - ;; - - let poly_enum { Named.name; data = _ } : Type.decl Named.t list = - [ { Named.name; data = Type.Alias Type.unit } ] - ;; - - let poly_enum_conv (t : _ Named.t) = - if List.for_all t.data ~f:(fun (c : Ml.Type.constr) -> List.is_empty c.args) - then - (* This is equivalent to an enum *) - List.map t.data ~f:(fun (c : Ml.Type.constr) -> c.name, Literal.String c.name) - |> Named.set_data t - |> Json_gen.Enum.conv ~allow_other:false ~poly:true - else [ Json_gen.Poly_variant.of_json t; Json_gen.Poly_variant.to_json t ] - ;; - - (* This is the more complex case *) - - let module_ db { Ml.Module.name; bindings } : Module.t = - let type_decls = - let add_record = function - | None -> [] - | Some (decl, literals) -> [ `Record (decl, literals) ] - in - let add_else = List.map ~f:(fun x -> `Type x) in - List.concat_map bindings ~f:(fun (r : Expanded.binding Named.t) -> - match r.data with - | Record data -> record db { r with data } |> add_record - | Interface data -> record db { r with data = data.fields } |> add_record - | Poly_enum data -> poly_enum { r with data } |> add_else - | Alias data -> type_ db { r with data } |> add_else) - in - let intf : Ml.Module.sig_ Named.t list = - List.map type_decls ~f:(function - | `Record (t, _) -> t - | `Type t -> t) - |> List.concat_map ~f:(fun (td : Ml.Type.decl Named.t) -> - let td = { td with data = Module.rename_invalid_fields Intf td.data } in - [ { td with Named.data = (Ml.Module.Type_decl td.data : Ml.Module.sig_) } ] - @ Ml_create.intf_of_type td) - in - let impl : Ml.Module.impl Named.t list = - (* TODO we should make sure to handle duplicate variants extracted *) - List.concat_map type_decls ~f:(fun d -> - let d, literal_wrapper = - match d with - | `Record (l, [ lw ]) -> l, Some lw - | `Record (l, []) -> l, None - | `Record (_, _ :: _) -> - assert false - (* we don't support multiple literals in a single record for - now *) - | `Type l -> l, None - in - let typ_, poly_vars = Mapper.extract_poly_vars (Named.data d) in - let poly_vars_and_convs = - List.concat_map poly_vars ~f:(fun pv -> - let decl = - Named.map pv ~f:(fun decl -> - Ml.Module.Type_decl (Alias (Poly_variant decl))) - in - let json_conv = - poly_enum_conv pv |> List.map ~f:(Named.map ~f:(fun v -> Ml.Module.Value v)) - in - decl :: json_conv) - in - let typ_ = { d with data = typ_ } in - let literal_wrapper = - match literal_wrapper with - | None -> [] - | Some { field_name; literal_value } -> - Json_gen.make_literal_wrapper_conv - ~field_name - ~literal_value - ~type_name:typ_.name - in - let typ_ = { typ_ with data = Module.rename_invalid_fields Impl typ_.data } in - let json_convs_for_t = - match d.data with - | Alias (Poly_variant data) -> - poly_enum_conv { d with Named.data } - |> List.map ~f:(Named.map ~f:(fun v -> Ml.Module.Value v)) - | _ -> [] - in - poly_vars_and_convs - @ [ { typ_ with data = Ml.Module.Type_decl typ_.data } ] - @ json_convs_for_t - @ Ml_create.impl_of_type typ_ - @ literal_wrapper) - in - let module_ bindings = { Ml.Module.name; bindings } in - { Ml.Kind.intf = module_ intf; impl = module_ impl } - ;; -end - -(* extract all resovled identifiers *) -class name_idents = - object - inherit [Ident.t list] Resolved.fold - - method! ident i ~init = - match i with - | Resolved r -> r :: init - | _ -> init - end - -let resolve_typescript (ts : Unresolved.t list) = - let ts, db = Typescript.resolve_all ts in - let db = Entities.of_map db ts in - match - let idents = new name_idents in - Ident.Top_closure.top_closure - ts - ~key:(fun x -> Entities.rev_find db x) - ~deps:(fun x -> idents#t x ~init:[] |> List.map ~f:(Entities.find db)) - with - | Error cycle -> - let cycle = List.map cycle ~f:(fun (x : Resolved.t) -> x.name) in - Code_error.raise "Unexpected cycle" [ "cycle", Dyn.(list string) cycle ] - | Ok ts -> db, ts -;; - -let of_resolved_typescript db (ts : Resolved.t list) = - let simple_enums, everything_else = - List.filter_partition_map ts ~f:(fun (t : Resolved.t) -> - if List.mem skipped_ts_decls t.name ~equal:String.equal - then Skip - else ( - match t.data with - | Enum_anon data -> Left { t with data } - | Interface _ | Type _ -> Right t)) - in - let simple_enums = - List.map simple_enums ~f:(fun (t : _ Named.t) -> - (* "open" enums need an `Other constructor *) - let allow_other = List.mem ~equal:String.equal with_custom_values t.name in - let data = - List.filter_map t.data ~f:(fun (constr, v) -> - match (v : Ts_types.Enum.case) with - | Literal l -> Some (constr, l) - | Alias _ -> - (* TODO we don't handle these for now *) - None) - in - enum_module ~allow_other { t with data }) - in - let everything_else = - List.map everything_else ~f:(fun (t : _ Named.t) -> - let mod_ = Expanded.of_ts t in - Gen.module_ db mod_) - in - simple_enums @ everything_else - |> List.map ~f:(fun (decl : _ Ml.Kind.pair) -> - let decl = - let intf = Json_gen.add_json_conv_for_t decl.intf in - { decl with intf } - in - Module.use_json_conv_types decl) -;; - -let of_typescript ts = - let db, ts = resolve_typescript ts in - of_resolved_typescript db ts -;; diff --git a/lsp/bin/ocaml/ocaml.mli b/lsp/bin/ocaml/ocaml.mli deleted file mode 100644 index 42a03f910..000000000 --- a/lsp/bin/ocaml/ocaml.mli +++ /dev/null @@ -1,7 +0,0 @@ -module Module : sig - type t = (Ml.Module.sig_ Ml.Module.t, Ml.Module.impl Ml.Module.t) Ml.Kind.pair - - val pp : t -> unit Pp.t Ml.Kind.Map.t -end - -val of_typescript : Ts_types.Unresolved.t list -> Module.t list diff --git a/lsp/bin/ocaml/w.ml b/lsp/bin/ocaml/w.ml deleted file mode 100644 index 626ceb74b..000000000 --- a/lsp/bin/ocaml/w.ml +++ /dev/null @@ -1,199 +0,0 @@ -open Import -open Pp.O -open Pp - -type t = unit Pp.t -type w = t - -(* This module contains all the writing primitives *) - -let ident = verbatim -let i = verbatim -let quoted s = i (sprintf "%S" s) - -let surround delim a = - let start, finish = - match delim with - | `Paren -> i "(", i ")" - | `Curly -> i "{", i "}" - | `Square -> i "[", i "]" - in - Pp.concat [ start; a; finish ] -;; - -module Json = struct - let invalid_pat name = ident "json", Pp.textf "Json.error \"invalid %s\" json" name - let typ = "Json.t" - - module Literal = struct - let str n = sprintf "`String %S" n - let int i = sprintf "`Int (%d)" i - let null = "`Null" - let bool b = sprintf "`Bool %b" b - end - - let str = sprintf "`String %s" - let int = sprintf "`Int %s" - let bool = sprintf "`Bool %s" -end - -module Gen = struct - let record ~delim fields = - let sep = Pp.concat [ Pp.verbatim ";"; Pp.newline ] in - Pp.text "{" - ++ Pp.concat_map ~sep fields ~f:(fun (name, f) -> - Pp.concat [ Pp.textf "%s %s " name delim; f ]) - ++ Pp.verbatim "}" - ;; - - let clause ~delim l r = Pp.concat [ l; Pp.verbatim (sprintf " %s " delim); r ] -end - -module Attr = struct - type t = - { name : string - ; payload : w list - } - - let make name payload = { name; payload } - - let pp kind { name; payload } = - let kind = - match kind with - | `Field -> "@" - | `Type -> "@@" - in - Pp.concat [ i kind; i name; Pp.space; Pp.concat ~sep:Pp.space payload ] - |> surround `Square - ;; -end - -module Type = struct - let string = i "string" - let int = i "int" - let name = i - let bool = i "bool" - let gen_decl kw name body = Pp.concat [ Pp.textf "%s %s =" kw name; Pp.newline; body ] - let and_ name body = gen_decl "and" name body - let decl name body = gen_decl "type" name body - let record fields = Gen.record ~delim:":" fields - - let field_attrs ~field ~attrs = - match attrs with - | [] -> field - | attrs -> - let attrs = Pp.concat_map attrs ~sep:Pp.space ~f:(Attr.pp `Field) in - Pp.concat [ field; Pp.space; attrs ] - ;; - - let var typ = Pp.textf "'%s" typ - - let app typ = function - | [] -> assert false - | [ x ] -> Pp.concat [ x; Pp.space; typ ] - | xs -> - let args = - let sep = Pp.verbatim "," in - Pp.concat [ Pp.verbatim "("; Pp.concat ~sep xs; Pp.verbatim ")" ] - in - Pp.concat [ args; Pp.space; typ ] - ;; - - let tuple fields = - let sep = i "*" in - i "(" ++ Pp.concat ~sep fields ++ i ")" - ;; - - let rec_decls xs = - match xs with - | [] -> Pp.concat [] - | (name, body) :: xs -> - decl name body - ++ newline - ++ Pp.concat_map xs ~sep:Pp.newline ~f:(fun (name, body) -> and_ name body) - ;; - - let deriving td ~record = - let fields = if record then space ++ i "[@@yojson.allow_extra_fields]" else space in - Pp.concat - [ td - ; Pp.newline - ; Pp.text "[@@deriving_inline yojson]" - ; fields - ; space - ; Pp.text "[@@@end]" - ] - ;; - - let opt_attr = ident "option [@yojson.option]" - let opt_field f = Pp.seq f opt_attr - let default f def = Pp.concat [ f; ident "[@default "; ident def; ident "]" ] - let key name = concat [ ident "[@key "; quoted name; ident "]" ] - - let gen_variant ~poly constrs = - let sep = Pp.concat [ Pp.newline; i "| " ] in - Pp.concat_map constrs ~sep ~f:(fun (name, arg) -> - let name = - let name = String.capitalize_ascii name in - if poly then "`" ^ name else name - in - match arg with - | [] -> i name - | xs -> - let xs = - match xs with - | [ x ] -> x - | xs -> tuple xs - in - Gen.clause ~delim:"of" (ident name) xs) - ;; - - let poly constrs = concat [ i "["; gen_variant ~poly:true constrs; i "]" ] - let variant constrs = gen_variant ~poly:false constrs -end - -let gen_module kw name body = - Pp.concat - [ Pp.textf "module %s %s" name kw - ; Pp.newline - ; body - ; newline - ; verbatim "end" - ; newline - ] -;; - -module Sig = struct - let module_ name body = gen_module ": sig" name body - - let include_ name destructive_subs = - let inc_ = Pp.textf "include %s" name in - match destructive_subs with - | [] -> inc_ - | substs -> - let substs = - let sep = Pp.text " and " in - Pp.concat_map ~sep substs ~f:(fun (l, r) -> - Pp.concat - [ Pp.text "type"; Pp.space; l; Pp.space; Pp.verbatim ":="; Pp.space; r ]) - in - Pp.concat [ inc_; Pp.space; Pp.text "with"; Pp.space; substs ] - ;; - - let val_ name b = - let sep = Pp.concat [ space; i "->"; space ] in - let b = Pp.concat ~sep b in - Pp.concat [ textf "val %s : " name; b; Pp.newline ] - ;; - - let assoc k v = Pp.concat [ Type.tuple [ k; v ]; Pp.space; i "list" ] -end - -let warnings codes = seq (textf "[@@@warning %S]" codes) newline - -let opens names = - Pp.concat_map names ~f:(fun name -> Pp.concat [ textf "open! %s" name; newline ]) -;; - -let module_ name body = gen_module "= struct" name body -let record fields = Gen.record ~delim:"=" fields diff --git a/lsp/bin/ocaml/w.mli b/lsp/bin/ocaml/w.mli deleted file mode 100644 index b5ae1ebf2..000000000 --- a/lsp/bin/ocaml/w.mli +++ /dev/null @@ -1,62 +0,0 @@ -(** Helpers to generate OCaml code. Consider merging with ML *) - -type t = unit Pp.t -type w = t - -val surround : [ `Curly | `Paren | `Square ] -> 'a Pp.t -> 'a Pp.t - -module Json : sig - val invalid_pat : string -> w * w - val typ : string - - module Literal : sig - val str : string -> string - val int : int -> string - val null : string - val bool : bool -> string - end - - val str : string -> string - val int : string -> string - val bool : string -> string -end - -module Attr : sig - type t - - val make : string -> unit Pp.t list -> t -end - -module Type : sig - val string : w - val int : w - val bool : w - val name : string -> w - val and_ : string -> w -> w - val decl : string -> w -> w - val record : (string * w) list -> w - val field_attrs : field:w -> attrs:Attr.t list -> w - val rec_decls : (string * w) list -> w - val var : string -> w - val poly : (string * w list) list -> w - val app : w -> w list -> w - val tuple : w list -> w - val deriving : w -> record:bool -> w - val opt_attr : w - val opt_field : w -> w - val default : w -> string -> w - val key : string -> w - val variant : (string * w list) list -> w -end - -module Sig : sig - val module_ : string -> w -> w - val include_ : string -> (w * w) list -> w - val val_ : string -> w list -> w - val assoc : w -> w -> w -end - -val warnings : string -> w -val module_ : string -> w -> w -val opens : string list -> w -val record : (string * w) list -> w diff --git a/lsp/bin/test_metamodel.ml b/lsp/bin/test_metamodel.ml deleted file mode 100644 index 931412a1a..000000000 --- a/lsp/bin/test_metamodel.ml +++ /dev/null @@ -1,11 +0,0 @@ -module Metamodel = Lsp_gen.Metamodel - -let file = Sys.argv.(1) - -let () = - let read = open_in file in - let s = really_input_string read (in_channel_length read) in - let json = Yojson.Safe.from_string s in - let (_ : Metamodel.t) = Metamodel.t json in - close_in read -;; diff --git a/lsp/bin/typescript/ts_types.ml b/lsp/bin/typescript/ts_types.ml deleted file mode 100644 index c454410ed..000000000 --- a/lsp/bin/typescript/ts_types.ml +++ /dev/null @@ -1,423 +0,0 @@ -(* Representation of the typescript defined spec we're working with *) - -open Import - -module Literal = struct - type t = - | String of string - | Int of int - | Float of float - - let to_maybe_quoted_string = function - | String s -> sprintf "%S" s - | Int i -> string_of_int i - | Float f -> string_of_float f - ;; - - let to_dyn : t -> Dyn.t = - let open Dyn in - function - | String s -> string s - | Int i -> int i - | Float f -> float f - ;; -end - -module Enum = struct - type case = - | Literal of Literal.t - | Alias of string - - let dyn_of_case = - let open Dyn in - function - | Literal l -> variant "Literal" [ Literal.to_dyn l ] - | Alias l -> variant "Alias" [ string l ] - ;; - - type t = (string * case) list - - let to_dyn t = - let open Dyn in - list (fun (name, case) -> pair string dyn_of_case (name, case)) t - ;; -end - -module type S = sig - (** Kept abstract for resolved vs. unresolved trees *) - type ident - - type field_def = - | Single of - { optional : bool - ; typ : typ - } - | Pattern of - { pat : typ - ; typ : typ - } - - and field = field_def Named.t - - and typ = - | Literal of Literal.t - | Ident of ident - | Sum of typ list - | List of typ - | Record of field list - | Tuple of typ list - | App of typ * typ - - and interface = { fields : field list } - - and decl = - | Interface of interface - | Type of typ - | Enum_anon of Enum.t - - and t = decl Named.t - - val to_dyn : t -> Dyn.t - val dyn_of_typ : typ -> Dyn.t - val dyn_of_field : field -> Dyn.t - - class map : object - method typ : typ -> typ - method sum : typ list -> typ - method interface : interface -> interface - method enum_anon : Enum.t -> Enum.t - method field : field -> field - method t : t -> t - end - - class ['a] fold : object - method field : field -> init:'a -> 'a - method ident : ident -> init:'a -> 'a - method t : t -> init:'a -> 'a - method typ : typ -> init:'a -> 'a - end -end - -module Make (Ident : sig - type t - - val to_dyn : t -> Dyn.t - end) = -struct - type field_def = - | Single of - { optional : bool - ; typ : typ - } - | Pattern of - { pat : typ - ; typ : typ - } - - and field = field_def Named.t - - and typ = - | Literal of Literal.t - | Ident of Ident.t - | Sum of typ list - | List of typ - | Record of field list - | Tuple of typ list - | App of typ * typ - - and interface = { fields : field list } - - and decl = - | Interface of interface - | Type of typ - | Enum_anon of Enum.t - - and t = decl Named.t - - let rec dyn_of_typ = - let open Dyn in - function - | Literal l -> variant "Literal" [ Literal.to_dyn l ] - | Ident l -> variant "Ident" [ Ident.to_dyn l ] - | Sum l -> variant "Sum" (List.map ~f:dyn_of_typ l) - | List l -> variant "List" [ dyn_of_typ l ] - | Tuple l -> variant "Tuple" (List.map ~f:dyn_of_typ l) - | App (f, x) -> variant "App" [ dyn_of_typ f; dyn_of_typ x ] - | Record fs -> variant "Record" (List.map fs ~f:dyn_of_field) - - and field_def_of_dyn = - let open Dyn in - function - | Single { optional; typ } -> - record [ "optional", bool optional; "typ", dyn_of_typ typ ] - | Pattern { pat : typ; typ : typ } -> - record [ "pat", dyn_of_typ pat; "typ", dyn_of_typ typ ] - - and dyn_of_field f = Named.to_dyn field_def_of_dyn f - - let dyn_of_interface { fields } = - let open Dyn in - record [ "fields", (list dyn_of_field) fields ] - ;; - - let dyn_of_decl = - let open Dyn in - function - | Interface i -> variant "Interface" [ dyn_of_interface i ] - | Type t -> variant "Type" [ dyn_of_typ t ] - | Enum_anon t -> variant "Enum_anon" [ Enum.to_dyn t ] - ;; - - let to_dyn t = Named.to_dyn dyn_of_decl t - - class ['a] fold = - object (self) - method t (t : t) ~init = - match t.data with - | Interface (i : interface) -> - List.fold_left ~init i.fields ~f:(fun init f -> self#field f ~init) - | Type (t : typ) -> self#typ t ~init - | Enum_anon _ -> init - - method ident _ ~init = init - - method field (f : field) ~init : 'a = - match f.data with - | Single { optional = _; typ } -> self#typ ~init typ - | Pattern { pat; typ } -> - let init = self#typ ~init pat in - self#typ ~init typ - - method typ (t : typ) ~init = - match t with - | Literal _ -> init - | Ident i -> self#ident i ~init - | App (t1, t2) -> - let init = self#typ t1 ~init in - self#typ t2 ~init - | List t -> self#typ t ~init - | Tuple typs | Sum typs -> - List.fold_left typs ~init ~f:(fun init f -> self#typ f ~init) - | Record fs -> List.fold_left fs ~init ~f:(fun init f -> self#field f ~init) - end - - class map = - object (self) - method field (f : field) = - let data = - match f.data with - | Single s -> - let typ = self#typ s.typ in - Single { s with typ } - | Pattern { pat; typ } -> - let pat = self#typ pat in - let typ = self#typ typ in - Pattern { pat; typ } - in - { f with data } - - method interface (i : interface) = - let fields = List.map ~f:self#field i.fields in - { fields } - - method sum (constrs : typ list) = Sum (List.map constrs ~f:self#typ) - - method typ (t : typ) = - match t with - | Literal i -> Literal i - | Ident i -> Ident i - | App (x, y) -> - let x = self#typ x - and y = self#typ y in - App (x, y) - | List t -> List (self#typ t) - | Tuple ts -> Tuple (List.map ts ~f:self#typ) - | Sum ts -> self#sum ts - | Record ts -> Record (List.map ts ~f:self#field) - - method enum_anon (t : Enum.t) = t - - method t (t : t) = - let data = - match t.data with - | Interface i -> Interface (self#interface i) - | Type t -> Type (self#typ t) - | Enum_anon t -> Enum_anon (self#enum_anon t) - in - { t with data } - end -end - -module Unresolved = struct - (** In the unresolved AST, all identifiers are just strings *) - include Make (String) - - let enum ~name ~constrs : Enum.t Named.t = { Named.name; data = constrs } - let interface ~name ~fields : interface Named.t = { Named.name; data = { fields } } - let pattern_field ~name ~pat ~typ = { Named.name; data = Pattern { pat; typ } } - - let named_field ?(optional = false) typ name = - { Named.name; data = Single { optional; typ } } - ;; -end - -module Ident = struct - module Id = Stdune.Id.Make () - - module T = struct - type t = - { id : Id.t - ; name : string - } - - let to_dyn { id; name } = - let open Dyn in - record [ "id", Id.to_dyn id; "name", String name ] - ;; - - let compare t { id; name = _ } = Id.compare t.id id - end - - include T - - let make name = { name; id = Id.gen () } - - module C = Comparable.Make (T) - module Set = C.Set - module Top_closure = Top_closure.Make (Set) (Stdune.Monad.Id) -end - -module Prim = struct - type t = - | Null - | String - | Bool - | Number - | Uinteger - | Uri - | Any - | Object - | List - | Self - | Resolved of Ident.t - - let to_dyn = - let open Dyn in - function - | Null -> variant "Null" [] - | String -> variant "String" [] - | Bool -> variant "Bool" [] - | Number -> variant "Number" [] - | Uinteger -> variant "Uinteger" [] - | Any -> variant "Any" [] - | Object -> variant "Object" [] - | List -> variant "List" [] - | Self -> variant "Self" [] - | Uri -> variant "Uri" [] - | Resolved r -> variant "Resolved" [ Ident.to_dyn r ] - ;; - - let of_string s ~resolve = - match String.lowercase_ascii s with - | "null" -> Null - | "string" -> String - | "boolean" -> Bool - | "number" -> Number - | "uinteger" -> Uinteger - | "json" -> Any - | "lspany" -> Any - | "array" -> List - | "object" -> Object - | "lspobject" -> Object - | "uri" -> Uri - | _ -> resolve s - ;; -end - -module Resolved = Make (Prim) - -let subst unresolved = - object - val params = String.Map.empty - val inside = None - - (* Resolve self references. *) - method inside s = {} - - method resolve n = - match String.Map.find params n with - | Some [] -> assert false - | Some (x :: _) -> `Resolved x - | None -> - if inside = Some n then `Self else `Unresolved (String.Map.find_exn unresolved n) - - method push x y = - let params = - String.Map.update params x ~f:(function - | None -> Some [ y ] - | Some [] -> assert false - | Some (y' :: xs) -> if y = y' then Some xs else Some (y :: y' :: xs)) - in - {} - - method pop x = - let params = - String.Map.update params x ~f:(function - | None -> - ignore (String.Map.find_exn params x); - None - | Some [] -> assert false - | Some (_ :: xs) -> Some xs) - in - {} - end -;; - -let rec resolve_all ts ~(names : Ident.t String.Map.t) : Resolved.t list = - let names = subst names in - List.map ts ~f:(resolve ~names) - -and resolve (t : Unresolved.t) ~names : Resolved.t = - let data : Resolved.decl = - match t.data with - | Interface i -> Interface (resolve_interface { t with data = i } ~names) - | Type t -> Type (resolve_type t ~names) - | Enum_anon a -> Enum_anon a - in - { t with Named.data } - -and resolve_ident i ~names : Prim.t = - Prim.of_string i ~resolve:(fun s -> - match names#resolve s with - | `Resolved s -> s - | `Self -> Self - | `Unresolved s -> Resolved s) - -and resolve_type (t : Unresolved.typ) ~names : Resolved.typ = - match t with - | Literal l -> Literal l - | Ident i -> Ident (resolve_ident ~names i) - | Sum l -> Sum (List.map ~f:(resolve_type ~names) l) - | Tuple l -> Tuple (List.map ~f:(resolve_type ~names) l) - | App (f, x) -> App (resolve_type ~names f, resolve_type ~names x) - | List t -> List (resolve_type t ~names) - | Record fields -> Record (List.map ~f:(resolve_field ~names) fields) - -and resolve_interface i ~names : Resolved.interface = - let names = names#inside i.name in - let i = i.data in - { fields = List.map ~f:(resolve_field ~names) i.fields } - -and resolve_field f ~names : Resolved.field = - let data : Resolved.field_def = - match f.data with - | Single { optional; typ } -> - let typ = resolve_type ~names typ in - Single { optional; typ } - | Pattern { pat; typ } -> - let typ = resolve_type ~names typ in - let pat = resolve_type ~names pat in - Pattern { pat; typ } - in - { f with Named.data } -;; diff --git a/lsp/bin/typescript/ts_types.mli b/lsp/bin/typescript/ts_types.mli deleted file mode 100644 index aa33961b9..000000000 --- a/lsp/bin/typescript/ts_types.mli +++ /dev/null @@ -1,128 +0,0 @@ -open Import - -module Literal : sig - type t = - | String of string - | Int of int - | Float of float - - val to_maybe_quoted_string : t -> string - val to_dyn : t -> Dyn.t -end - -module Enum : sig - type case = - | Literal of Literal.t - | Alias of string - - val dyn_of_case : case -> Dyn.t - - type t = (string * case) list - - val to_dyn : (string * case) list -> Dyn.t -end - -module type S = sig - type ident - - type field_def = - | Single of - { optional : bool - ; typ : typ - } - | Pattern of - { pat : typ - ; typ : typ - } - - and field = field_def Named.t - - and typ = - | Literal of Literal.t - | Ident of ident - | Sum of typ list - | List of typ - | Record of field list - | Tuple of typ list - | App of typ * typ - - and interface = { fields : field list } - - and decl = - | Interface of interface - | Type of typ - | Enum_anon of Enum.t - - and t = decl Named.t - - val to_dyn : t -> Dyn.t - val dyn_of_typ : typ -> Dyn.t - val dyn_of_field : field -> Dyn.t - - class map : object - method enum_anon : Enum.t -> Enum.t - method field : field -> field - method interface : interface -> interface - method sum : typ list -> typ - method t : t -> t - method typ : typ -> typ - end - - class ['a] fold : object - method field : field -> init:'a -> 'a - method ident : ident -> init:'a -> 'a - method t : t -> init:'a -> 'a - method typ : typ -> init:'a -> 'a - end -end - -module Unresolved : sig - include S with type ident := String.t - - val enum : name:string -> constrs:Enum.t -> Enum.t Named.t - val interface : name:string -> fields:field list -> interface Named.t - val pattern_field : name:string -> pat:typ -> typ:typ -> field_def Named.t - val named_field : ?optional:bool -> typ -> string -> field_def Named.t -end - -module Ident : sig - module Id : Id.S - - type t = - { id : Id.t - ; name : string - } - - val to_dyn : t -> Dyn.t - val make : string -> t - - module Top_closure : sig - val top_closure - : key:('a -> t) - -> deps:('a -> 'a list) - -> 'a list - -> ('a list, 'a list) result - end -end - -module Prim : sig - type t = - | Null - | String - | Bool - | Number - | Uinteger - | Uri - | Any - | Object - | List - | Self - | Resolved of Ident.t - - val to_dyn : t -> Dyn.t - val of_string : string -> resolve:(string -> t) -> t -end - -module Resolved : S with type ident := Prim.t - -val resolve_all : Unresolved.t list -> names:Ident.t String.Map.t -> Resolved.t list diff --git a/lsp/bin/typescript/typescript.ml b/lsp/bin/typescript/typescript.ml deleted file mode 100644 index e755d14cd..000000000 --- a/lsp/bin/typescript/typescript.ml +++ /dev/null @@ -1,128 +0,0 @@ -open Import -open Ts_types - -let name_table (defns : Unresolved.t list) = - List.map defns ~f:(fun (def : _ Named.t) -> - def.name, (def, Ts_types.Ident.make def.name)) - |> String.Map.of_list_reducei ~f:(fun name (v1, id1) (v2, id2) -> - let open Unresolved in - match v1.Named.data, v2.data with - | Enum_anon _, _ -> v1, id1 - | _, Enum_anon _ -> v2, id2 - | _, _ -> - if v1 = v2 - then v1, id1 - else - let open Dyn in - Code_error.raise "definition conflict" [ "name", string name ]) -;; - -let resolve_all (defns : Unresolved.t list) = - let names = name_table defns in - let defns = String.Map.values names |> List.map ~f:fst in - let names = String.Map.map ~f:snd names in - Ts_types.resolve_all defns ~names, names -;; - -module Unresolved = Ts_types.Unresolved -open Unresolved -open Metamodel - -let rename = function - | "_InitializeParams" -> "InitializedParams_" - | s -> s -;; - -let reference s = - match rename s with - | "LSPAny" -> "Json" - | s -> s -;; - -let named ~name s = - let name = rename name in - Named.make ~name s -;; - -let baseType (baseType : Metamodel.baseType) : Ts_types.Unresolved.typ = - match baseType with - | Uri -> Ident "URI" - | DocumentUri -> Ident "URI" - | Integer -> Ident "number" - | Uinteger -> Ident "uinteger" - | Decimal -> Ident "number" - | RegExp -> assert false - | String -> Ident "string" - | Boolean -> Ident "boolean" - | Null -> Ident "null" -;; - -let rec typ (type_ : Metamodel.type_) : Ts_types.Unresolved.typ = - match type_ with - | Reference s -> Ident (reference s) - | Base b -> baseType b - | Array t -> List (typ t) - | Or ts -> Sum (List.map ts ~f:typ) - | And _ -> failwith "and" - | Tuple ts -> Tuple (List.map ts ~f:typ) - | Literal l -> literal l - | Map m -> mapType m - -and mapType { Metamodel.key; value } : Ts_types.Unresolved.typ = - let pat = - match key with - | Uri -> Ident "URI" - | DocumentUri -> Ident "URI" - | String -> Ident "string" - | Integer -> Ident "number" - | Reference s -> Ident (reference s) - in - let typ = typ value in - let field = named ~name:"" (Pattern { pat; typ }) in - Record [ field ] - -and literal (l : Metamodel.literalType) : Ts_types.Unresolved.typ = - match l with - | String s -> Literal (String s) - | Boolean _ -> assert false - | Integer i -> Literal (Int i) - | Record fields -> Record (List.map ~f:field fields) - -and field { Metamodel.name; optional; doc = _; type_ } : Ts_types.Unresolved.field = - let field : Ts_types.Unresolved.field_def = Single { optional; typ = typ type_ } in - named ~name field -;; - -let structure - ({ doc = _; extends = _; mixins = _; name; properties } : Metamodel.structure) - : Ts_types.Unresolved.t - = - let interface : Ts_types.Unresolved.interface = - let fields = List.map properties ~f:field in - { fields } - in - named ~name (Interface interface) -;; - -let typeAlias ({ name; type_; doc = _ } : Metamodel.typeAlias) = - named ~name (Type (typ type_)) -;; - -let enumeration { doc = _; name; supportsCustomValues = _; type_ = _; values } = - named ~name - @@ Enum_anon - (List.map values ~f:(fun ({ name; value; doc = _ } : enumerationEntry) -> - let case : Enum.case = - match value with - | `Int i -> Literal (Int i) - | `String s -> Literal (String s) - in - name, case)) -;; - -let of_metamodel (m : Metamodel.t) : Ts_types.Unresolved.t list = - let structures = List.map m.structures ~f:structure in - let type_aliases = List.map m.typeAliases ~f:typeAlias in - let enumerations = List.map m.enumerations ~f:enumeration in - List.concat [ structures; type_aliases; enumerations ] -;; diff --git a/lsp/bin/typescript/typescript.mli b/lsp/bin/typescript/typescript.mli deleted file mode 100644 index 5f69c4042..000000000 --- a/lsp/bin/typescript/typescript.mli +++ /dev/null @@ -1,7 +0,0 @@ -open Import - -val of_metamodel : Metamodel.t -> Ts_types.Unresolved.t list - -val resolve_all - : Ts_types.Unresolved.t list - -> Ts_types.Resolved.t list * Ts_types.Ident.t String.Map.t diff --git a/lsp/src/array_view.mli b/lsp/src/array_view.mli index cbc758c4c..eff069148 100644 --- a/lsp/src/array_view.mli +++ b/lsp/src/array_view.mli @@ -1,14 +1,14 @@ type 'a t -(** [make arr ~pos ~len] can be thought of a new array for which the 0-th - element is [arr.(pos)] and has length [len] if specified. If [len] is - omitted, [Array.length arr - pos] is taken as the length. Importantly, the - "new array" does not copy but simply references [arr]. Hence, creating views - is constant time. However, keep in mind that since a view references an - array, the array will be alive in memory as long as the view is alive. +(** [make arr ~pos ~len] can be thought of a new array for which the 0-th element is + [arr.(pos)] and has length [len] if specified. If [len] is omitted, + [Array.length arr - pos] is taken as the length. Importantly, the "new array" does not + copy but simply references [arr]. Hence, creating views is constant time. However, + keep in mind that since a view references an array, the array will be alive in memory + as long as the view is alive. @raise Invalid_argument - if [pos + len > Array.length arr] or [pos < 0 || pos >= Array.length arr]*) + if [pos + len > Array.length arr] or [pos < 0 || pos >= Array.length arr] *) val make : ?len:int -> 'a array -> pos:int -> 'a t val get : 'a t -> int -> 'a diff --git a/lsp/src/cli.mli b/lsp/src/cli.mli index ac5e70746..3f508ff0f 100644 --- a/lsp/src/cli.mli +++ b/lsp/src/cli.mli @@ -17,16 +17,15 @@ module Arg : sig (** [create ()] create a new record for arguments *) val create : unit -> t - (** [spec t] returns the spec that should be provided to [Stdlib.Arg] to - populate [t] using the interpreted cli args *) + (** [spec t] returns the spec that should be provided to [Stdlib.Arg] to populate [t] + using the interpreted cli args *) val spec : t -> (string * Arg.spec * string) list - (** [channel t] return the channel if correctly supplied. An error if the - arguments were provided incorrectly. *) + (** [channel t] return the channel if correctly supplied. An error if the arguments were + provided incorrectly. *) val channel : t -> (Channel.t, string) result - (** Return the process id of the client used to run the lsp server if it was - provided *) + (** Return the process id of the client used to run the lsp server if it was provided *) val clientProcessId : t -> int option end diff --git a/lsp/src/client_notification.ml b/lsp/src/client_notification.ml index 2d678d973..904b4b256 100644 --- a/lsp/src/client_notification.ml +++ b/lsp/src/client_notification.ml @@ -159,3 +159,31 @@ let to_jsonrpc t = let params = yojson_of_t t |> Option.map Jsonrpc.Structured.t_of_yojson in { Jsonrpc.Notification.params; method_ } ;; + +let all_uris = function + | TextDocumentDidOpen t -> [ t.textDocument.uri ] + | TextDocumentDidClose t -> [ t.textDocument.uri ] + | TextDocumentDidChange t -> [ t.textDocument.uri ] + | DidSaveTextDocument t -> [ t.textDocument.uri ] + | WillSaveTextDocument t -> [ t.textDocument.uri ] + | DidChangeWatchedFiles t -> List.map ~f:(fun (c : FileEvent.t) -> c.uri) t.changes + | DidCreateFiles t -> + List.map ~f:(fun (f : FileCreate.t) -> f.uri |> Uri0.of_path) t.files + | DidDeleteFiles t -> + List.map ~f:(fun (f : FileDelete.t) -> f.uri |> Uri0.of_path) t.files + | DidRenameFiles t -> + List.map ~f:(fun (f : FileRename.t) -> f.newUri |> Uri0.of_path) t.files + | NotebookDocumentDidOpen t -> [ t.notebookDocument.uri ] + | NotebookDocumentDidChange t -> [ t.notebookDocument.uri ] + | NotebookDocumentDidSave t -> [ t.notebookDocument.uri ] + | NotebookDocumentDidClose t -> [ t.notebookDocument.uri ] + | ChangeWorkspaceFolders _ + | ChangeConfiguration _ + | Initialized + | Exit + | CancelRequest _ + | WorkDoneProgressCancel _ + | SetTrace _ + | WorkDoneProgress _ + | UnknownNotification _ -> [] +;; diff --git a/lsp/src/client_notification.mli b/lsp/src/client_notification.mli index a09c9003e..562b68d06 100644 --- a/lsp/src/client_notification.mli +++ b/lsp/src/client_notification.mli @@ -25,5 +25,9 @@ type t = | NotebookDocumentDidClose of DidCloseNotebookDocumentParams.t | UnknownNotification of Jsonrpc.Notification.t +(** This is a to_string function. It's exposed for use in logging. *) +val method_ : t -> string + val of_jsonrpc : Jsonrpc.Notification.t -> (t, string) result val to_jsonrpc : t -> Jsonrpc.Notification.t +val all_uris : t -> Uri0.t list diff --git a/lsp/src/client_request.ml b/lsp/src/client_request.ml index b100a2b9a..87d345efe 100644 --- a/lsp/src/client_request.ml +++ b/lsp/src/client_request.ml @@ -704,3 +704,92 @@ let text_document (type a) (t : a t) f : TextDocumentIdentifier.t option = | WillRenameFiles _ -> None | UnknownRequest { meth; params } -> f ~meth ~params ;; + +let all_uris (type a) (t : a t) ~fallback : Uri0.t list = + match t with + | TextDocumentLinkResolve r -> r.target |> Option.to_list + | CodeActionResolve r -> + (match Option.bind r.edit (fun (e : WorkspaceEdit.t) -> e.changes) with + | None -> [] + | Some changes -> List.map ~f:fst changes) + | WorkspaceSymbolResolve r -> [ r.location.uri ] + | WillCreateFiles r -> List.map r.files ~f:(fun { FileCreate.uri } -> Uri0.of_path uri) + | WillDeleteFiles r -> List.map r.files ~f:(fun { FileDelete.uri } -> Uri0.of_path uri) + | WillRenameFiles r -> + List.map r.files ~f:(fun { FileRename.newUri; _ } -> Uri0.of_path newUri) + | _ as req -> + text_document req fallback + |> Option.to_list + |> List.map ~f:(fun { TextDocumentIdentifier.uri } -> uri) +;; + +let positions (type a) (t : a t) ~fallback : Position.t list = + match t with + | CompletionItemResolve r -> + (match r.textEdit with + | None -> [] + | Some (`InsertReplaceEdit { insert; _ }) -> [ insert.end_ ] + | Some (`TextEdit { range; _ }) -> [ range.end_ ]) + | TextDocumentLinkResolve r -> [ r.range.end_ ] + | TextDocumentCodeLensResolve r -> [ r.range.end_ ] + | TextDocumentHover r -> [ r.position ] + | TextDocumentDefinition r -> [ r.position ] + | TextDocumentDeclaration r -> [ r.position ] + | TextDocumentTypeDefinition r -> [ r.position ] + | TextDocumentImplementation r -> [ r.position ] + | TextDocumentCompletion r -> [ r.position ] + | TextDocumentPrepareCallHierarchy r -> [ r.position ] + | TextDocumentPrepareTypeHierarchy r -> [ r.position ] + | TextDocumentPrepareRename r -> [ r.position ] + | TextDocumentRangeFormatting r -> [ r.range.end_ ] + | TextDocumentRangesFormatting r -> + List.map r.ranges ~f:(fun (range : Range.t) -> range.end_) + | TextDocumentRename r -> [ r.position ] + | DebugTextDocumentGet r -> [ r.position ] + | TextDocumentReferences r -> [ r.position ] + | TextDocumentHighlight r -> [ r.position ] + | TextDocumentMoniker r -> [ r.position ] + | SignatureHelp r -> [ r.position ] + | CodeAction r -> [ r.range.end_ ] + | CodeActionResolve r -> + (match Option.bind r.edit (fun (e : WorkspaceEdit.t) -> e.changes) with + | None -> [] + | Some changes -> + List.map ~f:snd changes + |> List.concat + |> List.map ~f:(fun (e : TextEdit.t) -> e.range.end_)) + | TextDocumentOnTypeFormatting r -> [ r.position ] + | TextDocumentColorPresentation r -> [ r.range.end_ ] + | SelectionRange r -> r.positions + | SemanticTokensRange r -> [ r.range.end_ ] + | LinkedEditingRange r -> [ r.position ] + | InlayHint r -> [ r.range.end_ ] + | TextDocumentInlineCompletion r -> [ r.position ] + | TextDocumentInlineValue r -> [ r.range.end_ ] + | WorkspaceSymbolResolve r -> [ r.location.range.end_ ] + | InlayHintResolve r -> [ r.position ] + | ExecuteCommand _ + | WorkspaceSymbol _ + | DebugEcho _ + | Shutdown + | Initialize _ + | TextDocumentCodeLens _ + | TextDocumentLink _ + | DocumentSymbol _ + | TextDocumentFoldingRange _ + | WillSaveWaitUntilTextDocument _ + | TextDocumentFormatting _ + | TextDocumentColor _ + | SemanticTokensFull _ + | SemanticTokensDelta _ + | TextDocumentDiagnostic _ + | TypeHierarchySubtypes _ + | TypeHierarchySupertypes _ + | WorkspaceDiagnostic _ + | CallHierarchyIncomingCalls _ + | CallHierarchyOutgoingCalls _ + | WillCreateFiles _ + | WillDeleteFiles _ + | WillRenameFiles _ -> [] + | UnknownRequest { meth; params } -> fallback ~meth ~params +;; diff --git a/lsp/src/client_request.mli b/lsp/src/client_request.mli index f02321a12..48f2620ac 100644 --- a/lsp/src/client_request.mli +++ b/lsp/src/client_request.mli @@ -122,3 +122,19 @@ val text_document -> params:Jsonrpc.Structured.t option -> TextDocumentIdentifier.t option) -> TextDocumentIdentifier.t option + +val all_uris + : _ t + -> fallback: + (meth:string + -> params:Jsonrpc.Structured.t option + -> Types.TextDocumentIdentifier.t option) + -> Uri0.t list + +val positions + : _ t + -> fallback:(meth:string -> params:Jsonrpc.Structured.t option -> Position.t list) + -> Position.t list + +(** This is a to_string function. It's exposed for use in logging. *) +val method_ : 'a t -> string diff --git a/lsp/src/dune b/lsp/src/dune index fecf6df28..18036c94f 100644 --- a/lsp/src/dune +++ b/lsp/src/dune @@ -3,8 +3,8 @@ (library (name lsp) (public_name lsp) - (libraries jsonrpc ppx_yojson_conv_lib uutf yojson) - (lint + (libraries base jsonrpc ppx_yojson_conv_lib uutf yojson) + (preprocess (pps ppx_yojson_conv)) (instrumentation (backend bisect_ppx))) diff --git a/lsp/src/extension.ml b/lsp/src/extension.ml index d4761b512..a56865a7b 100644 --- a/lsp/src/extension.ml +++ b/lsp/src/extension.ml @@ -3,85 +3,7 @@ open Json.Conv module DebugEcho = struct module T = struct - type t = { message : string } [@@deriving_inline yojson] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/extension.ml.DebugEcho.T.t" in - function - | `Assoc field_yojsons as yojson -> - let message_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "message" -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - message_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> - if - Ppx_yojson_conv_lib.( ! ) - Ppx_yojson_conv_lib.Yojson_conv.record_check_extra_fields - then extra := field_name :: Ppx_yojson_conv_lib.( ! ) extra - else ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.Some message_value -> - { message = message_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) message_field) - Ppx_yojson_conv_lib.Option.None - , "message" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { message = v_message } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_message in - ("message", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@deriving.end] + type t = { message : string } [@@deriving yojson] end module Params = T diff --git a/lsp/src/import.ml b/lsp/src/import.ml index 04cfdf71b..9b3159b7e 100644 --- a/lsp/src/import.ml +++ b/lsp/src/import.ml @@ -168,12 +168,12 @@ module Json = struct ;; let literal_field - (type a) - (name : string) - (k : string) - (v : string) - (f : t -> a) - (json : t) + (type a) + (name : string) + (k : string) + (v : string) + (f : t -> a) + (json : t) : a = match json with diff --git a/lsp/src/io.ml b/lsp/src/io.ml index 40a6ab185..fc8819de2 100644 --- a/lsp/src/io.ml +++ b/lsp/src/io.ml @@ -3,7 +3,7 @@ open Import exception Error of string let () = - Printexc.register_printer (function + (Printexc.register_printer [@ocaml.alert "-unsafe_multidomain"]) (function | Error msg -> Some ("Error: " ^ msg) | _ -> None) ;; @@ -64,9 +64,8 @@ struct | None -> loop chan content_length content_type | Some (k, v) -> let k = String.trim k in - if - caseless_equal k content_length_lowercase - && content_length = init_content_length + if caseless_equal k content_length_lowercase + && content_length = init_content_length then ( let content_length = int_of_string_opt (String.trim v) in match content_length with diff --git a/lsp/src/string_zipper.ml b/lsp/src/string_zipper.ml index d7a1ade1d..23fd82b57 100644 --- a/lsp/src/string_zipper.ml +++ b/lsp/src/string_zipper.ml @@ -8,7 +8,7 @@ type invalid_utf = exception Invalid_utf of invalid_utf let () = - Printexc.register_printer (function + (Printexc.register_printer [@ocaml.alert "-unsafe_multidomain"]) (function | Invalid_utf (Malformed s) -> Some (sprintf "malformed %S" s) | Invalid_utf Insufficient_input -> Some "insufficient input" | _ -> None) @@ -20,9 +20,8 @@ module T = struct ; rel_pos : int (** the cursor's position inside [current] *) ; abs_pos : int (** the total length of strings in [left] *) ; current : Substring.t - (** [current] needed to prevent fragmentation of the substring. E.g. - so that moving inside the substring doesn't create unnecessary - splits *) + (** [current] needed to prevent fragmentation of the substring. E.g. so that moving + inside the substring doesn't create unnecessary splits *) ; line : int (** the number of '\n' characters traversed past the current position *) ; right : Substring.t list } diff --git a/lsp/src/text_document.ml b/lsp/src/text_document.ml index 13ea05228..efd562429 100644 --- a/lsp/src/text_document.ml +++ b/lsp/src/text_document.ml @@ -29,10 +29,10 @@ type t = let position_encoding t = t.position_encoding let make - ~position_encoding - { DidOpenTextDocumentParams.textDocument = - { TextDocumentItem.languageId; text; uri; version } - } + ~position_encoding + { DidOpenTextDocumentParams.textDocument = + { TextDocumentItem.languageId; text; uri; version } + } = let zipper = String_zipper.of_string text in { text = Some text; position_encoding; zipper; uri; version; languageId } diff --git a/lsp/src/text_document.mli b/lsp/src/text_document.mli index 2ee794599..dcd24a33e 100644 --- a/lsp/src/text_document.mli +++ b/lsp/src/text_document.mli @@ -28,15 +28,14 @@ val apply_content_changes val set_version : t -> version:int -> t -(** Apply a list of non overlapping text edits. The order of application matters - when multiple inserts are done in the same position. All the offsets are - interpreted relative to the original document. *) +(** Apply a list of non overlapping text edits. The order of application matters when + multiple inserts are done in the same position. All the offsets are interpreted + relative to the original document. *) val apply_text_document_edits : t -> TextEdit.t list -> t -(** [absolute_position t pos] returns the absolute position of [pos] inside - [text t]. If the position is outside the bounds of the document, the offset - returned will be the length of the document. [pos] is interpreted with - [position_encoding t] *) +(** [absolute_position t pos] returns the absolute position of [pos] inside [text t]. If + the position is outside the bounds of the document, the offset returned will be the + length of the document. [pos] is interpreted with [position_encoding t] *) val absolute_position : t -> Position.t -> int (* [absolute_range t range] same as [(absolute_position t range.start , diff --git a/lsp/src/types.ml b/lsp/src/types.ml index 36c2730a3..953c9da86 100644 --- a/lsp/src/types.ml +++ b/lsp/src/types.ml @@ -1,40 +1,77 @@ open! Import open Json.Conv -module NotebookDocumentSyncOptions = struct - type t = unit [@@deriving_inline yojson] +module NotebookDocumentFilter = struct + type t = + { notebookType : string option [@yojson.option] + ; scheme : string option [@yojson.option] + ; pattern : string option [@yojson.option] + } + [@@deriving yojson] +end - let _ = fun (_ : t) -> () - let t_of_yojson = (unit_of_yojson : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - let _ = t_of_yojson - let yojson_of_t = (yojson_of_unit : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - let _ = yojson_of_t +module NotebookSelector = struct + type notebook_pvar = + [ `Notebook of string + | `NotebookDocumentFilter of NotebookDocumentFilter.t + ] - [@@@end] -end + let notebook_pvar_of_yojson (json : Json.t) : notebook_pvar = + Json.Of.untagged_union + "notebook_pvar" + [ (fun json -> `Notebook (string_of_yojson json)) + ; (fun json -> `NotebookDocumentFilter (NotebookDocumentFilter.t_of_yojson json)) + ] + json + ;; -module NotebookDocumentSyncRegistrationOptions = struct - type t = unit [@@deriving_inline yojson] + let yojson_of_notebook_pvar (notebook_pvar : notebook_pvar) : Json.t = + match notebook_pvar with + | `Notebook j -> `String j + | `NotebookDocumentFilter j -> NotebookDocumentFilter.yojson_of_t j + ;; - let _ = fun (_ : t) -> () - let t_of_yojson = (unit_of_yojson : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - let _ = t_of_yojson - let yojson_of_t = (yojson_of_unit : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - let _ = yojson_of_t + type cell = { language : string } [@@deriving yojson] - [@@@end] + type t = + { notebook : notebook_pvar option [@yojson.option] + ; cells : cell list option [@yojson.option] + } + [@@deriving yojson] end -module NotebookDocumentFilter = struct - type t = unit [@@deriving_inline yojson] +module NotebookDocumentSyncOptions = struct + type notebookSelector_pvar = + [ `NotebookSelector of NotebookSelector.t + | `List of NotebookSelector.t list + ] - let _ = fun (_ : t) -> () - let t_of_yojson = (unit_of_yojson : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - let _ = t_of_yojson - let yojson_of_t = (yojson_of_unit : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - let _ = yojson_of_t + let notebookSelector_pvar_of_yojson (json : Json.t) : notebookSelector_pvar = + Json.Of.untagged_union + "notebookSelector" + [ (fun json -> `NotebookSelector (NotebookSelector.t_of_yojson json)) + ; (fun json -> `List (Json.Of.list NotebookSelector.t_of_yojson json)) + ] + json + ;; + + let yojson_of_notebookSelector_pvar (notebookSelector_pvar : notebookSelector_pvar) + : Json.t + = + match notebookSelector_pvar with + | `NotebookSelector s -> NotebookSelector.yojson_of_t s + | `List s -> Json.To.list NotebookSelector.yojson_of_t s + ;; + + type t = + { notebookSelector : notebookSelector_pvar + ; save : bool option + } + [@@deriving yojson] +end - [@@@end] +module NotebookDocumentSyncRegistrationOptions = struct + type t = unit [@@deriving yojson] end module MarkedString = struct @@ -83,108 +120,7 @@ module ProgressParams = struct { token : ProgressToken.t ; value : 'a } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : 'a t) -> () - - let t_of_yojson - : 'a. - (Ppx_yojson_conv_lib.Yojson.Safe.t -> 'a) - -> Ppx_yojson_conv_lib.Yojson.Safe.t - -> 'a t - = - let _tp_loc = "lsp/src/types.ml.ProgressParams.t" in - fun _of_a -> function - | `Assoc field_yojsons as yojson -> - let token_field = ref Ppx_yojson_conv_lib.Option.None - and value_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "token" -> - (match Ppx_yojson_conv_lib.( ! ) token_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = ProgressToken.t_of_yojson _field_yojson in - token_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "value" -> - (match Ppx_yojson_conv_lib.( ! ) value_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = _of_a _field_yojson in - value_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) token_field - , Ppx_yojson_conv_lib.( ! ) value_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some token_value - , Ppx_yojson_conv_lib.Option.Some value_value ) -> - { token = token_value; value = value_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) token_field) - Ppx_yojson_conv_lib.Option.None - , "token" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) value_field) - Ppx_yojson_conv_lib.Option.None - , "value" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - ;; - - let _ = t_of_yojson - - let yojson_of_t - : 'a. - ('a -> Ppx_yojson_conv_lib.Yojson.Safe.t) - -> 'a t - -> Ppx_yojson_conv_lib.Yojson.Safe.t - = - fun _of_a -> function - | { token = v_token; value = v_value } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = _of_a v_value in - ("value", arg) :: bnds - in - let bnds = - let arg = ProgressToken.yojson_of_t v_token in - ("token", arg) :: bnds - in - `Assoc bnds - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(token : ProgressToken.t) ~value = { token; value } end @@ -195,121 +131,7 @@ module TextDocumentFilter = struct ; scheme : string option ; pattern : string option } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentFilter.t" in - function - | `Assoc field_yojsons as yojson -> - let language_field = ref Ppx_yojson_conv_lib.Option.None - and scheme_field = ref Ppx_yojson_conv_lib.Option.None - and pattern_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "language" -> - (match Ppx_yojson_conv_lib.( ! ) language_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = option_of_yojson string_of_yojson _field_yojson in - language_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "scheme" -> - (match Ppx_yojson_conv_lib.( ! ) scheme_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = option_of_yojson string_of_yojson _field_yojson in - scheme_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "pattern" -> - (match Ppx_yojson_conv_lib.( ! ) pattern_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = option_of_yojson string_of_yojson _field_yojson in - pattern_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) language_field - , Ppx_yojson_conv_lib.( ! ) scheme_field - , Ppx_yojson_conv_lib.( ! ) pattern_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some language_value - , Ppx_yojson_conv_lib.Option.Some scheme_value - , Ppx_yojson_conv_lib.Option.Some pattern_value ) -> - { language = language_value - ; scheme = scheme_value - ; pattern = pattern_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) language_field) - Ppx_yojson_conv_lib.Option.None - , "language" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) scheme_field) - Ppx_yojson_conv_lib.Option.None - , "scheme" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) pattern_field) - Ppx_yojson_conv_lib.Option.None - , "pattern" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { language = v_language; scheme = v_scheme; pattern = v_pattern } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_option yojson_of_string v_pattern in - ("pattern", arg) :: bnds - in - let bnds = - let arg = yojson_of_option yojson_of_string v_scheme in - ("scheme", arg) :: bnds - in - let bnds = - let arg = yojson_of_option yojson_of_string v_language in - ("language", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?language ?scheme ?pattern () = { language; scheme; pattern } end @@ -1348,100 +1170,7 @@ module Position = struct { character : int ; line : int } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.Position.t" in - function - | `Assoc field_yojsons as yojson -> - let character_field = ref Ppx_yojson_conv_lib.Option.None - and line_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "character" -> - (match Ppx_yojson_conv_lib.( ! ) character_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - character_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "line" -> - (match Ppx_yojson_conv_lib.( ! ) line_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - line_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) character_field - , Ppx_yojson_conv_lib.( ! ) line_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some character_value - , Ppx_yojson_conv_lib.Option.Some line_value ) -> - { character = character_value; line = line_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) character_field) - Ppx_yojson_conv_lib.Option.None - , "character" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) line_field) - Ppx_yojson_conv_lib.Option.None - , "line" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { character = v_character; line = v_line } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_int v_line in - ("line", arg) :: bnds - in - let bnds = - let arg = yojson_of_int v_character in - ("character", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(character : int) ~(line : int) : t = { character; line } end @@ -1451,114 +1180,13 @@ module Range = struct { end_ : Position.t [@key "end"] ; start : Position.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.Range.t" in - function - | `Assoc field_yojsons as yojson -> - let end__field = ref Ppx_yojson_conv_lib.Option.None - and start_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "end" -> - (match Ppx_yojson_conv_lib.( ! ) end__field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - end__field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "start" -> - (match Ppx_yojson_conv_lib.( ! ) start_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - start_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) end__field - , Ppx_yojson_conv_lib.( ! ) start_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some end__value - , Ppx_yojson_conv_lib.Option.Some start_value ) -> - { end_ = end__value; start = start_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) end__field) - Ppx_yojson_conv_lib.Option.None - , "end_" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) start_field) - Ppx_yojson_conv_lib.Option.None - , "start" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { end_ = v_end_; start = v_start } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Position.yojson_of_t v_start in - ("start", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_end_ in - ("end", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(end_ : Position.t) ~(start : Position.t) : t = { end_; start } end module ChangeAnnotationIdentifier = struct - type t = string [@@deriving_inline yojson] - - let _ = fun (_ : t) -> () - let t_of_yojson = (string_of_yojson : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - let _ = t_of_yojson - let yojson_of_t = (yojson_of_string : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - let _ = yojson_of_t - - [@@@end] + type t = string [@@deriving yojson] end module AnnotatedTextEdit = struct @@ -1567,126 +1195,12 @@ module AnnotatedTextEdit = struct ; newText : string ; range : Range.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.AnnotatedTextEdit.t" in - function - | `Assoc field_yojsons as yojson -> - let annotationId_field = ref Ppx_yojson_conv_lib.Option.None - and newText_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "annotationId" -> - (match Ppx_yojson_conv_lib.( ! ) annotationId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = ChangeAnnotationIdentifier.t_of_yojson _field_yojson in - annotationId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "newText" -> - (match Ppx_yojson_conv_lib.( ! ) newText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - newText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) annotationId_field - , Ppx_yojson_conv_lib.( ! ) newText_field - , Ppx_yojson_conv_lib.( ! ) range_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some annotationId_value - , Ppx_yojson_conv_lib.Option.Some newText_value - , Ppx_yojson_conv_lib.Option.Some range_value ) -> - { annotationId = annotationId_value - ; newText = newText_value - ; range = range_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) annotationId_field) - Ppx_yojson_conv_lib.Option.None - , "annotationId" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) newText_field) - Ppx_yojson_conv_lib.Option.None - , "newText" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { annotationId = v_annotationId; newText = v_newText; range = v_range } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_newText in - ("newText", arg) :: bnds - in - let bnds = - let arg = ChangeAnnotationIdentifier.yojson_of_t v_annotationId in - ("annotationId", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(annotationId : ChangeAnnotationIdentifier.t) - ~(newText : string) - ~(range : Range.t) + ~(annotationId : ChangeAnnotationIdentifier.t) + ~(newText : string) + ~(range : Range.t) : t = { annotationId; newText; range } @@ -1696,110 +1210,10 @@ end module DeleteFileOptions = struct type t = { ignoreIfNotExists : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; recursive : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DeleteFileOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let ignoreIfNotExists_field = ref Ppx_yojson_conv_lib.Option.None - and recursive_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "ignoreIfNotExists" -> - (match Ppx_yojson_conv_lib.( ! ) ignoreIfNotExists_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - ignoreIfNotExists_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "recursive" -> - (match Ppx_yojson_conv_lib.( ! ) recursive_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - recursive_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ignoreIfNotExists_value, recursive_value = - ( Ppx_yojson_conv_lib.( ! ) ignoreIfNotExists_field - , Ppx_yojson_conv_lib.( ! ) recursive_field ) - in - { ignoreIfNotExists = - (match ignoreIfNotExists_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; recursive = - (match recursive_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { ignoreIfNotExists = v_ignoreIfNotExists; recursive = v_recursive } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_recursive - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_recursive in - let bnd = "recursive", arg in - bnd :: bnds) - in - let bnds = - if None = v_ignoreIfNotExists - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_ignoreIfNotExists - in - let bnd = "ignoreIfNotExists", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(ignoreIfNotExists : bool option) ?(recursive : bool option) (() : unit) : t = @@ -1810,151 +1224,18 @@ end module DeleteFile = struct type t = { annotationId : ChangeAnnotationIdentifier.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; options : DeleteFileOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; uri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DeleteFile.t" in - function - | `Assoc field_yojsons as yojson -> - let annotationId_field = ref Ppx_yojson_conv_lib.Option.None - and options_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "annotationId" -> - (match Ppx_yojson_conv_lib.( ! ) annotationId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ChangeAnnotationIdentifier.t_of_yojson - _field_yojson - in - annotationId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "options" -> - (match Ppx_yojson_conv_lib.( ! ) options_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DeleteFileOptions.t_of_yojson - _field_yojson - in - options_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) annotationId_field - , Ppx_yojson_conv_lib.( ! ) options_field - , Ppx_yojson_conv_lib.( ! ) uri_field ) - with - | ( annotationId_value - , options_value - , Ppx_yojson_conv_lib.Option.Some uri_value ) -> - { annotationId = - (match annotationId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; options = - (match options_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; uri = uri_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { annotationId = v_annotationId; options = v_options; uri = v_uri } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - if None = v_options - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DeleteFileOptions.yojson_of_t) v_options - in - let bnd = "options", arg in - bnd :: bnds) - in - let bnds = - if None = v_annotationId - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ChangeAnnotationIdentifier.yojson_of_t) - v_annotationId - in - let bnd = "annotationId", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(annotationId : ChangeAnnotationIdentifier.t option) - ?(options : DeleteFileOptions.t option) - ~(uri : DocumentUri.t) - (() : unit) + ?(annotationId : ChangeAnnotationIdentifier.t option) + ?(options : DeleteFileOptions.t option) + ~(uri : DocumentUri.t) + (() : unit) : t = { annotationId; options; uri } @@ -1970,108 +1251,10 @@ end module RenameFileOptions = struct type t = { ignoreIfExists : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; overwrite : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RenameFileOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let ignoreIfExists_field = ref Ppx_yojson_conv_lib.Option.None - and overwrite_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "ignoreIfExists" -> - (match Ppx_yojson_conv_lib.( ! ) ignoreIfExists_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - ignoreIfExists_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "overwrite" -> - (match Ppx_yojson_conv_lib.( ! ) overwrite_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - overwrite_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ignoreIfExists_value, overwrite_value = - ( Ppx_yojson_conv_lib.( ! ) ignoreIfExists_field - , Ppx_yojson_conv_lib.( ! ) overwrite_field ) - in - { ignoreIfExists = - (match ignoreIfExists_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; overwrite = - (match overwrite_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { ignoreIfExists = v_ignoreIfExists; overwrite = v_overwrite } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_overwrite - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_overwrite in - let bnd = "overwrite", arg in - bnd :: bnds) - in - let bnds = - if None = v_ignoreIfExists - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_ignoreIfExists in - let bnd = "ignoreIfExists", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(ignoreIfExists : bool option) ?(overwrite : bool option) (() : unit) : t = { ignoreIfExists; overwrite } @@ -2081,176 +1264,20 @@ end module RenameFile = struct type t = { annotationId : ChangeAnnotationIdentifier.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; newUri : DocumentUri.t ; oldUri : DocumentUri.t ; options : RenameFileOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RenameFile.t" in - function - | `Assoc field_yojsons as yojson -> - let annotationId_field = ref Ppx_yojson_conv_lib.Option.None - and newUri_field = ref Ppx_yojson_conv_lib.Option.None - and oldUri_field = ref Ppx_yojson_conv_lib.Option.None - and options_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "annotationId" -> - (match Ppx_yojson_conv_lib.( ! ) annotationId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ChangeAnnotationIdentifier.t_of_yojson - _field_yojson - in - annotationId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "newUri" -> - (match Ppx_yojson_conv_lib.( ! ) newUri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - newUri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "oldUri" -> - (match Ppx_yojson_conv_lib.( ! ) oldUri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - oldUri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "options" -> - (match Ppx_yojson_conv_lib.( ! ) options_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - RenameFileOptions.t_of_yojson - _field_yojson - in - options_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) annotationId_field - , Ppx_yojson_conv_lib.( ! ) newUri_field - , Ppx_yojson_conv_lib.( ! ) oldUri_field - , Ppx_yojson_conv_lib.( ! ) options_field ) - with - | ( annotationId_value - , Ppx_yojson_conv_lib.Option.Some newUri_value - , Ppx_yojson_conv_lib.Option.Some oldUri_value - , options_value ) -> - { annotationId = - (match annotationId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; newUri = newUri_value - ; oldUri = oldUri_value - ; options = - (match options_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) newUri_field) - Ppx_yojson_conv_lib.Option.None - , "newUri" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) oldUri_field) - Ppx_yojson_conv_lib.Option.None - , "oldUri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { annotationId = v_annotationId - ; newUri = v_newUri - ; oldUri = v_oldUri - ; options = v_options - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_options - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t RenameFileOptions.yojson_of_t) v_options - in - let bnd = "options", arg in - bnd :: bnds) - in - let bnds = - let arg = DocumentUri.yojson_of_t v_oldUri in - ("oldUri", arg) :: bnds - in - let bnds = - let arg = DocumentUri.yojson_of_t v_newUri in - ("newUri", arg) :: bnds - in - let bnds = - if None = v_annotationId - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ChangeAnnotationIdentifier.yojson_of_t) - v_annotationId - in - let bnd = "annotationId", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(annotationId : ChangeAnnotationIdentifier.t option) - ~(newUri : DocumentUri.t) - ~(oldUri : DocumentUri.t) - ?(options : RenameFileOptions.t option) - (() : unit) + ?(annotationId : ChangeAnnotationIdentifier.t option) + ~(newUri : DocumentUri.t) + ~(oldUri : DocumentUri.t) + ?(options : RenameFileOptions.t option) + (() : unit) : t = { annotationId; newUri; oldUri; options } @@ -2266,108 +1293,10 @@ end module CreateFileOptions = struct type t = { ignoreIfExists : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; overwrite : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CreateFileOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let ignoreIfExists_field = ref Ppx_yojson_conv_lib.Option.None - and overwrite_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "ignoreIfExists" -> - (match Ppx_yojson_conv_lib.( ! ) ignoreIfExists_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - ignoreIfExists_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "overwrite" -> - (match Ppx_yojson_conv_lib.( ! ) overwrite_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - overwrite_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ignoreIfExists_value, overwrite_value = - ( Ppx_yojson_conv_lib.( ! ) ignoreIfExists_field - , Ppx_yojson_conv_lib.( ! ) overwrite_field ) - in - { ignoreIfExists = - (match ignoreIfExists_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; overwrite = - (match overwrite_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { ignoreIfExists = v_ignoreIfExists; overwrite = v_overwrite } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_overwrite - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_overwrite in - let bnd = "overwrite", arg in - bnd :: bnds) - in - let bnds = - if None = v_ignoreIfExists - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_ignoreIfExists in - let bnd = "ignoreIfExists", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(ignoreIfExists : bool option) ?(overwrite : bool option) (() : unit) : t = { ignoreIfExists; overwrite } @@ -2377,151 +1306,18 @@ end module CreateFile = struct type t = { annotationId : ChangeAnnotationIdentifier.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; options : CreateFileOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; uri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CreateFile.t" in - function - | `Assoc field_yojsons as yojson -> - let annotationId_field = ref Ppx_yojson_conv_lib.Option.None - and options_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "annotationId" -> - (match Ppx_yojson_conv_lib.( ! ) annotationId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ChangeAnnotationIdentifier.t_of_yojson - _field_yojson - in - annotationId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "options" -> - (match Ppx_yojson_conv_lib.( ! ) options_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CreateFileOptions.t_of_yojson - _field_yojson - in - options_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) annotationId_field - , Ppx_yojson_conv_lib.( ! ) options_field - , Ppx_yojson_conv_lib.( ! ) uri_field ) - with - | ( annotationId_value - , options_value - , Ppx_yojson_conv_lib.Option.Some uri_value ) -> - { annotationId = - (match annotationId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; options = - (match options_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; uri = uri_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { annotationId = v_annotationId; options = v_options; uri = v_uri } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - if None = v_options - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CreateFileOptions.yojson_of_t) v_options - in - let bnd = "options", arg in - bnd :: bnds) - in - let bnds = - if None = v_annotationId - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ChangeAnnotationIdentifier.yojson_of_t) - v_annotationId - in - let bnd = "annotationId", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(annotationId : ChangeAnnotationIdentifier.t option) - ?(options : CreateFileOptions.t option) - ~(uri : DocumentUri.t) - (() : unit) + ?(annotationId : ChangeAnnotationIdentifier.t option) + ?(options : CreateFileOptions.t option) + ~(uri : DocumentUri.t) + (() : unit) : t = { annotationId; options; uri } @@ -2539,106 +1335,7 @@ module OptionalVersionedTextDocumentIdentifier = struct { uri : DocumentUri.t ; version : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.OptionalVersionedTextDocumentIdentifier.t" in - function - | `Assoc field_yojsons as yojson -> - let uri_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) uri_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | Ppx_yojson_conv_lib.Option.Some uri_value, version_value -> - { uri = uri_value - ; version = - (match version_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { uri = v_uri; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_version - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_version in - let bnd = "version", arg in - bnd :: bnds) - in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(uri : DocumentUri.t) ?(version : int option) (() : unit) : t = { uri; version } @@ -2650,100 +1347,7 @@ module TextEdit = struct { newText : string ; range : Range.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextEdit.t" in - function - | `Assoc field_yojsons as yojson -> - let newText_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "newText" -> - (match Ppx_yojson_conv_lib.( ! ) newText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - newText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) newText_field - , Ppx_yojson_conv_lib.( ! ) range_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some newText_value - , Ppx_yojson_conv_lib.Option.Some range_value ) -> - { newText = newText_value; range = range_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) newText_field) - Ppx_yojson_conv_lib.Option.None - , "newText" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { newText = v_newText; range = v_range } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_newText in - ("newText", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(newText : string) ~(range : Range.t) : t = { newText; range } end @@ -2773,106 +1377,11 @@ module TextDocumentEdit = struct { edits : edits_pvar list ; textDocument : OptionalVersionedTextDocumentIdentifier.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentEdit.t" in - function - | `Assoc field_yojsons as yojson -> - let edits_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "edits" -> - (match Ppx_yojson_conv_lib.( ! ) edits_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson edits_pvar_of_yojson _field_yojson in - edits_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - OptionalVersionedTextDocumentIdentifier.t_of_yojson _field_yojson - in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) edits_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some edits_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value ) -> - { edits = edits_value; textDocument = textDocument_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) edits_field) - Ppx_yojson_conv_lib.Option.None - , "edits" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { edits = v_edits; textDocument = v_textDocument } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = OptionalVersionedTextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = yojson_of_list yojson_of_edits_pvar v_edits in - ("edits", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(edits : edits_pvar list) - ~(textDocument : OptionalVersionedTextDocumentIdentifier.t) + ~(edits : edits_pvar list) + ~(textDocument : OptionalVersionedTextDocumentIdentifier.t) : t = { edits; textDocument } @@ -2882,147 +1391,18 @@ end module ChangeAnnotation = struct type t = { description : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; label : string ; needsConfirmation : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ChangeAnnotation.t" in - function - | `Assoc field_yojsons as yojson -> - let description_field = ref Ppx_yojson_conv_lib.Option.None - and label_field = ref Ppx_yojson_conv_lib.Option.None - and needsConfirmation_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "description" -> - (match Ppx_yojson_conv_lib.( ! ) description_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - description_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "label" -> - (match Ppx_yojson_conv_lib.( ! ) label_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - label_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "needsConfirmation" -> - (match Ppx_yojson_conv_lib.( ! ) needsConfirmation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - needsConfirmation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) description_field - , Ppx_yojson_conv_lib.( ! ) label_field - , Ppx_yojson_conv_lib.( ! ) needsConfirmation_field ) - with - | ( description_value - , Ppx_yojson_conv_lib.Option.Some label_value - , needsConfirmation_value ) -> - { description = - (match description_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; label = label_value - ; needsConfirmation = - (match needsConfirmation_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) label_field) - Ppx_yojson_conv_lib.Option.None - , "label" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { description = v_description - ; label = v_label - ; needsConfirmation = v_needsConfirmation - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_needsConfirmation - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_needsConfirmation - in - let bnd = "needsConfirmation", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_label in - ("label", arg) :: bnds - in - let bnds = - if None = v_description - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_description in - let bnd = "description", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(description : string option) - ~(label : string) - ?(needsConfirmation : bool option) - (() : unit) + ?(description : string option) + ~(label : string) + ?(needsConfirmation : bool option) + (() : unit) : t = { description; label; needsConfirmation } @@ -3062,170 +1442,20 @@ module WorkspaceEdit = struct { changeAnnotations : (ChangeAnnotationIdentifier.t, ChangeAnnotation.t) Json.Assoc.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; changes : (DocumentUri.t, TextEdit.t list) Json.Assoc.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentChanges : documentChanges_pvar list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceEdit.t" in - function - | `Assoc field_yojsons as yojson -> - let changeAnnotations_field = ref Ppx_yojson_conv_lib.Option.None - and changes_field = ref Ppx_yojson_conv_lib.Option.None - and documentChanges_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "changeAnnotations" -> - (match Ppx_yojson_conv_lib.( ! ) changeAnnotations_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (Json.Assoc.t_of_yojson - ChangeAnnotationIdentifier.t_of_yojson - ChangeAnnotation.t_of_yojson) - _field_yojson - in - changeAnnotations_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "changes" -> - (match Ppx_yojson_conv_lib.( ! ) changes_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (Json.Assoc.t_of_yojson - DocumentUri.t_of_yojson - (list_of_yojson TextEdit.t_of_yojson)) - _field_yojson - in - changes_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentChanges" -> - (match Ppx_yojson_conv_lib.( ! ) documentChanges_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson documentChanges_pvar_of_yojson) - _field_yojson - in - documentChanges_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let changeAnnotations_value, changes_value, documentChanges_value = - ( Ppx_yojson_conv_lib.( ! ) changeAnnotations_field - , Ppx_yojson_conv_lib.( ! ) changes_field - , Ppx_yojson_conv_lib.( ! ) documentChanges_field ) - in - { changeAnnotations = - (match changeAnnotations_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; changes = - (match changes_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentChanges = - (match documentChanges_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { changeAnnotations = v_changeAnnotations - ; changes = v_changes - ; documentChanges = v_documentChanges - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_documentChanges - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list yojson_of_documentChanges_pvar)) - v_documentChanges - in - let bnd = "documentChanges", arg in - bnd :: bnds) - in - let bnds = - if None = v_changes - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (Json.Assoc.yojson_of_t - DocumentUri.yojson_of_t - (yojson_of_list TextEdit.yojson_of_t))) - v_changes - in - let bnd = "changes", arg in - bnd :: bnds) - in - let bnds = - if None = v_changeAnnotations - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (Json.Assoc.yojson_of_t - ChangeAnnotationIdentifier.yojson_of_t - ChangeAnnotation.yojson_of_t)) - v_changeAnnotations - in - let bnd = "changeAnnotations", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(changeAnnotations : - (ChangeAnnotationIdentifier.t, ChangeAnnotation.t) Json.Assoc.t option) - ?(changes : (DocumentUri.t, TextEdit.t list) Json.Assoc.t option) - ?(documentChanges : documentChanges_pvar list option) - (() : unit) + ?(changeAnnotations : + (ChangeAnnotationIdentifier.t, ChangeAnnotation.t) Json.Assoc.t option) + ?(changes : (DocumentUri.t, TextEdit.t list) Json.Assoc.t option) + ?(documentChanges : documentChanges_pvar list option) + (() : unit) : t = { changeAnnotations; changes; documentChanges } @@ -3237,106 +1467,7 @@ module ApplyWorkspaceEditParams = struct { edit : WorkspaceEdit.t ; label : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ApplyWorkspaceEditParams.t" in - function - | `Assoc field_yojsons as yojson -> - let edit_field = ref Ppx_yojson_conv_lib.Option.None - and label_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "edit" -> - (match Ppx_yojson_conv_lib.( ! ) edit_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = WorkspaceEdit.t_of_yojson _field_yojson in - edit_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "label" -> - (match Ppx_yojson_conv_lib.( ! ) label_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - label_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) edit_field - , Ppx_yojson_conv_lib.( ! ) label_field ) - with - | Ppx_yojson_conv_lib.Option.Some edit_value, label_value -> - { edit = edit_value - ; label = - (match label_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) edit_field) - Ppx_yojson_conv_lib.Option.None - , "edit" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { edit = v_edit; label = v_label } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_label - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_label in - let bnd = "label", arg in - bnd :: bnds) - in - let bnds = - let arg = WorkspaceEdit.yojson_of_t v_edit in - ("edit", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(edit : WorkspaceEdit.t) ?(label : string option) (() : unit) : t = { edit; label } @@ -3347,146 +1478,17 @@ module ApplyWorkspaceEditResult = struct type t = { applied : bool ; failedChange : int Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; failureReason : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ApplyWorkspaceEditResult.t" in - function - | `Assoc field_yojsons as yojson -> - let applied_field = ref Ppx_yojson_conv_lib.Option.None - and failedChange_field = ref Ppx_yojson_conv_lib.Option.None - and failureReason_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "applied" -> - (match Ppx_yojson_conv_lib.( ! ) applied_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - applied_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "failedChange" -> - (match Ppx_yojson_conv_lib.( ! ) failedChange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - failedChange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "failureReason" -> - (match Ppx_yojson_conv_lib.( ! ) failureReason_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - failureReason_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) applied_field - , Ppx_yojson_conv_lib.( ! ) failedChange_field - , Ppx_yojson_conv_lib.( ! ) failureReason_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some applied_value - , failedChange_value - , failureReason_value ) -> - { applied = applied_value - ; failedChange = - (match failedChange_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; failureReason = - (match failureReason_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) applied_field) - Ppx_yojson_conv_lib.Option.None - , "applied" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { applied = v_applied - ; failedChange = v_failedChange - ; failureReason = v_failureReason - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_failureReason - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_string) v_failureReason - in - let bnd = "failureReason", arg in - bnd :: bnds) - in - let bnds = - if None = v_failedChange - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_failedChange in - let bnd = "failedChange", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_bool v_applied in - ("applied", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(applied : bool) - ?(failedChange : int option) - ?(failureReason : string option) - (() : unit) + ~(applied : bool) + ?(failedChange : int option) + ?(failureReason : string option) + (() : unit) : t = { applied; failedChange; failureReason } @@ -3496,170 +1498,20 @@ end module BaseSymbolInformation = struct type t = { containerName : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; kind : SymbolKind.t ; name : string ; tags : SymbolTag.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.BaseSymbolInformation.t" in - function - | `Assoc field_yojsons as yojson -> - let containerName_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and name_field = ref Ppx_yojson_conv_lib.Option.None - and tags_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "containerName" -> - (match Ppx_yojson_conv_lib.( ! ) containerName_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - containerName_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = SymbolKind.t_of_yojson _field_yojson in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "name" -> - (match Ppx_yojson_conv_lib.( ! ) name_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - name_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tags" -> - (match Ppx_yojson_conv_lib.( ! ) tags_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson SymbolTag.t_of_yojson) - _field_yojson - in - tags_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) containerName_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) name_field - , Ppx_yojson_conv_lib.( ! ) tags_field ) - with - | ( containerName_value - , Ppx_yojson_conv_lib.Option.Some kind_value - , Ppx_yojson_conv_lib.Option.Some name_value - , tags_value ) -> - { containerName = - (match containerName_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; kind = kind_value - ; name = name_value - ; tags = - (match tags_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) kind_field) - Ppx_yojson_conv_lib.Option.None - , "kind" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) name_field) - Ppx_yojson_conv_lib.Option.None - , "name" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { containerName = v_containerName; kind = v_kind; name = v_name; tags = v_tags } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_tags - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list SymbolTag.yojson_of_t)) - v_tags - in - let bnd = "tags", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_name in - ("name", arg) :: bnds - in - let bnds = - let arg = SymbolKind.yojson_of_t v_kind in - ("kind", arg) :: bnds - in - let bnds = - if None = v_containerName - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_string) v_containerName - in - let bnd = "containerName", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(containerName : string option) - ~(kind : SymbolKind.t) - ~(name : string) - ?(tags : SymbolTag.t list option) - (() : unit) + ?(containerName : string option) + ~(kind : SymbolKind.t) + ~(name : string) + ?(tags : SymbolTag.t list option) + (() : unit) : t = { containerName; kind; name; tags } @@ -3669,86 +1521,9 @@ end module CallHierarchyClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CallHierarchyClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -3764,253 +1539,21 @@ module CallHierarchyItem = struct ; range : Range.t ; selectionRange : Range.t ; tags : SymbolTag.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; uri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CallHierarchyItem.t" in - function - | `Assoc field_yojsons as yojson -> - let data_field = ref Ppx_yojson_conv_lib.Option.None - and detail_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and name_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and selectionRange_field = ref Ppx_yojson_conv_lib.Option.None - and tags_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "detail" -> - (match Ppx_yojson_conv_lib.( ! ) detail_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - detail_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = SymbolKind.t_of_yojson _field_yojson in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "name" -> - (match Ppx_yojson_conv_lib.( ! ) name_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - name_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "selectionRange" -> - (match Ppx_yojson_conv_lib.( ! ) selectionRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - selectionRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tags" -> - (match Ppx_yojson_conv_lib.( ! ) tags_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson SymbolTag.t_of_yojson) - _field_yojson - in - tags_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) detail_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) name_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) selectionRange_field - , Ppx_yojson_conv_lib.( ! ) tags_field - , Ppx_yojson_conv_lib.( ! ) uri_field ) - with - | ( data_value - , detail_value - , Ppx_yojson_conv_lib.Option.Some kind_value - , Ppx_yojson_conv_lib.Option.Some name_value - , Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some selectionRange_value - , tags_value - , Ppx_yojson_conv_lib.Option.Some uri_value ) -> - { data = data_value - ; detail = - (match detail_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; kind = kind_value - ; name = name_value - ; range = range_value - ; selectionRange = selectionRange_value - ; tags = - (match tags_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; uri = uri_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) kind_field) - Ppx_yojson_conv_lib.Option.None - , "kind" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) name_field) - Ppx_yojson_conv_lib.Option.None - , "name" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) selectionRange_field) - Ppx_yojson_conv_lib.Option.None - , "selectionRange" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { data = v_data - ; detail = v_detail - ; kind = v_kind - ; name = v_name - ; range = v_range - ; selectionRange = v_selectionRange - ; tags = v_tags - ; uri = v_uri - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - if None = v_tags - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list SymbolTag.yojson_of_t)) - v_tags - in - let bnd = "tags", arg in - bnd :: bnds) - in - let bnds = - let arg = Range.yojson_of_t v_selectionRange in - ("selectionRange", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_name in - ("name", arg) :: bnds - in - let bnds = - let arg = SymbolKind.yojson_of_t v_kind in - ("kind", arg) :: bnds - in - let bnds = - if None = v_detail - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_detail in - let bnd = "detail", arg in - bnd :: bnds) - in - let bnds = - match v_data with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "data", arg in - bnd :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(data : Json.t option) - ?(detail : string option) - ~(kind : SymbolKind.t) - ~(name : string) - ~(range : Range.t) - ~(selectionRange : Range.t) - ?(tags : SymbolTag.t list option) - ~(uri : DocumentUri.t) - (() : unit) + ?(data : Json.t option) + ?(detail : string option) + ~(kind : SymbolKind.t) + ~(name : string) + ~(range : Range.t) + ~(selectionRange : Range.t) + ?(tags : SymbolTag.t list option) + ~(uri : DocumentUri.t) + (() : unit) : t = { data; detail; kind; name; range; selectionRange; tags; uri } @@ -4022,100 +1565,7 @@ module CallHierarchyIncomingCall = struct { from : CallHierarchyItem.t ; fromRanges : Range.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CallHierarchyIncomingCall.t" in - function - | `Assoc field_yojsons as yojson -> - let from_field = ref Ppx_yojson_conv_lib.Option.None - and fromRanges_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "from" -> - (match Ppx_yojson_conv_lib.( ! ) from_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = CallHierarchyItem.t_of_yojson _field_yojson in - from_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "fromRanges" -> - (match Ppx_yojson_conv_lib.( ! ) fromRanges_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Range.t_of_yojson _field_yojson in - fromRanges_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) from_field - , Ppx_yojson_conv_lib.( ! ) fromRanges_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some from_value - , Ppx_yojson_conv_lib.Option.Some fromRanges_value ) -> - { from = from_value; fromRanges = fromRanges_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) from_field) - Ppx_yojson_conv_lib.Option.None - , "from" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) fromRanges_field) - Ppx_yojson_conv_lib.Option.None - , "fromRanges" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { from = v_from; fromRanges = v_fromRanges } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list Range.yojson_of_t v_fromRanges in - ("fromRanges", arg) :: bnds - in - let bnds = - let arg = CallHierarchyItem.yojson_of_t v_from in - ("from", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(from : CallHierarchyItem.t) ~(fromRanges : Range.t list) : t = { from; fromRanges } @@ -4126,153 +1576,17 @@ module CallHierarchyIncomingCallsParams = struct type t = { item : CallHierarchyItem.t ; partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CallHierarchyIncomingCallsParams.t" in - function - | `Assoc field_yojsons as yojson -> - let item_field = ref Ppx_yojson_conv_lib.Option.None - and partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "item" -> - (match Ppx_yojson_conv_lib.( ! ) item_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = CallHierarchyItem.t_of_yojson _field_yojson in - item_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) item_field - , Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some item_value - , partialResultToken_value - , workDoneToken_value ) -> - { item = item_value - ; partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) item_field) - Ppx_yojson_conv_lib.Option.None - , "item" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { item = v_item - ; partialResultToken = v_partialResultToken - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - let bnds = - let arg = CallHierarchyItem.yojson_of_t v_item in - ("item", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(item : CallHierarchyItem.t) - ?(partialResultToken : ProgressToken.t option) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(item : CallHierarchyItem.t) + ?(partialResultToken : ProgressToken.t option) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { item; partialResultToken; workDoneToken } @@ -4282,86 +1596,9 @@ end module CallHierarchyOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CallHierarchyOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -4371,100 +1608,7 @@ module CallHierarchyOutgoingCall = struct { fromRanges : Range.t list ; to_ : CallHierarchyItem.t [@key "to"] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CallHierarchyOutgoingCall.t" in - function - | `Assoc field_yojsons as yojson -> - let fromRanges_field = ref Ppx_yojson_conv_lib.Option.None - and to__field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "fromRanges" -> - (match Ppx_yojson_conv_lib.( ! ) fromRanges_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Range.t_of_yojson _field_yojson in - fromRanges_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "to" -> - (match Ppx_yojson_conv_lib.( ! ) to__field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = CallHierarchyItem.t_of_yojson _field_yojson in - to__field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) fromRanges_field - , Ppx_yojson_conv_lib.( ! ) to__field ) - with - | ( Ppx_yojson_conv_lib.Option.Some fromRanges_value - , Ppx_yojson_conv_lib.Option.Some to__value ) -> - { fromRanges = fromRanges_value; to_ = to__value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) fromRanges_field) - Ppx_yojson_conv_lib.Option.None - , "fromRanges" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) to__field) - Ppx_yojson_conv_lib.Option.None - , "to_" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { fromRanges = v_fromRanges; to_ = v_to_ } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = CallHierarchyItem.yojson_of_t v_to_ in - ("to", arg) :: bnds - in - let bnds = - let arg = yojson_of_list Range.yojson_of_t v_fromRanges in - ("fromRanges", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(fromRanges : Range.t list) ~(to_ : CallHierarchyItem.t) : t = { fromRanges; to_ } @@ -4475,153 +1619,17 @@ module CallHierarchyOutgoingCallsParams = struct type t = { item : CallHierarchyItem.t ; partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CallHierarchyOutgoingCallsParams.t" in - function - | `Assoc field_yojsons as yojson -> - let item_field = ref Ppx_yojson_conv_lib.Option.None - and partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "item" -> - (match Ppx_yojson_conv_lib.( ! ) item_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = CallHierarchyItem.t_of_yojson _field_yojson in - item_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) item_field - , Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some item_value - , partialResultToken_value - , workDoneToken_value ) -> - { item = item_value - ; partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) item_field) - Ppx_yojson_conv_lib.Option.None - , "item" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { item = v_item - ; partialResultToken = v_partialResultToken - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - let bnds = - let arg = CallHierarchyItem.yojson_of_t v_item in - ("item", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(item : CallHierarchyItem.t) - ?(partialResultToken : ProgressToken.t option) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(item : CallHierarchyItem.t) + ?(partialResultToken : ProgressToken.t option) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { item; partialResultToken; workDoneToken } @@ -4629,80 +1637,7 @@ module CallHierarchyOutgoingCallsParams = struct end module TextDocumentIdentifier = struct - type t = { uri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentIdentifier.t" in - function - | `Assoc field_yojsons as yojson -> - let uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.Some uri_value -> { uri = uri_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { uri = v_uri } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { uri : DocumentUri.t } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(uri : DocumentUri.t) : t = { uri } end @@ -4712,141 +1647,15 @@ module CallHierarchyPrepareParams = struct { position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CallHierarchyPrepareParams.t" in - function - | `Assoc field_yojsons as yojson -> - let position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { position; textDocument; workDoneToken } @@ -4878,109 +1687,10 @@ module NotebookCellTextDocumentFilter = struct type t = { language : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; notebook : notebook_pvar } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookCellTextDocumentFilter.t" in - function - | `Assoc field_yojsons as yojson -> - let language_field = ref Ppx_yojson_conv_lib.Option.None - and notebook_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "language" -> - (match Ppx_yojson_conv_lib.( ! ) language_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - language_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "notebook" -> - (match Ppx_yojson_conv_lib.( ! ) notebook_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = notebook_pvar_of_yojson _field_yojson in - notebook_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) language_field - , Ppx_yojson_conv_lib.( ! ) notebook_field ) - with - | language_value, Ppx_yojson_conv_lib.Option.Some notebook_value -> - { language = - (match language_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; notebook = notebook_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) notebook_field) - Ppx_yojson_conv_lib.Option.None - , "notebook" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { language = v_language; notebook = v_notebook } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_notebook_pvar v_notebook in - ("notebook", arg) :: bnds - in - let bnds = - if None = v_language - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_language in - let bnd = "language", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(language : string option) ~(notebook : notebook_pvar) (() : unit) : t = { language; notebook } @@ -5012,174 +1722,24 @@ module DocumentFilter = struct end module DocumentSelector = struct - type t = DocumentFilter.t list [@@deriving_inline yojson] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentSelector.t" in - fun t -> list_of_yojson DocumentFilter.t_of_yojson t - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (fun v -> yojson_of_list DocumentFilter.yojson_of_t v - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = DocumentFilter.t list [@@deriving yojson] end module CallHierarchyRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CallHierarchyRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -5187,79 +1747,7 @@ module CallHierarchyRegistrationOptions = struct end module CancelParams = struct - type t = { id : Jsonrpc.Id.t } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CancelParams.t" in - function - | `Assoc field_yojsons as yojson -> - let id_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Jsonrpc.Id.t_of_yojson _field_yojson in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.Some id_value -> { id = id_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) id_field) - Ppx_yojson_conv_lib.Option.None - , "id" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { id = v_id } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Jsonrpc.Id.yojson_of_t v_id in - ("id", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { id : Jsonrpc.Id.t } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(id : Jsonrpc.Id.t) : t = { id } end @@ -5267,84 +1755,9 @@ end module WorkspaceEditClientCapabilities = struct type changeAnnotationSupport = { groupsOnLabel : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : changeAnnotationSupport) -> () - - let changeAnnotationSupport_of_yojson = - (let _tp_loc = - "lsp/src/types.ml.WorkspaceEditClientCapabilities.changeAnnotationSupport" - in - function - | `Assoc field_yojsons as yojson -> - let groupsOnLabel_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "groupsOnLabel" -> - (match Ppx_yojson_conv_lib.( ! ) groupsOnLabel_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - groupsOnLabel_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let groupsOnLabel_value = Ppx_yojson_conv_lib.( ! ) groupsOnLabel_field in - { groupsOnLabel = - (match groupsOnLabel_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> changeAnnotationSupport) - ;; - - let _ = changeAnnotationSupport_of_yojson - - let yojson_of_changeAnnotationSupport = - (function - | { groupsOnLabel = v_groupsOnLabel } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_groupsOnLabel - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_groupsOnLabel in - let bnd = "groupsOnLabel", arg in - bnd :: bnds) - in - `Assoc bnds - : changeAnnotationSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_changeAnnotationSupport - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_changeAnnotationSupport ?(groupsOnLabel : bool option) (() : unit) : changeAnnotationSupport @@ -5354,222 +1767,25 @@ module WorkspaceEditClientCapabilities = struct type t = { changeAnnotationSupport : changeAnnotationSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentChanges : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; failureHandling : FailureHandlingKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; normalizesLineEndings : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resourceOperations : ResourceOperationKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceEditClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let changeAnnotationSupport_field = ref Ppx_yojson_conv_lib.Option.None - and documentChanges_field = ref Ppx_yojson_conv_lib.Option.None - and failureHandling_field = ref Ppx_yojson_conv_lib.Option.None - and normalizesLineEndings_field = ref Ppx_yojson_conv_lib.Option.None - and resourceOperations_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "changeAnnotationSupport" -> - (match Ppx_yojson_conv_lib.( ! ) changeAnnotationSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - changeAnnotationSupport_of_yojson - _field_yojson - in - changeAnnotationSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentChanges" -> - (match Ppx_yojson_conv_lib.( ! ) documentChanges_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - documentChanges_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "failureHandling" -> - (match Ppx_yojson_conv_lib.( ! ) failureHandling_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FailureHandlingKind.t_of_yojson - _field_yojson - in - failureHandling_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "normalizesLineEndings" -> - (match Ppx_yojson_conv_lib.( ! ) normalizesLineEndings_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - normalizesLineEndings_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resourceOperations" -> - (match Ppx_yojson_conv_lib.( ! ) resourceOperations_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson ResourceOperationKind.t_of_yojson) - _field_yojson - in - resourceOperations_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( changeAnnotationSupport_value - , documentChanges_value - , failureHandling_value - , normalizesLineEndings_value - , resourceOperations_value ) - = - ( Ppx_yojson_conv_lib.( ! ) changeAnnotationSupport_field - , Ppx_yojson_conv_lib.( ! ) documentChanges_field - , Ppx_yojson_conv_lib.( ! ) failureHandling_field - , Ppx_yojson_conv_lib.( ! ) normalizesLineEndings_field - , Ppx_yojson_conv_lib.( ! ) resourceOperations_field ) - in - { changeAnnotationSupport = - (match changeAnnotationSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentChanges = - (match documentChanges_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; failureHandling = - (match failureHandling_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; normalizesLineEndings = - (match normalizesLineEndings_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resourceOperations = - (match resourceOperations_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { changeAnnotationSupport = v_changeAnnotationSupport - ; documentChanges = v_documentChanges - ; failureHandling = v_failureHandling - ; normalizesLineEndings = v_normalizesLineEndings - ; resourceOperations = v_resourceOperations - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_resourceOperations - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list ResourceOperationKind.yojson_of_t)) - v_resourceOperations - in - let bnd = "resourceOperations", arg in - bnd :: bnds) - in - let bnds = - if None = v_normalizesLineEndings - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_normalizesLineEndings - in - let bnd = "normalizesLineEndings", arg in - bnd :: bnds) - in - let bnds = - if None = v_failureHandling - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t FailureHandlingKind.yojson_of_t) - v_failureHandling - in - let bnd = "failureHandling", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentChanges - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_documentChanges - in - let bnd = "documentChanges", arg in - bnd :: bnds) - in - let bnds = - if None = v_changeAnnotationSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_changeAnnotationSupport) - v_changeAnnotationSupport - in - let bnd = "changeAnnotationSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(changeAnnotationSupport : changeAnnotationSupport option) - ?(documentChanges : bool option) - ?(failureHandling : FailureHandlingKind.t option) - ?(normalizesLineEndings : bool option) - ?(resourceOperations : ResourceOperationKind.t list option) - (() : unit) + ?(changeAnnotationSupport : changeAnnotationSupport option) + ?(documentChanges : bool option) + ?(failureHandling : FailureHandlingKind.t option) + ?(normalizesLineEndings : bool option) + ?(resourceOperations : ResourceOperationKind.t list option) + (() : unit) : t = { changeAnnotationSupport @@ -5583,427 +1799,43 @@ end module WorkspaceSymbolClientCapabilities = struct type tagSupport = { valueSet : SymbolTag.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : tagSupport) -> () - - let tagSupport_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceSymbolClientCapabilities.tagSupport" in - function - | `Assoc field_yojsons as yojson -> - let valueSet_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "valueSet" -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson SymbolTag.t_of_yojson _field_yojson in - valueSet_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.Some valueSet_value -> - { valueSet = valueSet_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) valueSet_field) - Ppx_yojson_conv_lib.Option.None - , "valueSet" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> tagSupport) - ;; - - let _ = tagSupport_of_yojson - - let yojson_of_tagSupport = - (function - | { valueSet = v_valueSet } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list SymbolTag.yojson_of_t v_valueSet in - ("valueSet", arg) :: bnds - in - `Assoc bnds - : tagSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_tagSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_tagSupport ~(valueSet : SymbolTag.t list) : tagSupport = { valueSet } type symbolKind = { valueSet : SymbolKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : symbolKind) -> () - - let symbolKind_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceSymbolClientCapabilities.symbolKind" in - function - | `Assoc field_yojsons as yojson -> - let valueSet_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "valueSet" -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson SymbolKind.t_of_yojson) - _field_yojson - in - valueSet_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let valueSet_value = Ppx_yojson_conv_lib.( ! ) valueSet_field in - { valueSet = - (match valueSet_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> symbolKind) - ;; - - let _ = symbolKind_of_yojson - - let yojson_of_symbolKind = - (function - | { valueSet = v_valueSet } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_valueSet - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list SymbolKind.yojson_of_t)) - v_valueSet - in - let bnd = "valueSet", arg in - bnd :: bnds) - in - `Assoc bnds - : symbolKind -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_symbolKind - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_symbolKind ?(valueSet : SymbolKind.t list option) (() : unit) : symbolKind = { valueSet } ;; type resolveSupport = { properties : string list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : resolveSupport) -> () - - let resolveSupport_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceSymbolClientCapabilities.resolveSupport" in - function - | `Assoc field_yojsons as yojson -> - let properties_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "properties" -> - (match Ppx_yojson_conv_lib.( ! ) properties_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - properties_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) properties_field with - | Ppx_yojson_conv_lib.Option.Some properties_value -> - { properties = properties_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) properties_field) - Ppx_yojson_conv_lib.Option.None - , "properties" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> resolveSupport) - ;; - - let _ = resolveSupport_of_yojson - - let yojson_of_resolveSupport = - (function - | { properties = v_properties } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list yojson_of_string v_properties in - ("properties", arg) :: bnds - in - `Assoc bnds - : resolveSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_resolveSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_resolveSupport ~(properties : string list) : resolveSupport = { properties } type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resolveSupport : resolveSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; symbolKind : symbolKind Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; tagSupport : tagSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceSymbolClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and resolveSupport_field = ref Ppx_yojson_conv_lib.Option.None - and symbolKind_field = ref Ppx_yojson_conv_lib.Option.None - and tagSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveSupport" -> - (match Ppx_yojson_conv_lib.( ! ) resolveSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson resolveSupport_of_yojson _field_yojson - in - resolveSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "symbolKind" -> - (match Ppx_yojson_conv_lib.( ! ) symbolKind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson symbolKind_of_yojson _field_yojson - in - symbolKind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tagSupport" -> - (match Ppx_yojson_conv_lib.( ! ) tagSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson tagSupport_of_yojson _field_yojson - in - tagSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( dynamicRegistration_value - , resolveSupport_value - , symbolKind_value - , tagSupport_value ) - = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) resolveSupport_field - , Ppx_yojson_conv_lib.( ! ) symbolKind_field - , Ppx_yojson_conv_lib.( ! ) tagSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveSupport = - (match resolveSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; symbolKind = - (match symbolKind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tagSupport = - (match tagSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration - ; resolveSupport = v_resolveSupport - ; symbolKind = v_symbolKind - ; tagSupport = v_tagSupport - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_tagSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_tagSupport) v_tagSupport - in - let bnd = "tagSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_symbolKind - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_symbolKind) v_symbolKind - in - let bnd = "symbolKind", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_resolveSupport) v_resolveSupport - in - let bnd = "resolveSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(dynamicRegistration : bool option) - ?(resolveSupport : resolveSupport option) - ?(symbolKind : symbolKind option) - ?(tagSupport : tagSupport option) - (() : unit) + ?(dynamicRegistration : bool option) + ?(resolveSupport : resolveSupport option) + ?(symbolKind : symbolKind option) + ?(tagSupport : tagSupport option) + (() : unit) : t = { dynamicRegistration; resolveSupport; symbolKind; tagSupport } @@ -6013,82 +1845,9 @@ end module SemanticTokensWorkspaceClientCapabilities = struct type t = { refreshSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensWorkspaceClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let refreshSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "refreshSupport" -> - (match Ppx_yojson_conv_lib.( ! ) refreshSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - refreshSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let refreshSupport_value = Ppx_yojson_conv_lib.( ! ) refreshSupport_field in - { refreshSupport = - (match refreshSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { refreshSupport = v_refreshSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_refreshSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_refreshSupport in - let bnd = "refreshSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(refreshSupport : bool option) (() : unit) : t = { refreshSupport } end @@ -6096,82 +1855,9 @@ end module InlineValueWorkspaceClientCapabilities = struct type t = { refreshSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineValueWorkspaceClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let refreshSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "refreshSupport" -> - (match Ppx_yojson_conv_lib.( ! ) refreshSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - refreshSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let refreshSupport_value = Ppx_yojson_conv_lib.( ! ) refreshSupport_field in - { refreshSupport = - (match refreshSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { refreshSupport = v_refreshSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_refreshSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_refreshSupport in - let bnd = "refreshSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(refreshSupport : bool option) (() : unit) : t = { refreshSupport } end @@ -6179,82 +1865,9 @@ end module InlayHintWorkspaceClientCapabilities = struct type t = { refreshSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlayHintWorkspaceClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let refreshSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "refreshSupport" -> - (match Ppx_yojson_conv_lib.( ! ) refreshSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - refreshSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let refreshSupport_value = Ppx_yojson_conv_lib.( ! ) refreshSupport_field in - { refreshSupport = - (match refreshSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { refreshSupport = v_refreshSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_refreshSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_refreshSupport in - let bnd = "refreshSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(refreshSupport : bool option) (() : unit) : t = { refreshSupport } end @@ -6262,82 +1875,9 @@ end module FoldingRangeWorkspaceClientCapabilities = struct type t = { refreshSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FoldingRangeWorkspaceClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let refreshSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "refreshSupport" -> - (match Ppx_yojson_conv_lib.( ! ) refreshSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - refreshSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let refreshSupport_value = Ppx_yojson_conv_lib.( ! ) refreshSupport_field in - { refreshSupport = - (match refreshSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { refreshSupport = v_refreshSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_refreshSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_refreshSupport in - let bnd = "refreshSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(refreshSupport : bool option) (() : unit) : t = { refreshSupport } end @@ -6348,254 +1888,25 @@ module FileOperationClientCapabilities = struct ; didDelete : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; didRename : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; willCreate : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; willDelete : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; willRename : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileOperationClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let didCreate_field = ref Ppx_yojson_conv_lib.Option.None - and didDelete_field = ref Ppx_yojson_conv_lib.Option.None - and didRename_field = ref Ppx_yojson_conv_lib.Option.None - and dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and willCreate_field = ref Ppx_yojson_conv_lib.Option.None - and willDelete_field = ref Ppx_yojson_conv_lib.Option.None - and willRename_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "didCreate" -> - (match Ppx_yojson_conv_lib.( ! ) didCreate_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - didCreate_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "didDelete" -> - (match Ppx_yojson_conv_lib.( ! ) didDelete_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - didDelete_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "didRename" -> - (match Ppx_yojson_conv_lib.( ! ) didRename_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - didRename_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "willCreate" -> - (match Ppx_yojson_conv_lib.( ! ) willCreate_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - willCreate_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "willDelete" -> - (match Ppx_yojson_conv_lib.( ! ) willDelete_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - willDelete_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "willRename" -> - (match Ppx_yojson_conv_lib.( ! ) willRename_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - willRename_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( didCreate_value - , didDelete_value - , didRename_value - , dynamicRegistration_value - , willCreate_value - , willDelete_value - , willRename_value ) - = - ( Ppx_yojson_conv_lib.( ! ) didCreate_field - , Ppx_yojson_conv_lib.( ! ) didDelete_field - , Ppx_yojson_conv_lib.( ! ) didRename_field - , Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) willCreate_field - , Ppx_yojson_conv_lib.( ! ) willDelete_field - , Ppx_yojson_conv_lib.( ! ) willRename_field ) - in - { didCreate = - (match didCreate_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; didDelete = - (match didDelete_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; didRename = - (match didRename_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; willCreate = - (match willCreate_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; willDelete = - (match willDelete_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; willRename = - (match willRename_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { didCreate = v_didCreate - ; didDelete = v_didDelete - ; didRename = v_didRename - ; dynamicRegistration = v_dynamicRegistration - ; willCreate = v_willCreate - ; willDelete = v_willDelete - ; willRename = v_willRename - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_willRename - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_willRename in - let bnd = "willRename", arg in - bnd :: bnds) - in - let bnds = - if None = v_willDelete - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_willDelete in - let bnd = "willDelete", arg in - bnd :: bnds) - in - let bnds = - if None = v_willCreate - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_willCreate in - let bnd = "willCreate", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - let bnds = - if None = v_didRename - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_didRename in - let bnd = "didRename", arg in - bnd :: bnds) - in - let bnds = - if None = v_didDelete - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_didDelete in - let bnd = "didDelete", arg in - bnd :: bnds) - in - let bnds = - if None = v_didCreate - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_didCreate in - let bnd = "didCreate", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(didCreate : bool option) - ?(didDelete : bool option) - ?(didRename : bool option) - ?(dynamicRegistration : bool option) - ?(willCreate : bool option) - ?(willDelete : bool option) - ?(willRename : bool option) - (() : unit) + ?(didCreate : bool option) + ?(didDelete : bool option) + ?(didRename : bool option) + ?(dynamicRegistration : bool option) + ?(willCreate : bool option) + ?(willDelete : bool option) + ?(willRename : bool option) + (() : unit) : t = { didCreate @@ -6612,86 +1923,9 @@ end module ExecuteCommandClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ExecuteCommandClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -6701,120 +1935,16 @@ end module DidChangeWatchedFilesClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; relativePatternSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidChangeWatchedFilesClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and relativePatternSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "relativePatternSupport" -> - (match Ppx_yojson_conv_lib.( ! ) relativePatternSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - relativePatternSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value, relativePatternSupport_value = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) relativePatternSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; relativePatternSupport = - (match relativePatternSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration - ; relativePatternSupport = v_relativePatternSupport - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_relativePatternSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_relativePatternSupport - in - let bnd = "relativePatternSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(dynamicRegistration : bool option) - ?(relativePatternSupport : bool option) - (() : unit) + ?(dynamicRegistration : bool option) + ?(relativePatternSupport : bool option) + (() : unit) : t = { dynamicRegistration; relativePatternSupport } @@ -6824,86 +1954,9 @@ end module DidChangeConfigurationClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidChangeConfigurationClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -6913,82 +1966,9 @@ end module DiagnosticWorkspaceClientCapabilities = struct type t = { refreshSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DiagnosticWorkspaceClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let refreshSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "refreshSupport" -> - (match Ppx_yojson_conv_lib.( ! ) refreshSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - refreshSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let refreshSupport_value = Ppx_yojson_conv_lib.( ! ) refreshSupport_field in - { refreshSupport = - (match refreshSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { refreshSupport = v_refreshSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_refreshSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_refreshSupport in - let bnd = "refreshSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(refreshSupport : bool option) (() : unit) : t = { refreshSupport } end @@ -6996,82 +1976,9 @@ end module CodeLensWorkspaceClientCapabilities = struct type t = { refreshSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeLensWorkspaceClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let refreshSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "refreshSupport" -> - (match Ppx_yojson_conv_lib.( ! ) refreshSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - refreshSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let refreshSupport_value = Ppx_yojson_conv_lib.( ! ) refreshSupport_field in - { refreshSupport = - (match refreshSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { refreshSupport = v_refreshSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_refreshSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_refreshSupport in - let bnd = "refreshSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(refreshSupport : bool option) (() : unit) : t = { refreshSupport } end @@ -7080,556 +1987,55 @@ module WorkspaceClientCapabilities = struct type t = { applyEdit : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; codeLens : CodeLensWorkspaceClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; configuration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; diagnostics : DiagnosticWorkspaceClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; didChangeConfiguration : DidChangeConfigurationClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; didChangeWatchedFiles : DidChangeWatchedFilesClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; executeCommand : ExecuteCommandClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; fileOperations : FileOperationClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; foldingRange : FoldingRangeWorkspaceClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; inlayHint : InlayHintWorkspaceClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; inlineValue : InlineValueWorkspaceClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; semanticTokens : SemanticTokensWorkspaceClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; symbol : WorkspaceSymbolClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workspaceEdit : WorkspaceEditClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workspaceFolders : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let applyEdit_field = ref Ppx_yojson_conv_lib.Option.None - and codeLens_field = ref Ppx_yojson_conv_lib.Option.None - and configuration_field = ref Ppx_yojson_conv_lib.Option.None - and diagnostics_field = ref Ppx_yojson_conv_lib.Option.None - and didChangeConfiguration_field = ref Ppx_yojson_conv_lib.Option.None - and didChangeWatchedFiles_field = ref Ppx_yojson_conv_lib.Option.None - and executeCommand_field = ref Ppx_yojson_conv_lib.Option.None - and fileOperations_field = ref Ppx_yojson_conv_lib.Option.None - and foldingRange_field = ref Ppx_yojson_conv_lib.Option.None - and inlayHint_field = ref Ppx_yojson_conv_lib.Option.None - and inlineValue_field = ref Ppx_yojson_conv_lib.Option.None - and semanticTokens_field = ref Ppx_yojson_conv_lib.Option.None - and symbol_field = ref Ppx_yojson_conv_lib.Option.None - and workspaceEdit_field = ref Ppx_yojson_conv_lib.Option.None - and workspaceFolders_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "applyEdit" -> - (match Ppx_yojson_conv_lib.( ! ) applyEdit_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - applyEdit_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "codeLens" -> - (match Ppx_yojson_conv_lib.( ! ) codeLens_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CodeLensWorkspaceClientCapabilities.t_of_yojson - _field_yojson - in - codeLens_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "configuration" -> - (match Ppx_yojson_conv_lib.( ! ) configuration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - configuration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "diagnostics" -> - (match Ppx_yojson_conv_lib.( ! ) diagnostics_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DiagnosticWorkspaceClientCapabilities.t_of_yojson - _field_yojson - in - diagnostics_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "didChangeConfiguration" -> - (match Ppx_yojson_conv_lib.( ! ) didChangeConfiguration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DidChangeConfigurationClientCapabilities.t_of_yojson - _field_yojson - in - didChangeConfiguration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "didChangeWatchedFiles" -> - (match Ppx_yojson_conv_lib.( ! ) didChangeWatchedFiles_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DidChangeWatchedFilesClientCapabilities.t_of_yojson - _field_yojson - in - didChangeWatchedFiles_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "executeCommand" -> - (match Ppx_yojson_conv_lib.( ! ) executeCommand_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ExecuteCommandClientCapabilities.t_of_yojson - _field_yojson - in - executeCommand_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "fileOperations" -> - (match Ppx_yojson_conv_lib.( ! ) fileOperations_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FileOperationClientCapabilities.t_of_yojson - _field_yojson - in - fileOperations_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "foldingRange" -> - (match Ppx_yojson_conv_lib.( ! ) foldingRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FoldingRangeWorkspaceClientCapabilities.t_of_yojson - _field_yojson - in - foldingRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "inlayHint" -> - (match Ppx_yojson_conv_lib.( ! ) inlayHint_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InlayHintWorkspaceClientCapabilities.t_of_yojson - _field_yojson - in - inlayHint_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "inlineValue" -> - (match Ppx_yojson_conv_lib.( ! ) inlineValue_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InlineValueWorkspaceClientCapabilities.t_of_yojson - _field_yojson - in - inlineValue_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "semanticTokens" -> - (match Ppx_yojson_conv_lib.( ! ) semanticTokens_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - SemanticTokensWorkspaceClientCapabilities.t_of_yojson - _field_yojson - in - semanticTokens_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "symbol" -> - (match Ppx_yojson_conv_lib.( ! ) symbol_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - WorkspaceSymbolClientCapabilities.t_of_yojson - _field_yojson - in - symbol_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workspaceEdit" -> - (match Ppx_yojson_conv_lib.( ! ) workspaceEdit_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - WorkspaceEditClientCapabilities.t_of_yojson - _field_yojson - in - workspaceEdit_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workspaceFolders" -> - (match Ppx_yojson_conv_lib.( ! ) workspaceFolders_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workspaceFolders_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( applyEdit_value - , codeLens_value - , configuration_value - , diagnostics_value - , didChangeConfiguration_value - , didChangeWatchedFiles_value - , executeCommand_value - , fileOperations_value - , foldingRange_value - , inlayHint_value - , inlineValue_value - , semanticTokens_value - , symbol_value - , workspaceEdit_value - , workspaceFolders_value ) - = - ( Ppx_yojson_conv_lib.( ! ) applyEdit_field - , Ppx_yojson_conv_lib.( ! ) codeLens_field - , Ppx_yojson_conv_lib.( ! ) configuration_field - , Ppx_yojson_conv_lib.( ! ) diagnostics_field - , Ppx_yojson_conv_lib.( ! ) didChangeConfiguration_field - , Ppx_yojson_conv_lib.( ! ) didChangeWatchedFiles_field - , Ppx_yojson_conv_lib.( ! ) executeCommand_field - , Ppx_yojson_conv_lib.( ! ) fileOperations_field - , Ppx_yojson_conv_lib.( ! ) foldingRange_field - , Ppx_yojson_conv_lib.( ! ) inlayHint_field - , Ppx_yojson_conv_lib.( ! ) inlineValue_field - , Ppx_yojson_conv_lib.( ! ) semanticTokens_field - , Ppx_yojson_conv_lib.( ! ) symbol_field - , Ppx_yojson_conv_lib.( ! ) workspaceEdit_field - , Ppx_yojson_conv_lib.( ! ) workspaceFolders_field ) - in - { applyEdit = - (match applyEdit_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; codeLens = - (match codeLens_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; configuration = - (match configuration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; diagnostics = - (match diagnostics_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; didChangeConfiguration = - (match didChangeConfiguration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; didChangeWatchedFiles = - (match didChangeWatchedFiles_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; executeCommand = - (match executeCommand_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; fileOperations = - (match fileOperations_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; foldingRange = - (match foldingRange_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; inlayHint = - (match inlayHint_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; inlineValue = - (match inlineValue_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; semanticTokens = - (match semanticTokens_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; symbol = - (match symbol_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workspaceEdit = - (match workspaceEdit_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workspaceFolders = - (match workspaceFolders_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { applyEdit = v_applyEdit - ; codeLens = v_codeLens - ; configuration = v_configuration - ; diagnostics = v_diagnostics - ; didChangeConfiguration = v_didChangeConfiguration - ; didChangeWatchedFiles = v_didChangeWatchedFiles - ; executeCommand = v_executeCommand - ; fileOperations = v_fileOperations - ; foldingRange = v_foldingRange - ; inlayHint = v_inlayHint - ; inlineValue = v_inlineValue - ; semanticTokens = v_semanticTokens - ; symbol = v_symbol - ; workspaceEdit = v_workspaceEdit - ; workspaceFolders = v_workspaceFolders - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workspaceFolders - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workspaceFolders - in - let bnd = "workspaceFolders", arg in - bnd :: bnds) - in - let bnds = - if None = v_workspaceEdit - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - WorkspaceEditClientCapabilities.yojson_of_t) - v_workspaceEdit - in - let bnd = "workspaceEdit", arg in - bnd :: bnds) - in - let bnds = - if None = v_symbol - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - WorkspaceSymbolClientCapabilities.yojson_of_t) - v_symbol - in - let bnd = "symbol", arg in - bnd :: bnds) - in - let bnds = - if None = v_semanticTokens - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - SemanticTokensWorkspaceClientCapabilities.yojson_of_t) - v_semanticTokens - in - let bnd = "semanticTokens", arg in - bnd :: bnds) - in - let bnds = - if None = v_inlineValue - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - InlineValueWorkspaceClientCapabilities.yojson_of_t) - v_inlineValue - in - let bnd = "inlineValue", arg in - bnd :: bnds) - in - let bnds = - if None = v_inlayHint - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - InlayHintWorkspaceClientCapabilities.yojson_of_t) - v_inlayHint - in - let bnd = "inlayHint", arg in - bnd :: bnds) - in - let bnds = - if None = v_foldingRange - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - FoldingRangeWorkspaceClientCapabilities.yojson_of_t) - v_foldingRange - in - let bnd = "foldingRange", arg in - bnd :: bnds) - in - let bnds = - if None = v_fileOperations - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - FileOperationClientCapabilities.yojson_of_t) - v_fileOperations - in - let bnd = "fileOperations", arg in - bnd :: bnds) - in - let bnds = - if None = v_executeCommand - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - ExecuteCommandClientCapabilities.yojson_of_t) - v_executeCommand - in - let bnd = "executeCommand", arg in - bnd :: bnds) - in - let bnds = - if None = v_didChangeWatchedFiles - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - DidChangeWatchedFilesClientCapabilities.yojson_of_t) - v_didChangeWatchedFiles - in - let bnd = "didChangeWatchedFiles", arg in - bnd :: bnds) - in - let bnds = - if None = v_didChangeConfiguration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - DidChangeConfigurationClientCapabilities.yojson_of_t) - v_didChangeConfiguration - in - let bnd = "didChangeConfiguration", arg in - bnd :: bnds) - in - let bnds = - if None = v_diagnostics - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - DiagnosticWorkspaceClientCapabilities.yojson_of_t) - v_diagnostics - in - let bnd = "diagnostics", arg in - bnd :: bnds) - in - let bnds = - if None = v_configuration - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_configuration in - let bnd = "configuration", arg in - bnd :: bnds) - in - let bnds = - if None = v_codeLens - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - CodeLensWorkspaceClientCapabilities.yojson_of_t) - v_codeLens - in - let bnd = "codeLens", arg in - bnd :: bnds) - in - let bnds = - if None = v_applyEdit - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_applyEdit in - let bnd = "applyEdit", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(applyEdit : bool option) - ?(codeLens : CodeLensWorkspaceClientCapabilities.t option) - ?(configuration : bool option) - ?(diagnostics : DiagnosticWorkspaceClientCapabilities.t option) - ?(didChangeConfiguration : DidChangeConfigurationClientCapabilities.t option) - ?(didChangeWatchedFiles : DidChangeWatchedFilesClientCapabilities.t option) - ?(executeCommand : ExecuteCommandClientCapabilities.t option) - ?(fileOperations : FileOperationClientCapabilities.t option) - ?(foldingRange : FoldingRangeWorkspaceClientCapabilities.t option) - ?(inlayHint : InlayHintWorkspaceClientCapabilities.t option) - ?(inlineValue : InlineValueWorkspaceClientCapabilities.t option) - ?(semanticTokens : SemanticTokensWorkspaceClientCapabilities.t option) - ?(symbol : WorkspaceSymbolClientCapabilities.t option) - ?(workspaceEdit : WorkspaceEditClientCapabilities.t option) - ?(workspaceFolders : bool option) - (() : unit) + ?(applyEdit : bool option) + ?(codeLens : CodeLensWorkspaceClientCapabilities.t option) + ?(configuration : bool option) + ?(diagnostics : DiagnosticWorkspaceClientCapabilities.t option) + ?(didChangeConfiguration : DidChangeConfigurationClientCapabilities.t option) + ?(didChangeWatchedFiles : DidChangeWatchedFilesClientCapabilities.t option) + ?(executeCommand : ExecuteCommandClientCapabilities.t option) + ?(fileOperations : FileOperationClientCapabilities.t option) + ?(foldingRange : FoldingRangeWorkspaceClientCapabilities.t option) + ?(inlayHint : InlayHintWorkspaceClientCapabilities.t option) + ?(inlineValue : InlineValueWorkspaceClientCapabilities.t option) + ?(semanticTokens : SemanticTokensWorkspaceClientCapabilities.t option) + ?(symbol : WorkspaceSymbolClientCapabilities.t option) + ?(workspaceEdit : WorkspaceEditClientCapabilities.t option) + ?(workspaceFolders : bool option) + (() : unit) : t = { applyEdit @@ -7654,90 +2060,9 @@ end module ShowMessageRequestClientCapabilities = struct type messageActionItem = { additionalPropertiesSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : messageActionItem) -> () - - let messageActionItem_of_yojson = - (let _tp_loc = - "lsp/src/types.ml.ShowMessageRequestClientCapabilities.messageActionItem" - in - function - | `Assoc field_yojsons as yojson -> - let additionalPropertiesSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "additionalPropertiesSupport" -> - (match Ppx_yojson_conv_lib.( ! ) additionalPropertiesSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - additionalPropertiesSupport_field - := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let additionalPropertiesSupport_value = - Ppx_yojson_conv_lib.( ! ) additionalPropertiesSupport_field - in - { additionalPropertiesSupport = - (match additionalPropertiesSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> messageActionItem) - ;; - - let _ = messageActionItem_of_yojson - - let yojson_of_messageActionItem = - (function - | { additionalPropertiesSupport = v_additionalPropertiesSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_additionalPropertiesSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) - v_additionalPropertiesSupport - in - let bnd = "additionalPropertiesSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : messageActionItem -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_messageActionItem - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_messageActionItem ?(additionalPropertiesSupport : bool option) (() : unit) : messageActionItem @@ -7747,89 +2072,9 @@ module ShowMessageRequestClientCapabilities = struct type t = { messageActionItem : messageActionItem Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ShowMessageRequestClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let messageActionItem_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "messageActionItem" -> - (match Ppx_yojson_conv_lib.( ! ) messageActionItem_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - messageActionItem_of_yojson - _field_yojson - in - messageActionItem_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let messageActionItem_value = - Ppx_yojson_conv_lib.( ! ) messageActionItem_field - in - { messageActionItem = - (match messageActionItem_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { messageActionItem = v_messageActionItem } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_messageActionItem - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_messageActionItem) - v_messageActionItem - in - let bnd = "messageActionItem", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(messageActionItem : messageActionItem option) (() : unit) : t = { messageActionItem } @@ -7837,80 +2082,7 @@ module ShowMessageRequestClientCapabilities = struct end module ShowDocumentClientCapabilities = struct - type t = { support : bool } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ShowDocumentClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let support_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "support" -> - (match Ppx_yojson_conv_lib.( ! ) support_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - support_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) support_field with - | Ppx_yojson_conv_lib.Option.Some support_value -> - { support = support_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) support_field) - Ppx_yojson_conv_lib.Option.None - , "support" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { support = v_support } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_support in - ("support", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { support : bool } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(support : bool) : t = { support } end @@ -7918,156 +2090,19 @@ end module WindowClientCapabilities = struct type t = { showDocument : ShowDocumentClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; showMessage : ShowMessageRequestClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WindowClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let showDocument_field = ref Ppx_yojson_conv_lib.Option.None - and showMessage_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "showDocument" -> - (match Ppx_yojson_conv_lib.( ! ) showDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ShowDocumentClientCapabilities.t_of_yojson - _field_yojson - in - showDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "showMessage" -> - (match Ppx_yojson_conv_lib.( ! ) showMessage_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ShowMessageRequestClientCapabilities.t_of_yojson - _field_yojson - in - showMessage_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let showDocument_value, showMessage_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) showDocument_field - , Ppx_yojson_conv_lib.( ! ) showMessage_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { showDocument = - (match showDocument_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; showMessage = - (match showMessage_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { showDocument = v_showDocument - ; showMessage = v_showMessage - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_showMessage - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - ShowMessageRequestClientCapabilities.yojson_of_t) - v_showMessage - in - let bnd = "showMessage", arg in - bnd :: bnds) - in - let bnds = - if None = v_showDocument - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ShowDocumentClientCapabilities.yojson_of_t) - v_showDocument - in - let bnd = "showDocument", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(showDocument : ShowDocumentClientCapabilities.t option) - ?(showMessage : ShowMessageRequestClientCapabilities.t option) - ?(workDoneProgress : bool option) - (() : unit) + ?(showDocument : ShowDocumentClientCapabilities.t option) + ?(showMessage : ShowMessageRequestClientCapabilities.t option) + ?(workDoneProgress : bool option) + (() : unit) : t = { showDocument; showMessage; workDoneProgress } @@ -8077,86 +2112,9 @@ end module TypeHierarchyClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeHierarchyClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -8166,111 +2124,11 @@ end module TypeDefinitionClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; linkSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeDefinitionClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and linkSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "linkSupport" -> - (match Ppx_yojson_conv_lib.( ! ) linkSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - linkSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value, linkSupport_value = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) linkSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; linkSupport = - (match linkSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration; linkSupport = v_linkSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_linkSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_linkSupport in - let bnd = "linkSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) ?(linkSupport : bool option) (() : unit) : t @@ -8283,175 +2141,19 @@ module TextDocumentSyncClientCapabilities = struct type t = { didSave : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; willSave : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; willSaveWaitUntil : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentSyncClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let didSave_field = ref Ppx_yojson_conv_lib.Option.None - and dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and willSave_field = ref Ppx_yojson_conv_lib.Option.None - and willSaveWaitUntil_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "didSave" -> - (match Ppx_yojson_conv_lib.( ! ) didSave_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - didSave_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "willSave" -> - (match Ppx_yojson_conv_lib.( ! ) willSave_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - willSave_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "willSaveWaitUntil" -> - (match Ppx_yojson_conv_lib.( ! ) willSaveWaitUntil_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - willSaveWaitUntil_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( didSave_value - , dynamicRegistration_value - , willSave_value - , willSaveWaitUntil_value ) - = - ( Ppx_yojson_conv_lib.( ! ) didSave_field - , Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) willSave_field - , Ppx_yojson_conv_lib.( ! ) willSaveWaitUntil_field ) - in - { didSave = - (match didSave_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; willSave = - (match willSave_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; willSaveWaitUntil = - (match willSaveWaitUntil_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { didSave = v_didSave - ; dynamicRegistration = v_dynamicRegistration - ; willSave = v_willSave - ; willSaveWaitUntil = v_willSaveWaitUntil - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_willSaveWaitUntil - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_willSaveWaitUntil - in - let bnd = "willSaveWaitUntil", arg in - bnd :: bnds) - in - let bnds = - if None = v_willSave - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_willSave in - let bnd = "willSave", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - let bnds = - if None = v_didSave - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_didSave in - let bnd = "didSave", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(didSave : bool option) - ?(dynamicRegistration : bool option) - ?(willSave : bool option) - ?(willSaveWaitUntil : bool option) - (() : unit) + ?(didSave : bool option) + ?(dynamicRegistration : bool option) + ?(willSave : bool option) + ?(willSaveWaitUntil : bool option) + (() : unit) : t = { didSave; dynamicRegistration; willSave; willSaveWaitUntil } @@ -8461,88 +2163,9 @@ end module SignatureHelpClientCapabilities = struct type parameterInformation = { labelOffsetSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : parameterInformation) -> () - - let parameterInformation_of_yojson = - (let _tp_loc = - "lsp/src/types.ml.SignatureHelpClientCapabilities.parameterInformation" - in - function - | `Assoc field_yojsons as yojson -> - let labelOffsetSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "labelOffsetSupport" -> - (match Ppx_yojson_conv_lib.( ! ) labelOffsetSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - labelOffsetSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let labelOffsetSupport_value = - Ppx_yojson_conv_lib.( ! ) labelOffsetSupport_field - in - { labelOffsetSupport = - (match labelOffsetSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> parameterInformation) - ;; - - let _ = parameterInformation_of_yojson - - let yojson_of_parameterInformation = - (function - | { labelOffsetSupport = v_labelOffsetSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_labelOffsetSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_labelOffsetSupport - in - let bnd = "labelOffsetSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : parameterInformation -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_parameterInformation - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_parameterInformation ?(labelOffsetSupport : bool option) (() : unit) : parameterInformation @@ -8552,190 +2175,22 @@ module SignatureHelpClientCapabilities = struct type signatureInformation = { documentationFormat : MarkupKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; parameterInformation : parameterInformation Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; activeParameterSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; noActiveParameterSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : signatureInformation) -> () - - let signatureInformation_of_yojson = - (let _tp_loc = - "lsp/src/types.ml.SignatureHelpClientCapabilities.signatureInformation" - in - function - | `Assoc field_yojsons as yojson -> - let documentationFormat_field = ref Ppx_yojson_conv_lib.Option.None - and parameterInformation_field = ref Ppx_yojson_conv_lib.Option.None - and activeParameterSupport_field = ref Ppx_yojson_conv_lib.Option.None - and noActiveParameterSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentationFormat" -> - (match Ppx_yojson_conv_lib.( ! ) documentationFormat_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson MarkupKind.t_of_yojson) - _field_yojson - in - documentationFormat_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "parameterInformation" -> - (match Ppx_yojson_conv_lib.( ! ) parameterInformation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - parameterInformation_of_yojson - _field_yojson - in - parameterInformation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "activeParameterSupport" -> - (match Ppx_yojson_conv_lib.( ! ) activeParameterSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - activeParameterSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "noActiveParameterSupport" -> - (match Ppx_yojson_conv_lib.( ! ) noActiveParameterSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - noActiveParameterSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( documentationFormat_value - , parameterInformation_value - , activeParameterSupport_value - , noActiveParameterSupport_value ) - = - ( Ppx_yojson_conv_lib.( ! ) documentationFormat_field - , Ppx_yojson_conv_lib.( ! ) parameterInformation_field - , Ppx_yojson_conv_lib.( ! ) activeParameterSupport_field - , Ppx_yojson_conv_lib.( ! ) noActiveParameterSupport_field ) - in - { documentationFormat = - (match documentationFormat_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; parameterInformation = - (match parameterInformation_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; activeParameterSupport = - (match activeParameterSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; noActiveParameterSupport = - (match noActiveParameterSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> signatureInformation) - ;; - - let _ = signatureInformation_of_yojson - - let yojson_of_signatureInformation = - (function - | { documentationFormat = v_documentationFormat - ; parameterInformation = v_parameterInformation - ; activeParameterSupport = v_activeParameterSupport - ; noActiveParameterSupport = v_noActiveParameterSupport - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_noActiveParameterSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_noActiveParameterSupport - in - let bnd = "noActiveParameterSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_activeParameterSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_activeParameterSupport - in - let bnd = "activeParameterSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_parameterInformation - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_parameterInformation) - v_parameterInformation - in - let bnd = "parameterInformation", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentationFormat - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list MarkupKind.yojson_of_t)) - v_documentationFormat - in - let bnd = "documentationFormat", arg in - bnd :: bnds) - in - `Assoc bnds - : signatureInformation -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_signatureInformation - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_signatureInformation - ?(documentationFormat : MarkupKind.t list option) - ?(parameterInformation : parameterInformation option) - ?(activeParameterSupport : bool option) - ?(noActiveParameterSupport : bool option) - (() : unit) + ?(documentationFormat : MarkupKind.t list option) + ?(parameterInformation : parameterInformation option) + ?(activeParameterSupport : bool option) + ?(noActiveParameterSupport : bool option) + (() : unit) : signatureInformation = { documentationFormat @@ -8747,153 +2202,19 @@ module SignatureHelpClientCapabilities = struct type t = { contextSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; signatureInformation : signatureInformation Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SignatureHelpClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let contextSupport_field = ref Ppx_yojson_conv_lib.Option.None - and dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and signatureInformation_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "contextSupport" -> - (match Ppx_yojson_conv_lib.( ! ) contextSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - contextSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "signatureInformation" -> - (match Ppx_yojson_conv_lib.( ! ) signatureInformation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - signatureInformation_of_yojson - _field_yojson - in - signatureInformation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( contextSupport_value - , dynamicRegistration_value - , signatureInformation_value ) - = - ( Ppx_yojson_conv_lib.( ! ) contextSupport_field - , Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) signatureInformation_field ) - in - { contextSupport = - (match contextSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; signatureInformation = - (match signatureInformation_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { contextSupport = v_contextSupport - ; dynamicRegistration = v_dynamicRegistration - ; signatureInformation = v_signatureInformation - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_signatureInformation - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_signatureInformation) - v_signatureInformation - in - let bnd = "signatureInformation", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - let bnds = - if None = v_contextSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_contextSupport in - let bnd = "contextSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(contextSupport : bool option) - ?(dynamicRegistration : bool option) - ?(signatureInformation : signatureInformation option) - (() : unit) + ?(contextSupport : bool option) + ?(dynamicRegistration : bool option) + ?(signatureInformation : signatureInformation option) + (() : unit) : t = { contextSupport; dynamicRegistration; signatureInformation } @@ -8903,80 +2224,7 @@ end module SemanticTokensClientCapabilities = struct type full = { delta : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : full) -> () - - let full_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensClientCapabilities.full" in - function - | `Assoc field_yojsons as yojson -> - let delta_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "delta" -> - (match Ppx_yojson_conv_lib.( ! ) delta_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - delta_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let delta_value = Ppx_yojson_conv_lib.( ! ) delta_field in - { delta = - (match delta_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> full) - ;; - - let _ = full_of_yojson - - let yojson_of_full = - (function - | { delta = v_delta } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_delta - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_delta in - let bnd = "delta", arg in - bnd :: bnds) - in - `Assoc bnds - : full -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_full - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_full ?(delta : bool option) (() : unit) : full = { delta } @@ -9005,104 +2253,7 @@ module SemanticTokensClientCapabilities = struct { range : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; full : full_pvar Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : requests) -> () - - let requests_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensClientCapabilities.requests" in - function - | `Assoc field_yojsons as yojson -> - let range_field = ref Ppx_yojson_conv_lib.Option.None - and full_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "full" -> - (match Ppx_yojson_conv_lib.( ! ) full_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson full_pvar_of_yojson _field_yojson - in - full_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let range_value, full_value = - Ppx_yojson_conv_lib.( ! ) range_field, Ppx_yojson_conv_lib.( ! ) full_field - in - { range = - (match range_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; full = - (match full_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> requests) - ;; - - let _ = requests_of_yojson - - let yojson_of_requests = - (function - | { range = v_range; full = v_full } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_full - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_full_pvar) v_full in - let bnd = "full", arg in - bnd :: bnds) - in - let bnds = - if None = v_range - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_range in - let bnd = "range", arg in - bnd :: bnds) - in - `Assoc bnds - : requests -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_requests - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_requests ?(range : bool option) ?(full : full_pvar option) (() : unit) : requests @@ -9112,305 +2263,33 @@ module SemanticTokensClientCapabilities = struct type t = { augmentsSyntaxTokens : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; formats : TokenFormat.t list ; multilineTokenSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; overlappingTokenSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; requests : requests ; serverCancelSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; tokenModifiers : string list ; tokenTypes : string list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let augmentsSyntaxTokens_field = ref Ppx_yojson_conv_lib.Option.None - and dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and formats_field = ref Ppx_yojson_conv_lib.Option.None - and multilineTokenSupport_field = ref Ppx_yojson_conv_lib.Option.None - and overlappingTokenSupport_field = ref Ppx_yojson_conv_lib.Option.None - and requests_field = ref Ppx_yojson_conv_lib.Option.None - and serverCancelSupport_field = ref Ppx_yojson_conv_lib.Option.None - and tokenModifiers_field = ref Ppx_yojson_conv_lib.Option.None - and tokenTypes_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "augmentsSyntaxTokens" -> - (match Ppx_yojson_conv_lib.( ! ) augmentsSyntaxTokens_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - augmentsSyntaxTokens_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "formats" -> - (match Ppx_yojson_conv_lib.( ! ) formats_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson TokenFormat.t_of_yojson _field_yojson in - formats_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "multilineTokenSupport" -> - (match Ppx_yojson_conv_lib.( ! ) multilineTokenSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - multilineTokenSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "overlappingTokenSupport" -> - (match Ppx_yojson_conv_lib.( ! ) overlappingTokenSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - overlappingTokenSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "requests" -> - (match Ppx_yojson_conv_lib.( ! ) requests_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = requests_of_yojson _field_yojson in - requests_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "serverCancelSupport" -> - (match Ppx_yojson_conv_lib.( ! ) serverCancelSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - serverCancelSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tokenModifiers" -> - (match Ppx_yojson_conv_lib.( ! ) tokenModifiers_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - tokenModifiers_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tokenTypes" -> - (match Ppx_yojson_conv_lib.( ! ) tokenTypes_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - tokenTypes_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) augmentsSyntaxTokens_field - , Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) formats_field - , Ppx_yojson_conv_lib.( ! ) multilineTokenSupport_field - , Ppx_yojson_conv_lib.( ! ) overlappingTokenSupport_field - , Ppx_yojson_conv_lib.( ! ) requests_field - , Ppx_yojson_conv_lib.( ! ) serverCancelSupport_field - , Ppx_yojson_conv_lib.( ! ) tokenModifiers_field - , Ppx_yojson_conv_lib.( ! ) tokenTypes_field ) - with - | ( augmentsSyntaxTokens_value - , dynamicRegistration_value - , Ppx_yojson_conv_lib.Option.Some formats_value - , multilineTokenSupport_value - , overlappingTokenSupport_value - , Ppx_yojson_conv_lib.Option.Some requests_value - , serverCancelSupport_value - , Ppx_yojson_conv_lib.Option.Some tokenModifiers_value - , Ppx_yojson_conv_lib.Option.Some tokenTypes_value ) -> - { augmentsSyntaxTokens = - (match augmentsSyntaxTokens_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; formats = formats_value - ; multilineTokenSupport = - (match multilineTokenSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; overlappingTokenSupport = - (match overlappingTokenSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; requests = requests_value - ; serverCancelSupport = - (match serverCancelSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tokenModifiers = tokenModifiers_value - ; tokenTypes = tokenTypes_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) formats_field) - Ppx_yojson_conv_lib.Option.None - , "formats" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) requests_field) - Ppx_yojson_conv_lib.Option.None - , "requests" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) tokenModifiers_field) - Ppx_yojson_conv_lib.Option.None - , "tokenModifiers" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) tokenTypes_field) - Ppx_yojson_conv_lib.Option.None - , "tokenTypes" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { augmentsSyntaxTokens = v_augmentsSyntaxTokens - ; dynamicRegistration = v_dynamicRegistration - ; formats = v_formats - ; multilineTokenSupport = v_multilineTokenSupport - ; overlappingTokenSupport = v_overlappingTokenSupport - ; requests = v_requests - ; serverCancelSupport = v_serverCancelSupport - ; tokenModifiers = v_tokenModifiers - ; tokenTypes = v_tokenTypes - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list yojson_of_string v_tokenTypes in - ("tokenTypes", arg) :: bnds - in - let bnds = - let arg = yojson_of_list yojson_of_string v_tokenModifiers in - ("tokenModifiers", arg) :: bnds - in - let bnds = - if None = v_serverCancelSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_serverCancelSupport - in - let bnd = "serverCancelSupport", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_requests v_requests in - ("requests", arg) :: bnds - in - let bnds = - if None = v_overlappingTokenSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_overlappingTokenSupport - in - let bnd = "overlappingTokenSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_multilineTokenSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_multilineTokenSupport - in - let bnd = "multilineTokenSupport", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list TokenFormat.yojson_of_t v_formats in - ("formats", arg) :: bnds - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - let bnds = - if None = v_augmentsSyntaxTokens - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_augmentsSyntaxTokens - in - let bnd = "augmentsSyntaxTokens", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(augmentsSyntaxTokens : bool option) - ?(dynamicRegistration : bool option) - ~(formats : TokenFormat.t list) - ?(multilineTokenSupport : bool option) - ?(overlappingTokenSupport : bool option) - ~(requests : requests) - ?(serverCancelSupport : bool option) - ~(tokenModifiers : string list) - ~(tokenTypes : string list) - (() : unit) + ?(augmentsSyntaxTokens : bool option) + ?(dynamicRegistration : bool option) + ~(formats : TokenFormat.t list) + ?(multilineTokenSupport : bool option) + ?(overlappingTokenSupport : bool option) + ~(requests : requests) + ?(serverCancelSupport : bool option) + ~(tokenModifiers : string list) + ~(tokenTypes : string list) + (() : unit) : t = { augmentsSyntaxTokens @@ -9429,86 +2308,9 @@ end module SelectionRangeClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SelectionRangeClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -9518,185 +2320,23 @@ end module RenameClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; honorsChangeAnnotations : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; prepareSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; prepareSupportDefaultBehavior : PrepareSupportDefaultBehavior.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RenameClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and honorsChangeAnnotations_field = ref Ppx_yojson_conv_lib.Option.None - and prepareSupport_field = ref Ppx_yojson_conv_lib.Option.None - and prepareSupportDefaultBehavior_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "honorsChangeAnnotations" -> - (match Ppx_yojson_conv_lib.( ! ) honorsChangeAnnotations_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - honorsChangeAnnotations_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "prepareSupport" -> - (match Ppx_yojson_conv_lib.( ! ) prepareSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - prepareSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "prepareSupportDefaultBehavior" -> - (match Ppx_yojson_conv_lib.( ! ) prepareSupportDefaultBehavior_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - PrepareSupportDefaultBehavior.t_of_yojson - _field_yojson - in - prepareSupportDefaultBehavior_field - := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( dynamicRegistration_value - , honorsChangeAnnotations_value - , prepareSupport_value - , prepareSupportDefaultBehavior_value ) - = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) honorsChangeAnnotations_field - , Ppx_yojson_conv_lib.( ! ) prepareSupport_field - , Ppx_yojson_conv_lib.( ! ) prepareSupportDefaultBehavior_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; honorsChangeAnnotations = - (match honorsChangeAnnotations_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; prepareSupport = - (match prepareSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; prepareSupportDefaultBehavior = - (match prepareSupportDefaultBehavior_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration - ; honorsChangeAnnotations = v_honorsChangeAnnotations - ; prepareSupport = v_prepareSupport - ; prepareSupportDefaultBehavior = v_prepareSupportDefaultBehavior - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_prepareSupportDefaultBehavior - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t PrepareSupportDefaultBehavior.yojson_of_t) - v_prepareSupportDefaultBehavior - in - let bnd = "prepareSupportDefaultBehavior", arg in - bnd :: bnds) - in - let bnds = - if None = v_prepareSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_prepareSupport in - let bnd = "prepareSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_honorsChangeAnnotations - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_honorsChangeAnnotations - in - let bnd = "honorsChangeAnnotations", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(dynamicRegistration : bool option) - ?(honorsChangeAnnotations : bool option) - ?(prepareSupport : bool option) - ?(prepareSupportDefaultBehavior : PrepareSupportDefaultBehavior.t option) - (() : unit) + ?(dynamicRegistration : bool option) + ?(honorsChangeAnnotations : bool option) + ?(prepareSupport : bool option) + ?(prepareSupportDefaultBehavior : PrepareSupportDefaultBehavior.t option) + (() : unit) : t = { dynamicRegistration @@ -9710,86 +2350,9 @@ end module ReferenceClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ReferenceClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -9799,116 +2362,16 @@ end module DocumentRangeFormattingClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; rangesSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentRangeFormattingClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and rangesSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "rangesSupport" -> - (match Ppx_yojson_conv_lib.( ! ) rangesSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - rangesSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value, rangesSupport_value = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) rangesSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; rangesSupport = - (match rangesSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration; rangesSupport = v_rangesSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_rangesSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_rangesSupport in - let bnd = "rangesSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(dynamicRegistration : bool option) - ?(rangesSupport : bool option) - (() : unit) + ?(dynamicRegistration : bool option) + ?(rangesSupport : bool option) + (() : unit) : t = { dynamicRegistration; rangesSupport } @@ -9917,287 +2380,31 @@ end module PublishDiagnosticsClientCapabilities = struct type tagSupport = { valueSet : DiagnosticTag.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : tagSupport) -> () - - let tagSupport_of_yojson = - (let _tp_loc = "lsp/src/types.ml.PublishDiagnosticsClientCapabilities.tagSupport" in - function - | `Assoc field_yojsons as yojson -> - let valueSet_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "valueSet" -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson DiagnosticTag.t_of_yojson _field_yojson in - valueSet_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.Some valueSet_value -> - { valueSet = valueSet_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) valueSet_field) - Ppx_yojson_conv_lib.Option.None - , "valueSet" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> tagSupport) - ;; - - let _ = tagSupport_of_yojson - - let yojson_of_tagSupport = - (function - | { valueSet = v_valueSet } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list DiagnosticTag.yojson_of_t v_valueSet in - ("valueSet", arg) :: bnds - in - `Assoc bnds - : tagSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_tagSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_tagSupport ~(valueSet : DiagnosticTag.t list) : tagSupport = { valueSet } type t = { codeDescriptionSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; dataSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; relatedInformation : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; tagSupport : tagSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; versionSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.PublishDiagnosticsClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let codeDescriptionSupport_field = ref Ppx_yojson_conv_lib.Option.None - and dataSupport_field = ref Ppx_yojson_conv_lib.Option.None - and relatedInformation_field = ref Ppx_yojson_conv_lib.Option.None - and tagSupport_field = ref Ppx_yojson_conv_lib.Option.None - and versionSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "codeDescriptionSupport" -> - (match Ppx_yojson_conv_lib.( ! ) codeDescriptionSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - codeDescriptionSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "dataSupport" -> - (match Ppx_yojson_conv_lib.( ! ) dataSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dataSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "relatedInformation" -> - (match Ppx_yojson_conv_lib.( ! ) relatedInformation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - relatedInformation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tagSupport" -> - (match Ppx_yojson_conv_lib.( ! ) tagSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson tagSupport_of_yojson _field_yojson - in - tagSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "versionSupport" -> - (match Ppx_yojson_conv_lib.( ! ) versionSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - versionSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( codeDescriptionSupport_value - , dataSupport_value - , relatedInformation_value - , tagSupport_value - , versionSupport_value ) - = - ( Ppx_yojson_conv_lib.( ! ) codeDescriptionSupport_field - , Ppx_yojson_conv_lib.( ! ) dataSupport_field - , Ppx_yojson_conv_lib.( ! ) relatedInformation_field - , Ppx_yojson_conv_lib.( ! ) tagSupport_field - , Ppx_yojson_conv_lib.( ! ) versionSupport_field ) - in - { codeDescriptionSupport = - (match codeDescriptionSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; dataSupport = - (match dataSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; relatedInformation = - (match relatedInformation_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tagSupport = - (match tagSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; versionSupport = - (match versionSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { codeDescriptionSupport = v_codeDescriptionSupport - ; dataSupport = v_dataSupport - ; relatedInformation = v_relatedInformation - ; tagSupport = v_tagSupport - ; versionSupport = v_versionSupport - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_versionSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_versionSupport in - let bnd = "versionSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_tagSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_tagSupport) v_tagSupport - in - let bnd = "tagSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_relatedInformation - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_relatedInformation - in - let bnd = "relatedInformation", arg in - bnd :: bnds) - in - let bnds = - if None = v_dataSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dataSupport in - let bnd = "dataSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_codeDescriptionSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_codeDescriptionSupport - in - let bnd = "codeDescriptionSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(codeDescriptionSupport : bool option) - ?(dataSupport : bool option) - ?(relatedInformation : bool option) - ?(tagSupport : tagSupport option) - ?(versionSupport : bool option) - (() : unit) + ?(codeDescriptionSupport : bool option) + ?(dataSupport : bool option) + ?(relatedInformation : bool option) + ?(tagSupport : tagSupport option) + ?(versionSupport : bool option) + (() : unit) : t = { codeDescriptionSupport @@ -10212,86 +2419,9 @@ end module DocumentOnTypeFormattingClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentOnTypeFormattingClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -10301,86 +2431,9 @@ end module MonikerClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.MonikerClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -10390,86 +2443,9 @@ end module LinkedEditingRangeClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.LinkedEditingRangeClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -10479,86 +2455,9 @@ end module InlineValueClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineValueClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -10568,86 +2467,9 @@ end module InlineCompletionClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineCompletionClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -10656,198 +2478,22 @@ end module InlayHintClientCapabilities = struct type resolveSupport = { properties : string list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : resolveSupport) -> () - - let resolveSupport_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlayHintClientCapabilities.resolveSupport" in - function - | `Assoc field_yojsons as yojson -> - let properties_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "properties" -> - (match Ppx_yojson_conv_lib.( ! ) properties_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - properties_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) properties_field with - | Ppx_yojson_conv_lib.Option.Some properties_value -> - { properties = properties_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) properties_field) - Ppx_yojson_conv_lib.Option.None - , "properties" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> resolveSupport) - ;; - - let _ = resolveSupport_of_yojson - - let yojson_of_resolveSupport = - (function - | { properties = v_properties } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list yojson_of_string v_properties in - ("properties", arg) :: bnds - in - `Assoc bnds - : resolveSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_resolveSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_resolveSupport ~(properties : string list) : resolveSupport = { properties } type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resolveSupport : resolveSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlayHintClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and resolveSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveSupport" -> - (match Ppx_yojson_conv_lib.( ! ) resolveSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson resolveSupport_of_yojson _field_yojson - in - resolveSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value, resolveSupport_value = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) resolveSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveSupport = - (match resolveSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration; resolveSupport = v_resolveSupport } - -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_resolveSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_resolveSupport) v_resolveSupport - in - let bnd = "resolveSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(dynamicRegistration : bool option) - ?(resolveSupport : resolveSupport option) - (() : unit) + ?(dynamicRegistration : bool option) + ?(resolveSupport : resolveSupport option) + (() : unit) : t = { dynamicRegistration; resolveSupport } @@ -10857,111 +2503,11 @@ end module ImplementationClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; linkSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ImplementationClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and linkSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "linkSupport" -> - (match Ppx_yojson_conv_lib.( ! ) linkSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - linkSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value, linkSupport_value = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) linkSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; linkSupport = - (match linkSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration; linkSupport = v_linkSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_linkSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_linkSupport in - let bnd = "linkSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) ?(linkSupport : bool option) (() : unit) : t @@ -10973,121 +2519,16 @@ end module HoverClientCapabilities = struct type t = { contentFormat : MarkupKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.HoverClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let contentFormat_field = ref Ppx_yojson_conv_lib.Option.None - and dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "contentFormat" -> - (match Ppx_yojson_conv_lib.( ! ) contentFormat_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson MarkupKind.t_of_yojson) - _field_yojson - in - contentFormat_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let contentFormat_value, dynamicRegistration_value = - ( Ppx_yojson_conv_lib.( ! ) contentFormat_field - , Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field ) - in - { contentFormat = - (match contentFormat_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { contentFormat = v_contentFormat; dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - let bnds = - if None = v_contentFormat - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list MarkupKind.yojson_of_t)) - v_contentFormat - in - let bnd = "contentFormat", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(contentFormat : MarkupKind.t list option) - ?(dynamicRegistration : bool option) - (() : unit) + ?(contentFormat : MarkupKind.t list option) + ?(dynamicRegistration : bool option) + (() : unit) : t = { contentFormat; dynamicRegistration } @@ -11097,86 +2538,9 @@ end module DocumentFormattingClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentFormattingClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -11186,88 +2550,9 @@ end module FoldingRangeClientCapabilities = struct type foldingRangeKind = { valueSet : FoldingRangeKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : foldingRangeKind) -> () - - let foldingRangeKind_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FoldingRangeClientCapabilities.foldingRangeKind" in - function - | `Assoc field_yojsons as yojson -> - let valueSet_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "valueSet" -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson FoldingRangeKind.t_of_yojson) - _field_yojson - in - valueSet_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let valueSet_value = Ppx_yojson_conv_lib.( ! ) valueSet_field in - { valueSet = - (match valueSet_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> foldingRangeKind) - ;; - - let _ = foldingRangeKind_of_yojson - - let yojson_of_foldingRangeKind = - (function - | { valueSet = v_valueSet } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_valueSet - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list FoldingRangeKind.yojson_of_t)) - v_valueSet - in - let bnd = "valueSet", arg in - bnd :: bnds) - in - `Assoc bnds - : foldingRangeKind -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_foldingRangeKind - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_foldingRangeKind ?(valueSet : FoldingRangeKind.t list option) (() : unit) : foldingRangeKind @@ -11277,82 +2562,9 @@ module FoldingRangeClientCapabilities = struct type foldingRange = { collapsedText : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : foldingRange) -> () - - let foldingRange_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FoldingRangeClientCapabilities.foldingRange" in - function - | `Assoc field_yojsons as yojson -> - let collapsedText_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "collapsedText" -> - (match Ppx_yojson_conv_lib.( ! ) collapsedText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - collapsedText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let collapsedText_value = Ppx_yojson_conv_lib.( ! ) collapsedText_field in - { collapsedText = - (match collapsedText_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> foldingRange) - ;; - - let _ = foldingRange_of_yojson - - let yojson_of_foldingRange = - (function - | { collapsedText = v_collapsedText } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_collapsedText - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_collapsedText in - let bnd = "collapsedText", arg in - bnd :: bnds) - in - `Assoc bnds - : foldingRange -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_foldingRange - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_foldingRange ?(collapsedText : bool option) (() : unit) : foldingRange = { collapsedText } @@ -11360,212 +2572,24 @@ module FoldingRangeClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; foldingRange : foldingRange Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; foldingRangeKind : foldingRangeKind Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; lineFoldingOnly : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; rangeLimit : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FoldingRangeClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and foldingRange_field = ref Ppx_yojson_conv_lib.Option.None - and foldingRangeKind_field = ref Ppx_yojson_conv_lib.Option.None - and lineFoldingOnly_field = ref Ppx_yojson_conv_lib.Option.None - and rangeLimit_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "foldingRange" -> - (match Ppx_yojson_conv_lib.( ! ) foldingRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson foldingRange_of_yojson _field_yojson - in - foldingRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "foldingRangeKind" -> - (match Ppx_yojson_conv_lib.( ! ) foldingRangeKind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - foldingRangeKind_of_yojson - _field_yojson - in - foldingRangeKind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "lineFoldingOnly" -> - (match Ppx_yojson_conv_lib.( ! ) lineFoldingOnly_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - lineFoldingOnly_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "rangeLimit" -> - (match Ppx_yojson_conv_lib.( ! ) rangeLimit_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - rangeLimit_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( dynamicRegistration_value - , foldingRange_value - , foldingRangeKind_value - , lineFoldingOnly_value - , rangeLimit_value ) - = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) foldingRange_field - , Ppx_yojson_conv_lib.( ! ) foldingRangeKind_field - , Ppx_yojson_conv_lib.( ! ) lineFoldingOnly_field - , Ppx_yojson_conv_lib.( ! ) rangeLimit_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; foldingRange = - (match foldingRange_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; foldingRangeKind = - (match foldingRangeKind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; lineFoldingOnly = - (match lineFoldingOnly_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; rangeLimit = - (match rangeLimit_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration - ; foldingRange = v_foldingRange - ; foldingRangeKind = v_foldingRangeKind - ; lineFoldingOnly = v_lineFoldingOnly - ; rangeLimit = v_rangeLimit - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_rangeLimit - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_rangeLimit in - let bnd = "rangeLimit", arg in - bnd :: bnds) - in - let bnds = - if None = v_lineFoldingOnly - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_lineFoldingOnly - in - let bnd = "lineFoldingOnly", arg in - bnd :: bnds) - in - let bnds = - if None = v_foldingRangeKind - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_foldingRangeKind) - v_foldingRangeKind - in - let bnd = "foldingRangeKind", arg in - bnd :: bnds) - in - let bnds = - if None = v_foldingRange - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_foldingRange) v_foldingRange - in - let bnd = "foldingRange", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(dynamicRegistration : bool option) - ?(foldingRange : foldingRange option) - ?(foldingRangeKind : foldingRangeKind option) - ?(lineFoldingOnly : bool option) - ?(rangeLimit : int option) - (() : unit) + ?(dynamicRegistration : bool option) + ?(foldingRange : foldingRange option) + ?(foldingRangeKind : foldingRangeKind option) + ?(lineFoldingOnly : bool option) + ?(rangeLimit : int option) + (() : unit) : t = { dynamicRegistration; foldingRange; foldingRangeKind; lineFoldingOnly; rangeLimit } @@ -11574,166 +2598,15 @@ end module DocumentSymbolClientCapabilities = struct type tagSupport = { valueSet : SymbolTag.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : tagSupport) -> () - - let tagSupport_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentSymbolClientCapabilities.tagSupport" in - function - | `Assoc field_yojsons as yojson -> - let valueSet_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "valueSet" -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson SymbolTag.t_of_yojson _field_yojson in - valueSet_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.Some valueSet_value -> - { valueSet = valueSet_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) valueSet_field) - Ppx_yojson_conv_lib.Option.None - , "valueSet" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> tagSupport) - ;; - - let _ = tagSupport_of_yojson - - let yojson_of_tagSupport = - (function - | { valueSet = v_valueSet } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list SymbolTag.yojson_of_t v_valueSet in - ("valueSet", arg) :: bnds - in - `Assoc bnds - : tagSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_tagSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_tagSupport ~(valueSet : SymbolTag.t list) : tagSupport = { valueSet } type symbolKind = { valueSet : SymbolKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : symbolKind) -> () - - let symbolKind_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentSymbolClientCapabilities.symbolKind" in - function - | `Assoc field_yojsons as yojson -> - let valueSet_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "valueSet" -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson SymbolKind.t_of_yojson) - _field_yojson - in - valueSet_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let valueSet_value = Ppx_yojson_conv_lib.( ! ) valueSet_field in - { valueSet = - (match valueSet_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> symbolKind) - ;; - - let _ = symbolKind_of_yojson - - let yojson_of_symbolKind = - (function - | { valueSet = v_valueSet } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_valueSet - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list SymbolKind.yojson_of_t)) - v_valueSet - in - let bnd = "valueSet", arg in - bnd :: bnds) - in - `Assoc bnds - : symbolKind -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_symbolKind - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_symbolKind ?(valueSet : SymbolKind.t list option) (() : unit) : symbolKind = { valueSet } @@ -11741,214 +2614,25 @@ module DocumentSymbolClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; hierarchicalDocumentSymbolSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; labelSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; symbolKind : symbolKind Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; tagSupport : tagSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentSymbolClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and hierarchicalDocumentSymbolSupport_field = ref Ppx_yojson_conv_lib.Option.None - and labelSupport_field = ref Ppx_yojson_conv_lib.Option.None - and symbolKind_field = ref Ppx_yojson_conv_lib.Option.None - and tagSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "hierarchicalDocumentSymbolSupport" -> - (match - Ppx_yojson_conv_lib.( ! ) hierarchicalDocumentSymbolSupport_field - with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - hierarchicalDocumentSymbolSupport_field - := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "labelSupport" -> - (match Ppx_yojson_conv_lib.( ! ) labelSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - labelSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "symbolKind" -> - (match Ppx_yojson_conv_lib.( ! ) symbolKind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson symbolKind_of_yojson _field_yojson - in - symbolKind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tagSupport" -> - (match Ppx_yojson_conv_lib.( ! ) tagSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson tagSupport_of_yojson _field_yojson - in - tagSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( dynamicRegistration_value - , hierarchicalDocumentSymbolSupport_value - , labelSupport_value - , symbolKind_value - , tagSupport_value ) - = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) hierarchicalDocumentSymbolSupport_field - , Ppx_yojson_conv_lib.( ! ) labelSupport_field - , Ppx_yojson_conv_lib.( ! ) symbolKind_field - , Ppx_yojson_conv_lib.( ! ) tagSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; hierarchicalDocumentSymbolSupport = - (match hierarchicalDocumentSymbolSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; labelSupport = - (match labelSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; symbolKind = - (match symbolKind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tagSupport = - (match tagSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration - ; hierarchicalDocumentSymbolSupport = v_hierarchicalDocumentSymbolSupport - ; labelSupport = v_labelSupport - ; symbolKind = v_symbolKind - ; tagSupport = v_tagSupport - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_tagSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_tagSupport) v_tagSupport - in - let bnd = "tagSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_symbolKind - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_symbolKind) v_symbolKind - in - let bnd = "symbolKind", arg in - bnd :: bnds) - in - let bnds = - if None = v_labelSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_labelSupport in - let bnd = "labelSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_hierarchicalDocumentSymbolSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) - v_hierarchicalDocumentSymbolSupport - in - let bnd = "hierarchicalDocumentSymbolSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(dynamicRegistration : bool option) - ?(hierarchicalDocumentSymbolSupport : bool option) - ?(labelSupport : bool option) - ?(symbolKind : symbolKind option) - ?(tagSupport : tagSupport option) - (() : unit) + ?(dynamicRegistration : bool option) + ?(hierarchicalDocumentSymbolSupport : bool option) + ?(labelSupport : bool option) + ?(symbolKind : symbolKind option) + ?(tagSupport : tagSupport option) + (() : unit) : t = { dynamicRegistration @@ -11963,117 +2647,16 @@ end module DocumentLinkClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; tooltipSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentLinkClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and tooltipSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tooltipSupport" -> - (match Ppx_yojson_conv_lib.( ! ) tooltipSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - tooltipSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value, tooltipSupport_value = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) tooltipSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tooltipSupport = - (match tooltipSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration; tooltipSupport = v_tooltipSupport } - -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_tooltipSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_tooltipSupport in - let bnd = "tooltipSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(dynamicRegistration : bool option) - ?(tooltipSupport : bool option) - (() : unit) + ?(dynamicRegistration : bool option) + ?(tooltipSupport : bool option) + (() : unit) : t = { dynamicRegistration; tooltipSupport } @@ -12083,86 +2666,9 @@ end module DocumentHighlightClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentHighlightClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -12172,152 +2678,19 @@ end module DiagnosticClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; markupMessageSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; relatedDocumentSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DiagnosticClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and markupMessageSupport_field = ref Ppx_yojson_conv_lib.Option.None - and relatedDocumentSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "markupMessageSupport" -> - (match Ppx_yojson_conv_lib.( ! ) markupMessageSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - markupMessageSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "relatedDocumentSupport" -> - (match Ppx_yojson_conv_lib.( ! ) relatedDocumentSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - relatedDocumentSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( dynamicRegistration_value - , markupMessageSupport_value - , relatedDocumentSupport_value ) - = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) markupMessageSupport_field - , Ppx_yojson_conv_lib.( ! ) relatedDocumentSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; markupMessageSupport = - (match markupMessageSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; relatedDocumentSupport = - (match relatedDocumentSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration - ; markupMessageSupport = v_markupMessageSupport - ; relatedDocumentSupport = v_relatedDocumentSupport - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_relatedDocumentSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_relatedDocumentSupport - in - let bnd = "relatedDocumentSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_markupMessageSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_markupMessageSupport - in - let bnd = "markupMessageSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(dynamicRegistration : bool option) - ?(markupMessageSupport : bool option) - ?(relatedDocumentSupport : bool option) - (() : unit) + ?(dynamicRegistration : bool option) + ?(markupMessageSupport : bool option) + ?(relatedDocumentSupport : bool option) + (() : unit) : t = { dynamicRegistration; markupMessageSupport; relatedDocumentSupport } @@ -12327,111 +2700,11 @@ end module DefinitionClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; linkSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DefinitionClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and linkSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "linkSupport" -> - (match Ppx_yojson_conv_lib.( ! ) linkSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - linkSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value, linkSupport_value = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) linkSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; linkSupport = - (match linkSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration; linkSupport = v_linkSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_linkSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_linkSupport in - let bnd = "linkSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) ?(linkSupport : bool option) (() : unit) : t @@ -12443,111 +2716,11 @@ end module DeclarationClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; linkSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DeclarationClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and linkSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "linkSupport" -> - (match Ppx_yojson_conv_lib.( ! ) linkSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - linkSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value, linkSupport_value = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) linkSupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; linkSupport = - (match linkSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration; linkSupport = v_linkSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_linkSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_linkSupport in - let bnd = "linkSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) ?(linkSupport : bool option) (() : unit) : t @@ -12559,87 +2732,9 @@ end module CompletionClientCapabilities = struct type completionList = { itemDefaults : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : completionList) -> () - - let completionList_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionClientCapabilities.completionList" in - function - | `Assoc field_yojsons as yojson -> - let itemDefaults_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "itemDefaults" -> - (match Ppx_yojson_conv_lib.( ! ) itemDefaults_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - itemDefaults_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let itemDefaults_value = Ppx_yojson_conv_lib.( ! ) itemDefaults_field in - { itemDefaults = - (match itemDefaults_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> completionList) - ;; - - let _ = completionList_of_yojson - - let yojson_of_completionList = - (function - | { itemDefaults = v_itemDefaults } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_itemDefaults - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_itemDefaults - in - let bnd = "itemDefaults", arg in - bnd :: bnds) - in - `Assoc bnds - : completionList -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_completionList - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_completionList ?(itemDefaults : string list option) (() : unit) : completionList @@ -12649,88 +2744,9 @@ module CompletionClientCapabilities = struct type completionItemKind = { valueSet : CompletionItemKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : completionItemKind) -> () - - let completionItemKind_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionClientCapabilities.completionItemKind" in - function - | `Assoc field_yojsons as yojson -> - let valueSet_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "valueSet" -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson CompletionItemKind.t_of_yojson) - _field_yojson - in - valueSet_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let valueSet_value = Ppx_yojson_conv_lib.( ! ) valueSet_field in - { valueSet = - (match valueSet_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> completionItemKind) - ;; - - let _ = completionItemKind_of_yojson - - let yojson_of_completionItemKind = - (function - | { valueSet = v_valueSet } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_valueSet - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list CompletionItemKind.yojson_of_t)) - v_valueSet - in - let bnd = "valueSet", arg in - bnd :: bnds) - in - `Assoc bnds - : completionItemKind -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_completionItemKind - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_completionItemKind ?(valueSet : CompletionItemKind.t list option) (() : unit) : completionItemKind @@ -12739,82 +2755,7 @@ module CompletionClientCapabilities = struct ;; type insertTextModeSupport = { valueSet : InsertTextMode.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : insertTextModeSupport) -> () - - let insertTextModeSupport_of_yojson = - (let _tp_loc = - "lsp/src/types.ml.CompletionClientCapabilities.insertTextModeSupport" - in - function - | `Assoc field_yojsons as yojson -> - let valueSet_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "valueSet" -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson InsertTextMode.t_of_yojson _field_yojson in - valueSet_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.Some valueSet_value -> - { valueSet = valueSet_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) valueSet_field) - Ppx_yojson_conv_lib.Option.None - , "valueSet" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> insertTextModeSupport) - ;; - - let _ = insertTextModeSupport_of_yojson - - let yojson_of_insertTextModeSupport = - (function - | { valueSet = v_valueSet } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list InsertTextMode.yojson_of_t v_valueSet in - ("valueSet", arg) :: bnds - in - `Assoc bnds - : insertTextModeSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_insertTextModeSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_insertTextModeSupport ~(valueSet : InsertTextMode.t list) : insertTextModeSupport @@ -12823,525 +2764,51 @@ module CompletionClientCapabilities = struct ;; type resolveSupport = { properties : string list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : resolveSupport) -> () - - let resolveSupport_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionClientCapabilities.resolveSupport" in - function - | `Assoc field_yojsons as yojson -> - let properties_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "properties" -> - (match Ppx_yojson_conv_lib.( ! ) properties_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - properties_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) properties_field with - | Ppx_yojson_conv_lib.Option.Some properties_value -> - { properties = properties_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) properties_field) - Ppx_yojson_conv_lib.Option.None - , "properties" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> resolveSupport) - ;; - - let _ = resolveSupport_of_yojson - - let yojson_of_resolveSupport = - (function - | { properties = v_properties } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list yojson_of_string v_properties in - ("properties", arg) :: bnds - in - `Assoc bnds - : resolveSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_resolveSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_resolveSupport ~(properties : string list) : resolveSupport = { properties } type tagSupport = { valueSet : CompletionItemTag.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : tagSupport) -> () - - let tagSupport_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionClientCapabilities.tagSupport" in - function - | `Assoc field_yojsons as yojson -> - let valueSet_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "valueSet" -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson CompletionItemTag.t_of_yojson _field_yojson - in - valueSet_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.Some valueSet_value -> - { valueSet = valueSet_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) valueSet_field) - Ppx_yojson_conv_lib.Option.None - , "valueSet" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> tagSupport) - ;; - - let _ = tagSupport_of_yojson - - let yojson_of_tagSupport = - (function - | { valueSet = v_valueSet } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list CompletionItemTag.yojson_of_t v_valueSet in - ("valueSet", arg) :: bnds - in - `Assoc bnds - : tagSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_tagSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_tagSupport ~(valueSet : CompletionItemTag.t list) : tagSupport = { valueSet } type completionItem = { snippetSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; commitCharactersSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentationFormat : MarkupKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; deprecatedSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; preselectSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; tagSupport : tagSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; insertReplaceSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resolveSupport : resolveSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; insertTextModeSupport : insertTextModeSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; labelDetailsSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : completionItem) -> () - - let completionItem_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionClientCapabilities.completionItem" in - function - | `Assoc field_yojsons as yojson -> - let snippetSupport_field = ref Ppx_yojson_conv_lib.Option.None - and commitCharactersSupport_field = ref Ppx_yojson_conv_lib.Option.None - and documentationFormat_field = ref Ppx_yojson_conv_lib.Option.None - and deprecatedSupport_field = ref Ppx_yojson_conv_lib.Option.None - and preselectSupport_field = ref Ppx_yojson_conv_lib.Option.None - and tagSupport_field = ref Ppx_yojson_conv_lib.Option.None - and insertReplaceSupport_field = ref Ppx_yojson_conv_lib.Option.None - and resolveSupport_field = ref Ppx_yojson_conv_lib.Option.None - and insertTextModeSupport_field = ref Ppx_yojson_conv_lib.Option.None - and labelDetailsSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "snippetSupport" -> - (match Ppx_yojson_conv_lib.( ! ) snippetSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - snippetSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "commitCharactersSupport" -> - (match Ppx_yojson_conv_lib.( ! ) commitCharactersSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - commitCharactersSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentationFormat" -> - (match Ppx_yojson_conv_lib.( ! ) documentationFormat_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson MarkupKind.t_of_yojson) - _field_yojson - in - documentationFormat_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "deprecatedSupport" -> - (match Ppx_yojson_conv_lib.( ! ) deprecatedSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - deprecatedSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "preselectSupport" -> - (match Ppx_yojson_conv_lib.( ! ) preselectSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - preselectSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tagSupport" -> - (match Ppx_yojson_conv_lib.( ! ) tagSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson tagSupport_of_yojson _field_yojson - in - tagSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "insertReplaceSupport" -> - (match Ppx_yojson_conv_lib.( ! ) insertReplaceSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - insertReplaceSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveSupport" -> - (match Ppx_yojson_conv_lib.( ! ) resolveSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson resolveSupport_of_yojson _field_yojson - in - resolveSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "insertTextModeSupport" -> - (match Ppx_yojson_conv_lib.( ! ) insertTextModeSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - insertTextModeSupport_of_yojson - _field_yojson - in - insertTextModeSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "labelDetailsSupport" -> - (match Ppx_yojson_conv_lib.( ! ) labelDetailsSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - labelDetailsSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( snippetSupport_value - , commitCharactersSupport_value - , documentationFormat_value - , deprecatedSupport_value - , preselectSupport_value - , tagSupport_value - , insertReplaceSupport_value - , resolveSupport_value - , insertTextModeSupport_value - , labelDetailsSupport_value ) - = - ( Ppx_yojson_conv_lib.( ! ) snippetSupport_field - , Ppx_yojson_conv_lib.( ! ) commitCharactersSupport_field - , Ppx_yojson_conv_lib.( ! ) documentationFormat_field - , Ppx_yojson_conv_lib.( ! ) deprecatedSupport_field - , Ppx_yojson_conv_lib.( ! ) preselectSupport_field - , Ppx_yojson_conv_lib.( ! ) tagSupport_field - , Ppx_yojson_conv_lib.( ! ) insertReplaceSupport_field - , Ppx_yojson_conv_lib.( ! ) resolveSupport_field - , Ppx_yojson_conv_lib.( ! ) insertTextModeSupport_field - , Ppx_yojson_conv_lib.( ! ) labelDetailsSupport_field ) - in - { snippetSupport = - (match snippetSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; commitCharactersSupport = - (match commitCharactersSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentationFormat = - (match documentationFormat_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; deprecatedSupport = - (match deprecatedSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; preselectSupport = - (match preselectSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tagSupport = - (match tagSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; insertReplaceSupport = - (match insertReplaceSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveSupport = - (match resolveSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; insertTextModeSupport = - (match insertTextModeSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; labelDetailsSupport = - (match labelDetailsSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> completionItem) - ;; - - let _ = completionItem_of_yojson - - let yojson_of_completionItem = - (function - | { snippetSupport = v_snippetSupport - ; commitCharactersSupport = v_commitCharactersSupport - ; documentationFormat = v_documentationFormat - ; deprecatedSupport = v_deprecatedSupport - ; preselectSupport = v_preselectSupport - ; tagSupport = v_tagSupport - ; insertReplaceSupport = v_insertReplaceSupport - ; resolveSupport = v_resolveSupport - ; insertTextModeSupport = v_insertTextModeSupport - ; labelDetailsSupport = v_labelDetailsSupport - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_labelDetailsSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_labelDetailsSupport - in - let bnd = "labelDetailsSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_insertTextModeSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_insertTextModeSupport) - v_insertTextModeSupport - in - let bnd = "insertTextModeSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_resolveSupport) v_resolveSupport - in - let bnd = "resolveSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_insertReplaceSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_insertReplaceSupport - in - let bnd = "insertReplaceSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_tagSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_tagSupport) v_tagSupport - in - let bnd = "tagSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_preselectSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_preselectSupport - in - let bnd = "preselectSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_deprecatedSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_deprecatedSupport - in - let bnd = "deprecatedSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentationFormat - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list MarkupKind.yojson_of_t)) - v_documentationFormat - in - let bnd = "documentationFormat", arg in - bnd :: bnds) - in - let bnds = - if None = v_commitCharactersSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_commitCharactersSupport - in - let bnd = "commitCharactersSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_snippetSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_snippetSupport in - let bnd = "snippetSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : completionItem -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_completionItem - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_completionItem - ?(snippetSupport : bool option) - ?(commitCharactersSupport : bool option) - ?(documentationFormat : MarkupKind.t list option) - ?(deprecatedSupport : bool option) - ?(preselectSupport : bool option) - ?(tagSupport : tagSupport option) - ?(insertReplaceSupport : bool option) - ?(resolveSupport : resolveSupport option) - ?(insertTextModeSupport : insertTextModeSupport option) - ?(labelDetailsSupport : bool option) - (() : unit) + ?(snippetSupport : bool option) + ?(commitCharactersSupport : bool option) + ?(documentationFormat : MarkupKind.t list option) + ?(deprecatedSupport : bool option) + ?(preselectSupport : bool option) + ?(tagSupport : tagSupport option) + ?(insertReplaceSupport : bool option) + ?(resolveSupport : resolveSupport option) + ?(insertTextModeSupport : insertTextModeSupport option) + ?(labelDetailsSupport : bool option) + (() : unit) : completionItem = { snippetSupport @@ -13359,246 +2826,28 @@ module CompletionClientCapabilities = struct type t = { completionItem : completionItem Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; completionItemKind : completionItemKind Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; completionList : completionList Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; contextSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; insertTextMode : InsertTextMode.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let completionItem_field = ref Ppx_yojson_conv_lib.Option.None - and completionItemKind_field = ref Ppx_yojson_conv_lib.Option.None - and completionList_field = ref Ppx_yojson_conv_lib.Option.None - and contextSupport_field = ref Ppx_yojson_conv_lib.Option.None - and dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and insertTextMode_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "completionItem" -> - (match Ppx_yojson_conv_lib.( ! ) completionItem_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson completionItem_of_yojson _field_yojson - in - completionItem_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "completionItemKind" -> - (match Ppx_yojson_conv_lib.( ! ) completionItemKind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - completionItemKind_of_yojson - _field_yojson - in - completionItemKind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "completionList" -> - (match Ppx_yojson_conv_lib.( ! ) completionList_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson completionList_of_yojson _field_yojson - in - completionList_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "contextSupport" -> - (match Ppx_yojson_conv_lib.( ! ) contextSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - contextSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "insertTextMode" -> - (match Ppx_yojson_conv_lib.( ! ) insertTextMode_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InsertTextMode.t_of_yojson - _field_yojson - in - insertTextMode_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( completionItem_value - , completionItemKind_value - , completionList_value - , contextSupport_value - , dynamicRegistration_value - , insertTextMode_value ) - = - ( Ppx_yojson_conv_lib.( ! ) completionItem_field - , Ppx_yojson_conv_lib.( ! ) completionItemKind_field - , Ppx_yojson_conv_lib.( ! ) completionList_field - , Ppx_yojson_conv_lib.( ! ) contextSupport_field - , Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) insertTextMode_field ) - in - { completionItem = - (match completionItem_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; completionItemKind = - (match completionItemKind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; completionList = - (match completionList_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; contextSupport = - (match contextSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; insertTextMode = - (match insertTextMode_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { completionItem = v_completionItem - ; completionItemKind = v_completionItemKind - ; completionList = v_completionList - ; contextSupport = v_contextSupport - ; dynamicRegistration = v_dynamicRegistration - ; insertTextMode = v_insertTextMode - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_insertTextMode - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t InsertTextMode.yojson_of_t) - v_insertTextMode - in - let bnd = "insertTextMode", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - let bnds = - if None = v_contextSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_contextSupport in - let bnd = "contextSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_completionList - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_completionList) v_completionList - in - let bnd = "completionList", arg in - bnd :: bnds) - in - let bnds = - if None = v_completionItemKind - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_completionItemKind) - v_completionItemKind - in - let bnd = "completionItemKind", arg in - bnd :: bnds) - in - let bnds = - if None = v_completionItem - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_completionItem) v_completionItem - in - let bnd = "completionItem", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(completionItem : completionItem option) - ?(completionItemKind : completionItemKind option) - ?(completionList : completionList option) - ?(contextSupport : bool option) - ?(dynamicRegistration : bool option) - ?(insertTextMode : InsertTextMode.t option) - (() : unit) + ?(completionItem : completionItem option) + ?(completionItemKind : completionItemKind option) + ?(completionList : completionList option) + ?(contextSupport : bool option) + ?(dynamicRegistration : bool option) + ?(insertTextMode : InsertTextMode.t option) + (() : unit) : t = { completionItem @@ -13614,86 +2863,9 @@ end module DocumentColorClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentColorClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -13703,86 +2875,9 @@ end module CodeLensClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeLensClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value = - Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(dynamicRegistration : bool option) (() : unit) : t = { dynamicRegistration } @@ -13791,240 +2886,19 @@ end module CodeActionClientCapabilities = struct type resolveSupport = { properties : string list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : resolveSupport) -> () - - let resolveSupport_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeActionClientCapabilities.resolveSupport" in - function - | `Assoc field_yojsons as yojson -> - let properties_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "properties" -> - (match Ppx_yojson_conv_lib.( ! ) properties_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - properties_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) properties_field with - | Ppx_yojson_conv_lib.Option.Some properties_value -> - { properties = properties_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) properties_field) - Ppx_yojson_conv_lib.Option.None - , "properties" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> resolveSupport) - ;; - - let _ = resolveSupport_of_yojson - - let yojson_of_resolveSupport = - (function - | { properties = v_properties } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list yojson_of_string v_properties in - ("properties", arg) :: bnds - in - `Assoc bnds - : resolveSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_resolveSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_resolveSupport ~(properties : string list) : resolveSupport = { properties } type codeActionKind = { valueSet : CodeActionKind.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : codeActionKind) -> () - - let codeActionKind_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeActionClientCapabilities.codeActionKind" in - function - | `Assoc field_yojsons as yojson -> - let valueSet_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "valueSet" -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson CodeActionKind.t_of_yojson _field_yojson in - valueSet_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) valueSet_field with - | Ppx_yojson_conv_lib.Option.Some valueSet_value -> - { valueSet = valueSet_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) valueSet_field) - Ppx_yojson_conv_lib.Option.None - , "valueSet" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> codeActionKind) - ;; - - let _ = codeActionKind_of_yojson - - let yojson_of_codeActionKind = - (function - | { valueSet = v_valueSet } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list CodeActionKind.yojson_of_t v_valueSet in - ("valueSet", arg) :: bnds - in - `Assoc bnds - : codeActionKind -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_codeActionKind - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_codeActionKind ~(valueSet : CodeActionKind.t list) : codeActionKind = { valueSet } ;; type codeActionLiteralSupport = { codeActionKind : codeActionKind } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : codeActionLiteralSupport) -> () - - let codeActionLiteralSupport_of_yojson = - (let _tp_loc = - "lsp/src/types.ml.CodeActionClientCapabilities.codeActionLiteralSupport" - in - function - | `Assoc field_yojsons as yojson -> - let codeActionKind_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "codeActionKind" -> - (match Ppx_yojson_conv_lib.( ! ) codeActionKind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = codeActionKind_of_yojson _field_yojson in - codeActionKind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) codeActionKind_field with - | Ppx_yojson_conv_lib.Option.Some codeActionKind_value -> - { codeActionKind = codeActionKind_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) codeActionKind_field) - Ppx_yojson_conv_lib.Option.None - , "codeActionKind" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> codeActionLiteralSupport) - ;; - - let _ = codeActionLiteralSupport_of_yojson - - let yojson_of_codeActionLiteralSupport = - (function - | { codeActionKind = v_codeActionKind } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_codeActionKind v_codeActionKind in - ("codeActionKind", arg) :: bnds - in - `Assoc bnds - : codeActionLiteralSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_codeActionLiteralSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_codeActionLiteralSupport ~(codeActionKind : codeActionKind) : codeActionLiteralSupport @@ -14034,273 +2908,31 @@ module CodeActionClientCapabilities = struct type t = { codeActionLiteralSupport : codeActionLiteralSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; dataSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; disabledSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; honorsChangeAnnotations : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; isPreferredSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resolveSupport : resolveSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeActionClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let codeActionLiteralSupport_field = ref Ppx_yojson_conv_lib.Option.None - and dataSupport_field = ref Ppx_yojson_conv_lib.Option.None - and disabledSupport_field = ref Ppx_yojson_conv_lib.Option.None - and dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and honorsChangeAnnotations_field = ref Ppx_yojson_conv_lib.Option.None - and isPreferredSupport_field = ref Ppx_yojson_conv_lib.Option.None - and resolveSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "codeActionLiteralSupport" -> - (match Ppx_yojson_conv_lib.( ! ) codeActionLiteralSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - codeActionLiteralSupport_of_yojson - _field_yojson - in - codeActionLiteralSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "dataSupport" -> - (match Ppx_yojson_conv_lib.( ! ) dataSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dataSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "disabledSupport" -> - (match Ppx_yojson_conv_lib.( ! ) disabledSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - disabledSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "honorsChangeAnnotations" -> - (match Ppx_yojson_conv_lib.( ! ) honorsChangeAnnotations_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - honorsChangeAnnotations_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "isPreferredSupport" -> - (match Ppx_yojson_conv_lib.( ! ) isPreferredSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - isPreferredSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveSupport" -> - (match Ppx_yojson_conv_lib.( ! ) resolveSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson resolveSupport_of_yojson _field_yojson - in - resolveSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( codeActionLiteralSupport_value - , dataSupport_value - , disabledSupport_value - , dynamicRegistration_value - , honorsChangeAnnotations_value - , isPreferredSupport_value - , resolveSupport_value ) - = - ( Ppx_yojson_conv_lib.( ! ) codeActionLiteralSupport_field - , Ppx_yojson_conv_lib.( ! ) dataSupport_field - , Ppx_yojson_conv_lib.( ! ) disabledSupport_field - , Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) honorsChangeAnnotations_field - , Ppx_yojson_conv_lib.( ! ) isPreferredSupport_field - , Ppx_yojson_conv_lib.( ! ) resolveSupport_field ) - in - { codeActionLiteralSupport = - (match codeActionLiteralSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; dataSupport = - (match dataSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; disabledSupport = - (match disabledSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; honorsChangeAnnotations = - (match honorsChangeAnnotations_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; isPreferredSupport = - (match isPreferredSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveSupport = - (match resolveSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { codeActionLiteralSupport = v_codeActionLiteralSupport - ; dataSupport = v_dataSupport - ; disabledSupport = v_disabledSupport - ; dynamicRegistration = v_dynamicRegistration - ; honorsChangeAnnotations = v_honorsChangeAnnotations - ; isPreferredSupport = v_isPreferredSupport - ; resolveSupport = v_resolveSupport - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_resolveSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_resolveSupport) v_resolveSupport - in - let bnd = "resolveSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_isPreferredSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_isPreferredSupport - in - let bnd = "isPreferredSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_honorsChangeAnnotations - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_honorsChangeAnnotations - in - let bnd = "honorsChangeAnnotations", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - let bnds = - if None = v_disabledSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_disabledSupport - in - let bnd = "disabledSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dataSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dataSupport in - let bnd = "dataSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_codeActionLiteralSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_codeActionLiteralSupport) - v_codeActionLiteralSupport - in - let bnd = "codeActionLiteralSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(codeActionLiteralSupport : codeActionLiteralSupport option) - ?(dataSupport : bool option) - ?(disabledSupport : bool option) - ?(dynamicRegistration : bool option) - ?(honorsChangeAnnotations : bool option) - ?(isPreferredSupport : bool option) - ?(resolveSupport : resolveSupport option) - (() : unit) + ?(codeActionLiteralSupport : codeActionLiteralSupport option) + ?(dataSupport : bool option) + ?(disabledSupport : bool option) + ?(dynamicRegistration : bool option) + ?(honorsChangeAnnotations : bool option) + ?(isPreferredSupport : bool option) + ?(resolveSupport : resolveSupport option) + (() : unit) : t = { codeActionLiteralSupport @@ -14317,1103 +2949,104 @@ end module TextDocumentClientCapabilities = struct type t = { callHierarchy : CallHierarchyClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; codeAction : CodeActionClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; codeLens : CodeLensClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; colorProvider : DocumentColorClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; completion : CompletionClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; declaration : DeclarationClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; definition : DefinitionClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; diagnostic : DiagnosticClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentHighlight : DocumentHighlightClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentLink : DocumentLinkClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentSymbol : DocumentSymbolClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; foldingRange : FoldingRangeClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; formatting : DocumentFormattingClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; hover : HoverClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; implementation : ImplementationClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; inlayHint : InlayHintClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; inlineCompletion : InlineCompletionClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; inlineValue : InlineValueClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; linkedEditingRange : LinkedEditingRangeClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; moniker : MonikerClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; onTypeFormatting : DocumentOnTypeFormattingClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; publishDiagnostics : PublishDiagnosticsClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; rangeFormatting : DocumentRangeFormattingClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; references : ReferenceClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; rename : RenameClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; selectionRange : SelectionRangeClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; semanticTokens : SemanticTokensClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; signatureHelp : SignatureHelpClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; synchronization : TextDocumentSyncClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; typeDefinition : TypeDefinitionClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; typeHierarchy : TypeHierarchyClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let callHierarchy_field = ref Ppx_yojson_conv_lib.Option.None - and codeAction_field = ref Ppx_yojson_conv_lib.Option.None - and codeLens_field = ref Ppx_yojson_conv_lib.Option.None - and colorProvider_field = ref Ppx_yojson_conv_lib.Option.None - and completion_field = ref Ppx_yojson_conv_lib.Option.None - and declaration_field = ref Ppx_yojson_conv_lib.Option.None - and definition_field = ref Ppx_yojson_conv_lib.Option.None - and diagnostic_field = ref Ppx_yojson_conv_lib.Option.None - and documentHighlight_field = ref Ppx_yojson_conv_lib.Option.None - and documentLink_field = ref Ppx_yojson_conv_lib.Option.None - and documentSymbol_field = ref Ppx_yojson_conv_lib.Option.None - and foldingRange_field = ref Ppx_yojson_conv_lib.Option.None - and formatting_field = ref Ppx_yojson_conv_lib.Option.None - and hover_field = ref Ppx_yojson_conv_lib.Option.None - and implementation_field = ref Ppx_yojson_conv_lib.Option.None - and inlayHint_field = ref Ppx_yojson_conv_lib.Option.None - and inlineCompletion_field = ref Ppx_yojson_conv_lib.Option.None - and inlineValue_field = ref Ppx_yojson_conv_lib.Option.None - and linkedEditingRange_field = ref Ppx_yojson_conv_lib.Option.None - and moniker_field = ref Ppx_yojson_conv_lib.Option.None - and onTypeFormatting_field = ref Ppx_yojson_conv_lib.Option.None - and publishDiagnostics_field = ref Ppx_yojson_conv_lib.Option.None - and rangeFormatting_field = ref Ppx_yojson_conv_lib.Option.None - and references_field = ref Ppx_yojson_conv_lib.Option.None - and rename_field = ref Ppx_yojson_conv_lib.Option.None - and selectionRange_field = ref Ppx_yojson_conv_lib.Option.None - and semanticTokens_field = ref Ppx_yojson_conv_lib.Option.None - and signatureHelp_field = ref Ppx_yojson_conv_lib.Option.None - and synchronization_field = ref Ppx_yojson_conv_lib.Option.None - and typeDefinition_field = ref Ppx_yojson_conv_lib.Option.None - and typeHierarchy_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "callHierarchy" -> - (match Ppx_yojson_conv_lib.( ! ) callHierarchy_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CallHierarchyClientCapabilities.t_of_yojson - _field_yojson - in - callHierarchy_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "codeAction" -> - (match Ppx_yojson_conv_lib.( ! ) codeAction_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CodeActionClientCapabilities.t_of_yojson - _field_yojson - in - codeAction_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "codeLens" -> - (match Ppx_yojson_conv_lib.( ! ) codeLens_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CodeLensClientCapabilities.t_of_yojson - _field_yojson - in - codeLens_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "colorProvider" -> - (match Ppx_yojson_conv_lib.( ! ) colorProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentColorClientCapabilities.t_of_yojson - _field_yojson - in - colorProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "completion" -> - (match Ppx_yojson_conv_lib.( ! ) completion_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CompletionClientCapabilities.t_of_yojson - _field_yojson - in - completion_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "declaration" -> - (match Ppx_yojson_conv_lib.( ! ) declaration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DeclarationClientCapabilities.t_of_yojson - _field_yojson - in - declaration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "definition" -> - (match Ppx_yojson_conv_lib.( ! ) definition_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DefinitionClientCapabilities.t_of_yojson - _field_yojson - in - definition_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "diagnostic" -> - (match Ppx_yojson_conv_lib.( ! ) diagnostic_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DiagnosticClientCapabilities.t_of_yojson - _field_yojson - in - diagnostic_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentHighlight" -> - (match Ppx_yojson_conv_lib.( ! ) documentHighlight_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentHighlightClientCapabilities.t_of_yojson - _field_yojson - in - documentHighlight_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentLink" -> - (match Ppx_yojson_conv_lib.( ! ) documentLink_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentLinkClientCapabilities.t_of_yojson - _field_yojson - in - documentLink_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentSymbol" -> - (match Ppx_yojson_conv_lib.( ! ) documentSymbol_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSymbolClientCapabilities.t_of_yojson - _field_yojson - in - documentSymbol_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "foldingRange" -> - (match Ppx_yojson_conv_lib.( ! ) foldingRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FoldingRangeClientCapabilities.t_of_yojson - _field_yojson - in - foldingRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "formatting" -> - (match Ppx_yojson_conv_lib.( ! ) formatting_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentFormattingClientCapabilities.t_of_yojson - _field_yojson - in - formatting_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "hover" -> - (match Ppx_yojson_conv_lib.( ! ) hover_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - HoverClientCapabilities.t_of_yojson - _field_yojson - in - hover_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "implementation" -> - (match Ppx_yojson_conv_lib.( ! ) implementation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ImplementationClientCapabilities.t_of_yojson - _field_yojson - in - implementation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "inlayHint" -> - (match Ppx_yojson_conv_lib.( ! ) inlayHint_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InlayHintClientCapabilities.t_of_yojson - _field_yojson - in - inlayHint_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "inlineCompletion" -> - (match Ppx_yojson_conv_lib.( ! ) inlineCompletion_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InlineCompletionClientCapabilities.t_of_yojson - _field_yojson - in - inlineCompletion_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "inlineValue" -> - (match Ppx_yojson_conv_lib.( ! ) inlineValue_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InlineValueClientCapabilities.t_of_yojson - _field_yojson - in - inlineValue_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "linkedEditingRange" -> - (match Ppx_yojson_conv_lib.( ! ) linkedEditingRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - LinkedEditingRangeClientCapabilities.t_of_yojson - _field_yojson - in - linkedEditingRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "moniker" -> - (match Ppx_yojson_conv_lib.( ! ) moniker_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - MonikerClientCapabilities.t_of_yojson - _field_yojson - in - moniker_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "onTypeFormatting" -> - (match Ppx_yojson_conv_lib.( ! ) onTypeFormatting_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentOnTypeFormattingClientCapabilities.t_of_yojson - _field_yojson - in - onTypeFormatting_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "publishDiagnostics" -> - (match Ppx_yojson_conv_lib.( ! ) publishDiagnostics_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - PublishDiagnosticsClientCapabilities.t_of_yojson - _field_yojson - in - publishDiagnostics_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "rangeFormatting" -> - (match Ppx_yojson_conv_lib.( ! ) rangeFormatting_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentRangeFormattingClientCapabilities.t_of_yojson - _field_yojson - in - rangeFormatting_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "references" -> - (match Ppx_yojson_conv_lib.( ! ) references_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ReferenceClientCapabilities.t_of_yojson - _field_yojson - in - references_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "rename" -> - (match Ppx_yojson_conv_lib.( ! ) rename_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - RenameClientCapabilities.t_of_yojson - _field_yojson - in - rename_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "selectionRange" -> - (match Ppx_yojson_conv_lib.( ! ) selectionRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - SelectionRangeClientCapabilities.t_of_yojson - _field_yojson - in - selectionRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "semanticTokens" -> - (match Ppx_yojson_conv_lib.( ! ) semanticTokens_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - SemanticTokensClientCapabilities.t_of_yojson - _field_yojson - in - semanticTokens_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "signatureHelp" -> - (match Ppx_yojson_conv_lib.( ! ) signatureHelp_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - SignatureHelpClientCapabilities.t_of_yojson - _field_yojson - in - signatureHelp_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "synchronization" -> - (match Ppx_yojson_conv_lib.( ! ) synchronization_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - TextDocumentSyncClientCapabilities.t_of_yojson - _field_yojson - in - synchronization_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "typeDefinition" -> - (match Ppx_yojson_conv_lib.( ! ) typeDefinition_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - TypeDefinitionClientCapabilities.t_of_yojson - _field_yojson - in - typeDefinition_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "typeHierarchy" -> - (match Ppx_yojson_conv_lib.( ! ) typeHierarchy_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - TypeHierarchyClientCapabilities.t_of_yojson - _field_yojson - in - typeHierarchy_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( callHierarchy_value - , codeAction_value - , codeLens_value - , colorProvider_value - , completion_value - , declaration_value - , definition_value - , diagnostic_value - , documentHighlight_value - , documentLink_value - , documentSymbol_value - , foldingRange_value - , formatting_value - , hover_value - , implementation_value - , inlayHint_value - , inlineCompletion_value - , inlineValue_value - , linkedEditingRange_value - , moniker_value - , onTypeFormatting_value - , publishDiagnostics_value - , rangeFormatting_value - , references_value - , rename_value - , selectionRange_value - , semanticTokens_value - , signatureHelp_value - , synchronization_value - , typeDefinition_value - , typeHierarchy_value ) - = - ( Ppx_yojson_conv_lib.( ! ) callHierarchy_field - , Ppx_yojson_conv_lib.( ! ) codeAction_field - , Ppx_yojson_conv_lib.( ! ) codeLens_field - , Ppx_yojson_conv_lib.( ! ) colorProvider_field - , Ppx_yojson_conv_lib.( ! ) completion_field - , Ppx_yojson_conv_lib.( ! ) declaration_field - , Ppx_yojson_conv_lib.( ! ) definition_field - , Ppx_yojson_conv_lib.( ! ) diagnostic_field - , Ppx_yojson_conv_lib.( ! ) documentHighlight_field - , Ppx_yojson_conv_lib.( ! ) documentLink_field - , Ppx_yojson_conv_lib.( ! ) documentSymbol_field - , Ppx_yojson_conv_lib.( ! ) foldingRange_field - , Ppx_yojson_conv_lib.( ! ) formatting_field - , Ppx_yojson_conv_lib.( ! ) hover_field - , Ppx_yojson_conv_lib.( ! ) implementation_field - , Ppx_yojson_conv_lib.( ! ) inlayHint_field - , Ppx_yojson_conv_lib.( ! ) inlineCompletion_field - , Ppx_yojson_conv_lib.( ! ) inlineValue_field - , Ppx_yojson_conv_lib.( ! ) linkedEditingRange_field - , Ppx_yojson_conv_lib.( ! ) moniker_field - , Ppx_yojson_conv_lib.( ! ) onTypeFormatting_field - , Ppx_yojson_conv_lib.( ! ) publishDiagnostics_field - , Ppx_yojson_conv_lib.( ! ) rangeFormatting_field - , Ppx_yojson_conv_lib.( ! ) references_field - , Ppx_yojson_conv_lib.( ! ) rename_field - , Ppx_yojson_conv_lib.( ! ) selectionRange_field - , Ppx_yojson_conv_lib.( ! ) semanticTokens_field - , Ppx_yojson_conv_lib.( ! ) signatureHelp_field - , Ppx_yojson_conv_lib.( ! ) synchronization_field - , Ppx_yojson_conv_lib.( ! ) typeDefinition_field - , Ppx_yojson_conv_lib.( ! ) typeHierarchy_field ) - in - { callHierarchy = - (match callHierarchy_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; codeAction = - (match codeAction_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; codeLens = - (match codeLens_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; colorProvider = - (match colorProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; completion = - (match completion_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; declaration = - (match declaration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; definition = - (match definition_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; diagnostic = - (match diagnostic_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentHighlight = - (match documentHighlight_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentLink = - (match documentLink_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentSymbol = - (match documentSymbol_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; foldingRange = - (match foldingRange_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; formatting = - (match formatting_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; hover = - (match hover_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; implementation = - (match implementation_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; inlayHint = - (match inlayHint_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; inlineCompletion = - (match inlineCompletion_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; inlineValue = - (match inlineValue_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; linkedEditingRange = - (match linkedEditingRange_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; moniker = - (match moniker_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; onTypeFormatting = - (match onTypeFormatting_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; publishDiagnostics = - (match publishDiagnostics_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; rangeFormatting = - (match rangeFormatting_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; references = - (match references_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; rename = - (match rename_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; selectionRange = - (match selectionRange_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; semanticTokens = - (match semanticTokens_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; signatureHelp = - (match signatureHelp_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; synchronization = - (match synchronization_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; typeDefinition = - (match typeDefinition_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; typeHierarchy = - (match typeHierarchy_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { callHierarchy = v_callHierarchy - ; codeAction = v_codeAction - ; codeLens = v_codeLens - ; colorProvider = v_colorProvider - ; completion = v_completion - ; declaration = v_declaration - ; definition = v_definition - ; diagnostic = v_diagnostic - ; documentHighlight = v_documentHighlight - ; documentLink = v_documentLink - ; documentSymbol = v_documentSymbol - ; foldingRange = v_foldingRange - ; formatting = v_formatting - ; hover = v_hover - ; implementation = v_implementation - ; inlayHint = v_inlayHint - ; inlineCompletion = v_inlineCompletion - ; inlineValue = v_inlineValue - ; linkedEditingRange = v_linkedEditingRange - ; moniker = v_moniker - ; onTypeFormatting = v_onTypeFormatting - ; publishDiagnostics = v_publishDiagnostics - ; rangeFormatting = v_rangeFormatting - ; references = v_references - ; rename = v_rename - ; selectionRange = v_selectionRange - ; semanticTokens = v_semanticTokens - ; signatureHelp = v_signatureHelp - ; synchronization = v_synchronization - ; typeDefinition = v_typeDefinition - ; typeHierarchy = v_typeHierarchy - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_typeHierarchy - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - TypeHierarchyClientCapabilities.yojson_of_t) - v_typeHierarchy - in - let bnd = "typeHierarchy", arg in - bnd :: bnds) - in - let bnds = - if None = v_typeDefinition - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - TypeDefinitionClientCapabilities.yojson_of_t) - v_typeDefinition - in - let bnd = "typeDefinition", arg in - bnd :: bnds) - in - let bnds = - if None = v_synchronization - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - TextDocumentSyncClientCapabilities.yojson_of_t) - v_synchronization - in - let bnd = "synchronization", arg in - bnd :: bnds) - in - let bnds = - if None = v_signatureHelp - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - SignatureHelpClientCapabilities.yojson_of_t) - v_signatureHelp - in - let bnd = "signatureHelp", arg in - bnd :: bnds) - in - let bnds = - if None = v_semanticTokens - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - SemanticTokensClientCapabilities.yojson_of_t) - v_semanticTokens - in - let bnd = "semanticTokens", arg in - bnd :: bnds) - in - let bnds = - if None = v_selectionRange - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - SelectionRangeClientCapabilities.yojson_of_t) - v_selectionRange - in - let bnd = "selectionRange", arg in - bnd :: bnds) - in - let bnds = - if None = v_rename - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t RenameClientCapabilities.yojson_of_t) - v_rename - in - let bnd = "rename", arg in - bnd :: bnds) - in - let bnds = - if None = v_references - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ReferenceClientCapabilities.yojson_of_t) - v_references - in - let bnd = "references", arg in - bnd :: bnds) - in - let bnds = - if None = v_rangeFormatting - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - DocumentRangeFormattingClientCapabilities.yojson_of_t) - v_rangeFormatting - in - let bnd = "rangeFormatting", arg in - bnd :: bnds) - in - let bnds = - if None = v_publishDiagnostics - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - PublishDiagnosticsClientCapabilities.yojson_of_t) - v_publishDiagnostics - in - let bnd = "publishDiagnostics", arg in - bnd :: bnds) - in - let bnds = - if None = v_onTypeFormatting - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - DocumentOnTypeFormattingClientCapabilities.yojson_of_t) - v_onTypeFormatting - in - let bnd = "onTypeFormatting", arg in - bnd :: bnds) - in - let bnds = - if None = v_moniker - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t MonikerClientCapabilities.yojson_of_t) - v_moniker - in - let bnd = "moniker", arg in - bnd :: bnds) - in - let bnds = - if None = v_linkedEditingRange - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - LinkedEditingRangeClientCapabilities.yojson_of_t) - v_linkedEditingRange - in - let bnd = "linkedEditingRange", arg in - bnd :: bnds) - in - let bnds = - if None = v_inlineValue - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t InlineValueClientCapabilities.yojson_of_t) - v_inlineValue - in - let bnd = "inlineValue", arg in - bnd :: bnds) - in - let bnds = - if None = v_inlineCompletion - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - InlineCompletionClientCapabilities.yojson_of_t) - v_inlineCompletion - in - let bnd = "inlineCompletion", arg in - bnd :: bnds) - in - let bnds = - if None = v_inlayHint - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t InlayHintClientCapabilities.yojson_of_t) - v_inlayHint - in - let bnd = "inlayHint", arg in - bnd :: bnds) - in - let bnds = - if None = v_implementation - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - ImplementationClientCapabilities.yojson_of_t) - v_implementation - in - let bnd = "implementation", arg in - bnd :: bnds) - in - let bnds = - if None = v_hover - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t HoverClientCapabilities.yojson_of_t) - v_hover - in - let bnd = "hover", arg in - bnd :: bnds) - in - let bnds = - if None = v_formatting - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - DocumentFormattingClientCapabilities.yojson_of_t) - v_formatting - in - let bnd = "formatting", arg in - bnd :: bnds) - in - let bnds = - if None = v_foldingRange - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t FoldingRangeClientCapabilities.yojson_of_t) - v_foldingRange - in - let bnd = "foldingRange", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSymbol - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - DocumentSymbolClientCapabilities.yojson_of_t) - v_documentSymbol - in - let bnd = "documentSymbol", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentLink - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentLinkClientCapabilities.yojson_of_t) - v_documentLink - in - let bnd = "documentLink", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentHighlight - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - DocumentHighlightClientCapabilities.yojson_of_t) - v_documentHighlight - in - let bnd = "documentHighlight", arg in - bnd :: bnds) - in - let bnds = - if None = v_diagnostic - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DiagnosticClientCapabilities.yojson_of_t) - v_diagnostic - in - let bnd = "diagnostic", arg in - bnd :: bnds) - in - let bnds = - if None = v_definition - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DefinitionClientCapabilities.yojson_of_t) - v_definition - in - let bnd = "definition", arg in - bnd :: bnds) - in - let bnds = - if None = v_declaration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DeclarationClientCapabilities.yojson_of_t) - v_declaration - in - let bnd = "declaration", arg in - bnd :: bnds) - in - let bnds = - if None = v_completion - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CompletionClientCapabilities.yojson_of_t) - v_completion - in - let bnd = "completion", arg in - bnd :: bnds) - in - let bnds = - if None = v_colorProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - DocumentColorClientCapabilities.yojson_of_t) - v_colorProvider - in - let bnd = "colorProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_codeLens - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CodeLensClientCapabilities.yojson_of_t) - v_codeLens - in - let bnd = "codeLens", arg in - bnd :: bnds) - in - let bnds = - if None = v_codeAction - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CodeActionClientCapabilities.yojson_of_t) - v_codeAction - in - let bnd = "codeAction", arg in - bnd :: bnds) - in - let bnds = - if None = v_callHierarchy - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - CallHierarchyClientCapabilities.yojson_of_t) - v_callHierarchy - in - let bnd = "callHierarchy", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] - - let create - ?(callHierarchy : CallHierarchyClientCapabilities.t option) - ?(codeAction : CodeActionClientCapabilities.t option) - ?(codeLens : CodeLensClientCapabilities.t option) - ?(colorProvider : DocumentColorClientCapabilities.t option) - ?(completion : CompletionClientCapabilities.t option) - ?(declaration : DeclarationClientCapabilities.t option) - ?(definition : DefinitionClientCapabilities.t option) - ?(diagnostic : DiagnosticClientCapabilities.t option) - ?(documentHighlight : DocumentHighlightClientCapabilities.t option) - ?(documentLink : DocumentLinkClientCapabilities.t option) - ?(documentSymbol : DocumentSymbolClientCapabilities.t option) - ?(foldingRange : FoldingRangeClientCapabilities.t option) - ?(formatting : DocumentFormattingClientCapabilities.t option) - ?(hover : HoverClientCapabilities.t option) - ?(implementation : ImplementationClientCapabilities.t option) - ?(inlayHint : InlayHintClientCapabilities.t option) - ?(inlineCompletion : InlineCompletionClientCapabilities.t option) - ?(inlineValue : InlineValueClientCapabilities.t option) - ?(linkedEditingRange : LinkedEditingRangeClientCapabilities.t option) - ?(moniker : MonikerClientCapabilities.t option) - ?(onTypeFormatting : DocumentOnTypeFormattingClientCapabilities.t option) - ?(publishDiagnostics : PublishDiagnosticsClientCapabilities.t option) - ?(rangeFormatting : DocumentRangeFormattingClientCapabilities.t option) - ?(references : ReferenceClientCapabilities.t option) - ?(rename : RenameClientCapabilities.t option) - ?(selectionRange : SelectionRangeClientCapabilities.t option) - ?(semanticTokens : SemanticTokensClientCapabilities.t option) - ?(signatureHelp : SignatureHelpClientCapabilities.t option) - ?(synchronization : TextDocumentSyncClientCapabilities.t option) - ?(typeDefinition : TypeDefinitionClientCapabilities.t option) - ?(typeHierarchy : TypeHierarchyClientCapabilities.t option) - (() : unit) + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] + + let create + ?(callHierarchy : CallHierarchyClientCapabilities.t option) + ?(codeAction : CodeActionClientCapabilities.t option) + ?(codeLens : CodeLensClientCapabilities.t option) + ?(colorProvider : DocumentColorClientCapabilities.t option) + ?(completion : CompletionClientCapabilities.t option) + ?(declaration : DeclarationClientCapabilities.t option) + ?(definition : DefinitionClientCapabilities.t option) + ?(diagnostic : DiagnosticClientCapabilities.t option) + ?(documentHighlight : DocumentHighlightClientCapabilities.t option) + ?(documentLink : DocumentLinkClientCapabilities.t option) + ?(documentSymbol : DocumentSymbolClientCapabilities.t option) + ?(foldingRange : FoldingRangeClientCapabilities.t option) + ?(formatting : DocumentFormattingClientCapabilities.t option) + ?(hover : HoverClientCapabilities.t option) + ?(implementation : ImplementationClientCapabilities.t option) + ?(inlayHint : InlayHintClientCapabilities.t option) + ?(inlineCompletion : InlineCompletionClientCapabilities.t option) + ?(inlineValue : InlineValueClientCapabilities.t option) + ?(linkedEditingRange : LinkedEditingRangeClientCapabilities.t option) + ?(moniker : MonikerClientCapabilities.t option) + ?(onTypeFormatting : DocumentOnTypeFormattingClientCapabilities.t option) + ?(publishDiagnostics : PublishDiagnosticsClientCapabilities.t option) + ?(rangeFormatting : DocumentRangeFormattingClientCapabilities.t option) + ?(references : ReferenceClientCapabilities.t option) + ?(rename : RenameClientCapabilities.t option) + ?(selectionRange : SelectionRangeClientCapabilities.t option) + ?(semanticTokens : SemanticTokensClientCapabilities.t option) + ?(signatureHelp : SignatureHelpClientCapabilities.t option) + ?(synchronization : TextDocumentSyncClientCapabilities.t option) + ?(typeDefinition : TypeDefinitionClientCapabilities.t option) + ?(typeHierarchy : TypeHierarchyClientCapabilities.t option) + (() : unit) : t = { callHierarchy @@ -15454,120 +3087,16 @@ end module NotebookDocumentSyncClientCapabilities = struct type t = { dynamicRegistration : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; executionSummarySupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookDocumentSyncClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let dynamicRegistration_field = ref Ppx_yojson_conv_lib.Option.None - and executionSummarySupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "dynamicRegistration" -> - (match Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - dynamicRegistration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "executionSummarySupport" -> - (match Ppx_yojson_conv_lib.( ! ) executionSummarySupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - executionSummarySupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let dynamicRegistration_value, executionSummarySupport_value = - ( Ppx_yojson_conv_lib.( ! ) dynamicRegistration_field - , Ppx_yojson_conv_lib.( ! ) executionSummarySupport_field ) - in - { dynamicRegistration = - (match dynamicRegistration_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; executionSummarySupport = - (match executionSummarySupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { dynamicRegistration = v_dynamicRegistration - ; executionSummarySupport = v_executionSummarySupport - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_executionSummarySupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_executionSummarySupport - in - let bnd = "executionSummarySupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_dynamicRegistration - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_dynamicRegistration - in - let bnd = "dynamicRegistration", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(dynamicRegistration : bool option) - ?(executionSummarySupport : bool option) - (() : unit) + ?(dynamicRegistration : bool option) + ?(executionSummarySupport : bool option) + (() : unit) : t = { dynamicRegistration; executionSummarySupport } @@ -15576,82 +3105,7 @@ end module NotebookDocumentClientCapabilities = struct type t = { synchronization : NotebookDocumentSyncClientCapabilities.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookDocumentClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let synchronization_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "synchronization" -> - (match Ppx_yojson_conv_lib.( ! ) synchronization_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - NotebookDocumentSyncClientCapabilities.t_of_yojson _field_yojson - in - synchronization_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) synchronization_field with - | Ppx_yojson_conv_lib.Option.Some synchronization_value -> - { synchronization = synchronization_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) synchronization_field) - Ppx_yojson_conv_lib.Option.None - , "synchronization" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { synchronization = v_synchronization } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = NotebookDocumentSyncClientCapabilities.yojson_of_t v_synchronization in - ("synchronization", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(synchronization : NotebookDocumentSyncClientCapabilities.t) : t = { synchronization } @@ -15663,106 +3117,7 @@ module RegularExpressionsClientCapabilities = struct { engine : string ; version : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RegularExpressionsClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let engine_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "engine" -> - (match Ppx_yojson_conv_lib.( ! ) engine_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - engine_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) engine_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | Ppx_yojson_conv_lib.Option.Some engine_value, version_value -> - { engine = engine_value - ; version = - (match version_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) engine_field) - Ppx_yojson_conv_lib.Option.None - , "engine" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { engine = v_engine; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_version - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_version in - let bnd = "version", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_engine in - ("engine", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(engine : string) ?(version : string option) (() : unit) : t = { engine; version } @@ -15772,146 +3127,17 @@ end module MarkdownClientCapabilities = struct type t = { allowedTags : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; parser : string ; version : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.MarkdownClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let allowedTags_field = ref Ppx_yojson_conv_lib.Option.None - and parser_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "allowedTags" -> - (match Ppx_yojson_conv_lib.( ! ) allowedTags_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - allowedTags_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "parser" -> - (match Ppx_yojson_conv_lib.( ! ) parser_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - parser_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) allowedTags_field - , Ppx_yojson_conv_lib.( ! ) parser_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | ( allowedTags_value - , Ppx_yojson_conv_lib.Option.Some parser_value - , version_value ) -> - { allowedTags = - (match allowedTags_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; parser = parser_value - ; version = - (match version_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) parser_field) - Ppx_yojson_conv_lib.Option.None - , "parser" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { allowedTags = v_allowedTags; parser = v_parser; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_version - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_version in - let bnd = "version", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_parser in - ("parser", arg) :: bnds - in - let bnds = - if None = v_allowedTags - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_allowedTags - in - let bnd = "allowedTags", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(allowedTags : string list option) - ~(parser : string) - ?(version : string option) - (() : unit) + ?(allowedTags : string list option) + ~(parser : string) + ?(version : string option) + (() : unit) : t = { allowedTags; parser; version } @@ -15923,102 +3149,7 @@ module GeneralClientCapabilities = struct { cancel : bool ; retryOnContentModified : string list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : staleRequestSupport) -> () - - let staleRequestSupport_of_yojson = - (let _tp_loc = "lsp/src/types.ml.GeneralClientCapabilities.staleRequestSupport" in - function - | `Assoc field_yojsons as yojson -> - let cancel_field = ref Ppx_yojson_conv_lib.Option.None - and retryOnContentModified_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "cancel" -> - (match Ppx_yojson_conv_lib.( ! ) cancel_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - cancel_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "retryOnContentModified" -> - (match Ppx_yojson_conv_lib.( ! ) retryOnContentModified_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - retryOnContentModified_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) cancel_field - , Ppx_yojson_conv_lib.( ! ) retryOnContentModified_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some cancel_value - , Ppx_yojson_conv_lib.Option.Some retryOnContentModified_value ) -> - { cancel = cancel_value - ; retryOnContentModified = retryOnContentModified_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) cancel_field) - Ppx_yojson_conv_lib.Option.None - , "cancel" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) retryOnContentModified_field) - Ppx_yojson_conv_lib.Option.None - , "retryOnContentModified" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> staleRequestSupport) - ;; - - let _ = staleRequestSupport_of_yojson - - let yojson_of_staleRequestSupport = - (function - | { cancel = v_cancel; retryOnContentModified = v_retryOnContentModified } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list yojson_of_string v_retryOnContentModified in - ("retryOnContentModified", arg) :: bnds - in - let bnds = - let arg = yojson_of_bool v_cancel in - ("cancel", arg) :: bnds - in - `Assoc bnds - : staleRequestSupport -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_staleRequestSupport - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_staleRequestSupport ~(cancel : bool) ~(retryOnContentModified : string list) : staleRequestSupport @@ -16028,196 +3159,22 @@ module GeneralClientCapabilities = struct type t = { markdown : MarkdownClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; positionEncodings : PositionEncodingKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; regularExpressions : RegularExpressionsClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; staleRequestSupport : staleRequestSupport Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.GeneralClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let markdown_field = ref Ppx_yojson_conv_lib.Option.None - and positionEncodings_field = ref Ppx_yojson_conv_lib.Option.None - and regularExpressions_field = ref Ppx_yojson_conv_lib.Option.None - and staleRequestSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "markdown" -> - (match Ppx_yojson_conv_lib.( ! ) markdown_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - MarkdownClientCapabilities.t_of_yojson - _field_yojson - in - markdown_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "positionEncodings" -> - (match Ppx_yojson_conv_lib.( ! ) positionEncodings_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson PositionEncodingKind.t_of_yojson) - _field_yojson - in - positionEncodings_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "regularExpressions" -> - (match Ppx_yojson_conv_lib.( ! ) regularExpressions_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - RegularExpressionsClientCapabilities.t_of_yojson - _field_yojson - in - regularExpressions_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "staleRequestSupport" -> - (match Ppx_yojson_conv_lib.( ! ) staleRequestSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - staleRequestSupport_of_yojson - _field_yojson - in - staleRequestSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( markdown_value - , positionEncodings_value - , regularExpressions_value - , staleRequestSupport_value ) - = - ( Ppx_yojson_conv_lib.( ! ) markdown_field - , Ppx_yojson_conv_lib.( ! ) positionEncodings_field - , Ppx_yojson_conv_lib.( ! ) regularExpressions_field - , Ppx_yojson_conv_lib.( ! ) staleRequestSupport_field ) - in - { markdown = - (match markdown_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; positionEncodings = - (match positionEncodings_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; regularExpressions = - (match regularExpressions_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; staleRequestSupport = - (match staleRequestSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { markdown = v_markdown - ; positionEncodings = v_positionEncodings - ; regularExpressions = v_regularExpressions - ; staleRequestSupport = v_staleRequestSupport - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_staleRequestSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_staleRequestSupport) - v_staleRequestSupport - in - let bnd = "staleRequestSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_regularExpressions - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - RegularExpressionsClientCapabilities.yojson_of_t) - v_regularExpressions - in - let bnd = "regularExpressions", arg in - bnd :: bnds) - in - let bnds = - if None = v_positionEncodings - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list PositionEncodingKind.yojson_of_t)) - v_positionEncodings - in - let bnd = "positionEncodings", arg in - bnd :: bnds) - in - let bnds = - if None = v_markdown - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t MarkdownClientCapabilities.yojson_of_t) - v_markdown - in - let bnd = "markdown", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(markdown : MarkdownClientCapabilities.t option) - ?(positionEncodings : PositionEncodingKind.t list option) - ?(regularExpressions : RegularExpressionsClientCapabilities.t option) - ?(staleRequestSupport : staleRequestSupport option) - (() : unit) + ?(markdown : MarkdownClientCapabilities.t option) + ?(positionEncodings : PositionEncodingKind.t list option) + ?(regularExpressions : RegularExpressionsClientCapabilities.t option) + ?(staleRequestSupport : staleRequestSupport option) + (() : unit) : t = { markdown; positionEncodings; regularExpressions; staleRequestSupport } @@ -16228,249 +3185,26 @@ module ClientCapabilities = struct type t = { experimental : Json.t option [@yojson.option] ; general : GeneralClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; notebookDocument : NotebookDocumentClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textDocument : TextDocumentClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; window : WindowClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workspace : WorkspaceClientCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ClientCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let experimental_field = ref Ppx_yojson_conv_lib.Option.None - and general_field = ref Ppx_yojson_conv_lib.Option.None - and notebookDocument_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and window_field = ref Ppx_yojson_conv_lib.Option.None - and workspace_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "experimental" -> - (match Ppx_yojson_conv_lib.( ! ) experimental_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - experimental_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "general" -> - (match Ppx_yojson_conv_lib.( ! ) general_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - GeneralClientCapabilities.t_of_yojson - _field_yojson - in - general_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "notebookDocument" -> - (match Ppx_yojson_conv_lib.( ! ) notebookDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - NotebookDocumentClientCapabilities.t_of_yojson - _field_yojson - in - notebookDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - TextDocumentClientCapabilities.t_of_yojson - _field_yojson - in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "window" -> - (match Ppx_yojson_conv_lib.( ! ) window_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - WindowClientCapabilities.t_of_yojson - _field_yojson - in - window_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workspace" -> - (match Ppx_yojson_conv_lib.( ! ) workspace_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - WorkspaceClientCapabilities.t_of_yojson - _field_yojson - in - workspace_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( experimental_value - , general_value - , notebookDocument_value - , textDocument_value - , window_value - , workspace_value ) - = - ( Ppx_yojson_conv_lib.( ! ) experimental_field - , Ppx_yojson_conv_lib.( ! ) general_field - , Ppx_yojson_conv_lib.( ! ) notebookDocument_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) window_field - , Ppx_yojson_conv_lib.( ! ) workspace_field ) - in - { experimental = experimental_value - ; general = - (match general_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; notebookDocument = - (match notebookDocument_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocument = - (match textDocument_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; window = - (match window_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workspace = - (match workspace_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { experimental = v_experimental - ; general = v_general - ; notebookDocument = v_notebookDocument - ; textDocument = v_textDocument - ; window = v_window - ; workspace = v_workspace - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workspace - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t WorkspaceClientCapabilities.yojson_of_t) - v_workspace - in - let bnd = "workspace", arg in - bnd :: bnds) - in - let bnds = - if None = v_window - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t WindowClientCapabilities.yojson_of_t) - v_window - in - let bnd = "window", arg in - bnd :: bnds) - in - let bnds = - if None = v_textDocument - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t TextDocumentClientCapabilities.yojson_of_t) - v_textDocument - in - let bnd = "textDocument", arg in - bnd :: bnds) - in - let bnds = - if None = v_notebookDocument - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - NotebookDocumentClientCapabilities.yojson_of_t) - v_notebookDocument - in - let bnd = "notebookDocument", arg in - bnd :: bnds) - in - let bnds = - if None = v_general - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t GeneralClientCapabilities.yojson_of_t) - v_general - in - let bnd = "general", arg in - bnd :: bnds) - in - let bnds = - match v_experimental with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "experimental", arg in - bnd :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(experimental : Json.t option) - ?(general : GeneralClientCapabilities.t option) - ?(notebookDocument : NotebookDocumentClientCapabilities.t option) - ?(textDocument : TextDocumentClientCapabilities.t option) - ?(window : WindowClientCapabilities.t option) - ?(workspace : WorkspaceClientCapabilities.t option) - (() : unit) + ?(experimental : Json.t option) + ?(general : GeneralClientCapabilities.t option) + ?(notebookDocument : NotebookDocumentClientCapabilities.t option) + ?(textDocument : TextDocumentClientCapabilities.t option) + ?(window : WindowClientCapabilities.t option) + ?(workspace : WorkspaceClientCapabilities.t option) + (() : unit) : t = { experimental; general; notebookDocument; textDocument; window; workspace } @@ -16482,99 +3216,7 @@ module Location = struct { range : Range.t ; uri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.Location.t" in - function - | `Assoc field_yojsons as yojson -> - let range_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - Ppx_yojson_conv_lib.( ! ) range_field, Ppx_yojson_conv_lib.( ! ) uri_field - with - | ( Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some uri_value ) -> - { range = range_value; uri = uri_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { range = v_range; uri = v_uri } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(range : Range.t) ~(uri : DocumentUri.t) : t = { range; uri } end @@ -16584,100 +3226,7 @@ module DiagnosticRelatedInformation = struct { location : Location.t ; message : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DiagnosticRelatedInformation.t" in - function - | `Assoc field_yojsons as yojson -> - let location_field = ref Ppx_yojson_conv_lib.Option.None - and message_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "location" -> - (match Ppx_yojson_conv_lib.( ! ) location_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Location.t_of_yojson _field_yojson in - location_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "message" -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - message_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) location_field - , Ppx_yojson_conv_lib.( ! ) message_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some location_value - , Ppx_yojson_conv_lib.Option.Some message_value ) -> - { location = location_value; message = message_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) location_field) - Ppx_yojson_conv_lib.Option.None - , "location" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) message_field) - Ppx_yojson_conv_lib.Option.None - , "message" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { location = v_location; message = v_message } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_message in - ("message", arg) :: bnds - in - let bnds = - let arg = Location.yojson_of_t v_location in - ("location", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(location : Location.t) ~(message : string) : t = { location; message } end @@ -16687,179 +3236,13 @@ module MarkupContent = struct { kind : MarkupKind.t ; value : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.MarkupContent.t" in - function - | `Assoc field_yojsons as yojson -> - let kind_field = ref Ppx_yojson_conv_lib.Option.None - and value_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = MarkupKind.t_of_yojson _field_yojson in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "value" -> - (match Ppx_yojson_conv_lib.( ! ) value_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - value_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) value_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some kind_value - , Ppx_yojson_conv_lib.Option.Some value_value ) -> - { kind = kind_value; value = value_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) kind_field) - Ppx_yojson_conv_lib.Option.None - , "kind" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) value_field) - Ppx_yojson_conv_lib.Option.None - , "value" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { kind = v_kind; value = v_value } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_value in - ("value", arg) :: bnds - in - let bnds = - let arg = MarkupKind.yojson_of_t v_kind in - ("kind", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(kind : MarkupKind.t) ~(value : string) : t = { kind; value } end module CodeDescription = struct - type t = { href : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeDescription.t" in - function - | `Assoc field_yojsons as yojson -> - let href_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "href" -> - (match Ppx_yojson_conv_lib.( ! ) href_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - href_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) href_field with - | Ppx_yojson_conv_lib.Option.Some href_value -> { href = href_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) href_field) - Ppx_yojson_conv_lib.Option.None - , "href" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { href = v_href } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_href in - ("href", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { href : DocumentUri.t } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(href : DocumentUri.t) : t = { href } end @@ -16888,320 +3271,33 @@ module Diagnostic = struct type t = { code : Jsonrpc.Id.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; codeDescription : CodeDescription.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; data : Json.t option [@yojson.option] ; message : message_pvar ; range : Range.t ; relatedInformation : DiagnosticRelatedInformation.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; severity : DiagnosticSeverity.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; source : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; tags : DiagnosticTag.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.Diagnostic.t" in - function - | `Assoc field_yojsons as yojson -> - let code_field = ref Ppx_yojson_conv_lib.Option.None - and codeDescription_field = ref Ppx_yojson_conv_lib.Option.None - and data_field = ref Ppx_yojson_conv_lib.Option.None - and message_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and relatedInformation_field = ref Ppx_yojson_conv_lib.Option.None - and severity_field = ref Ppx_yojson_conv_lib.Option.None - and source_field = ref Ppx_yojson_conv_lib.Option.None - and tags_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "code" -> - (match Ppx_yojson_conv_lib.( ! ) code_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Jsonrpc.Id.t_of_yojson _field_yojson - in - code_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "codeDescription" -> - (match Ppx_yojson_conv_lib.( ! ) codeDescription_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CodeDescription.t_of_yojson - _field_yojson - in - codeDescription_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "message" -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = message_pvar_of_yojson _field_yojson in - message_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "relatedInformation" -> - (match Ppx_yojson_conv_lib.( ! ) relatedInformation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson DiagnosticRelatedInformation.t_of_yojson) - _field_yojson - in - relatedInformation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "severity" -> - (match Ppx_yojson_conv_lib.( ! ) severity_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DiagnosticSeverity.t_of_yojson - _field_yojson - in - severity_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "source" -> - (match Ppx_yojson_conv_lib.( ! ) source_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - source_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tags" -> - (match Ppx_yojson_conv_lib.( ! ) tags_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson DiagnosticTag.t_of_yojson) - _field_yojson - in - tags_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) code_field - , Ppx_yojson_conv_lib.( ! ) codeDescription_field - , Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) message_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) relatedInformation_field - , Ppx_yojson_conv_lib.( ! ) severity_field - , Ppx_yojson_conv_lib.( ! ) source_field - , Ppx_yojson_conv_lib.( ! ) tags_field ) - with - | ( code_value - , codeDescription_value - , data_value - , Ppx_yojson_conv_lib.Option.Some message_value - , Ppx_yojson_conv_lib.Option.Some range_value - , relatedInformation_value - , severity_value - , source_value - , tags_value ) -> - { code = - (match code_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; codeDescription = - (match codeDescription_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; data = data_value - ; message = message_value - ; range = range_value - ; relatedInformation = - (match relatedInformation_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; severity = - (match severity_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; source = - (match source_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tags = - (match tags_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) message_field) - Ppx_yojson_conv_lib.Option.None - , "message" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { code = v_code - ; codeDescription = v_codeDescription - ; data = v_data - ; message = v_message - ; range = v_range - ; relatedInformation = v_relatedInformation - ; severity = v_severity - ; source = v_source - ; tags = v_tags - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_tags - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list DiagnosticTag.yojson_of_t)) - v_tags - in - let bnd = "tags", arg in - bnd :: bnds) - in - let bnds = - if None = v_source - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_source in - let bnd = "source", arg in - bnd :: bnds) - in - let bnds = - if None = v_severity - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DiagnosticSeverity.yojson_of_t) v_severity - in - let bnd = "severity", arg in - bnd :: bnds) - in - let bnds = - if None = v_relatedInformation - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list DiagnosticRelatedInformation.yojson_of_t)) - v_relatedInformation - in - let bnd = "relatedInformation", arg in - bnd :: bnds) - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - let arg = yojson_of_message_pvar v_message in - ("message", arg) :: bnds - in - let bnds = - match v_data with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "data", arg in - bnd :: bnds - in - let bnds = - if None = v_codeDescription - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CodeDescription.yojson_of_t) - v_codeDescription - in - let bnd = "codeDescription", arg in - bnd :: bnds) - in - let bnds = - if None = v_code - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Jsonrpc.Id.yojson_of_t) v_code in - let bnd = "code", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(code : Jsonrpc.Id.t option) - ?(codeDescription : CodeDescription.t option) - ?(data : Json.t option) - ~(message : message_pvar) - ~(range : Range.t) - ?(relatedInformation : DiagnosticRelatedInformation.t list option) - ?(severity : DiagnosticSeverity.t option) - ?(source : string option) - ?(tags : DiagnosticTag.t list option) - (() : unit) + ?(code : Jsonrpc.Id.t option) + ?(codeDescription : CodeDescription.t option) + ?(data : Json.t option) + ~(message : message_pvar) + ~(range : Range.t) + ?(relatedInformation : DiagnosticRelatedInformation.t list option) + ?(severity : DiagnosticSeverity.t option) + ?(source : string option) + ?(tags : DiagnosticTag.t list option) + (() : unit) : t = { code @@ -17220,141 +3316,17 @@ end module Command = struct type t = { arguments : Json.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; command : string ; title : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.Command.t" in - function - | `Assoc field_yojsons as yojson -> - let arguments_field = ref Ppx_yojson_conv_lib.Option.None - and command_field = ref Ppx_yojson_conv_lib.Option.None - and title_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "arguments" -> - (match Ppx_yojson_conv_lib.( ! ) arguments_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson Json.t_of_yojson) - _field_yojson - in - arguments_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "command" -> - (match Ppx_yojson_conv_lib.( ! ) command_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - command_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "title" -> - (match Ppx_yojson_conv_lib.( ! ) title_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - title_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) arguments_field - , Ppx_yojson_conv_lib.( ! ) command_field - , Ppx_yojson_conv_lib.( ! ) title_field ) - with - | ( arguments_value - , Ppx_yojson_conv_lib.Option.Some command_value - , Ppx_yojson_conv_lib.Option.Some title_value ) -> - { arguments = - (match arguments_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; command = command_value - ; title = title_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) command_field) - Ppx_yojson_conv_lib.Option.None - , "command" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) title_field) - Ppx_yojson_conv_lib.Option.None - , "title" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { arguments = v_arguments; command = v_command; title = v_title } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_title in - ("title", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_command in - ("command", arg) :: bnds - in - let bnds = - if None = v_arguments - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list Json.yojson_of_t)) - v_arguments - in - let bnd = "arguments", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(arguments : Json.t list option) - ~(command : string) - ~(title : string) - (() : unit) + ?(arguments : Json.t list option) + ~(command : string) + ~(title : string) + (() : unit) : t = { arguments; command; title } @@ -17362,371 +3334,38 @@ module Command = struct end module CodeAction = struct - type disabled = { reason : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : disabled) -> () - - let disabled_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeAction.disabled" in - function - | `Assoc field_yojsons as yojson -> - let reason_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "reason" -> - (match Ppx_yojson_conv_lib.( ! ) reason_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - reason_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) reason_field with - | Ppx_yojson_conv_lib.Option.Some reason_value -> { reason = reason_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) reason_field) - Ppx_yojson_conv_lib.Option.None - , "reason" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> disabled) - ;; - - let _ = disabled_of_yojson - - let yojson_of_disabled = - (function - | { reason = v_reason } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_reason in - ("reason", arg) :: bnds - in - `Assoc bnds - : disabled -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_disabled - - [@@@end] + type disabled = { reason : string } [@@deriving yojson] [@@yojson.allow_extra_fields] let create_disabled ~(reason : string) : disabled = { reason } type t = { command : Command.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; data : Json.t option [@yojson.option] ; diagnostics : Diagnostic.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; disabled : disabled Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; edit : WorkspaceEdit.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; isPreferred : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; kind : CodeActionKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; title : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeAction.t" in - function - | `Assoc field_yojsons as yojson -> - let command_field = ref Ppx_yojson_conv_lib.Option.None - and data_field = ref Ppx_yojson_conv_lib.Option.None - and diagnostics_field = ref Ppx_yojson_conv_lib.Option.None - and disabled_field = ref Ppx_yojson_conv_lib.Option.None - and edit_field = ref Ppx_yojson_conv_lib.Option.None - and isPreferred_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and title_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "command" -> - (match Ppx_yojson_conv_lib.( ! ) command_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Command.t_of_yojson _field_yojson - in - command_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "diagnostics" -> - (match Ppx_yojson_conv_lib.( ! ) diagnostics_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson Diagnostic.t_of_yojson) - _field_yojson - in - diagnostics_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "disabled" -> - (match Ppx_yojson_conv_lib.( ! ) disabled_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson disabled_of_yojson _field_yojson - in - disabled_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "edit" -> - (match Ppx_yojson_conv_lib.( ! ) edit_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - WorkspaceEdit.t_of_yojson - _field_yojson - in - edit_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "isPreferred" -> - (match Ppx_yojson_conv_lib.( ! ) isPreferred_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - isPreferred_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CodeActionKind.t_of_yojson - _field_yojson - in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "title" -> - (match Ppx_yojson_conv_lib.( ! ) title_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - title_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) command_field - , Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) diagnostics_field - , Ppx_yojson_conv_lib.( ! ) disabled_field - , Ppx_yojson_conv_lib.( ! ) edit_field - , Ppx_yojson_conv_lib.( ! ) isPreferred_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) title_field ) - with - | ( command_value - , data_value - , diagnostics_value - , disabled_value - , edit_value - , isPreferred_value - , kind_value - , Ppx_yojson_conv_lib.Option.Some title_value ) -> - { command = - (match command_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; data = data_value - ; diagnostics = - (match diagnostics_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; disabled = - (match disabled_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; edit = - (match edit_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; isPreferred = - (match isPreferred_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; kind = - (match kind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; title = title_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) title_field) - Ppx_yojson_conv_lib.Option.None - , "title" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { command = v_command - ; data = v_data - ; diagnostics = v_diagnostics - ; disabled = v_disabled - ; edit = v_edit - ; isPreferred = v_isPreferred - ; kind = v_kind - ; title = v_title - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_title in - ("title", arg) :: bnds - in - let bnds = - if None = v_kind - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CodeActionKind.yojson_of_t) v_kind - in - let bnd = "kind", arg in - bnd :: bnds) - in - let bnds = - if None = v_isPreferred - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_isPreferred in - let bnd = "isPreferred", arg in - bnd :: bnds) - in - let bnds = - if None = v_edit - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t WorkspaceEdit.yojson_of_t) v_edit - in - let bnd = "edit", arg in - bnd :: bnds) - in - let bnds = - if None = v_disabled - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_disabled) v_disabled in - let bnd = "disabled", arg in - bnd :: bnds) - in - let bnds = - if None = v_diagnostics - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list Diagnostic.yojson_of_t)) - v_diagnostics - in - let bnd = "diagnostics", arg in - bnd :: bnds) - in - let bnds = - match v_data with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "data", arg in - bnd :: bnds - in - let bnds = - if None = v_command - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Command.yojson_of_t) v_command in - let bnd = "command", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(command : Command.t option) - ?(data : Json.t option) - ?(diagnostics : Diagnostic.t list option) - ?(disabled : disabled option) - ?(edit : WorkspaceEdit.t option) - ?(isPreferred : bool option) - ?(kind : CodeActionKind.t option) - ~(title : string) - (() : unit) + ?(command : Command.t option) + ?(data : Json.t option) + ?(diagnostics : Diagnostic.t list option) + ?(disabled : disabled option) + ?(edit : WorkspaceEdit.t option) + ?(isPreferred : bool option) + ?(kind : CodeActionKind.t option) + ~(title : string) + (() : unit) : t = { command; data; diagnostics; disabled; edit; isPreferred; kind; title } @@ -17737,152 +3376,17 @@ module CodeActionContext = struct type t = { diagnostics : Diagnostic.t list ; only : CodeActionKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; triggerKind : CodeActionTriggerKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeActionContext.t" in - function - | `Assoc field_yojsons as yojson -> - let diagnostics_field = ref Ppx_yojson_conv_lib.Option.None - and only_field = ref Ppx_yojson_conv_lib.Option.None - and triggerKind_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "diagnostics" -> - (match Ppx_yojson_conv_lib.( ! ) diagnostics_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Diagnostic.t_of_yojson _field_yojson in - diagnostics_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "only" -> - (match Ppx_yojson_conv_lib.( ! ) only_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson CodeActionKind.t_of_yojson) - _field_yojson - in - only_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "triggerKind" -> - (match Ppx_yojson_conv_lib.( ! ) triggerKind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CodeActionTriggerKind.t_of_yojson - _field_yojson - in - triggerKind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) diagnostics_field - , Ppx_yojson_conv_lib.( ! ) only_field - , Ppx_yojson_conv_lib.( ! ) triggerKind_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some diagnostics_value - , only_value - , triggerKind_value ) -> - { diagnostics = diagnostics_value - ; only = - (match only_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; triggerKind = - (match triggerKind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) diagnostics_field) - Ppx_yojson_conv_lib.Option.None - , "diagnostics" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { diagnostics = v_diagnostics; only = v_only; triggerKind = v_triggerKind } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_triggerKind - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CodeActionTriggerKind.yojson_of_t) - v_triggerKind - in - let bnd = "triggerKind", arg in - bnd :: bnds) - in - let bnds = - if None = v_only - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list CodeActionKind.yojson_of_t)) - v_only - in - let bnd = "only", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list Diagnostic.yojson_of_t v_diagnostics in - ("diagnostics", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(diagnostics : Diagnostic.t list) - ?(only : CodeActionKind.t list option) - ?(triggerKind : CodeActionTriggerKind.t option) - (() : unit) + ~(diagnostics : Diagnostic.t list) + ?(only : CodeActionKind.t list option) + ?(triggerKind : CodeActionTriggerKind.t option) + (() : unit) : t = { diagnostics; only; triggerKind } @@ -17892,153 +3396,19 @@ end module CodeActionOptions = struct type t = { codeActionKinds : CodeActionKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeActionOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let codeActionKinds_field = ref Ppx_yojson_conv_lib.Option.None - and resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "codeActionKinds" -> - (match Ppx_yojson_conv_lib.( ! ) codeActionKinds_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson CodeActionKind.t_of_yojson) - _field_yojson - in - codeActionKinds_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let codeActionKinds_value, resolveProvider_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) codeActionKinds_field - , Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { codeActionKinds = - (match codeActionKinds_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { codeActionKinds = v_codeActionKinds - ; resolveProvider = v_resolveProvider - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_codeActionKinds - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list CodeActionKind.yojson_of_t)) - v_codeActionKinds - in - let bnd = "codeActionKinds", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(codeActionKinds : CodeActionKind.t list option) - ?(resolveProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(codeActionKinds : CodeActionKind.t list option) + ?(resolveProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { codeActionKinds; resolveProvider; workDoneProgress } @@ -18049,197 +3419,21 @@ module CodeActionParams = struct type t = { context : CodeActionContext.t ; partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; range : Range.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeActionParams.t" in - function - | `Assoc field_yojsons as yojson -> - let context_field = ref Ppx_yojson_conv_lib.Option.None - and partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "context" -> - (match Ppx_yojson_conv_lib.( ! ) context_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = CodeActionContext.t_of_yojson _field_yojson in - context_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) context_field - , Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some context_value - , partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { context = context_value - ; partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; range = range_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) context_field) - Ppx_yojson_conv_lib.Option.None - , "context" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { context = v_context - ; partialResultToken = v_partialResultToken - ; range = v_range - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - let bnds = - let arg = CodeActionContext.yojson_of_t v_context in - ("context", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(context : CodeActionContext.t) - ?(partialResultToken : ProgressToken.t option) - ~(range : Range.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(context : CodeActionContext.t) + ?(partialResultToken : ProgressToken.t option) + ~(range : Range.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { context; partialResultToken; range; textDocument; workDoneToken } @@ -18249,189 +3443,22 @@ end module CodeActionRegistrationOptions = struct type t = { codeActionKinds : CodeActionKind.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeActionRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let codeActionKinds_field = ref Ppx_yojson_conv_lib.Option.None - and documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "codeActionKinds" -> - (match Ppx_yojson_conv_lib.( ! ) codeActionKinds_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson CodeActionKind.t_of_yojson) - _field_yojson - in - codeActionKinds_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( codeActionKinds_value - , documentSelector_value - , resolveProvider_value - , workDoneProgress_value ) - = - ( Ppx_yojson_conv_lib.( ! ) codeActionKinds_field - , Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { codeActionKinds = - (match codeActionKinds_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { codeActionKinds = v_codeActionKinds - ; documentSelector = v_documentSelector - ; resolveProvider = v_resolveProvider - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - let bnds = - if None = v_codeActionKinds - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list CodeActionKind.yojson_of_t)) - v_codeActionKinds - in - let bnd = "codeActionKinds", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(codeActionKinds : CodeActionKind.t list option) - ?(documentSelector : DocumentSelector.t option) - ?(resolveProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(codeActionKinds : CodeActionKind.t list option) + ?(documentSelector : DocumentSelector.t option) + ?(resolveProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { codeActionKinds; documentSelector; resolveProvider; workDoneProgress } @@ -18441,134 +3468,17 @@ end module CodeLens = struct type t = { command : Command.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; data : Json.t option [@yojson.option] ; range : Range.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeLens.t" in - function - | `Assoc field_yojsons as yojson -> - let command_field = ref Ppx_yojson_conv_lib.Option.None - and data_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "command" -> - (match Ppx_yojson_conv_lib.( ! ) command_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Command.t_of_yojson _field_yojson - in - command_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) command_field - , Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) range_field ) - with - | command_value, data_value, Ppx_yojson_conv_lib.Option.Some range_value -> - { command = - (match command_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; data = data_value - ; range = range_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { command = v_command; data = v_data; range = v_range } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - match v_data with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "data", arg in - bnd :: bnds - in - let bnds = - if None = v_command - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Command.yojson_of_t) v_command in - let bnd = "command", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(command : Command.t option) - ?(data : Json.t option) - ~(range : Range.t) - (() : unit) + ?(command : Command.t option) + ?(data : Json.t option) + ~(range : Range.t) + (() : unit) : t = { command; data; range } @@ -18578,118 +3488,16 @@ end module CodeLensOptions = struct type t = { resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeLensOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let resolveProvider_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { resolveProvider = v_resolveProvider; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(resolveProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(resolveProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { resolveProvider; workDoneProgress } @@ -18699,154 +3507,18 @@ end module CodeLensParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeLensParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; textDocument; workDoneToken } @@ -18856,152 +3528,19 @@ end module CodeLensRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CodeLensRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, resolveProvider_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; resolveProvider = v_resolveProvider - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(resolveProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(resolveProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; resolveProvider; workDoneProgress } @@ -19010,147 +3549,14 @@ end module Color = struct type t = - { alpha : int - ; blue : int - ; green : int - ; red : int - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.Color.t" in - function - | `Assoc field_yojsons as yojson -> - let alpha_field = ref Ppx_yojson_conv_lib.Option.None - and blue_field = ref Ppx_yojson_conv_lib.Option.None - and green_field = ref Ppx_yojson_conv_lib.Option.None - and red_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "alpha" -> - (match Ppx_yojson_conv_lib.( ! ) alpha_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - alpha_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "blue" -> - (match Ppx_yojson_conv_lib.( ! ) blue_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - blue_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "green" -> - (match Ppx_yojson_conv_lib.( ! ) green_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - green_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "red" -> - (match Ppx_yojson_conv_lib.( ! ) red_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - red_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) alpha_field - , Ppx_yojson_conv_lib.( ! ) blue_field - , Ppx_yojson_conv_lib.( ! ) green_field - , Ppx_yojson_conv_lib.( ! ) red_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some alpha_value - , Ppx_yojson_conv_lib.Option.Some blue_value - , Ppx_yojson_conv_lib.Option.Some green_value - , Ppx_yojson_conv_lib.Option.Some red_value ) -> - { alpha = alpha_value - ; blue = blue_value - ; green = green_value - ; red = red_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) alpha_field) - Ppx_yojson_conv_lib.Option.None - , "alpha" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) blue_field) - Ppx_yojson_conv_lib.Option.None - , "blue" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) green_field) - Ppx_yojson_conv_lib.Option.None - , "green" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) red_field) - Ppx_yojson_conv_lib.Option.None - , "red" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { alpha = v_alpha; blue = v_blue; green = v_green; red = v_red } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_int v_red in - ("red", arg) :: bnds - in - let bnds = - let arg = yojson_of_int v_green in - ("green", arg) :: bnds - in - let bnds = - let arg = yojson_of_int v_blue in - ("blue", arg) :: bnds - in - let bnds = - let arg = yojson_of_int v_alpha in - ("alpha", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] - - let create ~(alpha : int) ~(blue : int) ~(green : int) ~(red : int) : t = + { alpha : float + ; blue : float + ; green : float + ; red : float + } + [@@deriving yojson] [@@yojson.allow_extra_fields] + + let create ~(alpha : float) ~(blue : float) ~(green : float) ~(red : float) : t = { alpha; blue; green; red } ;; end @@ -19160,100 +3566,7 @@ module ColorInformation = struct { color : Color.t ; range : Range.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ColorInformation.t" in - function - | `Assoc field_yojsons as yojson -> - let color_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "color" -> - (match Ppx_yojson_conv_lib.( ! ) color_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Color.t_of_yojson _field_yojson in - color_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) color_field - , Ppx_yojson_conv_lib.( ! ) range_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some color_value - , Ppx_yojson_conv_lib.Option.Some range_value ) -> - { color = color_value; range = range_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) color_field) - Ppx_yojson_conv_lib.Option.None - , "color" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { color = v_color; range = v_range } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - let arg = Color.yojson_of_t v_color in - ("color", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(color : Color.t) ~(range : Range.t) : t = { color; range } end @@ -19261,150 +3574,18 @@ end module ColorPresentation = struct type t = { additionalTextEdits : TextEdit.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; label : string ; textEdit : TextEdit.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ColorPresentation.t" in - function - | `Assoc field_yojsons as yojson -> - let additionalTextEdits_field = ref Ppx_yojson_conv_lib.Option.None - and label_field = ref Ppx_yojson_conv_lib.Option.None - and textEdit_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "additionalTextEdits" -> - (match Ppx_yojson_conv_lib.( ! ) additionalTextEdits_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson TextEdit.t_of_yojson) - _field_yojson - in - additionalTextEdits_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "label" -> - (match Ppx_yojson_conv_lib.( ! ) label_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - label_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textEdit" -> - (match Ppx_yojson_conv_lib.( ! ) textEdit_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson TextEdit.t_of_yojson _field_yojson - in - textEdit_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) additionalTextEdits_field - , Ppx_yojson_conv_lib.( ! ) label_field - , Ppx_yojson_conv_lib.( ! ) textEdit_field ) - with - | ( additionalTextEdits_value - , Ppx_yojson_conv_lib.Option.Some label_value - , textEdit_value ) -> - { additionalTextEdits = - (match additionalTextEdits_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; label = label_value - ; textEdit = - (match textEdit_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) label_field) - Ppx_yojson_conv_lib.Option.None - , "label" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { additionalTextEdits = v_additionalTextEdits - ; label = v_label - ; textEdit = v_textEdit - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_textEdit - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t TextEdit.yojson_of_t) v_textEdit in - let bnd = "textEdit", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_label in - ("label", arg) :: bnds - in - let bnds = - if None = v_additionalTextEdits - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list TextEdit.yojson_of_t)) - v_additionalTextEdits - in - let bnd = "additionalTextEdits", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(additionalTextEdits : TextEdit.t list option) - ~(label : string) - ?(textEdit : TextEdit.t option) - (() : unit) + ?(additionalTextEdits : TextEdit.t list option) + ~(label : string) + ?(textEdit : TextEdit.t option) + (() : unit) : t = { additionalTextEdits; label; textEdit } @@ -19415,197 +3596,21 @@ module ColorPresentationParams = struct type t = { color : Color.t ; partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; range : Range.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ColorPresentationParams.t" in - function - | `Assoc field_yojsons as yojson -> - let color_field = ref Ppx_yojson_conv_lib.Option.None - and partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "color" -> - (match Ppx_yojson_conv_lib.( ! ) color_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Color.t_of_yojson _field_yojson in - color_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) color_field - , Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some color_value - , partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { color = color_value - ; partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; range = range_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) color_field) - Ppx_yojson_conv_lib.Option.None - , "color" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { color = v_color - ; partialResultToken = v_partialResultToken - ; range = v_range - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - let bnds = - let arg = Color.yojson_of_t v_color in - ("color", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(color : Color.t) - ?(partialResultToken : ProgressToken.t option) - ~(range : Range.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(color : Color.t) + ?(partialResultToken : ProgressToken.t option) + ~(range : Range.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { color; partialResultToken; range; textDocument; workDoneToken } @@ -19615,117 +3620,15 @@ end module CompletionContext = struct type t = { triggerCharacter : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; triggerKind : CompletionTriggerKind.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionContext.t" in - function - | `Assoc field_yojsons as yojson -> - let triggerCharacter_field = ref Ppx_yojson_conv_lib.Option.None - and triggerKind_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "triggerCharacter" -> - (match Ppx_yojson_conv_lib.( ! ) triggerCharacter_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - triggerCharacter_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "triggerKind" -> - (match Ppx_yojson_conv_lib.( ! ) triggerKind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = CompletionTriggerKind.t_of_yojson _field_yojson in - triggerKind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) triggerCharacter_field - , Ppx_yojson_conv_lib.( ! ) triggerKind_field ) - with - | triggerCharacter_value, Ppx_yojson_conv_lib.Option.Some triggerKind_value - -> - { triggerCharacter = - (match triggerCharacter_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; triggerKind = triggerKind_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) triggerKind_field) - Ppx_yojson_conv_lib.Option.None - , "triggerKind" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { triggerCharacter = v_triggerCharacter; triggerKind = v_triggerKind } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = CompletionTriggerKind.yojson_of_t v_triggerKind in - ("triggerKind", arg) :: bnds - in - let bnds = - if None = v_triggerCharacter - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_string) v_triggerCharacter - in - let bnd = "triggerCharacter", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(triggerCharacter : string option) - ~(triggerKind : CompletionTriggerKind.t) - (() : unit) + ?(triggerCharacter : string option) + ~(triggerKind : CompletionTriggerKind.t) + (() : unit) : t = { triggerCharacter; triggerKind } @@ -19738,121 +3641,7 @@ module InsertReplaceEdit = struct ; newText : string ; replace : Range.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InsertReplaceEdit.t" in - function - | `Assoc field_yojsons as yojson -> - let insert_field = ref Ppx_yojson_conv_lib.Option.None - and newText_field = ref Ppx_yojson_conv_lib.Option.None - and replace_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "insert" -> - (match Ppx_yojson_conv_lib.( ! ) insert_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - insert_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "newText" -> - (match Ppx_yojson_conv_lib.( ! ) newText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - newText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "replace" -> - (match Ppx_yojson_conv_lib.( ! ) replace_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - replace_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) insert_field - , Ppx_yojson_conv_lib.( ! ) newText_field - , Ppx_yojson_conv_lib.( ! ) replace_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some insert_value - , Ppx_yojson_conv_lib.Option.Some newText_value - , Ppx_yojson_conv_lib.Option.Some replace_value ) -> - { insert = insert_value - ; newText = newText_value - ; replace = replace_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) insert_field) - Ppx_yojson_conv_lib.Option.None - , "insert" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) newText_field) - Ppx_yojson_conv_lib.Option.None - , "newText" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) replace_field) - Ppx_yojson_conv_lib.Option.None - , "replace" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { insert = v_insert; newText = v_newText; replace = v_replace } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Range.yojson_of_t v_replace in - ("replace", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_newText in - ("newText", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_insert in - ("insert", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(insert : Range.t) ~(newText : string) ~(replace : Range.t) : t = { insert; newText; replace } @@ -19862,108 +3651,10 @@ end module CompletionItemLabelDetails = struct type t = { description : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; detail : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionItemLabelDetails.t" in - function - | `Assoc field_yojsons as yojson -> - let description_field = ref Ppx_yojson_conv_lib.Option.None - and detail_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "description" -> - (match Ppx_yojson_conv_lib.( ! ) description_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - description_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "detail" -> - (match Ppx_yojson_conv_lib.( ! ) detail_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - detail_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let description_value, detail_value = - ( Ppx_yojson_conv_lib.( ! ) description_field - , Ppx_yojson_conv_lib.( ! ) detail_field ) - in - { description = - (match description_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; detail = - (match detail_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { description = v_description; detail = v_detail } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_detail - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_detail in - let bnd = "detail", arg in - bnd :: bnds) - in - let bnds = - if None = v_description - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_description in - let bnd = "description", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(description : string option) ?(detail : string option) (() : unit) : t = { description; detail } @@ -20014,627 +3705,63 @@ module CompletionItem = struct type t = { additionalTextEdits : TextEdit.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; command : Command.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; commitCharacters : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; data : Json.t option [@yojson.option] ; deprecated : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; detail : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; documentation : documentation_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; filterText : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; insertText : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; insertTextFormat : InsertTextFormat.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; insertTextMode : InsertTextMode.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; kind : CompletionItemKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; label : string ; labelDetails : CompletionItemLabelDetails.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; preselect : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; sortText : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; tags : CompletionItemTag.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textEdit : textEdit_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textEditText : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionItem.t" in - function - | `Assoc field_yojsons as yojson -> - let additionalTextEdits_field = ref Ppx_yojson_conv_lib.Option.None - and command_field = ref Ppx_yojson_conv_lib.Option.None - and commitCharacters_field = ref Ppx_yojson_conv_lib.Option.None - and data_field = ref Ppx_yojson_conv_lib.Option.None - and deprecated_field = ref Ppx_yojson_conv_lib.Option.None - and detail_field = ref Ppx_yojson_conv_lib.Option.None - and documentation_field = ref Ppx_yojson_conv_lib.Option.None - and filterText_field = ref Ppx_yojson_conv_lib.Option.None - and insertText_field = ref Ppx_yojson_conv_lib.Option.None - and insertTextFormat_field = ref Ppx_yojson_conv_lib.Option.None - and insertTextMode_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and label_field = ref Ppx_yojson_conv_lib.Option.None - and labelDetails_field = ref Ppx_yojson_conv_lib.Option.None - and preselect_field = ref Ppx_yojson_conv_lib.Option.None - and sortText_field = ref Ppx_yojson_conv_lib.Option.None - and tags_field = ref Ppx_yojson_conv_lib.Option.None - and textEdit_field = ref Ppx_yojson_conv_lib.Option.None - and textEditText_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "additionalTextEdits" -> - (match Ppx_yojson_conv_lib.( ! ) additionalTextEdits_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson TextEdit.t_of_yojson) - _field_yojson - in - additionalTextEdits_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "command" -> - (match Ppx_yojson_conv_lib.( ! ) command_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Command.t_of_yojson _field_yojson - in - command_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "commitCharacters" -> - (match Ppx_yojson_conv_lib.( ! ) commitCharacters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - commitCharacters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "deprecated" -> - (match Ppx_yojson_conv_lib.( ! ) deprecated_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - deprecated_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "detail" -> - (match Ppx_yojson_conv_lib.( ! ) detail_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - detail_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentation" -> - (match Ppx_yojson_conv_lib.( ! ) documentation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - documentation_pvar_of_yojson - _field_yojson - in - documentation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "filterText" -> - (match Ppx_yojson_conv_lib.( ! ) filterText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - filterText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "insertText" -> - (match Ppx_yojson_conv_lib.( ! ) insertText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - insertText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "insertTextFormat" -> - (match Ppx_yojson_conv_lib.( ! ) insertTextFormat_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InsertTextFormat.t_of_yojson - _field_yojson - in - insertTextFormat_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "insertTextMode" -> - (match Ppx_yojson_conv_lib.( ! ) insertTextMode_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InsertTextMode.t_of_yojson - _field_yojson - in - insertTextMode_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CompletionItemKind.t_of_yojson - _field_yojson - in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "label" -> - (match Ppx_yojson_conv_lib.( ! ) label_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - label_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "labelDetails" -> - (match Ppx_yojson_conv_lib.( ! ) labelDetails_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CompletionItemLabelDetails.t_of_yojson - _field_yojson - in - labelDetails_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "preselect" -> - (match Ppx_yojson_conv_lib.( ! ) preselect_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - preselect_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "sortText" -> - (match Ppx_yojson_conv_lib.( ! ) sortText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - sortText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tags" -> - (match Ppx_yojson_conv_lib.( ! ) tags_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson CompletionItemTag.t_of_yojson) - _field_yojson - in - tags_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textEdit" -> - (match Ppx_yojson_conv_lib.( ! ) textEdit_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson textEdit_pvar_of_yojson _field_yojson - in - textEdit_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textEditText" -> - (match Ppx_yojson_conv_lib.( ! ) textEditText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - textEditText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) additionalTextEdits_field - , Ppx_yojson_conv_lib.( ! ) command_field - , Ppx_yojson_conv_lib.( ! ) commitCharacters_field - , Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) deprecated_field - , Ppx_yojson_conv_lib.( ! ) detail_field - , Ppx_yojson_conv_lib.( ! ) documentation_field - , Ppx_yojson_conv_lib.( ! ) filterText_field - , Ppx_yojson_conv_lib.( ! ) insertText_field - , Ppx_yojson_conv_lib.( ! ) insertTextFormat_field - , Ppx_yojson_conv_lib.( ! ) insertTextMode_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) label_field - , Ppx_yojson_conv_lib.( ! ) labelDetails_field - , Ppx_yojson_conv_lib.( ! ) preselect_field - , Ppx_yojson_conv_lib.( ! ) sortText_field - , Ppx_yojson_conv_lib.( ! ) tags_field - , Ppx_yojson_conv_lib.( ! ) textEdit_field - , Ppx_yojson_conv_lib.( ! ) textEditText_field ) - with - | ( additionalTextEdits_value - , command_value - , commitCharacters_value - , data_value - , deprecated_value - , detail_value - , documentation_value - , filterText_value - , insertText_value - , insertTextFormat_value - , insertTextMode_value - , kind_value - , Ppx_yojson_conv_lib.Option.Some label_value - , labelDetails_value - , preselect_value - , sortText_value - , tags_value - , textEdit_value - , textEditText_value ) -> - { additionalTextEdits = - (match additionalTextEdits_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; command = - (match command_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; commitCharacters = - (match commitCharacters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; data = data_value - ; deprecated = - (match deprecated_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; detail = - (match detail_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentation = - (match documentation_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; filterText = - (match filterText_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; insertText = - (match insertText_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; insertTextFormat = - (match insertTextFormat_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; insertTextMode = - (match insertTextMode_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; kind = - (match kind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; label = label_value - ; labelDetails = - (match labelDetails_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; preselect = - (match preselect_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; sortText = - (match sortText_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tags = - (match tags_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textEdit = - (match textEdit_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textEditText = - (match textEditText_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) label_field) - Ppx_yojson_conv_lib.Option.None - , "label" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { additionalTextEdits = v_additionalTextEdits - ; command = v_command - ; commitCharacters = v_commitCharacters - ; data = v_data - ; deprecated = v_deprecated - ; detail = v_detail - ; documentation = v_documentation - ; filterText = v_filterText - ; insertText = v_insertText - ; insertTextFormat = v_insertTextFormat - ; insertTextMode = v_insertTextMode - ; kind = v_kind - ; label = v_label - ; labelDetails = v_labelDetails - ; preselect = v_preselect - ; sortText = v_sortText - ; tags = v_tags - ; textEdit = v_textEdit - ; textEditText = v_textEditText - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_textEditText - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_textEditText in - let bnd = "textEditText", arg in - bnd :: bnds) - in - let bnds = - if None = v_textEdit - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_textEdit_pvar) v_textEdit - in - let bnd = "textEdit", arg in - bnd :: bnds) - in - let bnds = - if None = v_tags - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list CompletionItemTag.yojson_of_t)) - v_tags - in - let bnd = "tags", arg in - bnd :: bnds) - in - let bnds = - if None = v_sortText - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_sortText in - let bnd = "sortText", arg in - bnd :: bnds) - in - let bnds = - if None = v_preselect - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_preselect in - let bnd = "preselect", arg in - bnd :: bnds) - in - let bnds = - if None = v_labelDetails - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CompletionItemLabelDetails.yojson_of_t) - v_labelDetails - in - let bnd = "labelDetails", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_label in - ("label", arg) :: bnds - in - let bnds = - if None = v_kind - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CompletionItemKind.yojson_of_t) v_kind - in - let bnd = "kind", arg in - bnd :: bnds) - in - let bnds = - if None = v_insertTextMode - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t InsertTextMode.yojson_of_t) - v_insertTextMode - in - let bnd = "insertTextMode", arg in - bnd :: bnds) - in - let bnds = - if None = v_insertTextFormat - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t InsertTextFormat.yojson_of_t) - v_insertTextFormat - in - let bnd = "insertTextFormat", arg in - bnd :: bnds) - in - let bnds = - if None = v_insertText - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_insertText in - let bnd = "insertText", arg in - bnd :: bnds) - in - let bnds = - if None = v_filterText - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_filterText in - let bnd = "filterText", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentation - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_documentation_pvar) - v_documentation - in - let bnd = "documentation", arg in - bnd :: bnds) - in - let bnds = - if None = v_detail - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_detail in - let bnd = "detail", arg in - bnd :: bnds) - in - let bnds = - if None = v_deprecated - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_deprecated in - let bnd = "deprecated", arg in - bnd :: bnds) - in - let bnds = - match v_data with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "data", arg in - bnd :: bnds - in - let bnds = - if None = v_commitCharacters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_commitCharacters - in - let bnd = "commitCharacters", arg in - bnd :: bnds) - in - let bnds = - if None = v_command - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Command.yojson_of_t) v_command in - let bnd = "command", arg in - bnd :: bnds) - in - let bnds = - if None = v_additionalTextEdits - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list TextEdit.yojson_of_t)) - v_additionalTextEdits - in - let bnd = "additionalTextEdits", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] - - let create - ?(additionalTextEdits : TextEdit.t list option) - ?(command : Command.t option) - ?(commitCharacters : string list option) - ?(data : Json.t option) - ?(deprecated : bool option) - ?(detail : string option) - ?(documentation : documentation_pvar option) - ?(filterText : string option) - ?(insertText : string option) - ?(insertTextFormat : InsertTextFormat.t option) - ?(insertTextMode : InsertTextMode.t option) - ?(kind : CompletionItemKind.t option) - ~(label : string) - ?(labelDetails : CompletionItemLabelDetails.t option) - ?(preselect : bool option) - ?(sortText : string option) - ?(tags : CompletionItemTag.t list option) - ?(textEdit : textEdit_pvar option) - ?(textEditText : string option) - (() : unit) + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] + + let create + ?(additionalTextEdits : TextEdit.t list option) + ?(command : Command.t option) + ?(commitCharacters : string list option) + ?(data : Json.t option) + ?(deprecated : bool option) + ?(detail : string option) + ?(documentation : documentation_pvar option) + ?(filterText : string option) + ?(insertText : string option) + ?(insertTextFormat : InsertTextFormat.t option) + ?(insertTextMode : InsertTextMode.t option) + ?(kind : CompletionItemKind.t option) + ~(label : string) + ?(labelDetails : CompletionItemLabelDetails.t option) + ?(preselect : bool option) + ?(sortText : string option) + ?(tags : CompletionItemTag.t list option) + ?(textEdit : textEdit_pvar option) + ?(textEditText : string option) + (() : unit) : t = { additionalTextEdits @@ -20665,100 +3792,7 @@ module CompletionList = struct { insert : Range.t ; replace : Range.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : editRange) -> () - - let editRange_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionList.editRange" in - function - | `Assoc field_yojsons as yojson -> - let insert_field = ref Ppx_yojson_conv_lib.Option.None - and replace_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "insert" -> - (match Ppx_yojson_conv_lib.( ! ) insert_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - insert_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "replace" -> - (match Ppx_yojson_conv_lib.( ! ) replace_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - replace_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) insert_field - , Ppx_yojson_conv_lib.( ! ) replace_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some insert_value - , Ppx_yojson_conv_lib.Option.Some replace_value ) -> - { insert = insert_value; replace = replace_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) insert_field) - Ppx_yojson_conv_lib.Option.None - , "insert" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) replace_field) - Ppx_yojson_conv_lib.Option.None - , "replace" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> editRange) - ;; - - let _ = editRange_of_yojson - - let yojson_of_editRange = - (function - | { insert = v_insert; replace = v_replace } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Range.yojson_of_t v_replace in - ("replace", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_insert in - ("insert", arg) :: bnds - in - `Assoc bnds - : editRange -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_editRange - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_editRange ~(insert : Range.t) ~(replace : Range.t) : editRange = { insert; replace } @@ -20786,213 +3820,24 @@ module CompletionList = struct type itemDefaults = { commitCharacters : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; editRange : editRange_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; insertTextFormat : InsertTextFormat.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; insertTextMode : InsertTextMode.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; data : Json.t option [@yojson.option] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : itemDefaults) -> () - - let itemDefaults_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionList.itemDefaults" in - function - | `Assoc field_yojsons as yojson -> - let commitCharacters_field = ref Ppx_yojson_conv_lib.Option.None - and editRange_field = ref Ppx_yojson_conv_lib.Option.None - and insertTextFormat_field = ref Ppx_yojson_conv_lib.Option.None - and insertTextMode_field = ref Ppx_yojson_conv_lib.Option.None - and data_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "commitCharacters" -> - (match Ppx_yojson_conv_lib.( ! ) commitCharacters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - commitCharacters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "editRange" -> - (match Ppx_yojson_conv_lib.( ! ) editRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson editRange_pvar_of_yojson _field_yojson - in - editRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "insertTextFormat" -> - (match Ppx_yojson_conv_lib.( ! ) insertTextFormat_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InsertTextFormat.t_of_yojson - _field_yojson - in - insertTextFormat_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "insertTextMode" -> - (match Ppx_yojson_conv_lib.( ! ) insertTextMode_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InsertTextMode.t_of_yojson - _field_yojson - in - insertTextMode_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( commitCharacters_value - , editRange_value - , insertTextFormat_value - , insertTextMode_value - , data_value ) - = - ( Ppx_yojson_conv_lib.( ! ) commitCharacters_field - , Ppx_yojson_conv_lib.( ! ) editRange_field - , Ppx_yojson_conv_lib.( ! ) insertTextFormat_field - , Ppx_yojson_conv_lib.( ! ) insertTextMode_field - , Ppx_yojson_conv_lib.( ! ) data_field ) - in - { commitCharacters = - (match commitCharacters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; editRange = - (match editRange_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; insertTextFormat = - (match insertTextFormat_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; insertTextMode = - (match insertTextMode_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; data = data_value - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> itemDefaults) - ;; - - let _ = itemDefaults_of_yojson - - let yojson_of_itemDefaults = - (function - | { commitCharacters = v_commitCharacters - ; editRange = v_editRange - ; insertTextFormat = v_insertTextFormat - ; insertTextMode = v_insertTextMode - ; data = v_data - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - match v_data with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "data", arg in - bnd :: bnds - in - let bnds = - if None = v_insertTextMode - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t InsertTextMode.yojson_of_t) - v_insertTextMode - in - let bnd = "insertTextMode", arg in - bnd :: bnds) - in - let bnds = - if None = v_insertTextFormat - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t InsertTextFormat.yojson_of_t) - v_insertTextFormat - in - let bnd = "insertTextFormat", arg in - bnd :: bnds) - in - let bnds = - if None = v_editRange - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_editRange_pvar) v_editRange - in - let bnd = "editRange", arg in - bnd :: bnds) - in - let bnds = - if None = v_commitCharacters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_commitCharacters - in - let bnd = "commitCharacters", arg in - bnd :: bnds) - in - `Assoc bnds - : itemDefaults -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_itemDefaults - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_itemDefaults - ?(commitCharacters : string list option) - ?(editRange : editRange_pvar option) - ?(insertTextFormat : InsertTextFormat.t option) - ?(insertTextMode : InsertTextMode.t option) - ?(data : Json.t option) - (() : unit) + ?(commitCharacters : string list option) + ?(editRange : editRange_pvar option) + ?(insertTextFormat : InsertTextFormat.t option) + ?(insertTextMode : InsertTextMode.t option) + ?(data : Json.t option) + (() : unit) : itemDefaults = { commitCharacters; editRange; insertTextFormat; insertTextMode; data } @@ -21001,138 +3846,16 @@ module CompletionList = struct type t = { isIncomplete : bool ; itemDefaults : itemDefaults Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; items : CompletionItem.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionList.t" in - function - | `Assoc field_yojsons as yojson -> - let isIncomplete_field = ref Ppx_yojson_conv_lib.Option.None - and itemDefaults_field = ref Ppx_yojson_conv_lib.Option.None - and items_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "isIncomplete" -> - (match Ppx_yojson_conv_lib.( ! ) isIncomplete_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - isIncomplete_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "itemDefaults" -> - (match Ppx_yojson_conv_lib.( ! ) itemDefaults_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson itemDefaults_of_yojson _field_yojson - in - itemDefaults_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "items" -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson CompletionItem.t_of_yojson _field_yojson in - items_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) isIncomplete_field - , Ppx_yojson_conv_lib.( ! ) itemDefaults_field - , Ppx_yojson_conv_lib.( ! ) items_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some isIncomplete_value - , itemDefaults_value - , Ppx_yojson_conv_lib.Option.Some items_value ) -> - { isIncomplete = isIncomplete_value - ; itemDefaults = - (match itemDefaults_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; items = items_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) isIncomplete_field) - Ppx_yojson_conv_lib.Option.None - , "isIncomplete" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) items_field) - Ppx_yojson_conv_lib.Option.None - , "items" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { isIncomplete = v_isIncomplete; itemDefaults = v_itemDefaults; items = v_items } - -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list CompletionItem.yojson_of_t v_items in - ("items", arg) :: bnds - in - let bnds = - if None = v_itemDefaults - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_itemDefaults) v_itemDefaults - in - let bnd = "itemDefaults", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_bool v_isIncomplete in - ("isIncomplete", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(isIncomplete : bool) - ?(itemDefaults : itemDefaults option) - ~(items : CompletionItem.t list) - (() : unit) + ~(isIncomplete : bool) + ?(itemDefaults : itemDefaults option) + ~(items : CompletionItem.t list) + (() : unit) : t = { isIncomplete; itemDefaults; items } @@ -21142,86 +3865,9 @@ end module CompletionOptions = struct type completionItem = { labelDetailsSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : completionItem) -> () - - let completionItem_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionOptions.completionItem" in - function - | `Assoc field_yojsons as yojson -> - let labelDetailsSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "labelDetailsSupport" -> - (match Ppx_yojson_conv_lib.( ! ) labelDetailsSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - labelDetailsSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let labelDetailsSupport_value = - Ppx_yojson_conv_lib.( ! ) labelDetailsSupport_field - in - { labelDetailsSupport = - (match labelDetailsSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> completionItem) - ;; - - let _ = completionItem_of_yojson - - let yojson_of_completionItem = - (function - | { labelDetailsSupport = v_labelDetailsSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_labelDetailsSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_labelDetailsSupport - in - let bnd = "labelDetailsSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : completionItem -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_completionItem - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_completionItem ?(labelDetailsSupport : bool option) (() : unit) : completionItem @@ -21231,218 +3877,25 @@ module CompletionOptions = struct type t = { allCommitCharacters : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; completionItem : completionItem Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; triggerCharacters : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let allCommitCharacters_field = ref Ppx_yojson_conv_lib.Option.None - and completionItem_field = ref Ppx_yojson_conv_lib.Option.None - and resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and triggerCharacters_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "allCommitCharacters" -> - (match Ppx_yojson_conv_lib.( ! ) allCommitCharacters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - allCommitCharacters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "completionItem" -> - (match Ppx_yojson_conv_lib.( ! ) completionItem_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson completionItem_of_yojson _field_yojson - in - completionItem_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "triggerCharacters" -> - (match Ppx_yojson_conv_lib.( ! ) triggerCharacters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - triggerCharacters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( allCommitCharacters_value - , completionItem_value - , resolveProvider_value - , triggerCharacters_value - , workDoneProgress_value ) - = - ( Ppx_yojson_conv_lib.( ! ) allCommitCharacters_field - , Ppx_yojson_conv_lib.( ! ) completionItem_field - , Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) triggerCharacters_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { allCommitCharacters = - (match allCommitCharacters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; completionItem = - (match completionItem_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; triggerCharacters = - (match triggerCharacters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { allCommitCharacters = v_allCommitCharacters - ; completionItem = v_completionItem - ; resolveProvider = v_resolveProvider - ; triggerCharacters = v_triggerCharacters - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_triggerCharacters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_triggerCharacters - in - let bnd = "triggerCharacters", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_completionItem - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_completionItem) v_completionItem - in - let bnd = "completionItem", arg in - bnd :: bnds) - in - let bnds = - if None = v_allCommitCharacters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_allCommitCharacters - in - let bnd = "allCommitCharacters", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(allCommitCharacters : string list option) - ?(completionItem : completionItem option) - ?(resolveProvider : bool option) - ?(triggerCharacters : string list option) - ?(workDoneProgress : bool option) - (() : unit) + ?(allCommitCharacters : string list option) + ?(completionItem : completionItem option) + ?(resolveProvider : bool option) + ?(triggerCharacters : string list option) + ?(workDoneProgress : bool option) + (() : unit) : t = { allCommitCharacters @@ -21457,208 +3910,23 @@ end module CompletionParams = struct type t = { context : CompletionContext.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionParams.t" in - function - | `Assoc field_yojsons as yojson -> - let context_field = ref Ppx_yojson_conv_lib.Option.None - and partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "context" -> - (match Ppx_yojson_conv_lib.( ! ) context_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CompletionContext.t_of_yojson - _field_yojson - in - context_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) context_field - , Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( context_value - , partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { context = - (match context_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { context = v_context - ; partialResultToken = v_partialResultToken - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - let bnds = - if None = v_context - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CompletionContext.yojson_of_t) v_context - in - let bnd = "context", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(context : CompletionContext.t option) - ?(partialResultToken : ProgressToken.t option) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(context : CompletionContext.t option) + ?(partialResultToken : ProgressToken.t option) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { context; partialResultToken; position; textDocument; workDoneToken } @@ -21668,86 +3936,9 @@ end module CompletionRegistrationOptions = struct type completionItem = { labelDetailsSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : completionItem) -> () - - let completionItem_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionRegistrationOptions.completionItem" in - function - | `Assoc field_yojsons as yojson -> - let labelDetailsSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "labelDetailsSupport" -> - (match Ppx_yojson_conv_lib.( ! ) labelDetailsSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - labelDetailsSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let labelDetailsSupport_value = - Ppx_yojson_conv_lib.( ! ) labelDetailsSupport_field - in - { labelDetailsSupport = - (match labelDetailsSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> completionItem) - ;; - - let _ = completionItem_of_yojson - - let yojson_of_completionItem = - (function - | { labelDetailsSupport = v_labelDetailsSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_labelDetailsSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_labelDetailsSupport - in - let bnd = "labelDetailsSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : completionItem -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_completionItem - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_completionItem ?(labelDetailsSupport : bool option) (() : unit) : completionItem @@ -21757,251 +3948,28 @@ module CompletionRegistrationOptions = struct type t = { allCommitCharacters : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; completionItem : completionItem Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; triggerCharacters : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CompletionRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let allCommitCharacters_field = ref Ppx_yojson_conv_lib.Option.None - and completionItem_field = ref Ppx_yojson_conv_lib.Option.None - and documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and triggerCharacters_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "allCommitCharacters" -> - (match Ppx_yojson_conv_lib.( ! ) allCommitCharacters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - allCommitCharacters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "completionItem" -> - (match Ppx_yojson_conv_lib.( ! ) completionItem_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson completionItem_of_yojson _field_yojson - in - completionItem_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "triggerCharacters" -> - (match Ppx_yojson_conv_lib.( ! ) triggerCharacters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - triggerCharacters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( allCommitCharacters_value - , completionItem_value - , documentSelector_value - , resolveProvider_value - , triggerCharacters_value - , workDoneProgress_value ) - = - ( Ppx_yojson_conv_lib.( ! ) allCommitCharacters_field - , Ppx_yojson_conv_lib.( ! ) completionItem_field - , Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) triggerCharacters_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { allCommitCharacters = - (match allCommitCharacters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; completionItem = - (match completionItem_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; triggerCharacters = - (match triggerCharacters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { allCommitCharacters = v_allCommitCharacters - ; completionItem = v_completionItem - ; documentSelector = v_documentSelector - ; resolveProvider = v_resolveProvider - ; triggerCharacters = v_triggerCharacters - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_triggerCharacters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_triggerCharacters - in - let bnd = "triggerCharacters", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - let bnds = - if None = v_completionItem - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_completionItem) v_completionItem - in - let bnd = "completionItem", arg in - bnd :: bnds) - in - let bnds = - if None = v_allCommitCharacters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_allCommitCharacters - in - let bnd = "allCommitCharacters", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(allCommitCharacters : string list option) - ?(completionItem : completionItem option) - ?(documentSelector : DocumentSelector.t option) - ?(resolveProvider : bool option) - ?(triggerCharacters : string list option) - ?(workDoneProgress : bool option) - (() : unit) + ?(allCommitCharacters : string list option) + ?(completionItem : completionItem option) + ?(documentSelector : DocumentSelector.t option) + ?(resolveProvider : bool option) + ?(triggerCharacters : string list option) + ?(workDoneProgress : bool option) + (() : unit) : t = { allCommitCharacters @@ -22017,110 +3985,10 @@ end module ConfigurationItem = struct type t = { scopeUri : DocumentUri.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; section : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ConfigurationItem.t" in - function - | `Assoc field_yojsons as yojson -> - let scopeUri_field = ref Ppx_yojson_conv_lib.Option.None - and section_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "scopeUri" -> - (match Ppx_yojson_conv_lib.( ! ) scopeUri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson DocumentUri.t_of_yojson _field_yojson - in - scopeUri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "section" -> - (match Ppx_yojson_conv_lib.( ! ) section_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - section_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let scopeUri_value, section_value = - ( Ppx_yojson_conv_lib.( ! ) scopeUri_field - , Ppx_yojson_conv_lib.( ! ) section_field ) - in - { scopeUri = - (match scopeUri_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; section = - (match section_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { scopeUri = v_scopeUri; section = v_section } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_section - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_section in - let bnd = "section", arg in - bnd :: bnds) - in - let bnds = - if None = v_scopeUri - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentUri.yojson_of_t) v_scopeUri - in - let bnd = "scopeUri", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(scopeUri : DocumentUri.t option) ?(section : string option) (() : unit) : t = @@ -22130,238 +3998,19 @@ end module ConfigurationParams = struct type t = { items : ConfigurationItem.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ConfigurationParams.t" in - function - | `Assoc field_yojsons as yojson -> - let items_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "items" -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson ConfigurationItem.t_of_yojson _field_yojson - in - items_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.Some items_value -> { items = items_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) items_field) - Ppx_yojson_conv_lib.Option.None - , "items" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { items = v_items } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list ConfigurationItem.yojson_of_t v_items in - ("items", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(items : ConfigurationItem.t list) : t = { items } end module FileCreate = struct - type t = { uri : string } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileCreate.t" in - function - | `Assoc field_yojsons as yojson -> - let uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.Some uri_value -> { uri = uri_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { uri = v_uri } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_uri in - ("uri", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { uri : string } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(uri : string) : t = { uri } end module CreateFilesParams = struct - type t = { files : FileCreate.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.CreateFilesParams.t" in - function - | `Assoc field_yojsons as yojson -> - let files_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "files" -> - (match Ppx_yojson_conv_lib.( ! ) files_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson FileCreate.t_of_yojson _field_yojson in - files_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) files_field with - | Ppx_yojson_conv_lib.Option.Some files_value -> { files = files_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) files_field) - Ppx_yojson_conv_lib.Option.None - , "files" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { files = v_files } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list FileCreate.yojson_of_t v_files in - ("files", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { files : FileCreate.t list } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(files : FileCreate.t list) : t = { files } end @@ -22391,163 +4040,19 @@ end module LocationLink = struct type t = { originSelectionRange : Range.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; targetRange : Range.t ; targetSelectionRange : Range.t ; targetUri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.LocationLink.t" in - function - | `Assoc field_yojsons as yojson -> - let originSelectionRange_field = ref Ppx_yojson_conv_lib.Option.None - and targetRange_field = ref Ppx_yojson_conv_lib.Option.None - and targetSelectionRange_field = ref Ppx_yojson_conv_lib.Option.None - and targetUri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "originSelectionRange" -> - (match Ppx_yojson_conv_lib.( ! ) originSelectionRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Range.t_of_yojson _field_yojson - in - originSelectionRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "targetRange" -> - (match Ppx_yojson_conv_lib.( ! ) targetRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - targetRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "targetSelectionRange" -> - (match Ppx_yojson_conv_lib.( ! ) targetSelectionRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - targetSelectionRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "targetUri" -> - (match Ppx_yojson_conv_lib.( ! ) targetUri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - targetUri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) originSelectionRange_field - , Ppx_yojson_conv_lib.( ! ) targetRange_field - , Ppx_yojson_conv_lib.( ! ) targetSelectionRange_field - , Ppx_yojson_conv_lib.( ! ) targetUri_field ) - with - | ( originSelectionRange_value - , Ppx_yojson_conv_lib.Option.Some targetRange_value - , Ppx_yojson_conv_lib.Option.Some targetSelectionRange_value - , Ppx_yojson_conv_lib.Option.Some targetUri_value ) -> - { originSelectionRange = - (match originSelectionRange_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; targetRange = targetRange_value - ; targetSelectionRange = targetSelectionRange_value - ; targetUri = targetUri_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) targetRange_field) - Ppx_yojson_conv_lib.Option.None - , "targetRange" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) targetSelectionRange_field) - Ppx_yojson_conv_lib.Option.None - , "targetSelectionRange" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) targetUri_field) - Ppx_yojson_conv_lib.Option.None - , "targetUri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { originSelectionRange = v_originSelectionRange - ; targetRange = v_targetRange - ; targetSelectionRange = v_targetSelectionRange - ; targetUri = v_targetUri - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_targetUri in - ("targetUri", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_targetSelectionRange in - ("targetSelectionRange", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_targetRange in - ("targetRange", arg) :: bnds - in - let bnds = - if None = v_originSelectionRange - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t Range.yojson_of_t) v_originSelectionRange - in - let bnd = "originSelectionRange", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(originSelectionRange : Range.t option) - ~(targetRange : Range.t) - ~(targetSelectionRange : Range.t) - ~(targetUri : DocumentUri.t) - (() : unit) + ?(originSelectionRange : Range.t option) + ~(targetRange : Range.t) + ~(targetSelectionRange : Range.t) + ~(targetUri : DocumentUri.t) + (() : unit) : t = { originSelectionRange; targetRange; targetSelectionRange; targetUri } @@ -22555,100 +4060,15 @@ module LocationLink = struct end module DeclarationLink = struct - type t = LocationLink.t [@@deriving_inline yojson] - - let _ = fun (_ : t) -> () - let t_of_yojson = (LocationLink.t_of_yojson : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - let _ = t_of_yojson - let yojson_of_t = (LocationLink.yojson_of_t : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - let _ = yojson_of_t - - [@@@end] + type t = LocationLink.t [@@deriving yojson] end module DeclarationOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DeclarationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -22656,176 +4076,20 @@ end module DeclarationParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DeclarationParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; position; textDocument; workDoneToken } @@ -22835,149 +4099,18 @@ end module DeclarationRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DeclarationRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -23007,100 +4140,15 @@ module Definition = struct end module DefinitionLink = struct - type t = LocationLink.t [@@deriving_inline yojson] - - let _ = fun (_ : t) -> () - let t_of_yojson = (LocationLink.t_of_yojson : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - let _ = t_of_yojson - let yojson_of_t = (LocationLink.yojson_of_t : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - let _ = yojson_of_t - - [@@@end] + type t = LocationLink.t [@@deriving yojson] end module DefinitionOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DefinitionOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -23108,176 +4156,20 @@ end module DefinitionParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DefinitionParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; position; textDocument; workDoneToken } @@ -23287,121 +4179,16 @@ end module DefinitionRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DefinitionRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; workDoneProgress } @@ -23409,158 +4196,13 @@ module DefinitionRegistrationOptions = struct end module FileDelete = struct - type t = { uri : string } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileDelete.t" in - function - | `Assoc field_yojsons as yojson -> - let uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.Some uri_value -> { uri = uri_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { uri = v_uri } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_uri in - ("uri", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { uri : string } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(uri : string) : t = { uri } end module DeleteFilesParams = struct - type t = { files : FileDelete.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DeleteFilesParams.t" in - function - | `Assoc field_yojsons as yojson -> - let files_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "files" -> - (match Ppx_yojson_conv_lib.( ! ) files_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson FileDelete.t_of_yojson _field_yojson in - files_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) files_field with - | Ppx_yojson_conv_lib.Option.Some files_value -> { files = files_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) files_field) - Ppx_yojson_conv_lib.Option.None - , "files" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { files = v_files } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list FileDelete.yojson_of_t v_files in - ("files", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { files : FileDelete.t list } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(files : FileDelete.t list) : t = { files } end @@ -23568,169 +4210,20 @@ end module DiagnosticOptions = struct type t = { identifier : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; interFileDependencies : bool ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workspaceDiagnostics : bool } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DiagnosticOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let identifier_field = ref Ppx_yojson_conv_lib.Option.None - and interFileDependencies_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and workspaceDiagnostics_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "identifier" -> - (match Ppx_yojson_conv_lib.( ! ) identifier_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - identifier_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "interFileDependencies" -> - (match Ppx_yojson_conv_lib.( ! ) interFileDependencies_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - interFileDependencies_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workspaceDiagnostics" -> - (match Ppx_yojson_conv_lib.( ! ) workspaceDiagnostics_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - workspaceDiagnostics_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) identifier_field - , Ppx_yojson_conv_lib.( ! ) interFileDependencies_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - , Ppx_yojson_conv_lib.( ! ) workspaceDiagnostics_field ) - with - | ( identifier_value - , Ppx_yojson_conv_lib.Option.Some interFileDependencies_value - , workDoneProgress_value - , Ppx_yojson_conv_lib.Option.Some workspaceDiagnostics_value ) -> - { identifier = - (match identifier_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; interFileDependencies = interFileDependencies_value - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workspaceDiagnostics = workspaceDiagnostics_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) interFileDependencies_field) - Ppx_yojson_conv_lib.Option.None - , "interFileDependencies" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) workspaceDiagnostics_field) - Ppx_yojson_conv_lib.Option.None - , "workspaceDiagnostics" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { identifier = v_identifier - ; interFileDependencies = v_interFileDependencies - ; workDoneProgress = v_workDoneProgress - ; workspaceDiagnostics = v_workspaceDiagnostics - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_workspaceDiagnostics in - ("workspaceDiagnostics", arg) :: bnds - in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_bool v_interFileDependencies in - ("interFileDependencies", arg) :: bnds - in - let bnds = - if None = v_identifier - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_identifier in - let bnd = "identifier", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(identifier : string option) - ~(interFileDependencies : bool) - ?(workDoneProgress : bool option) - ~(workspaceDiagnostics : bool) - (() : unit) + ?(identifier : string option) + ~(interFileDependencies : bool) + ?(workDoneProgress : bool option) + ~(workspaceDiagnostics : bool) + (() : unit) : t = { identifier; interFileDependencies; workDoneProgress; workspaceDiagnostics } @@ -23740,229 +4233,25 @@ end module DiagnosticRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; identifier : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; interFileDependencies : bool ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workspaceDiagnostics : bool } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DiagnosticRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and identifier_field = ref Ppx_yojson_conv_lib.Option.None - and interFileDependencies_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and workspaceDiagnostics_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "identifier" -> - (match Ppx_yojson_conv_lib.( ! ) identifier_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - identifier_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "interFileDependencies" -> - (match Ppx_yojson_conv_lib.( ! ) interFileDependencies_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - interFileDependencies_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workspaceDiagnostics" -> - (match Ppx_yojson_conv_lib.( ! ) workspaceDiagnostics_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - workspaceDiagnostics_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) identifier_field - , Ppx_yojson_conv_lib.( ! ) interFileDependencies_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - , Ppx_yojson_conv_lib.( ! ) workspaceDiagnostics_field ) - with - | ( documentSelector_value - , id_value - , identifier_value - , Ppx_yojson_conv_lib.Option.Some interFileDependencies_value - , workDoneProgress_value - , Ppx_yojson_conv_lib.Option.Some workspaceDiagnostics_value ) -> - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; identifier = - (match identifier_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; interFileDependencies = interFileDependencies_value - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workspaceDiagnostics = workspaceDiagnostics_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) interFileDependencies_field) - Ppx_yojson_conv_lib.Option.None - , "interFileDependencies" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) workspaceDiagnostics_field) - Ppx_yojson_conv_lib.Option.None - , "workspaceDiagnostics" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; identifier = v_identifier - ; interFileDependencies = v_interFileDependencies - ; workDoneProgress = v_workDoneProgress - ; workspaceDiagnostics = v_workspaceDiagnostics - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_workspaceDiagnostics in - ("workspaceDiagnostics", arg) :: bnds - in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_bool v_interFileDependencies in - ("interFileDependencies", arg) :: bnds - in - let bnds = - if None = v_identifier - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_identifier in - let bnd = "identifier", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(identifier : string option) - ~(interFileDependencies : bool) - ?(workDoneProgress : bool option) - ~(workspaceDiagnostics : bool) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(identifier : string option) + ~(interFileDependencies : bool) + ?(workDoneProgress : bool option) + ~(workspaceDiagnostics : bool) + (() : unit) : t = { documentSelector @@ -23976,160 +4265,13 @@ module DiagnosticRegistrationOptions = struct end module DiagnosticServerCancellationData = struct - type t = { retriggerRequest : bool } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DiagnosticServerCancellationData.t" in - function - | `Assoc field_yojsons as yojson -> - let retriggerRequest_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "retriggerRequest" -> - (match Ppx_yojson_conv_lib.( ! ) retriggerRequest_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - retriggerRequest_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) retriggerRequest_field with - | Ppx_yojson_conv_lib.Option.Some retriggerRequest_value -> - { retriggerRequest = retriggerRequest_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) retriggerRequest_field) - Ppx_yojson_conv_lib.Option.None - , "retriggerRequest" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { retriggerRequest = v_retriggerRequest } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_retriggerRequest in - ("retriggerRequest", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { retriggerRequest : bool } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(retriggerRequest : bool) : t = { retriggerRequest } end module DidChangeConfigurationParams = struct - type t = { settings : Json.t } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidChangeConfigurationParams.t" in - function - | `Assoc field_yojsons as yojson -> - let settings_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "settings" -> - (match Ppx_yojson_conv_lib.( ! ) settings_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - settings_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) settings_field with - | Ppx_yojson_conv_lib.Option.Some settings_value -> - { settings = settings_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) settings_field) - Ppx_yojson_conv_lib.Option.None - , "settings" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { settings = v_settings } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Json.yojson_of_t v_settings in - ("settings", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { settings : Json.t } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(settings : Json.t) : t = { settings } end @@ -24158,84 +4300,9 @@ module DidChangeConfigurationRegistrationOptions = struct type t = { section : section_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidChangeConfigurationRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let section_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "section" -> - (match Ppx_yojson_conv_lib.( ! ) section_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson section_pvar_of_yojson _field_yojson - in - section_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let section_value = Ppx_yojson_conv_lib.( ! ) section_field in - { section = - (match section_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { section = v_section } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_section - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_section_pvar) v_section - in - let bnd = "section", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(section : section_pvar option) (() : unit) : t = { section } end @@ -24245,100 +4312,7 @@ module VersionedNotebookDocumentIdentifier = struct { uri : DocumentUri.t ; version : int } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.VersionedNotebookDocumentIdentifier.t" in - function - | `Assoc field_yojsons as yojson -> - let uri_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) uri_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some uri_value - , Ppx_yojson_conv_lib.Option.Some version_value ) -> - { uri = uri_value; version = version_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) version_field) - Ppx_yojson_conv_lib.Option.None - , "version" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { uri = v_uri; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_int v_version in - ("version", arg) :: bnds - in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(uri : DocumentUri.t) ~(version : int) : t = { uri; version } end @@ -24347,139 +4321,16 @@ module TextDocumentContentChangeEvent = struct type t = { range : Range.t Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; rangeLength : int Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; text : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentContentChangeEvent.t" in - function - | `Assoc field_yojsons as yojson -> - let range_field = ref Ppx_yojson_conv_lib.Option.None - and rangeLength_field = ref Ppx_yojson_conv_lib.Option.None - and text_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Range.t_of_yojson _field_yojson - in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "rangeLength" -> - (match Ppx_yojson_conv_lib.( ! ) rangeLength_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - rangeLength_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "text" -> - (match Ppx_yojson_conv_lib.( ! ) text_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - text_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) rangeLength_field - , Ppx_yojson_conv_lib.( ! ) text_field ) - with - | range_value, rangeLength_value, Ppx_yojson_conv_lib.Option.Some text_value - -> - { range = - (match range_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; rangeLength = - (match rangeLength_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; text = text_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) text_field) - Ppx_yojson_conv_lib.Option.None - , "text" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { range = v_range; rangeLength = v_rangeLength; text = v_text } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_text in - ("text", arg) :: bnds - in - let bnds = - if None = v_rangeLength - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_rangeLength in - let bnd = "rangeLength", arg in - bnd :: bnds) - in - let bnds = - if None = v_range - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Range.yojson_of_t) v_range in - let bnd = "range", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(range : Range.t option) - ?(rangeLength : int option) - ~(text : string) - (() : unit) + ?(range : Range.t option) + ?(rangeLength : int option) + ~(text : string) + (() : unit) : t = { range; rangeLength; text } @@ -24491,100 +4342,7 @@ module VersionedTextDocumentIdentifier = struct { uri : DocumentUri.t ; version : int } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.VersionedTextDocumentIdentifier.t" in - function - | `Assoc field_yojsons as yojson -> - let uri_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) uri_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some uri_value - , Ppx_yojson_conv_lib.Option.Some version_value ) -> - { uri = uri_value; version = version_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) version_field) - Ppx_yojson_conv_lib.Option.None - , "version" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { uri = v_uri; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_int v_version in - ("version", arg) :: bnds - in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(uri : DocumentUri.t) ~(version : int) : t = { uri; version } end @@ -24594,106 +4352,7 @@ module ExecutionSummary = struct { executionOrder : int ; success : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ExecutionSummary.t" in - function - | `Assoc field_yojsons as yojson -> - let executionOrder_field = ref Ppx_yojson_conv_lib.Option.None - and success_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "executionOrder" -> - (match Ppx_yojson_conv_lib.( ! ) executionOrder_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - executionOrder_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "success" -> - (match Ppx_yojson_conv_lib.( ! ) success_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - success_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) executionOrder_field - , Ppx_yojson_conv_lib.( ! ) success_field ) - with - | Ppx_yojson_conv_lib.Option.Some executionOrder_value, success_value -> - { executionOrder = executionOrder_value - ; success = - (match success_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) executionOrder_field) - Ppx_yojson_conv_lib.Option.None - , "executionOrder" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { executionOrder = v_executionOrder; success = v_success } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_success - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_success in - let bnd = "success", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_int v_executionOrder in - ("executionOrder", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(executionOrder : int) ?(success : bool option) (() : unit) : t = { executionOrder; success } @@ -24704,173 +4363,19 @@ module NotebookCell = struct type t = { document : DocumentUri.t ; executionSummary : ExecutionSummary.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; kind : NotebookCellKind.t ; metadata : Json.Object.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookCell.t" in - function - | `Assoc field_yojsons as yojson -> - let document_field = ref Ppx_yojson_conv_lib.Option.None - and executionSummary_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and metadata_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "document" -> - (match Ppx_yojson_conv_lib.( ! ) document_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - document_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "executionSummary" -> - (match Ppx_yojson_conv_lib.( ! ) executionSummary_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ExecutionSummary.t_of_yojson - _field_yojson - in - executionSummary_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = NotebookCellKind.t_of_yojson _field_yojson in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "metadata" -> - (match Ppx_yojson_conv_lib.( ! ) metadata_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Json.Object.t_of_yojson _field_yojson - in - metadata_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) document_field - , Ppx_yojson_conv_lib.( ! ) executionSummary_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) metadata_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some document_value - , executionSummary_value - , Ppx_yojson_conv_lib.Option.Some kind_value - , metadata_value ) -> - { document = document_value - ; executionSummary = - (match executionSummary_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; kind = kind_value - ; metadata = - (match metadata_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) document_field) - Ppx_yojson_conv_lib.Option.None - , "document" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) kind_field) - Ppx_yojson_conv_lib.Option.None - , "kind" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { document = v_document - ; executionSummary = v_executionSummary - ; kind = v_kind - ; metadata = v_metadata - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_metadata - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t Json.Object.yojson_of_t) v_metadata - in - let bnd = "metadata", arg in - bnd :: bnds) - in - let bnds = - let arg = NotebookCellKind.yojson_of_t v_kind in - ("kind", arg) :: bnds - in - let bnds = - if None = v_executionSummary - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ExecutionSummary.yojson_of_t) - v_executionSummary - in - let bnd = "executionSummary", arg in - bnd :: bnds) - in - let bnds = - let arg = DocumentUri.yojson_of_t v_document in - ("document", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(document : DocumentUri.t) - ?(executionSummary : ExecutionSummary.t option) - ~(kind : NotebookCellKind.t) - ?(metadata : Json.Object.t option) - (() : unit) + ~(document : DocumentUri.t) + ?(executionSummary : ExecutionSummary.t option) + ~(kind : NotebookCellKind.t) + ?(metadata : Json.Object.t option) + (() : unit) : t = { document; executionSummary; kind; metadata } @@ -24884,146 +4389,13 @@ module TextDocumentItem = struct ; uri : DocumentUri.t ; version : int } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentItem.t" in - function - | `Assoc field_yojsons as yojson -> - let languageId_field = ref Ppx_yojson_conv_lib.Option.None - and text_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "languageId" -> - (match Ppx_yojson_conv_lib.( ! ) languageId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - languageId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "text" -> - (match Ppx_yojson_conv_lib.( ! ) text_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - text_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) languageId_field - , Ppx_yojson_conv_lib.( ! ) text_field - , Ppx_yojson_conv_lib.( ! ) uri_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some languageId_value - , Ppx_yojson_conv_lib.Option.Some text_value - , Ppx_yojson_conv_lib.Option.Some uri_value - , Ppx_yojson_conv_lib.Option.Some version_value ) -> - { languageId = languageId_value - ; text = text_value - ; uri = uri_value - ; version = version_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) languageId_field) - Ppx_yojson_conv_lib.Option.None - , "languageId" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) text_field) - Ppx_yojson_conv_lib.Option.None - , "text" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) version_field) - Ppx_yojson_conv_lib.Option.None - , "version" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { languageId = v_languageId; text = v_text; uri = v_uri; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_int v_version in - ("version", arg) :: bnds - in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_text in - ("text", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_languageId in - ("languageId", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(languageId : string) - ~(text : string) - ~(uri : DocumentUri.t) - ~(version : int) + ~(languageId : string) + ~(text : string) + ~(uri : DocumentUri.t) + ~(version : int) : t = { languageId; text; uri; version } @@ -25033,141 +4405,17 @@ end module NotebookCellArrayChange = struct type t = { cells : NotebookCell.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; deleteCount : int ; start : int } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookCellArrayChange.t" in - function - | `Assoc field_yojsons as yojson -> - let cells_field = ref Ppx_yojson_conv_lib.Option.None - and deleteCount_field = ref Ppx_yojson_conv_lib.Option.None - and start_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "cells" -> - (match Ppx_yojson_conv_lib.( ! ) cells_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson NotebookCell.t_of_yojson) - _field_yojson - in - cells_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "deleteCount" -> - (match Ppx_yojson_conv_lib.( ! ) deleteCount_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - deleteCount_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "start" -> - (match Ppx_yojson_conv_lib.( ! ) start_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - start_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) cells_field - , Ppx_yojson_conv_lib.( ! ) deleteCount_field - , Ppx_yojson_conv_lib.( ! ) start_field ) - with - | ( cells_value - , Ppx_yojson_conv_lib.Option.Some deleteCount_value - , Ppx_yojson_conv_lib.Option.Some start_value ) -> - { cells = - (match cells_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; deleteCount = deleteCount_value - ; start = start_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) deleteCount_field) - Ppx_yojson_conv_lib.Option.None - , "deleteCount" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) start_field) - Ppx_yojson_conv_lib.Option.None - , "start" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { cells = v_cells; deleteCount = v_deleteCount; start = v_start } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_int v_start in - ("start", arg) :: bnds - in - let bnds = - let arg = yojson_of_int v_deleteCount in - ("deleteCount", arg) :: bnds - in - let bnds = - if None = v_cells - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list NotebookCell.yojson_of_t)) - v_cells - in - let bnd = "cells", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(cells : NotebookCell.t list option) - ~(deleteCount : int) - ~(start : int) - (() : unit) + ?(cells : NotebookCell.t list option) + ~(deleteCount : int) + ~(start : int) + (() : unit) : t = { cells; deleteCount; start } @@ -25179,106 +4427,11 @@ module NotebookDocumentChangeEvent = struct { document : VersionedTextDocumentIdentifier.t ; changes : TextDocumentContentChangeEvent.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : textContent) -> () - - let textContent_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookDocumentChangeEvent.textContent" in - function - | `Assoc field_yojsons as yojson -> - let document_field = ref Ppx_yojson_conv_lib.Option.None - and changes_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "document" -> - (match Ppx_yojson_conv_lib.( ! ) document_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = VersionedTextDocumentIdentifier.t_of_yojson _field_yojson in - document_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "changes" -> - (match Ppx_yojson_conv_lib.( ! ) changes_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson TextDocumentContentChangeEvent.t_of_yojson _field_yojson - in - changes_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) document_field - , Ppx_yojson_conv_lib.( ! ) changes_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some document_value - , Ppx_yojson_conv_lib.Option.Some changes_value ) -> - { document = document_value; changes = changes_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) document_field) - Ppx_yojson_conv_lib.Option.None - , "document" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) changes_field) - Ppx_yojson_conv_lib.Option.None - , "changes" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> textContent) - ;; - - let _ = textContent_of_yojson - - let yojson_of_textContent = - (function - | { document = v_document; changes = v_changes } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list TextDocumentContentChangeEvent.yojson_of_t v_changes in - ("changes", arg) :: bnds - in - let bnds = - let arg = VersionedTextDocumentIdentifier.yojson_of_t v_document in - ("document", arg) :: bnds - in - `Assoc bnds - : textContent -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_textContent - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_textContent - ~(document : VersionedTextDocumentIdentifier.t) - ~(changes : TextDocumentContentChangeEvent.t list) + ~(document : VersionedTextDocumentIdentifier.t) + ~(changes : TextDocumentContentChangeEvent.t list) : textContent = { document; changes } @@ -25287,152 +4440,17 @@ module NotebookDocumentChangeEvent = struct type structure = { array : NotebookCellArrayChange.t ; didOpen : TextDocumentItem.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; didClose : TextDocumentIdentifier.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : structure) -> () - - let structure_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookDocumentChangeEvent.structure" in - function - | `Assoc field_yojsons as yojson -> - let array_field = ref Ppx_yojson_conv_lib.Option.None - and didOpen_field = ref Ppx_yojson_conv_lib.Option.None - and didClose_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "array" -> - (match Ppx_yojson_conv_lib.( ! ) array_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = NotebookCellArrayChange.t_of_yojson _field_yojson in - array_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "didOpen" -> - (match Ppx_yojson_conv_lib.( ! ) didOpen_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson TextDocumentItem.t_of_yojson) - _field_yojson - in - didOpen_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "didClose" -> - (match Ppx_yojson_conv_lib.( ! ) didClose_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson TextDocumentIdentifier.t_of_yojson) - _field_yojson - in - didClose_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) array_field - , Ppx_yojson_conv_lib.( ! ) didOpen_field - , Ppx_yojson_conv_lib.( ! ) didClose_field ) - with - | Ppx_yojson_conv_lib.Option.Some array_value, didOpen_value, didClose_value - -> - { array = array_value - ; didOpen = - (match didOpen_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; didClose = - (match didClose_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) array_field) - Ppx_yojson_conv_lib.Option.None - , "array" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> structure) - ;; - - let _ = structure_of_yojson - - let yojson_of_structure = - (function - | { array = v_array; didOpen = v_didOpen; didClose = v_didClose } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_didClose - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list TextDocumentIdentifier.yojson_of_t)) - v_didClose - in - let bnd = "didClose", arg in - bnd :: bnds) - in - let bnds = - if None = v_didOpen - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list TextDocumentItem.yojson_of_t)) - v_didOpen - in - let bnd = "didOpen", arg in - bnd :: bnds) - in - let bnds = - let arg = NotebookCellArrayChange.yojson_of_t v_array in - ("array", arg) :: bnds - in - `Assoc bnds - : structure -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_structure - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_structure - ~(array : NotebookCellArrayChange.t) - ?(didOpen : TextDocumentItem.t list option) - ?(didClose : TextDocumentIdentifier.t list option) - (() : unit) + ~(array : NotebookCellArrayChange.t) + ?(didOpen : TextDocumentItem.t list option) + ?(didClose : TextDocumentIdentifier.t list option) + (() : unit) : structure = { array; didOpen; didClose } @@ -25440,150 +4458,19 @@ module NotebookDocumentChangeEvent = struct type cells = { structure : structure Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; data : NotebookCell.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textContent : textContent list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : cells) -> () - - let cells_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookDocumentChangeEvent.cells" in - function - | `Assoc field_yojsons as yojson -> - let structure_field = ref Ppx_yojson_conv_lib.Option.None - and data_field = ref Ppx_yojson_conv_lib.Option.None - and textContent_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "structure" -> - (match Ppx_yojson_conv_lib.( ! ) structure_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson structure_of_yojson _field_yojson - in - structure_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson NotebookCell.t_of_yojson) - _field_yojson - in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textContent" -> - (match Ppx_yojson_conv_lib.( ! ) textContent_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson textContent_of_yojson) - _field_yojson - in - textContent_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let structure_value, data_value, textContent_value = - ( Ppx_yojson_conv_lib.( ! ) structure_field - , Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) textContent_field ) - in - { structure = - (match structure_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; data = - (match data_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textContent = - (match textContent_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> cells) - ;; - - let _ = cells_of_yojson - - let yojson_of_cells = - (function - | { structure = v_structure; data = v_data; textContent = v_textContent } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_textContent - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_textContent)) - v_textContent - in - let bnd = "textContent", arg in - bnd :: bnds) - in - let bnds = - if None = v_data - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list NotebookCell.yojson_of_t)) - v_data - in - let bnd = "data", arg in - bnd :: bnds) - in - let bnds = - if None = v_structure - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_structure) v_structure in - let bnd = "structure", arg in - bnd :: bnds) - in - `Assoc bnds - : cells -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_cells - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_cells - ?(structure : structure option) - ?(data : NotebookCell.t list option) - ?(textContent : textContent list option) - (() : unit) + ?(structure : structure option) + ?(data : NotebookCell.t list option) + ?(textContent : textContent list option) + (() : unit) : cells = { structure; data; textContent } @@ -25592,109 +4479,9 @@ module NotebookDocumentChangeEvent = struct type t = { cells : cells Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; metadata : Json.Object.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookDocumentChangeEvent.t" in - function - | `Assoc field_yojsons as yojson -> - let cells_field = ref Ppx_yojson_conv_lib.Option.None - and metadata_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "cells" -> - (match Ppx_yojson_conv_lib.( ! ) cells_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson cells_of_yojson _field_yojson - in - cells_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "metadata" -> - (match Ppx_yojson_conv_lib.( ! ) metadata_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Json.Object.t_of_yojson _field_yojson - in - metadata_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let cells_value, metadata_value = - ( Ppx_yojson_conv_lib.( ! ) cells_field - , Ppx_yojson_conv_lib.( ! ) metadata_field ) - in - { cells = - (match cells_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; metadata = - (match metadata_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { cells = v_cells; metadata = v_metadata } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_metadata - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t Json.Object.yojson_of_t) v_metadata - in - let bnd = "metadata", arg in - bnd :: bnds) - in - let bnds = - if None = v_cells - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_cells) v_cells in - let bnd = "cells", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(cells : cells option) ?(metadata : Json.Object.t option) (() : unit) : t = { cells; metadata } @@ -25706,106 +4493,11 @@ module DidChangeNotebookDocumentParams = struct { change : NotebookDocumentChangeEvent.t ; notebookDocument : VersionedNotebookDocumentIdentifier.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidChangeNotebookDocumentParams.t" in - function - | `Assoc field_yojsons as yojson -> - let change_field = ref Ppx_yojson_conv_lib.Option.None - and notebookDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "change" -> - (match Ppx_yojson_conv_lib.( ! ) change_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = NotebookDocumentChangeEvent.t_of_yojson _field_yojson in - change_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "notebookDocument" -> - (match Ppx_yojson_conv_lib.( ! ) notebookDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - VersionedNotebookDocumentIdentifier.t_of_yojson _field_yojson - in - notebookDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) change_field - , Ppx_yojson_conv_lib.( ! ) notebookDocument_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some change_value - , Ppx_yojson_conv_lib.Option.Some notebookDocument_value ) -> - { change = change_value; notebookDocument = notebookDocument_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) change_field) - Ppx_yojson_conv_lib.Option.None - , "change" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) notebookDocument_field) - Ppx_yojson_conv_lib.Option.None - , "notebookDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { change = v_change; notebookDocument = v_notebookDocument } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = VersionedNotebookDocumentIdentifier.yojson_of_t v_notebookDocument in - ("notebookDocument", arg) :: bnds - in - let bnds = - let arg = NotebookDocumentChangeEvent.yojson_of_t v_change in - ("change", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(change : NotebookDocumentChangeEvent.t) - ~(notebookDocument : VersionedNotebookDocumentIdentifier.t) + ~(change : NotebookDocumentChangeEvent.t) + ~(notebookDocument : VersionedNotebookDocumentIdentifier.t) : t = { change; notebookDocument } @@ -25817,110 +4509,11 @@ module DidChangeTextDocumentParams = struct { contentChanges : TextDocumentContentChangeEvent.t list ; textDocument : VersionedTextDocumentIdentifier.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidChangeTextDocumentParams.t" in - function - | `Assoc field_yojsons as yojson -> - let contentChanges_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "contentChanges" -> - (match Ppx_yojson_conv_lib.( ! ) contentChanges_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson TextDocumentContentChangeEvent.t_of_yojson _field_yojson - in - contentChanges_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = VersionedTextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) contentChanges_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some contentChanges_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value ) -> - { contentChanges = contentChanges_value - ; textDocument = textDocument_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) contentChanges_field) - Ppx_yojson_conv_lib.Option.None - , "contentChanges" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { contentChanges = v_contentChanges; textDocument = v_textDocument } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = VersionedTextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = - yojson_of_list TextDocumentContentChangeEvent.yojson_of_t v_contentChanges - in - ("contentChanges", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(contentChanges : TextDocumentContentChangeEvent.t list) - ~(textDocument : VersionedTextDocumentIdentifier.t) + ~(contentChanges : TextDocumentContentChangeEvent.t list) + ~(textDocument : VersionedTextDocumentIdentifier.t) : t = { contentChanges; textDocument } @@ -25932,193 +4525,20 @@ module FileEvent = struct { type_ : FileChangeType.t [@key "type"] ; uri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileEvent.t" in - function - | `Assoc field_yojsons as yojson -> - let type__field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "type" -> - (match Ppx_yojson_conv_lib.( ! ) type__field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = FileChangeType.t_of_yojson _field_yojson in - type__field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - Ppx_yojson_conv_lib.( ! ) type__field, Ppx_yojson_conv_lib.( ! ) uri_field - with - | ( Ppx_yojson_conv_lib.Option.Some type__value - , Ppx_yojson_conv_lib.Option.Some uri_value ) -> - { type_ = type__value; uri = uri_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) type__field) - Ppx_yojson_conv_lib.Option.None - , "type_" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { type_ = v_type_; uri = v_uri } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - let arg = FileChangeType.yojson_of_t v_type_ in - ("type", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(type_ : FileChangeType.t) ~(uri : DocumentUri.t) : t = { type_; uri } end module DidChangeWatchedFilesParams = struct type t = { changes : FileEvent.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidChangeWatchedFilesParams.t" in - function - | `Assoc field_yojsons as yojson -> - let changes_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "changes" -> - (match Ppx_yojson_conv_lib.( ! ) changes_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson FileEvent.t_of_yojson _field_yojson in - changes_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) changes_field with - | Ppx_yojson_conv_lib.Option.Some changes_value -> - { changes = changes_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) changes_field) - Ppx_yojson_conv_lib.Option.None - , "changes" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { changes = v_changes } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list FileEvent.yojson_of_t v_changes in - ("changes", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(changes : FileEvent.t list) : t = { changes } end module Pattern = struct - type t = string [@@deriving_inline yojson] - - let _ = fun (_ : t) -> () - let t_of_yojson = (string_of_yojson : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - let _ = t_of_yojson - let yojson_of_t = (yojson_of_string : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - let _ = yojson_of_t - - [@@@end] + type t = string [@@deriving yojson] end module WorkspaceFolder = struct @@ -26126,99 +4546,7 @@ module WorkspaceFolder = struct { name : string ; uri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceFolder.t" in - function - | `Assoc field_yojsons as yojson -> - let name_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "name" -> - (match Ppx_yojson_conv_lib.( ! ) name_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - name_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - Ppx_yojson_conv_lib.( ! ) name_field, Ppx_yojson_conv_lib.( ! ) uri_field - with - | ( Ppx_yojson_conv_lib.Option.Some name_value - , Ppx_yojson_conv_lib.Option.Some uri_value ) -> - { name = name_value; uri = uri_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) name_field) - Ppx_yojson_conv_lib.Option.None - , "name" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { name = v_name; uri = v_uri } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_name in - ("name", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(name : string) ~(uri : DocumentUri.t) : t = { name; uri } end @@ -26228,100 +4556,7 @@ module RelativePattern = struct { baseUri : unit ; pattern : Pattern.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RelativePattern.t" in - function - | `Assoc field_yojsons as yojson -> - let baseUri_field = ref Ppx_yojson_conv_lib.Option.None - and pattern_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "baseUri" -> - (match Ppx_yojson_conv_lib.( ! ) baseUri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = unit_of_yojson _field_yojson in - baseUri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "pattern" -> - (match Ppx_yojson_conv_lib.( ! ) pattern_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Pattern.t_of_yojson _field_yojson in - pattern_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) baseUri_field - , Ppx_yojson_conv_lib.( ! ) pattern_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some baseUri_value - , Ppx_yojson_conv_lib.Option.Some pattern_value ) -> - { baseUri = baseUri_value; pattern = pattern_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) baseUri_field) - Ppx_yojson_conv_lib.Option.None - , "baseUri" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) pattern_field) - Ppx_yojson_conv_lib.Option.None - , "pattern" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { baseUri = v_baseUri; pattern = v_pattern } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Pattern.yojson_of_t v_pattern in - ("pattern", arg) :: bnds - in - let bnds = - let arg = yojson_of_unit v_baseUri in - ("baseUri", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(baseUri : unit) ~(pattern : Pattern.t) : t = { baseUri; pattern } end @@ -26352,108 +4587,9 @@ module FileSystemWatcher = struct type t = { globPattern : GlobPattern.t ; kind : WatchKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileSystemWatcher.t" in - function - | `Assoc field_yojsons as yojson -> - let globPattern_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "globPattern" -> - (match Ppx_yojson_conv_lib.( ! ) globPattern_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = GlobPattern.t_of_yojson _field_yojson in - globPattern_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson WatchKind.t_of_yojson _field_yojson - in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) globPattern_field - , Ppx_yojson_conv_lib.( ! ) kind_field ) - with - | Ppx_yojson_conv_lib.Option.Some globPattern_value, kind_value -> - { globPattern = globPattern_value - ; kind = - (match kind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) globPattern_field) - Ppx_yojson_conv_lib.Option.None - , "globPattern" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { globPattern = v_globPattern; kind = v_kind } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_kind - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t WatchKind.yojson_of_t) v_kind in - let bnd = "kind", arg in - bnd :: bnds) - in - let bnds = - let arg = GlobPattern.yojson_of_t v_globPattern in - ("globPattern", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(globPattern : GlobPattern.t) ?(kind : WatchKind.t option) (() : unit) : t = { globPattern; kind } @@ -26462,82 +4598,7 @@ end module DidChangeWatchedFilesRegistrationOptions = struct type t = { watchers : FileSystemWatcher.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidChangeWatchedFilesRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let watchers_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "watchers" -> - (match Ppx_yojson_conv_lib.( ! ) watchers_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson FileSystemWatcher.t_of_yojson _field_yojson - in - watchers_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) watchers_field with - | Ppx_yojson_conv_lib.Option.Some watchers_value -> - { watchers = watchers_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) watchers_field) - Ppx_yojson_conv_lib.Option.None - , "watchers" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { watchers = v_watchers } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list FileSystemWatcher.yojson_of_t v_watchers in - ("watchers", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(watchers : FileSystemWatcher.t list) : t = { watchers } end @@ -26547,100 +4608,7 @@ module WorkspaceFoldersChangeEvent = struct { added : WorkspaceFolder.t list ; removed : WorkspaceFolder.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceFoldersChangeEvent.t" in - function - | `Assoc field_yojsons as yojson -> - let added_field = ref Ppx_yojson_conv_lib.Option.None - and removed_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "added" -> - (match Ppx_yojson_conv_lib.( ! ) added_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson WorkspaceFolder.t_of_yojson _field_yojson in - added_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "removed" -> - (match Ppx_yojson_conv_lib.( ! ) removed_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson WorkspaceFolder.t_of_yojson _field_yojson in - removed_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) added_field - , Ppx_yojson_conv_lib.( ! ) removed_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some added_value - , Ppx_yojson_conv_lib.Option.Some removed_value ) -> - { added = added_value; removed = removed_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) added_field) - Ppx_yojson_conv_lib.Option.None - , "added" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) removed_field) - Ppx_yojson_conv_lib.Option.None - , "removed" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { added = v_added; removed = v_removed } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list WorkspaceFolder.yojson_of_t v_removed in - ("removed", arg) :: bnds - in - let bnds = - let arg = yojson_of_list WorkspaceFolder.yojson_of_t v_added in - ("added", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(added : WorkspaceFolder.t list) ~(removed : WorkspaceFolder.t list) : t = { added; removed } @@ -26649,158 +4617,13 @@ end module DidChangeWorkspaceFoldersParams = struct type t = { event : WorkspaceFoldersChangeEvent.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidChangeWorkspaceFoldersParams.t" in - function - | `Assoc field_yojsons as yojson -> - let event_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "event" -> - (match Ppx_yojson_conv_lib.( ! ) event_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = WorkspaceFoldersChangeEvent.t_of_yojson _field_yojson in - event_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) event_field with - | Ppx_yojson_conv_lib.Option.Some event_value -> { event = event_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) event_field) - Ppx_yojson_conv_lib.Option.None - , "event" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { event = v_event } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = WorkspaceFoldersChangeEvent.yojson_of_t v_event in - ("event", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(event : WorkspaceFoldersChangeEvent.t) : t = { event } end module NotebookDocumentIdentifier = struct - type t = { uri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookDocumentIdentifier.t" in - function - | `Assoc field_yojsons as yojson -> - let uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.Some uri_value -> { uri = uri_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { uri = v_uri } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { uri : DocumentUri.t } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(uri : DocumentUri.t) : t = { uri } end @@ -26810,111 +4633,11 @@ module DidCloseNotebookDocumentParams = struct { cellTextDocuments : TextDocumentIdentifier.t list ; notebookDocument : NotebookDocumentIdentifier.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidCloseNotebookDocumentParams.t" in - function - | `Assoc field_yojsons as yojson -> - let cellTextDocuments_field = ref Ppx_yojson_conv_lib.Option.None - and notebookDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "cellTextDocuments" -> - (match Ppx_yojson_conv_lib.( ! ) cellTextDocuments_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson TextDocumentIdentifier.t_of_yojson _field_yojson - in - cellTextDocuments_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "notebookDocument" -> - (match Ppx_yojson_conv_lib.( ! ) notebookDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = NotebookDocumentIdentifier.t_of_yojson _field_yojson in - notebookDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) cellTextDocuments_field - , Ppx_yojson_conv_lib.( ! ) notebookDocument_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some cellTextDocuments_value - , Ppx_yojson_conv_lib.Option.Some notebookDocument_value ) -> - { cellTextDocuments = cellTextDocuments_value - ; notebookDocument = notebookDocument_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) cellTextDocuments_field) - Ppx_yojson_conv_lib.Option.None - , "cellTextDocuments" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) notebookDocument_field) - Ppx_yojson_conv_lib.Option.None - , "notebookDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { cellTextDocuments = v_cellTextDocuments; notebookDocument = v_notebookDocument } - -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = NotebookDocumentIdentifier.yojson_of_t v_notebookDocument in - ("notebookDocument", arg) :: bnds - in - let bnds = - let arg = - yojson_of_list TextDocumentIdentifier.yojson_of_t v_cellTextDocuments - in - ("cellTextDocuments", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(cellTextDocuments : TextDocumentIdentifier.t list) - ~(notebookDocument : NotebookDocumentIdentifier.t) + ~(cellTextDocuments : TextDocumentIdentifier.t list) + ~(notebookDocument : NotebookDocumentIdentifier.t) : t = { cellTextDocuments; notebookDocument } @@ -26923,80 +4646,7 @@ end module DidCloseTextDocumentParams = struct type t = { textDocument : TextDocumentIdentifier.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidCloseTextDocumentParams.t" in - function - | `Assoc field_yojsons as yojson -> - let textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.Some textDocument_value -> - { textDocument = textDocument_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { textDocument = v_textDocument } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(textDocument : TextDocumentIdentifier.t) : t = { textDocument } end @@ -27005,184 +4655,20 @@ module NotebookDocument = struct type t = { cells : NotebookCell.t list ; metadata : Json.Object.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; notebookType : string ; uri : DocumentUri.t ; version : int } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.NotebookDocument.t" in - function - | `Assoc field_yojsons as yojson -> - let cells_field = ref Ppx_yojson_conv_lib.Option.None - and metadata_field = ref Ppx_yojson_conv_lib.Option.None - and notebookType_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "cells" -> - (match Ppx_yojson_conv_lib.( ! ) cells_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson NotebookCell.t_of_yojson _field_yojson in - cells_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "metadata" -> - (match Ppx_yojson_conv_lib.( ! ) metadata_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Json.Object.t_of_yojson _field_yojson - in - metadata_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "notebookType" -> - (match Ppx_yojson_conv_lib.( ! ) notebookType_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - notebookType_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) cells_field - , Ppx_yojson_conv_lib.( ! ) metadata_field - , Ppx_yojson_conv_lib.( ! ) notebookType_field - , Ppx_yojson_conv_lib.( ! ) uri_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some cells_value - , metadata_value - , Ppx_yojson_conv_lib.Option.Some notebookType_value - , Ppx_yojson_conv_lib.Option.Some uri_value - , Ppx_yojson_conv_lib.Option.Some version_value ) -> - { cells = cells_value - ; metadata = - (match metadata_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; notebookType = notebookType_value - ; uri = uri_value - ; version = version_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) cells_field) - Ppx_yojson_conv_lib.Option.None - , "cells" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) notebookType_field) - Ppx_yojson_conv_lib.Option.None - , "notebookType" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) version_field) - Ppx_yojson_conv_lib.Option.None - , "version" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { cells = v_cells - ; metadata = v_metadata - ; notebookType = v_notebookType - ; uri = v_uri - ; version = v_version - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_int v_version in - ("version", arg) :: bnds - in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_notebookType in - ("notebookType", arg) :: bnds - in - let bnds = - if None = v_metadata - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t Json.Object.yojson_of_t) v_metadata - in - let bnd = "metadata", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list NotebookCell.yojson_of_t v_cells in - ("cells", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(cells : NotebookCell.t list) - ?(metadata : Json.Object.t option) - ~(notebookType : string) - ~(uri : DocumentUri.t) - ~(version : int) - (() : unit) + ~(cells : NotebookCell.t list) + ?(metadata : Json.Object.t option) + ~(notebookType : string) + ~(uri : DocumentUri.t) + ~(version : int) + (() : unit) : t = { cells; metadata; notebookType; uri; version } @@ -27194,107 +4680,11 @@ module DidOpenNotebookDocumentParams = struct { cellTextDocuments : TextDocumentItem.t list ; notebookDocument : NotebookDocument.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidOpenNotebookDocumentParams.t" in - function - | `Assoc field_yojsons as yojson -> - let cellTextDocuments_field = ref Ppx_yojson_conv_lib.Option.None - and notebookDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "cellTextDocuments" -> - (match Ppx_yojson_conv_lib.( ! ) cellTextDocuments_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson TextDocumentItem.t_of_yojson _field_yojson in - cellTextDocuments_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "notebookDocument" -> - (match Ppx_yojson_conv_lib.( ! ) notebookDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = NotebookDocument.t_of_yojson _field_yojson in - notebookDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) cellTextDocuments_field - , Ppx_yojson_conv_lib.( ! ) notebookDocument_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some cellTextDocuments_value - , Ppx_yojson_conv_lib.Option.Some notebookDocument_value ) -> - { cellTextDocuments = cellTextDocuments_value - ; notebookDocument = notebookDocument_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) cellTextDocuments_field) - Ppx_yojson_conv_lib.Option.None - , "cellTextDocuments" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) notebookDocument_field) - Ppx_yojson_conv_lib.Option.None - , "notebookDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { cellTextDocuments = v_cellTextDocuments; notebookDocument = v_notebookDocument } - -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = NotebookDocument.yojson_of_t v_notebookDocument in - ("notebookDocument", arg) :: bnds - in - let bnds = - let arg = yojson_of_list TextDocumentItem.yojson_of_t v_cellTextDocuments in - ("cellTextDocuments", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(cellTextDocuments : TextDocumentItem.t list) - ~(notebookDocument : NotebookDocument.t) + ~(cellTextDocuments : TextDocumentItem.t list) + ~(notebookDocument : NotebookDocument.t) : t = { cellTextDocuments; notebookDocument } @@ -27303,160 +4693,14 @@ end module DidOpenTextDocumentParams = struct type t = { textDocument : TextDocumentItem.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidOpenTextDocumentParams.t" in - function - | `Assoc field_yojsons as yojson -> - let textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentItem.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.Some textDocument_value -> - { textDocument = textDocument_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { textDocument = v_textDocument } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = TextDocumentItem.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(textDocument : TextDocumentItem.t) : t = { textDocument } end module DidSaveNotebookDocumentParams = struct type t = { notebookDocument : NotebookDocumentIdentifier.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidSaveNotebookDocumentParams.t" in - function - | `Assoc field_yojsons as yojson -> - let notebookDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "notebookDocument" -> - (match Ppx_yojson_conv_lib.( ! ) notebookDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = NotebookDocumentIdentifier.t_of_yojson _field_yojson in - notebookDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) notebookDocument_field with - | Ppx_yojson_conv_lib.Option.Some notebookDocument_value -> - { notebookDocument = notebookDocument_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) notebookDocument_field) - Ppx_yojson_conv_lib.Option.None - , "notebookDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { notebookDocument = v_notebookDocument } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = NotebookDocumentIdentifier.yojson_of_t v_notebookDocument in - ("notebookDocument", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(notebookDocument : NotebookDocumentIdentifier.t) : t = { notebookDocument } end @@ -27466,111 +4710,12 @@ module DidSaveTextDocumentParams = struct { text : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; textDocument : TextDocumentIdentifier.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DidSaveTextDocumentParams.t" in - function - | `Assoc field_yojsons as yojson -> - let text_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "text" -> - (match Ppx_yojson_conv_lib.( ! ) text_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - text_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) text_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field ) - with - | text_value, Ppx_yojson_conv_lib.Option.Some textDocument_value -> - { text = - (match text_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocument = textDocument_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { text = v_text; textDocument = v_textDocument } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - if None = v_text - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_text in - let bnd = "text", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(text : string option) - ~(textDocument : TextDocumentIdentifier.t) - (() : unit) + ?(text : string option) + ~(textDocument : TextDocumentIdentifier.t) + (() : unit) : t = { text; textDocument } @@ -27580,86 +4725,9 @@ end module DocumentColorOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentColorOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -27667,154 +4735,18 @@ end module DocumentColorParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentColorParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; textDocument; workDoneToken } @@ -27824,149 +4756,18 @@ end module DocumentColorRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentColorRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -27976,212 +4777,24 @@ end module DocumentDiagnosticParams = struct type t = { identifier : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; previousResultId : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentDiagnosticParams.t" in - function - | `Assoc field_yojsons as yojson -> - let identifier_field = ref Ppx_yojson_conv_lib.Option.None - and partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and previousResultId_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "identifier" -> - (match Ppx_yojson_conv_lib.( ! ) identifier_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - identifier_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "previousResultId" -> - (match Ppx_yojson_conv_lib.( ! ) previousResultId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - previousResultId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) identifier_field - , Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) previousResultId_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( identifier_value - , partialResultToken_value - , previousResultId_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { identifier = - (match identifier_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; previousResultId = - (match previousResultId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { identifier = v_identifier - ; partialResultToken = v_partialResultToken - ; previousResultId = v_previousResultId - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - if None = v_previousResultId - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_string) v_previousResultId - in - let bnd = "previousResultId", arg in - bnd :: bnds) - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - let bnds = - if None = v_identifier - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_identifier in - let bnd = "identifier", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(identifier : string option) - ?(partialResultToken : ProgressToken.t option) - ?(previousResultId : string option) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(identifier : string option) + ?(partialResultToken : ProgressToken.t option) + ?(previousResultId : string option) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { identifier; partialResultToken; previousResultId; textDocument; workDoneToken } @@ -28189,80 +4802,7 @@ module DocumentDiagnosticParams = struct end module UnchangedDocumentDiagnosticReport = struct - type t = { resultId : string } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.UnchangedDocumentDiagnosticReport.t" in - function - | `Assoc field_yojsons as yojson -> - let resultId_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "resultId" -> - (match Ppx_yojson_conv_lib.( ! ) resultId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - resultId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) resultId_field with - | Ppx_yojson_conv_lib.Option.Some resultId_value -> - { resultId = resultId_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) resultId_field) - Ppx_yojson_conv_lib.Option.None - , "resultId" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { resultId = v_resultId } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_resultId in - ("resultId", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { resultId : string } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(resultId : string) : t = { resultId } @@ -28279,108 +4819,9 @@ module FullDocumentDiagnosticReport = struct type t = { items : Diagnostic.t list ; resultId : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FullDocumentDiagnosticReport.t" in - function - | `Assoc field_yojsons as yojson -> - let items_field = ref Ppx_yojson_conv_lib.Option.None - and resultId_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "items" -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Diagnostic.t_of_yojson _field_yojson in - items_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resultId" -> - (match Ppx_yojson_conv_lib.( ! ) resultId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - resultId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) items_field - , Ppx_yojson_conv_lib.( ! ) resultId_field ) - with - | Ppx_yojson_conv_lib.Option.Some items_value, resultId_value -> - { items = items_value - ; resultId = - (match resultId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) items_field) - Ppx_yojson_conv_lib.Option.None - , "items" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { items = v_items; resultId = v_resultId } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_resultId - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_resultId in - let bnd = "resultId", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list Diagnostic.yojson_of_t v_items in - ("items", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(items : Diagnostic.t list) ?(resultId : string option) (() : unit) : t = { items; resultId } @@ -28423,124 +4864,15 @@ module RelatedUnchangedDocumentDiagnosticReport = struct type t = { relatedDocuments : (DocumentUri.t, relatedDocuments_pvar) Json.Assoc.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resultId : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RelatedUnchangedDocumentDiagnosticReport.t" in - function - | `Assoc field_yojsons as yojson -> - let relatedDocuments_field = ref Ppx_yojson_conv_lib.Option.None - and resultId_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "relatedDocuments" -> - (match Ppx_yojson_conv_lib.( ! ) relatedDocuments_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (Json.Assoc.t_of_yojson - DocumentUri.t_of_yojson - relatedDocuments_pvar_of_yojson) - _field_yojson - in - relatedDocuments_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resultId" -> - (match Ppx_yojson_conv_lib.( ! ) resultId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - resultId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) relatedDocuments_field - , Ppx_yojson_conv_lib.( ! ) resultId_field ) - with - | relatedDocuments_value, Ppx_yojson_conv_lib.Option.Some resultId_value -> - { relatedDocuments = - (match relatedDocuments_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resultId = resultId_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) resultId_field) - Ppx_yojson_conv_lib.Option.None - , "resultId" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { relatedDocuments = v_relatedDocuments; resultId = v_resultId } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_resultId in - ("resultId", arg) :: bnds - in - let bnds = - if None = v_relatedDocuments - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (Json.Assoc.yojson_of_t - DocumentUri.yojson_of_t - yojson_of_relatedDocuments_pvar)) - v_relatedDocuments - in - let bnd = "relatedDocuments", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(relatedDocuments : (DocumentUri.t, relatedDocuments_pvar) Json.Assoc.t option) - ~(resultId : string) - (() : unit) + ?(relatedDocuments : (DocumentUri.t, relatedDocuments_pvar) Json.Assoc.t option) + ~(resultId : string) + (() : unit) : t = { relatedDocuments; resultId } @@ -28586,152 +4918,17 @@ module RelatedFullDocumentDiagnosticReport = struct { items : Diagnostic.t list ; relatedDocuments : (DocumentUri.t, relatedDocuments_pvar) Json.Assoc.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resultId : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RelatedFullDocumentDiagnosticReport.t" in - function - | `Assoc field_yojsons as yojson -> - let items_field = ref Ppx_yojson_conv_lib.Option.None - and relatedDocuments_field = ref Ppx_yojson_conv_lib.Option.None - and resultId_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "items" -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Diagnostic.t_of_yojson _field_yojson in - items_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "relatedDocuments" -> - (match Ppx_yojson_conv_lib.( ! ) relatedDocuments_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (Json.Assoc.t_of_yojson - DocumentUri.t_of_yojson - relatedDocuments_pvar_of_yojson) - _field_yojson - in - relatedDocuments_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resultId" -> - (match Ppx_yojson_conv_lib.( ! ) resultId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - resultId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) items_field - , Ppx_yojson_conv_lib.( ! ) relatedDocuments_field - , Ppx_yojson_conv_lib.( ! ) resultId_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some items_value - , relatedDocuments_value - , resultId_value ) -> - { items = items_value - ; relatedDocuments = - (match relatedDocuments_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resultId = - (match resultId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) items_field) - Ppx_yojson_conv_lib.Option.None - , "items" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { items = v_items; relatedDocuments = v_relatedDocuments; resultId = v_resultId } - -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_resultId - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_resultId in - let bnd = "resultId", arg in - bnd :: bnds) - in - let bnds = - if None = v_relatedDocuments - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (Json.Assoc.yojson_of_t - DocumentUri.yojson_of_t - yojson_of_relatedDocuments_pvar)) - v_relatedDocuments - in - let bnd = "relatedDocuments", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list Diagnostic.yojson_of_t v_items in - ("items", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(items : Diagnostic.t list) - ?(relatedDocuments : (DocumentUri.t, relatedDocuments_pvar) Json.Assoc.t option) - ?(resultId : string option) - (() : unit) + ~(items : Diagnostic.t list) + ?(relatedDocuments : (DocumentUri.t, relatedDocuments_pvar) Json.Assoc.t option) + ?(resultId : string option) + (() : unit) : t = { items; relatedDocuments; resultId } @@ -28748,7 +4945,7 @@ module DocumentDiagnosticReport = struct type t = [ `RelatedFullDocumentDiagnosticReport of RelatedFullDocumentDiagnosticReport.t | `RelatedUnchangedDocumentDiagnosticReport of - RelatedUnchangedDocumentDiagnosticReport.t + RelatedUnchangedDocumentDiagnosticReport.t ] let t_of_yojson (json : Json.t) : t = @@ -28801,90 +4998,7 @@ module DocumentDiagnosticReportPartialResult = struct ;; type t = { relatedDocuments : (DocumentUri.t, relatedDocuments_pvar) Json.Assoc.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentDiagnosticReportPartialResult.t" in - function - | `Assoc field_yojsons as yojson -> - let relatedDocuments_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "relatedDocuments" -> - (match Ppx_yojson_conv_lib.( ! ) relatedDocuments_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Assoc.t_of_yojson - DocumentUri.t_of_yojson - relatedDocuments_pvar_of_yojson - _field_yojson - in - relatedDocuments_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) relatedDocuments_field with - | Ppx_yojson_conv_lib.Option.Some relatedDocuments_value -> - { relatedDocuments = relatedDocuments_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) relatedDocuments_field) - Ppx_yojson_conv_lib.Option.None - , "relatedDocuments" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { relatedDocuments = v_relatedDocuments } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = - Json.Assoc.yojson_of_t - DocumentUri.yojson_of_t - yojson_of_relatedDocuments_pvar - v_relatedDocuments - in - ("relatedDocuments", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(relatedDocuments : (DocumentUri.t, relatedDocuments_pvar) Json.Assoc.t) : t = @@ -28895,86 +5009,9 @@ end module DocumentFormattingOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentFormattingOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -28982,201 +5019,23 @@ end module FormattingOptions = struct type t = { insertFinalNewline : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; insertSpaces : bool ; tabSize : int ; trimFinalNewlines : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; trimTrailingWhitespace : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FormattingOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let insertFinalNewline_field = ref Ppx_yojson_conv_lib.Option.None - and insertSpaces_field = ref Ppx_yojson_conv_lib.Option.None - and tabSize_field = ref Ppx_yojson_conv_lib.Option.None - and trimFinalNewlines_field = ref Ppx_yojson_conv_lib.Option.None - and trimTrailingWhitespace_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "insertFinalNewline" -> - (match Ppx_yojson_conv_lib.( ! ) insertFinalNewline_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - insertFinalNewline_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "insertSpaces" -> - (match Ppx_yojson_conv_lib.( ! ) insertSpaces_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - insertSpaces_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tabSize" -> - (match Ppx_yojson_conv_lib.( ! ) tabSize_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - tabSize_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "trimFinalNewlines" -> - (match Ppx_yojson_conv_lib.( ! ) trimFinalNewlines_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - trimFinalNewlines_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "trimTrailingWhitespace" -> - (match Ppx_yojson_conv_lib.( ! ) trimTrailingWhitespace_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - trimTrailingWhitespace_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) insertFinalNewline_field - , Ppx_yojson_conv_lib.( ! ) insertSpaces_field - , Ppx_yojson_conv_lib.( ! ) tabSize_field - , Ppx_yojson_conv_lib.( ! ) trimFinalNewlines_field - , Ppx_yojson_conv_lib.( ! ) trimTrailingWhitespace_field ) - with - | ( insertFinalNewline_value - , Ppx_yojson_conv_lib.Option.Some insertSpaces_value - , Ppx_yojson_conv_lib.Option.Some tabSize_value - , trimFinalNewlines_value - , trimTrailingWhitespace_value ) -> - { insertFinalNewline = - (match insertFinalNewline_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; insertSpaces = insertSpaces_value - ; tabSize = tabSize_value - ; trimFinalNewlines = - (match trimFinalNewlines_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; trimTrailingWhitespace = - (match trimTrailingWhitespace_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) insertSpaces_field) - Ppx_yojson_conv_lib.Option.None - , "insertSpaces" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) tabSize_field) - Ppx_yojson_conv_lib.Option.None - , "tabSize" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { insertFinalNewline = v_insertFinalNewline - ; insertSpaces = v_insertSpaces - ; tabSize = v_tabSize - ; trimFinalNewlines = v_trimFinalNewlines - ; trimTrailingWhitespace = v_trimTrailingWhitespace - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_trimTrailingWhitespace - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_trimTrailingWhitespace - in - let bnd = "trimTrailingWhitespace", arg in - bnd :: bnds) - in - let bnds = - if None = v_trimFinalNewlines - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_trimFinalNewlines - in - let bnd = "trimFinalNewlines", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_int v_tabSize in - ("tabSize", arg) :: bnds - in - let bnds = - let arg = yojson_of_bool v_insertSpaces in - ("insertSpaces", arg) :: bnds - in - let bnds = - if None = v_insertFinalNewline - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_insertFinalNewline - in - let bnd = "insertFinalNewline", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(insertFinalNewline : bool option) - ~(insertSpaces : bool) - ~(tabSize : int) - ?(trimFinalNewlines : bool option) - ?(trimTrailingWhitespace : bool option) - (() : unit) + ?(insertFinalNewline : bool option) + ~(insertSpaces : bool) + ~(tabSize : int) + ?(trimFinalNewlines : bool option) + ?(trimTrailingWhitespace : bool option) + (() : unit) : t = { insertFinalNewline @@ -29193,141 +5052,15 @@ module DocumentFormattingParams = struct { options : FormattingOptions.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentFormattingParams.t" in - function - | `Assoc field_yojsons as yojson -> - let options_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "options" -> - (match Ppx_yojson_conv_lib.( ! ) options_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = FormattingOptions.t_of_yojson _field_yojson in - options_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) options_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some options_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { options = options_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) options_field) - Ppx_yojson_conv_lib.Option.None - , "options" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { options = v_options - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = FormattingOptions.yojson_of_t v_options in - ("options", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(options : FormattingOptions.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(options : FormattingOptions.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { options; textDocument; workDoneToken } @@ -29337,121 +5070,16 @@ end module DocumentFormattingRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentFormattingRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; workDoneProgress } @@ -29461,113 +5089,10 @@ end module DocumentHighlight = struct type t = { kind : DocumentHighlightKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; range : Range.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentHighlight.t" in - function - | `Assoc field_yojsons as yojson -> - let kind_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentHighlightKind.t_of_yojson - _field_yojson - in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) range_field ) - with - | kind_value, Ppx_yojson_conv_lib.Option.Some range_value -> - { kind = - (match kind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; range = range_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { kind = v_kind; range = v_range } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - if None = v_kind - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentHighlightKind.yojson_of_t) v_kind - in - let bnd = "kind", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(kind : DocumentHighlightKind.t option) ~(range : Range.t) (() : unit) : t = { kind; range } @@ -29577,86 +5102,9 @@ end module DocumentHighlightOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentHighlightOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -29664,176 +5112,20 @@ end module DocumentHighlightParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentHighlightParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; position; textDocument; workDoneToken } @@ -29843,121 +5135,16 @@ end module DocumentHighlightRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentHighlightRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; workDoneProgress } @@ -29969,162 +5156,17 @@ module DocumentLink = struct { data : Json.t option [@yojson.option] ; range : Range.t ; target : DocumentUri.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; tooltip : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentLink.t" in - function - | `Assoc field_yojsons as yojson -> - let data_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and target_field = ref Ppx_yojson_conv_lib.Option.None - and tooltip_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "target" -> - (match Ppx_yojson_conv_lib.( ! ) target_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson DocumentUri.t_of_yojson _field_yojson - in - target_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tooltip" -> - (match Ppx_yojson_conv_lib.( ! ) tooltip_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - tooltip_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) target_field - , Ppx_yojson_conv_lib.( ! ) tooltip_field ) - with - | ( data_value - , Ppx_yojson_conv_lib.Option.Some range_value - , target_value - , tooltip_value ) -> - { data = data_value - ; range = range_value - ; target = - (match target_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tooltip = - (match tooltip_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { data = v_data; range = v_range; target = v_target; tooltip = v_tooltip } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_tooltip - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_tooltip in - let bnd = "tooltip", arg in - bnd :: bnds) - in - let bnds = - if None = v_target - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentUri.yojson_of_t) v_target - in - let bnd = "target", arg in - bnd :: bnds) - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - match v_data with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "data", arg in - bnd :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(data : Json.t option) - ~(range : Range.t) - ?(target : DocumentUri.t option) - ?(tooltip : string option) - (() : unit) + ?(data : Json.t option) + ~(range : Range.t) + ?(target : DocumentUri.t option) + ?(tooltip : string option) + (() : unit) : t = { data; range; target; tooltip } @@ -30134,118 +5176,16 @@ end module DocumentLinkOptions = struct type t = { resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentLinkOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let resolveProvider_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { resolveProvider = v_resolveProvider; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(resolveProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(resolveProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { resolveProvider; workDoneProgress } @@ -30255,154 +5195,18 @@ end module DocumentLinkParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentLinkParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; textDocument; workDoneToken } @@ -30412,152 +5216,19 @@ end module DocumentLinkRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentLinkRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, resolveProvider_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; resolveProvider = v_resolveProvider - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(resolveProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(resolveProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; resolveProvider; workDoneProgress } @@ -30568,121 +5239,14 @@ module DocumentOnTypeFormattingOptions = struct type t = { firstTriggerCharacter : string ; moreTriggerCharacter : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentOnTypeFormattingOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let firstTriggerCharacter_field = ref Ppx_yojson_conv_lib.Option.None - and moreTriggerCharacter_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "firstTriggerCharacter" -> - (match Ppx_yojson_conv_lib.( ! ) firstTriggerCharacter_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - firstTriggerCharacter_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "moreTriggerCharacter" -> - (match Ppx_yojson_conv_lib.( ! ) moreTriggerCharacter_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - moreTriggerCharacter_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) firstTriggerCharacter_field - , Ppx_yojson_conv_lib.( ! ) moreTriggerCharacter_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some firstTriggerCharacter_value - , moreTriggerCharacter_value ) -> - { firstTriggerCharacter = firstTriggerCharacter_value - ; moreTriggerCharacter = - (match moreTriggerCharacter_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) firstTriggerCharacter_field) - Ppx_yojson_conv_lib.Option.None - , "firstTriggerCharacter" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { firstTriggerCharacter = v_firstTriggerCharacter - ; moreTriggerCharacter = v_moreTriggerCharacter - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_moreTriggerCharacter - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_moreTriggerCharacter - in - let bnd = "moreTriggerCharacter", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_firstTriggerCharacter in - ("firstTriggerCharacter", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(firstTriggerCharacter : string) - ?(moreTriggerCharacter : string list option) - (() : unit) + ~(firstTriggerCharacter : string) + ?(moreTriggerCharacter : string list option) + (() : unit) : t = { firstTriggerCharacter; moreTriggerCharacter } @@ -30696,150 +5260,13 @@ module DocumentOnTypeFormattingParams = struct ; position : Position.t ; textDocument : TextDocumentIdentifier.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentOnTypeFormattingParams.t" in - function - | `Assoc field_yojsons as yojson -> - let ch_field = ref Ppx_yojson_conv_lib.Option.None - and options_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "ch" -> - (match Ppx_yojson_conv_lib.( ! ) ch_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - ch_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "options" -> - (match Ppx_yojson_conv_lib.( ! ) options_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = FormattingOptions.t_of_yojson _field_yojson in - options_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) ch_field - , Ppx_yojson_conv_lib.( ! ) options_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some ch_value - , Ppx_yojson_conv_lib.Option.Some options_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value ) -> - { ch = ch_value - ; options = options_value - ; position = position_value - ; textDocument = textDocument_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) ch_field) - Ppx_yojson_conv_lib.Option.None - , "ch" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) options_field) - Ppx_yojson_conv_lib.Option.None - , "options" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { ch = v_ch - ; options = v_options - ; position = v_position - ; textDocument = v_textDocument - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - let arg = FormattingOptions.yojson_of_t v_options in - ("options", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_ch in - ("ch", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(ch : string) - ~(options : FormattingOptions.t) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) + ~(ch : string) + ~(options : FormattingOptions.t) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) : t = { ch; options; position; textDocument } @@ -30849,155 +5276,18 @@ end module DocumentOnTypeFormattingRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; firstTriggerCharacter : string ; moreTriggerCharacter : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentOnTypeFormattingRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and firstTriggerCharacter_field = ref Ppx_yojson_conv_lib.Option.None - and moreTriggerCharacter_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "firstTriggerCharacter" -> - (match Ppx_yojson_conv_lib.( ! ) firstTriggerCharacter_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - firstTriggerCharacter_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "moreTriggerCharacter" -> - (match Ppx_yojson_conv_lib.( ! ) moreTriggerCharacter_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - moreTriggerCharacter_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) firstTriggerCharacter_field - , Ppx_yojson_conv_lib.( ! ) moreTriggerCharacter_field ) - with - | ( documentSelector_value - , Ppx_yojson_conv_lib.Option.Some firstTriggerCharacter_value - , moreTriggerCharacter_value ) -> - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; firstTriggerCharacter = firstTriggerCharacter_value - ; moreTriggerCharacter = - (match moreTriggerCharacter_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) firstTriggerCharacter_field) - Ppx_yojson_conv_lib.Option.None - , "firstTriggerCharacter" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; firstTriggerCharacter = v_firstTriggerCharacter - ; moreTriggerCharacter = v_moreTriggerCharacter - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_moreTriggerCharacter - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_moreTriggerCharacter - in - let bnd = "moreTriggerCharacter", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_firstTriggerCharacter in - ("firstTriggerCharacter", arg) :: bnds - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ~(firstTriggerCharacter : string) - ?(moreTriggerCharacter : string list option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ~(firstTriggerCharacter : string) + ?(moreTriggerCharacter : string list option) + (() : unit) : t = { documentSelector; firstTriggerCharacter; moreTriggerCharacter } @@ -31007,111 +5297,11 @@ end module DocumentRangeFormattingOptions = struct type t = { rangesSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentRangeFormattingOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let rangesSupport_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "rangesSupport" -> - (match Ppx_yojson_conv_lib.( ! ) rangesSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - rangesSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let rangesSupport_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) rangesSupport_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { rangesSupport = - (match rangesSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { rangesSupport = v_rangesSupport; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_rangesSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_rangesSupport in - let bnd = "rangesSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(rangesSupport : bool option) ?(workDoneProgress : bool option) (() : unit) : t @@ -31126,162 +5316,16 @@ module DocumentRangeFormattingParams = struct ; range : Range.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentRangeFormattingParams.t" in - function - | `Assoc field_yojsons as yojson -> - let options_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "options" -> - (match Ppx_yojson_conv_lib.( ! ) options_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = FormattingOptions.t_of_yojson _field_yojson in - options_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) options_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some options_value - , Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { options = options_value - ; range = range_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) options_field) - Ppx_yojson_conv_lib.Option.None - , "options" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { options = v_options - ; range = v_range - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - let arg = FormattingOptions.yojson_of_t v_options in - ("options", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(options : FormattingOptions.t) - ~(range : Range.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(options : FormattingOptions.t) + ~(range : Range.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { options; range; textDocument; workDoneToken } @@ -31291,150 +5335,19 @@ end module DocumentRangeFormattingRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; rangesSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentRangeFormattingRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and rangesSupport_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "rangesSupport" -> - (match Ppx_yojson_conv_lib.( ! ) rangesSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - rangesSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, rangesSupport_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) rangesSupport_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; rangesSupport = - (match rangesSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; rangesSupport = v_rangesSupport - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_rangesSupport - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_rangesSupport in - let bnd = "rangesSupport", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(rangesSupport : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(rangesSupport : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; rangesSupport; workDoneProgress } @@ -31447,162 +5360,16 @@ module DocumentRangesFormattingParams = struct ; ranges : Range.t list ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentRangesFormattingParams.t" in - function - | `Assoc field_yojsons as yojson -> - let options_field = ref Ppx_yojson_conv_lib.Option.None - and ranges_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "options" -> - (match Ppx_yojson_conv_lib.( ! ) options_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = FormattingOptions.t_of_yojson _field_yojson in - options_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "ranges" -> - (match Ppx_yojson_conv_lib.( ! ) ranges_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Range.t_of_yojson _field_yojson in - ranges_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) options_field - , Ppx_yojson_conv_lib.( ! ) ranges_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some options_value - , Ppx_yojson_conv_lib.Option.Some ranges_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { options = options_value - ; ranges = ranges_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) options_field) - Ppx_yojson_conv_lib.Option.None - , "options" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) ranges_field) - Ppx_yojson_conv_lib.Option.None - , "ranges" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { options = v_options - ; ranges = v_ranges - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = yojson_of_list Range.yojson_of_t v_ranges in - ("ranges", arg) :: bnds - in - let bnds = - let arg = FormattingOptions.yojson_of_t v_options in - ("options", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(options : FormattingOptions.t) - ~(ranges : Range.t list) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(options : FormattingOptions.t) + ~(ranges : Range.t list) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { options; ranges; textDocument; workDoneToken } @@ -31612,275 +5379,29 @@ end module DocumentSymbol = struct type t = { children : t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; deprecated : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; detail : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; kind : SymbolKind.t ; name : string ; range : Range.t ; selectionRange : Range.t ; tags : SymbolTag.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let rec t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentSymbol.t" in - function - | `Assoc field_yojsons as yojson -> - let children_field = ref Ppx_yojson_conv_lib.Option.None - and deprecated_field = ref Ppx_yojson_conv_lib.Option.None - and detail_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and name_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and selectionRange_field = ref Ppx_yojson_conv_lib.Option.None - and tags_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "children" -> - (match Ppx_yojson_conv_lib.( ! ) children_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson t_of_yojson) - _field_yojson - in - children_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "deprecated" -> - (match Ppx_yojson_conv_lib.( ! ) deprecated_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - deprecated_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "detail" -> - (match Ppx_yojson_conv_lib.( ! ) detail_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - detail_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = SymbolKind.t_of_yojson _field_yojson in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "name" -> - (match Ppx_yojson_conv_lib.( ! ) name_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - name_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "selectionRange" -> - (match Ppx_yojson_conv_lib.( ! ) selectionRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - selectionRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tags" -> - (match Ppx_yojson_conv_lib.( ! ) tags_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson SymbolTag.t_of_yojson) - _field_yojson - in - tags_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) children_field - , Ppx_yojson_conv_lib.( ! ) deprecated_field - , Ppx_yojson_conv_lib.( ! ) detail_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) name_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) selectionRange_field - , Ppx_yojson_conv_lib.( ! ) tags_field ) - with - | ( children_value - , deprecated_value - , detail_value - , Ppx_yojson_conv_lib.Option.Some kind_value - , Ppx_yojson_conv_lib.Option.Some name_value - , Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some selectionRange_value - , tags_value ) -> - { children = - (match children_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; deprecated = - (match deprecated_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; detail = - (match detail_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; kind = kind_value - ; name = name_value - ; range = range_value - ; selectionRange = selectionRange_value - ; tags = - (match tags_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) kind_field) - Ppx_yojson_conv_lib.Option.None - , "kind" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) name_field) - Ppx_yojson_conv_lib.Option.None - , "name" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) selectionRange_field) - Ppx_yojson_conv_lib.Option.None - , "selectionRange" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let rec yojson_of_t = - (function - | { children = v_children - ; deprecated = v_deprecated - ; detail = v_detail - ; kind = v_kind - ; name = v_name - ; range = v_range - ; selectionRange = v_selectionRange - ; tags = v_tags - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_tags - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list SymbolTag.yojson_of_t)) - v_tags - in - let bnd = "tags", arg in - bnd :: bnds) - in - let bnds = - let arg = Range.yojson_of_t v_selectionRange in - ("selectionRange", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_name in - ("name", arg) :: bnds - in - let bnds = - let arg = SymbolKind.yojson_of_t v_kind in - ("kind", arg) :: bnds - in - let bnds = - if None = v_detail - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_detail in - let bnd = "detail", arg in - bnd :: bnds) - in - let bnds = - if None = v_deprecated - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_deprecated in - let bnd = "deprecated", arg in - bnd :: bnds) - in - let bnds = - if None = v_children - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_t)) v_children - in - let bnd = "children", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(children : t list option) - ?(deprecated : bool option) - ?(detail : string option) - ~(kind : SymbolKind.t) - ~(name : string) - ~(range : Range.t) - ~(selectionRange : Range.t) - ?(tags : SymbolTag.t list option) - (() : unit) + ?(children : t list option) + ?(deprecated : bool option) + ?(detail : string option) + ~(kind : SymbolKind.t) + ~(name : string) + ~(range : Range.t) + ~(selectionRange : Range.t) + ?(tags : SymbolTag.t list option) + (() : unit) : t = { children; deprecated; detail; kind; name; range; selectionRange; tags } @@ -31891,109 +5412,9 @@ module DocumentSymbolOptions = struct type t = { label : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentSymbolOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let label_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "label" -> - (match Ppx_yojson_conv_lib.( ! ) label_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - label_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let label_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) label_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { label = - (match label_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { label = v_label; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_label - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_label in - let bnd = "label", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(label : string option) ?(workDoneProgress : bool option) (() : unit) : t = { label; workDoneProgress } @@ -32003,154 +5424,18 @@ end module DocumentSymbolParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentSymbolParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; textDocument; workDoneToken } @@ -32160,149 +5445,18 @@ end module DocumentSymbolRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; label : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.DocumentSymbolRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and label_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "label" -> - (match Ppx_yojson_conv_lib.( ! ) label_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - label_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, label_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) label_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; label = - (match label_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; label = v_label - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_label - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_label in - let bnd = "label", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(label : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(label : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; label; workDoneProgress } @@ -32313,110 +5467,9 @@ module ExecuteCommandOptions = struct type t = { commands : string list ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ExecuteCommandOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let commands_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "commands" -> - (match Ppx_yojson_conv_lib.( ! ) commands_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - commands_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) commands_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - with - | Ppx_yojson_conv_lib.Option.Some commands_value, workDoneProgress_value -> - { commands = commands_value - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) commands_field) - Ppx_yojson_conv_lib.Option.None - , "commands" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { commands = v_commands; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list yojson_of_string v_commands in - ("commands", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(commands : string list) ?(workDoneProgress : bool option) (() : unit) : t = { commands; workDoneProgress } @@ -32426,152 +5479,18 @@ end module ExecuteCommandParams = struct type t = { arguments : Json.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; command : string ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ExecuteCommandParams.t" in - function - | `Assoc field_yojsons as yojson -> - let arguments_field = ref Ppx_yojson_conv_lib.Option.None - and command_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "arguments" -> - (match Ppx_yojson_conv_lib.( ! ) arguments_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson Json.t_of_yojson) - _field_yojson - in - arguments_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "command" -> - (match Ppx_yojson_conv_lib.( ! ) command_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - command_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) arguments_field - , Ppx_yojson_conv_lib.( ! ) command_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( arguments_value - , Ppx_yojson_conv_lib.Option.Some command_value - , workDoneToken_value ) -> - { arguments = - (match arguments_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; command = command_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) command_field) - Ppx_yojson_conv_lib.Option.None - , "command" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { arguments = v_arguments; command = v_command; workDoneToken = v_workDoneToken } - -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_command in - ("command", arg) :: bnds - in - let bnds = - if None = v_arguments - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list Json.yojson_of_t)) - v_arguments - in - let bnd = "arguments", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(arguments : Json.t list option) - ~(command : string) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(arguments : Json.t list option) + ~(command : string) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { arguments; command; workDoneToken } @@ -32582,110 +5501,9 @@ module ExecuteCommandRegistrationOptions = struct type t = { commands : string list ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ExecuteCommandRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let commands_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "commands" -> - (match Ppx_yojson_conv_lib.( ! ) commands_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - commands_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) commands_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - with - | Ppx_yojson_conv_lib.Option.Some commands_value, workDoneProgress_value -> - { commands = commands_value - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) commands_field) - Ppx_yojson_conv_lib.Option.None - , "commands" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { commands = v_commands; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list yojson_of_string v_commands in - ("commands", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(commands : string list) ?(workDoneProgress : bool option) (() : unit) : t = { commands; workDoneProgress } @@ -32695,82 +5513,9 @@ end module FileOperationPatternOptions = struct type t = { ignoreCase : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileOperationPatternOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let ignoreCase_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "ignoreCase" -> - (match Ppx_yojson_conv_lib.( ! ) ignoreCase_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - ignoreCase_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ignoreCase_value = Ppx_yojson_conv_lib.( ! ) ignoreCase_field in - { ignoreCase = - (match ignoreCase_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { ignoreCase = v_ignoreCase } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_ignoreCase - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_ignoreCase in - let bnd = "ignoreCase", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(ignoreCase : bool option) (() : unit) : t = { ignoreCase } end @@ -32779,150 +5524,17 @@ module FileOperationPattern = struct type t = { glob : string ; matches : FileOperationPatternKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; options : FileOperationPatternOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileOperationPattern.t" in - function - | `Assoc field_yojsons as yojson -> - let glob_field = ref Ppx_yojson_conv_lib.Option.None - and matches_field = ref Ppx_yojson_conv_lib.Option.None - and options_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "glob" -> - (match Ppx_yojson_conv_lib.( ! ) glob_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - glob_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "matches" -> - (match Ppx_yojson_conv_lib.( ! ) matches_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FileOperationPatternKind.t_of_yojson - _field_yojson - in - matches_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "options" -> - (match Ppx_yojson_conv_lib.( ! ) options_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FileOperationPatternOptions.t_of_yojson - _field_yojson - in - options_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) glob_field - , Ppx_yojson_conv_lib.( ! ) matches_field - , Ppx_yojson_conv_lib.( ! ) options_field ) - with - | Ppx_yojson_conv_lib.Option.Some glob_value, matches_value, options_value - -> - { glob = glob_value - ; matches = - (match matches_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; options = - (match options_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) glob_field) - Ppx_yojson_conv_lib.Option.None - , "glob" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { glob = v_glob; matches = v_matches; options = v_options } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_options - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t FileOperationPatternOptions.yojson_of_t) - v_options - in - let bnd = "options", arg in - bnd :: bnds) - in - let bnds = - if None = v_matches - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t FileOperationPatternKind.yojson_of_t) - v_matches - in - let bnd = "matches", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_glob in - ("glob", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(glob : string) - ?(matches : FileOperationPatternKind.t option) - ?(options : FileOperationPatternOptions.t option) - (() : unit) + ~(glob : string) + ?(matches : FileOperationPatternKind.t option) + ?(options : FileOperationPatternOptions.t option) + (() : unit) : t = { glob; matches; options } @@ -32934,106 +5546,7 @@ module FileOperationFilter = struct { pattern : FileOperationPattern.t ; scheme : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileOperationFilter.t" in - function - | `Assoc field_yojsons as yojson -> - let pattern_field = ref Ppx_yojson_conv_lib.Option.None - and scheme_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "pattern" -> - (match Ppx_yojson_conv_lib.( ! ) pattern_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = FileOperationPattern.t_of_yojson _field_yojson in - pattern_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "scheme" -> - (match Ppx_yojson_conv_lib.( ! ) scheme_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - scheme_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) pattern_field - , Ppx_yojson_conv_lib.( ! ) scheme_field ) - with - | Ppx_yojson_conv_lib.Option.Some pattern_value, scheme_value -> - { pattern = pattern_value - ; scheme = - (match scheme_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) pattern_field) - Ppx_yojson_conv_lib.Option.None - , "pattern" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { pattern = v_pattern; scheme = v_scheme } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_scheme - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_scheme in - let bnd = "scheme", arg in - bnd :: bnds) - in - let bnds = - let arg = FileOperationPattern.yojson_of_t v_pattern in - ("pattern", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(pattern : FileOperationPattern.t) ?(scheme : string option) (() : unit) : t = @@ -33043,82 +5556,7 @@ end module FileOperationRegistrationOptions = struct type t = { filters : FileOperationFilter.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileOperationRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let filters_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "filters" -> - (match Ppx_yojson_conv_lib.( ! ) filters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson FileOperationFilter.t_of_yojson _field_yojson - in - filters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) filters_field with - | Ppx_yojson_conv_lib.Option.Some filters_value -> - { filters = filters_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) filters_field) - Ppx_yojson_conv_lib.Option.None - , "filters" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { filters = v_filters } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list FileOperationFilter.yojson_of_t v_filters in - ("filters", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(filters : FileOperationFilter.t list) : t = { filters } end @@ -33126,266 +5564,28 @@ end module FileOperationOptions = struct type t = { didCreate : FileOperationRegistrationOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; didDelete : FileOperationRegistrationOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; didRename : FileOperationRegistrationOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; willCreate : FileOperationRegistrationOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; willDelete : FileOperationRegistrationOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; willRename : FileOperationRegistrationOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileOperationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let didCreate_field = ref Ppx_yojson_conv_lib.Option.None - and didDelete_field = ref Ppx_yojson_conv_lib.Option.None - and didRename_field = ref Ppx_yojson_conv_lib.Option.None - and willCreate_field = ref Ppx_yojson_conv_lib.Option.None - and willDelete_field = ref Ppx_yojson_conv_lib.Option.None - and willRename_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "didCreate" -> - (match Ppx_yojson_conv_lib.( ! ) didCreate_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FileOperationRegistrationOptions.t_of_yojson - _field_yojson - in - didCreate_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "didDelete" -> - (match Ppx_yojson_conv_lib.( ! ) didDelete_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FileOperationRegistrationOptions.t_of_yojson - _field_yojson - in - didDelete_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "didRename" -> - (match Ppx_yojson_conv_lib.( ! ) didRename_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FileOperationRegistrationOptions.t_of_yojson - _field_yojson - in - didRename_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "willCreate" -> - (match Ppx_yojson_conv_lib.( ! ) willCreate_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FileOperationRegistrationOptions.t_of_yojson - _field_yojson - in - willCreate_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "willDelete" -> - (match Ppx_yojson_conv_lib.( ! ) willDelete_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FileOperationRegistrationOptions.t_of_yojson - _field_yojson - in - willDelete_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "willRename" -> - (match Ppx_yojson_conv_lib.( ! ) willRename_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FileOperationRegistrationOptions.t_of_yojson - _field_yojson - in - willRename_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( didCreate_value - , didDelete_value - , didRename_value - , willCreate_value - , willDelete_value - , willRename_value ) - = - ( Ppx_yojson_conv_lib.( ! ) didCreate_field - , Ppx_yojson_conv_lib.( ! ) didDelete_field - , Ppx_yojson_conv_lib.( ! ) didRename_field - , Ppx_yojson_conv_lib.( ! ) willCreate_field - , Ppx_yojson_conv_lib.( ! ) willDelete_field - , Ppx_yojson_conv_lib.( ! ) willRename_field ) - in - { didCreate = - (match didCreate_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; didDelete = - (match didDelete_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; didRename = - (match didRename_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; willCreate = - (match willCreate_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; willDelete = - (match willDelete_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; willRename = - (match willRename_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { didCreate = v_didCreate - ; didDelete = v_didDelete - ; didRename = v_didRename - ; willCreate = v_willCreate - ; willDelete = v_willDelete - ; willRename = v_willRename - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_willRename - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - FileOperationRegistrationOptions.yojson_of_t) - v_willRename - in - let bnd = "willRename", arg in - bnd :: bnds) - in - let bnds = - if None = v_willDelete - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - FileOperationRegistrationOptions.yojson_of_t) - v_willDelete - in - let bnd = "willDelete", arg in - bnd :: bnds) - in - let bnds = - if None = v_willCreate - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - FileOperationRegistrationOptions.yojson_of_t) - v_willCreate - in - let bnd = "willCreate", arg in - bnd :: bnds) - in - let bnds = - if None = v_didRename - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - FileOperationRegistrationOptions.yojson_of_t) - v_didRename - in - let bnd = "didRename", arg in - bnd :: bnds) - in - let bnds = - if None = v_didDelete - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - FileOperationRegistrationOptions.yojson_of_t) - v_didDelete - in - let bnd = "didDelete", arg in - bnd :: bnds) - in - let bnds = - if None = v_didCreate - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - FileOperationRegistrationOptions.yojson_of_t) - v_didCreate - in - let bnd = "didCreate", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(didCreate : FileOperationRegistrationOptions.t option) - ?(didDelete : FileOperationRegistrationOptions.t option) - ?(didRename : FileOperationRegistrationOptions.t option) - ?(willCreate : FileOperationRegistrationOptions.t option) - ?(willDelete : FileOperationRegistrationOptions.t option) - ?(willRename : FileOperationRegistrationOptions.t option) - (() : unit) + ?(didCreate : FileOperationRegistrationOptions.t option) + ?(didDelete : FileOperationRegistrationOptions.t option) + ?(didRename : FileOperationRegistrationOptions.t option) + ?(willCreate : FileOperationRegistrationOptions.t option) + ?(willDelete : FileOperationRegistrationOptions.t option) + ?(willRename : FileOperationRegistrationOptions.t option) + (() : unit) : t = { didCreate; didDelete; didRename; willCreate; willDelete; willRename } @@ -33397,100 +5597,7 @@ module FileRename = struct { newUri : string ; oldUri : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FileRename.t" in - function - | `Assoc field_yojsons as yojson -> - let newUri_field = ref Ppx_yojson_conv_lib.Option.None - and oldUri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "newUri" -> - (match Ppx_yojson_conv_lib.( ! ) newUri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - newUri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "oldUri" -> - (match Ppx_yojson_conv_lib.( ! ) oldUri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - oldUri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) newUri_field - , Ppx_yojson_conv_lib.( ! ) oldUri_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some newUri_value - , Ppx_yojson_conv_lib.Option.Some oldUri_value ) -> - { newUri = newUri_value; oldUri = oldUri_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) newUri_field) - Ppx_yojson_conv_lib.Option.None - , "newUri" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) oldUri_field) - Ppx_yojson_conv_lib.Option.None - , "oldUri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { newUri = v_newUri; oldUri = v_oldUri } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_oldUri in - ("oldUri", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_newUri in - ("newUri", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(newUri : string) ~(oldUri : string) : t = { newUri; oldUri } end @@ -33498,229 +5605,26 @@ end module FoldingRange = struct type t = { collapsedText : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; endCharacter : int Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; endLine : int ; kind : FoldingRangeKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; startCharacter : int Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; startLine : int } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FoldingRange.t" in - function - | `Assoc field_yojsons as yojson -> - let collapsedText_field = ref Ppx_yojson_conv_lib.Option.None - and endCharacter_field = ref Ppx_yojson_conv_lib.Option.None - and endLine_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and startCharacter_field = ref Ppx_yojson_conv_lib.Option.None - and startLine_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "collapsedText" -> - (match Ppx_yojson_conv_lib.( ! ) collapsedText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - collapsedText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "endCharacter" -> - (match Ppx_yojson_conv_lib.( ! ) endCharacter_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - endCharacter_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "endLine" -> - (match Ppx_yojson_conv_lib.( ! ) endLine_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - endLine_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FoldingRangeKind.t_of_yojson - _field_yojson - in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "startCharacter" -> - (match Ppx_yojson_conv_lib.( ! ) startCharacter_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - startCharacter_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "startLine" -> - (match Ppx_yojson_conv_lib.( ! ) startLine_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - startLine_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) collapsedText_field - , Ppx_yojson_conv_lib.( ! ) endCharacter_field - , Ppx_yojson_conv_lib.( ! ) endLine_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) startCharacter_field - , Ppx_yojson_conv_lib.( ! ) startLine_field ) - with - | ( collapsedText_value - , endCharacter_value - , Ppx_yojson_conv_lib.Option.Some endLine_value - , kind_value - , startCharacter_value - , Ppx_yojson_conv_lib.Option.Some startLine_value ) -> - { collapsedText = - (match collapsedText_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; endCharacter = - (match endCharacter_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; endLine = endLine_value - ; kind = - (match kind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; startCharacter = - (match startCharacter_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; startLine = startLine_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) endLine_field) - Ppx_yojson_conv_lib.Option.None - , "endLine" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) startLine_field) - Ppx_yojson_conv_lib.Option.None - , "startLine" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { collapsedText = v_collapsedText - ; endCharacter = v_endCharacter - ; endLine = v_endLine - ; kind = v_kind - ; startCharacter = v_startCharacter - ; startLine = v_startLine - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_int v_startLine in - ("startLine", arg) :: bnds - in - let bnds = - if None = v_startCharacter - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_startCharacter in - let bnd = "startCharacter", arg in - bnd :: bnds) - in - let bnds = - if None = v_kind - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t FoldingRangeKind.yojson_of_t) v_kind - in - let bnd = "kind", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_int v_endLine in - ("endLine", arg) :: bnds - in - let bnds = - if None = v_endCharacter - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_endCharacter in - let bnd = "endCharacter", arg in - bnd :: bnds) - in - let bnds = - if None = v_collapsedText - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_string) v_collapsedText - in - let bnd = "collapsedText", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(collapsedText : string option) - ?(endCharacter : int option) - ~(endLine : int) - ?(kind : FoldingRangeKind.t option) - ?(startCharacter : int option) - ~(startLine : int) - (() : unit) + ?(collapsedText : string option) + ?(endCharacter : int option) + ~(endLine : int) + ?(kind : FoldingRangeKind.t option) + ?(startCharacter : int option) + ~(startLine : int) + (() : unit) : t = { collapsedText; endCharacter; endLine; kind; startCharacter; startLine } @@ -33730,86 +5634,9 @@ end module FoldingRangeOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FoldingRangeOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -33817,154 +5644,18 @@ end module FoldingRangeParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FoldingRangeParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; textDocument; workDoneToken } @@ -33974,149 +5665,18 @@ end module FoldingRangeRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.FoldingRangeRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -34151,106 +5711,7 @@ module Hover = struct { contents : contents_pvar ; range : Range.t Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.Hover.t" in - function - | `Assoc field_yojsons as yojson -> - let contents_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "contents" -> - (match Ppx_yojson_conv_lib.( ! ) contents_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = contents_pvar_of_yojson _field_yojson in - contents_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Range.t_of_yojson _field_yojson - in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) contents_field - , Ppx_yojson_conv_lib.( ! ) range_field ) - with - | Ppx_yojson_conv_lib.Option.Some contents_value, range_value -> - { contents = contents_value - ; range = - (match range_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) contents_field) - Ppx_yojson_conv_lib.Option.None - , "contents" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { contents = v_contents; range = v_range } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_range - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Range.yojson_of_t) v_range in - let bnd = "range", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_contents_pvar v_contents in - ("contents", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(contents : contents_pvar) ?(range : Range.t option) (() : unit) : t = { contents; range } @@ -34260,86 +5721,9 @@ end module HoverOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.HoverOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -34349,141 +5733,15 @@ module HoverParams = struct { position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.HoverParams.t" in - function - | `Assoc field_yojsons as yojson -> - let position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { position; textDocument; workDoneToken } @@ -34493,121 +5751,16 @@ end module HoverRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.HoverRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; workDoneProgress } @@ -34617,86 +5770,9 @@ end module ImplementationOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ImplementationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -34704,176 +5780,20 @@ end module ImplementationParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ImplementationParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; position; textDocument; workDoneToken } @@ -34883,149 +5803,18 @@ end module ImplementationRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ImplementationRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -35033,79 +5822,7 @@ module ImplementationRegistrationOptions = struct end module InitializeError = struct - type t = { retry : bool } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InitializeError.t" in - function - | `Assoc field_yojsons as yojson -> - let retry_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "retry" -> - (match Ppx_yojson_conv_lib.( ! ) retry_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - retry_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) retry_field with - | Ppx_yojson_conv_lib.Option.Some retry_value -> { retry = retry_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) retry_field) - Ppx_yojson_conv_lib.Option.None - , "retry" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { retry = v_retry } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_retry in - ("retry", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { retry : bool } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(retry : bool) : t = { retry } end @@ -35115,106 +5832,7 @@ module InitializeParams = struct { name : string ; version : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : clientInfo) -> () - - let clientInfo_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InitializeParams.clientInfo" in - function - | `Assoc field_yojsons as yojson -> - let name_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "name" -> - (match Ppx_yojson_conv_lib.( ! ) name_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - name_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) name_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | Ppx_yojson_conv_lib.Option.Some name_value, version_value -> - { name = name_value - ; version = - (match version_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) name_field) - Ppx_yojson_conv_lib.Option.None - , "name" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> clientInfo) - ;; - - let _ = clientInfo_of_yojson - - let yojson_of_clientInfo = - (function - | { name = v_name; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_version - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_version in - let bnd = "version", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_name in - ("name", arg) :: bnds - in - `Assoc bnds - : clientInfo -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_clientInfo - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_clientInfo ~(name : string) ?(version : string option) (() : unit) : clientInfo @@ -35222,358 +5840,50 @@ module InitializeParams = struct { name; version } ;; + let get_editor { name; version } = + let editor = + match Base.String.split ~on:' ' name with + | [] -> "" + | first_tok :: _ -> first_tok + in + match version with + | None -> editor, "unknown" + | Some v -> editor, v + ;; + type t = { capabilities : ClientCapabilities.t ; clientInfo : clientInfo Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; initializationOptions : Json.t option [@yojson.option] ; locale : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; processId : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; rootPath : string Json.Nullable_option.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; rootUri : DocumentUri.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; trace : TraceValues.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workspaceFolders : WorkspaceFolder.t list Json.Nullable_option.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InitializeParams.t" in - function - | `Assoc field_yojsons as yojson -> - let capabilities_field = ref Ppx_yojson_conv_lib.Option.None - and clientInfo_field = ref Ppx_yojson_conv_lib.Option.None - and initializationOptions_field = ref Ppx_yojson_conv_lib.Option.None - and locale_field = ref Ppx_yojson_conv_lib.Option.None - and processId_field = ref Ppx_yojson_conv_lib.Option.None - and rootPath_field = ref Ppx_yojson_conv_lib.Option.None - and rootUri_field = ref Ppx_yojson_conv_lib.Option.None - and trace_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and workspaceFolders_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "capabilities" -> - (match Ppx_yojson_conv_lib.( ! ) capabilities_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = ClientCapabilities.t_of_yojson _field_yojson in - capabilities_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "clientInfo" -> - (match Ppx_yojson_conv_lib.( ! ) clientInfo_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson clientInfo_of_yojson _field_yojson - in - clientInfo_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "initializationOptions" -> - (match Ppx_yojson_conv_lib.( ! ) initializationOptions_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - initializationOptions_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "locale" -> - (match Ppx_yojson_conv_lib.( ! ) locale_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - locale_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "processId" -> - (match Ppx_yojson_conv_lib.( ! ) processId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - processId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "rootPath" -> - (match Ppx_yojson_conv_lib.( ! ) rootPath_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (Json.Nullable_option.t_of_yojson string_of_yojson) - _field_yojson - in - rootPath_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "rootUri" -> - (match Ppx_yojson_conv_lib.( ! ) rootUri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson DocumentUri.t_of_yojson _field_yojson - in - rootUri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "trace" -> - (match Ppx_yojson_conv_lib.( ! ) trace_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson TraceValues.t_of_yojson _field_yojson - in - trace_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workspaceFolders" -> - (match Ppx_yojson_conv_lib.( ! ) workspaceFolders_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (Json.Nullable_option.t_of_yojson - (list_of_yojson WorkspaceFolder.t_of_yojson)) - _field_yojson - in - workspaceFolders_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) capabilities_field - , Ppx_yojson_conv_lib.( ! ) clientInfo_field - , Ppx_yojson_conv_lib.( ! ) initializationOptions_field - , Ppx_yojson_conv_lib.( ! ) locale_field - , Ppx_yojson_conv_lib.( ! ) processId_field - , Ppx_yojson_conv_lib.( ! ) rootPath_field - , Ppx_yojson_conv_lib.( ! ) rootUri_field - , Ppx_yojson_conv_lib.( ! ) trace_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field - , Ppx_yojson_conv_lib.( ! ) workspaceFolders_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some capabilities_value - , clientInfo_value - , initializationOptions_value - , locale_value - , processId_value - , rootPath_value - , rootUri_value - , trace_value - , workDoneToken_value - , workspaceFolders_value ) -> - { capabilities = capabilities_value - ; clientInfo = - (match clientInfo_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; initializationOptions = initializationOptions_value - ; locale = - (match locale_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; processId = - (match processId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; rootPath = - (match rootPath_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; rootUri = - (match rootUri_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; trace = - (match trace_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workspaceFolders = - (match workspaceFolders_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) capabilities_field) - Ppx_yojson_conv_lib.Option.None - , "capabilities" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { capabilities = v_capabilities - ; clientInfo = v_clientInfo - ; initializationOptions = v_initializationOptions - ; locale = v_locale - ; processId = v_processId - ; rootPath = v_rootPath - ; rootUri = v_rootUri - ; trace = v_trace - ; workDoneToken = v_workDoneToken - ; workspaceFolders = v_workspaceFolders - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workspaceFolders - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (Json.Nullable_option.yojson_of_t - (yojson_of_list WorkspaceFolder.yojson_of_t))) - v_workspaceFolders - in - let bnd = "workspaceFolders", arg in - bnd :: bnds) - in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - if None = v_trace - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t TraceValues.yojson_of_t) v_trace in - let bnd = "trace", arg in - bnd :: bnds) - in - let bnds = - if None = v_rootUri - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentUri.yojson_of_t) v_rootUri - in - let bnd = "rootUri", arg in - bnd :: bnds) - in - let bnds = - if None = v_rootPath - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (Json.Nullable_option.yojson_of_t yojson_of_string)) - v_rootPath - in - let bnd = "rootPath", arg in - bnd :: bnds) - in - let bnds = - if None = v_processId - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_processId in - let bnd = "processId", arg in - bnd :: bnds) - in - let bnds = - if None = v_locale - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_locale in - let bnd = "locale", arg in - bnd :: bnds) - in - let bnds = - match v_initializationOptions with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "initializationOptions", arg in - bnd :: bnds - in - let bnds = - if None = v_clientInfo - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_clientInfo) v_clientInfo - in - let bnd = "clientInfo", arg in - bnd :: bnds) - in - let bnds = - let arg = ClientCapabilities.yojson_of_t v_capabilities in - ("capabilities", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(capabilities : ClientCapabilities.t) - ?(clientInfo : clientInfo option) - ?(initializationOptions : Json.t option) - ?(locale : string option) - ?(processId : int option) - ?(rootPath : string option option) - ?(rootUri : DocumentUri.t option) - ?(trace : TraceValues.t option) - ?(workDoneToken : ProgressToken.t option) - ?(workspaceFolders : WorkspaceFolder.t list option option) - (() : unit) + ~(capabilities : ClientCapabilities.t) + ?(clientInfo : clientInfo option) + ?(initializationOptions : Json.t option) + ?(locale : string option) + ?(processId : int option) + ?(rootPath : string option option) + ?(rootUri : DocumentUri.t option) + ?(trace : TraceValues.t option) + ?(workDoneToken : ProgressToken.t option) + ?(workspaceFolders : WorkspaceFolder.t list option option) + (() : unit) : t = { capabilities @@ -35593,118 +5903,16 @@ end module WorkspaceSymbolOptions = struct type t = { resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceSymbolOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let resolveProvider_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { resolveProvider = v_resolveProvider; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(resolveProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(resolveProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { resolveProvider; workDoneProgress } @@ -35725,7 +5933,7 @@ module WorkspaceFoldersServerCapabilities = struct ;; let yojson_of_changeNotifications_pvar - (changeNotifications_pvar : changeNotifications_pvar) + (changeNotifications_pvar : changeNotifications_pvar) : Json.t = match changeNotifications_pvar with @@ -35735,118 +5943,15 @@ module WorkspaceFoldersServerCapabilities = struct type t = { changeNotifications : changeNotifications_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; supported : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceFoldersServerCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let changeNotifications_field = ref Ppx_yojson_conv_lib.Option.None - and supported_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "changeNotifications" -> - (match Ppx_yojson_conv_lib.( ! ) changeNotifications_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - changeNotifications_pvar_of_yojson - _field_yojson - in - changeNotifications_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "supported" -> - (match Ppx_yojson_conv_lib.( ! ) supported_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - supported_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let changeNotifications_value, supported_value = - ( Ppx_yojson_conv_lib.( ! ) changeNotifications_field - , Ppx_yojson_conv_lib.( ! ) supported_field ) - in - { changeNotifications = - (match changeNotifications_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; supported = - (match supported_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { changeNotifications = v_changeNotifications; supported = v_supported } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_supported - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_supported in - let bnd = "supported", arg in - bnd :: bnds) - in - let bnds = - if None = v_changeNotifications - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_changeNotifications_pvar) - v_changeNotifications - in - let bnd = "changeNotifications", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(changeNotifications : changeNotifications_pvar option) - ?(supported : bool option) - (() : unit) + ?(changeNotifications : changeNotifications_pvar option) + ?(supported : bool option) + (() : unit) : t = { changeNotifications; supported } @@ -35856,149 +5961,18 @@ end module TypeHierarchyRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeHierarchyRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -36008,86 +5982,9 @@ end module TypeHierarchyOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeHierarchyOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -36095,149 +5992,18 @@ end module TypeDefinitionRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeDefinitionRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -36247,86 +6013,9 @@ end module TypeDefinitionOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeDefinitionOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -36334,82 +6023,9 @@ end module SaveOptions = struct type t = { includeText : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SaveOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let includeText_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "includeText" -> - (match Ppx_yojson_conv_lib.( ! ) includeText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - includeText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let includeText_value = Ppx_yojson_conv_lib.( ! ) includeText_field in - { includeText = - (match includeText_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { includeText = v_includeText } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_includeText - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_includeText in - let bnd = "includeText", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(includeText : bool option) (() : unit) : t = { includeText } end @@ -36438,205 +6054,22 @@ module TextDocumentSyncOptions = struct type t = { change : TextDocumentSyncKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; openClose : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; save : save_pvar Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; willSave : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; willSaveWaitUntil : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentSyncOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let change_field = ref Ppx_yojson_conv_lib.Option.None - and openClose_field = ref Ppx_yojson_conv_lib.Option.None - and save_field = ref Ppx_yojson_conv_lib.Option.None - and willSave_field = ref Ppx_yojson_conv_lib.Option.None - and willSaveWaitUntil_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "change" -> - (match Ppx_yojson_conv_lib.( ! ) change_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - TextDocumentSyncKind.t_of_yojson - _field_yojson - in - change_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "openClose" -> - (match Ppx_yojson_conv_lib.( ! ) openClose_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - openClose_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "save" -> - (match Ppx_yojson_conv_lib.( ! ) save_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson save_pvar_of_yojson _field_yojson - in - save_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "willSave" -> - (match Ppx_yojson_conv_lib.( ! ) willSave_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - willSave_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "willSaveWaitUntil" -> - (match Ppx_yojson_conv_lib.( ! ) willSaveWaitUntil_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - willSaveWaitUntil_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( change_value - , openClose_value - , save_value - , willSave_value - , willSaveWaitUntil_value ) - = - ( Ppx_yojson_conv_lib.( ! ) change_field - , Ppx_yojson_conv_lib.( ! ) openClose_field - , Ppx_yojson_conv_lib.( ! ) save_field - , Ppx_yojson_conv_lib.( ! ) willSave_field - , Ppx_yojson_conv_lib.( ! ) willSaveWaitUntil_field ) - in - { change = - (match change_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; openClose = - (match openClose_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; save = - (match save_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; willSave = - (match willSave_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; willSaveWaitUntil = - (match willSaveWaitUntil_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { change = v_change - ; openClose = v_openClose - ; save = v_save - ; willSave = v_willSave - ; willSaveWaitUntil = v_willSaveWaitUntil - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_willSaveWaitUntil - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_willSaveWaitUntil - in - let bnd = "willSaveWaitUntil", arg in - bnd :: bnds) - in - let bnds = - if None = v_willSave - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_willSave in - let bnd = "willSave", arg in - bnd :: bnds) - in - let bnds = - if None = v_save - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_save_pvar) v_save in - let bnd = "save", arg in - bnd :: bnds) - in - let bnds = - if None = v_openClose - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_openClose in - let bnd = "openClose", arg in - bnd :: bnds) - in - let bnds = - if None = v_change - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t TextDocumentSyncKind.yojson_of_t) v_change - in - let bnd = "change", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(change : TextDocumentSyncKind.t option) - ?(openClose : bool option) - ?(save : save_pvar option) - ?(willSave : bool option) - ?(willSaveWaitUntil : bool option) - (() : unit) + ?(change : TextDocumentSyncKind.t option) + ?(openClose : bool option) + ?(save : save_pvar option) + ?(willSave : bool option) + ?(willSaveWaitUntil : bool option) + (() : unit) : t = { change; openClose; save; willSave; willSaveWaitUntil } @@ -36646,158 +6079,19 @@ end module SignatureHelpOptions = struct type t = { retriggerCharacters : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; triggerCharacters : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SignatureHelpOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let retriggerCharacters_field = ref Ppx_yojson_conv_lib.Option.None - and triggerCharacters_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "retriggerCharacters" -> - (match Ppx_yojson_conv_lib.( ! ) retriggerCharacters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - retriggerCharacters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "triggerCharacters" -> - (match Ppx_yojson_conv_lib.( ! ) triggerCharacters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - triggerCharacters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( retriggerCharacters_value - , triggerCharacters_value - , workDoneProgress_value ) - = - ( Ppx_yojson_conv_lib.( ! ) retriggerCharacters_field - , Ppx_yojson_conv_lib.( ! ) triggerCharacters_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { retriggerCharacters = - (match retriggerCharacters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; triggerCharacters = - (match triggerCharacters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { retriggerCharacters = v_retriggerCharacters - ; triggerCharacters = v_triggerCharacters - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_triggerCharacters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_triggerCharacters - in - let bnd = "triggerCharacters", arg in - bnd :: bnds) - in - let bnds = - if None = v_retriggerCharacters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_retriggerCharacters - in - let bnd = "retriggerCharacters", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(retriggerCharacters : string list option) - ?(triggerCharacters : string list option) - ?(workDoneProgress : bool option) - (() : unit) + ?(retriggerCharacters : string list option) + ?(triggerCharacters : string list option) + ?(workDoneProgress : bool option) + (() : unit) : t = { retriggerCharacters; triggerCharacters; workDoneProgress } @@ -36809,100 +6103,7 @@ module SemanticTokensLegend = struct { tokenModifiers : string list ; tokenTypes : string list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensLegend.t" in - function - | `Assoc field_yojsons as yojson -> - let tokenModifiers_field = ref Ppx_yojson_conv_lib.Option.None - and tokenTypes_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "tokenModifiers" -> - (match Ppx_yojson_conv_lib.( ! ) tokenModifiers_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - tokenModifiers_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tokenTypes" -> - (match Ppx_yojson_conv_lib.( ! ) tokenTypes_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson string_of_yojson _field_yojson in - tokenTypes_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) tokenModifiers_field - , Ppx_yojson_conv_lib.( ! ) tokenTypes_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some tokenModifiers_value - , Ppx_yojson_conv_lib.Option.Some tokenTypes_value ) -> - { tokenModifiers = tokenModifiers_value; tokenTypes = tokenTypes_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) tokenModifiers_field) - Ppx_yojson_conv_lib.Option.None - , "tokenModifiers" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) tokenTypes_field) - Ppx_yojson_conv_lib.Option.None - , "tokenTypes" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { tokenModifiers = v_tokenModifiers; tokenTypes = v_tokenTypes } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list yojson_of_string v_tokenTypes in - ("tokenTypes", arg) :: bnds - in - let bnds = - let arg = yojson_of_list yojson_of_string v_tokenModifiers in - ("tokenModifiers", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(tokenModifiers : string list) ~(tokenTypes : string list) : t = { tokenModifiers; tokenTypes } @@ -36912,80 +6113,7 @@ end module SemanticTokensRegistrationOptions = struct type full = { delta : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : full) -> () - - let full_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensRegistrationOptions.full" in - function - | `Assoc field_yojsons as yojson -> - let delta_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "delta" -> - (match Ppx_yojson_conv_lib.( ! ) delta_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - delta_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let delta_value = Ppx_yojson_conv_lib.( ! ) delta_field in - { delta = - (match delta_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> full) - ;; - - let _ = full_of_yojson - - let yojson_of_full = - (function - | { delta = v_delta } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_delta - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_delta in - let bnd = "delta", arg in - bnd :: bnds) - in - `Assoc bnds - : full -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_full - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_full ?(delta : bool option) (() : unit) : full = { delta } @@ -37012,233 +6140,24 @@ module SemanticTokensRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; full : full_pvar Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; legend : SemanticTokensLegend.t ; range : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and full_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and legend_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "full" -> - (match Ppx_yojson_conv_lib.( ! ) full_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson full_pvar_of_yojson _field_yojson - in - full_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "legend" -> - (match Ppx_yojson_conv_lib.( ! ) legend_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = SemanticTokensLegend.t_of_yojson _field_yojson in - legend_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) full_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) legend_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - with - | ( documentSelector_value - , full_value - , id_value - , Ppx_yojson_conv_lib.Option.Some legend_value - , range_value - , workDoneProgress_value ) -> - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; full = - (match full_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; legend = legend_value - ; range = - (match range_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) legend_field) - Ppx_yojson_conv_lib.Option.None - , "legend" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; full = v_full - ; id = v_id - ; legend = v_legend - ; range = v_range - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_range - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_range in - let bnd = "range", arg in - bnd :: bnds) - in - let bnds = - let arg = SemanticTokensLegend.yojson_of_t v_legend in - ("legend", arg) :: bnds - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_full - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_full_pvar) v_full in - let bnd = "full", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(full : full_pvar option) - ?(id : string option) - ~(legend : SemanticTokensLegend.t) - ?(range : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(full : full_pvar option) + ?(id : string option) + ~(legend : SemanticTokensLegend.t) + ?(range : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; full; id; legend; range; workDoneProgress } @@ -37248,80 +6167,7 @@ end module SemanticTokensOptions = struct type full = { delta : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : full) -> () - - let full_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensOptions.full" in - function - | `Assoc field_yojsons as yojson -> - let delta_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "delta" -> - (match Ppx_yojson_conv_lib.( ! ) delta_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - delta_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let delta_value = Ppx_yojson_conv_lib.( ! ) delta_field in - { delta = - (match delta_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> full) - ;; - - let _ = full_of_yojson - - let yojson_of_full = - (function - | { delta = v_delta } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_delta - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_delta in - let bnd = "delta", arg in - bnd :: bnds) - in - `Assoc bnds - : full -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_full - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_full ?(delta : bool option) (() : unit) : full = { delta } @@ -37351,170 +6197,16 @@ module SemanticTokensOptions = struct ; legend : SemanticTokensLegend.t ; range : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let full_field = ref Ppx_yojson_conv_lib.Option.None - and legend_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "full" -> - (match Ppx_yojson_conv_lib.( ! ) full_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson full_pvar_of_yojson _field_yojson - in - full_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "legend" -> - (match Ppx_yojson_conv_lib.( ! ) legend_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = SemanticTokensLegend.t_of_yojson _field_yojson in - legend_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) full_field - , Ppx_yojson_conv_lib.( ! ) legend_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - with - | ( full_value - , Ppx_yojson_conv_lib.Option.Some legend_value - , range_value - , workDoneProgress_value ) -> - { full = - (match full_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; legend = legend_value - ; range = - (match range_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) legend_field) - Ppx_yojson_conv_lib.Option.None - , "legend" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { full = v_full - ; legend = v_legend - ; range = v_range - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_range - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_range in - let bnd = "range", arg in - bnd :: bnds) - in - let bnds = - let arg = SemanticTokensLegend.yojson_of_t v_legend in - ("legend", arg) :: bnds - in - let bnds = - if None = v_full - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_full_pvar) v_full in - let bnd = "full", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(full : full_pvar option) - ~(legend : SemanticTokensLegend.t) - ?(range : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(full : full_pvar option) + ~(legend : SemanticTokensLegend.t) + ?(range : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { full; legend; range; workDoneProgress } @@ -37524,149 +6216,18 @@ end module SelectionRangeRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SelectionRangeRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -37676,86 +6237,9 @@ end module SelectionRangeOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SelectionRangeOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -37763,118 +6247,16 @@ end module RenameOptions = struct type t = { prepareProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RenameOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let prepareProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "prepareProvider" -> - (match Ppx_yojson_conv_lib.( ! ) prepareProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - prepareProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let prepareProvider_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) prepareProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { prepareProvider = - (match prepareProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { prepareProvider = v_prepareProvider; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_prepareProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_prepareProvider - in - let bnd = "prepareProvider", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(prepareProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(prepareProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { prepareProvider; workDoneProgress } @@ -37884,86 +6266,9 @@ end module ReferenceOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ReferenceOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -37971,121 +6276,16 @@ end module MonikerRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.MonikerRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; workDoneProgress } @@ -38095,86 +6295,9 @@ end module MonikerOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.MonikerOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -38182,149 +6305,18 @@ end module LinkedEditingRangeRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.LinkedEditingRangeRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -38334,86 +6326,9 @@ end module LinkedEditingRangeOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.LinkedEditingRangeOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -38421,149 +6336,18 @@ end module InlineValueRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineValueRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -38573,86 +6357,9 @@ end module InlineValueOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineValueOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -38660,86 +6367,9 @@ end module InlineCompletionOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineCompletionOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -38747,182 +6377,21 @@ end module InlayHintRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlayHintRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( documentSelector_value - , id_value - , resolveProvider_value - , workDoneProgress_value ) - = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; resolveProvider = v_resolveProvider - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(resolveProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(resolveProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; resolveProvider; workDoneProgress } @@ -38932,118 +6401,16 @@ end module InlayHintOptions = struct type t = { resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlayHintOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let resolveProvider_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { resolveProvider = v_resolveProvider; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(resolveProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(resolveProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { resolveProvider; workDoneProgress } @@ -39053,125 +6420,16 @@ end module ServerCapabilities = struct type workspace = { workspaceFolders : WorkspaceFoldersServerCapabilities.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; fileOperations : FileOperationOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : workspace) -> () - - let workspace_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ServerCapabilities.workspace" in - function - | `Assoc field_yojsons as yojson -> - let workspaceFolders_field = ref Ppx_yojson_conv_lib.Option.None - and fileOperations_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workspaceFolders" -> - (match Ppx_yojson_conv_lib.( ! ) workspaceFolders_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - WorkspaceFoldersServerCapabilities.t_of_yojson - _field_yojson - in - workspaceFolders_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "fileOperations" -> - (match Ppx_yojson_conv_lib.( ! ) fileOperations_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - FileOperationOptions.t_of_yojson - _field_yojson - in - fileOperations_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workspaceFolders_value, fileOperations_value = - ( Ppx_yojson_conv_lib.( ! ) workspaceFolders_field - , Ppx_yojson_conv_lib.( ! ) fileOperations_field ) - in - { workspaceFolders = - (match workspaceFolders_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; fileOperations = - (match fileOperations_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> workspace) - ;; - - let _ = workspace_of_yojson - - let yojson_of_workspace = - (function - | { workspaceFolders = v_workspaceFolders; fileOperations = v_fileOperations } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_fileOperations - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t FileOperationOptions.yojson_of_t) - v_fileOperations - in - let bnd = "fileOperations", arg in - bnd :: bnds) - in - let bnds = - if None = v_workspaceFolders - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - WorkspaceFoldersServerCapabilities.yojson_of_t) - v_workspaceFolders - in - let bnd = "workspaceFolders", arg in - bnd :: bnds) - in - `Assoc bnds - : workspace -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_workspace - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_workspace - ?(workspaceFolders : WorkspaceFoldersServerCapabilities.t option) - ?(fileOperations : FileOperationOptions.t option) - (() : unit) + ?(workspaceFolders : WorkspaceFoldersServerCapabilities.t option) + ?(fileOperations : FileOperationOptions.t option) + (() : unit) : workspace = { workspaceFolders; fileOperations } @@ -39179,86 +6437,9 @@ module ServerCapabilities = struct type diagnostic = { markupMessageSupport : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : diagnostic) -> () - - let diagnostic_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ServerCapabilities.diagnostic" in - function - | `Assoc field_yojsons as yojson -> - let markupMessageSupport_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "markupMessageSupport" -> - (match Ppx_yojson_conv_lib.( ! ) markupMessageSupport_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - markupMessageSupport_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let markupMessageSupport_value = - Ppx_yojson_conv_lib.( ! ) markupMessageSupport_field - in - { markupMessageSupport = - (match markupMessageSupport_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> diagnostic) - ;; - - let _ = diagnostic_of_yojson - - let yojson_of_diagnostic = - (function - | { markupMessageSupport = v_markupMessageSupport } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_markupMessageSupport - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_markupMessageSupport - in - let bnd = "markupMessageSupport", arg in - bnd :: bnds) - in - `Assoc bnds - : diagnostic -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_diagnostic - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_diagnostic ?(markupMessageSupport : bool option) (() : unit) : diagnostic = { markupMessageSupport } @@ -39266,84 +6447,9 @@ module ServerCapabilities = struct type textDocument = { diagnostic : diagnostic Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : textDocument) -> () - - let textDocument_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ServerCapabilities.textDocument" in - function - | `Assoc field_yojsons as yojson -> - let diagnostic_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "diagnostic" -> - (match Ppx_yojson_conv_lib.( ! ) diagnostic_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson diagnostic_of_yojson _field_yojson - in - diagnostic_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let diagnostic_value = Ppx_yojson_conv_lib.( ! ) diagnostic_field in - { diagnostic = - (match diagnostic_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> textDocument) - ;; - - let _ = textDocument_of_yojson - - let yojson_of_textDocument = - (function - | { diagnostic = v_diagnostic } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_diagnostic - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_diagnostic) v_diagnostic - in - let bnd = "diagnostic", arg in - bnd :: bnds) - in - `Assoc bnds - : textDocument -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_textDocument - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_textDocument ?(diagnostic : diagnostic option) (() : unit) : textDocument = { diagnostic } @@ -39370,7 +6476,7 @@ module ServerCapabilities = struct ;; let yojson_of_callHierarchyProvider_pvar - (callHierarchyProvider_pvar : callHierarchyProvider_pvar) + (callHierarchyProvider_pvar : callHierarchyProvider_pvar) : Json.t = match callHierarchyProvider_pvar with @@ -39396,7 +6502,7 @@ module ServerCapabilities = struct ;; let yojson_of_codeActionProvider_pvar - (codeActionProvider_pvar : codeActionProvider_pvar) + (codeActionProvider_pvar : codeActionProvider_pvar) : Json.t = match codeActionProvider_pvar with @@ -39453,7 +6559,7 @@ module ServerCapabilities = struct ;; let yojson_of_declarationProvider_pvar - (declarationProvider_pvar : declarationProvider_pvar) + (declarationProvider_pvar : declarationProvider_pvar) : Json.t = match declarationProvider_pvar with @@ -39478,7 +6584,7 @@ module ServerCapabilities = struct ;; let yojson_of_definitionProvider_pvar - (definitionProvider_pvar : definitionProvider_pvar) + (definitionProvider_pvar : definitionProvider_pvar) : Json.t = match definitionProvider_pvar with @@ -39502,7 +6608,7 @@ module ServerCapabilities = struct ;; let yojson_of_diagnosticProvider_pvar - (diagnosticProvider_pvar : diagnosticProvider_pvar) + (diagnosticProvider_pvar : diagnosticProvider_pvar) : Json.t = match diagnosticProvider_pvar with @@ -39530,7 +6636,7 @@ module ServerCapabilities = struct ;; let yojson_of_documentFormattingProvider_pvar - (documentFormattingProvider_pvar : documentFormattingProvider_pvar) + (documentFormattingProvider_pvar : documentFormattingProvider_pvar) : Json.t = match documentFormattingProvider_pvar with @@ -39558,7 +6664,7 @@ module ServerCapabilities = struct ;; let yojson_of_documentHighlightProvider_pvar - (documentHighlightProvider_pvar : documentHighlightProvider_pvar) + (documentHighlightProvider_pvar : documentHighlightProvider_pvar) : Json.t = match documentHighlightProvider_pvar with @@ -39587,7 +6693,7 @@ module ServerCapabilities = struct ;; let yojson_of_documentRangeFormattingProvider_pvar - (documentRangeFormattingProvider_pvar : documentRangeFormattingProvider_pvar) + (documentRangeFormattingProvider_pvar : documentRangeFormattingProvider_pvar) : Json.t = match documentRangeFormattingProvider_pvar with @@ -39611,7 +6717,7 @@ module ServerCapabilities = struct ;; let yojson_of_documentSymbolProvider_pvar - (documentSymbolProvider_pvar : documentSymbolProvider_pvar) + (documentSymbolProvider_pvar : documentSymbolProvider_pvar) : Json.t = match documentSymbolProvider_pvar with @@ -39640,7 +6746,7 @@ module ServerCapabilities = struct ;; let yojson_of_foldingRangeProvider_pvar - (foldingRangeProvider_pvar : foldingRangeProvider_pvar) + (foldingRangeProvider_pvar : foldingRangeProvider_pvar) : Json.t = match foldingRangeProvider_pvar with @@ -39691,7 +6797,7 @@ module ServerCapabilities = struct ;; let yojson_of_implementationProvider_pvar - (implementationProvider_pvar : implementationProvider_pvar) + (implementationProvider_pvar : implementationProvider_pvar) : Json.t = match implementationProvider_pvar with @@ -39749,7 +6855,7 @@ module ServerCapabilities = struct ;; let yojson_of_inlineCompletionProvider_pvar - (inlineCompletionProvider_pvar : inlineCompletionProvider_pvar) + (inlineCompletionProvider_pvar : inlineCompletionProvider_pvar) : Json.t = match inlineCompletionProvider_pvar with @@ -39778,7 +6884,7 @@ module ServerCapabilities = struct ;; let yojson_of_inlineValueProvider_pvar - (inlineValueProvider_pvar : inlineValueProvider_pvar) + (inlineValueProvider_pvar : inlineValueProvider_pvar) : Json.t = match inlineValueProvider_pvar with @@ -39811,7 +6917,7 @@ module ServerCapabilities = struct ;; let yojson_of_linkedEditingRangeProvider_pvar - (linkedEditingRangeProvider_pvar : linkedEditingRangeProvider_pvar) + (linkedEditingRangeProvider_pvar : linkedEditingRangeProvider_pvar) : Json.t = match linkedEditingRangeProvider_pvar with @@ -39852,7 +6958,7 @@ module ServerCapabilities = struct type notebookDocumentSync_pvar = [ `NotebookDocumentSyncOptions of NotebookDocumentSyncOptions.t | `NotebookDocumentSyncRegistrationOptions of - NotebookDocumentSyncRegistrationOptions.t + NotebookDocumentSyncRegistrationOptions.t ] let notebookDocumentSync_pvar_of_yojson (json : Json.t) : notebookDocumentSync_pvar = @@ -39868,7 +6974,7 @@ module ServerCapabilities = struct ;; let yojson_of_notebookDocumentSync_pvar - (notebookDocumentSync_pvar : notebookDocumentSync_pvar) + (notebookDocumentSync_pvar : notebookDocumentSync_pvar) : Json.t = match notebookDocumentSync_pvar with @@ -39893,7 +6999,7 @@ module ServerCapabilities = struct ;; let yojson_of_referencesProvider_pvar - (referencesProvider_pvar : referencesProvider_pvar) + (referencesProvider_pvar : referencesProvider_pvar) : Json.t = match referencesProvider_pvar with @@ -39943,7 +7049,7 @@ module ServerCapabilities = struct ;; let yojson_of_selectionRangeProvider_pvar - (selectionRangeProvider_pvar : selectionRangeProvider_pvar) + (selectionRangeProvider_pvar : selectionRangeProvider_pvar) : Json.t = match selectionRangeProvider_pvar with @@ -39970,7 +7076,7 @@ module ServerCapabilities = struct ;; let yojson_of_semanticTokensProvider_pvar - (semanticTokensProvider_pvar : semanticTokensProvider_pvar) + (semanticTokensProvider_pvar : semanticTokensProvider_pvar) : Json.t = match semanticTokensProvider_pvar with @@ -40022,7 +7128,7 @@ module ServerCapabilities = struct ;; let yojson_of_typeDefinitionProvider_pvar - (typeDefinitionProvider_pvar : typeDefinitionProvider_pvar) + (typeDefinitionProvider_pvar : typeDefinitionProvider_pvar) : Json.t = match typeDefinitionProvider_pvar with @@ -40053,7 +7159,7 @@ module ServerCapabilities = struct ;; let yojson_of_typeHierarchyProvider_pvar - (typeHierarchyProvider_pvar : typeHierarchyProvider_pvar) + (typeHierarchyProvider_pvar : typeHierarchyProvider_pvar) : Json.t = match typeHierarchyProvider_pvar with @@ -40082,7 +7188,7 @@ module ServerCapabilities = struct ;; let yojson_of_workspaceSymbolProvider_pvar - (workspaceSymbolProvider_pvar : workspaceSymbolProvider_pvar) + (workspaceSymbolProvider_pvar : workspaceSymbolProvider_pvar) : Json.t = match workspaceSymbolProvider_pvar with @@ -40092,1272 +7198,122 @@ module ServerCapabilities = struct type t = { callHierarchyProvider : callHierarchyProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; codeActionProvider : codeActionProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; codeLensProvider : CodeLensOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; colorProvider : colorProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; completionProvider : CompletionOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; declarationProvider : declarationProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; definitionProvider : definitionProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; diagnosticProvider : diagnosticProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentFormattingProvider : documentFormattingProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentHighlightProvider : documentHighlightProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentLinkProvider : DocumentLinkOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentOnTypeFormattingProvider : DocumentOnTypeFormattingOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentRangeFormattingProvider : documentRangeFormattingProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentSymbolProvider : documentSymbolProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; executeCommandProvider : ExecuteCommandOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; experimental : Json.t option [@yojson.option] ; foldingRangeProvider : foldingRangeProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; hoverProvider : hoverProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; implementationProvider : implementationProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; inlayHintProvider : inlayHintProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; inlineCompletionProvider : inlineCompletionProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; inlineValueProvider : inlineValueProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; linkedEditingRangeProvider : linkedEditingRangeProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; monikerProvider : monikerProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; notebookDocumentSync : notebookDocumentSync_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; positionEncoding : PositionEncodingKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; referencesProvider : referencesProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; renameProvider : renameProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; selectionRangeProvider : selectionRangeProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; semanticTokensProvider : semanticTokensProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; signatureHelpProvider : SignatureHelpOptions.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textDocument : textDocument Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textDocumentSync : textDocumentSync_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; typeDefinitionProvider : typeDefinitionProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; typeHierarchyProvider : typeHierarchyProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workspace : workspace Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workspaceSymbolProvider : workspaceSymbolProvider_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ServerCapabilities.t" in - function - | `Assoc field_yojsons as yojson -> - let callHierarchyProvider_field = ref Ppx_yojson_conv_lib.Option.None - and codeActionProvider_field = ref Ppx_yojson_conv_lib.Option.None - and codeLensProvider_field = ref Ppx_yojson_conv_lib.Option.None - and colorProvider_field = ref Ppx_yojson_conv_lib.Option.None - and completionProvider_field = ref Ppx_yojson_conv_lib.Option.None - and declarationProvider_field = ref Ppx_yojson_conv_lib.Option.None - and definitionProvider_field = ref Ppx_yojson_conv_lib.Option.None - and diagnosticProvider_field = ref Ppx_yojson_conv_lib.Option.None - and documentFormattingProvider_field = ref Ppx_yojson_conv_lib.Option.None - and documentHighlightProvider_field = ref Ppx_yojson_conv_lib.Option.None - and documentLinkProvider_field = ref Ppx_yojson_conv_lib.Option.None - and documentOnTypeFormattingProvider_field = ref Ppx_yojson_conv_lib.Option.None - and documentRangeFormattingProvider_field = ref Ppx_yojson_conv_lib.Option.None - and documentSymbolProvider_field = ref Ppx_yojson_conv_lib.Option.None - and executeCommandProvider_field = ref Ppx_yojson_conv_lib.Option.None - and experimental_field = ref Ppx_yojson_conv_lib.Option.None - and foldingRangeProvider_field = ref Ppx_yojson_conv_lib.Option.None - and hoverProvider_field = ref Ppx_yojson_conv_lib.Option.None - and implementationProvider_field = ref Ppx_yojson_conv_lib.Option.None - and inlayHintProvider_field = ref Ppx_yojson_conv_lib.Option.None - and inlineCompletionProvider_field = ref Ppx_yojson_conv_lib.Option.None - and inlineValueProvider_field = ref Ppx_yojson_conv_lib.Option.None - and linkedEditingRangeProvider_field = ref Ppx_yojson_conv_lib.Option.None - and monikerProvider_field = ref Ppx_yojson_conv_lib.Option.None - and notebookDocumentSync_field = ref Ppx_yojson_conv_lib.Option.None - and positionEncoding_field = ref Ppx_yojson_conv_lib.Option.None - and referencesProvider_field = ref Ppx_yojson_conv_lib.Option.None - and renameProvider_field = ref Ppx_yojson_conv_lib.Option.None - and selectionRangeProvider_field = ref Ppx_yojson_conv_lib.Option.None - and semanticTokensProvider_field = ref Ppx_yojson_conv_lib.Option.None - and signatureHelpProvider_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and textDocumentSync_field = ref Ppx_yojson_conv_lib.Option.None - and typeDefinitionProvider_field = ref Ppx_yojson_conv_lib.Option.None - and typeHierarchyProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workspace_field = ref Ppx_yojson_conv_lib.Option.None - and workspaceSymbolProvider_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "callHierarchyProvider" -> - (match Ppx_yojson_conv_lib.( ! ) callHierarchyProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - callHierarchyProvider_pvar_of_yojson - _field_yojson - in - callHierarchyProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "codeActionProvider" -> - (match Ppx_yojson_conv_lib.( ! ) codeActionProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - codeActionProvider_pvar_of_yojson - _field_yojson - in - codeActionProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "codeLensProvider" -> - (match Ppx_yojson_conv_lib.( ! ) codeLensProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CodeLensOptions.t_of_yojson - _field_yojson - in - codeLensProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "colorProvider" -> - (match Ppx_yojson_conv_lib.( ! ) colorProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - colorProvider_pvar_of_yojson - _field_yojson - in - colorProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "completionProvider" -> - (match Ppx_yojson_conv_lib.( ! ) completionProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - CompletionOptions.t_of_yojson - _field_yojson - in - completionProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "declarationProvider" -> - (match Ppx_yojson_conv_lib.( ! ) declarationProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - declarationProvider_pvar_of_yojson - _field_yojson - in - declarationProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "definitionProvider" -> - (match Ppx_yojson_conv_lib.( ! ) definitionProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - definitionProvider_pvar_of_yojson - _field_yojson - in - definitionProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "diagnosticProvider" -> - (match Ppx_yojson_conv_lib.( ! ) diagnosticProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - diagnosticProvider_pvar_of_yojson - _field_yojson - in - diagnosticProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentFormattingProvider" -> - (match Ppx_yojson_conv_lib.( ! ) documentFormattingProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - documentFormattingProvider_pvar_of_yojson - _field_yojson - in - documentFormattingProvider_field - := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentHighlightProvider" -> - (match Ppx_yojson_conv_lib.( ! ) documentHighlightProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - documentHighlightProvider_pvar_of_yojson - _field_yojson - in - documentHighlightProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentLinkProvider" -> - (match Ppx_yojson_conv_lib.( ! ) documentLinkProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentLinkOptions.t_of_yojson - _field_yojson - in - documentLinkProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentOnTypeFormattingProvider" -> - (match Ppx_yojson_conv_lib.( ! ) documentOnTypeFormattingProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentOnTypeFormattingOptions.t_of_yojson - _field_yojson - in - documentOnTypeFormattingProvider_field - := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentRangeFormattingProvider" -> - (match Ppx_yojson_conv_lib.( ! ) documentRangeFormattingProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - documentRangeFormattingProvider_pvar_of_yojson - _field_yojson - in - documentRangeFormattingProvider_field - := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentSymbolProvider" -> - (match Ppx_yojson_conv_lib.( ! ) documentSymbolProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - documentSymbolProvider_pvar_of_yojson - _field_yojson - in - documentSymbolProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "executeCommandProvider" -> - (match Ppx_yojson_conv_lib.( ! ) executeCommandProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ExecuteCommandOptions.t_of_yojson - _field_yojson - in - executeCommandProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "experimental" -> - (match Ppx_yojson_conv_lib.( ! ) experimental_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - experimental_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "foldingRangeProvider" -> - (match Ppx_yojson_conv_lib.( ! ) foldingRangeProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - foldingRangeProvider_pvar_of_yojson - _field_yojson - in - foldingRangeProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "hoverProvider" -> - (match Ppx_yojson_conv_lib.( ! ) hoverProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - hoverProvider_pvar_of_yojson - _field_yojson - in - hoverProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "implementationProvider" -> - (match Ppx_yojson_conv_lib.( ! ) implementationProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - implementationProvider_pvar_of_yojson - _field_yojson - in - implementationProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "inlayHintProvider" -> - (match Ppx_yojson_conv_lib.( ! ) inlayHintProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - inlayHintProvider_pvar_of_yojson - _field_yojson - in - inlayHintProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "inlineCompletionProvider" -> - (match Ppx_yojson_conv_lib.( ! ) inlineCompletionProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - inlineCompletionProvider_pvar_of_yojson - _field_yojson - in - inlineCompletionProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "inlineValueProvider" -> - (match Ppx_yojson_conv_lib.( ! ) inlineValueProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - inlineValueProvider_pvar_of_yojson - _field_yojson - in - inlineValueProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "linkedEditingRangeProvider" -> - (match Ppx_yojson_conv_lib.( ! ) linkedEditingRangeProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - linkedEditingRangeProvider_pvar_of_yojson - _field_yojson - in - linkedEditingRangeProvider_field - := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "monikerProvider" -> - (match Ppx_yojson_conv_lib.( ! ) monikerProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - monikerProvider_pvar_of_yojson - _field_yojson - in - monikerProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "notebookDocumentSync" -> - (match Ppx_yojson_conv_lib.( ! ) notebookDocumentSync_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - notebookDocumentSync_pvar_of_yojson - _field_yojson - in - notebookDocumentSync_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "positionEncoding" -> - (match Ppx_yojson_conv_lib.( ! ) positionEncoding_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - PositionEncodingKind.t_of_yojson - _field_yojson - in - positionEncoding_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "referencesProvider" -> - (match Ppx_yojson_conv_lib.( ! ) referencesProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - referencesProvider_pvar_of_yojson - _field_yojson - in - referencesProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "renameProvider" -> - (match Ppx_yojson_conv_lib.( ! ) renameProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - renameProvider_pvar_of_yojson - _field_yojson - in - renameProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "selectionRangeProvider" -> - (match Ppx_yojson_conv_lib.( ! ) selectionRangeProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - selectionRangeProvider_pvar_of_yojson - _field_yojson - in - selectionRangeProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "semanticTokensProvider" -> - (match Ppx_yojson_conv_lib.( ! ) semanticTokensProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - semanticTokensProvider_pvar_of_yojson - _field_yojson - in - semanticTokensProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "signatureHelpProvider" -> - (match Ppx_yojson_conv_lib.( ! ) signatureHelpProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - SignatureHelpOptions.t_of_yojson - _field_yojson - in - signatureHelpProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson textDocument_of_yojson _field_yojson - in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocumentSync" -> - (match Ppx_yojson_conv_lib.( ! ) textDocumentSync_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - textDocumentSync_pvar_of_yojson - _field_yojson - in - textDocumentSync_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "typeDefinitionProvider" -> - (match Ppx_yojson_conv_lib.( ! ) typeDefinitionProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - typeDefinitionProvider_pvar_of_yojson - _field_yojson - in - typeDefinitionProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "typeHierarchyProvider" -> - (match Ppx_yojson_conv_lib.( ! ) typeHierarchyProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - typeHierarchyProvider_pvar_of_yojson - _field_yojson - in - typeHierarchyProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workspace" -> - (match Ppx_yojson_conv_lib.( ! ) workspace_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson workspace_of_yojson _field_yojson - in - workspace_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workspaceSymbolProvider" -> - (match Ppx_yojson_conv_lib.( ! ) workspaceSymbolProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - workspaceSymbolProvider_pvar_of_yojson - _field_yojson - in - workspaceSymbolProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( callHierarchyProvider_value - , codeActionProvider_value - , codeLensProvider_value - , colorProvider_value - , completionProvider_value - , declarationProvider_value - , definitionProvider_value - , diagnosticProvider_value - , documentFormattingProvider_value - , documentHighlightProvider_value - , documentLinkProvider_value - , documentOnTypeFormattingProvider_value - , documentRangeFormattingProvider_value - , documentSymbolProvider_value - , executeCommandProvider_value - , experimental_value - , foldingRangeProvider_value - , hoverProvider_value - , implementationProvider_value - , inlayHintProvider_value - , inlineCompletionProvider_value - , inlineValueProvider_value - , linkedEditingRangeProvider_value - , monikerProvider_value - , notebookDocumentSync_value - , positionEncoding_value - , referencesProvider_value - , renameProvider_value - , selectionRangeProvider_value - , semanticTokensProvider_value - , signatureHelpProvider_value - , textDocument_value - , textDocumentSync_value - , typeDefinitionProvider_value - , typeHierarchyProvider_value - , workspace_value - , workspaceSymbolProvider_value ) - = - ( Ppx_yojson_conv_lib.( ! ) callHierarchyProvider_field - , Ppx_yojson_conv_lib.( ! ) codeActionProvider_field - , Ppx_yojson_conv_lib.( ! ) codeLensProvider_field - , Ppx_yojson_conv_lib.( ! ) colorProvider_field - , Ppx_yojson_conv_lib.( ! ) completionProvider_field - , Ppx_yojson_conv_lib.( ! ) declarationProvider_field - , Ppx_yojson_conv_lib.( ! ) definitionProvider_field - , Ppx_yojson_conv_lib.( ! ) diagnosticProvider_field - , Ppx_yojson_conv_lib.( ! ) documentFormattingProvider_field - , Ppx_yojson_conv_lib.( ! ) documentHighlightProvider_field - , Ppx_yojson_conv_lib.( ! ) documentLinkProvider_field - , Ppx_yojson_conv_lib.( ! ) documentOnTypeFormattingProvider_field - , Ppx_yojson_conv_lib.( ! ) documentRangeFormattingProvider_field - , Ppx_yojson_conv_lib.( ! ) documentSymbolProvider_field - , Ppx_yojson_conv_lib.( ! ) executeCommandProvider_field - , Ppx_yojson_conv_lib.( ! ) experimental_field - , Ppx_yojson_conv_lib.( ! ) foldingRangeProvider_field - , Ppx_yojson_conv_lib.( ! ) hoverProvider_field - , Ppx_yojson_conv_lib.( ! ) implementationProvider_field - , Ppx_yojson_conv_lib.( ! ) inlayHintProvider_field - , Ppx_yojson_conv_lib.( ! ) inlineCompletionProvider_field - , Ppx_yojson_conv_lib.( ! ) inlineValueProvider_field - , Ppx_yojson_conv_lib.( ! ) linkedEditingRangeProvider_field - , Ppx_yojson_conv_lib.( ! ) monikerProvider_field - , Ppx_yojson_conv_lib.( ! ) notebookDocumentSync_field - , Ppx_yojson_conv_lib.( ! ) positionEncoding_field - , Ppx_yojson_conv_lib.( ! ) referencesProvider_field - , Ppx_yojson_conv_lib.( ! ) renameProvider_field - , Ppx_yojson_conv_lib.( ! ) selectionRangeProvider_field - , Ppx_yojson_conv_lib.( ! ) semanticTokensProvider_field - , Ppx_yojson_conv_lib.( ! ) signatureHelpProvider_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) textDocumentSync_field - , Ppx_yojson_conv_lib.( ! ) typeDefinitionProvider_field - , Ppx_yojson_conv_lib.( ! ) typeHierarchyProvider_field - , Ppx_yojson_conv_lib.( ! ) workspace_field - , Ppx_yojson_conv_lib.( ! ) workspaceSymbolProvider_field ) - in - { callHierarchyProvider = - (match callHierarchyProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; codeActionProvider = - (match codeActionProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; codeLensProvider = - (match codeLensProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; colorProvider = - (match colorProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; completionProvider = - (match completionProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; declarationProvider = - (match declarationProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; definitionProvider = - (match definitionProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; diagnosticProvider = - (match diagnosticProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentFormattingProvider = - (match documentFormattingProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentHighlightProvider = - (match documentHighlightProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentLinkProvider = - (match documentLinkProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentOnTypeFormattingProvider = - (match documentOnTypeFormattingProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentRangeFormattingProvider = - (match documentRangeFormattingProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentSymbolProvider = - (match documentSymbolProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; executeCommandProvider = - (match executeCommandProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; experimental = experimental_value - ; foldingRangeProvider = - (match foldingRangeProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; hoverProvider = - (match hoverProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; implementationProvider = - (match implementationProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; inlayHintProvider = - (match inlayHintProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; inlineCompletionProvider = - (match inlineCompletionProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; inlineValueProvider = - (match inlineValueProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; linkedEditingRangeProvider = - (match linkedEditingRangeProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; monikerProvider = - (match monikerProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; notebookDocumentSync = - (match notebookDocumentSync_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; positionEncoding = - (match positionEncoding_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; referencesProvider = - (match referencesProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; renameProvider = - (match renameProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; selectionRangeProvider = - (match selectionRangeProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; semanticTokensProvider = - (match semanticTokensProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; signatureHelpProvider = - (match signatureHelpProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocument = - (match textDocument_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocumentSync = - (match textDocumentSync_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; typeDefinitionProvider = - (match typeDefinitionProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; typeHierarchyProvider = - (match typeHierarchyProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workspace = - (match workspace_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workspaceSymbolProvider = - (match workspaceSymbolProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { callHierarchyProvider = v_callHierarchyProvider - ; codeActionProvider = v_codeActionProvider - ; codeLensProvider = v_codeLensProvider - ; colorProvider = v_colorProvider - ; completionProvider = v_completionProvider - ; declarationProvider = v_declarationProvider - ; definitionProvider = v_definitionProvider - ; diagnosticProvider = v_diagnosticProvider - ; documentFormattingProvider = v_documentFormattingProvider - ; documentHighlightProvider = v_documentHighlightProvider - ; documentLinkProvider = v_documentLinkProvider - ; documentOnTypeFormattingProvider = v_documentOnTypeFormattingProvider - ; documentRangeFormattingProvider = v_documentRangeFormattingProvider - ; documentSymbolProvider = v_documentSymbolProvider - ; executeCommandProvider = v_executeCommandProvider - ; experimental = v_experimental - ; foldingRangeProvider = v_foldingRangeProvider - ; hoverProvider = v_hoverProvider - ; implementationProvider = v_implementationProvider - ; inlayHintProvider = v_inlayHintProvider - ; inlineCompletionProvider = v_inlineCompletionProvider - ; inlineValueProvider = v_inlineValueProvider - ; linkedEditingRangeProvider = v_linkedEditingRangeProvider - ; monikerProvider = v_monikerProvider - ; notebookDocumentSync = v_notebookDocumentSync - ; positionEncoding = v_positionEncoding - ; referencesProvider = v_referencesProvider - ; renameProvider = v_renameProvider - ; selectionRangeProvider = v_selectionRangeProvider - ; semanticTokensProvider = v_semanticTokensProvider - ; signatureHelpProvider = v_signatureHelpProvider - ; textDocument = v_textDocument - ; textDocumentSync = v_textDocumentSync - ; typeDefinitionProvider = v_typeDefinitionProvider - ; typeHierarchyProvider = v_typeHierarchyProvider - ; workspace = v_workspace - ; workspaceSymbolProvider = v_workspaceSymbolProvider - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workspaceSymbolProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_workspaceSymbolProvider_pvar) - v_workspaceSymbolProvider - in - let bnd = "workspaceSymbolProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_workspace - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_workspace) v_workspace in - let bnd = "workspace", arg in - bnd :: bnds) - in - let bnds = - if None = v_typeHierarchyProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_typeHierarchyProvider_pvar) - v_typeHierarchyProvider - in - let bnd = "typeHierarchyProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_typeDefinitionProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_typeDefinitionProvider_pvar) - v_typeDefinitionProvider - in - let bnd = "typeDefinitionProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_textDocumentSync - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_textDocumentSync_pvar) - v_textDocumentSync - in - let bnd = "textDocumentSync", arg in - bnd :: bnds) - in - let bnds = - if None = v_textDocument - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_textDocument) v_textDocument - in - let bnd = "textDocument", arg in - bnd :: bnds) - in - let bnds = - if None = v_signatureHelpProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t SignatureHelpOptions.yojson_of_t) - v_signatureHelpProvider - in - let bnd = "signatureHelpProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_semanticTokensProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_semanticTokensProvider_pvar) - v_semanticTokensProvider - in - let bnd = "semanticTokensProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_selectionRangeProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_selectionRangeProvider_pvar) - v_selectionRangeProvider - in - let bnd = "selectionRangeProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_renameProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_renameProvider_pvar) - v_renameProvider - in - let bnd = "renameProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_referencesProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_referencesProvider_pvar) - v_referencesProvider - in - let bnd = "referencesProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_positionEncoding - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t PositionEncodingKind.yojson_of_t) - v_positionEncoding - in - let bnd = "positionEncoding", arg in - bnd :: bnds) - in - let bnds = - if None = v_notebookDocumentSync - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_notebookDocumentSync_pvar) - v_notebookDocumentSync - in - let bnd = "notebookDocumentSync", arg in - bnd :: bnds) - in - let bnds = - if None = v_monikerProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_monikerProvider_pvar) - v_monikerProvider - in - let bnd = "monikerProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_linkedEditingRangeProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_linkedEditingRangeProvider_pvar) - v_linkedEditingRangeProvider - in - let bnd = "linkedEditingRangeProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_inlineValueProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_inlineValueProvider_pvar) - v_inlineValueProvider - in - let bnd = "inlineValueProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_inlineCompletionProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_inlineCompletionProvider_pvar) - v_inlineCompletionProvider - in - let bnd = "inlineCompletionProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_inlayHintProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_inlayHintProvider_pvar) - v_inlayHintProvider - in - let bnd = "inlayHintProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_implementationProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_implementationProvider_pvar) - v_implementationProvider - in - let bnd = "implementationProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_hoverProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_hoverProvider_pvar) - v_hoverProvider - in - let bnd = "hoverProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_foldingRangeProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_foldingRangeProvider_pvar) - v_foldingRangeProvider - in - let bnd = "foldingRangeProvider", arg in - bnd :: bnds) - in - let bnds = - match v_experimental with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "experimental", arg in - bnd :: bnds - in - let bnds = - if None = v_executeCommandProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ExecuteCommandOptions.yojson_of_t) - v_executeCommandProvider - in - let bnd = "executeCommandProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSymbolProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_documentSymbolProvider_pvar) - v_documentSymbolProvider - in - let bnd = "documentSymbolProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentRangeFormattingProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - yojson_of_documentRangeFormattingProvider_pvar) - v_documentRangeFormattingProvider - in - let bnd = "documentRangeFormattingProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentOnTypeFormattingProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - DocumentOnTypeFormattingOptions.yojson_of_t) - v_documentOnTypeFormattingProvider - in - let bnd = "documentOnTypeFormattingProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentLinkProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentLinkOptions.yojson_of_t) - v_documentLinkProvider - in - let bnd = "documentLinkProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentHighlightProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_documentHighlightProvider_pvar) - v_documentHighlightProvider - in - let bnd = "documentHighlightProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentFormattingProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_documentFormattingProvider_pvar) - v_documentFormattingProvider - in - let bnd = "documentFormattingProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_diagnosticProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_diagnosticProvider_pvar) - v_diagnosticProvider - in - let bnd = "diagnosticProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_definitionProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_definitionProvider_pvar) - v_definitionProvider - in - let bnd = "definitionProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_declarationProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_declarationProvider_pvar) - v_declarationProvider - in - let bnd = "declarationProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_completionProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CompletionOptions.yojson_of_t) - v_completionProvider - in - let bnd = "completionProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_colorProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_colorProvider_pvar) - v_colorProvider - in - let bnd = "colorProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_codeLensProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t CodeLensOptions.yojson_of_t) - v_codeLensProvider - in - let bnd = "codeLensProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_codeActionProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_codeActionProvider_pvar) - v_codeActionProvider - in - let bnd = "codeActionProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_callHierarchyProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_callHierarchyProvider_pvar) - v_callHierarchyProvider - in - let bnd = "callHierarchyProvider", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] - - let create - ?(callHierarchyProvider : callHierarchyProvider_pvar option) - ?(codeActionProvider : codeActionProvider_pvar option) - ?(codeLensProvider : CodeLensOptions.t option) - ?(colorProvider : colorProvider_pvar option) - ?(completionProvider : CompletionOptions.t option) - ?(declarationProvider : declarationProvider_pvar option) - ?(definitionProvider : definitionProvider_pvar option) - ?(diagnosticProvider : diagnosticProvider_pvar option) - ?(documentFormattingProvider : documentFormattingProvider_pvar option) - ?(documentHighlightProvider : documentHighlightProvider_pvar option) - ?(documentLinkProvider : DocumentLinkOptions.t option) - ?(documentOnTypeFormattingProvider : DocumentOnTypeFormattingOptions.t option) - ?(documentRangeFormattingProvider : documentRangeFormattingProvider_pvar option) - ?(documentSymbolProvider : documentSymbolProvider_pvar option) - ?(executeCommandProvider : ExecuteCommandOptions.t option) - ?(experimental : Json.t option) - ?(foldingRangeProvider : foldingRangeProvider_pvar option) - ?(hoverProvider : hoverProvider_pvar option) - ?(implementationProvider : implementationProvider_pvar option) - ?(inlayHintProvider : inlayHintProvider_pvar option) - ?(inlineCompletionProvider : inlineCompletionProvider_pvar option) - ?(inlineValueProvider : inlineValueProvider_pvar option) - ?(linkedEditingRangeProvider : linkedEditingRangeProvider_pvar option) - ?(monikerProvider : monikerProvider_pvar option) - ?(notebookDocumentSync : notebookDocumentSync_pvar option) - ?(positionEncoding : PositionEncodingKind.t option) - ?(referencesProvider : referencesProvider_pvar option) - ?(renameProvider : renameProvider_pvar option) - ?(selectionRangeProvider : selectionRangeProvider_pvar option) - ?(semanticTokensProvider : semanticTokensProvider_pvar option) - ?(signatureHelpProvider : SignatureHelpOptions.t option) - ?(textDocument : textDocument option) - ?(textDocumentSync : textDocumentSync_pvar option) - ?(typeDefinitionProvider : typeDefinitionProvider_pvar option) - ?(typeHierarchyProvider : typeHierarchyProvider_pvar option) - ?(workspace : workspace option) - ?(workspaceSymbolProvider : workspaceSymbolProvider_pvar option) - (() : unit) + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] + + let create + ?(callHierarchyProvider : callHierarchyProvider_pvar option) + ?(codeActionProvider : codeActionProvider_pvar option) + ?(codeLensProvider : CodeLensOptions.t option) + ?(colorProvider : colorProvider_pvar option) + ?(completionProvider : CompletionOptions.t option) + ?(declarationProvider : declarationProvider_pvar option) + ?(definitionProvider : definitionProvider_pvar option) + ?(diagnosticProvider : diagnosticProvider_pvar option) + ?(documentFormattingProvider : documentFormattingProvider_pvar option) + ?(documentHighlightProvider : documentHighlightProvider_pvar option) + ?(documentLinkProvider : DocumentLinkOptions.t option) + ?(documentOnTypeFormattingProvider : DocumentOnTypeFormattingOptions.t option) + ?(documentRangeFormattingProvider : documentRangeFormattingProvider_pvar option) + ?(documentSymbolProvider : documentSymbolProvider_pvar option) + ?(executeCommandProvider : ExecuteCommandOptions.t option) + ?(experimental : Json.t option) + ?(foldingRangeProvider : foldingRangeProvider_pvar option) + ?(hoverProvider : hoverProvider_pvar option) + ?(implementationProvider : implementationProvider_pvar option) + ?(inlayHintProvider : inlayHintProvider_pvar option) + ?(inlineCompletionProvider : inlineCompletionProvider_pvar option) + ?(inlineValueProvider : inlineValueProvider_pvar option) + ?(linkedEditingRangeProvider : linkedEditingRangeProvider_pvar option) + ?(monikerProvider : monikerProvider_pvar option) + ?(notebookDocumentSync : notebookDocumentSync_pvar option) + ?(positionEncoding : PositionEncodingKind.t option) + ?(referencesProvider : referencesProvider_pvar option) + ?(renameProvider : renameProvider_pvar option) + ?(selectionRangeProvider : selectionRangeProvider_pvar option) + ?(semanticTokensProvider : semanticTokensProvider_pvar option) + ?(signatureHelpProvider : SignatureHelpOptions.t option) + ?(textDocument : textDocument option) + ?(textDocumentSync : textDocumentSync_pvar option) + ?(typeDefinitionProvider : typeDefinitionProvider_pvar option) + ?(typeHierarchyProvider : typeHierarchyProvider_pvar option) + ?(workspace : workspace option) + ?(workspaceSymbolProvider : workspaceSymbolProvider_pvar option) + (() : unit) : t = { callHierarchyProvider @@ -41406,106 +7362,7 @@ module InitializeResult = struct { name : string ; version : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : serverInfo) -> () - - let serverInfo_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InitializeResult.serverInfo" in - function - | `Assoc field_yojsons as yojson -> - let name_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "name" -> - (match Ppx_yojson_conv_lib.( ! ) name_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - name_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) name_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | Ppx_yojson_conv_lib.Option.Some name_value, version_value -> - { name = name_value - ; version = - (match version_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) name_field) - Ppx_yojson_conv_lib.Option.None - , "name" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> serverInfo) - ;; - - let _ = serverInfo_of_yojson - - let yojson_of_serverInfo = - (function - | { name = v_name; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_version - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_version in - let bnd = "version", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_name in - ("name", arg) :: bnds - in - `Assoc bnds - : serverInfo -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_serverInfo - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_serverInfo ~(name : string) ?(version : string option) (() : unit) : serverInfo @@ -41516,115 +7373,14 @@ module InitializeResult = struct type t = { capabilities : ServerCapabilities.t ; serverInfo : serverInfo Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InitializeResult.t" in - function - | `Assoc field_yojsons as yojson -> - let capabilities_field = ref Ppx_yojson_conv_lib.Option.None - and serverInfo_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "capabilities" -> - (match Ppx_yojson_conv_lib.( ! ) capabilities_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = ServerCapabilities.t_of_yojson _field_yojson in - capabilities_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "serverInfo" -> - (match Ppx_yojson_conv_lib.( ! ) serverInfo_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson serverInfo_of_yojson _field_yojson - in - serverInfo_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) capabilities_field - , Ppx_yojson_conv_lib.( ! ) serverInfo_field ) - with - | Ppx_yojson_conv_lib.Option.Some capabilities_value, serverInfo_value -> - { capabilities = capabilities_value - ; serverInfo = - (match serverInfo_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) capabilities_field) - Ppx_yojson_conv_lib.Option.None - , "capabilities" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { capabilities = v_capabilities; serverInfo = v_serverInfo } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_serverInfo - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_serverInfo) v_serverInfo - in - let bnd = "serverInfo", arg in - bnd :: bnds) - in - let bnds = - let arg = ServerCapabilities.yojson_of_t v_capabilities in - ("capabilities", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(capabilities : ServerCapabilities.t) - ?(serverInfo : serverInfo option) - (() : unit) + ~(capabilities : ServerCapabilities.t) + ?(serverInfo : serverInfo option) + (() : unit) : t = { capabilities; serverInfo } @@ -41636,106 +7392,7 @@ module InitializedParams_ = struct { name : string ; version : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : clientInfo) -> () - - let clientInfo_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InitializedParams_.clientInfo" in - function - | `Assoc field_yojsons as yojson -> - let name_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "name" -> - (match Ppx_yojson_conv_lib.( ! ) name_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - name_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) name_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | Ppx_yojson_conv_lib.Option.Some name_value, version_value -> - { name = name_value - ; version = - (match version_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) name_field) - Ppx_yojson_conv_lib.Option.None - , "name" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> clientInfo) - ;; - - let _ = clientInfo_of_yojson - - let yojson_of_clientInfo = - (function - | { name = v_name; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_version - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_version in - let bnd = "version", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_name in - ("name", arg) :: bnds - in - `Assoc bnds - : clientInfo -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_clientInfo - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create_clientInfo ~(name : string) ?(version : string option) (() : unit) : clientInfo @@ -41746,318 +7403,32 @@ module InitializedParams_ = struct type t = { capabilities : ClientCapabilities.t ; clientInfo : clientInfo Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; initializationOptions : Json.t option [@yojson.option] ; locale : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; processId : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; rootPath : string Json.Nullable_option.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; rootUri : DocumentUri.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; trace : TraceValues.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InitializedParams_.t" in - function - | `Assoc field_yojsons as yojson -> - let capabilities_field = ref Ppx_yojson_conv_lib.Option.None - and clientInfo_field = ref Ppx_yojson_conv_lib.Option.None - and initializationOptions_field = ref Ppx_yojson_conv_lib.Option.None - and locale_field = ref Ppx_yojson_conv_lib.Option.None - and processId_field = ref Ppx_yojson_conv_lib.Option.None - and rootPath_field = ref Ppx_yojson_conv_lib.Option.None - and rootUri_field = ref Ppx_yojson_conv_lib.Option.None - and trace_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "capabilities" -> - (match Ppx_yojson_conv_lib.( ! ) capabilities_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = ClientCapabilities.t_of_yojson _field_yojson in - capabilities_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "clientInfo" -> - (match Ppx_yojson_conv_lib.( ! ) clientInfo_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson clientInfo_of_yojson _field_yojson - in - clientInfo_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "initializationOptions" -> - (match Ppx_yojson_conv_lib.( ! ) initializationOptions_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - initializationOptions_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "locale" -> - (match Ppx_yojson_conv_lib.( ! ) locale_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - locale_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "processId" -> - (match Ppx_yojson_conv_lib.( ! ) processId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - processId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "rootPath" -> - (match Ppx_yojson_conv_lib.( ! ) rootPath_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (Json.Nullable_option.t_of_yojson string_of_yojson) - _field_yojson - in - rootPath_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "rootUri" -> - (match Ppx_yojson_conv_lib.( ! ) rootUri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson DocumentUri.t_of_yojson _field_yojson - in - rootUri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "trace" -> - (match Ppx_yojson_conv_lib.( ! ) trace_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson TraceValues.t_of_yojson _field_yojson - in - trace_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) capabilities_field - , Ppx_yojson_conv_lib.( ! ) clientInfo_field - , Ppx_yojson_conv_lib.( ! ) initializationOptions_field - , Ppx_yojson_conv_lib.( ! ) locale_field - , Ppx_yojson_conv_lib.( ! ) processId_field - , Ppx_yojson_conv_lib.( ! ) rootPath_field - , Ppx_yojson_conv_lib.( ! ) rootUri_field - , Ppx_yojson_conv_lib.( ! ) trace_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some capabilities_value - , clientInfo_value - , initializationOptions_value - , locale_value - , processId_value - , rootPath_value - , rootUri_value - , trace_value - , workDoneToken_value ) -> - { capabilities = capabilities_value - ; clientInfo = - (match clientInfo_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; initializationOptions = initializationOptions_value - ; locale = - (match locale_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; processId = - (match processId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; rootPath = - (match rootPath_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; rootUri = - (match rootUri_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; trace = - (match trace_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) capabilities_field) - Ppx_yojson_conv_lib.Option.None - , "capabilities" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { capabilities = v_capabilities - ; clientInfo = v_clientInfo - ; initializationOptions = v_initializationOptions - ; locale = v_locale - ; processId = v_processId - ; rootPath = v_rootPath - ; rootUri = v_rootUri - ; trace = v_trace - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - if None = v_trace - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t TraceValues.yojson_of_t) v_trace in - let bnd = "trace", arg in - bnd :: bnds) - in - let bnds = - if None = v_rootUri - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentUri.yojson_of_t) v_rootUri - in - let bnd = "rootUri", arg in - bnd :: bnds) - in - let bnds = - if None = v_rootPath - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (Json.Nullable_option.yojson_of_t yojson_of_string)) - v_rootPath - in - let bnd = "rootPath", arg in - bnd :: bnds) - in - let bnds = - if None = v_processId - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_processId in - let bnd = "processId", arg in - bnd :: bnds) - in - let bnds = - if None = v_locale - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_locale in - let bnd = "locale", arg in - bnd :: bnds) - in - let bnds = - match v_initializationOptions with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "initializationOptions", arg in - bnd :: bnds - in - let bnds = - if None = v_clientInfo - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_clientInfo) v_clientInfo - in - let bnd = "clientInfo", arg in - bnd :: bnds) - in - let bnds = - let arg = ClientCapabilities.yojson_of_t v_capabilities in - ("capabilities", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(capabilities : ClientCapabilities.t) - ?(clientInfo : clientInfo option) - ?(initializationOptions : Json.t option) - ?(locale : string option) - ?(processId : int option) - ?(rootPath : string option option) - ?(rootUri : DocumentUri.t option) - ?(trace : TraceValues.t option) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(capabilities : ClientCapabilities.t) + ?(clientInfo : clientInfo option) + ?(initializationOptions : Json.t option) + ?(locale : string option) + ?(processId : int option) + ?(rootPath : string option option) + ?(rootUri : DocumentUri.t option) + ?(trace : TraceValues.t option) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { capabilities @@ -42097,175 +7468,21 @@ module InlayHintLabelPart = struct type t = { command : Command.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; location : Location.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; tooltip : tooltip_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; value : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlayHintLabelPart.t" in - function - | `Assoc field_yojsons as yojson -> - let command_field = ref Ppx_yojson_conv_lib.Option.None - and location_field = ref Ppx_yojson_conv_lib.Option.None - and tooltip_field = ref Ppx_yojson_conv_lib.Option.None - and value_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "command" -> - (match Ppx_yojson_conv_lib.( ! ) command_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Command.t_of_yojson _field_yojson - in - command_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "location" -> - (match Ppx_yojson_conv_lib.( ! ) location_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Location.t_of_yojson _field_yojson - in - location_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tooltip" -> - (match Ppx_yojson_conv_lib.( ! ) tooltip_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson tooltip_pvar_of_yojson _field_yojson - in - tooltip_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "value" -> - (match Ppx_yojson_conv_lib.( ! ) value_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - value_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) command_field - , Ppx_yojson_conv_lib.( ! ) location_field - , Ppx_yojson_conv_lib.( ! ) tooltip_field - , Ppx_yojson_conv_lib.( ! ) value_field ) - with - | ( command_value - , location_value - , tooltip_value - , Ppx_yojson_conv_lib.Option.Some value_value ) -> - { command = - (match command_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; location = - (match location_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tooltip = - (match tooltip_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; value = value_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) value_field) - Ppx_yojson_conv_lib.Option.None - , "value" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { command = v_command - ; location = v_location - ; tooltip = v_tooltip - ; value = v_value - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_value in - ("value", arg) :: bnds - in - let bnds = - if None = v_tooltip - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_tooltip_pvar) v_tooltip - in - let bnd = "tooltip", arg in - bnd :: bnds) - in - let bnds = - if None = v_location - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Location.yojson_of_t) v_location in - let bnd = "location", arg in - bnd :: bnds) - in - let bnds = - if None = v_command - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Command.yojson_of_t) v_command in - let bnd = "command", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(command : Command.t option) - ?(location : Location.t option) - ?(tooltip : tooltip_pvar option) - ~(value : string) - (() : unit) + ?(command : Command.t option) + ?(location : Location.t option) + ?(tooltip : tooltip_pvar option) + ~(value : string) + (() : unit) : t = { command; location; tooltip; value } @@ -42318,283 +7535,30 @@ module InlayHint = struct type t = { data : Json.t option [@yojson.option] ; kind : InlayHintKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; label : label_pvar ; paddingLeft : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; paddingRight : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; position : Position.t ; textEdits : TextEdit.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; tooltip : tooltip_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlayHint.t" in - function - | `Assoc field_yojsons as yojson -> - let data_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and label_field = ref Ppx_yojson_conv_lib.Option.None - and paddingLeft_field = ref Ppx_yojson_conv_lib.Option.None - and paddingRight_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textEdits_field = ref Ppx_yojson_conv_lib.Option.None - and tooltip_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - InlayHintKind.t_of_yojson - _field_yojson - in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "label" -> - (match Ppx_yojson_conv_lib.( ! ) label_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = label_pvar_of_yojson _field_yojson in - label_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "paddingLeft" -> - (match Ppx_yojson_conv_lib.( ! ) paddingLeft_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - paddingLeft_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "paddingRight" -> - (match Ppx_yojson_conv_lib.( ! ) paddingRight_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - paddingRight_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textEdits" -> - (match Ppx_yojson_conv_lib.( ! ) textEdits_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson TextEdit.t_of_yojson) - _field_yojson - in - textEdits_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tooltip" -> - (match Ppx_yojson_conv_lib.( ! ) tooltip_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson tooltip_pvar_of_yojson _field_yojson - in - tooltip_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) label_field - , Ppx_yojson_conv_lib.( ! ) paddingLeft_field - , Ppx_yojson_conv_lib.( ! ) paddingRight_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textEdits_field - , Ppx_yojson_conv_lib.( ! ) tooltip_field ) - with - | ( data_value - , kind_value - , Ppx_yojson_conv_lib.Option.Some label_value - , paddingLeft_value - , paddingRight_value - , Ppx_yojson_conv_lib.Option.Some position_value - , textEdits_value - , tooltip_value ) -> - { data = data_value - ; kind = - (match kind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; label = label_value - ; paddingLeft = - (match paddingLeft_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; paddingRight = - (match paddingRight_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; position = position_value - ; textEdits = - (match textEdits_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; tooltip = - (match tooltip_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) label_field) - Ppx_yojson_conv_lib.Option.None - , "label" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { data = v_data - ; kind = v_kind - ; label = v_label - ; paddingLeft = v_paddingLeft - ; paddingRight = v_paddingRight - ; position = v_position - ; textEdits = v_textEdits - ; tooltip = v_tooltip - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_tooltip - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_tooltip_pvar) v_tooltip - in - let bnd = "tooltip", arg in - bnd :: bnds) - in - let bnds = - if None = v_textEdits - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list TextEdit.yojson_of_t)) - v_textEdits - in - let bnd = "textEdits", arg in - bnd :: bnds) - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - if None = v_paddingRight - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_paddingRight in - let bnd = "paddingRight", arg in - bnd :: bnds) - in - let bnds = - if None = v_paddingLeft - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_paddingLeft in - let bnd = "paddingLeft", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_label_pvar v_label in - ("label", arg) :: bnds - in - let bnds = - if None = v_kind - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t InlayHintKind.yojson_of_t) v_kind - in - let bnd = "kind", arg in - bnd :: bnds) - in - let bnds = - match v_data with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "data", arg in - bnd :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(data : Json.t option) - ?(kind : InlayHintKind.t option) - ~(label : label_pvar) - ?(paddingLeft : bool option) - ?(paddingRight : bool option) - ~(position : Position.t) - ?(textEdits : TextEdit.t list option) - ?(tooltip : tooltip_pvar option) - (() : unit) + ?(data : Json.t option) + ?(kind : InlayHintKind.t option) + ~(label : label_pvar) + ?(paddingLeft : bool option) + ?(paddingRight : bool option) + ~(position : Position.t) + ?(textEdits : TextEdit.t list option) + ?(tooltip : tooltip_pvar option) + (() : unit) : t = { data; kind; label; paddingLeft; paddingRight; position; textEdits; tooltip } @@ -42606,139 +7570,15 @@ module InlayHintParams = struct { range : Range.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlayHintParams.t" in - function - | `Assoc field_yojsons as yojson -> - let range_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { range = range_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { range = v_range; textDocument = v_textDocument; workDoneToken = v_workDoneToken } - -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(range : Range.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(range : Range.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { range; textDocument; workDoneToken } @@ -42750,100 +7590,7 @@ module SelectedCompletionInfo = struct { range : Range.t ; text : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SelectedCompletionInfo.t" in - function - | `Assoc field_yojsons as yojson -> - let range_field = ref Ppx_yojson_conv_lib.Option.None - and text_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "text" -> - (match Ppx_yojson_conv_lib.( ! ) text_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - text_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) text_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some text_value ) -> - { range = range_value; text = text_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) text_field) - Ppx_yojson_conv_lib.Option.None - , "text" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { range = v_range; text = v_text } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_text in - ("text", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(range : Range.t) ~(text : string) : t = { range; text } end @@ -42851,121 +7598,15 @@ end module InlineCompletionContext = struct type t = { selectedCompletionInfo : SelectedCompletionInfo.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; triggerKind : InlineCompletionTriggerKind.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineCompletionContext.t" in - function - | `Assoc field_yojsons as yojson -> - let selectedCompletionInfo_field = ref Ppx_yojson_conv_lib.Option.None - and triggerKind_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "selectedCompletionInfo" -> - (match Ppx_yojson_conv_lib.( ! ) selectedCompletionInfo_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - SelectedCompletionInfo.t_of_yojson - _field_yojson - in - selectedCompletionInfo_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "triggerKind" -> - (match Ppx_yojson_conv_lib.( ! ) triggerKind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = InlineCompletionTriggerKind.t_of_yojson _field_yojson in - triggerKind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) selectedCompletionInfo_field - , Ppx_yojson_conv_lib.( ! ) triggerKind_field ) - with - | ( selectedCompletionInfo_value - , Ppx_yojson_conv_lib.Option.Some triggerKind_value ) -> - { selectedCompletionInfo = - (match selectedCompletionInfo_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; triggerKind = triggerKind_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) triggerKind_field) - Ppx_yojson_conv_lib.Option.None - , "triggerKind" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { selectedCompletionInfo = v_selectedCompletionInfo; triggerKind = v_triggerKind } - -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = InlineCompletionTriggerKind.yojson_of_t v_triggerKind in - ("triggerKind", arg) :: bnds - in - let bnds = - if None = v_selectedCompletionInfo - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t SelectedCompletionInfo.yojson_of_t) - v_selectedCompletionInfo - in - let bnd = "selectedCompletionInfo", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(selectedCompletionInfo : SelectedCompletionInfo.t option) - ~(triggerKind : InlineCompletionTriggerKind.t) - (() : unit) + ?(selectedCompletionInfo : SelectedCompletionInfo.t option) + ~(triggerKind : InlineCompletionTriggerKind.t) + (() : unit) : t = { selectedCompletionInfo; triggerKind } @@ -42973,79 +7614,7 @@ module InlineCompletionContext = struct end module StringValue = struct - type t = { value : string } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.StringValue.t" in - function - | `Assoc field_yojsons as yojson -> - let value_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "value" -> - (match Ppx_yojson_conv_lib.( ! ) value_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - value_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) value_field with - | Ppx_yojson_conv_lib.Option.Some value_value -> { value = value_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) value_field) - Ppx_yojson_conv_lib.Option.None - , "value" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { value = v_value } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_value in - ("value", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { value : string } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(value : string) : t = { value } let yojson_of_t (t : t) : Json.t = Json.To.literal_field "kind" "snippet" yojson_of_t t @@ -43079,172 +7648,20 @@ module InlineCompletionItem = struct type t = { command : Command.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; filterText : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; insertText : insertText_pvar ; range : Range.t Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineCompletionItem.t" in - function - | `Assoc field_yojsons as yojson -> - let command_field = ref Ppx_yojson_conv_lib.Option.None - and filterText_field = ref Ppx_yojson_conv_lib.Option.None - and insertText_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "command" -> - (match Ppx_yojson_conv_lib.( ! ) command_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Command.t_of_yojson _field_yojson - in - command_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "filterText" -> - (match Ppx_yojson_conv_lib.( ! ) filterText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - filterText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "insertText" -> - (match Ppx_yojson_conv_lib.( ! ) insertText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = insertText_pvar_of_yojson _field_yojson in - insertText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Range.t_of_yojson _field_yojson - in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) command_field - , Ppx_yojson_conv_lib.( ! ) filterText_field - , Ppx_yojson_conv_lib.( ! ) insertText_field - , Ppx_yojson_conv_lib.( ! ) range_field ) - with - | ( command_value - , filterText_value - , Ppx_yojson_conv_lib.Option.Some insertText_value - , range_value ) -> - { command = - (match command_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; filterText = - (match filterText_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; insertText = insertText_value - ; range = - (match range_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) insertText_field) - Ppx_yojson_conv_lib.Option.None - , "insertText" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { command = v_command - ; filterText = v_filterText - ; insertText = v_insertText - ; range = v_range - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_range - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Range.yojson_of_t) v_range in - let bnd = "range", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_insertText_pvar v_insertText in - ("insertText", arg) :: bnds - in - let bnds = - if None = v_filterText - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_filterText in - let bnd = "filterText", arg in - bnd :: bnds) - in - let bnds = - if None = v_command - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Command.yojson_of_t) v_command in - let bnd = "command", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(command : Command.t option) - ?(filterText : string option) - ~(insertText : insertText_pvar) - ?(range : Range.t option) - (() : unit) + ?(command : Command.t option) + ?(filterText : string option) + ~(insertText : insertText_pvar) + ?(range : Range.t option) + (() : unit) : t = { command; filterText; insertText; range } @@ -43253,81 +7670,7 @@ end module InlineCompletionList = struct type t = { items : InlineCompletionItem.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineCompletionList.t" in - function - | `Assoc field_yojsons as yojson -> - let items_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "items" -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson InlineCompletionItem.t_of_yojson _field_yojson - in - items_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.Some items_value -> { items = items_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) items_field) - Ppx_yojson_conv_lib.Option.None - , "items" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { items = v_items } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list InlineCompletionItem.yojson_of_t v_items in - ("items", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(items : InlineCompletionItem.t list) : t = { items } end @@ -43338,162 +7681,16 @@ module InlineCompletionParams = struct ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineCompletionParams.t" in - function - | `Assoc field_yojsons as yojson -> - let context_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "context" -> - (match Ppx_yojson_conv_lib.( ! ) context_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = InlineCompletionContext.t_of_yojson _field_yojson in - context_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) context_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some context_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { context = context_value - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) context_field) - Ppx_yojson_conv_lib.Option.None - , "context" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { context = v_context - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - let arg = InlineCompletionContext.yojson_of_t v_context in - ("context", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(context : InlineCompletionContext.t) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(context : InlineCompletionContext.t) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { context; position; textDocument; workDoneToken } @@ -43503,149 +7700,18 @@ end module InlineCompletionRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineCompletionRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and id_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, id_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; id = v_id - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(id : string option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(id : string option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; id; workDoneProgress } @@ -43655,109 +7721,10 @@ end module InlineValueEvaluatableExpression = struct type t = { expression : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; range : Range.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineValueEvaluatableExpression.t" in - function - | `Assoc field_yojsons as yojson -> - let expression_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "expression" -> - (match Ppx_yojson_conv_lib.( ! ) expression_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - expression_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) expression_field - , Ppx_yojson_conv_lib.( ! ) range_field ) - with - | expression_value, Ppx_yojson_conv_lib.Option.Some range_value -> - { expression = - (match expression_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; range = range_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { expression = v_expression; range = v_range } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - if None = v_expression - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_expression in - let bnd = "expression", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(expression : string option) ~(range : Range.t) (() : unit) : t = { expression; range } @@ -43769,137 +7736,15 @@ module InlineValueVariableLookup = struct { caseSensitiveLookup : bool ; range : Range.t ; variableName : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineValueVariableLookup.t" in - function - | `Assoc field_yojsons as yojson -> - let caseSensitiveLookup_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and variableName_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "caseSensitiveLookup" -> - (match Ppx_yojson_conv_lib.( ! ) caseSensitiveLookup_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - caseSensitiveLookup_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "variableName" -> - (match Ppx_yojson_conv_lib.( ! ) variableName_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - variableName_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) caseSensitiveLookup_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) variableName_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some caseSensitiveLookup_value - , Ppx_yojson_conv_lib.Option.Some range_value - , variableName_value ) -> - { caseSensitiveLookup = caseSensitiveLookup_value - ; range = range_value - ; variableName = - (match variableName_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) caseSensitiveLookup_field) - Ppx_yojson_conv_lib.Option.None - , "caseSensitiveLookup" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { caseSensitiveLookup = v_caseSensitiveLookup - ; range = v_range - ; variableName = v_variableName - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_variableName - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_variableName in - let bnd = "variableName", arg in - bnd :: bnds) - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - let arg = yojson_of_bool v_caseSensitiveLookup in - ("caseSensitiveLookup", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(caseSensitiveLookup : bool) - ~(range : Range.t) - ?(variableName : string option) - (() : unit) + ~(caseSensitiveLookup : bool) + ~(range : Range.t) + ?(variableName : string option) + (() : unit) : t = { caseSensitiveLookup; range; variableName } @@ -43911,100 +7756,7 @@ module InlineValueText = struct { range : Range.t ; text : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineValueText.t" in - function - | `Assoc field_yojsons as yojson -> - let range_field = ref Ppx_yojson_conv_lib.Option.None - and text_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "text" -> - (match Ppx_yojson_conv_lib.( ! ) text_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - text_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) text_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some text_value ) -> - { range = range_value; text = text_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) text_field) - Ppx_yojson_conv_lib.Option.None - , "text" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { range = v_range; text = v_text } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_text in - ("text", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(range : Range.t) ~(text : string) : t = { range; text } end @@ -44043,100 +7795,7 @@ module InlineValueContext = struct { frameId : int ; stoppedLocation : Range.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineValueContext.t" in - function - | `Assoc field_yojsons as yojson -> - let frameId_field = ref Ppx_yojson_conv_lib.Option.None - and stoppedLocation_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "frameId" -> - (match Ppx_yojson_conv_lib.( ! ) frameId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - frameId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "stoppedLocation" -> - (match Ppx_yojson_conv_lib.( ! ) stoppedLocation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - stoppedLocation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) frameId_field - , Ppx_yojson_conv_lib.( ! ) stoppedLocation_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some frameId_value - , Ppx_yojson_conv_lib.Option.Some stoppedLocation_value ) -> - { frameId = frameId_value; stoppedLocation = stoppedLocation_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) frameId_field) - Ppx_yojson_conv_lib.Option.None - , "frameId" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) stoppedLocation_field) - Ppx_yojson_conv_lib.Option.None - , "stoppedLocation" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { frameId = v_frameId; stoppedLocation = v_stoppedLocation } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Range.yojson_of_t v_stoppedLocation in - ("stoppedLocation", arg) :: bnds - in - let bnds = - let arg = yojson_of_int v_frameId in - ("frameId", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(frameId : int) ~(stoppedLocation : Range.t) : t = { frameId; stoppedLocation } @@ -44149,162 +7808,16 @@ module InlineValueParams = struct ; range : Range.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.InlineValueParams.t" in - function - | `Assoc field_yojsons as yojson -> - let context_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "context" -> - (match Ppx_yojson_conv_lib.( ! ) context_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = InlineValueContext.t_of_yojson _field_yojson in - context_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) context_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some context_value - , Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { context = context_value - ; range = range_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) context_field) - Ppx_yojson_conv_lib.Option.None - , "context" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { context = v_context - ; range = v_range - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - let arg = InlineValueContext.yojson_of_t v_context in - ("context", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(context : InlineValueContext.t) - ~(range : Range.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(context : InlineValueContext.t) + ~(range : Range.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { context; range; textDocument; workDoneToken } @@ -44316,141 +7829,15 @@ module LinkedEditingRangeParams = struct { position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.LinkedEditingRangeParams.t" in - function - | `Assoc field_yojsons as yojson -> - let position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { position; textDocument; workDoneToken } @@ -44461,108 +7848,9 @@ module LinkedEditingRanges = struct type t = { ranges : Range.t list ; wordPattern : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.LinkedEditingRanges.t" in - function - | `Assoc field_yojsons as yojson -> - let ranges_field = ref Ppx_yojson_conv_lib.Option.None - and wordPattern_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "ranges" -> - (match Ppx_yojson_conv_lib.( ! ) ranges_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Range.t_of_yojson _field_yojson in - ranges_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "wordPattern" -> - (match Ppx_yojson_conv_lib.( ! ) wordPattern_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - wordPattern_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) ranges_field - , Ppx_yojson_conv_lib.( ! ) wordPattern_field ) - with - | Ppx_yojson_conv_lib.Option.Some ranges_value, wordPattern_value -> - { ranges = ranges_value - ; wordPattern = - (match wordPattern_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) ranges_field) - Ppx_yojson_conv_lib.Option.None - , "ranges" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { ranges = v_ranges; wordPattern = v_wordPattern } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_wordPattern - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_wordPattern in - let bnd = "wordPattern", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list Range.yojson_of_t v_ranges in - ("ranges", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(ranges : Range.t list) ?(wordPattern : string option) (() : unit) : t = { ranges; wordPattern } @@ -44574,100 +7862,7 @@ module LogMessageParams = struct { message : string ; type_ : MessageType.t [@key "type"] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.LogMessageParams.t" in - function - | `Assoc field_yojsons as yojson -> - let message_field = ref Ppx_yojson_conv_lib.Option.None - and type__field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "message" -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - message_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "type" -> - (match Ppx_yojson_conv_lib.( ! ) type__field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = MessageType.t_of_yojson _field_yojson in - type__field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) message_field - , Ppx_yojson_conv_lib.( ! ) type__field ) - with - | ( Ppx_yojson_conv_lib.Option.Some message_value - , Ppx_yojson_conv_lib.Option.Some type__value ) -> - { message = message_value; type_ = type__value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) message_field) - Ppx_yojson_conv_lib.Option.None - , "message" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) type__field) - Ppx_yojson_conv_lib.Option.None - , "type_" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { message = v_message; type_ = v_type_ } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = MessageType.yojson_of_t v_type_ in - ("type", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_message in - ("message", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(message : string) ~(type_ : MessageType.t) : t = { message; type_ } end @@ -44677,106 +7872,7 @@ module LogTraceParams = struct { message : string ; verbose : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.LogTraceParams.t" in - function - | `Assoc field_yojsons as yojson -> - let message_field = ref Ppx_yojson_conv_lib.Option.None - and verbose_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "message" -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - message_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "verbose" -> - (match Ppx_yojson_conv_lib.( ! ) verbose_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - verbose_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) message_field - , Ppx_yojson_conv_lib.( ! ) verbose_field ) - with - | Ppx_yojson_conv_lib.Option.Some message_value, verbose_value -> - { message = message_value - ; verbose = - (match verbose_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) message_field) - Ppx_yojson_conv_lib.Option.None - , "message" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { message = v_message; verbose = v_verbose } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_verbose - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_verbose in - let bnd = "verbose", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_message in - ("message", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(message : string) ?(verbose : string option) (() : unit) : t = { message; verbose } @@ -44784,79 +7880,7 @@ module LogTraceParams = struct end module MessageActionItem = struct - type t = { title : string } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.MessageActionItem.t" in - function - | `Assoc field_yojsons as yojson -> - let title_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "title" -> - (match Ppx_yojson_conv_lib.( ! ) title_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - title_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) title_field with - | Ppx_yojson_conv_lib.Option.Some title_value -> { title = title_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) title_field) - Ppx_yojson_conv_lib.Option.None - , "title" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { title = v_title } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_title in - ("title", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { title : string } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(title : string) : t = { title } end @@ -44865,157 +7889,18 @@ module Moniker = struct type t = { identifier : string ; kind : MonikerKind.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; scheme : string ; unique : UniquenessLevel.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.Moniker.t" in - function - | `Assoc field_yojsons as yojson -> - let identifier_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and scheme_field = ref Ppx_yojson_conv_lib.Option.None - and unique_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "identifier" -> - (match Ppx_yojson_conv_lib.( ! ) identifier_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - identifier_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson MonikerKind.t_of_yojson _field_yojson - in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "scheme" -> - (match Ppx_yojson_conv_lib.( ! ) scheme_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - scheme_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "unique" -> - (match Ppx_yojson_conv_lib.( ! ) unique_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = UniquenessLevel.t_of_yojson _field_yojson in - unique_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) identifier_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) scheme_field - , Ppx_yojson_conv_lib.( ! ) unique_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some identifier_value - , kind_value - , Ppx_yojson_conv_lib.Option.Some scheme_value - , Ppx_yojson_conv_lib.Option.Some unique_value ) -> - { identifier = identifier_value - ; kind = - (match kind_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; scheme = scheme_value - ; unique = unique_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) identifier_field) - Ppx_yojson_conv_lib.Option.None - , "identifier" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) scheme_field) - Ppx_yojson_conv_lib.Option.None - , "scheme" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) unique_field) - Ppx_yojson_conv_lib.Option.None - , "unique" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { identifier = v_identifier; kind = v_kind; scheme = v_scheme; unique = v_unique } - -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = UniquenessLevel.yojson_of_t v_unique in - ("unique", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_scheme in - ("scheme", arg) :: bnds - in - let bnds = - if None = v_kind - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t MonikerKind.yojson_of_t) v_kind in - let bnd = "kind", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_identifier in - ("identifier", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(identifier : string) - ?(kind : MonikerKind.t option) - ~(scheme : string) - ~(unique : UniquenessLevel.t) - (() : unit) + ~(identifier : string) + ?(kind : MonikerKind.t option) + ~(scheme : string) + ~(unique : UniquenessLevel.t) + (() : unit) : t = { identifier; kind; scheme; unique } @@ -45025,176 +7910,20 @@ end module MonikerParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.MonikerParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; position; textDocument; workDoneToken } @@ -45246,119 +7975,15 @@ module ParameterInformation = struct type t = { documentation : documentation_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; label : label_pvar } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ParameterInformation.t" in - function - | `Assoc field_yojsons as yojson -> - let documentation_field = ref Ppx_yojson_conv_lib.Option.None - and label_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentation" -> - (match Ppx_yojson_conv_lib.( ! ) documentation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - documentation_pvar_of_yojson - _field_yojson - in - documentation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "label" -> - (match Ppx_yojson_conv_lib.( ! ) label_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = label_pvar_of_yojson _field_yojson in - label_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) documentation_field - , Ppx_yojson_conv_lib.( ! ) label_field ) - with - | documentation_value, Ppx_yojson_conv_lib.Option.Some label_value -> - { documentation = - (match documentation_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; label = label_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) label_field) - Ppx_yojson_conv_lib.Option.None - , "label" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentation = v_documentation; label = v_label } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_label_pvar v_label in - ("label", arg) :: bnds - in - let bnds = - if None = v_documentation - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_documentation_pvar) - v_documentation - in - let bnd = "documentation", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentation : documentation_pvar option) - ~(label : label_pvar) - (() : unit) + ?(documentation : documentation_pvar option) + ~(label : label_pvar) + (() : unit) : t = { documentation; label } @@ -45368,89 +7993,9 @@ end module PartialResultParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.PartialResultParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let partialResultToken_value = - Ppx_yojson_conv_lib.( ! ) partialResultToken_field - in - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(partialResultToken : ProgressToken.t option) (() : unit) : t = { partialResultToken } @@ -45462,141 +8007,15 @@ module PrepareRenameParams = struct { position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.PrepareRenameParams.t" in - function - | `Assoc field_yojsons as yojson -> - let position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { position; textDocument; workDoneToken } @@ -45608,99 +8027,7 @@ module PreviousResultId = struct { uri : DocumentUri.t ; value : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.PreviousResultId.t" in - function - | `Assoc field_yojsons as yojson -> - let uri_field = ref Ppx_yojson_conv_lib.Option.None - and value_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "value" -> - (match Ppx_yojson_conv_lib.( ! ) value_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - value_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - Ppx_yojson_conv_lib.( ! ) uri_field, Ppx_yojson_conv_lib.( ! ) value_field - with - | ( Ppx_yojson_conv_lib.Option.Some uri_value - , Ppx_yojson_conv_lib.Option.Some value_value ) -> - { uri = uri_value; value = value_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) value_field) - Ppx_yojson_conv_lib.Option.None - , "value" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { uri = v_uri; value = v_value } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_value in - ("value", arg) :: bnds - in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(uri : DocumentUri.t) ~(value : string) : t = { uri; value } end @@ -45711,132 +8038,13 @@ module PublishDiagnosticsParams = struct ; uri : DocumentUri.t ; version : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.PublishDiagnosticsParams.t" in - function - | `Assoc field_yojsons as yojson -> - let diagnostics_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "diagnostics" -> - (match Ppx_yojson_conv_lib.( ! ) diagnostics_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Diagnostic.t_of_yojson _field_yojson in - diagnostics_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) diagnostics_field - , Ppx_yojson_conv_lib.( ! ) uri_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some diagnostics_value - , Ppx_yojson_conv_lib.Option.Some uri_value - , version_value ) -> - { diagnostics = diagnostics_value - ; uri = uri_value - ; version = - (match version_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) diagnostics_field) - Ppx_yojson_conv_lib.Option.None - , "diagnostics" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { diagnostics = v_diagnostics; uri = v_uri; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_version - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_version in - let bnd = "version", arg in - bnd :: bnds) - in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - let arg = yojson_of_list Diagnostic.yojson_of_t v_diagnostics in - ("diagnostics", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(diagnostics : Diagnostic.t list) - ~(uri : DocumentUri.t) - ?(version : int option) - (() : unit) + ~(diagnostics : Diagnostic.t list) + ~(uri : DocumentUri.t) + ?(version : int option) + (() : unit) : t = { diagnostics; uri; version } @@ -45844,81 +8052,7 @@ module PublishDiagnosticsParams = struct end module ReferenceContext = struct - type t = { includeDeclaration : bool } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ReferenceContext.t" in - function - | `Assoc field_yojsons as yojson -> - let includeDeclaration_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "includeDeclaration" -> - (match Ppx_yojson_conv_lib.( ! ) includeDeclaration_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - includeDeclaration_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) includeDeclaration_field with - | Ppx_yojson_conv_lib.Option.Some includeDeclaration_value -> - { includeDeclaration = includeDeclaration_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) includeDeclaration_field) - Ppx_yojson_conv_lib.Option.None - , "includeDeclaration" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { includeDeclaration = v_includeDeclaration } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_includeDeclaration in - ("includeDeclaration", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { includeDeclaration : bool } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(includeDeclaration : bool) : t = { includeDeclaration } end @@ -45927,197 +8061,21 @@ module ReferenceParams = struct type t = { context : ReferenceContext.t ; partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ReferenceParams.t" in - function - | `Assoc field_yojsons as yojson -> - let context_field = ref Ppx_yojson_conv_lib.Option.None - and partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "context" -> - (match Ppx_yojson_conv_lib.( ! ) context_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = ReferenceContext.t_of_yojson _field_yojson in - context_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) context_field - , Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some context_value - , partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { context = context_value - ; partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) context_field) - Ppx_yojson_conv_lib.Option.None - , "context" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { context = v_context - ; partialResultToken = v_partialResultToken - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - let bnds = - let arg = ReferenceContext.yojson_of_t v_context in - ("context", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(context : ReferenceContext.t) - ?(partialResultToken : ProgressToken.t option) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(context : ReferenceContext.t) + ?(partialResultToken : ProgressToken.t option) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { context; partialResultToken; position; textDocument; workDoneToken } @@ -46127,121 +8085,16 @@ end module ReferenceRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ReferenceRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; workDoneProgress } @@ -46254,127 +8107,13 @@ module Registration = struct ; method_ : string [@key "method"] ; registerOptions : Json.t option [@yojson.option] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.Registration.t" in - function - | `Assoc field_yojsons as yojson -> - let id_field = ref Ppx_yojson_conv_lib.Option.None - and method__field = ref Ppx_yojson_conv_lib.Option.None - and registerOptions_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "method" -> - (match Ppx_yojson_conv_lib.( ! ) method__field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - method__field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "registerOptions" -> - (match Ppx_yojson_conv_lib.( ! ) registerOptions_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - registerOptions_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) method__field - , Ppx_yojson_conv_lib.( ! ) registerOptions_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some id_value - , Ppx_yojson_conv_lib.Option.Some method__value - , registerOptions_value ) -> - { id = id_value - ; method_ = method__value - ; registerOptions = registerOptions_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) id_field) - Ppx_yojson_conv_lib.Option.None - , "id" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) method__field) - Ppx_yojson_conv_lib.Option.None - , "method_" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { id = v_id; method_ = v_method_; registerOptions = v_registerOptions } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - match v_registerOptions with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "registerOptions", arg in - bnd :: bnds - in - let bnds = - let arg = yojson_of_string v_method_ in - ("method", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_id in - ("id", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(id : string) - ~(method_ : string) - ?(registerOptions : Json.t option) - (() : unit) + ~(id : string) + ~(method_ : string) + ?(registerOptions : Json.t option) + (() : unit) : t = { id; method_; registerOptions } @@ -46383,159 +8122,13 @@ end module RegistrationParams = struct type t = { registrations : Registration.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RegistrationParams.t" in - function - | `Assoc field_yojsons as yojson -> - let registrations_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "registrations" -> - (match Ppx_yojson_conv_lib.( ! ) registrations_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Registration.t_of_yojson _field_yojson in - registrations_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) registrations_field with - | Ppx_yojson_conv_lib.Option.Some registrations_value -> - { registrations = registrations_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) registrations_field) - Ppx_yojson_conv_lib.Option.None - , "registrations" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { registrations = v_registrations } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list Registration.yojson_of_t v_registrations in - ("registrations", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(registrations : Registration.t list) : t = { registrations } end module RenameFilesParams = struct - type t = { files : FileRename.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RenameFilesParams.t" in - function - | `Assoc field_yojsons as yojson -> - let files_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "files" -> - (match Ppx_yojson_conv_lib.( ! ) files_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson FileRename.t_of_yojson _field_yojson in - files_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) files_field with - | Ppx_yojson_conv_lib.Option.Some files_value -> { files = files_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) files_field) - Ppx_yojson_conv_lib.Option.None - , "files" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { files = v_files } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list FileRename.yojson_of_t v_files in - ("files", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { files : FileRename.t list } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(files : FileRename.t list) : t = { files } end @@ -46546,162 +8139,16 @@ module RenameParams = struct ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RenameParams.t" in - function - | `Assoc field_yojsons as yojson -> - let newName_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "newName" -> - (match Ppx_yojson_conv_lib.( ! ) newName_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - newName_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) newName_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some newName_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { newName = newName_value - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) newName_field) - Ppx_yojson_conv_lib.Option.None - , "newName" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { newName = v_newName - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_newName in - ("newName", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(newName : string) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(newName : string) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { newName; position; textDocument; workDoneToken } @@ -46711,152 +8158,19 @@ end module RenameRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; prepareProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.RenameRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and prepareProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "prepareProvider" -> - (match Ppx_yojson_conv_lib.( ! ) prepareProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - prepareProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, prepareProvider_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) prepareProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; prepareProvider = - (match prepareProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; prepareProvider = v_prepareProvider - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_prepareProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_prepareProvider - in - let bnd = "prepareProvider", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(prepareProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(prepareProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; prepareProvider; workDoneProgress } @@ -46866,119 +8180,15 @@ end module ResourceOperation = struct type t = { annotationId : ChangeAnnotationIdentifier.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; kind : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ResourceOperation.t" in - function - | `Assoc field_yojsons as yojson -> - let annotationId_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "annotationId" -> - (match Ppx_yojson_conv_lib.( ! ) annotationId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ChangeAnnotationIdentifier.t_of_yojson - _field_yojson - in - annotationId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) annotationId_field - , Ppx_yojson_conv_lib.( ! ) kind_field ) - with - | annotationId_value, Ppx_yojson_conv_lib.Option.Some kind_value -> - { annotationId = - (match annotationId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; kind = kind_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) kind_field) - Ppx_yojson_conv_lib.Option.None - , "kind" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { annotationId = v_annotationId; kind = v_kind } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_kind in - ("kind", arg) :: bnds - in - let bnds = - if None = v_annotationId - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ChangeAnnotationIdentifier.yojson_of_t) - v_annotationId - in - let bnd = "annotationId", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(annotationId : ChangeAnnotationIdentifier.t option) - ~(kind : string) - (() : unit) + ?(annotationId : ChangeAnnotationIdentifier.t option) + ~(kind : string) + (() : unit) : t = { annotationId; kind } @@ -46990,106 +8200,7 @@ module SelectionRange = struct { parent : t Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; range : Range.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let rec t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SelectionRange.t" in - function - | `Assoc field_yojsons as yojson -> - let parent_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "parent" -> - (match Ppx_yojson_conv_lib.( ! ) parent_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson t_of_yojson _field_yojson - in - parent_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) parent_field - , Ppx_yojson_conv_lib.( ! ) range_field ) - with - | parent_value, Ppx_yojson_conv_lib.Option.Some range_value -> - { parent = - (match parent_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; range = range_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let rec yojson_of_t = - (function - | { parent = v_parent; range = v_range } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - if None = v_parent - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_t) v_parent in - let bnd = "parent", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(parent : t option) ~(range : Range.t) (() : unit) : t = { parent; range } end @@ -47097,176 +8208,20 @@ end module SelectionRangeParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; positions : Position.t list ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SelectionRangeParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and positions_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "positions" -> - (match Ppx_yojson_conv_lib.( ! ) positions_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Position.t_of_yojson _field_yojson in - positions_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) positions_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some positions_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; positions = positions_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) positions_field) - Ppx_yojson_conv_lib.Option.None - , "positions" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; positions = v_positions - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = yojson_of_list Position.yojson_of_t v_positions in - ("positions", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(positions : Position.t list) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(positions : Position.t list) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; positions; textDocument; workDoneToken } @@ -47277,108 +8232,9 @@ module SemanticTokens = struct type t = { data : int array ; resultId : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokens.t" in - function - | `Assoc field_yojsons as yojson -> - let data_field = ref Ppx_yojson_conv_lib.Option.None - and resultId_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = array_of_yojson int_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resultId" -> - (match Ppx_yojson_conv_lib.( ! ) resultId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - resultId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) resultId_field ) - with - | Ppx_yojson_conv_lib.Option.Some data_value, resultId_value -> - { data = data_value - ; resultId = - (match resultId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) data_field) - Ppx_yojson_conv_lib.Option.None - , "data" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { data = v_data; resultId = v_resultId } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_resultId - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_resultId in - let bnd = "resultId", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_array yojson_of_int v_data in - ("data", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(data : int array) ?(resultId : string option) (() : unit) : t = { data; resultId } @@ -47391,130 +8247,7 @@ module SemanticTokensEdit = struct ; deleteCount : int ; start : int } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensEdit.t" in - function - | `Assoc field_yojsons as yojson -> - let data_field = ref Ppx_yojson_conv_lib.Option.None - and deleteCount_field = ref Ppx_yojson_conv_lib.Option.None - and start_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (array_of_yojson int_of_yojson) - _field_yojson - in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "deleteCount" -> - (match Ppx_yojson_conv_lib.( ! ) deleteCount_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - deleteCount_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "start" -> - (match Ppx_yojson_conv_lib.( ! ) start_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = int_of_yojson _field_yojson in - start_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) deleteCount_field - , Ppx_yojson_conv_lib.( ! ) start_field ) - with - | ( data_value - , Ppx_yojson_conv_lib.Option.Some deleteCount_value - , Ppx_yojson_conv_lib.Option.Some start_value ) -> - { data = - (match data_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; deleteCount = deleteCount_value - ; start = start_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) deleteCount_field) - Ppx_yojson_conv_lib.Option.None - , "deleteCount" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) start_field) - Ppx_yojson_conv_lib.Option.None - , "start" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { data = v_data; deleteCount = v_deleteCount; start = v_start } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_int v_start in - ("start", arg) :: bnds - in - let bnds = - let arg = yojson_of_int v_deleteCount in - ("deleteCount", arg) :: bnds - in - let bnds = - if None = v_data - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_array yojson_of_int)) v_data - in - let bnd = "data", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(data : int array option) ~(deleteCount : int) ~(start : int) (() : unit) : t @@ -47527,110 +8260,9 @@ module SemanticTokensDelta = struct type t = { edits : SemanticTokensEdit.t list ; resultId : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensDelta.t" in - function - | `Assoc field_yojsons as yojson -> - let edits_field = ref Ppx_yojson_conv_lib.Option.None - and resultId_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "edits" -> - (match Ppx_yojson_conv_lib.( ! ) edits_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson SemanticTokensEdit.t_of_yojson _field_yojson - in - edits_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resultId" -> - (match Ppx_yojson_conv_lib.( ! ) resultId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - resultId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) edits_field - , Ppx_yojson_conv_lib.( ! ) resultId_field ) - with - | Ppx_yojson_conv_lib.Option.Some edits_value, resultId_value -> - { edits = edits_value - ; resultId = - (match resultId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) edits_field) - Ppx_yojson_conv_lib.Option.None - , "edits" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { edits = v_edits; resultId = v_resultId } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_resultId - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_resultId in - let bnd = "resultId", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list SemanticTokensEdit.yojson_of_t v_edits in - ("edits", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(edits : SemanticTokensEdit.t list) ?(resultId : string option) (() : unit) : t @@ -47642,176 +8274,20 @@ end module SemanticTokensDeltaParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; previousResultId : string ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensDeltaParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and previousResultId_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "previousResultId" -> - (match Ppx_yojson_conv_lib.( ! ) previousResultId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - previousResultId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) previousResultId_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some previousResultId_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; previousResultId = previousResultId_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) previousResultId_field) - Ppx_yojson_conv_lib.Option.None - , "previousResultId" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; previousResultId = v_previousResultId - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_previousResultId in - ("previousResultId", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(previousResultId : string) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(previousResultId : string) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; previousResultId; textDocument; workDoneToken } @@ -47820,81 +8296,7 @@ end module SemanticTokensDeltaPartialResult = struct type t = { edits : SemanticTokensEdit.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensDeltaPartialResult.t" in - function - | `Assoc field_yojsons as yojson -> - let edits_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "edits" -> - (match Ppx_yojson_conv_lib.( ! ) edits_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson SemanticTokensEdit.t_of_yojson _field_yojson - in - edits_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) edits_field with - | Ppx_yojson_conv_lib.Option.Some edits_value -> { edits = edits_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) edits_field) - Ppx_yojson_conv_lib.Option.None - , "edits" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { edits = v_edits } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list SemanticTokensEdit.yojson_of_t v_edits in - ("edits", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(edits : SemanticTokensEdit.t list) : t = { edits } end @@ -47902,154 +8304,18 @@ end module SemanticTokensParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; textDocument; workDoneToken } @@ -48057,79 +8323,7 @@ module SemanticTokensParams = struct end module SemanticTokensPartialResult = struct - type t = { data : int array } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensPartialResult.t" in - function - | `Assoc field_yojsons as yojson -> - let data_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = array_of_yojson int_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.Some data_value -> { data = data_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) data_field) - Ppx_yojson_conv_lib.Option.None - , "data" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { data = v_data } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_array yojson_of_int v_data in - ("data", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { data : int array } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(data : int array) : t = { data } end @@ -48137,176 +8331,20 @@ end module SemanticTokensRangeParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; range : Range.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SemanticTokensRangeParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; range = range_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; range = v_range - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(range : Range.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(range : Range.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; range; textDocument; workDoneToken } @@ -48314,80 +8352,7 @@ module SemanticTokensRangeParams = struct end module SetTraceParams = struct - type t = { value : TraceValues.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SetTraceParams.t" in - function - | `Assoc field_yojsons as yojson -> - let value_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "value" -> - (match Ppx_yojson_conv_lib.( ! ) value_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TraceValues.t_of_yojson _field_yojson in - value_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) value_field with - | Ppx_yojson_conv_lib.Option.Some value_value -> { value = value_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) value_field) - Ppx_yojson_conv_lib.Option.None - , "value" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { value = v_value } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = TraceValues.yojson_of_t v_value in - ("value", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { value : TraceValues.t } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(value : TraceValues.t) : t = { value } end @@ -48395,172 +8360,20 @@ end module ShowDocumentParams = struct type t = { external_ : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] [@key "external"] + [@default None] [@yojson_drop_default ( = )] [@key "external"] ; selection : Range.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; takeFocus : bool Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; uri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ShowDocumentParams.t" in - function - | `Assoc field_yojsons as yojson -> - let external__field = ref Ppx_yojson_conv_lib.Option.None - and selection_field = ref Ppx_yojson_conv_lib.Option.None - and takeFocus_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "external" -> - (match Ppx_yojson_conv_lib.( ! ) external__field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - external__field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "selection" -> - (match Ppx_yojson_conv_lib.( ! ) selection_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Range.t_of_yojson _field_yojson - in - selection_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "takeFocus" -> - (match Ppx_yojson_conv_lib.( ! ) takeFocus_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - takeFocus_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) external__field - , Ppx_yojson_conv_lib.( ! ) selection_field - , Ppx_yojson_conv_lib.( ! ) takeFocus_field - , Ppx_yojson_conv_lib.( ! ) uri_field ) - with - | ( external__value - , selection_value - , takeFocus_value - , Ppx_yojson_conv_lib.Option.Some uri_value ) -> - { external_ = - (match external__value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; selection = - (match selection_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; takeFocus = - (match takeFocus_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; uri = uri_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { external_ = v_external_ - ; selection = v_selection - ; takeFocus = v_takeFocus - ; uri = v_uri - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - if None = v_takeFocus - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_takeFocus in - let bnd = "takeFocus", arg in - bnd :: bnds) - in - let bnds = - if None = v_selection - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Range.yojson_of_t) v_selection in - let bnd = "selection", arg in - bnd :: bnds) - in - let bnds = - if None = v_external_ - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_external_ in - let bnd = "external", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(external_ : bool option) - ?(selection : Range.t option) - ?(takeFocus : bool option) - ~(uri : DocumentUri.t) - (() : unit) + ?(external_ : bool option) + ?(selection : Range.t option) + ?(takeFocus : bool option) + ~(uri : DocumentUri.t) + (() : unit) : t = { external_; selection; takeFocus; uri } @@ -48568,80 +8381,7 @@ module ShowDocumentParams = struct end module ShowDocumentResult = struct - type t = { success : bool } [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ShowDocumentResult.t" in - function - | `Assoc field_yojsons as yojson -> - let success_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "success" -> - (match Ppx_yojson_conv_lib.( ! ) success_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - success_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) success_field with - | Ppx_yojson_conv_lib.Option.Some success_value -> - { success = success_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) success_field) - Ppx_yojson_conv_lib.Option.None - , "success" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { success = v_success } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_success in - ("success", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { success : bool } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(success : bool) : t = { success } end @@ -48651,100 +8391,7 @@ module ShowMessageParams = struct { message : string ; type_ : MessageType.t [@key "type"] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ShowMessageParams.t" in - function - | `Assoc field_yojsons as yojson -> - let message_field = ref Ppx_yojson_conv_lib.Option.None - and type__field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "message" -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - message_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "type" -> - (match Ppx_yojson_conv_lib.( ! ) type__field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = MessageType.t_of_yojson _field_yojson in - type__field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) message_field - , Ppx_yojson_conv_lib.( ! ) type__field ) - with - | ( Ppx_yojson_conv_lib.Option.Some message_value - , Ppx_yojson_conv_lib.Option.Some type__value ) -> - { message = message_value; type_ = type__value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) message_field) - Ppx_yojson_conv_lib.Option.None - , "message" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) type__field) - Ppx_yojson_conv_lib.Option.None - , "type_" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { message = v_message; type_ = v_type_ } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = MessageType.yojson_of_t v_type_ in - ("type", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_message in - ("message", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(message : string) ~(type_ : MessageType.t) : t = { message; type_ } end @@ -48752,142 +8399,17 @@ end module ShowMessageRequestParams = struct type t = { actions : MessageActionItem.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; message : string ; type_ : MessageType.t [@key "type"] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.ShowMessageRequestParams.t" in - function - | `Assoc field_yojsons as yojson -> - let actions_field = ref Ppx_yojson_conv_lib.Option.None - and message_field = ref Ppx_yojson_conv_lib.Option.None - and type__field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "actions" -> - (match Ppx_yojson_conv_lib.( ! ) actions_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson MessageActionItem.t_of_yojson) - _field_yojson - in - actions_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "message" -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - message_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "type" -> - (match Ppx_yojson_conv_lib.( ! ) type__field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = MessageType.t_of_yojson _field_yojson in - type__field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) actions_field - , Ppx_yojson_conv_lib.( ! ) message_field - , Ppx_yojson_conv_lib.( ! ) type__field ) - with - | ( actions_value - , Ppx_yojson_conv_lib.Option.Some message_value - , Ppx_yojson_conv_lib.Option.Some type__value ) -> - { actions = - (match actions_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; message = message_value - ; type_ = type__value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) message_field) - Ppx_yojson_conv_lib.Option.None - , "message" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) type__field) - Ppx_yojson_conv_lib.Option.None - , "type_" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { actions = v_actions; message = v_message; type_ = v_type_ } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = MessageType.yojson_of_t v_type_ in - ("type", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_message in - ("message", arg) :: bnds - in - let bnds = - if None = v_actions - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list MessageActionItem.yojson_of_t)) - v_actions - in - let bnd = "actions", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(actions : MessageActionItem.t list option) - ~(message : string) - ~(type_ : MessageType.t) - (() : unit) + ?(actions : MessageActionItem.t list option) + ~(message : string) + ~(type_ : MessageType.t) + (() : unit) : t = { actions; message; type_ } @@ -48918,190 +8440,21 @@ module SignatureInformation = struct type t = { activeParameter : int Json.Nullable_option.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; documentation : documentation_pvar Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; label : string ; parameters : ParameterInformation.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SignatureInformation.t" in - function - | `Assoc field_yojsons as yojson -> - let activeParameter_field = ref Ppx_yojson_conv_lib.Option.None - and documentation_field = ref Ppx_yojson_conv_lib.Option.None - and label_field = ref Ppx_yojson_conv_lib.Option.None - and parameters_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "activeParameter" -> - (match Ppx_yojson_conv_lib.( ! ) activeParameter_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (Json.Nullable_option.t_of_yojson int_of_yojson) - _field_yojson - in - activeParameter_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "documentation" -> - (match Ppx_yojson_conv_lib.( ! ) documentation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - documentation_pvar_of_yojson - _field_yojson - in - documentation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "label" -> - (match Ppx_yojson_conv_lib.( ! ) label_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - label_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "parameters" -> - (match Ppx_yojson_conv_lib.( ! ) parameters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson ParameterInformation.t_of_yojson) - _field_yojson - in - parameters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) activeParameter_field - , Ppx_yojson_conv_lib.( ! ) documentation_field - , Ppx_yojson_conv_lib.( ! ) label_field - , Ppx_yojson_conv_lib.( ! ) parameters_field ) - with - | ( activeParameter_value - , documentation_value - , Ppx_yojson_conv_lib.Option.Some label_value - , parameters_value ) -> - { activeParameter = - (match activeParameter_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; documentation = - (match documentation_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; label = label_value - ; parameters = - (match parameters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) label_field) - Ppx_yojson_conv_lib.Option.None - , "label" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { activeParameter = v_activeParameter - ; documentation = v_documentation - ; label = v_label - ; parameters = v_parameters - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_parameters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (yojson_of_list ParameterInformation.yojson_of_t)) - v_parameters - in - let bnd = "parameters", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_label in - ("label", arg) :: bnds - in - let bnds = - if None = v_documentation - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_documentation_pvar) - v_documentation - in - let bnd = "documentation", arg in - bnd :: bnds) - in - let bnds = - if None = v_activeParameter - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (Json.Nullable_option.yojson_of_t yojson_of_int)) - v_activeParameter - in - let bnd = "activeParameter", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(activeParameter : int option option) - ?(documentation : documentation_pvar option) - ~(label : string) - ?(parameters : ParameterInformation.t list option) - (() : unit) + ?(activeParameter : int option option) + ?(documentation : documentation_pvar option) + ~(label : string) + ?(parameters : ParameterInformation.t list option) + (() : unit) : t = { activeParameter; documentation; label; parameters } @@ -49111,153 +8464,18 @@ end module SignatureHelp = struct type t = { activeParameter : int Json.Nullable_option.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; activeSignature : int Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; signatures : SignatureInformation.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SignatureHelp.t" in - function - | `Assoc field_yojsons as yojson -> - let activeParameter_field = ref Ppx_yojson_conv_lib.Option.None - and activeSignature_field = ref Ppx_yojson_conv_lib.Option.None - and signatures_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "activeParameter" -> - (match Ppx_yojson_conv_lib.( ! ) activeParameter_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (Json.Nullable_option.t_of_yojson int_of_yojson) - _field_yojson - in - activeParameter_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "activeSignature" -> - (match Ppx_yojson_conv_lib.( ! ) activeSignature_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - activeSignature_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "signatures" -> - (match Ppx_yojson_conv_lib.( ! ) signatures_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson SignatureInformation.t_of_yojson _field_yojson - in - signatures_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) activeParameter_field - , Ppx_yojson_conv_lib.( ! ) activeSignature_field - , Ppx_yojson_conv_lib.( ! ) signatures_field ) - with - | ( activeParameter_value - , activeSignature_value - , Ppx_yojson_conv_lib.Option.Some signatures_value ) -> - { activeParameter = - (match activeParameter_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; activeSignature = - (match activeSignature_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; signatures = signatures_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) signatures_field) - Ppx_yojson_conv_lib.Option.None - , "signatures" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { activeParameter = v_activeParameter - ; activeSignature = v_activeSignature - ; signatures = v_signatures - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list SignatureInformation.yojson_of_t v_signatures in - ("signatures", arg) :: bnds - in - let bnds = - if None = v_activeSignature - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_activeSignature in - let bnd = "activeSignature", arg in - bnd :: bnds) - in - let bnds = - if None = v_activeParameter - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (Json.Nullable_option.yojson_of_t yojson_of_int)) - v_activeParameter - in - let bnd = "activeParameter", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(activeParameter : int option option) - ?(activeSignature : int option) - ~(signatures : SignatureInformation.t list) - (() : unit) + ?(activeParameter : int option option) + ?(activeSignature : int option) + ~(signatures : SignatureInformation.t list) + (() : unit) : t = { activeParameter; activeSignature; signatures } @@ -49267,174 +8485,20 @@ end module SignatureHelpContext = struct type t = { activeSignatureHelp : SignatureHelp.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; isRetrigger : bool ; triggerCharacter : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; triggerKind : SignatureHelpTriggerKind.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SignatureHelpContext.t" in - function - | `Assoc field_yojsons as yojson -> - let activeSignatureHelp_field = ref Ppx_yojson_conv_lib.Option.None - and isRetrigger_field = ref Ppx_yojson_conv_lib.Option.None - and triggerCharacter_field = ref Ppx_yojson_conv_lib.Option.None - and triggerKind_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "activeSignatureHelp" -> - (match Ppx_yojson_conv_lib.( ! ) activeSignatureHelp_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - SignatureHelp.t_of_yojson - _field_yojson - in - activeSignatureHelp_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "isRetrigger" -> - (match Ppx_yojson_conv_lib.( ! ) isRetrigger_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - isRetrigger_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "triggerCharacter" -> - (match Ppx_yojson_conv_lib.( ! ) triggerCharacter_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - triggerCharacter_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "triggerKind" -> - (match Ppx_yojson_conv_lib.( ! ) triggerKind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = SignatureHelpTriggerKind.t_of_yojson _field_yojson in - triggerKind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) activeSignatureHelp_field - , Ppx_yojson_conv_lib.( ! ) isRetrigger_field - , Ppx_yojson_conv_lib.( ! ) triggerCharacter_field - , Ppx_yojson_conv_lib.( ! ) triggerKind_field ) - with - | ( activeSignatureHelp_value - , Ppx_yojson_conv_lib.Option.Some isRetrigger_value - , triggerCharacter_value - , Ppx_yojson_conv_lib.Option.Some triggerKind_value ) -> - { activeSignatureHelp = - (match activeSignatureHelp_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; isRetrigger = isRetrigger_value - ; triggerCharacter = - (match triggerCharacter_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; triggerKind = triggerKind_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) isRetrigger_field) - Ppx_yojson_conv_lib.Option.None - , "isRetrigger" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) triggerKind_field) - Ppx_yojson_conv_lib.Option.None - , "triggerKind" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { activeSignatureHelp = v_activeSignatureHelp - ; isRetrigger = v_isRetrigger - ; triggerCharacter = v_triggerCharacter - ; triggerKind = v_triggerKind - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = SignatureHelpTriggerKind.yojson_of_t v_triggerKind in - ("triggerKind", arg) :: bnds - in - let bnds = - if None = v_triggerCharacter - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_string) v_triggerCharacter - in - let bnd = "triggerCharacter", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_bool v_isRetrigger in - ("isRetrigger", arg) :: bnds - in - let bnds = - if None = v_activeSignatureHelp - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t SignatureHelp.yojson_of_t) - v_activeSignatureHelp - in - let bnd = "activeSignatureHelp", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(activeSignatureHelp : SignatureHelp.t option) - ~(isRetrigger : bool) - ?(triggerCharacter : string option) - ~(triggerKind : SignatureHelpTriggerKind.t) - (() : unit) + ?(activeSignatureHelp : SignatureHelp.t option) + ~(isRetrigger : bool) + ?(triggerCharacter : string option) + ~(triggerKind : SignatureHelpTriggerKind.t) + (() : unit) : t = { activeSignatureHelp; isRetrigger; triggerCharacter; triggerKind } @@ -49444,175 +8508,20 @@ end module SignatureHelpParams = struct type t = { context : SignatureHelpContext.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SignatureHelpParams.t" in - function - | `Assoc field_yojsons as yojson -> - let context_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "context" -> - (match Ppx_yojson_conv_lib.( ! ) context_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - SignatureHelpContext.t_of_yojson - _field_yojson - in - context_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) context_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( context_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { context = - (match context_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { context = v_context - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - if None = v_context - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t SignatureHelpContext.yojson_of_t) v_context - in - let bnd = "context", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(context : SignatureHelpContext.t option) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(context : SignatureHelpContext.t option) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { context; position; textDocument; workDoneToken } @@ -49622,191 +8531,22 @@ end module SignatureHelpRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; retriggerCharacters : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; triggerCharacters : string list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SignatureHelpRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and retriggerCharacters_field = ref Ppx_yojson_conv_lib.Option.None - and triggerCharacters_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "retriggerCharacters" -> - (match Ppx_yojson_conv_lib.( ! ) retriggerCharacters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - retriggerCharacters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "triggerCharacters" -> - (match Ppx_yojson_conv_lib.( ! ) triggerCharacters_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson string_of_yojson) - _field_yojson - in - triggerCharacters_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( documentSelector_value - , retriggerCharacters_value - , triggerCharacters_value - , workDoneProgress_value ) - = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) retriggerCharacters_field - , Ppx_yojson_conv_lib.( ! ) triggerCharacters_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; retriggerCharacters = - (match retriggerCharacters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; triggerCharacters = - (match triggerCharacters_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector - ; retriggerCharacters = v_retriggerCharacters - ; triggerCharacters = v_triggerCharacters - ; workDoneProgress = v_workDoneProgress - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_triggerCharacters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_triggerCharacters - in - let bnd = "triggerCharacters", arg in - bnd :: bnds) - in - let bnds = - if None = v_retriggerCharacters - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_string)) - v_retriggerCharacters - in - let bnd = "retriggerCharacters", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(retriggerCharacters : string list option) - ?(triggerCharacters : string list option) - ?(workDoneProgress : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(retriggerCharacters : string list option) + ?(triggerCharacters : string list option) + ?(workDoneProgress : bool option) + (() : unit) : t = { documentSelector; retriggerCharacters; triggerCharacters; workDoneProgress } @@ -49816,80 +8556,7 @@ end module StaticRegistrationOptions = struct type t = { id : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.StaticRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let id_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let id_value = Ppx_yojson_conv_lib.( ! ) id_field in - { id = - (match id_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { id = v_id } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_id - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_id in - let bnd = "id", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(id : string option) (() : unit) : t = { id } end @@ -49897,224 +8564,25 @@ end module SymbolInformation = struct type t = { containerName : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; deprecated : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; kind : SymbolKind.t ; location : Location.t ; name : string ; tags : SymbolTag.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.SymbolInformation.t" in - function - | `Assoc field_yojsons as yojson -> - let containerName_field = ref Ppx_yojson_conv_lib.Option.None - and deprecated_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and location_field = ref Ppx_yojson_conv_lib.Option.None - and name_field = ref Ppx_yojson_conv_lib.Option.None - and tags_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "containerName" -> - (match Ppx_yojson_conv_lib.( ! ) containerName_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - containerName_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "deprecated" -> - (match Ppx_yojson_conv_lib.( ! ) deprecated_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - deprecated_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = SymbolKind.t_of_yojson _field_yojson in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "location" -> - (match Ppx_yojson_conv_lib.( ! ) location_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Location.t_of_yojson _field_yojson in - location_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "name" -> - (match Ppx_yojson_conv_lib.( ! ) name_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - name_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tags" -> - (match Ppx_yojson_conv_lib.( ! ) tags_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson SymbolTag.t_of_yojson) - _field_yojson - in - tags_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) containerName_field - , Ppx_yojson_conv_lib.( ! ) deprecated_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) location_field - , Ppx_yojson_conv_lib.( ! ) name_field - , Ppx_yojson_conv_lib.( ! ) tags_field ) - with - | ( containerName_value - , deprecated_value - , Ppx_yojson_conv_lib.Option.Some kind_value - , Ppx_yojson_conv_lib.Option.Some location_value - , Ppx_yojson_conv_lib.Option.Some name_value - , tags_value ) -> - { containerName = - (match containerName_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; deprecated = - (match deprecated_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; kind = kind_value - ; location = location_value - ; name = name_value - ; tags = - (match tags_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) kind_field) - Ppx_yojson_conv_lib.Option.None - , "kind" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) location_field) - Ppx_yojson_conv_lib.Option.None - , "location" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) name_field) - Ppx_yojson_conv_lib.Option.None - , "name" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { containerName = v_containerName - ; deprecated = v_deprecated - ; kind = v_kind - ; location = v_location - ; name = v_name - ; tags = v_tags - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_tags - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list SymbolTag.yojson_of_t)) - v_tags - in - let bnd = "tags", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_name in - ("name", arg) :: bnds - in - let bnds = - let arg = Location.yojson_of_t v_location in - ("location", arg) :: bnds - in - let bnds = - let arg = SymbolKind.yojson_of_t v_kind in - ("kind", arg) :: bnds - in - let bnds = - if None = v_deprecated - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_deprecated in - let bnd = "deprecated", arg in - bnd :: bnds) - in - let bnds = - if None = v_containerName - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_string) v_containerName - in - let bnd = "containerName", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(containerName : string option) - ?(deprecated : bool option) - ~(kind : SymbolKind.t) - ~(location : Location.t) - ~(name : string) - ?(tags : SymbolTag.t list option) - (() : unit) + ?(containerName : string option) + ?(deprecated : bool option) + ~(kind : SymbolKind.t) + ~(location : Location.t) + ~(name : string) + ?(tags : SymbolTag.t list option) + (() : unit) : t = { containerName; deprecated; kind; location; name; tags } @@ -50124,119 +8592,15 @@ end module TextDocumentChangeRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; syncKind : TextDocumentSyncKind.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentChangeRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and syncKind_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "syncKind" -> - (match Ppx_yojson_conv_lib.( ! ) syncKind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentSyncKind.t_of_yojson _field_yojson in - syncKind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) syncKind_field ) - with - | documentSelector_value, Ppx_yojson_conv_lib.Option.Some syncKind_value -> - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; syncKind = syncKind_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) syncKind_field) - Ppx_yojson_conv_lib.Option.None - , "syncKind" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector; syncKind = v_syncKind } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = TextDocumentSyncKind.yojson_of_t v_syncKind in - ("syncKind", arg) :: bnds - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ~(syncKind : TextDocumentSyncKind.t) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ~(syncKind : TextDocumentSyncKind.t) + (() : unit) : t = { documentSelector; syncKind } @@ -50248,100 +8612,7 @@ module TextDocumentPositionParams = struct { position : Position.t ; textDocument : TextDocumentIdentifier.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentPositionParams.t" in - function - | `Assoc field_yojsons as yojson -> - let position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value ) -> - { position = position_value; textDocument = textDocument_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { position = v_position; textDocument = v_textDocument } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(position : Position.t) ~(textDocument : TextDocumentIdentifier.t) : t = { position; textDocument } @@ -50351,89 +8622,9 @@ end module TextDocumentRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value = - Ppx_yojson_conv_lib.( ! ) documentSelector_field - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(documentSelector : DocumentSelector.t option) (() : unit) : t = { documentSelector } @@ -50443,119 +8634,16 @@ end module TextDocumentSaveRegistrationOptions = struct type t = { documentSelector : DocumentSelector.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; includeText : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TextDocumentSaveRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let documentSelector_field = ref Ppx_yojson_conv_lib.Option.None - and includeText_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "documentSelector" -> - (match Ppx_yojson_conv_lib.( ! ) documentSelector_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DocumentSelector.t_of_yojson - _field_yojson - in - documentSelector_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "includeText" -> - (match Ppx_yojson_conv_lib.( ! ) includeText_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - includeText_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let documentSelector_value, includeText_value = - ( Ppx_yojson_conv_lib.( ! ) documentSelector_field - , Ppx_yojson_conv_lib.( ! ) includeText_field ) - in - { documentSelector = - (match documentSelector_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; includeText = - (match includeText_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { documentSelector = v_documentSelector; includeText = v_includeText } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_includeText - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_includeText in - let bnd = "includeText", arg in - bnd :: bnds) - in - let bnds = - if None = v_documentSelector - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DocumentSelector.yojson_of_t) - v_documentSelector - in - let bnd = "documentSelector", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(documentSelector : DocumentSelector.t option) - ?(includeText : bool option) - (() : unit) + ?(documentSelector : DocumentSelector.t option) + ?(includeText : bool option) + (() : unit) : t = { documentSelector; includeText } @@ -50565,176 +8653,20 @@ end module TypeDefinitionParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeDefinitionParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; position; textDocument; workDoneToken } @@ -50750,253 +8682,21 @@ module TypeHierarchyItem = struct ; range : Range.t ; selectionRange : Range.t ; tags : SymbolTag.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; uri : DocumentUri.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeHierarchyItem.t" in - function - | `Assoc field_yojsons as yojson -> - let data_field = ref Ppx_yojson_conv_lib.Option.None - and detail_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and name_field = ref Ppx_yojson_conv_lib.Option.None - and range_field = ref Ppx_yojson_conv_lib.Option.None - and selectionRange_field = ref Ppx_yojson_conv_lib.Option.None - and tags_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "detail" -> - (match Ppx_yojson_conv_lib.( ! ) detail_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - detail_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = SymbolKind.t_of_yojson _field_yojson in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "name" -> - (match Ppx_yojson_conv_lib.( ! ) name_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - name_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "range" -> - (match Ppx_yojson_conv_lib.( ! ) range_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - range_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "selectionRange" -> - (match Ppx_yojson_conv_lib.( ! ) selectionRange_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Range.t_of_yojson _field_yojson in - selectionRange_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tags" -> - (match Ppx_yojson_conv_lib.( ! ) tags_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson SymbolTag.t_of_yojson) - _field_yojson - in - tags_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) detail_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) name_field - , Ppx_yojson_conv_lib.( ! ) range_field - , Ppx_yojson_conv_lib.( ! ) selectionRange_field - , Ppx_yojson_conv_lib.( ! ) tags_field - , Ppx_yojson_conv_lib.( ! ) uri_field ) - with - | ( data_value - , detail_value - , Ppx_yojson_conv_lib.Option.Some kind_value - , Ppx_yojson_conv_lib.Option.Some name_value - , Ppx_yojson_conv_lib.Option.Some range_value - , Ppx_yojson_conv_lib.Option.Some selectionRange_value - , tags_value - , Ppx_yojson_conv_lib.Option.Some uri_value ) -> - { data = data_value - ; detail = - (match detail_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; kind = kind_value - ; name = name_value - ; range = range_value - ; selectionRange = selectionRange_value - ; tags = - (match tags_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; uri = uri_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) kind_field) - Ppx_yojson_conv_lib.Option.None - , "kind" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) name_field) - Ppx_yojson_conv_lib.Option.None - , "name" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) range_field) - Ppx_yojson_conv_lib.Option.None - , "range" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) selectionRange_field) - Ppx_yojson_conv_lib.Option.None - , "selectionRange" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { data = v_data - ; detail = v_detail - ; kind = v_kind - ; name = v_name - ; range = v_range - ; selectionRange = v_selectionRange - ; tags = v_tags - ; uri = v_uri - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - if None = v_tags - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list SymbolTag.yojson_of_t)) - v_tags - in - let bnd = "tags", arg in - bnd :: bnds) - in - let bnds = - let arg = Range.yojson_of_t v_selectionRange in - ("selectionRange", arg) :: bnds - in - let bnds = - let arg = Range.yojson_of_t v_range in - ("range", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_name in - ("name", arg) :: bnds - in - let bnds = - let arg = SymbolKind.yojson_of_t v_kind in - ("kind", arg) :: bnds - in - let bnds = - if None = v_detail - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_detail in - let bnd = "detail", arg in - bnd :: bnds) - in - let bnds = - match v_data with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "data", arg in - bnd :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(data : Json.t option) - ?(detail : string option) - ~(kind : SymbolKind.t) - ~(name : string) - ~(range : Range.t) - ~(selectionRange : Range.t) - ?(tags : SymbolTag.t list option) - ~(uri : DocumentUri.t) - (() : unit) + ?(data : Json.t option) + ?(detail : string option) + ~(kind : SymbolKind.t) + ~(name : string) + ~(range : Range.t) + ~(selectionRange : Range.t) + ?(tags : SymbolTag.t list option) + ~(uri : DocumentUri.t) + (() : unit) : t = { data; detail; kind; name; range; selectionRange; tags; uri } @@ -51008,141 +8708,15 @@ module TypeHierarchyPrepareParams = struct { position : Position.t ; textDocument : TextDocumentIdentifier.t ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeHierarchyPrepareParams.t" in - function - | `Assoc field_yojsons as yojson -> - let position_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) position_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some position_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value - , workDoneToken_value ) -> - { position = position_value - ; textDocument = textDocument_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) position_field) - Ppx_yojson_conv_lib.Option.None - , "position" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { position = v_position - ; textDocument = v_textDocument - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = Position.yojson_of_t v_position in - ("position", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(position : Position.t) - ~(textDocument : TextDocumentIdentifier.t) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(position : Position.t) + ~(textDocument : TextDocumentIdentifier.t) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { position; textDocument; workDoneToken } @@ -51153,153 +8727,17 @@ module TypeHierarchySubtypesParams = struct type t = { item : TypeHierarchyItem.t ; partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeHierarchySubtypesParams.t" in - function - | `Assoc field_yojsons as yojson -> - let item_field = ref Ppx_yojson_conv_lib.Option.None - and partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "item" -> - (match Ppx_yojson_conv_lib.( ! ) item_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TypeHierarchyItem.t_of_yojson _field_yojson in - item_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) item_field - , Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some item_value - , partialResultToken_value - , workDoneToken_value ) -> - { item = item_value - ; partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) item_field) - Ppx_yojson_conv_lib.Option.None - , "item" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { item = v_item - ; partialResultToken = v_partialResultToken - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TypeHierarchyItem.yojson_of_t v_item in - ("item", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(item : TypeHierarchyItem.t) - ?(partialResultToken : ProgressToken.t option) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(item : TypeHierarchyItem.t) + ?(partialResultToken : ProgressToken.t option) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { item; partialResultToken; workDoneToken } @@ -51310,153 +8748,17 @@ module TypeHierarchySupertypesParams = struct type t = { item : TypeHierarchyItem.t ; partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.TypeHierarchySupertypesParams.t" in - function - | `Assoc field_yojsons as yojson -> - let item_field = ref Ppx_yojson_conv_lib.Option.None - and partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "item" -> - (match Ppx_yojson_conv_lib.( ! ) item_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TypeHierarchyItem.t_of_yojson _field_yojson in - item_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) item_field - , Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some item_value - , partialResultToken_value - , workDoneToken_value ) -> - { item = item_value - ; partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) item_field) - Ppx_yojson_conv_lib.Option.None - , "item" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { item = v_item - ; partialResultToken = v_partialResultToken - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - let bnds = - let arg = TypeHierarchyItem.yojson_of_t v_item in - ("item", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(item : TypeHierarchyItem.t) - ?(partialResultToken : ProgressToken.t option) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ~(item : TypeHierarchyItem.t) + ?(partialResultToken : ProgressToken.t option) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { item; partialResultToken; workDoneToken } @@ -51468,180 +8770,14 @@ module Unregistration = struct { id : string ; method_ : string [@key "method"] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.Unregistration.t" in - function - | `Assoc field_yojsons as yojson -> - let id_field = ref Ppx_yojson_conv_lib.Option.None - and method__field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "id" -> - (match Ppx_yojson_conv_lib.( ! ) id_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - id_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "method" -> - (match Ppx_yojson_conv_lib.( ! ) method__field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - method__field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) id_field - , Ppx_yojson_conv_lib.( ! ) method__field ) - with - | ( Ppx_yojson_conv_lib.Option.Some id_value - , Ppx_yojson_conv_lib.Option.Some method__value ) -> - { id = id_value; method_ = method__value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) id_field) - Ppx_yojson_conv_lib.Option.None - , "id" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) method__field) - Ppx_yojson_conv_lib.Option.None - , "method_" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { id = v_id; method_ = v_method_ } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_method_ in - ("method", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_id in - ("id", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(id : string) ~(method_ : string) : t = { id; method_ } end module UnregistrationParams = struct type t = { unregisterations : Unregistration.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.UnregistrationParams.t" in - function - | `Assoc field_yojsons as yojson -> - let unregisterations_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "unregisterations" -> - (match Ppx_yojson_conv_lib.( ! ) unregisterations_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Unregistration.t_of_yojson _field_yojson in - unregisterations_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) unregisterations_field with - | Ppx_yojson_conv_lib.Option.Some unregisterations_value -> - { unregisterations = unregisterations_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) unregisterations_field) - Ppx_yojson_conv_lib.Option.None - , "unregisterations" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { unregisterations = v_unregisterations } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list Unregistration.yojson_of_t v_unregisterations in - ("unregisterations", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(unregisterations : Unregistration.t list) : t = { unregisterations } end @@ -51651,104 +8787,11 @@ module WillSaveTextDocumentParams = struct { reason : TextDocumentSaveReason.t ; textDocument : TextDocumentIdentifier.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WillSaveTextDocumentParams.t" in - function - | `Assoc field_yojsons as yojson -> - let reason_field = ref Ppx_yojson_conv_lib.Option.None - and textDocument_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "reason" -> - (match Ppx_yojson_conv_lib.( ! ) reason_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentSaveReason.t_of_yojson _field_yojson in - reason_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) textDocument_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - textDocument_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) reason_field - , Ppx_yojson_conv_lib.( ! ) textDocument_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some reason_value - , Ppx_yojson_conv_lib.Option.Some textDocument_value ) -> - { reason = reason_value; textDocument = textDocument_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) reason_field) - Ppx_yojson_conv_lib.Option.None - , "reason" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) textDocument_field) - Ppx_yojson_conv_lib.Option.None - , "textDocument" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { reason = v_reason; textDocument = v_textDocument } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_textDocument in - ("textDocument", arg) :: bnds - in - let bnds = - let arg = TextDocumentSaveReason.yojson_of_t v_reason in - ("reason", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(reason : TextDocumentSaveReason.t) - ~(textDocument : TextDocumentIdentifier.t) + ~(reason : TextDocumentSaveReason.t) + ~(textDocument : TextDocumentIdentifier.t) : t = { reason; textDocument } @@ -51758,171 +8801,19 @@ end module WorkDoneProgressBegin = struct type t = { cancellable : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; message : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; percentage : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; title : string } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkDoneProgressBegin.t" in - function - | `Assoc field_yojsons as yojson -> - let cancellable_field = ref Ppx_yojson_conv_lib.Option.None - and message_field = ref Ppx_yojson_conv_lib.Option.None - and percentage_field = ref Ppx_yojson_conv_lib.Option.None - and title_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "cancellable" -> - (match Ppx_yojson_conv_lib.( ! ) cancellable_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - cancellable_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "message" -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - message_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "percentage" -> - (match Ppx_yojson_conv_lib.( ! ) percentage_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - percentage_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "title" -> - (match Ppx_yojson_conv_lib.( ! ) title_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - title_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) cancellable_field - , Ppx_yojson_conv_lib.( ! ) message_field - , Ppx_yojson_conv_lib.( ! ) percentage_field - , Ppx_yojson_conv_lib.( ! ) title_field ) - with - | ( cancellable_value - , message_value - , percentage_value - , Ppx_yojson_conv_lib.Option.Some title_value ) -> - { cancellable = - (match cancellable_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; message = - (match message_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; percentage = - (match percentage_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; title = title_value - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) title_field) - Ppx_yojson_conv_lib.Option.None - , "title" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { cancellable = v_cancellable - ; message = v_message - ; percentage = v_percentage - ; title = v_title - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_string v_title in - ("title", arg) :: bnds - in - let bnds = - if None = v_percentage - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_percentage in - let bnd = "percentage", arg in - bnd :: bnds) - in - let bnds = - if None = v_message - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_message in - let bnd = "message", arg in - bnd :: bnds) - in - let bnds = - if None = v_cancellable - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_cancellable in - let bnd = "cancellable", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(cancellable : bool option) - ?(message : string option) - ?(percentage : int option) - ~(title : string) - (() : unit) + ?(cancellable : bool option) + ?(message : string option) + ?(percentage : int option) + ~(title : string) + (() : unit) : t = { cancellable; message; percentage; title } @@ -51936,159 +8827,13 @@ module WorkDoneProgressBegin = struct end module WorkDoneProgressCancelParams = struct - type t = { token : ProgressToken.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkDoneProgressCancelParams.t" in - function - | `Assoc field_yojsons as yojson -> - let token_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "token" -> - (match Ppx_yojson_conv_lib.( ! ) token_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = ProgressToken.t_of_yojson _field_yojson in - token_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) token_field with - | Ppx_yojson_conv_lib.Option.Some token_value -> { token = token_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) token_field) - Ppx_yojson_conv_lib.Option.None - , "token" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { token = v_token } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = ProgressToken.yojson_of_t v_token in - ("token", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { token : ProgressToken.t } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(token : ProgressToken.t) : t = { token } end module WorkDoneProgressCreateParams = struct - type t = { token : ProgressToken.t } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkDoneProgressCreateParams.t" in - function - | `Assoc field_yojsons as yojson -> - let token_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "token" -> - (match Ppx_yojson_conv_lib.( ! ) token_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = ProgressToken.t_of_yojson _field_yojson in - token_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) token_field with - | Ppx_yojson_conv_lib.Option.Some token_value -> { token = token_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) token_field) - Ppx_yojson_conv_lib.Option.None - , "token" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { token = v_token } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = ProgressToken.yojson_of_t v_token in - ("token", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + type t = { token : ProgressToken.t } [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(token : ProgressToken.t) : t = { token } end @@ -52097,80 +8842,7 @@ module WorkDoneProgressEnd = struct type t = { message : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkDoneProgressEnd.t" in - function - | `Assoc field_yojsons as yojson -> - let message_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "message" -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - message_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let message_value = Ppx_yojson_conv_lib.( ! ) message_field in - { message = - (match message_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { message = v_message } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_message - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_message in - let bnd = "message", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(message : string option) (() : unit) : t = { message } let yojson_of_t (t : t) : Json.t = Json.To.literal_field "kind" "end" yojson_of_t t @@ -52183,86 +8855,9 @@ end module WorkDoneProgressOptions = struct type t = { workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkDoneProgressOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneProgress_value = - Ppx_yojson_conv_lib.( ! ) workDoneProgress_field - in - { workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneProgress : bool option) (() : unit) : t = { workDoneProgress } end @@ -52270,86 +8865,9 @@ end module WorkDoneProgressParams = struct type t = { workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkDoneProgressParams.t" in - function - | `Assoc field_yojsons as yojson -> - let workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workDoneToken_value = Ppx_yojson_conv_lib.( ! ) workDoneToken_field in - { workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workDoneToken = v_workDoneToken } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workDoneToken : ProgressToken.t option) (() : unit) : t = { workDoneToken } end @@ -52357,138 +8875,17 @@ end module WorkDoneProgressReport = struct type t = { cancellable : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; message : string Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; percentage : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkDoneProgressReport.t" in - function - | `Assoc field_yojsons as yojson -> - let cancellable_field = ref Ppx_yojson_conv_lib.Option.None - and message_field = ref Ppx_yojson_conv_lib.Option.None - and percentage_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "cancellable" -> - (match Ppx_yojson_conv_lib.( ! ) cancellable_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - cancellable_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "message" -> - (match Ppx_yojson_conv_lib.( ! ) message_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - message_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "percentage" -> - (match Ppx_yojson_conv_lib.( ! ) percentage_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - percentage_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let cancellable_value, message_value, percentage_value = - ( Ppx_yojson_conv_lib.( ! ) cancellable_field - , Ppx_yojson_conv_lib.( ! ) message_field - , Ppx_yojson_conv_lib.( ! ) percentage_field ) - in - { cancellable = - (match cancellable_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; message = - (match message_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; percentage = - (match percentage_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { cancellable = v_cancellable; message = v_message; percentage = v_percentage } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_percentage - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_percentage in - let bnd = "percentage", arg in - bnd :: bnds) - in - let bnds = - if None = v_message - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_message in - let bnd = "message", arg in - bnd :: bnds) - in - let bnds = - if None = v_cancellable - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_bool) v_cancellable in - let bnd = "cancellable", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(cancellable : bool option) - ?(message : string option) - ?(percentage : int option) - (() : unit) + ?(cancellable : bool option) + ?(message : string option) + ?(percentage : int option) + (() : unit) : t = { cancellable; message; percentage } @@ -52504,182 +8901,21 @@ end module WorkspaceDiagnosticParams = struct type t = { identifier : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; previousResultIds : PreviousResultId.t list ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceDiagnosticParams.t" in - function - | `Assoc field_yojsons as yojson -> - let identifier_field = ref Ppx_yojson_conv_lib.Option.None - and partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and previousResultIds_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "identifier" -> - (match Ppx_yojson_conv_lib.( ! ) identifier_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - identifier_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "previousResultIds" -> - (match Ppx_yojson_conv_lib.( ! ) previousResultIds_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson PreviousResultId.t_of_yojson _field_yojson in - previousResultIds_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) identifier_field - , Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) previousResultIds_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( identifier_value - , partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some previousResultIds_value - , workDoneToken_value ) -> - { identifier = - (match identifier_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; previousResultIds = previousResultIds_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) previousResultIds_field) - Ppx_yojson_conv_lib.Option.None - , "previousResultIds" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { identifier = v_identifier - ; partialResultToken = v_partialResultToken - ; previousResultIds = v_previousResultIds - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list PreviousResultId.yojson_of_t v_previousResultIds in - ("previousResultIds", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - let bnds = - if None = v_identifier - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_identifier in - let bnd = "identifier", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(identifier : string option) - ?(partialResultToken : ProgressToken.t option) - ~(previousResultIds : PreviousResultId.t list) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(identifier : string option) + ?(partialResultToken : ProgressToken.t option) + ~(previousResultIds : PreviousResultId.t list) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { identifier; partialResultToken; previousResultIds; workDoneToken } @@ -52692,132 +8928,13 @@ module WorkspaceUnchangedDocumentDiagnosticReport = struct ; uri : DocumentUri.t ; version : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceUnchangedDocumentDiagnosticReport.t" in - function - | `Assoc field_yojsons as yojson -> - let resultId_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "resultId" -> - (match Ppx_yojson_conv_lib.( ! ) resultId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - resultId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) resultId_field - , Ppx_yojson_conv_lib.( ! ) uri_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some resultId_value - , Ppx_yojson_conv_lib.Option.Some uri_value - , version_value ) -> - { resultId = resultId_value - ; uri = uri_value - ; version = - (match version_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) resultId_field) - Ppx_yojson_conv_lib.Option.None - , "resultId" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { resultId = v_resultId; uri = v_uri; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_version - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_version in - let bnd = "version", arg in - bnd :: bnds) - in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - let arg = yojson_of_string v_resultId in - ("resultId", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(resultId : string) - ~(uri : DocumentUri.t) - ?(version : int option) - (() : unit) + ~(resultId : string) + ~(uri : DocumentUri.t) + ?(version : int option) + (() : unit) : t = { resultId; uri; version } @@ -52836,161 +8953,18 @@ module WorkspaceFullDocumentDiagnosticReport = struct type t = { items : Diagnostic.t list ; resultId : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; uri : DocumentUri.t ; version : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceFullDocumentDiagnosticReport.t" in - function - | `Assoc field_yojsons as yojson -> - let items_field = ref Ppx_yojson_conv_lib.Option.None - and resultId_field = ref Ppx_yojson_conv_lib.Option.None - and uri_field = ref Ppx_yojson_conv_lib.Option.None - and version_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "items" -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = list_of_yojson Diagnostic.t_of_yojson _field_yojson in - items_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "resultId" -> - (match Ppx_yojson_conv_lib.( ! ) resultId_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - resultId_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "uri" -> - (match Ppx_yojson_conv_lib.( ! ) uri_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = DocumentUri.t_of_yojson _field_yojson in - uri_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "version" -> - (match Ppx_yojson_conv_lib.( ! ) version_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - version_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) items_field - , Ppx_yojson_conv_lib.( ! ) resultId_field - , Ppx_yojson_conv_lib.( ! ) uri_field - , Ppx_yojson_conv_lib.( ! ) version_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some items_value - , resultId_value - , Ppx_yojson_conv_lib.Option.Some uri_value - , version_value ) -> - { items = items_value - ; resultId = - (match resultId_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; uri = uri_value - ; version = - (match version_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) items_field) - Ppx_yojson_conv_lib.Option.None - , "items" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) uri_field) - Ppx_yojson_conv_lib.Option.None - , "uri" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { items = v_items; resultId = v_resultId; uri = v_uri; version = v_version } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_version - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_version in - let bnd = "version", arg in - bnd :: bnds) - in - let bnds = - let arg = DocumentUri.yojson_of_t v_uri in - ("uri", arg) :: bnds - in - let bnds = - if None = v_resultId - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_string) v_resultId in - let bnd = "resultId", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_list Diagnostic.yojson_of_t v_items in - ("items", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ~(items : Diagnostic.t list) - ?(resultId : string option) - ~(uri : DocumentUri.t) - ?(version : int option) - (() : unit) + ~(items : Diagnostic.t list) + ?(resultId : string option) + ~(uri : DocumentUri.t) + ?(version : int option) + (() : unit) : t = { items; resultId; uri; version } @@ -53007,7 +8981,7 @@ module WorkspaceDocumentDiagnosticReport = struct type t = [ `WorkspaceFullDocumentDiagnosticReport of WorkspaceFullDocumentDiagnosticReport.t | `WorkspaceUnchangedDocumentDiagnosticReport of - WorkspaceUnchangedDocumentDiagnosticReport.t + WorkspaceUnchangedDocumentDiagnosticReport.t ] let t_of_yojson (json : Json.t) : t = @@ -53034,166 +9008,14 @@ end module WorkspaceDiagnosticReport = struct type t = { items : WorkspaceDocumentDiagnosticReport.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceDiagnosticReport.t" in - function - | `Assoc field_yojsons as yojson -> - let items_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "items" -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson - WorkspaceDocumentDiagnosticReport.t_of_yojson - _field_yojson - in - items_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.Some items_value -> { items = items_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) items_field) - Ppx_yojson_conv_lib.Option.None - , "items" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { items = v_items } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list WorkspaceDocumentDiagnosticReport.yojson_of_t v_items in - ("items", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(items : WorkspaceDocumentDiagnosticReport.t list) : t = { items } end module WorkspaceDiagnosticReportPartialResult = struct type t = { items : WorkspaceDocumentDiagnosticReport.t list } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceDiagnosticReportPartialResult.t" in - function - | `Assoc field_yojsons as yojson -> - let items_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "items" -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - list_of_yojson - WorkspaceDocumentDiagnosticReport.t_of_yojson - _field_yojson - in - items_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) items_field with - | Ppx_yojson_conv_lib.Option.Some items_value -> { items = items_value } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) items_field) - Ppx_yojson_conv_lib.Option.None - , "items" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { items = v_items } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_list WorkspaceDocumentDiagnosticReport.yojson_of_t v_items in - ("items", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ~(items : WorkspaceDocumentDiagnosticReport.t list) : t = { items } end @@ -53202,92 +9024,9 @@ module WorkspaceFoldersInitializeParams = struct type t = { workspaceFolders : WorkspaceFolder.t list Json.Nullable_option.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceFoldersInitializeParams.t" in - function - | `Assoc field_yojsons as yojson -> - let workspaceFolders_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "workspaceFolders" -> - (match Ppx_yojson_conv_lib.( ! ) workspaceFolders_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (Json.Nullable_option.t_of_yojson - (list_of_yojson WorkspaceFolder.t_of_yojson)) - _field_yojson - in - workspaceFolders_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let workspaceFolders_value = - Ppx_yojson_conv_lib.( ! ) workspaceFolders_field - in - { workspaceFolders = - (match workspaceFolders_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { workspaceFolders = v_workspaceFolders } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workspaceFolders - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t - (Json.Nullable_option.yojson_of_t - (yojson_of_list WorkspaceFolder.yojson_of_t))) - v_workspaceFolders - in - let bnd = "workspaceFolders", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create ?(workspaceFolders : WorkspaceFolder.t list option option) (() : unit) : t = { workspaceFolders } @@ -53297,218 +9036,24 @@ end module WorkspaceSymbol = struct type t = { containerName : string Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; data : Json.t option [@yojson.option] ; kind : SymbolKind.t ; location : Location.t ; name : string ; tags : SymbolTag.t list Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceSymbol.t" in - function - | `Assoc field_yojsons as yojson -> - let containerName_field = ref Ppx_yojson_conv_lib.Option.None - and data_field = ref Ppx_yojson_conv_lib.Option.None - and kind_field = ref Ppx_yojson_conv_lib.Option.None - and location_field = ref Ppx_yojson_conv_lib.Option.None - and name_field = ref Ppx_yojson_conv_lib.Option.None - and tags_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "containerName" -> - (match Ppx_yojson_conv_lib.( ! ) containerName_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson string_of_yojson _field_yojson - in - containerName_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "data" -> - (match Ppx_yojson_conv_lib.( ! ) data_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Json.t_of_yojson _field_yojson in - data_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "kind" -> - (match Ppx_yojson_conv_lib.( ! ) kind_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = SymbolKind.t_of_yojson _field_yojson in - kind_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "location" -> - (match Ppx_yojson_conv_lib.( ! ) location_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Location.t_of_yojson _field_yojson in - location_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "name" -> - (match Ppx_yojson_conv_lib.( ! ) name_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - name_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "tags" -> - (match Ppx_yojson_conv_lib.( ! ) tags_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - (list_of_yojson SymbolTag.t_of_yojson) - _field_yojson - in - tags_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) containerName_field - , Ppx_yojson_conv_lib.( ! ) data_field - , Ppx_yojson_conv_lib.( ! ) kind_field - , Ppx_yojson_conv_lib.( ! ) location_field - , Ppx_yojson_conv_lib.( ! ) name_field - , Ppx_yojson_conv_lib.( ! ) tags_field ) - with - | ( containerName_value - , data_value - , Ppx_yojson_conv_lib.Option.Some kind_value - , Ppx_yojson_conv_lib.Option.Some location_value - , Ppx_yojson_conv_lib.Option.Some name_value - , tags_value ) -> - { containerName = - (match containerName_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; data = data_value - ; kind = kind_value - ; location = location_value - ; name = name_value - ; tags = - (match tags_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) kind_field) - Ppx_yojson_conv_lib.Option.None - , "kind" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) location_field) - Ppx_yojson_conv_lib.Option.None - , "location" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) name_field) - Ppx_yojson_conv_lib.Option.None - , "name" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { containerName = v_containerName - ; data = v_data - ; kind = v_kind - ; location = v_location - ; name = v_name - ; tags = v_tags - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_tags - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t (yojson_of_list SymbolTag.yojson_of_t)) - v_tags - in - let bnd = "tags", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_name in - ("name", arg) :: bnds - in - let bnds = - let arg = Location.yojson_of_t v_location in - ("location", arg) :: bnds - in - let bnds = - let arg = SymbolKind.yojson_of_t v_kind in - ("kind", arg) :: bnds - in - let bnds = - match v_data with - | Ppx_yojson_conv_lib.Option.None -> bnds - | Ppx_yojson_conv_lib.Option.Some v -> - let arg = Json.yojson_of_t v in - let bnd = "data", arg in - bnd :: bnds - in - let bnds = - if None = v_containerName - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_string) v_containerName - in - let bnd = "containerName", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(containerName : string option) - ?(data : Json.t option) - ~(kind : SymbolKind.t) - ~(location : Location.t) - ~(name : string) - ?(tags : SymbolTag.t list option) - (() : unit) + ?(containerName : string option) + ?(data : Json.t option) + ~(kind : SymbolKind.t) + ~(location : Location.t) + ~(name : string) + ?(tags : SymbolTag.t list option) + (() : unit) : t = { containerName; data; kind; location; name; tags } @@ -53518,154 +9063,18 @@ end module WorkspaceSymbolParams = struct type t = { partialResultToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; query : string ; workDoneToken : ProgressToken.t Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceSymbolParams.t" in - function - | `Assoc field_yojsons as yojson -> - let partialResultToken_field = ref Ppx_yojson_conv_lib.Option.None - and query_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneToken_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "partialResultToken" -> - (match Ppx_yojson_conv_lib.( ! ) partialResultToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - partialResultToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "query" -> - (match Ppx_yojson_conv_lib.( ! ) query_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = string_of_yojson _field_yojson in - query_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneToken" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneToken_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ProgressToken.t_of_yojson - _field_yojson - in - workDoneToken_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) partialResultToken_field - , Ppx_yojson_conv_lib.( ! ) query_field - , Ppx_yojson_conv_lib.( ! ) workDoneToken_field ) - with - | ( partialResultToken_value - , Ppx_yojson_conv_lib.Option.Some query_value - , workDoneToken_value ) -> - { partialResultToken = - (match partialResultToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; query = query_value - ; workDoneToken = - (match workDoneToken_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) query_field) - Ppx_yojson_conv_lib.Option.None - , "query" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { partialResultToken = v_partialResultToken - ; query = v_query - ; workDoneToken = v_workDoneToken - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) v_workDoneToken - in - let bnd = "workDoneToken", arg in - bnd :: bnds) - in - let bnds = - let arg = yojson_of_string v_query in - ("query", arg) :: bnds - in - let bnds = - if None = v_partialResultToken - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ProgressToken.yojson_of_t) - v_partialResultToken - in - let bnd = "partialResultToken", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(partialResultToken : ProgressToken.t option) - ~(query : string) - ?(workDoneToken : ProgressToken.t option) - (() : unit) + ?(partialResultToken : ProgressToken.t option) + ~(query : string) + ?(workDoneToken : ProgressToken.t option) + (() : unit) : t = { partialResultToken; query; workDoneToken } @@ -53675,118 +9084,16 @@ end module WorkspaceSymbolRegistrationOptions = struct type t = { resolveProvider : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] + [@default None] [@yojson_drop_default ( = )] ; workDoneProgress : bool Json.Nullable_option.t - [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "lsp/src/types.ml.WorkspaceSymbolRegistrationOptions.t" in - function - | `Assoc field_yojsons as yojson -> - let resolveProvider_field = ref Ppx_yojson_conv_lib.Option.None - and workDoneProgress_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "resolveProvider" -> - (match Ppx_yojson_conv_lib.( ! ) resolveProvider_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - resolveProvider_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "workDoneProgress" -> - (match Ppx_yojson_conv_lib.( ! ) workDoneProgress_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson bool_of_yojson _field_yojson - in - workDoneProgress_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let resolveProvider_value, workDoneProgress_value = - ( Ppx_yojson_conv_lib.( ! ) resolveProvider_field - , Ppx_yojson_conv_lib.( ! ) workDoneProgress_field ) - in - { resolveProvider = - (match resolveProvider_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; workDoneProgress = - (match workDoneProgress_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { resolveProvider = v_resolveProvider; workDoneProgress = v_workDoneProgress } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_workDoneProgress - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_workDoneProgress - in - let bnd = "workDoneProgress", arg in - bnd :: bnds) - in - let bnds = - if None = v_resolveProvider - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t yojson_of_bool) v_resolveProvider - in - let bnd = "resolveProvider", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] let create - ?(resolveProvider : bool option) - ?(workDoneProgress : bool option) - (() : unit) + ?(resolveProvider : bool option) + ?(workDoneProgress : bool option) + (() : unit) : t = { resolveProvider; workDoneProgress } diff --git a/lsp/src/types.mli b/lsp/src/types.mli index 7957fe9b1..6ff512529 100644 --- a/lsp/src/types.mli +++ b/lsp/src/types.mli @@ -31,19 +31,44 @@ module ProgressParams : sig include Json.Jsonable.S1 with type 'a t := 'a t end -module NotebookDocumentSyncOptions : sig - type t = unit +module NotebookDocumentFilter : sig + (* This type isn't exactly correct. At least one of the fields must be defined. + https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notebookDocumentFilter + *) + type t = + { notebookType : string option + ; scheme : string option + ; pattern : string option + } include Json.Jsonable.S with type t := t end -module NotebookDocumentSyncRegistrationOptions : sig - type t = unit +module NotebookSelector : sig + type cell = { language : string } + + (* This type isn't exactly correct. At least one of the fields must be defined. + https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notebookDocumentSyncOptions + *) + type t = + { notebook : + [ `Notebook of string | `NotebookDocumentFilter of NotebookDocumentFilter.t ] + option + ; cells : cell list option + } +end + +module NotebookDocumentSyncOptions : sig + type t = + { notebookSelector : + [ `NotebookSelector of NotebookSelector.t | `List of NotebookSelector.t list ] + ; save : bool option + } include Json.Jsonable.S with type t := t end -module NotebookDocumentFilter : sig +module NotebookDocumentSyncRegistrationOptions : sig type t = unit include Json.Jsonable.S with type t := t @@ -2053,13 +2078,13 @@ end module Color : sig type t = - { alpha : int - ; blue : int - ; green : int - ; red : int + { alpha : float + ; blue : float + ; green : float + ; red : float } - val create : alpha:int -> blue:int -> green:int -> red:int -> t + val create : alpha:float -> blue:float -> green:float -> red:float -> t include Json.Jsonable.S with type t := t end @@ -3053,7 +3078,7 @@ module DocumentDiagnosticReport : sig type t = [ `RelatedFullDocumentDiagnosticReport of RelatedFullDocumentDiagnosticReport.t | `RelatedUnchangedDocumentDiagnosticReport of - RelatedUnchangedDocumentDiagnosticReport.t + RelatedUnchangedDocumentDiagnosticReport.t ] include Json.Jsonable.S with type t := t @@ -3739,6 +3764,7 @@ module InitializeParams : sig } val create_clientInfo : name:string -> ?version:string -> unit -> clientInfo + val get_editor : clientInfo -> string * string type t = { capabilities : ClientCapabilities.t @@ -4201,7 +4227,7 @@ module ServerCapabilities : sig [ `Bool of bool | `LinkedEditingRangeOptions of LinkedEditingRangeOptions.t | `LinkedEditingRangeRegistrationOptions of - LinkedEditingRangeRegistrationOptions.t + LinkedEditingRangeRegistrationOptions.t ] option ; monikerProvider : @@ -4213,7 +4239,7 @@ module ServerCapabilities : sig ; notebookDocumentSync : [ `NotebookDocumentSyncOptions of NotebookDocumentSyncOptions.t | `NotebookDocumentSyncRegistrationOptions of - NotebookDocumentSyncRegistrationOptions.t + NotebookDocumentSyncRegistrationOptions.t ] option ; positionEncoding : PositionEncodingKind.t option @@ -4320,7 +4346,7 @@ module ServerCapabilities : sig [ `Bool of bool | `LinkedEditingRangeOptions of LinkedEditingRangeOptions.t | `LinkedEditingRangeRegistrationOptions of - LinkedEditingRangeRegistrationOptions.t + LinkedEditingRangeRegistrationOptions.t ] -> ?monikerProvider: [ `Bool of bool @@ -4330,7 +4356,7 @@ module ServerCapabilities : sig -> ?notebookDocumentSync: [ `NotebookDocumentSyncOptions of NotebookDocumentSyncOptions.t | `NotebookDocumentSyncRegistrationOptions of - NotebookDocumentSyncRegistrationOptions.t + NotebookDocumentSyncRegistrationOptions.t ] -> ?positionEncoding:PositionEncodingKind.t -> ?referencesProvider:[ `Bool of bool | `ReferenceOptions of ReferenceOptions.t ] @@ -5563,7 +5589,7 @@ module WorkspaceDocumentDiagnosticReport : sig type t = [ `WorkspaceFullDocumentDiagnosticReport of WorkspaceFullDocumentDiagnosticReport.t | `WorkspaceUnchangedDocumentDiagnosticReport of - WorkspaceUnchangedDocumentDiagnosticReport.t + WorkspaceUnchangedDocumentDiagnosticReport.t ] include Json.Jsonable.S with type t := t diff --git a/lsp/src/uri0.ml b/lsp/src/uri0.ml index 4cf514262..bebb1d7d2 100644 --- a/lsp/src/uri0.ml +++ b/lsp/src/uri0.ml @@ -14,11 +14,9 @@ type t = Uri_lexer.t = ; authority : string ; path : string ; query : string option - ; fragment : string option } let query t = t.query -let fragment t = t.fragment let backslash_to_slash = String.map ~f:(function @@ -37,7 +35,7 @@ let of_path path = Uri_lexer.of_path path ;; -let to_path { path; authority; scheme; query; _ } = +let to_path { path; authority; scheme; query } = let path = let len = String.length path in if len = 0 @@ -106,7 +104,7 @@ let encode ?(allow_slash = false) s = Buffer.contents buf ;; -let to_string { scheme; authority; path; query; fragment } = +let to_string { scheme; authority; path; query } = let buff = Buffer.create 64 in if not (String.is_empty scheme) then ( @@ -149,11 +147,6 @@ let to_string { scheme; authority; path; query; fragment } = | Some q -> Buffer.add_char buff '?'; Buffer.add_string buff (encode q)); - (match fragment with - | None -> () - | Some f -> - Buffer.add_char buff '#'; - Buffer.add_string buff (encode f)); Buffer.contents buff ;; diff --git a/lsp/src/uri0.mli b/lsp/src/uri0.mli index e834a1550..12174b6b4 100644 --- a/lsp/src/uri0.mli +++ b/lsp/src/uri0.mli @@ -10,9 +10,7 @@ val hash : t -> int val to_path : t -> string val of_path : string -> t val to_string : t -> string -val of_string : string -> t val query : t -> string option -val fragment : t -> string option module Private : sig val win32 : bool ref diff --git a/lsp/src/uri_lexer.mli b/lsp/src/uri_lexer.mli index 4c0122682..7cb68c163 100644 --- a/lsp/src/uri_lexer.mli +++ b/lsp/src/uri_lexer.mli @@ -3,7 +3,6 @@ type t = ; authority : string ; path : string ; query : string option - ; fragment : string option } val of_string : string -> t diff --git a/lsp/src/uri_lexer.mll b/lsp/src/uri_lexer.mll index ca89b4653..4ec02fef7 100644 --- a/lsp/src/uri_lexer.mll +++ b/lsp/src/uri_lexer.mll @@ -7,7 +7,6 @@ type t = ; authority : string ; path : string ; query: string option - ; fragment: string option } let int_of_hex_char c = @@ -85,8 +84,7 @@ and uri = parse ([^':' '/' '?' '#']+ as scheme ':') ? ("//" ([^ '/' '?' '#']* as authority)) ? ([^ '?' '#']* as path) -('?' ([^ '#']* as raw_query)) ? -('#' (_ * as fragment)) ? +(('?' ([^ '#']* as raw_query) '#'?)) ? { let scheme = scheme |> Option.value ~default:"file" in let authority = @@ -104,15 +102,15 @@ and uri = parse | None -> None | Some c -> Some (query (Buffer.create (String.length c)) (Lexing.from_string c)) in - { scheme; authority; path; query; fragment } + { scheme; authority; path; query } } and path = parse -| "" { { scheme = "file"; authority = ""; path = "/"; query = None; fragment = None } } -| "//" ([^ '/']* as authority) (['/']_* as path) { { scheme = "file"; authority; path ; query = None ; fragment = None } } -| "//" ([^ '/']* as authority) { { scheme = "file"; authority; path = "/" ; query = None ; fragment = None } } -| ("/" _* as path) { { scheme = "file"; authority = ""; path ; query = None ; fragment = None } } -| (_* as path) { { scheme = "file"; authority = ""; path = "/" ^ path ; query = None ; fragment = None } } +| "" { { scheme = "file"; authority = ""; path = "/"; query = None } } +| "//" ([^ '/']* as authority) (['/']_* as path) { { scheme = "file"; authority; path ; query = None } } +| "//" ([^ '/']* as authority) { { scheme = "file"; authority; path = "/" ; query = None } } +| ("/" _* as path) { { scheme = "file"; authority = ""; path ; query = None } } +| (_* as path) { { scheme = "file"; authority = ""; path = "/" ^ path ; query = None } } { let of_string s = diff --git a/lsp/test/diff_tests.ml b/lsp/test/diff_tests.ml index 55d5e5ee2..a4de2ce0e 100644 --- a/lsp/test/diff_tests.ml +++ b/lsp/test/diff_tests.ml @@ -31,9 +31,7 @@ let test ~from ~to_ = let%expect_test "empty strings" = test ~from:"" ~to_:""; - [%expect - {| - [] |}] + [%expect {| [] |}] ;; let%expect_test "from empty" = @@ -48,7 +46,8 @@ let%expect_test "from empty" = "start": { "character": 0, "line": 0 } } } - ] |}]; + ] + |}]; test ~from:"\n" ~to_:"foobar"; [%expect {| @@ -60,22 +59,24 @@ let%expect_test "from empty" = "start": { "character": 0, "line": 0 } } } - ] |}] + ] + |}] ;; let%expect_test "from empty - with newline" = test ~from:"" ~to_:"foobar\n"; [%expect {| - [ - { - "newText": "foobar\n", - "range": { - "end": { "character": 0, "line": 0 }, - "start": { "character": 0, "line": 0 } + [ + { + "newText": "foobar\n", + "range": { + "end": { "character": 0, "line": 0 }, + "start": { "character": 0, "line": 0 } + } } - } - ] |}] + ] + |}] ;; let%expect_test "to empty" = @@ -90,14 +91,13 @@ let%expect_test "to empty" = "start": { "character": 0, "line": 0 } } } - ] |}] + ] + |}] ;; let%expect_test "no change" = test ~from:"foobar" ~to_:"foobar"; - [%expect - {| - [] |}] + [%expect {| [] |}] ;; let%expect_test "multiline" = @@ -112,7 +112,8 @@ let%expect_test "multiline" = "start": { "character": 0, "line": 0 } } } - ] |}] + ] + |}] ;; let%expect_test "change a character" = @@ -127,7 +128,8 @@ let%expect_test "change a character" = "start": { "character": 0, "line": 0 } } } - ] |}] + ] + |}] ;; let%expect_test "delete empty line" = @@ -142,7 +144,8 @@ let%expect_test "delete empty line" = "start": { "character": 0, "line": 1 } } } - ] |}] + ] + |}] ;; let%expect_test "regerssion test 1" = @@ -176,7 +179,8 @@ z "start": { "character": 0, "line": 3 } } } - ] |}] + ] + |}] ;; let%expect_test "regerssion test 2" = @@ -198,7 +202,8 @@ let%expect_test "regerssion test 2" = "start": { "character": 0, "line": 1 } } } - ] |}] + ] + |}] ;; let%expect_test "regression test 3" = @@ -221,7 +226,8 @@ let%expect_test "regression test 3" = "start": { "character": 0, "line": 3 } } } - ] |}] + ] + |}] ;; let%expect_test "regression test 4" = @@ -244,7 +250,8 @@ let%expect_test "regression test 4" = "start": { "character": 0, "line": 3 } } } - ] |}] + ] + |}] ;; let%expect_test "regression test 5" = @@ -266,5 +273,6 @@ let%expect_test "regression test 5" = "start": { "character": 0, "line": 2 } } } - ] |}] + ] + |}] ;; diff --git a/lsp/test/dune b/lsp/test/dune index 1156aae86..ed491a083 100644 --- a/lsp/test/dune +++ b/lsp/test/dune @@ -11,9 +11,9 @@ ;; This is because of the (implicit_transitive_deps false) ;; in dune-project base - ppx_expect ppx_expect.config ppx_expect.config_types - ppx_inline_test.config) + ppx_inline_test.config + ppx_expect.runtime_types) (preprocess (pps ppx_expect))) diff --git a/lsp/test/string_zipper_tests.ml b/lsp/test/string_zipper_tests.ml index 3fad28329..d95377ad3 100644 --- a/lsp/test/string_zipper_tests.ml +++ b/lsp/test/string_zipper_tests.ml @@ -87,35 +87,35 @@ let%expect_test "goto line" = line 2: "foo\nX\n|Y" line 1: "foo\n|X\nY" line 0: "|foo\nX\nY" - line 0: "|foo\nX\nY" |}]; + line 0: "|foo\nX\nY" + |}]; test `String (String_zipper.of_string "") [ `Goto_line 100; `Goto_line 0 ]; [%expect {| line 0: "|" - line 0: "|" |}]; + line 0: "|" + |}]; test `String foo [ `Insert "baz"; `Goto_line 1; `Insert "1" ]; [%expect {| line 0: "|bazfoo\nX\nY" line 1: "bazfoo\n|X\nY" - line 1: "bazfoo\n|1X\nY" |}] + line 1: "bazfoo\n|1X\nY" + |}] ;; let%expect_test "insertions" = let foo = String_zipper.of_string "foo" in test `String foo [ `Insert "" ]; - [%expect - {| - line 0: "|foo" |}]; + [%expect {| line 0: "|foo" |}]; test `String foo [ `Insert "a" ]; - [%expect - {| - line 0: "|afoo" |}]; + [%expect {| line 0: "|afoo" |}]; test `String foo [ `Insert "a"; `Insert "b" ]; [%expect {| line 0: "|afoo" - line 0: "|bafoo" |}] + line 0: "|bafoo" + |}] ;; let%expect_test "mixed insert goto" = @@ -125,7 +125,8 @@ let%expect_test "mixed insert goto" = {| line 0: "|XXXfoo" line 0: "|YYYXXXfoo" - line 0: "|zzzYYYXXXfoo" |}] + line 0: "|zzzYYYXXXfoo" + |}] ;; let%expect_test "drop_until" = @@ -134,16 +135,12 @@ let%expect_test "drop_until" = let t' = String_zipper.goto_line t 2 in let t = String_zipper.drop_until t t' in printfn "%S" (String_zipper.to_string_debug t); - [%expect - {| - "foo\n|xxx" |}]; + [%expect {| "foo\n|xxx" |}]; let t = String_zipper.of_string "foo\nbar\n" in let t = String_zipper.goto_line t 2 in let t = String_zipper.drop_until t t in printfn "%S" (String_zipper.to_string_debug t); - [%expect - {| - "foo\nbar\n|" |}]; + [%expect {| "foo\nbar\n|" |}]; let t = String_zipper.of_string "123\n" in let t = String_zipper.goto_line t 1 in let t = String_zipper.drop_until t t in @@ -158,9 +155,7 @@ let%expect_test "squashing" = let t, str' = String_zipper.squash t in assert (String.equal str str'); printfn "squashing: %S" (String_zipper.to_string_debug t); - [%expect - {| - squashing: "foo\n|bar" |}] + [%expect {| squashing: "foo\n|bar" |}] ;; let%expect_test "add buffer between" = @@ -170,9 +165,7 @@ let%expect_test "add buffer between" = let b = Buffer.create 0 in String_zipper.add_buffer_between b t t'; printfn "result: %S" (Buffer.contents b); - [%expect - {| - result: "foo\n" |}] + [%expect {| result: "foo\n" |}] ;; let%expect_test "drop_until bug" = @@ -181,11 +174,7 @@ let%expect_test "drop_until bug" = let t = String_zipper.goto_line t 2 in let t = String_zipper.drop_until t t' in printfn "%S" (String_zipper.to_string_debug t); - [%expect - {| - "foo\nbar\n|" |}]; + [%expect {| "foo\nbar\n|" |}]; printfn "abs_pos: %d" (String_zipper.Private.reflect t).abs_pos; - [%expect - {| - abs_pos: 8 |}] + [%expect {| abs_pos: 8 |}] ;; diff --git a/lsp/test/substring_tests.ml b/lsp/test/substring_tests.ml index e34c52641..c3a6889fb 100644 --- a/lsp/test/substring_tests.ml +++ b/lsp/test/substring_tests.ml @@ -59,17 +59,11 @@ let%expect_test "rsplit_at" = in let s = Substring.of_string "foo|bar" in test s 0; - [%expect - {| - "foo|bar" "" |}]; + [%expect {| "foo|bar" "" |}]; test s 4; - [%expect - {| - "foo" "|bar" |}]; + [%expect {| "foo" "|bar" |}]; test s 7; - [%expect - {| - "" "foo|bar" |}] + [%expect {| "" "foo|bar" |}] ;; let test f sub ~pos ~len = @@ -94,27 +88,32 @@ let%expect_test "move_left" = [%expect {| [definitive] - newlines = 0 consumed = 2 |}]; + newlines = 0 consumed = 2 + |}]; test "foobar" ~pos:3 ~len:0; [%expect {| [definitive] - newlines = 0 consumed = 0 |}]; + newlines = 0 consumed = 0 + |}]; test "fo\no\nbar" ~pos:4 ~len:3; [%expect {| [definitive] - newlines = 1 consumed = 3 |}]; + newlines = 1 consumed = 3 + |}]; test "fo\no\nbar" ~pos:4 ~len:2; [%expect {| [definitive] - newlines = 1 consumed = 2 |}]; + newlines = 1 consumed = 2 + |}]; test "fo" ~pos:1 ~len:2; [%expect {| [definitive] - newlines = 0 consumed = 1 |}] + newlines = 0 consumed = 1 + |}] ;; let%expect_test "move_right" = @@ -123,22 +122,26 @@ let%expect_test "move_right" = [%expect {| [definitive] - newlines = 0 consumed = 2 |}]; + newlines = 0 consumed = 2 + |}]; test "foobar" ~pos:3 ~len:0; [%expect {| [definitive] - newlines = 0 consumed = 0 |}]; + newlines = 0 consumed = 0 + |}]; test "\n\nf" ~pos:2 ~len:3; [%expect {| [definitive] - newlines = 0 consumed = 1 |}]; + newlines = 0 consumed = 1 + |}]; test "fo\no\nbar" ~pos:4 ~len:2; [%expect {| [definitive] - newlines = 1 consumed = 2 |}] + newlines = 1 consumed = 2 + |}] ;; let%expect_test "rindex_from" = @@ -168,41 +171,49 @@ let%expect_test "rindex_from" = test "foo" 0; [%expect {| - [definitive] - not found |}]; + [definitive] + not found + |}]; test "foo" 1; [%expect {| - [definitive] - not found |}]; + [definitive] + not found + |}]; test "\nfoo" 1; [%expect {| [definitive] - 0 |}]; + 0 + |}]; test "\nfoo" 2; [%expect {| [definitive] - 0 |}]; + 0 + |}]; test "\nfoo" 4; [%expect {| [definitive] - 0 |}]; + 0 + |}]; test "\nfoo" 5; [%expect {| [definitive] - exception: Invalid_argument("Substring.rindex_from: out of bounds") |}]; + exception: Invalid_argument("Substring.rindex_from: out of bounds") + |}]; test "" 0; [%expect {| [definitive] - not found |}]; + not found + |}]; test "" 1; [%expect {| [definitive] - exception: Invalid_argument("Substring.rindex_from: out of bounds") |}] + exception: Invalid_argument("Substring.rindex_from: out of bounds") + |}] ;; diff --git a/lsp/test/text_document_tests.ml b/lsp/test/text_document_tests.ml index 2f703508e..3bec0061c 100644 --- a/lsp/test/text_document_tests.ml +++ b/lsp/test/text_document_tests.ml @@ -63,23 +63,17 @@ let test_multiple text changes = let%expect_test "first line insert" = let range = tuple_range (0, 1) (0, 3) in test "foo bar baz" range ~change:"XXXX"; - [%expect - {| - result: fXXXX bar baz |}] + [%expect {| result: fXXXX bar baz |}] ;; let%expect_test "null edit" = test "foo bar" (tuple_range (0, 2) (0, 2)) ~change:""; - [%expect - {| - result: foo bar |}] + [%expect {| result: foo bar |}] ;; let%expect_test "no range" = test_general "foo bar baz" [ None, "XXXX" ]; - [%expect - {| - result: XXXX |}] + [%expect {| result: XXXX |}] ;; let%expect_test "char by char" = @@ -89,9 +83,7 @@ let%expect_test "char by char" = ; tuple_range (0, 1) (0, 1), "o" ; tuple_range (0, 2) (0, 2), "o" ]; - [%expect - {| - result: foo |}] + [%expect {| result: foo |}] ;; let%expect_test "char by char - 2" = @@ -102,9 +94,7 @@ let%expect_test "char by char - 2" = ; tuple_range (1, 10) (1, 10), "r" ; tuple_range (1, 1) (1, 2), "" ]; - [%expect - {| - result: char by char - 2\nbr |}] + [%expect {| result: char by char - 2\nbr |}] ;; let%expect_test "char by char - 3" = @@ -114,159 +104,113 @@ let%expect_test "char by char - 3" = ; tuple_range (1, 3) (1, 4), "" ; tuple_range (1, 3) (1, 3), "x" ]; - [%expect - {| - result: first line skip\nchaxby char - 2\n |}] + [%expect {| result: first line skip\nchaxby char - 2\n |}] ;; let%expect_test "insert last" = test "x" (tuple_range (0, 1) (0, 1)) ~change:"y"; - [%expect - {| - result: xy |}]; + [%expect {| result: xy |}]; test "x\ny" (tuple_range (1, 1) (1, 1)) ~change:"z"; - [%expect - {| - result: x\nyz |}]; + [%expect {| result: x\nyz |}]; test "x\ny" (tuple_range (1, 10) (1, 10)) ~change:"z"; - [%expect - {| - result: x\nyz |}] + [%expect {| result: x\nyz |}] ;; let%expect_test "replace second line" = let range = tuple_range (1, 0) (2, 0) in test "foo\nbar\nbaz\n" range ~change:"XXXX\n"; - [%expect - {| - result: foo\nXXXX\nbaz\n |}] + [%expect {| result: foo\nXXXX\nbaz\n |}] ;; let%expect_test "edit in second line" = let range = tuple_range (1, 1) (1, 2) in test "foo\nbar\nbaz\n" range ~change:"-XXX-"; - [%expect - {| - result: foo\nb-XXX-r\nbaz\n |}] + [%expect {| result: foo\nb-XXX-r\nbaz\n |}] ;; let%expect_test "insert at the end" = let range = tuple_range (3, 0) (3, 0) in test "foo\nbar\nbaz\n" range ~change:"XXX"; - [%expect - {| - result: foo\nbar\nbaz\nXXX |}]; + [%expect {| result: foo\nbar\nbaz\nXXX |}]; let range = tuple_range (3, 0) (4, 0) in test "foo\nbar\nbaz\n" range ~change:"XXX"; - [%expect - {| - result: foo\nbar\nbaz\nXXX |}] + [%expect {| result: foo\nbar\nbaz\nXXX |}] ;; let%expect_test "insert at the beginning" = let range = tuple_range (0, 0) (0, 0) in test "foo\n\bar\nbaz\n" range ~change:"XXX\n"; - [%expect - {| - result: XXX\nfoo\n\bar\nbaz\n |}] + [%expect {| result: XXX\nfoo\n\bar\nbaz\n |}] ;; let%expect_test "insert in the middle" = test "ab" (tuple_range (0, 1) (0, 1)) ~change:"---"; - [%expect - {| - result: a---b |}] + [%expect {| result: a---b |}] ;; let%expect_test "replace first line" = let range = tuple_range (0, 0) (1, 0) in test "foo\nbar\n" range ~change:"baz\n"; - [%expect - {| - result: baz\nbar\n |}] + [%expect {| result: baz\nbar\n |}] ;; let%expect_test "beyond max char" = let range = tuple_range (0, 0) (0, 100) in test "foo\nbar\n" range ~change:"baz"; - [%expect - {| - result: baz\nbar\n |}] + [%expect {| result: baz\nbar\n |}] ;; let%expect_test "entire line without newline" = test "xxx\n" (tuple_range (0, 0) (0, 3)) ~change:"baz"; - [%expect - {| - result: baz\n |}]; + [%expect {| result: baz\n |}]; test "xxx\n" (tuple_range (0, 0) (0, 4)) ~change:"baz"; - [%expect - {| - result: baz\n |}]; + [%expect {| result: baz\n |}]; test "xxx\n" (tuple_range (0, 0) (1, 0)) ~change:"baz"; - [%expect - {| - result: baz |}] + [%expect {| result: baz |}] ;; let%expect_test "replace two lines" = test "a\nb\nc\n" (tuple_range (0, 0) (2, 0)) ~change:"XXX\n"; - [%expect - {| - result: XXX\nc\n |}] + [%expect {| result: XXX\nc\n |}] ;; let%expect_test "join lines" = test "a\nb" (tuple_range (0, 1) (1, 0)) ~change:""; - [%expect - {| - result: ab |}] + [%expect {| result: ab |}] ;; let%expect_test "remove text" = test "a---b" (tuple_range (0, 1) (0, 4)) ~change:""; - [%expect - {| - result: ab |}] + [%expect {| result: ab |}] ;; let%expect_test "remove newline - 1" = test "\n" (tuple_range (0, 0) (0, 1)) ~change:""; - [%expect - {| - result: \n |}] + [%expect {| result: \n |}] ;; let%expect_test "remove newlines - 2" = test_multiple "\nXXX\n" [ tuple_range (0, 0) (0, 1), "" ]; - [%expect - {| - result: \nXXX\n |}] + [%expect {| result: \nXXX\n |}] ;; let%expect_test "remove newlines - 3" = test_multiple "\nXXX\n\n" [ tuple_range (0, 0) (0, 1), ""; tuple_range (0, 1) (0, 2), "" ]; - [%expect - {| - result: \nXXX\n\n |}] + [%expect {| result: \nXXX\n\n |}] ;; let%expect_test "update when inserting a line at the end of the doc" = test "let x = 1;\n\nlet y = 2;" (tuple_range (2, 10) (2, 10)) ~change:"\n-ZZZ"; - [%expect - {| - result: let x = 1;\n\nlet y = 2;\n-ZZZ |}] + [%expect {| result: let x = 1;\n\nlet y = 2;\n-ZZZ |}] ;; let%expect_test "update when inserting a line at the end of the doc" = test_multiple "1\n2\n3\n" [ tuple_range (1, 9) (1, 9), "l"; tuple_range (1, 9) (1, 10), "" ]; - [%expect - {| - result: 1\n2l\n3\n |}] + [%expect {| result: 1\n2l\n3\n |}] ;; let%expect_test "absolute_position" = @@ -296,9 +240,7 @@ let%expect_test "replace second line first line is \\n" = let edit = TextEdit.create ~newText:"change" ~range in let new_doc = Text_document.apply_text_document_edits doc [ edit ] in new_doc |> Text_document.text |> String.escaped |> print_endline; - [%expect - {| - \nfochangeo\nbar\nbaz\n |}] + [%expect {| \nfochangeo\nbar\nbaz\n |}] ;; let%expect_test "get position after change" = @@ -312,5 +254,6 @@ let%expect_test "get position after change" = [%expect {| \nfochangeo\nbar\nbaz\n - pos: 22 |}] + pos: 22 + |}] ;; diff --git a/lsp/test/uri_tests.ml b/lsp/test/uri_tests.ml index af743af67..4c3f4eb78 100644 --- a/lsp/test/uri_tests.ml +++ b/lsp/test/uri_tests.ml @@ -52,7 +52,8 @@ let%expect_test "test uri parsing" = http://xxx? -> \? query: http://xyz?ab%3D1%23 -> \?ab=1# - query: ab=1# |}] + query: ab=1# + |}] ;; let uri_of_path = @@ -72,7 +73,8 @@ let%expect_test "uri of path" = foo/bar.mli -> file:///foo/bar.mli Windows: /foo/bar.ml -> file:///foo/bar.ml - foo/bar.mli -> file:///foo/bar.mli |}] + foo/bar.mli -> file:///foo/bar.mli + |}] ;; let%expect_test "of_path -> to_string" = @@ -255,7 +257,7 @@ let%expect_test "of_string -> to_string" = [%expect {| Unix: - file://shares/pröjects/c%23/#l12 -> file://shares/pr%C3%B6jects/c%23/#l12 + file://shares/pröjects/c%23/#l12 -> file://shares/pr%C3%B6jects/c%23/ file://sh%c3%a4res/path -> file://sh%C3%A4res/path untitled:c:/Users/jrieken/Code/abc.txt -> untitled:c%3A/Users/jrieken/Code/abc.txt untitled:C:/Users/jrieken/Code/abc.txt -> untitled:c%3A/Users/jrieken/Code/abc.txt @@ -267,7 +269,7 @@ let%expect_test "of_string -> to_string" = file:///pro%2Fjects/ -> file:///pro/jects/ vscode://mount/test.ml -> vscode://mount/test.ml Windows: - file://shares/pröjects/c%23/#l12 -> file://shares/pr%C3%B6jects/c%23/#l12 + file://shares/pröjects/c%23/#l12 -> file://shares/pr%C3%B6jects/c%23/ file://sh%c3%a4res/path -> file://sh%C3%A4res/path untitled:c:/Users/jrieken/Code/abc.txt -> untitled:c%3A/Users/jrieken/Code/abc.txt untitled:C:/Users/jrieken/Code/abc.txt -> untitled:c%3A/Users/jrieken/Code/abc.txt @@ -298,17 +300,17 @@ let%expect_test "of_string -> to_path" = ]; [%expect {| - Unix: - file://%2Fhome%2Fticino%2Fdesktop%2Fcpluscplus%2Ftest.cpp -> / - file://shares/pröjects/c%23/#l12 -> //shares/pröjects/c#/ - file:///_:/path -> /_:/path - -> / - file://LöC%2FAL/host:8080/projects/ -> //LöC/AL/host:8080/projects/ - Windows: - file://%2Fhome%2Fticino%2Fdesktop%2Fcpluscplus%2Ftest.cpp -> \ - file://shares/pröjects/c%23/#l12 -> \\shares\pröjects\c#\ - file:///_:/path -> \_:\path - -> \ - file://LöC%2FAL/host:8080/projects/ -> \\LöC\AL\host:8080\projects\ - |}] + Unix: + file://%2Fhome%2Fticino%2Fdesktop%2Fcpluscplus%2Ftest.cpp -> / + file://shares/pröjects/c%23/#l12 -> //shares/pröjects/c#/ + file:///_:/path -> /_:/path + -> / + file://LöC%2FAL/host:8080/projects/ -> //LöC/AL/host:8080/projects/ + Windows: + file://%2Fhome%2Fticino%2Fdesktop%2Fcpluscplus%2Ftest.cpp -> \ + file://shares/pröjects/c%23/#l12 -> \\shares\pröjects\c#\ + file:///_:/path -> \_:\path + -> \ + file://LöC%2FAL/host:8080/projects/ -> \\LöC\AL\host:8080\projects\ + |}] ;; diff --git a/ocaml-lsp-server.opam b/ocaml-lsp-server.opam index 8710e83ff..7f5a201d8 100644 --- a/ocaml-lsp-server.opam +++ b/ocaml-lsp-server.opam @@ -1,5 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" +version: "1.19.0+ox" synopsis: "LSP Server for OCaml" description: "An LSP server for OCaml." maintainer: ["Rudi Grinberg "] @@ -31,7 +32,7 @@ depends: [ "dyn" "stdune" "fiber" {>= "3.1.1" & < "4.0.0"} - "ocaml" {>= "5.3" & < "5.4"} + "ocaml" "xdg" "ordering" "dune-build-info" @@ -45,8 +46,12 @@ depends: [ "csexp" {>= "1.5"} "ocamlformat-rpc-lib" {>= "0.21.0"} "odoc" {with-doc} - "merlin-lib" {>= "5.4" & < "6.0"} - "ppx_yojson_conv" {with-dev-setup} + "odoc-parser" {= "3.1.0+ox"} + "merlin-lib" {= "5.2.1-502+ox"} + "ppx_yojson_conv" + "core_unix" + "async" + "cmarkit" ] dev-repo: "git+https://github.com/ocaml/ocaml-lsp.git" build: [ diff --git a/ocaml-lsp-server/bin/dune b/ocaml-lsp-server/bin/dune index e28bbbf21..5c410804d 100644 --- a/ocaml-lsp-server/bin/dune +++ b/ocaml-lsp-server/bin/dune @@ -2,6 +2,19 @@ (name main) (package ocaml-lsp-server) (public_name ocamllsp) - (libraries dune-build-info stdune lsp ocaml_lsp_server) + (libraries + async + async_kernel + async_unix + async.async_command + base + core + core.command + core_unix.command_unix + core_unix.filename_unix + core_unix.signal_unix + lsp + ocaml_lsp_server) + (preprocess (pps ppx_let ppx_sexp_conv)) (instrumentation (backend bisect_ppx))) diff --git a/ocaml-lsp-server/bin/main.ml b/ocaml-lsp-server/bin/main.ml index 6aef73d00..77ca22131 100644 --- a/ocaml-lsp-server/bin/main.ml +++ b/ocaml-lsp-server/bin/main.ml @@ -1,46 +1,64 @@ -open Stdune -module Cli = Lsp.Cli +open Core +open Async -let () = - Printexc.record_backtrace true; - let version = ref false in - let read_dot_merlin = ref false in - let arg = Lsp.Cli.Arg.create () in - let spec = - [ "--version", Arg.Set version, "print version" - ; ( "--fallback-read-dot-merlin" - , Arg.Set read_dot_merlin - , "read Merlin config from .merlin files. The `dot-merlin-reader` package must be \ - installed" ) - ] - @ Cli.Arg.spec arg - in - let usage = - "ocamllsp [ --stdio | --socket PORT | --port PORT | --pipe PIPE ] [ \ - --clientProcessId pid ]" - in - Arg.parse spec (fun _ -> raise @@ Arg.Bad "anonymous arguments aren't allowed") usage; - let channel = - match Cli.Arg.channel arg with - | Ok c -> c - | Error s -> - Format.eprintf "%s@.%!" s; - Arg.usage spec usage; - exit 1 - in - let version = !version in - if version - then ( - let version = Ocaml_lsp_server.Version.get () in - print_endline version) - else - let module Exn_with_backtrace = Stdune.Exn_with_backtrace in - match - Exn_with_backtrace.try_with - (Ocaml_lsp_server.run channel ~read_dot_merlin:!read_dot_merlin) - with - | Ok () -> () - | Error exn -> - Format.eprintf "%a@." Exn_with_backtrace.pp_uncaught exn; - exit 1 +module Channel = struct + type t = Lsp.Cli.Channel.t = + | Stdio + | Pipe of string + | Socket of int +end + +let command = + Command.async + ~summary:"OCaml LSP" + (let%map_open.Command () = return () + and channel = + choose_one_non_optional + [ flag + "stdio" + (no_arg_required Channel.Stdio) + ~doc:"Communicate over stdio (default)" + ; flag + "port" + (required int |> map_flag ~f:(fun port -> Channel.Socket port)) + ~doc:"PORT Communicate over an internet socket (127.0.0.1:PORT)" + ; flag + "unix" + (required string |> map_flag ~f:(fun unix -> Channel.Pipe unix)) + ~doc:"UNIX Communicate over a unix domain socket" + ] + ~if_nothing_chosen:(Default_to Stdio) + and client_pid = + flag + "client-pid" + (optional int) + ~doc: + "PID Process id of client. When passed, the server will exit when this client \ + dies." + and client_existence_check_interval = + flag_optional_with_default_doc + "check-client-existence-every" + Time_ns.Span.arg_type + [%sexp_of: Time_ns.Span.t] + ~default:(Time_ns.Span.of_int_sec 10) + ~doc: + "SPAN How frequently to check if client exists. Only relevant with \ + [-client-pid]." + and dot_merlin = + flag + "dot-merlin" + (optional Filename_unix.arg_type) + ~doc:"FILE Path to .merlin file. Used for OCaml_plugin." + in + fun () -> + Option.iter client_pid ~f:(fun pid -> + Clock_ns.every' client_existence_check_interval (fun () -> + match Signal_unix.can_send_to (Pid.of_int pid) with + | true -> return () + | false -> exit 0)); + (* TODO: Once Jenga is no longer supported, we can explore communicating with dune + directly instead of reading dot-merlin files. *) + Ocaml_lsp_server.run channel ~dot_merlin) ;; + +let () = Command_unix.run command diff --git a/ocaml-lsp-server/bin/main.mli b/ocaml-lsp-server/bin/main.mli index e69de29bb..d217255ec 100644 --- a/ocaml-lsp-server/bin/main.mli +++ b/ocaml-lsp-server/bin/main.mli @@ -0,0 +1 @@ +(*_ Intentionally left blank. *) diff --git a/ocaml-lsp-server/docs/ocamllsp/config.md b/ocaml-lsp-server/docs/ocamllsp/config.md index aea4ddfc3..2d9bfb2a6 100644 --- a/ocaml-lsp-server/docs/ocamllsp/config.md +++ b/ocaml-lsp-server/docs/ocamllsp/config.md @@ -42,12 +42,5 @@ interface config { * @since 1.18 */ syntaxDocumentation: { enable : boolean } - - /** - * Enable/Disable Merlin Jump code actions - * @default true - * @since 1.19 - */ - merlinJumpCodeActions: { enable : boolean } } ``` diff --git a/ocaml-lsp-server/docs/ocamllsp/construct-spec.md b/ocaml-lsp-server/docs/ocamllsp/construct-spec.md deleted file mode 100644 index b387f66d1..000000000 --- a/ocaml-lsp-server/docs/ocamllsp/construct-spec.md +++ /dev/null @@ -1,49 +0,0 @@ -# Construct Request - -## Description - -Provides commands to fill typed holes (`_`). Such holes sometimes -appear in the result of other commands like `destruct` and can also be inserted -manually in the source. The command is already accessible via a completion hook, -however, in certain situations, invoking `construct` on a hole via a request -allows more control. - -## Client Capability - -There is no client capability relative to this request. - -## Server capability - -- property name: `handleConstruct` -- property type: `boolean` - -## Request - -- method: `ocamllsp/construct` -- params: - - ```json - { - "uri": TextDocumentIdentifier, - "position": Position - "depth?": uinteger (default value: 0) - "withValues?": <"local" | "none">, - } - ``` - -The `depth` parameter allows to recursively construct terms. Note that -when `depth > 1` partial results of inferior depth will not be -returned. The `withValues` parameter enables the use of values from -the environment (`local`) or not (`none`), It defaults to `none`. - -## Response - -```json -{ - "position": Range, - "result": string[] -} -``` - -The result contains the range (`position`) to be replaced (describing the hole) -and the list of possible substitution values (`result`). diff --git a/ocaml-lsp-server/docs/ocamllsp/jumpToTypedHole-spec.md b/ocaml-lsp-server/docs/ocamllsp/jumpToTypedHole-spec.md deleted file mode 100644 index 6c124e515..000000000 --- a/ocaml-lsp-server/docs/ocamllsp/jumpToTypedHole-spec.md +++ /dev/null @@ -1,57 +0,0 @@ -# Jump To Typed Holes Requet - -### Description - -Returns the next or previous typed hole at a given position (included -in a range or not). - - -### Why this custom request needed - -Reduces the need for editor-side logic and works well with the -expression construct command. For example, constructing a value of -type `int option` constructs the following expression: -`Some _`, coupled with typed hole navigation, you can move the cursor -directly over the generated hole. - - -### A note on stability: - -> OCaml-LSP does not guarantee stability for this custom request, -> meaning the core contributors may change or remove this custom -> request, as they see necessary. - -## Client capability - -N/A - -## Server capability - -- property name: `handleJumpToTypedHole` -- property type: `boolean` - -## Request - -- method: `ocamllsp/jumpToTypedHole` -- params: - -```json -{ - "uri": TextDocumentIdentifier, - "position": Position, - "direction": <"next"|"prev">, - "range?": Range -} -``` - -If a `range` is given, it will only select holes present in the given -range. - -## Response - -```json -Range | null -``` - -Returns the next or previous typed hole at a given position. An -optional range can be used to restrict the search. diff --git a/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md b/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md deleted file mode 100644 index d92b30821..000000000 --- a/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md +++ /dev/null @@ -1,54 +0,0 @@ -# Merlin Jump Request - -## Description - -This custom request allows Merlin-type code navigation in a source buffer. - -## Server capability - -- propert name: `handleJump` -- property type: `boolean` - -## Request - -- method: `ocamllsp/jump` -- params: `JumpParams` extends [TextDocumentPositionParams](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentPositionParams) and is defined as follows: - -```js -export interface JumpParams extends TextDocumentPositionParams -{ - /** - * The requested target of the jump, one of `fun`, `let`, `module`, - * `module-type`, `match`, `match-next-case`, `match-prev-case`. - * - * If omitted, all valid targets will be considered. - */ - target?: string; -} -``` - -## Response - -- result: `Jump` - -```js - -export interface TargetPosition { - /** - * The target's kind. - */ - target: string; - - /** - * The corresponding position in the request's document. - */ - position: Position; -} - -export interface Jump { - /** - * The list of possible targets to jump-to. - */ - jumps: TargetPosition[] -} -``` diff --git a/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md b/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md deleted file mode 100644 index 2b34815db..000000000 --- a/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md +++ /dev/null @@ -1,55 +0,0 @@ -# TypeSearch Request - -## Description - -This custom request allows clients to perform a type search at a specific position within a text document based on finding functions or types that match a specific query pattern. - -## Server capability - -- property name: `handleTypeSearch` -- property type: `boolean` - -## Request - -```js -export interface TypeSearchParams extends TexDocumentPositionParams -{ - query: string; - limit: int; - with_doc: bool; - doc_format: string; -} -``` -- method: `ocamllsp/typeSearch` -- params: - - `TextDocumentPositionParams`: This is an existing interface that includes: - - `TextDocumentIdentifier`: Specifies the document uri for which the request is sent. - - `Position`: Specifies the cursor position. - More details can be found in the [TextDocumentPositionParams - LSP Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentPositionParams). - - `query`: The search pattern. - - `limit`: The number of results to return - - `with_doc`: If to return documentation information or not - -## Response -```json -{ - [ - "name": string, - "typ": string, - "loc": Range, - "doc": { - "value": string, - "kind": string - }, - "cost": int, - "constructible" : string - ] -} - ``` -- name: The fully qualified name of this result., -- typ: The signature of this result, -- loc: The location of the definition of this result in the source code., -- doc: Optional documentation associated with this result., -- cost: A numeric value representing the "cost" or distance between this result and the query. -- constructible: A constructible form or template that can be used to invoke this result -- A response with null result is returned if no entries are found. diff --git a/ocaml-lsp-server/src/code_actions/action_add_rec.ml b/ocaml-lsp-server/src/action_add_rec.ml similarity index 95% rename from ocaml-lsp-server/src/code_actions/action_add_rec.ml rename to ocaml-lsp-server/src/action_add_rec.ml index 5ecc37849..087ef5b3f 100644 --- a/ocaml-lsp-server/src/code_actions/action_add_rec.ml +++ b/ocaml-lsp-server/src/action_add_rec.ml @@ -6,12 +6,12 @@ let action_title = "Add missing `rec` keyword" let let_bound_vars bindings = List.filter_map bindings ~f:(fun vb -> match vb.Typedtree.vb_pat.pat_desc with - | Typedtree.Tpat_var (id, loc, _) -> Some (id, loc) + | Typedtree.Tpat_var (id, loc, _, _, _) -> Some (id, loc) | _ -> None) ;; -(** If the cursor position is inside a let binding which should have a ret tag - and does not, return the Location.t of the binding. *) +(** If the cursor position is inside a let binding which should have a ret tag and does + not, return the Location.t of the binding. *) let has_missing_rec pipeline pos_start = let open Option.O in (* Find identifier under cursor *) diff --git a/ocaml-lsp-server/src/code_actions/action_add_rec.mli b/ocaml-lsp-server/src/action_add_rec.mli similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_add_rec.mli rename to ocaml-lsp-server/src/action_add_rec.mli diff --git a/ocaml-lsp-server/src/action_combine_cases.ml b/ocaml-lsp-server/src/action_combine_cases.ml new file mode 100644 index 000000000..4beefa783 --- /dev/null +++ b/ocaml-lsp-server/src/action_combine_cases.ml @@ -0,0 +1,82 @@ +open Import +open Core +open Option.Let_syntax + +let action_kind = "combine-cases" +let kind = CodeActionKind.Other action_kind + +(** If the range spans multiple lines, then extend it to ensure it captures the full first + and last lines. *) +let select_complete_lines (range : Range.t) : Range.t option = + if range.start.line = range.end_.line + then None + else ( + let start = { range.start with character = 0 } in + match range.end_.character with + | 0 -> Some { range with start } + | _ -> + let end_ : Position.t = { line = range.end_.line + 1; character = 0 } in + Some { start; end_ }) +;; + +(** {v + If each line of [code] is a match-statement case of the form + "| lhs-pattern -> rhs-expression" + then return two lists containing all the lhs-patterns and all the rhs-expressions. + v} *) +let split_cases code = + let lines = String.split code ~on:'\n' in + (* Matches a line that starts with "|" and contains "->". *) + let case_regex = Re2.create_exn "^\\s*\\|.*->" in + let drop_from_lines lines regex = + List.map lines ~f:(Re2.replace_exn regex ~f:(Fn.const "")) + in + match List.for_all ~f:(Re2.matches case_regex) lines with + | false -> None + | true -> + (* Removes a leading "|" (with possible surrounding whitespace). *) + let without_pipes = drop_from_lines lines (Re2.create_exn "^\\s*\\|\\s*") in + (* Removes everything after the first "->" (with possible leading whitespace). *) + let lhs_patterns = drop_from_lines without_pipes (Re2.create_exn "\\s*->.*$") in + (* Removes everything before the first "->" (with possible trailing whitespace). *) + let rhs_expressions = drop_from_lines without_pipes (Re2.create_exn "^.*->\\s*") in + Some (lhs_patterns, rhs_expressions) +;; + +(** If there is exactly one non-empty expression, return it; otherwise return a hole. *) +let pick_rhs rhs_expressions = + let distinct_nonempty = + List.map rhs_expressions ~f:String.strip + |> List.filter ~f:(fun s -> (not (String.is_empty s)) && not (String.equal s "_")) + |> List.dedup_and_sort ~compare:String.compare + in + match distinct_nonempty with + | expr :: [] -> expr + | _ -> "_" +;; + +(** Called by the combine-cases code action. *) +let code_action ~log_info:_ (doc : Document.t) (params : CodeActionParams.t) = + match Document.kind doc with + | `Other -> Fiber.return None + | `Merlin merlin -> + (match Document.Merlin.kind merlin with + | Intf -> Fiber.return None + | Impl -> + Fiber.return + (let%bind range = select_complete_lines params.range in + let%bind code = Document.substring doc range in + let code = String.strip ~drop:(fun c -> Char.equal c '\n') code in + let%bind lhs_patterns, rhs_expressions = split_cases code in + let%bind i = String.index code '|' in + let indent = String.sub code ~pos:0 ~len:i in + let lhs = String.concat ~sep:" | " lhs_patterns in + let rhs = pick_rhs rhs_expressions in + let newText = [%string "%{indent}| %{lhs} -> %{rhs}\n"] in + let edit = Document.edit doc [ { range; newText } ] in + let title = String.capitalize action_kind in + let action = CodeAction.create ~title ~kind ~edit ~isPreferred:false () in + Some action)) +;; + +let t = { Code_action.kind; run = `Non_batchable code_action } diff --git a/ocaml-lsp-server/src/action_combine_cases.mli b/ocaml-lsp-server/src/action_combine_cases.mli new file mode 100644 index 000000000..e21bc4580 --- /dev/null +++ b/ocaml-lsp-server/src/action_combine_cases.mli @@ -0,0 +1,39 @@ +open Import + +(** {v + The combine-cases code action allows the user to select several one-line cases of a + match and combine them into a single one-line case. If there is a unique non-empty + right-hand-side expression it will be preserved; otherwise the RHS will be a hole. + + For example, if the user highlights the King and Queen lines of the following snippet + and invokes combine-cases... + [ match card with + | Ace -> _ + | King -> _ + | Queen -> "Face card!" + | Jack -> "Face card?" + | Number _ -> _] + then the code action will update the snippet to: + [ match card with + | Ace -> _ + | King | Queen -> "Face card!" + | Jack -> "Face card?" + | Number _ -> _] + If instead (or afterwards) they invoke combine-cases highlighting the King, Queen, + and Jack lines, they'll get: + [ match card with + | Ace -> _ + | King | Queen | Jack -> _ + | Number _ -> _] + + The intended use-case is immediately following a destruct-line code action, which + produces lots of empty cases on separate lines; this allows several related cases to + be quickly combined. + + Combine-cases avoids invoking Merlin and instead just works by regular expression + matching to detect the "|" and "->" tokens. This means it doesn't handle multi-line + cases and doesn't do anything smart when combining cases. + v} *) + +val kind : CodeActionKind.t +val t : Code_action.t diff --git a/ocaml-lsp-server/src/action_construct.ml b/ocaml-lsp-server/src/action_construct.ml new file mode 100644 index 000000000..8d745896a --- /dev/null +++ b/ocaml-lsp-server/src/action_construct.ml @@ -0,0 +1,45 @@ +open Import +open Fiber.O + +let make_construct_action ~state ~doc loc newText = + let title = [%string "Construct: %{newText}"] in + let kind = CodeActionKind.Other "construct" in + let range : Range.t = Range.of_loc loc in + let edit = Document.edit doc [ { range; newText } ] in + let command = Typed_hole.next_hole_cmd ~state ~edit:{ range; newText } in + CodeAction.create ~title ~kind ~edit ?command ~isPreferred:false () +;; + +(* Called by compute_ocaml_code_actions to get all construct options. *) +let get_construct_actions ~log_info (state : State.t) doc (params : CodeActionParams.t) = + match Document.kind doc with + | `Other -> Fiber.return [] + | `Merlin m when Document.Merlin.kind m = Intf -> Fiber.return [] + | `Merlin merlin -> + let pos = Position.logical params.range.Range.end_ in + let src = Document.source doc in + (* First do a fast local check to rule out non-holes. *) + let prefix = Compl.prefix_of_position ~short_path:false src pos in + let suffix = Compl.suffix_of_position src pos in + (match Typed_hole.can_be_hole prefix || Typed_hole.can_be_hole suffix with + | false -> Fiber.return [] + | true -> + (* Then use the Merlin type information for a slower check. *) + let* structures = + Document.Merlin.with_pipeline_exn ~log_info merlin (fun pipeline -> + let typer = Mpipeline.typer_result pipeline in + let typedtree = Mtyper.get_typedtree typer in + let pos = Mpipeline.get_lexing_pos pipeline pos in + Mbrowse.enclosing pos [ Mbrowse.of_typedtree typedtree ]) + in + (match Typed_hole.is_a_hole structures with + | false -> Fiber.return [] + | true -> + (* Finally ask Merlin for the actual constructions. *) + let command = Query_protocol.Construct (pos, Some `Local, Some 1) in + let+ res = Document.Merlin.dispatch ~log_info merlin command in + (match res with + | Ok (loc, constructions) -> + Core.List.map constructions ~f:(make_construct_action ~state ~doc loc) + | Error _ -> []))) +;; diff --git a/ocaml-lsp-server/src/action_construct.mli b/ocaml-lsp-server/src/action_construct.mli new file mode 100644 index 000000000..084885889 --- /dev/null +++ b/ocaml-lsp-server/src/action_construct.mli @@ -0,0 +1,11 @@ +open Import + +(** Produces a list of code actions based on Merlin-construct. Because the LSP doesn't + have a clean way of offering a sub-menu after the user selects construct, the solution + is to put all of the construct options directly into the code-action menu. *) +val get_construct_actions + : log_info:Lsp_timing_logger.t + -> State.t + -> Document.t + -> CodeActionParams.t + -> CodeAction.t list Fiber.t diff --git a/ocaml-lsp-server/src/code_actions/action_destruct.ml b/ocaml-lsp-server/src/action_destruct.ml similarity index 81% rename from ocaml-lsp-server/src/code_actions/action_destruct.ml rename to ocaml-lsp-server/src/action_destruct.ml index da7a13b12..33f65f0b2 100644 --- a/ocaml-lsp-server/src/code_actions/action_destruct.ml +++ b/ocaml-lsp-server/src/action_destruct.ml @@ -33,7 +33,7 @@ let code_action_of_case_analysis ~supportsJumpToNextHole doc uri (loc, newText) () ;; -let code_action (state : State.t) doc (params : CodeActionParams.t) = +let code_action ~log_info (state : State.t) doc (params : CodeActionParams.t) = let uri = params.textDocument.uri in match Document.kind doc with | `Other -> Fiber.return None @@ -44,18 +44,22 @@ let code_action (state : State.t) doc (params : CodeActionParams.t) = let finish = Position.logical params.range.end_ in Query_protocol.Case_analysis (start, finish) in - let* res = Document.Merlin.dispatch ~name:"destruct" merlin command in + let* res = Document.Merlin.dispatch ~log_info merlin command in (match res with | Ok (loc, newText) -> + let+ newText = + let+ formatted_text = + Ocamlformat_rpc.format_type state.ocamlformat_rpc ~typ:newText + in + match formatted_text with + | Ok formatted_text -> formatted_text + | Error _ -> newText + in let supportsJumpToNextHole = State.experimental_client_capabilities state |> Client.Experimental_capabilities.supportsJumpToNextHole in - let opt = - Some - (code_action_of_case_analysis ~supportsJumpToNextHole doc uri (loc, newText)) - in - Fiber.return opt + Some (code_action_of_case_analysis ~supportsJumpToNextHole doc uri (loc, newText)) | Error { exn = ( Merlin_analysis.Destruct.Wrong_parent _ diff --git a/ocaml-lsp-server/src/code_actions/action_destruct.mli b/ocaml-lsp-server/src/action_destruct.mli similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_destruct.mli rename to ocaml-lsp-server/src/action_destruct.mli diff --git a/ocaml-lsp-server/src/action_destruct_line.ml b/ocaml-lsp-server/src/action_destruct_line.ml new file mode 100644 index 000000000..785e8a447 --- /dev/null +++ b/ocaml-lsp-server/src/action_destruct_line.ml @@ -0,0 +1,310 @@ +open Import +open Fiber.O +open Core + +let action_kind = "destruct-line (enumerate cases, use existing match)" +let kind = CodeActionKind.Other action_kind + +(* TODO: All of the pre- and post-processing here is done by simple regexes and other + string manipulations. It would be nice if more of it could rely on the typed tree or + other analysis of the code provided by Merlin. *) + +type statement_kind = + | MatchLine (* [match ...] *) + | MatchWithLine (* [match ... with] *) + | CaseLine (* [|...->...] *) + | Hole (* [|..._...->...] AND the range indicates a query at the underscore. *) + | OffsetHole of int (* [| _ ->...] BUT the hole is here, not at the query location. *) + +type destructable_statement = + { code : string + ; kind : statement_kind + ; query_range : Range.t (* Range sent to Merlin based on our pre-processing. *) + ; reply_range : Range.t (* Where Merlin's reply will go. *) + } + +(** Extracts the line of [doc] that the query indicated by [range] starts on. *) +let get_line (doc : Document.t) (range : Range.t) = + let text = Document.text doc in + let start_line = range.start.line + 1 in + let source = Document.source doc in + let (`Offset pos) = Msource.get_offset source (`Logical (start_line, 0)) in + let (`Offset next) = Msource.get_offset source (`Logical (start_line + 1, 0)) in + let len = next - pos in + String.sub text ~pos ~len +;; + +(** Assumes [case_line] passes the check for a CaseLine, but hasn't had whitespace + removed. Checks that the cursor is before the arrow and the position before or after + the cursor has an underscore. *) +let is_hole (case_line : string) (cursor_pos : int) = + let arrow_pos = String.substr_index_exn case_line ~pattern:"->" in + if cursor_pos <= 0 || cursor_pos >= arrow_pos + then false (* We're only looking for '_' if the cursor is between "|" and "->". *) + else if Char.equal case_line.[cursor_pos] '_' + || Char.equal case_line.[cursor_pos - 1] '_' + then true + else false +;; + +(** Finds the index of a lhs underscore in [case_line], if any. *) +let find_hole (case_line : string) = + let start_of_lhs = 1 + String.substr_index_exn case_line ~pattern:"|" in + let end_of_lhs = String.substr_index_exn case_line ~pattern:"->" in + let lhs = + String.strip (String.sub case_line ~pos:start_of_lhs ~len:(end_of_lhs - start_of_lhs)) + in + if String.equal "_" lhs then String.substr_index case_line ~pattern:"_" else None +;; + +let get_statement_kind (code_line : string) (range : Range.t) = + let logical_line = String.strip code_line in + (* Line contains [match] and [with], and has at least one word in between. *) + let match_with_regex = ".*match[ \t]+[^ \t].*[ \t]with.*" in + (* Line contains [match] followed by at least one other word. *) + let match_regex = ".*match[ \t]+[^ \t]" in + (* Line starts with a pipe and contains an arrow. *) + let case_regex = "^\\|.*->.*" in + let regex = + Re2.Multiple.create_exn + [ match_with_regex, `MatchWithLine; match_regex, `MatchLine; case_regex, `CaseLine ] + in + match Re2.Multiple.matches regex logical_line with + | `MatchWithLine :: _ -> Some MatchWithLine + | `MatchLine :: _ -> Some MatchLine + | `CaseLine :: _ -> + if is_hole code_line range.start.character + then Some Hole + else ( + match find_hole code_line with + | None -> Some CaseLine + | Some offset -> Some (OffsetHole offset)) + | [] -> None +;; + +(** Given a line of the form [match x] or [match x with] or [| x -> y], create a query + range corresponding to [x]. *) +let get_query_range (code : string) (kind : statement_kind) (range : Range.t) : Range.t = + let start_char = + match kind with + | MatchLine | MatchWithLine -> 6 + String.substr_index_exn ~pattern:"match" code + | CaseLine -> 2 + String.substr_index_exn ~pattern:"|" code + | Hole -> range.start.character + | OffsetHole c -> c + in + let end_char = + match kind with + | MatchLine -> String.length code - 1 + | MatchWithLine -> String.substr_index_exn ~pattern:"with" code - 1 + | CaseLine -> String.substr_index_exn code ~pattern:"->" - 1 + | Hole -> range.end_.character + | OffsetHole c -> c + in + { start = { range.start with character = start_char } + ; end_ = { range.end_ with character = end_char } + } +;; + +(** Finds the portion of the text that will be overwritten by Merlin's reply. For a + MatchLine or a MatchWithLine, Merlin's reply will include "match" and "with", so to + avoid duplication, we want the existing "match" and (possibly) "with" to be included + in the range that gets replaced. *) +let get_reply_range (code : string) (kind : statement_kind) (query_range : Range.t) + : Range.t + = + let start_char = + match kind with + | CaseLine | Hole | OffsetHole _ -> query_range.start.character + | MatchLine | MatchWithLine -> String.substr_index_exn ~pattern:"match" code + in + let end_char = + match kind with + | MatchLine | CaseLine | Hole | OffsetHole _ -> query_range.end_.character + | MatchWithLine -> 4 + String.substr_index_exn ~pattern:"with" code + in + { start = { query_range.start with character = start_char } + ; end_ = { query_range.end_ with character = end_char } + } +;; + +(** Adjusts the location Merlin gave us to ensure the right text gets overwritten. *) +let adjust_reply_location ~(statement : destructable_statement) (loc : Loc.t) : Loc.t = + let start_offset = + statement.reply_range.start.character - statement.query_range.start.character + in + let end_offset = + statement.reply_range.end_.character - statement.query_range.end_.character + in + let loc_start = + { loc.loc_start with pos_cnum = loc.loc_start.pos_cnum + start_offset } + in + let loc_end = { loc.loc_end with pos_cnum = loc.loc_end.pos_cnum + end_offset } in + { loc with loc_start; loc_end } +;; + +(** Tries to find a statement we know how to handle on the line where the range starts. *) +let extract_statement (doc : Document.t) (ca_range : Range.t) + : destructable_statement option + = + if ca_range.start.line <> ca_range.end_.line + then None + else ( + let code = get_line doc ca_range in + match get_statement_kind code ca_range with + | None -> None + | Some kind -> + let query_range = get_query_range code kind ca_range in + let reply_range = get_reply_range code kind query_range in + Some { code; kind; query_range; reply_range }) +;; + +(** Strips " -> ... " off the rhs and " | " off the lhs of a case-line if present. *) +let strip_case_line line = + let line = String.strip line |> String.chop_prefix_if_exists ~prefix:"|" in + let line = + match String.substr_index line ~pattern:"->" with + | None -> line + | Some offset -> String.sub line ~pos:0 ~len:offset + in + String.strip line +;; + +(** [count_surrounding_parens "((( abc ())) (de) )"] returns [(3,1)]. *) +let count_surrounding_parens text = + let not_open _ c = Char.(c <> '(') in + let not_close _ c = Char.(c <> ')') in + let len = String.length text in + let num_opens = String.lfindi text ~f:not_open |> Option.value ~default:len in + let num_closes = + len - 1 - (String.rfindi text ~f:not_close |> Option.value ~default:(-1)) + in + num_opens, num_closes +;; + +let strip_matched_parens text = + let num_opens, num_closes = count_surrounding_parens text in + let num_matched = min num_opens num_closes in + String.sub text ~pos:num_matched ~len:(String.length text - (2 * num_matched)) +;; + +let remove_newlines text = + String.map text ~f:(function + | '\n' -> ' ' + | c -> c) +;; + +(** Combines match-case lines, stripping leading '(' characters, and keeping count of how + many more '(' have been removed than ')', in order to strip trailing ')' characters + only if the match matching '(' characters were already stripped. + + Gives an error if it strips too many '(' characters and can't match them. *) +let format_match_cases lines ~indent = + let extra_opens = ref 0 in + let extract_match_case l = + let l = strip_case_line l in + let num_opens, num_closes = count_surrounding_parens l in + let closes_to_strip = min (num_opens + !extra_opens) num_closes in + let l = + String.sub l ~pos:num_opens ~len:(String.length l - num_opens - closes_to_strip) + in + extra_opens := !extra_opens + num_opens - closes_to_strip; + l + in + let lines = + List.filter_map lines ~f:(fun l -> + let l = remove_newlines l in + match extract_match_case l with + | "" -> None + | l -> Some (indent ^ "| " ^ l ^ " -> _")) + in + match !extra_opens with + | 0 -> Ok ("\n" ^ String.concat lines ~sep:"\n") + | _ -> Error "Stripped too many open-parens." +;; + +(** Finds the "with" in the Merlin reply and splits after it. *) +let separate_match_line new_code = + let end_of_match = String.substr_index_exn new_code ~pattern:"with" in + let match_line = String.prefix new_code (end_of_match + 4) in + let rest = String.drop_prefix new_code (end_of_match + 4) in + match_line, rest +;; + +let format_merlin_reply ~(statement : destructable_statement) (new_code : string) = + let indent = String.take_while statement.code ~f:Char.is_whitespace in + match statement.kind with + | MatchLine | MatchWithLine -> + let new_code = strip_matched_parens new_code in + let match_line, rest = separate_match_line new_code in + let lines = String.split ~on:'|' rest in + (match format_match_cases lines ~indent with + | Ok case_lines -> match_line ^ case_lines + | Error _ -> new_code) + | CaseLine -> + (match format_match_cases (String.split new_code ~on:'|') ~indent with + | Ok case_line -> case_line + | Error _ -> new_code) + | Hole | OffsetHole _ -> + let lines = String.split ~on:'|' new_code in + (match List.hd lines, List.tl lines with + | None, _ | _, None -> new_code + | Some first_line, Some other_lines -> + let other_lines = + List.map other_lines ~f:(fun l -> + indent ^ "| " ^ strip_case_line (remove_newlines l)) + in + String.concat ~sep:" -> _\n" (String.strip first_line :: other_lines)) +;; + +let dispatch_destruct ~log_info (merlin : Document.Merlin.t) (range : Range.t) = + let command = + let start = Position.logical range.start in + let finish = Position.logical range.end_ in + Query_protocol.Case_analysis (start, finish) + in + Document.Merlin.dispatch ~log_info merlin command +;; + +let code_action + ~log_info + (state : State.t) + (doc : Document.t) + (params : CodeActionParams.t) + = + match Document.kind doc with + | `Other -> Fiber.return None + | `Merlin merlin -> + (match Document.Merlin.kind merlin with + | Intf -> Fiber.return None + | Impl -> + (match extract_statement doc params.range with + | None -> Fiber.return None + | Some statement -> + let+ res = dispatch_destruct ~log_info merlin statement.query_range in + (match res with + | Ok (loc, newText) -> + let loc = adjust_reply_location ~statement loc in + let newText = format_merlin_reply ~statement newText in + let range = Range.of_loc loc in + let edit = Document.edit doc [ { range; newText } ] in + let command = Typed_hole.next_hole_cmd ~state ~edit:{ range; newText } in + let title = String.capitalize action_kind in + let kind = CodeActionKind.Other action_kind in + let action = + CodeAction.create ~title ~kind ~edit ?command ~isPreferred:false () + in + Some action + | Error + { exn = + ( Merlin_analysis.Destruct.Wrong_parent _ + | Query_commands.No_nodes + | Merlin_analysis.Destruct.Not_allowed _ + | Merlin_analysis.Destruct.Useless_refine + | Merlin_analysis.Destruct.Ill_typed + | Merlin_analysis.Destruct.Nothing_to_do ) + ; backtrace = _ + } -> None + | Error exn -> Exn_with_backtrace.reraise exn))) +;; + +let t state = { Code_action.kind; run = `Non_batchable (code_action state) } diff --git a/ocaml-lsp-server/src/action_destruct_line.mli b/ocaml-lsp-server/src/action_destruct_line.mli new file mode 100644 index 000000000..4b5928adb --- /dev/null +++ b/ocaml-lsp-server/src/action_destruct_line.mli @@ -0,0 +1,53 @@ +open Import + +(** This code action allows the user to invoke Merlin-destruct to enumerate cases from + various lines of a partial match statement. If the line is of any of these forms: + [match x] [match x with] [| x -> y] then the pre-processing will extract [x] and + invoke Merlin-destruct on it. Some post-processing is applied to Merlin's response to + make it more useful for adding subsequent code: extraneous tokens are stripped and + cases are split across lines. For example, supposing [x] is a [bool], then the line + [match x with] expands to [match x with | false -> _ | true -> _]. The same expansion + results from invoking the code action on the second line of + [match x with | false -> _]. + + In addition, the code action detects a sub-case of the [| x -> y] form, where the + cursor is on an underscore within [x]. This often corresponds to a wildcard pattern + where a destruct action is useful and extra post-processing helps. The follwing + expansions result from repeated applications of [destruct-line]: + {v + let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = + match xs, ys + v} + (code action invoked anywhere on the match line) + {v + let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = + match (xs, ys) with + | (_, _) -> _ + v} + (CA invoked on the first underscore) + {v + let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = + match (xs, ys) with + | ([], _) -> _ + | (_::_, _) -> _ + v} + (CA invoked on the first underscore) + {v + let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = + match (xs, ys) with + | ([], []) -> _ + | ([], _::_) -> _ + | (_::_, _) -> _ + v} + (CA invoked on the second-to-last underscore) + {v + let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = + match (xs, ys) with + | ([], []) -> _ + | ([], _::_) -> _ + | (_::_, []) -> _ + | (_::_, _::_) -> _ + v} *) + +val kind : CodeActionKind.t +val t : State.t -> Code_action.t diff --git a/ocaml-lsp-server/src/code_actions/action_extract.ml b/ocaml-lsp-server/src/action_extract.ml similarity index 92% rename from ocaml-lsp-server/src/code_actions/action_extract.ml rename to ocaml-lsp-server/src/action_extract.ml index 7946c50f4..74360306e 100644 --- a/ocaml-lsp-server/src/code_actions/action_extract.ml +++ b/ocaml-lsp-server/src/action_extract.ml @@ -1,7 +1,6 @@ open Import open Option.O module H = Ocaml_parsing.Ast_helper -module Typedtree_utils = Merlin_analysis.Typedtree_utils let range_contains_loc range loc = match Range.of_loc_opt loc with @@ -69,19 +68,18 @@ let tightest_enclosing_binder_position typedtree range = I.default_iterator.expr iter expr; match expr.exp_desc with | Texp_let (_, _, body) - | Texp_while (_, body) - | Texp_for (_, _, _, _, _, body) + | Texp_while { wh_body = body; _ } + | Texp_for { for_body = body; _ } | Texp_letmodule (_, _, _, _, body) | Texp_letexception (_, body) | Texp_open (_, body) -> found_if_expr_contains body | Texp_letop { body; _ } -> found_if_case_contains [ body ] - | Texp_function (_, Tfunction_cases { cases; _ }) -> found_if_case_contains cases - | Texp_match _ -> - let m = Typedtree_utils.texp_match_of_expr expr |> Option.value_exn in - found_if_case_contains m.computation_cases - | Texp_try _ -> - let t = Typedtree_utils.texp_try_of_expr expr |> Option.value_exn in - found_if_case_contains t.value_cases + | Texp_function { body; _ } -> + (match body with + | Tfunction_body expr -> found_if_expr_contains expr + | Tfunction_cases { fc_cases = cases; _ } -> found_if_case_contains cases) + | Texp_match (_, _, cases, _) -> found_if_case_contains cases + | Texp_try (_, cases) -> found_if_case_contains cases | _ -> ()) in let structure_item_iter (iter : I.iterator) (item : Typedtree.structure_item) = @@ -116,7 +114,7 @@ let free (expr : Typedtree.expression) = let idents = ref [] in let expr_iter (iter : I.iterator) (expr : Typedtree.expression) = match expr.exp_desc with - | Texp_ident (path, { txt = ident; _ }, _) -> idents := (ident, path) :: !idents + | Texp_ident (path, { txt = ident; _ }, _, _, _) -> idents := (ident, path) :: !idents | _ -> I.default_iterator.expr iter expr; (* if a variable was bound but is no longer, it must be associated with a diff --git a/ocaml-lsp-server/src/code_actions/action_extract.mli b/ocaml-lsp-server/src/action_extract.mli similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_extract.mli rename to ocaml-lsp-server/src/action_extract.mli diff --git a/ocaml-lsp-server/src/code_actions/action_inferred_intf.ml b/ocaml-lsp-server/src/action_inferred_intf.ml similarity index 90% rename from ocaml-lsp-server/src/code_actions/action_inferred_intf.ml rename to ocaml-lsp-server/src/action_inferred_intf.ml index 2c41b4ecc..b1dc83af9 100644 --- a/ocaml-lsp-server/src/code_actions/action_inferred_intf.ml +++ b/ocaml-lsp-server/src/action_inferred_intf.ml @@ -25,12 +25,12 @@ let code_action_of_intf doc intf range = () ;; -let code_action (state : State.t) doc (params : CodeActionParams.t) = +let code_action ~log_info (state : State.t) doc (params : CodeActionParams.t) = match Document.kind doc with | `Other -> Fiber.return None | `Merlin m when Document.Merlin.kind m = Impl -> Fiber.return None | `Merlin _ -> - let* intf = Inference.infer_intf state doc in + let* intf = Inference.infer_intf ~log_info state doc in (match intf with | None -> Fiber.return None | Some intf -> diff --git a/ocaml-lsp-server/src/code_actions/action_inferred_intf.mli b/ocaml-lsp-server/src/action_inferred_intf.mli similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_inferred_intf.mli rename to ocaml-lsp-server/src/action_inferred_intf.mli diff --git a/ocaml-lsp-server/src/code_actions/action_inline.ml b/ocaml-lsp-server/src/action_inline.ml similarity index 81% rename from ocaml-lsp-server/src/code_actions/action_inline.ml rename to ocaml-lsp-server/src/action_inline.ml index 629c12b14..cf6b93145 100644 --- a/ocaml-lsp-server/src/code_actions/action_inline.ml +++ b/ocaml-lsp-server/src/action_inline.ml @@ -19,7 +19,7 @@ let check_shadowing (inlined_expr : Typedtree.expression) new_env = let exception Env_mismatch of (Longident.t * [ `Unbound | `Shadowed ]) in let expr_iter (iter : I.iterator) (expr : Typedtree.expression) = match expr.exp_desc with - | Texp_ident (path, { txt = ident; _ }, _) -> + | Texp_ident (path, { txt = ident; _ }, _, _, _) -> let in_orig_env = find_path_by_name ident orig_env |> Option.map ~f:(Path.same path) @@ -66,7 +66,7 @@ let find_inline_task typedtree pos = match expr.exp_desc with | Texp_let ( Nonrecursive - , [ { vb_pat = { pat_desc = Tpat_var (inlined_var, { loc; _ }, _); _ } + , [ { vb_pat = { pat_desc = Tpat_var (inlined_var, { loc; _ }, _, _, _); _ } ; vb_expr = inlined_expr ; _ } @@ -81,7 +81,7 @@ let find_inline_task typedtree pos = match item.str_desc with | Tstr_value ( Nonrecursive - , [ { vb_pat = { pat_desc = Tpat_var (inlined_var, { loc; _ }, _); _ } + , [ { vb_pat = { pat_desc = Tpat_var (inlined_var, { loc; _ }, _, _, _); _ } ; vb_expr = inlined_expr ; _ } @@ -99,8 +99,8 @@ let find_inline_task typedtree pos = | Found task -> Some task ;; -(** [find_parsetree_loc pl loc] finds an expression node in the parsetree with - location [loc] *) +(** [find_parsetree_loc pl loc] finds an expression node in the parsetree with location + [loc] *) let find_parsetree_loc pipeline loc = let exception Found of Parsetree.expression in try @@ -122,8 +122,7 @@ let find_parsetree_loc_exn pipeline loc = Option.value_exn (find_parsetree_loc pipeline loc) ;; -(** [strip_attribute name e] removes all instances of the attribute called - [name] in [e]. *) +(** [strip_attribute name e] removes all instances of the attribute called [name] in [e]. *) let strip_attribute attr_name expr = let module M = Ocaml_parsing.Ast_mapper in let expr_map (map : M.mapper) expr = @@ -137,8 +136,8 @@ let strip_attribute attr_name expr = mapper.expr mapper expr ;; -(** Mapping from [Location.t] to [Path.t]. Computed from the typedtree. Useful - for determining whether two parsetree identifiers refer to the same path. *) +(** Mapping from [Location.t] to [Path.t]. Computed from the typedtree. Useful for + determining whether two parsetree identifiers refer to the same path. *) module Paths : sig type t @@ -154,13 +153,13 @@ end = struct let paths = ref Loc.Map.empty in let expr_iter (iter : I.iterator) (expr : Typedtree.expression) = match expr.exp_desc with - | Texp_ident (path, { loc; _ }, _) -> paths := Loc.Map.set !paths loc path + | Texp_ident (path, { loc; _ }, _, _, _) -> paths := Loc.Map.set !paths loc path | _ -> I.default_iterator.expr iter expr in let pat_iter (type k) (iter : I.iterator) (pat : k Typedtree.general_pattern) = match pat.pat_desc with - | Tpat_var (id, { loc; _ }, _) -> paths := Loc.Map.set !paths loc (Pident id) - | Tpat_alias (pat, id, { loc; _ }, _) -> + | Tpat_var (id, { loc; _ }, _, _, _) -> paths := Loc.Map.set !paths loc (Pident id) + | Tpat_alias (pat, id, { loc; _ }, _, _, _, _) -> paths := Loc.Map.set !paths loc (Pident id); I.default_iterator.pat iter pat | _ -> I.default_iterator.pat iter pat @@ -188,12 +187,12 @@ let subst same subst_expr subst_id body = mapper.expr mapper body ;; -(** Rough check for expressions that can be duplicated without duplicating any - side effects (or introducing a sigificant performance difference). *) +(** Rough check for expressions that can be duplicated without duplicating any side + effects (or introducing a sigificant performance difference). *) let rec is_pure (expr : Parsetree.expression) = match expr.pexp_desc with | Pexp_ident _ | Pexp_constant _ | Pexp_unreachable -> true - | Pexp_field (e, _) | Pexp_constraint (e, _) -> is_pure e + | Pexp_field (e, _) | Pexp_constraint (e, _, _) -> is_pure e | _ -> false ;; @@ -210,16 +209,31 @@ let same_path paths (id : _ H.with_loc) (id' : _ H.with_loc) = let beta_reduce (paths : Paths.t) (app : Parsetree.expression) = let rec beta_reduce_arg body (pat : Parsetree.pattern) arg = - let with_let () = H.Exp.let_ Nonrecursive [ H.Vb.mk pat arg ] body in + let with_let () = H.Exp.let_ Immutable Nonrecursive [ H.Vb.mk pat arg ] body in let with_subst param = subst (same_path paths) arg param body in match pat.ppat_desc with | Ppat_any | Ppat_construct ({ txt = Lident "()"; _ }, _) -> if is_pure arg then body else with_let () - | Ppat_var param | Ppat_constraint ({ ppat_desc = Ppat_var param; _ }, _) -> + | Ppat_var param | Ppat_constraint ({ ppat_desc = Ppat_var param; _ }, _, _) -> if is_pure arg then with_subst param else with_let () - | Ppat_tuple pats -> + | Ppat_tuple (pats, Closed) -> + (* TODO: this case should use Merlin_typing.Typecore.reorder_pat to handle labeled + tuples *) (match arg.pexp_desc with - | Pexp_tuple args -> List.fold_left2 ~f:beta_reduce_arg ~init:body pats args + | Pexp_tuple args -> + (* Match up elements based on their order. If there are any labels, this means + that we cannot rely on their order, so we bail out. *) + let beta_reduce_element body (pat_label, pat) (arg_label, arg) = + match body, pat_label, arg_label with + | Some body, None, None -> Some (beta_reduce_arg body pat arg) + | None, _, _ | _, Some _, _ | _, _, Some _ -> None + in + let result_if_no_labels = + List.fold_left2 ~f:beta_reduce_element ~init:(Some body) pats args + in + (match result_if_no_labels with + | Some result -> result + | None -> with_let ()) | _ -> with_let ()) | _ -> with_let () in @@ -231,7 +245,7 @@ let beta_reduce (paths : Paths.t) (app : Parsetree.expression) = |> Option.List.all in match app.pexp_desc with - | Pexp_apply ({ pexp_desc = Pexp_function (params, None, Pfunction_body body); _ }, args) + | Pexp_apply ({ pexp_desc = Pexp_function (params, _, Pfunction_body body); _ }, args) when List.length params = List.length args && all_unlabeled_params params -> (match extract_param_pats params with | Some pats -> @@ -251,10 +265,9 @@ let inlined_text pipeline task = Format.asprintf "(%a)" Pprintast.expression expr ;; -(** [inline_edits pipeline task] returns a list of inlining edits and an - optional error value. An error will be generated if any of the potential - inlinings is not allowed due to shadowing. The successful edits will still - be returned *) +(** [inline_edits pipeline task] returns a list of inlining edits and an optional error + value. An error will be generated if any of the potential inlinings is not allowed due + to shadowing. The successful edits will still be returned *) let inline_edits pipeline task = let module I = Ocaml_typing.Tast_iterator in let open Option.O in @@ -272,14 +285,14 @@ let inline_edits pipeline task = in (* inlining into an argument context has some special cases *) let arg_iter - env - (iter : I.iterator) - (label : Asttypes.arg_label) - (m_arg_expr : Typedtree.expression option) + env + (iter : I.iterator) + (label : Typedtree.arg_label) + (m_arg_expr : Typedtree.expression option) = match label, m_arg_expr with (* handle the labeled argument shorthand `f ~x` when inlining `x` *) - | Labelled name, Some { exp_desc = Texp_ident (Pident id, { loc; _ }, _); _ } + | Labelled name, Some { exp_desc = Texp_ident (Pident id, { loc; _ }, _, _, _); _ } (* inlining is allowed for optional arguments that are being passed a Some parameter, i.e. `x` may be inlined in `let x = 1 in (fun ?(x = 0) -> x) ~x` *) @@ -288,7 +301,10 @@ let inline_edits pipeline task = { exp_desc = (* construct is part of desugaring, assumed to be Some *) Texp_construct - (_, _, [ { exp_desc = Texp_ident (Pident id, { loc; _ }, _); _ } ]) + ( _ + , _ + , [ { exp_desc = Texp_ident (Pident id, { loc; _ }, _, _, _); _ } ] + , _ ) ; _ } ) when Ident.same task.inlined_var id && not_shadowed env -> @@ -300,6 +316,9 @@ let inline_edits pipeline task = optional parameter i.e. `x` may _not_ be inlined in `let x = Some 1 in (fun ?(x = 0) -> x) ?x` *) | Optional _, Some _ -> () + (* inlining is not allowed for source position arguments because the source + location would not be well defined *) + | Position _, Some _ -> () | _, _ -> Option.iter m_arg_expr ~f:(iter.expr iter) in let paths = Paths.of_typedtree task.inlined_expr in @@ -308,7 +327,7 @@ let inline_edits pipeline task = match expr.exp_desc with (* when inlining into an application context, attempt to beta reduce the result *) - | Texp_apply ({ exp_desc = Texp_ident (Pident id, _, _); _ }, _) + | Texp_apply ({ exp_desc = Texp_ident (Pident id, _, _, _, _); _ }, _, _, _, _) when Ident.same task.inlined_var id && not_shadowed expr.exp_env -> let reduced_pexpr = let app_pexpr = find_parsetree_loc_exn pipeline expr.exp_loc in @@ -322,10 +341,16 @@ let inline_edits pipeline task = @@ strip_attribute "merlin.loc" reduced_pexpr in insert_edit newText expr.exp_loc - | Texp_apply (func, args) -> + | Texp_apply (func, args, _, _, _) -> iter.expr iter func; - List.iter args ~f:(fun (l, e) -> arg_iter expr.exp_env iter l e) - | Texp_ident (Pident id, { loc; _ }, _) + List.iter args ~f:(fun (l, e) -> + let e = + match e with + | Typedtree.Arg (e, _sort) -> Some e + | Omitted _ -> None + in + arg_iter expr.exp_env iter l e) + | Texp_ident (Pident id, { loc; _ }, _, _, _) when Ident.same task.inlined_var id && not_shadowed expr.exp_env -> insert_edit newText loc | _ -> I.default_iterator.expr iter expr diff --git a/ocaml-lsp-server/src/code_actions/action_inline.mli b/ocaml-lsp-server/src/action_inline.mli similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_inline.mli rename to ocaml-lsp-server/src/action_inline.mli diff --git a/ocaml-lsp-server/src/code_actions/action_mark_remove_unused.ml b/ocaml-lsp-server/src/action_mark_remove_unused.ml similarity index 95% rename from ocaml-lsp-server/src/code_actions/action_mark_remove_unused.ml rename to ocaml-lsp-server/src/action_mark_remove_unused.ml index c3e070856..ad6ba28da 100644 --- a/ocaml-lsp-server/src/code_actions/action_mark_remove_unused.ml +++ b/ocaml-lsp-server/src/action_mark_remove_unused.ml @@ -73,12 +73,13 @@ let rec mark_value_unused_edit name contexts = pats ~f: (function - | { loc = field_loc; _ }, _, { pat_desc = Tpat_var (ident, _, _); pat_loc; _ } + | ( { loc = field_loc; _ } + , _ + , { pat_desc = Tpat_var (ident, _, _, _, _); pat_loc; _ } ) when Ident.name ident = name -> (* Special case for record shorthand *) - if - field_loc.loc_start = pat_loc.loc_start - && field_loc.loc_end = pat_loc.loc_end + if field_loc.loc_start = pat_loc.loc_start + && field_loc.loc_end = pat_loc.loc_end then let+ end_pos = Position.of_lexical_position pat_loc.loc_end in TextEdit. @@ -96,7 +97,7 @@ let rec mark_value_unused_edit name contexts = (match m_field_edit with | Some e -> Some e | None -> mark_value_unused_edit name cs) - | Pattern { pat_desc = Tpat_var (ident, _, _); pat_loc = loc; _ } :: _ -> + | Pattern { pat_desc = Tpat_var (ident, _, _, _, _); pat_loc = loc; _ } :: _ -> if Ident.name ident = name then let+ start = Position.of_lexical_position loc.loc_start in @@ -131,7 +132,8 @@ let enclosing_value_binding_range name = { exp_desc = Texp_let ( _ - , [ { vb_pat = { pat_desc = Tpat_var (_, { txt = name'; _ }, _); _ }; _ } ] + , [ { vb_pat = { pat_desc = Tpat_var (_, { txt = name'; _ }, _, _, _); _ }; _ } + ] , { exp_loc = { loc_start = let_end; _ }; _ } ) ; exp_loc = { loc_start = let_start; _ } ; _ @@ -145,10 +147,10 @@ let enclosing_value_binding_range name = (* Create a code action that removes [range] and refers to [diagnostic]. *) let code_action_remove_range - ?(title = "Remove unused") - doc - (diagnostic : Diagnostic.t) - range + ?(title = "Remove unused") + doc + (diagnostic : Diagnostic.t) + range = let edit = Document.edit doc [ { range; newText = "" } ] in CodeAction.create @@ -169,8 +171,8 @@ let code_action_remove_value pipeline doc pos (diagnostic : Diagnostic.t) = |> Option.map ~f:(fun range -> code_action_remove_range doc diagnostic range) ;; -(** [create_mark_action ~title doc pos d] creates a code action that resolves - the diagnostic [d] by inserting an underscore at [pos] in [doc]. *) +(** [create_mark_action ~title doc pos d] creates a code action that resolves the + diagnostic [d] by inserting an underscore at [pos] in [doc]. *) let create_mark_action ~title doc pos d = let edit = Document.edit doc [ { range = Range.create ~start:pos ~end_:pos; newText = "_" } ] diff --git a/ocaml-lsp-server/src/code_actions/action_mark_remove_unused.mli b/ocaml-lsp-server/src/action_mark_remove_unused.mli similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_mark_remove_unused.mli rename to ocaml-lsp-server/src/action_mark_remove_unused.mli diff --git a/ocaml-lsp-server/src/code_actions/action_open_related.ml b/ocaml-lsp-server/src/action_open_related.ml similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_open_related.ml rename to ocaml-lsp-server/src/action_open_related.ml diff --git a/ocaml-lsp-server/src/code_actions/action_open_related.mli b/ocaml-lsp-server/src/action_open_related.mli similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_open_related.mli rename to ocaml-lsp-server/src/action_open_related.mli diff --git a/ocaml-lsp-server/src/code_actions/action_refactor_open.ml b/ocaml-lsp-server/src/action_refactor_open.ml similarity index 89% rename from ocaml-lsp-server/src/code_actions/action_refactor_open.ml rename to ocaml-lsp-server/src/action_refactor_open.ml index 844a74f01..ffb1aefe7 100644 --- a/ocaml-lsp-server/src/code_actions/action_refactor_open.ml +++ b/ocaml-lsp-server/src/action_refactor_open.ml @@ -1,11 +1,11 @@ open Import let code_action - (mode : [ `Qualify | `Unqualify ]) - (action_kind : string) - pipeline - _ - (params : CodeActionParams.t) + (mode : [ `Qualify | `Unqualify ]) + (action_kind : string) + pipeline + _ + (params : CodeActionParams.t) = let res = let command = diff --git a/ocaml-lsp-server/src/code_actions/action_refactor_open.mli b/ocaml-lsp-server/src/action_refactor_open.mli similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_refactor_open.mli rename to ocaml-lsp-server/src/action_refactor_open.mli diff --git a/ocaml-lsp-server/src/code_actions/action_remove_type_annotation.ml b/ocaml-lsp-server/src/action_remove_type_annotation.ml similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_remove_type_annotation.ml rename to ocaml-lsp-server/src/action_remove_type_annotation.ml diff --git a/ocaml-lsp-server/src/code_actions/action_remove_type_annotation.mli b/ocaml-lsp-server/src/action_remove_type_annotation.mli similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_remove_type_annotation.mli rename to ocaml-lsp-server/src/action_remove_type_annotation.mli diff --git a/ocaml-lsp-server/src/code_actions/action_type_annotate.ml b/ocaml-lsp-server/src/action_type_annotate.ml similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_type_annotate.ml rename to ocaml-lsp-server/src/action_type_annotate.ml diff --git a/ocaml-lsp-server/src/code_actions/action_type_annotate.mli b/ocaml-lsp-server/src/action_type_annotate.mli similarity index 100% rename from ocaml-lsp-server/src/code_actions/action_type_annotate.mli rename to ocaml-lsp-server/src/action_type_annotate.mli diff --git a/ocaml-lsp-server/src/code_actions/action_update_signature.ml b/ocaml-lsp-server/src/action_update_signature.ml similarity index 87% rename from ocaml-lsp-server/src/code_actions/action_update_signature.ml rename to ocaml-lsp-server/src/action_update_signature.ml index 21c696277..9082b36ec 100644 --- a/ocaml-lsp-server/src/code_actions/action_update_signature.ml +++ b/ocaml-lsp-server/src/action_update_signature.ml @@ -25,13 +25,13 @@ let code_action_of_intf doc text_edits = () ;; -let code_action (state : State.t) doc (params : CodeActionParams.t) = +let code_action ~log_info (state : State.t) doc (params : CodeActionParams.t) = match Document.kind doc with | `Other -> Fiber.return None | `Merlin m when Document.Merlin.kind m = Impl -> Fiber.return None | `Merlin intf_merlin -> let* text_edits = - Inference.update_signatures ~state ~doc ~range:params.range ~intf_merlin + Inference.update_signatures ~log_info ~state ~doc ~range:params.range ~intf_merlin in (match text_edits with | [] -> Fiber.return None diff --git a/ocaml-lsp-server/src/bin.ml b/ocaml-lsp-server/src/bin.ml index 37385d737..922e66ff1 100644 --- a/ocaml-lsp-server/src/bin.ml +++ b/ocaml-lsp-server/src/bin.ml @@ -5,4 +5,4 @@ let _PATH = lazy (Bin.parse_path (Option.value ~default:"" (Unix_env.get Unix_env.initial "PATH"))) ;; -let which x = Bin.which ~path:(Lazy.force _PATH) x |> Option.map ~f:Stdune.Path.to_string +let which = Bin.which ~path:(Lazy.force _PATH) diff --git a/ocaml-lsp-server/src/bin.mli b/ocaml-lsp-server/src/bin.mli index 492a447c7..369253827 100644 --- a/ocaml-lsp-server/src/bin.mli +++ b/ocaml-lsp-server/src/bin.mli @@ -1 +1,3 @@ -val which : string -> string option +open Import + +val which : string -> Fpath.t option diff --git a/ocaml-lsp-server/src/call_hierarchy.ml b/ocaml-lsp-server/src/call_hierarchy.ml new file mode 100644 index 000000000..0aa55c9b6 --- /dev/null +++ b/ocaml-lsp-server/src/call_hierarchy.ml @@ -0,0 +1,257 @@ +open Import + +module Fiber_option = struct + let bind t ~f = + Fiber.bind t ~f:(function + | None -> Fiber.return None + | Some x -> f x) + ;; + + module Let_syntax = struct + module Let_syntax = struct + let bind = bind + end + end +end + +let module_path_iter module_path_ref is_at_cursor = + let module_binding (self : Ast_iterator.iterator) (mb : Parsetree.module_binding) = + if is_at_cursor mb.pmb_loc + then ( + (match mb.pmb_name with + | { txt = Some name; _ } -> module_path_ref := name :: !module_path_ref + | _ -> ()); + Ast_iterator.default_iterator.module_binding self mb) + in + module_binding +;; + +let find_parent_function_of ~position parsetree = + (* TODO: This is not finding top level definitions that deconstruct values like + [let { foo } = some_fn ();], or [let () = command ... ;;] and more. *) + let is_at_cursor = Util.is_at_cursor position in + let last_fn = ref None in + let module_path = ref [] in + let value_binding (self : Ast_iterator.iterator) (vb : Parsetree.value_binding) = + if is_at_cursor vb.pvb_expr.pexp_loc + then ( + (match vb.pvb_pat.ppat_desc, vb.pvb_expr.pexp_desc with + (* E.g. [let foo a = a + 1], [let foo = fun a -> a + 1]*) + | Ppat_var fn_name, Pexp_function _ + (* E.g. [let foo a : int = a + 1] *) + | Ppat_constraint ({ ppat_desc = Ppat_var fn_name; _ }, _, _), Pexp_function _ + (* E.g. [let foo : type t. t -> int = fun x -> x + 1]*) + | ( Ppat_constraint ({ ppat_desc = Ppat_var fn_name; _ }, _, _) + , Pexp_newtype + ( _ + , _ + , { pexp_desc = Pexp_constraint ({ pexp_desc = Pexp_function _; _ }, _, _) + ; _ + } ) ) -> last_fn := Some fn_name + (* The following are only relevant for when [last_fn] is [None] this allows top + level call resolving e.g. [let () = main () ;;]*) + | Ppat_var name, _ when Option.is_none !last_fn -> last_fn := Some name + (* TODO: Add cases for deconstructed tuples, records, array and other top level + value bindings. *) + | _ -> ()); + Ast_iterator.default_iterator.value_binding self vb) + in + let module_binding = module_path_iter module_path is_at_cursor in + let iterator = { Ast_iterator.default_iterator with value_binding; module_binding } in + let () = + match parsetree with + | `Interface signature -> iterator.signature iterator signature + | `Implementation structure -> iterator.structure iterator structure + in + let%map.Option last_fn = !last_fn in + last_fn, List.rev !module_path +;; + +module Function_type = struct + type t = + | Not_a_function_or_identifier + | Maybe_fn_call_or_reference of Longident.t Asttypes.loc + | Maybe_fn_alias of string Asttypes.loc * Longident.t Asttypes.loc + | Fn_definition of string Asttypes.loc +end + +let function_type_at ~position parsetree = + let is_at_cursor = Util.is_at_cursor position in + let ret = ref Function_type.Not_a_function_or_identifier in + let module_path = ref [] in + let module_binding = module_path_iter module_path is_at_cursor in + let value_binding (self : Ast_iterator.iterator) (vb : Parsetree.value_binding) = + if is_at_cursor vb.pvb_loc + then ( + (match vb.pvb_pat.ppat_desc, vb.pvb_expr.pexp_desc with + | Ppat_var fn_name, Pexp_function _ when is_at_cursor fn_name.loc -> + ret := Fn_definition fn_name + | Ppat_constraint ({ ppat_desc = Ppat_var fn_name; _ }, _, _), _ + when is_at_cursor fn_name.loc -> ret := Fn_definition fn_name + | Ppat_var fn_name, Pexp_ident id when is_at_cursor fn_name.loc -> + ret := Maybe_fn_alias (fn_name, id) + | _ -> ()); + Ast_iterator.default_iterator.value_binding self vb) + in + let expr (self : Ast_iterator.iterator) (expr : Parsetree.expression) = + if is_at_cursor expr.pexp_loc + then ( + match expr.pexp_desc with + | Pexp_ident id -> ret := Maybe_fn_call_or_reference id + | _ -> ()); + Ast_iterator.default_iterator.expr self expr + in + let iterator = + { Ast_iterator.default_iterator with value_binding; expr; module_binding } + in + let () = + match parsetree with + | `Interface signature -> iterator.signature iterator signature + | `Implementation structure -> iterator.structure iterator structure + in + !ret, List.rev !module_path +;; + +let detail_str ~uri ~(state : State.t) = + let workspace_root = + (match state.init with + | Initialized { params = { rootUri; _ }; _ } -> + rootUri |> Option.map ~f:(fun p -> Uri.to_string p ^ "/") + | Uninitialized -> None) + |> Option.value ~default:(Uri.of_path "/" |> Uri.to_string) + in + String.chop_prefix_if_exists (Uri.to_string uri) ~prefix:workspace_root +;; + +let get_merlin_doc (state : State.t) uri = + let open Fiber.O in + let%bind.Fiber_option doc = + match Document_store.get_opt state.store uri with + | Some doc -> Fiber.return (Some doc) + | None -> + let%bind.Fiber_option doc = Util.open_document_from_file state uri in + let+ () = Document_store.open_document state.store doc in + Some doc + in + match Document.kind doc with + | `Other -> Fiber.return None + | `Merlin merlin -> Some merlin |> Fiber.return +;; + +let get_parsetree merlin_doc ~log_info = + Document.Merlin.with_pipeline_exn ~log_info merlin_doc (fun pipeline -> + Mpipeline.reader_parsetree pipeline) +;; + +let handle_prepare ~log_info (server : State.t Server.t) params = + let open Fiber.O in + let state = Server.state server in + let { CallHierarchyPrepareParams.textDocument = { uri }; position; _ } = params in + let first_alias = Core.Set_once.create () in + let rec get_prepare_item ~position ~uri = + let%bind.Fiber_option merlin_doc = get_merlin_doc state uri in + let* parsetree = get_parsetree merlin_doc ~log_info in + let resolve_definition (rhs : Longident.t Asttypes.loc) = + (* Important to use loc_end for the position, e.g. for [Foo.foo] we want to go to + [foo] not [Foo] *) + let position = Position.of_lexical_position rhs.loc.loc_end in + (* Definition is None whenever the cursor is on an identifier that is not a + function. Then we also don't want to to call hierachy, so fine to bind here. *) + let%bind.Fiber_option (`Location locs) = + Option.value_map position ~default:(Fiber.return None) ~f:(fun position -> + Definition_query.run ~log_info `Definition state uri position) + in + (* Definition should only return exactly one location. *) + let%bind.Fiber_option { range = { start; _ }; uri } = + List.hd locs |> Fiber.return + in + get_prepare_item ~position:start ~uri + in + match function_type_at ~position parsetree with + | Not_a_function_or_identifier, _ -> Fiber.return None + | Maybe_fn_call_or_reference rhs, _ -> resolve_definition rhs + | Maybe_fn_alias (lhs, rhs), module_path -> + Core.Set_once.set_if_none first_alias (uri, lhs, module_path); + resolve_definition rhs + | Fn_definition id, module_path -> + let item = + let uri, { Loc.txt; loc }, module_path = + Base.Option.value (Core.Set_once.get first_alias) ~default:(uri, id, module_path) + in + let name = String.concat (module_path @ [ txt ]) ~sep:"." in + let range = Range.of_loc loc in + CallHierarchyItem.create + ~detail:(detail_str ~state ~uri) + ~kind:SymbolKind.Function + ~name + ~range + ~selectionRange:range + ~uri + () + in + Some [ item ] |> Fiber.return + in + get_prepare_item ~position ~uri +;; + +(** Batched mapping for [Fiber.t], would be better if we had some sort of job queue, but + too much effort right now, and this should be good enough for now. *) +let batched_parallel fibers ~f ~batch_size = + let grouped = Base.List.chunks_of fibers ~length:batch_size in + Fiber.sequential_map grouped ~f:(Fiber.parallel_map ~f) |> Fiber.map ~f:List.concat +;; + +let handle_incoming ~log_info (server : State.t Server.t) params = + let open Fiber.O in + let state = Server.state server in + let { CallHierarchyIncomingCallsParams.item; _ } = params in + let { CallHierarchyItem.uri; range; _ } = item in + let%bind.Fiber_option merlin_doc = get_merlin_doc state uri in + let* occurrences, _synced = + Document.Merlin.dispatch_exn + ~log_info + merlin_doc + (Occurrences (`Ident_at (Position.logical range.end_), `Project)) + in + List.map occurrences ~f:(fun { loc; is_stale = _ } -> loc.loc_start.pos_fname, loc) + |> Base.List.Assoc.sort_and_group ~compare:Base.String.compare + |> batched_parallel ~batch_size:40 ~f:(fun (fn_name, locs) -> + (* Using Map to only open one doc and create one parsetree per file name. *) + let uri = DocumentUri.of_path fn_name in + let%bind.Fiber_option merlin_doc = get_merlin_doc state uri in + let+ parsetree = get_parsetree merlin_doc ~log_info in + List.filter_map locs ~f:(fun loc -> + let range = Range.of_loc loc in + let%map.Option { txt; loc }, module_path = + find_parent_function_of ~position:range.start parsetree + in + let name = String.concat (module_path @ [ txt ]) ~sep:"." in + loc, (name, range)) + |> Base.List.Assoc.sort_and_group ~compare:Loc.compare + |> List.map ~f:(fun (loc, ranges) -> + let name, _ = List.hd_exn ranges in + (* by construction every loc has at least one range associated with it *) + let ranges = List.map ranges ~f:snd in + let from = + CallHierarchyItem.create + ~detail:(detail_str ~state ~uri) + ~kind:SymbolKind.Function + ~name + ~range:(Range.of_loc loc) + ~selectionRange:(Range.of_loc loc) + ~uri + () + in + CallHierarchyIncomingCall.create ~from ~fromRanges:ranges) + |> Option.some) + >>| List.filter_opt + >>| List.concat + >>| Option.some +;; + +let handle_outgoing ~log_info (server : State.t Server.t) params = + ignore log_info; + ignore server; + ignore params; + Fiber.return None +;; diff --git a/ocaml-lsp-server/src/call_hierarchy.mli b/ocaml-lsp-server/src/call_hierarchy.mli new file mode 100644 index 000000000..4b0edc025 --- /dev/null +++ b/ocaml-lsp-server/src/call_hierarchy.mli @@ -0,0 +1,23 @@ +open Import + +(** If the cursor is on a function symbol, we resolve the reference of that function and + use it as the base for the call hierarchy. If the cursor is on any other place, we + find next closest parent function and use it for the call hierarchy. *) +val handle_prepare + : log_info:Lsp_timing_logger.t + -> State.t Server.t + -> CallHierarchyPrepareParams.t + -> CallHierarchyItem.t list option Fiber.t + +val handle_incoming + : log_info:Lsp_timing_logger.t + -> State.t Server.t + -> CallHierarchyIncomingCallsParams.t + -> CallHierarchyIncomingCall.t list option Fiber.t + +(* TODO: [handle_outgoing] is currently unimplemented. *) +val handle_outgoing + : log_info:Lsp_timing_logger.t + -> State.t Server.t + -> CallHierarchyOutgoingCallsParams.t + -> CallHierarchyOutgoingCall.t list option Fiber.t diff --git a/ocaml-lsp-server/src/check_for_comments.ml b/ocaml-lsp-server/src/check_for_comments.ml index ec7a61e5f..f0f9286ae 100644 --- a/ocaml-lsp-server/src/check_for_comments.ml +++ b/ocaml-lsp-server/src/check_for_comments.ml @@ -1,6 +1,6 @@ open Import -let position_in_comment ~position ~merlin = +let position_in_comment ~log_info ~position ~merlin = let loc_contains_position (_, (loc : Loc.t)) = let start = Position.of_lexical_position loc.loc_start in let end_ = Position.of_lexical_position loc.loc_end in @@ -12,6 +12,6 @@ let position_in_comment ~position ~merlin = | `Outside _ -> false) | None -> false in - Document.Merlin.with_pipeline_exn ~name:"get-comments" merlin (fun pipeline -> + Document.Merlin.with_pipeline_exn ~log_info merlin (fun pipeline -> Mpipeline.reader_comments pipeline |> List.exists ~f:loc_contains_position) ;; diff --git a/ocaml-lsp-server/src/check_for_comments.mli b/ocaml-lsp-server/src/check_for_comments.mli index 2c773d3f7..f85cec9e0 100644 --- a/ocaml-lsp-server/src/check_for_comments.mli +++ b/ocaml-lsp-server/src/check_for_comments.mli @@ -1,2 +1,6 @@ (** Returns [true] if [position] occurs inside a comment in the document *) -val position_in_comment : position:Position.t -> merlin:Document.Merlin.t -> bool Fiber.t +val position_in_comment + : log_info:Lsp_timing_logger.t + -> position:Position.t + -> merlin:Document.Merlin.t + -> bool Fiber.t diff --git a/ocaml-lsp-server/src/client.mli b/ocaml-lsp-server/src/client.mli index 90cb29a03..7059365fc 100644 --- a/ocaml-lsp-server/src/client.mli +++ b/ocaml-lsp-server/src/client.mli @@ -1,7 +1,6 @@ open Import -(** This module is a collection of client-specific functionality (client = - editor) *) +(** This module is a collection of client-specific functionality (client = editor) *) module Experimental_capabilities : sig (** Module to store experimental client capabilities *) @@ -18,8 +17,8 @@ module Vscode : sig Reference for VS Code built-in commands: https://code.visualstudio.com/api/references/commands *) module Commands : sig - (** [editor.action.triggerSuggest] is a vscode-specific command, which - triggers the completion request on all completion providers *) + (** [editor.action.triggerSuggest] is a vscode-specific command, which triggers the + completion request on all completion providers *) val triggerSuggest : Command.t end end @@ -28,14 +27,12 @@ end module Custom_commands : sig (** Request client cursor to jump to the next hole. - See the documentation for this command in [vscode-ocaml-platform] for - details. + See the documentation for this command in [vscode-ocaml-platform] for details. @param in_range - to pick a hole only in a given range; if omitted, the whole document is - used + to pick a hole only in a given range; if omitted, the whole document is used @param notify_if_no_hole - specifies whether we want the client to show the user a message if there - is no hole to jump to *) + specifies whether we want the client to show the user a message if there is no + hole to jump to *) val next_hole : ?in_range:Range.t -> notify_if_no_hole:bool -> unit -> Command.t end diff --git a/ocaml-lsp-server/src/code_actions/code_action.ml b/ocaml-lsp-server/src/code_action.ml similarity index 58% rename from ocaml-lsp-server/src/code_actions/code_action.ml rename to ocaml-lsp-server/src/code_action.ml index 468dd250c..a608ba455 100644 --- a/ocaml-lsp-server/src/code_actions/code_action.ml +++ b/ocaml-lsp-server/src/code_action.ml @@ -9,8 +9,12 @@ type t = { kind : CodeActionKind.t ; run : [ `Batchable of - Mpipeline.t -> Document.t -> CodeActionParams.t -> CodeAction.t option - | `Non_batchable of Document.t -> CodeActionParams.t -> CodeAction.t option Fiber.t + Mpipeline.t -> Document.t -> CodeActionParams.t -> CodeAction.t option + | `Non_batchable of + log_info:Lsp_timing_logger.t + -> Document.t + -> CodeActionParams.t + -> CodeAction.t option Fiber.t ] } diff --git a/ocaml-lsp-server/src/code_action.mli b/ocaml-lsp-server/src/code_action.mli new file mode 100644 index 000000000..f9a156069 --- /dev/null +++ b/ocaml-lsp-server/src/code_action.mli @@ -0,0 +1,30 @@ +open Import + +type t = + { kind : CodeActionKind.t + ; run : + [ `Batchable of + Mpipeline.t -> Document.t -> CodeActionParams.t -> CodeAction.t option + | `Non_batchable of + log_info:Lsp_timing_logger.t + -> Document.t + -> CodeActionParams.t + -> CodeAction.t option Fiber.t + ] + (** A code action is either "batchable" or "non-batchable". Batchable actions do not use + fibers internally, so they can be safely run inside a [with_pipeline] context. + Non-batchable actions can use fibers. *) + } + +val batchable + : CodeActionKind.t + -> (Mpipeline.t -> Document.t -> CodeActionParams.t -> CodeAction.t option) + -> t + +val non_batchable + : CodeActionKind.t + -> (log_info:Lsp_timing_logger.t + -> Document.t + -> CodeActionParams.t + -> CodeAction.t option Fiber.t) + -> t diff --git a/ocaml-lsp-server/src/code_actions.ml b/ocaml-lsp-server/src/code_actions.ml index 662599eea..aeeeabac4 100644 --- a/ocaml-lsp-server/src/code_actions.ml +++ b/ocaml-lsp-server/src/code_actions.ml @@ -25,7 +25,7 @@ module Code_action_error_monoid = struct include Stdune.Monoid.Make (Code_action_error) end -let compute_ocaml_code_actions (params : CodeActionParams.t) state doc = +let compute_ocaml_code_actions ~log_info (params : CodeActionParams.t) state doc = let action_is_enabled = match params.context.only with | None -> fun _ -> true @@ -42,7 +42,6 @@ let compute_ocaml_code_actions (params : CodeActionParams.t) state doc = ; Action_inferred_intf.t state ; Action_type_annotate.t ; Action_remove_type_annotation.t - ; Action_construct.t ; Action_refactor_open.unqualify ; Action_refactor_open.qualify ; Action_add_rec.t @@ -66,7 +65,7 @@ let compute_ocaml_code_actions (params : CodeActionParams.t) state doc = then Fiber.return [] else Document.Merlin.with_pipeline_exn - ~name:"batched-code-actions" + ~log_info (Document.merlin_exn doc) (fun pipeline -> List.filter_map batchable ~f:(fun ca -> @@ -82,7 +81,7 @@ let compute_ocaml_code_actions (params : CodeActionParams.t) state doc = Fiber.return (Code_action_error.Need_merlin_extend error) | _ -> Fiber.return (Code_action_error.Exn exn)) (module Code_action_error_monoid) - (fun () -> ca doc params) + (fun () -> ca ~log_info doc params) in match res with | Ok res -> res @@ -90,46 +89,37 @@ let compute_ocaml_code_actions (params : CodeActionParams.t) state doc = | Error (Need_merlin_extend _) -> None | Error (Exn exn) -> Exn_with_backtrace.reraise exn in - let+ non_batch_results = + let* non_batch_results = Fiber.parallel_map non_batchable ~f:code_action |> Fiber.map ~f:List.filter_opt in - batch_results @ non_batch_results + let+ construct_results = + Action_construct.get_construct_actions ~log_info state doc params + in + batch_results @ non_batch_results @ construct_results ;; -let compute server (params : CodeActionParams.t) = +let compute ~log_info server (params : CodeActionParams.t) = let state : State.t = Server.state server in let uri = params.textDocument.uri in let doc = let store = state.store in Document_store.get_opt store uri in - let dune_actions = Dune.code_actions (State.dune state) params.textDocument.uri in let actions = function | [] -> None | xs -> Some (List.map ~f:(fun a -> `CodeAction a) xs) in match doc with - | None -> Fiber.return (Reply.now (actions dune_actions), state) + | None -> Fiber.return (Reply.now None, state) | Some doc -> - let capabilities = - let open Option.O in - let* window = (State.client_capabilities state).window in - window.showDocument - in - let open_related = Action_open_related.for_uri capabilities doc in - let* merlin_jumps = - match state.configuration.data.merlin_jump_code_actions with - | Some { enable = true } -> Action_jump.code_actions doc params capabilities - | Some { enable = false } | None -> Fiber.return [] - in (match Document.syntax doc with - | Ocamllex | Menhir | Cram | Dune -> - Fiber.return (Reply.now (actions (dune_actions @ open_related)), state) + | Ocamllex | Menhir | Cram | Dune -> Fiber.return (Reply.now None, state) | Ocaml | Reason -> let reply () = - let+ code_action_results = compute_ocaml_code_actions params state doc in - List.concat [ code_action_results; dune_actions; open_related; merlin_jumps ] - |> actions + let+ code_action_results = + compute_ocaml_code_actions ~log_info params state doc + in + actions code_action_results in let later f = Fiber.return diff --git a/ocaml-lsp-server/src/code_actions.mli b/ocaml-lsp-server/src/code_actions.mli index 547d02f7b..a687fb077 100644 --- a/ocaml-lsp-server/src/code_actions.mli +++ b/ocaml-lsp-server/src/code_actions.mli @@ -1,6 +1,7 @@ open Import val compute - : State.t Server.t + : log_info:Lsp_timing_logger.t + -> State.t Server.t -> CodeActionParams.t -> ([> `CodeAction of CodeAction.t ] list option Reply.t * State.t) Fiber.t diff --git a/ocaml-lsp-server/src/code_actions/action_combine_cases.ml b/ocaml-lsp-server/src/code_actions/action_combine_cases.ml deleted file mode 100644 index d07252471..000000000 --- a/ocaml-lsp-server/src/code_actions/action_combine_cases.ml +++ /dev/null @@ -1,81 +0,0 @@ -open Import - -let action_kind = "combine-cases" -let kind = CodeActionKind.Other action_kind - -let select_complete_lines (range : Range.t) = - if range.start.line = range.end_.line - then None - else ( - let start = { range.start with character = 0 } in - match range.end_.character with - | 0 -> Some { range with start } - | _ -> - let end_ = Position.{ line = range.end_.line + 1; character = 0 } in - Some (Range.create ~start ~end_)) -;; - -let split_cases code = - let lines = String.split code ~on:'\n' in - let case_regex = Re.Perl.re {|^\s*\|.*->|} |> Re.compile in - let drop_from_lines lines regex = - List.map lines ~f:(Re.replace_string (Re.compile regex) ~by:"") - in - match List.for_all ~f:(Re.execp case_regex) lines with - | false -> None - | true -> - let without_pipes = drop_from_lines lines (Re.Perl.re {|\s*\|\s*|}) in - let lhs_patterns = drop_from_lines without_pipes (Re.Perl.re {|\s*->.*$|}) in - let rhs_expressions = drop_from_lines without_pipes (Re.Perl.re {|^.*->\s*|}) in - Some (lhs_patterns, rhs_expressions) -;; - -let pick_rhs rhs_expressions = - let distinct_nonempty = - List.map rhs_expressions ~f:String.strip - |> List.filter ~f:(fun s -> (not (String.is_empty s)) && not (String.equal s "_")) - |> Base.List.dedup_and_sort ~compare:Base.String.compare - in - match distinct_nonempty with - | [ expr ] -> expr - | _ -> "_" -;; - -let make_text_edit ~range ~newText ~doc ~uri = - let text_edit = TextEdit.create ~range ~newText in - let version = Document.version doc in - let textDocument = OptionalVersionedTextDocumentIdentifier.create ~uri ~version () in - let edit = TextDocumentEdit.create ~textDocument ~edits:[ `TextEdit text_edit ] in - WorkspaceEdit.create ~documentChanges:[ `TextDocumentEdit edit ] () -;; - -let code_action doc params = - match Document.kind doc with - | `Other -> Fiber.return None - | `Merlin merlin -> - (match Document.Merlin.kind merlin with - | Intf -> Fiber.return None - | Impl -> - let result = - let open Option.O in - let* range = select_complete_lines params.CodeActionParams.range in - let* code = Document.substring doc range in - let code = String.strip ~drop:(fun c -> Char.equal c '\n') code in - let* lhs_patterns, rhs_expressions = split_cases code in - let+ i = Base.String.index code '|' in - let indent = String.sub code ~pos:0 ~len:i in - let lhs = String.concat ~sep:" | " lhs_patterns in - let rhs = pick_rhs rhs_expressions in - let newText = indent ^ "| " ^ lhs ^ " -> " ^ rhs ^ "\n" in - let edit = make_text_edit ~range ~newText ~doc ~uri:params.textDocument.uri in - CodeAction.create - ~title:(String.capitalize action_kind) - ~kind - ~edit - ~isPreferred:false - () - in - Fiber.return result) -;; - -let t = { Code_action.kind; run = `Non_batchable code_action } diff --git a/ocaml-lsp-server/src/code_actions/action_combine_cases.mli b/ocaml-lsp-server/src/code_actions/action_combine_cases.mli deleted file mode 100644 index 6ef5f5a83..000000000 --- a/ocaml-lsp-server/src/code_actions/action_combine_cases.mli +++ /dev/null @@ -1,4 +0,0 @@ -open Import - -val kind : CodeActionKind.t -val t : Code_action.t diff --git a/ocaml-lsp-server/src/code_actions/action_construct.ml b/ocaml-lsp-server/src/code_actions/action_construct.ml deleted file mode 100644 index 5a529543f..000000000 --- a/ocaml-lsp-server/src/code_actions/action_construct.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Import - -let action_kind = "construct" - -let code_action pipeline doc (params : CodeActionParams.t) = - match Document.kind doc with - | `Other -> None - | `Merlin m when Document.Merlin.kind m = Intf -> None - | `Merlin _ -> - let pos = Position.logical params.range.Range.end_ in - (* we want this predicate to quickly eliminate prefixes that don't fit to be - a hole *) - let prefix = - let src = Document.source doc in - Compl.prefix_of_position ~short_path:false src pos - in - if not (Merlin_analysis.Typed_hole.can_be_hole prefix) - then None - else ( - let structures = - let typedtree = - let typer = Mpipeline.typer_result pipeline in - Mtyper.get_typedtree typer - in - let pos = Mpipeline.get_lexing_pos pipeline pos in - Mbrowse.enclosing pos [ Mbrowse.of_typedtree typedtree ] - in - if not (Merlin_analysis.Typed_hole.is_a_hole structures) - then None - else ( - (* ocaml-lsp can provide [Construct] values as completion entries, so - this code action requests the client [1] to trigger completion - request at the cursor's current position [2] - - this code action simply requests the client [1] to trigger completion - suggestions, as ocaml-lsp provides constructed values as completion - entries, when the cursor is on a typed hole [2] - - [1] currently, the command is vscode-specific, so only vscode client - is supported (note: this _code action_ works only for vscode; - [Construct] support works for all clients) - - [2] vscode doesn't provide API to show specific completion entries, - only a command to trigger all completion providers at the current - cursor position *) - let code_action = - CodeAction.create - ~title:"Construct an expression" - ~kind:(CodeActionKind.Other action_kind) - ~command:Client.Vscode.Commands.triggerSuggest - () - in - Some code_action)) -;; - -let t = Code_action.batchable (Other action_kind) code_action diff --git a/ocaml-lsp-server/src/code_actions/action_construct.mli b/ocaml-lsp-server/src/code_actions/action_construct.mli deleted file mode 100644 index 0caac27b3..000000000 --- a/ocaml-lsp-server/src/code_actions/action_construct.mli +++ /dev/null @@ -1 +0,0 @@ -val t : Code_action.t diff --git a/ocaml-lsp-server/src/code_actions/action_destruct_line.ml b/ocaml-lsp-server/src/code_actions/action_destruct_line.ml deleted file mode 100644 index f9258065a..000000000 --- a/ocaml-lsp-server/src/code_actions/action_destruct_line.ml +++ /dev/null @@ -1,316 +0,0 @@ -open Import -open Fiber.O - -let action_kind = "destruct-line (enumerate cases, use existing match)" -let kind = CodeActionKind.Other action_kind - -(* TODO: All of the pre- and post-processing here is done by simple regexes and other - string manipulations. It would be nice if more of it could rely on the typed tree or - other analysis of the code provided by Merlin. *) - -type statement_kind = - | MatchLine (* [match ...] *) - | MatchWithLine (* [match ... with] *) - | CaseLine (* [|...->...] *) - | Hole - (* [|..._...->...] AND the range indicates a query at the underscore. *) - | OffsetHole of int (* [| _ ->...] BUT the hole is here, not at the query location. *) - -type destructable_statement = - { code : string - ; kind : statement_kind - ; query_range : Range.t (* Range sent to Merlin based on our pre-processing. *) - ; reply_range : Range.t (* Where Merlin's reply will go. *) - } - -(** Extracts the line of [doc] that the query indicated by [range] starts on.*) -let get_line (doc : Document.t) (range : Range.t) = - let text = Document.text doc in - let start_line = range.start.line + 1 in - let source = Document.source doc in - let (`Offset pos) = Msource.get_offset source (`Logical (start_line, 0)) in - let (`Offset next) = Msource.get_offset source (`Logical (start_line + 1, 0)) in - let len = next - pos in - String.sub text ~pos ~len -;; - -(** Trims leading and trailing whitespace plus some number of additional - characters from the head and tail of a string. Used to transform [match x] - or [match x with] to [x]. *) -let strip_head_and_tail str ~head_offset ~tail_offset = - let str = String.strip str in - let l = String.length str in - let substr = String.sub str ~pos:head_offset ~len:(l - head_offset - tail_offset) in - String.strip substr -;; - -(** Finds the start and end indices of a substring for extraction. *) -let substr_endpoints_exn ~str ~substr = - let start_index = String.substr_index_exn str ~pattern:substr in - let end_index = start_index + String.length substr in - start_index, end_index -;; - -(** Assumes [case_line] passes the check for a CaseLine, but hasn't had - whitespace removed. Checks that the cursor is before the arrow and the - position before or after the cursor has an underscore. *) -let is_hole (case_line : string) (cursor_pos : int) = - let arrow_pos = String.substr_index_exn case_line ~pattern:"->" in - if cursor_pos <= 0 || cursor_pos >= arrow_pos - then false (* We're only looking for '_' if the cursor is between "|" and "->". *) - else if - Char.equal case_line.[cursor_pos] '_' || Char.equal case_line.[cursor_pos - 1] '_' - then true - else false -;; - -(** Finds the index of a lhs underscore in [case_line], if any. *) -let find_hole (case_line : string) = - let start_of_lhs = 1 + String.substr_index_exn case_line ~pattern:"|" in - let end_of_lhs = String.substr_index_exn case_line ~pattern:"->" in - let lhs = - String.strip (String.sub case_line ~pos:start_of_lhs ~len:(end_of_lhs - start_of_lhs)) - in - if String.equal "_" lhs then String.substr_index case_line ~pattern:"_" else None -;; - -let get_statement_kind = - let space_without_nl = Re.set " \t" in - (* Line starts with [match] and has at least one other word. *) - let match_regex = - let open Re in - seq [ str "match"; rep1 space_without_nl; compl [ space_without_nl ] ] - in - let match_with_regex = - let open Re in - seq [ match_regex; rep any; space_without_nl; str "with"; eos ] - in - (* Line starts with a pipe and contains an arrow. *) - let case_regex = - let open Re in - seq [ str "|"; rep any; str "->"; rep any ] - in - let regexes = - [ match_with_regex, `MatchWithLine; match_regex, `MatchLine; case_regex, `CaseLine ] - |> List.map ~f:(fun (re, kind) -> Re.(seq [ bos; re ] |> compile), kind) - in - fun (code_line : string) (range : Range.t) -> - let logical_line = String.strip code_line in - (* Line starts with [match], ends with [with], and has at least one other word. *) - List.find_map regexes ~f:(fun (re, name) -> - Option.some_if (Re.execp re logical_line) name) - |> Option.bind ~f:(function - | `MatchWithLine -> Some MatchWithLine - | `MatchLine -> Some MatchLine - | `CaseLine -> - if is_hole code_line range.start.character - then Some Hole - else ( - match find_hole code_line with - | None -> Some CaseLine - | Some offset -> Some (OffsetHole offset))) -;; - -(** Given a line of the form [match x] or [match x with] or [| x -> y], create a - query range corresponding to [x]. *) -let get_query_range (code : string) (kind : statement_kind) (range : Range.t) : Range.t = - let expr = - match kind with - | MatchLine -> strip_head_and_tail code ~head_offset:5 ~tail_offset:0 - | MatchWithLine -> strip_head_and_tail code ~head_offset:5 ~tail_offset:4 - | CaseLine -> - let len = String.substr_index_exn code ~pattern:"->" in - let expr = String.sub code ~pos:0 ~len in - strip_head_and_tail expr ~head_offset:1 ~tail_offset:0 - | Hole | OffsetHole _ -> "" - in - let start_index, end_index = - match kind with - | Hole -> range.start.character, range.end_.character - | OffsetHole offset -> offset, offset - | _ -> substr_endpoints_exn ~str:code ~substr:expr - in - { start = { range.start with character = start_index } - ; end_ = { range.end_ with character = end_index } - } -;; - -(** Finds the portion of the text that will be overwritten by Merlin's reply. - For a MatchLine or a MatchWithLine, Merlin's reply will include "match" and - "with", so to avoid duplication, we want the existing "match" and (possibly) - "with" to be included in the range that gets replaced. *) -let get_reply_range (code : string) (kind : statement_kind) (query_range : Range.t) = - match kind with - | CaseLine | Hole | OffsetHole _ -> query_range - | MatchLine | MatchWithLine -> - let logical_line = String.strip code in - let start_char, end_char = substr_endpoints_exn ~str:code ~substr:logical_line in - { start = { query_range.start with character = start_char } - ; end_ = { query_range.end_ with character = end_char } - } -;; - -(** Adjusts the location Merlin gave us to ensure the right text gets - overwritten. *) -let adjust_reply_location ~(statement : destructable_statement) (loc : Loc.t) : Loc.t = - let start_offset = - statement.reply_range.start.character - statement.query_range.start.character - in - let end_offset = - statement.reply_range.end_.character - statement.query_range.end_.character - in - let loc_start = - { loc.loc_start with pos_cnum = loc.loc_start.pos_cnum + start_offset } - in - let loc_end = { loc.loc_end with pos_cnum = loc.loc_end.pos_cnum + end_offset } in - { loc with loc_start; loc_end } -;; - -(** Tries to find a statement we know how to handle on the line where the range - starts. *) -let extract_statement (doc : Document.t) (ca_range : Range.t) - : destructable_statement option - = - if ca_range.start.line <> ca_range.end_.line - then None - else ( - let code = get_line doc ca_range in - match get_statement_kind code ca_range with - | None -> None - | Some kind -> - let query_range = get_query_range code kind ca_range in - let reply_range = get_reply_range code kind query_range in - Some { code; kind; query_range; reply_range }) -;; - -(** Strips " -> _ " off the rhs and " | " off the lhs of a case-line if present. *) -let strip_case_line line = - String.strip line - |> String.chop_prefix_if_exists ~prefix:"|" - |> String.chop_suffix_if_exists ~suffix:"_" - |> String.strip - |> String.chop_suffix_if_exists ~suffix:"->" - |> String.strip -;; - -let strip_parens line = - String.chop_prefix_if_exists line ~prefix:"(" - |> String.chop_suffix_if_exists ~suffix:")" -;; - -(** Combines match-case lines that have already been stripped. *) -let format_match_cases lines ~indent = - "\n" - ^ (List.filter_map lines ~f:(fun l -> - match strip_parens (strip_case_line l) with - | "" -> None - | l -> Some (indent ^ "| " ^ l ^ " -> _")) - |> String.concat ~sep:"\n") -;; - -(** Finds the "with" in the Merlin reply and splits after it. *) -let separate_match_line new_code = - let end_of_match = String.substr_index_exn new_code ~pattern:"with" in - let match_line = String.prefix new_code (end_of_match + 4) in - let rest = Base.String.drop_prefix new_code (end_of_match + 4) in - match_line, rest -;; - -let format_merlin_reply ~(statement : destructable_statement) (new_code : string) = - let indent = - match - String.lfindi statement.code ~f:(fun _ c -> not (Base.Char.is_whitespace c)) - with - | None -> "" - | Some i -> String.sub statement.code ~pos:0 ~len:i - in - match statement.kind with - | MatchLine | MatchWithLine -> - let match_line, rest = separate_match_line new_code in - let rest = String.chop_suffix_if_exists rest ~suffix:")" in - let match_line = String.chop_prefix_if_exists match_line ~prefix:"(" in - let lines = String.split ~on:'|' rest in - match_line ^ format_match_cases lines ~indent - | CaseLine -> format_match_cases (String.split ~on:'|' new_code) ~indent - | Hole | OffsetHole _ -> - let lines = String.split ~on:'|' new_code in - (match List.hd lines, List.tl lines with - | None, _ | _, None -> new_code - | Some first_line, Some other_lines -> - let other_lines = - List.map other_lines ~f:(fun l -> indent ^ "| " ^ strip_case_line l) - in - String.concat ~sep:" -> _\n" (String.strip first_line :: other_lines)) -;; - -let code_action_of_case_analysis ~supportsJumpToNextHole doc uri (loc, newText) = - let range : Range.t = Range.of_loc loc in - let textedit : TextEdit.t = { range; newText } in - let edit : WorkspaceEdit.t = - let version = Document.version doc in - let textDocument = OptionalVersionedTextDocumentIdentifier.create ~uri ~version () in - let edit = TextDocumentEdit.create ~textDocument ~edits:[ `TextEdit textedit ] in - WorkspaceEdit.create ~documentChanges:[ `TextDocumentEdit edit ] () - in - let title = String.capitalize action_kind in - let command = - if supportsJumpToNextHole - then - Some - (Client.Custom_commands.next_hole - ~in_range:(Range.resize_for_edit textedit) - ~notify_if_no_hole:false - ()) - else None - in - CodeAction.create - ~title - ~kind:(CodeActionKind.Other action_kind) - ~edit - ?command - ~isPreferred:false - () -;; - -let dispatch_destruct (merlin : Document.Merlin.t) (range : Range.t) = - let command = - let start = Position.logical range.start in - let finish = Position.logical range.end_ in - Query_protocol.Case_analysis (start, finish) - in - Document.Merlin.dispatch ~name:"destruct" merlin command -;; - -let code_action (state : State.t) (doc : Document.t) (params : CodeActionParams.t) = - let uri = params.textDocument.uri in - match Document.kind doc with - | `Other -> Fiber.return None - | `Merlin merlin -> - (match Document.Merlin.kind merlin, extract_statement doc params.range with - | Intf, _ | _, None -> Fiber.return None - | Impl, Some statement -> - let+ res = dispatch_destruct merlin statement.query_range in - (match res with - | Ok (loc, newText) -> - let loc = adjust_reply_location ~statement loc in - let newText = format_merlin_reply ~statement newText in - let supportsJumpToNextHole = - State.experimental_client_capabilities state - |> Client.Experimental_capabilities.supportsJumpToNextHole - in - Some - (code_action_of_case_analysis ~supportsJumpToNextHole doc uri (loc, newText)) - | Error - { exn = - ( Merlin_analysis.Destruct.Wrong_parent _ - | Query_commands.No_nodes - | Merlin_analysis.Destruct.Not_allowed _ - | Merlin_analysis.Destruct.Useless_refine - | Merlin_analysis.Destruct.Ill_typed - | Merlin_analysis.Destruct.Nothing_to_do ) - ; backtrace = _ - } -> None - | Error exn -> Exn_with_backtrace.reraise exn)) -;; - -let t state = { Code_action.kind; run = `Non_batchable (code_action state) } diff --git a/ocaml-lsp-server/src/code_actions/action_destruct_line.mli b/ocaml-lsp-server/src/code_actions/action_destruct_line.mli deleted file mode 100644 index 896f88834..000000000 --- a/ocaml-lsp-server/src/code_actions/action_destruct_line.mli +++ /dev/null @@ -1,48 +0,0 @@ -open Import - -(** This code action allows the user to invoke Merlin-destruct to enumerate - cases from various lines of a partial match statement. If the line is of any - of these forms: [match x] [match x with] [| x -> y] then the pre-processing - will extract [x] and invoke Merlin-destruct on it. Some post-processing is - applied to Merlin's response to make it more useful for adding subsequent - code: extraneous tokens are stripped and cases are split across lines. For - example, supposing [x] is a [bool], then the line [match x with] expands to - [match x with - | false -> _ - | true -> _]. The same expansion - results from invoking the code action on the second line of - [match x with - | false -> _]. - - In addition, the code action detects a sub-case of the [| x -> y] form, - where the cursor is on an underscore within [x]. This often corresponds to a - wildcard pattern where a destruct action is useful and extra post-processing - helps. The follwing expansions result from repeated applications of - [destruct-line]: - [let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = - match xs, ys] - (code action invoked anywhere on the match line) - [let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = - match (xs, ys) with - | (_, _) -> _] - (CA invoked on the first underscore) - [let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = - match (xs, ys) with - | ([], _) -> _ - | (_::_, _) -> _] - (CA invoked on the first underscore) - [let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = - match (xs, ys) with - | ([], []) -> _ - | ([], _::_) -> _ - | (_::_, _) -> _] - (CA invoked on the second-to-last underscore) - [let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = - match (xs, ys) with - | ([], []) -> _ - | ([], _::_) -> _ - | (_::_, []) -> _ - | (_::_, _::_) -> _] *) - -val kind : CodeActionKind.t -val t : State.t -> Code_action.t diff --git a/ocaml-lsp-server/src/code_actions/action_jump.ml b/ocaml-lsp-server/src/code_actions/action_jump.ml deleted file mode 100644 index 19e4cdf29..000000000 --- a/ocaml-lsp-server/src/code_actions/action_jump.ml +++ /dev/null @@ -1,93 +0,0 @@ -open Import -open Fiber.O -open Stdune - -let command_name = "ocamllsp/merlin-jump-to-target" - -let targets = - [ "fun"; "match"; "let"; "module"; "module-type"; "match-next-case"; "match-prev-case" ] -;; - -let rename_target target = - if String.starts_with ~prefix:"match-" target - then String.sub target ~pos:6 ~len:(String.length target - 6) - else target -;; - -let available (capabilities : ShowDocumentClientCapabilities.t option) = - match capabilities with - | Some { support } -> support - | None -> false -;; - -let error message = - Jsonrpc.Response.Error.raise - @@ Jsonrpc.Response.Error.make - ~code:Jsonrpc.Response.Error.Code.InvalidParams - ~message - () -;; - -let command_run server (params : ExecuteCommandParams.t) = - let uri, range = - match params.arguments with - | Some [ json_uri; json_range ] -> - let uri = DocumentUri.t_of_yojson json_uri in - let range = Range.t_of_yojson json_range in - uri, range - | None | Some _ -> error "takes a URI and a range as input" - in - let+ { ShowDocumentResult.success } = - let req = ShowDocumentParams.create ~uri ~selection:range ~takeFocus:true () in - Server.request server (Server_request.ShowDocumentRequest req) - in - if not success - then ( - let uri = Uri.to_string uri in - Format.eprintf "failed to open %s@." uri); - `Null -;; - -(* Dispatch the jump request to Merlin and get the result *) -let process_jump_request ~merlin ~position ~target = - let+ results = - Document.Merlin.with_pipeline_exn merlin (fun pipeline -> - let pposition = Position.logical position in - let query = Query_protocol.Jump (target, pposition) in - Query_commands.dispatch pipeline query) - in - match results with - | `Error _ -> None - | `Found pos -> Some pos -;; - -let code_actions - (doc : Document.t) - (params : CodeActionParams.t) - (capabilities : ShowDocumentClientCapabilities.t option) - = - match Document.kind doc with - | `Merlin merlin when available capabilities -> - let+ actions = - (* TODO: Merlin Jump command that returns all available jump locations for a source code buffer. *) - Fiber.parallel_map targets ~f:(fun target -> - let+ res = process_jump_request ~merlin ~position:params.range.start ~target in - let open Option.O in - let* lexing_pos = res in - let+ position = Position.of_lexical_position lexing_pos in - let uri = Document.uri doc in - let range = { Range.start = position; end_ = position } in - let title = sprintf "%s jump" (String.capitalize_ascii (rename_target target)) in - let command = - let arguments = [ DocumentUri.yojson_of_t uri; Range.yojson_of_t range ] in - Command.create ~title ~command:command_name ~arguments () - in - CodeAction.create - ~title - ~kind:(CodeActionKind.Other (sprintf "merlin-jump-%s" (rename_target target))) - ~command - ()) - in - List.filter_opt actions - | _ -> Fiber.return [] -;; diff --git a/ocaml-lsp-server/src/code_actions/action_jump.mli b/ocaml-lsp-server/src/code_actions/action_jump.mli deleted file mode 100644 index cc8352779..000000000 --- a/ocaml-lsp-server/src/code_actions/action_jump.mli +++ /dev/null @@ -1,11 +0,0 @@ -open Import - -val command_name : string -val available : ShowDocumentClientCapabilities.t option -> bool -val command_run : 'a Server.t -> ExecuteCommandParams.t -> Json.t Fiber.t - -val code_actions - : Document.t - -> CodeActionParams.t - -> ShowDocumentClientCapabilities.t option - -> CodeAction.t list Fiber.t diff --git a/ocaml-lsp-server/src/code_actions/code_action.mli b/ocaml-lsp-server/src/code_actions/code_action.mli deleted file mode 100644 index 37f2439fe..000000000 --- a/ocaml-lsp-server/src/code_actions/code_action.mli +++ /dev/null @@ -1,24 +0,0 @@ -open Import - -type t = - { kind : CodeActionKind.t - ; run : - [ `Batchable of - Mpipeline.t -> Document.t -> CodeActionParams.t -> CodeAction.t option - | `Non_batchable of Document.t -> CodeActionParams.t -> CodeAction.t option Fiber.t - ] - (** A code action is either "batchable" or "non-batchable". Batchable - actions do not use fibers internally, so they can be safely run - inside a [with_pipeline] context. Non-batchable actions can use - fibers. *) - } - -val batchable - : CodeActionKind.t - -> (Mpipeline.t -> Document.t -> CodeActionParams.t -> CodeAction.t option) - -> t - -val non_batchable - : CodeActionKind.t - -> (Document.t -> CodeActionParams.t -> CodeAction.t option Fiber.t) - -> t diff --git a/ocaml-lsp-server/src/compl.ml b/ocaml-lsp-server/src/compl.ml index c5054ff2f..ff50e694c 100644 --- a/ocaml-lsp-server/src/compl.ml +++ b/ocaml-lsp-server/src/compl.ml @@ -95,11 +95,11 @@ let sortText_of_index idx = Printf.sprintf "%04d" idx module Complete_by_prefix = struct let completionItem_of_completion_entry - idx - (entry : Query_protocol.Compl.entry) - ~compl_params - ~range - ~deprecated + idx + (entry : Query_protocol.Compl.entry) + ~compl_params + ~range + ~deprecated = let kind = completion_kind entry.kind in let textEdit = `TextEdit { TextEdit.range; newText = entry.name } in @@ -122,12 +122,12 @@ module Complete_by_prefix = struct ;; let process_dispatch_resp - ~deprecated - ~resolve - ~prefix - doc - pos - (completion : Query_protocol.completions) + ~deprecated + ~resolve + ~prefix + doc + pos + (completion : Query_protocol.completions) = let range = let logical_pos = Position.logical pos in @@ -151,6 +151,7 @@ module Complete_by_prefix = struct ; desc = typ ; info = "" ; deprecated = false (* TODO this is wrong *) + ; ppx_template_generated = false }) in (* we need to json-ify completion params to put them in completion item's @@ -181,9 +182,9 @@ module Complete_by_prefix = struct ~label:"in" ~textEdit: (`TextEdit - (TextEdit.create - ~newText:"in" - ~range:(range_prefix completion_position prefix))) + (TextEdit.create + ~newText:"in" + ~range:(range_prefix completion_position prefix))) ~kind:CompletionItemKind.Keyword () in @@ -191,13 +192,10 @@ module Complete_by_prefix = struct | _ -> [] ;; - let complete doc prefix pos ~deprecated ~resolve = + let complete ~log_info doc prefix pos ~deprecated ~resolve = let+ (completion : Query_protocol.completions) = let logical_pos = Position.logical pos in - Document.Merlin.with_pipeline_exn - ~name:"completion-prefix" - doc - (dispatch_cmd ~prefix logical_pos) + Document.Merlin.with_pipeline_exn ~log_info doc (dispatch_cmd ~prefix logical_pos) in let keyword_completionItems = (* we complete only keyword 'in' for now *) @@ -227,10 +225,9 @@ module Complete_with_construct = struct | Some (loc, constructed_exprs) -> let range = Range.of_loc loc in let deparen_constr_expr expr = - if - (not (String.equal expr "()")) - && String.is_prefix expr ~prefix:"(" - && String.is_suffix expr ~suffix:")" + if (not (String.equal expr "()")) + && String.is_prefix expr ~prefix:"(" + && String.is_suffix expr ~suffix:")" then String.sub expr ~pos:1 ~len:(String.length expr - 2) else expr in @@ -261,8 +258,9 @@ module Complete_with_construct = struct end let complete - (state : State.t) - ({ textDocument = { uri }; position = pos; context; _ } : CompletionParams.t) + ~log_info + (state : State.t) + ({ textDocument = { uri }; position = pos; context; _ } : CompletionParams.t) = Fiber.of_thunk (fun () -> let doc = Document_store.get state.store uri in @@ -291,7 +289,7 @@ let complete (match context.triggerKind with | TriggerCharacter -> let+ inside_comment = - Check_for_comments.position_in_comment ~position:pos ~merlin + Check_for_comments.position_in_comment ~log_info ~position:pos ~merlin in (match inside_comment with | true -> `Ignore @@ -315,8 +313,9 @@ let complete let* item = completion_item_capability in item.deprecatedSupport) in - if not (Merlin_analysis.Typed_hole.can_be_hole prefix) - then Complete_by_prefix.complete merlin prefix pos ~resolve ~deprecated + if not (Typed_hole.can_be_hole prefix) + then + Complete_by_prefix.complete merlin ~log_info prefix pos ~resolve ~deprecated else ( let reindex_sortText completion_items = List.mapi completion_items ~f:(fun idx (ci : CompletionItem.t) -> @@ -337,17 +336,14 @@ let complete { ci with CompletionItem.preselect = Some true } :: rest) in let+ construct_cmd_resp, compl_by_prefix_resp = - Document.Merlin.with_pipeline_exn - ~name:"completion" - merlin - (fun pipeline -> - let construct_cmd_resp = - Complete_with_construct.dispatch_cmd position pipeline - in - let compl_by_prefix_resp = - Complete_by_prefix.dispatch_cmd ~prefix position pipeline - in - construct_cmd_resp, compl_by_prefix_resp) + Document.Merlin.with_pipeline_exn ~log_info merlin (fun pipeline -> + let construct_cmd_resp = + Complete_with_construct.dispatch_cmd position pipeline + in + let compl_by_prefix_resp = + Complete_by_prefix.dispatch_cmd ~prefix position pipeline + in + construct_cmd_resp, compl_by_prefix_resp) in let construct_completionItems = let supportsJumpToNextHole = diff --git a/ocaml-lsp-server/src/compl.mli b/ocaml-lsp-server/src/compl.mli index 2b1403c9e..254c63523 100644 --- a/ocaml-lsp-server/src/compl.mli +++ b/ocaml-lsp-server/src/compl.mli @@ -5,15 +5,16 @@ module Resolve : sig val uri : t -> Uri.t - (** if the completion item doesn't have [data] field, then we don't resolve - but return it *) + (** if the completion item doesn't have [data] field, then we don't resolve but return + it *) val of_completion_item : CompletionItem.t -> t option include Json.Jsonable.S with type t := t end val complete - : State.t + : log_info:Lsp_timing_logger.t + -> State.t -> CompletionParams.t -> [> `CompletionList of CompletionList.t ] option Fiber.t @@ -26,7 +27,8 @@ val resolve -> markdown:bool -> CompletionItem.t Fiber.t -(** [prefix_of_position ~short_path source position] computes prefix before +(** {v + [prefix_of_position ~short_path source position] computes prefix before given [position]. A prefix is essentially a piece of code that refers to one thing eg a single infix operator "|>", a single reference to a function or variable: "List.map" a keyword "let" etc If there is semantically irrelivent @@ -36,11 +38,15 @@ val resolve determines whether we want full prefix or cut at ["."], e.g. [List.m] returns ["m"] when [short_path] is set vs ["List.m"] when not. - @return prefix of [position] in [source] and its length *) + @return prefix of [position] in [source] and its length + v} *) val prefix_of_position : short_path:bool -> Msource.t -> [< Msource.position ] -> string -(** [reconstruct_ident source position] returns the identifier at [position]. - Note: [position] can be in the middle of the identifier. +(** Similar to [prefix_of_position] but computes a suffix. *) +val suffix_of_position : Msource.t -> [< Msource.position ] -> string + +(** [reconstruct_ident source position] returns the identifier at [position]. Note: + [position] can be in the middle of the identifier. @return identifier unless none is found *) val reconstruct_ident : Msource.t -> [< Msource.position ] -> string option diff --git a/ocaml-lsp-server/src/config_data.ml b/ocaml-lsp-server/src/config_data.ml index 3fe22ce36..f034f27f2 100644 --- a/ocaml-lsp-server/src/config_data.ml +++ b/ocaml-lsp-server/src/config_data.ml @@ -1,938 +1,75 @@ open Import -open Import.Json.Conv - -module ShortenMerlinDiagnostics = struct - type t = { enable : bool [@default false] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "ocaml-lsp-server/src/config_data.ml.ShortenMerlinDiagnostics.t" in - function - | `Assoc field_yojsons as yojson -> - let enable_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "enable" -> - (match Ppx_yojson_conv_lib.( ! ) enable_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - enable_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let enable_value = Ppx_yojson_conv_lib.( ! ) enable_field in - { enable = - (match enable_value with - | Ppx_yojson_conv_lib.Option.None -> false - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { enable = v_enable } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_enable in - ("enable", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] -end module InlayHints = struct type t = { hint_pattern_variables : bool [@key "hintPatternVariables"] [@default false] ; hint_let_bindings : bool [@key "hintLetBindings"] [@default false] - ; hint_function_params : bool [@key "hintFunctionParams"] [@default true] + ; hint_function_params : bool [@key "hintFunctionParams"] [@default false] + ; hint_let_syntax_ppx : bool [@key "hintLetSyntaxPpx"] [@default false] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "ocaml-lsp-server/src/config_data.ml.InlayHints.t" in - function - | `Assoc field_yojsons as yojson -> - let hint_pattern_variables_field = ref Ppx_yojson_conv_lib.Option.None - and hint_let_bindings_field = ref Ppx_yojson_conv_lib.Option.None - and hint_function_params_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "hintPatternVariables" -> - (match Ppx_yojson_conv_lib.( ! ) hint_pattern_variables_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - hint_pattern_variables_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "hintLetBindings" -> - (match Ppx_yojson_conv_lib.( ! ) hint_let_bindings_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - hint_let_bindings_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "hintFunctionParams" -> - (match Ppx_yojson_conv_lib.( ! ) hint_function_params_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - hint_function_params_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( hint_pattern_variables_value - , hint_let_bindings_value - , hint_function_params_value ) - = - ( Ppx_yojson_conv_lib.( ! ) hint_pattern_variables_field - , Ppx_yojson_conv_lib.( ! ) hint_let_bindings_field - , Ppx_yojson_conv_lib.( ! ) hint_function_params_field ) - in - { hint_pattern_variables = - (match hint_pattern_variables_value with - | Ppx_yojson_conv_lib.Option.None -> false - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; hint_let_bindings = - (match hint_let_bindings_value with - | Ppx_yojson_conv_lib.Option.None -> false - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; hint_function_params = - (match hint_function_params_value with - | Ppx_yojson_conv_lib.Option.None -> true - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { hint_pattern_variables = v_hint_pattern_variables - ; hint_let_bindings = v_hint_let_bindings - ; hint_function_params = v_hint_function_params - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_hint_function_params in - ("hintFunctionParams", arg) :: bnds - in - let bnds = - let arg = yojson_of_bool v_hint_let_bindings in - ("hintLetBindings", arg) :: bnds - in - let bnds = - let arg = yojson_of_bool v_hint_pattern_variables in - ("hintPatternVariables", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] end module Lens = struct - type t = { enable : bool [@default true] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "ocaml-lsp-server/src/config_data.ml.Lens.t" in - function - | `Assoc field_yojsons as yojson -> - let enable_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "enable" -> - (match Ppx_yojson_conv_lib.( ! ) enable_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - enable_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let enable_value = Ppx_yojson_conv_lib.( ! ) enable_field in - { enable = - (match enable_value with - | Ppx_yojson_conv_lib.Option.None -> true - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { enable = v_enable } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_enable in - ("enable", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] -end - -module ExtendedHover = struct type t = { enable : bool [@default false] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "ocaml-lsp-server/src/config_data.ml.ExtendedHover.t" in - function - | `Assoc field_yojsons as yojson -> - let enable_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "enable" -> - (match Ppx_yojson_conv_lib.( ! ) enable_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - enable_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let enable_value = Ppx_yojson_conv_lib.( ! ) enable_field in - { enable = - (match enable_value with - | Ppx_yojson_conv_lib.Option.None -> false - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { enable = v_enable } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_enable in - ("enable", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] end -module StandardHover = struct - type t = { enable : bool [@default true] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "ocaml-lsp-server/src/config_data.ml.StandardHover.t" in - function - | `Assoc field_yojsons as yojson -> - let enable_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "enable" -> - (match Ppx_yojson_conv_lib.( ! ) enable_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - enable_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let enable_value = Ppx_yojson_conv_lib.( ! ) enable_field in - { enable = - (match enable_value with - | Ppx_yojson_conv_lib.Option.None -> true - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { enable = v_enable } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_enable in - ("enable", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] -end - -module DuneDiagnostics = struct +module ExtendedHover = struct type t = { enable : bool [@default true] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "ocaml-lsp-server/src/config_data.ml.DuneDiagnostics.t" in - function - | `Assoc field_yojsons as yojson -> - let enable_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "enable" -> - (match Ppx_yojson_conv_lib.( ! ) enable_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - enable_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let enable_value = Ppx_yojson_conv_lib.( ! ) enable_field in - { enable = - (match enable_value with - | Ppx_yojson_conv_lib.Option.None -> true - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { enable = v_enable } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_enable in - ("enable", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] end module SyntaxDocumentation = struct type t = { enable : bool [@default false] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "ocaml-lsp-server/src/config_data.ml.SyntaxDocumentation.t" in - function - | `Assoc field_yojsons as yojson -> - let enable_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "enable" -> - (match Ppx_yojson_conv_lib.( ! ) enable_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - enable_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let enable_value = Ppx_yojson_conv_lib.( ! ) enable_field in - { enable = - (match enable_value with - | Ppx_yojson_conv_lib.Option.None -> false - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { enable = v_enable } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_enable in - ("enable", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] + [@@deriving yojson] [@@yojson.allow_extra_fields] end -module MerlinJumpCodeActions = struct +module MerlinDiagnostics = struct type t = { enable : bool [@default false] } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = "ocaml-lsp-server/src/config_data.ml.MerlinJumpCodeActions.t" in - function - | `Assoc field_yojsons as yojson -> - let enable_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "enable" -> - (match Ppx_yojson_conv_lib.( ! ) enable_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = bool_of_yojson _field_yojson in - enable_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let enable_value = Ppx_yojson_conv_lib.( ! ) enable_field in - { enable = - (match enable_value with - | Ppx_yojson_conv_lib.Option.None -> false - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { enable = v_enable } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - let arg = yojson_of_bool v_enable in - ("enable", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; + [@@deriving yojson] [@@yojson.allow_extra_fields] +end - let _ = yojson_of_t +module ShortenMerlinDiagnostics = struct + type t = { enable : bool [@default false] } + [@@deriving yojson] [@@yojson.allow_extra_fields] +end - [@@@end] +module PpxCssColors = struct + type t = { enable : bool [@default true] } + [@@deriving yojson] [@@yojson.allow_extra_fields] end type t = { codelens : Lens.t Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] ; extended_hover : ExtendedHover.t Json.Nullable_option.t - [@key "extendedHover"] [@default None] [@yojson_drop_default ( = )] - ; standard_hover : StandardHover.t Json.Nullable_option.t - [@key "standardHover"] [@default None] [@yojson_drop_default ( = )] + [@key "extendedHover"] [@default None] [@yojson_drop_default ( = )] ; inlay_hints : InlayHints.t Json.Nullable_option.t - [@key "inlayHints"] [@default None] [@yojson_drop_default ( = )] - ; dune_diagnostics : DuneDiagnostics.t Json.Nullable_option.t - [@key "duneDiagnostics"] [@default None] [@yojson_drop_default ( = )] + [@key "inlayHints"] [@default None] [@yojson_drop_default ( = )] ; syntax_documentation : SyntaxDocumentation.t Json.Nullable_option.t - [@key "syntaxDocumentation"] [@default None] [@yojson_drop_default ( = )] - ; merlin_jump_code_actions : MerlinJumpCodeActions.t Json.Nullable_option.t - [@key "merlinJumpCodeActions"] [@default None] [@yojson_drop_default ( = )] - ; shorten_merlin_diagnostics : ShortenMerlinDiagnostics.t Json.Nullable_option.t - [@key "shortenMerlinDiagnostics"] [@default None] [@yojson_drop_default ( = )] + [@key "syntaxDocumentation"] [@default None] [@yojson_drop_default ( = )] + ; merlin_diagnostics : MerlinDiagnostics.t Json.Nullable_option.t + [@key "merlinDiagnostics"] [@default None] [@yojson_drop_default ( = )] + ; shorten_merlin_diagnostics : MerlinDiagnostics.t Json.Nullable_option.t + [@key "shortenMerlinDiagnostics"] [@default None] [@yojson_drop_default ( = )] + ; ppx_css_colors : PpxCssColors.t Json.Nullable_option.t + [@key "ppxCssColors"] [@default None] [@yojson_drop_default ( = )] } -[@@deriving_inline yojson] [@@yojson.allow_extra_fields] - -let _ = fun (_ : t) -> () - -let t_of_yojson = - (let _tp_loc = "ocaml-lsp-server/src/config_data.ml.t" in - function - | `Assoc field_yojsons as yojson -> - let codelens_field = ref Ppx_yojson_conv_lib.Option.None - and extended_hover_field = ref Ppx_yojson_conv_lib.Option.None - and standard_hover_field = ref Ppx_yojson_conv_lib.Option.None - and inlay_hints_field = ref Ppx_yojson_conv_lib.Option.None - and dune_diagnostics_field = ref Ppx_yojson_conv_lib.Option.None - and syntax_documentation_field = ref Ppx_yojson_conv_lib.Option.None - and merlin_jump_code_actions_field = ref Ppx_yojson_conv_lib.Option.None - and shorten_merlin_diagnostics_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "codelens" -> - (match Ppx_yojson_conv_lib.( ! ) codelens_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson Lens.t_of_yojson _field_yojson - in - codelens_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "extendedHover" -> - (match Ppx_yojson_conv_lib.( ! ) extended_hover_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson ExtendedHover.t_of_yojson _field_yojson - in - extended_hover_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "standardHover" -> - (match Ppx_yojson_conv_lib.( ! ) standard_hover_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson StandardHover.t_of_yojson _field_yojson - in - standard_hover_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "inlayHints" -> - (match Ppx_yojson_conv_lib.( ! ) inlay_hints_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson InlayHints.t_of_yojson _field_yojson - in - inlay_hints_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "duneDiagnostics" -> - (match Ppx_yojson_conv_lib.( ! ) dune_diagnostics_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - DuneDiagnostics.t_of_yojson - _field_yojson - in - dune_diagnostics_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "syntaxDocumentation" -> - (match Ppx_yojson_conv_lib.( ! ) syntax_documentation_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - SyntaxDocumentation.t_of_yojson - _field_yojson - in - syntax_documentation_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "merlinJumpCodeActions" -> - (match Ppx_yojson_conv_lib.( ! ) merlin_jump_code_actions_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - MerlinJumpCodeActions.t_of_yojson - _field_yojson - in - merlin_jump_code_actions_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "shortenMerlinDiagnostics" -> - (match Ppx_yojson_conv_lib.( ! ) shorten_merlin_diagnostics_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson - ShortenMerlinDiagnostics.t_of_yojson - _field_yojson - in - shorten_merlin_diagnostics_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - let ( codelens_value - , extended_hover_value - , standard_hover_value - , inlay_hints_value - , dune_diagnostics_value - , syntax_documentation_value - , merlin_jump_code_actions_value - , shorten_merlin_diagnostics_value ) - = - ( Ppx_yojson_conv_lib.( ! ) codelens_field - , Ppx_yojson_conv_lib.( ! ) extended_hover_field - , Ppx_yojson_conv_lib.( ! ) standard_hover_field - , Ppx_yojson_conv_lib.( ! ) inlay_hints_field - , Ppx_yojson_conv_lib.( ! ) dune_diagnostics_field - , Ppx_yojson_conv_lib.( ! ) syntax_documentation_field - , Ppx_yojson_conv_lib.( ! ) merlin_jump_code_actions_field - , Ppx_yojson_conv_lib.( ! ) shorten_merlin_diagnostics_field ) - in - { codelens = - (match codelens_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; extended_hover = - (match extended_hover_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; standard_hover = - (match standard_hover_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; inlay_hints = - (match inlay_hints_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; dune_diagnostics = - (match dune_diagnostics_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; syntax_documentation = - (match syntax_documentation_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; merlin_jump_code_actions = - (match merlin_jump_code_actions_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - ; shorten_merlin_diagnostics = - (match shorten_merlin_diagnostics_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - })) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) -;; - -let _ = t_of_yojson - -let yojson_of_t = - (function - | { codelens = v_codelens - ; extended_hover = v_extended_hover - ; standard_hover = v_standard_hover - ; inlay_hints = v_inlay_hints - ; dune_diagnostics = v_dune_diagnostics - ; syntax_documentation = v_syntax_documentation - ; merlin_jump_code_actions = v_merlin_jump_code_actions - ; shorten_merlin_diagnostics = v_shorten_merlin_diagnostics - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_shorten_merlin_diagnostics - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ShortenMerlinDiagnostics.yojson_of_t) - v_shorten_merlin_diagnostics - in - let bnd = "shortenMerlinDiagnostics", arg in - bnd :: bnds) - in - let bnds = - if None = v_merlin_jump_code_actions - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t MerlinJumpCodeActions.yojson_of_t) - v_merlin_jump_code_actions - in - let bnd = "merlinJumpCodeActions", arg in - bnd :: bnds) - in - let bnds = - if None = v_syntax_documentation - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t SyntaxDocumentation.yojson_of_t) - v_syntax_documentation - in - let bnd = "syntaxDocumentation", arg in - bnd :: bnds) - in - let bnds = - if None = v_dune_diagnostics - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t DuneDiagnostics.yojson_of_t) - v_dune_diagnostics - in - let bnd = "duneDiagnostics", arg in - bnd :: bnds) - in - let bnds = - if None = v_inlay_hints - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t InlayHints.yojson_of_t) v_inlay_hints - in - let bnd = "inlayHints", arg in - bnd :: bnds) - in - let bnds = - if None = v_standard_hover - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t StandardHover.yojson_of_t) v_standard_hover - in - let bnd = "standardHover", arg in - bnd :: bnds) - in - let bnds = - if None = v_extended_hover - then bnds - else ( - let arg = - (Json.Nullable_option.yojson_of_t ExtendedHover.yojson_of_t) v_extended_hover - in - let bnd = "extendedHover", arg in - bnd :: bnds) - in - let bnds = - if None = v_codelens - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t Lens.yojson_of_t) v_codelens in - let bnd = "codelens", arg in - bnd :: bnds) - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) -;; - -let _ = yojson_of_t - -[@@@end] +[@@deriving yojson] [@@yojson.allow_extra_fields] let default = { codelens = Some { enable = false } - ; extended_hover = Some { enable = false } - ; standard_hover = Some { enable = true } + ; extended_hover = Some { enable = true } ; inlay_hints = Some { hint_pattern_variables = false ; hint_let_bindings = false ; hint_function_params = false + ; hint_let_syntax_ppx = false } - ; dune_diagnostics = Some { enable = true } ; syntax_documentation = Some { enable = false } - ; merlin_jump_code_actions = Some { enable = false } + ; merlin_diagnostics = Some { enable = false } ; shorten_merlin_diagnostics = Some { enable = false } + ; ppx_css_colors = Some { enable = true } } ;; diff --git a/ocaml-lsp-server/src/configuration.ml b/ocaml-lsp-server/src/configuration.ml index 15ff44dcf..b8b8a6f1f 100644 --- a/ocaml-lsp-server/src/configuration.ml +++ b/ocaml-lsp-server/src/configuration.ml @@ -46,18 +46,31 @@ let update t { DidChangeConfigurationParams.settings } = let* () = Lev_fiber.Timer.Wheel.set_delay t.wheel ~delay in Fiber.return t.wheel in - let data = Config_data.t_of_yojson settings in + let data = + let new_data = Config_data.t_of_yojson settings in + let merge x y = Option.merge x y ~f:(fun _ y -> y) in + { Config_data.codelens = merge t.data.codelens new_data.codelens + ; extended_hover = merge t.data.extended_hover new_data.extended_hover + ; merlin_diagnostics = merge t.data.merlin_diagnostics new_data.merlin_diagnostics + ; inlay_hints = merge t.data.inlay_hints new_data.inlay_hints + ; syntax_documentation = + merge t.data.syntax_documentation new_data.syntax_documentation + ; shorten_merlin_diagnostics = + merge t.data.shorten_merlin_diagnostics new_data.shorten_merlin_diagnostics + ; ppx_css_colors = merge t.data.ppx_css_colors new_data.ppx_css_colors + } + in Fiber.return { wheel; data } ;; -let report_dune_diagnostics t = - match t.data.dune_diagnostics with - | Some { enable = true } | None -> true - | Some { enable = false } -> false +let display_merlin_diagnostics t = + match t.data.merlin_diagnostics with + | Some { enable = true } -> true + | Some { enable = false } | None -> false ;; let shorten_merlin_diagnostics t = match t.data.shorten_merlin_diagnostics with - | Some { enable = true } -> true - | Some { enable = false } | None -> false + | Some { enable = true } | None -> true + | Some { enable = false } -> false ;; diff --git a/ocaml-lsp-server/src/configuration.mli b/ocaml-lsp-server/src/configuration.mli index 87e8052ac..1a080d9c1 100644 --- a/ocaml-lsp-server/src/configuration.mli +++ b/ocaml-lsp-server/src/configuration.mli @@ -8,5 +8,5 @@ type t = val default : unit -> t Fiber.t val wheel : t -> Lev_fiber.Timer.Wheel.t val update : t -> DidChangeConfigurationParams.t -> t Fiber.t -val report_dune_diagnostics : t -> bool +val display_merlin_diagnostics : t -> bool val shorten_merlin_diagnostics : t -> bool diff --git a/ocaml-lsp-server/src/custom_requests/custom_request.ml b/ocaml-lsp-server/src/custom_request.ml similarity index 69% rename from ocaml-lsp-server/src/custom_requests/custom_request.ml rename to ocaml-lsp-server/src/custom_request.ml index 0152afe10..ae76394dd 100644 --- a/ocaml-lsp-server/src/custom_requests/custom_request.ml +++ b/ocaml-lsp-server/src/custom_request.ml @@ -1,12 +1,8 @@ -module Construct = Req_construct module Hover_extended = Req_hover_extended module Infer_intf = Req_infer_intf module Merlin_call_compatible = Req_merlin_call_compatible module Switch_impl_intf = Req_switch_impl_intf module Typed_holes = Req_typed_holes -module Jump_to_typed_hole = Req_jump_to_typed_hole module Type_enclosing = Req_type_enclosing module Wrapping_ast_node = Req_wrapping_ast_node module Get_documentation = Req_get_documentation -module Type_search = Req_type_search -module Merlin_jump = Req_merlin_jump diff --git a/ocaml-lsp-server/src/custom_requests/custom_request.mli b/ocaml-lsp-server/src/custom_request.mli similarity index 71% rename from ocaml-lsp-server/src/custom_requests/custom_request.mli rename to ocaml-lsp-server/src/custom_request.mli index 13027eb59..1033883bc 100644 --- a/ocaml-lsp-server/src/custom_requests/custom_request.mli +++ b/ocaml-lsp-server/src/custom_request.mli @@ -1,14 +1,10 @@ (** {1 Exposed Custom Request} *) -module Construct = Req_construct module Hover_extended = Req_hover_extended module Infer_intf = Req_infer_intf module Merlin_call_compatible = Req_merlin_call_compatible module Switch_impl_intf = Req_switch_impl_intf module Typed_holes = Req_typed_holes -module Jump_to_typed_hole = Req_jump_to_typed_hole module Type_enclosing = Req_type_enclosing module Wrapping_ast_node = Req_wrapping_ast_node module Get_documentation = Req_get_documentation -module Type_search = Req_type_search -module Merlin_jump = Req_merlin_jump diff --git a/ocaml-lsp-server/src/custom_requests/req_construct.ml b/ocaml-lsp-server/src/custom_requests/req_construct.ml deleted file mode 100644 index 28a297030..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_construct.ml +++ /dev/null @@ -1,111 +0,0 @@ -open Import - -let capability = "handleConstruct", `Bool true -let meth = "ocamllsp/construct" - -module Request_params = struct - type t = - { text_document : TextDocumentIdentifier.t - ; position : Position.t - ; depth : int option - ; with_values : [ `None | `Local ] option - } - - let create ?with_values ?depth ~text_document ~position () = - { text_document; position; with_values; depth } - ;; - - let yojson_of_with_values = function - | Some `Local -> `String "local" - | Some `None -> `String "none" - | None -> `Null - ;; - - let yojson_of_t { text_document; position; with_values; depth } = - match TextDocumentIdentifier.yojson_of_t text_document with - | `Assoc assoc -> - let depth = - ( "depth" - , match depth with - | None -> `Null - | Some x -> `Int x ) - in - let with_values = "withValues", yojson_of_with_values with_values in - let position = "position", Position.yojson_of_t position in - `Assoc (depth :: with_values :: position :: assoc) - | _ -> (* unreachable *) assert false - ;; - - let with_values_of_yojson json = - let open Yojson.Safe.Util in - json - |> member "withValues" - |> to_string_option - |> Option.bind ~f:(fun value -> - match String.(lowercase_ascii @@ trim value) with - | "none" -> Some `None - | "local" -> Some `Local - | _ -> None) - ;; - - let t_of_yojson json = - let open Yojson.Safe.Util in - let text_document = json |> TextDocumentIdentifier.t_of_yojson in - let position = json |> member "position" |> Position.t_of_yojson in - let depth = json |> member "depth" |> to_int_option in - let with_values = json |> with_values_of_yojson in - create ?with_values ?depth ~text_document ~position () - ;; -end - -type t = - { position : Range.t - ; result : string list - } - -let t_of_yojson json = - let open Yojson.Safe.Util in - let position = json |> member "position" |> Range.t_of_yojson in - let result = json |> member "result" |> to_list |> List.map ~f:to_string in - { position; result } -;; - -let yojson_of_t { position; result } = - `Assoc - [ "position", Range.yojson_of_t position - ; "result", `List (List.map ~f:(fun x -> `String x) result) - ] -;; - -let with_pipeline state uri f = - let doc = Document_store.get state.State.store uri in - match Document.kind doc with - | `Other -> Fiber.return `Null - | `Merlin merlin -> - (match Document.Merlin.kind merlin with - | Document.Kind.Intf -> - (* Construct makes no sense if its called from an interface. *) - Fiber.return `Null - | Document.Kind.Impl -> Document.Merlin.with_pipeline_exn merlin f) -;; - -let make_construct_command position with_values depth = - Query_protocol.Construct (position, with_values, depth) -;; - -let dispatch_construct position with_values depth pipeline = - let position = Position.logical position in - let command = make_construct_command position with_values depth in - let pos, result = Query_commands.dispatch pipeline command in - yojson_of_t { position = Range.of_loc pos; result } -;; - -let on_request ~params state = - Fiber.of_thunk (fun () -> - let params = (Option.value ~default:(`Assoc []) params :> Json.t) in - let Request_params.{ text_document; position; with_values; depth } = - Request_params.t_of_yojson params - in - let uri = text_document.uri in - with_pipeline state uri @@ dispatch_construct position with_values depth) -;; diff --git a/ocaml-lsp-server/src/custom_requests/req_construct.mli b/ocaml-lsp-server/src/custom_requests/req_construct.mli deleted file mode 100644 index d74fd8037..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_construct.mli +++ /dev/null @@ -1,22 +0,0 @@ -open Import - -module Request_params : sig - type t - - val create - : ?with_values:[ `None | `Local ] - -> ?depth:int - -> text_document:Lsp.Types.TextDocumentIdentifier.t - -> position:Position.t - -> unit - -> t - - val yojson_of_t : t -> Json.t -end - -type t - -val t_of_yojson : Json.t -> t -val capability : string * Json.t -val meth : string -val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_hover_extended.ml b/ocaml-lsp-server/src/custom_requests/req_hover_extended.ml deleted file mode 100644 index b6ccd15a2..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_hover_extended.ml +++ /dev/null @@ -1,186 +0,0 @@ -open Import -open Fiber.O - -let capability = "handleHoverExtended", `Bool true -let meth = "ocamllsp/hoverExtended" - -module Request_params = struct - open Json.Conv - - type t = - { text_document : TextDocumentIdentifier.t [@key "textDocument"] - ; cursor_position : Position.t [@key "position"] - ; verbosity : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] - } - [@@deriving_inline yojson] [@@yojson.allow_extra_fields] - - let _ = fun (_ : t) -> () - - let t_of_yojson = - (let _tp_loc = - "ocaml-lsp-server/src/custom_requests/req_hover_extended.ml.Request_params.t" - in - function - | `Assoc field_yojsons as yojson -> - let text_document_field = ref Ppx_yojson_conv_lib.Option.None - and cursor_position_field = ref Ppx_yojson_conv_lib.Option.None - and verbosity_field = ref Ppx_yojson_conv_lib.Option.None - and duplicates = ref [] - and extra = ref [] in - let rec iter = function - | (field_name, _field_yojson) :: tail -> - (match field_name with - | "textDocument" -> - (match Ppx_yojson_conv_lib.( ! ) text_document_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = TextDocumentIdentifier.t_of_yojson _field_yojson in - text_document_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "position" -> - (match Ppx_yojson_conv_lib.( ! ) cursor_position_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = Position.t_of_yojson _field_yojson in - cursor_position_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | "verbosity" -> - (match Ppx_yojson_conv_lib.( ! ) verbosity_field with - | Ppx_yojson_conv_lib.Option.None -> - let fvalue = - Json.Nullable_option.t_of_yojson int_of_yojson _field_yojson - in - verbosity_field := Ppx_yojson_conv_lib.Option.Some fvalue - | Ppx_yojson_conv_lib.Option.Some _ -> - duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates) - | _ -> ()); - iter tail - | [] -> () - in - iter field_yojsons; - (match Ppx_yojson_conv_lib.( ! ) duplicates with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_duplicate_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) duplicates) - yojson - | [] -> - (match Ppx_yojson_conv_lib.( ! ) extra with - | _ :: _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_extra_fields - _tp_loc - (Ppx_yojson_conv_lib.( ! ) extra) - yojson - | [] -> - (match - ( Ppx_yojson_conv_lib.( ! ) text_document_field - , Ppx_yojson_conv_lib.( ! ) cursor_position_field - , Ppx_yojson_conv_lib.( ! ) verbosity_field ) - with - | ( Ppx_yojson_conv_lib.Option.Some text_document_value - , Ppx_yojson_conv_lib.Option.Some cursor_position_value - , verbosity_value ) -> - { text_document = text_document_value - ; cursor_position = cursor_position_value - ; verbosity = - (match verbosity_value with - | Ppx_yojson_conv_lib.Option.None -> None - | Ppx_yojson_conv_lib.Option.Some v -> v) - } - | _ -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_undefined_elements - _tp_loc - yojson - [ ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) text_document_field) - Ppx_yojson_conv_lib.Option.None - , "text_document" ) - ; ( Ppx_yojson_conv_lib.poly_equal - (Ppx_yojson_conv_lib.( ! ) cursor_position_field) - Ppx_yojson_conv_lib.Option.None - , "cursor_position" ) - ]))) - | _ as yojson -> - Ppx_yojson_conv_lib.Yojson_conv_error.record_list_instead_atom _tp_loc yojson - : Ppx_yojson_conv_lib.Yojson.Safe.t -> t) - ;; - - let _ = t_of_yojson - - let yojson_of_t = - (function - | { text_document = v_text_document - ; cursor_position = v_cursor_position - ; verbosity = v_verbosity - } -> - let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in - let bnds = - if None = v_verbosity - then bnds - else ( - let arg = (Json.Nullable_option.yojson_of_t yojson_of_int) v_verbosity in - let bnd = "verbosity", arg in - bnd :: bnds) - in - let bnds = - let arg = Position.yojson_of_t v_cursor_position in - ("position", arg) :: bnds - in - let bnds = - let arg = TextDocumentIdentifier.yojson_of_t v_text_document in - ("textDocument", arg) :: bnds - in - `Assoc bnds - : t -> Ppx_yojson_conv_lib.Yojson.Safe.t) - ;; - - let _ = yojson_of_t - - [@@@end] - - let create ?verbosity ~text_document ~cursor_position () = - { text_document; cursor_position; verbosity } - ;; - - let params_schema = - `Assoc - [ "textDocument", `String "" - ; "position", `String "" - ; "verbosity", `String "" - ] - ;; - - let of_jsonrpc_params params = - try Some (t_of_yojson (Jsonrpc.Structured.yojson_of_t params)) with - | _exn -> None - ;; - - let of_jsonrpc_params_exn params : t = - let params_spec = Util.{ params_schema; of_jsonrpc_params } in - Util.of_jsonrpc_params_exn params_spec params - ;; -end - -type t = Hover.t - -let t_of_yojson = Hover.t_of_yojson - -let on_request ~(params : Jsonrpc.Structured.t option) (server : State.t Server.t) = - let { Request_params.text_document; cursor_position; verbosity } = - Request_params.of_jsonrpc_params_exn params - in - let+ res = - Hover_req.handle - server - { HoverParams.textDocument = text_document - ; position = cursor_position - ; workDoneToken = None - } - (match verbosity with - | None -> Hover_req.Extended_variable - | Some v -> Hover_req.Extended_fixed v) - in - match res with - | None -> `Null - | Some res -> Hover.yojson_of_t res -;; diff --git a/ocaml-lsp-server/src/custom_requests/req_hover_extended.mli b/ocaml-lsp-server/src/custom_requests/req_hover_extended.mli deleted file mode 100644 index 87c8a6301..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_hover_extended.mli +++ /dev/null @@ -1,21 +0,0 @@ -open Import - -module Request_params : sig - type t - - val create - : ?verbosity:int - -> text_document:Lsp.Types.TextDocumentIdentifier.t - -> cursor_position:Position.t - -> unit - -> t - - val yojson_of_t : t -> Json.t -end - -type t - -val t_of_yojson : Json.t -> t -val capability : string * Json.t -val meth : string -val on_request : params:Jsonrpc.Structured.t option -> State.t Server.t -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_infer_intf.mli b/ocaml-lsp-server/src/custom_requests/req_infer_intf.mli deleted file mode 100644 index 4afe187cb..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_infer_intf.mli +++ /dev/null @@ -1,5 +0,0 @@ -open Import - -val capability : string * Json.t -val meth : string -val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_jump_to_typed_hole.ml b/ocaml-lsp-server/src/custom_requests/req_jump_to_typed_hole.ml deleted file mode 100644 index 2a2452c62..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_jump_to_typed_hole.ml +++ /dev/null @@ -1,89 +0,0 @@ -open Import - -let capability = "handleJumpToTypedHole", `Bool true -let meth = "ocamllsp/jumpToTypedHole" - -module Request_params = struct - type t = - { text_document : TextDocumentIdentifier.t - ; position : Position.t - ; range : Range.t option - ; direction : [ `Next | `Prev ] - } - - let create ?(direction = `Next) ?range ~text_document ~position () = - { text_document; position; direction; range } - ;; - - let yojson_of_direction = function - | `Next -> `String "next" - | `Prev -> `String "prev" - ;; - - let yojson_of_t { text_document; position; direction; range } = - match TextDocumentIdentifier.yojson_of_t text_document with - | `Assoc assoc -> - let position = "position", Position.yojson_of_t position in - let range = - ( "range" - , match range with - | None -> `Null - | Some r -> Range.yojson_of_t r ) - in - let direction = "direction", yojson_of_direction direction in - `Assoc (direction :: position :: range :: assoc) - | _ -> (* unreachable *) assert false - ;; - - let direction_of_yojson json = - let open Yojson.Safe.Util in - let dir = json |> member "direction" |> to_string in - match String.lowercase_ascii dir with - | "prev" -> `Prev - | _ -> `Next - ;; - - let t_of_yojson json = - let open Yojson.Safe.Util in - let text_document = TextDocumentIdentifier.t_of_yojson json in - let position = json |> member "position" |> Position.t_of_yojson in - let direction = direction_of_yojson json in - let range = json |> member "range" |> to_option Range.t_of_yojson in - { text_document; position; direction; range } - ;; -end - -type t = Range.t option - -let t_of_yojson opt = - let open Yojson.Safe.Util in - to_option Range.t_of_yojson opt -;; - -let yojson_of_t = function - | None -> `Null - | Some range -> Range.yojson_of_t range -;; - -let on_request ~(params : Jsonrpc.Structured.t option) (state : State.t) = - Fiber.of_thunk (fun () -> - let params = (Option.value ~default:(`Assoc []) params :> Json.t) in - let Request_params.{ text_document = { uri }; position; direction; range } = - Request_params.t_of_yojson params - in - match Document_store.get_opt state.store uri with - | Some doc -> - let open Fiber.O in - let merlin = Document.merlin_exn doc in - let+ holes = Typed_hole.all ~pipeline_name:"jump-to-typed-hole" merlin in - holes |> Typed_hole.find ~position ~range ~direction |> yojson_of_t - | None -> - Jsonrpc.Response.Error.raise - @@ Jsonrpc.Response.Error.make - ~code:Jsonrpc.Response.Error.Code.InvalidParams - ~message: - (Printf.sprintf - "Document %s wasn't found in the document store" - (Uri.to_string uri)) - ()) -;; diff --git a/ocaml-lsp-server/src/custom_requests/req_jump_to_typed_hole.mli b/ocaml-lsp-server/src/custom_requests/req_jump_to_typed_hole.mli deleted file mode 100644 index 4abf3e951..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_jump_to_typed_hole.mli +++ /dev/null @@ -1,22 +0,0 @@ -open Import - -module Request_params : sig - type t - - val create - : ?direction:[ `Next | `Prev ] - -> ?range:Range.t - -> text_document:Lsp.Types.TextDocumentIdentifier.t - -> position:Position.t - -> unit - -> t - - val yojson_of_t : t -> Json.t -end - -type t - -val t_of_yojson : Json.t -> t -val capability : string * Json.t -val meth : string -val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_merlin_jump.ml b/ocaml-lsp-server/src/custom_requests/req_merlin_jump.ml deleted file mode 100644 index 1c84f81e7..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_merlin_jump.ml +++ /dev/null @@ -1,104 +0,0 @@ -open Import -module TextDocumentPositionParams = Lsp.Types.TextDocumentPositionParams - -let meth = "ocamllsp/jump" -let capability = "handleJump", `Bool true - -module JumpParams = struct - let targets = - [ "fun" - ; "match" - ; "let" - ; "module" - ; "module-type" - ; "match-next-case" - ; "match-prev-case" - ] - ;; - - type t = - { textDocument : TextDocumentIdentifier.t - ; position : Position.t - ; target : string option - } - - let t_of_yojson json = - let open Yojson.Safe.Util in - { textDocument = json |> member "textDocument" |> TextDocumentIdentifier.t_of_yojson - ; position = json |> member "position" |> Position.t_of_yojson - ; target = json |> member "target" |> to_string_option - } - ;; - - let yojson_of_t { textDocument; position; target } = - let target = - Option.value_map target ~default:[] ~f:(fun v -> [ "target", `String v ]) - in - `Assoc - (("textDocument", TextDocumentIdentifier.yojson_of_t textDocument) - :: ("position", Position.yojson_of_t position) - :: target) - ;; -end - -module Jump = struct - type t = (string * Position.t) list - - let yojson_of_t (lst : t) : Yojson.Safe.t = - let jumps = - List.map - ~f:(fun (target, position) -> - `Assoc [ "target", `String target; "position", Position.yojson_of_t position ]) - lst - in - `Assoc [ "jumps", `List jumps ] - ;; -end - -type t = Jump.t - -module Request_params = struct - type t = JumpParams.t - - let yojson_of_t t = JumpParams.yojson_of_t t - - let create ~uri ~position ~target = - { JumpParams.textDocument = TextDocumentIdentifier.create ~uri; position; target } - ;; -end - -let dispatch ~merlin ~position ~target = - Document.Merlin.with_pipeline_exn merlin (fun pipeline -> - let pposition = Position.logical position in - let query = Query_protocol.Jump (target, pposition) in - Query_commands.dispatch pipeline query) -;; - -let on_request ~params state = - let open Fiber.O in - Fiber.of_thunk (fun () -> - let params = (Option.value ~default:(`Assoc []) params :> Yojson.Safe.t) in - let params = JumpParams.t_of_yojson params in - let uri = params.textDocument.uri in - let position = params.position in - let doc = Document_store.get state.State.store uri in - match Document.kind doc with - | `Other -> Fiber.return `Null - | `Merlin merlin -> - let targets = - match params.target with - | None -> JumpParams.targets - | Some target -> [ target ] - in - let+ results = - Fiber.parallel_map targets ~f:(fun target -> - dispatch ~merlin ~position ~target - |> Fiber.map ~f:(function - | `Error _ -> None - | `Found pos -> - (match Position.of_lexical_position pos with - | None -> None - | Some position -> Some (target, position)))) - in - Jump.yojson_of_t (List.filter_map results ~f:Fun.id)) -;; diff --git a/ocaml-lsp-server/src/custom_requests/req_merlin_jump.mli b/ocaml-lsp-server/src/custom_requests/req_merlin_jump.mli deleted file mode 100644 index 95a9002d3..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_merlin_jump.mli +++ /dev/null @@ -1,14 +0,0 @@ -open Import - -module Request_params : sig - type t - - val yojson_of_t : t -> Json.t - val create : uri:DocumentUri.t -> position:Position.t -> target:string option -> t -end - -type t - -val meth : string -val capability : string * [> `Bool of bool ] -val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_type_search.ml b/ocaml-lsp-server/src/custom_requests/req_type_search.ml deleted file mode 100644 index 215280ec4..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_type_search.ml +++ /dev/null @@ -1,119 +0,0 @@ -open Import -module TextDocumentPositionParams = Lsp.Types.TextDocumentPositionParams - -let meth = "ocamllsp/typeSearch" -let capability = "handleTypeSearch", `Bool true - -module TypeSearchParams = struct - type t = - { text_document : TextDocumentIdentifier.t - ; position : Position.t - ; limit : int - ; query : string - ; with_doc : bool - ; doc_format : MarkupKind.t option - } - - let t_of_yojson json = - let open Yojson.Safe.Util in - let textDocumentPosition = Lsp.Types.TextDocumentPositionParams.t_of_yojson json in - let query = json |> member "query" |> to_string in - let limit = json |> member "limit" |> to_int in - let with_doc = json |> member "with_doc" |> to_bool in - let doc_format = json |> member "doc_format" |> to_option MarkupKind.t_of_yojson in - { position = textDocumentPosition.position - ; text_document = textDocumentPosition.textDocument - ; query - ; limit - ; with_doc - ; doc_format - } - ;; - - let yojson_of_t { text_document; position; query; limit; with_doc; doc_format } = - let doc_format = - match doc_format with - | Some format -> [ "doc_format", MarkupKind.yojson_of_t format ] - | None -> [] - in - `Assoc - (("textDocument", TextDocumentIdentifier.yojson_of_t text_document) - :: ("position", Position.yojson_of_t position) - :: ("limit", `Int limit) - :: ("with_doc", `Bool with_doc) - :: ("query", `String query) - :: doc_format) - ;; -end - -module TypeSearch = struct - type t = string Query_protocol.type_search_result list - - let doc_to_markupContent ~kind ~value = - let v = - match kind with - | MarkupKind.Markdown -> - (match Doc_to_md.translate value with - | Raw d -> d - | Markdown d -> d) - | MarkupKind.PlainText -> value - in - MarkupContent.create ~kind ~value:v - ;; - - let yojson_of_t (t : t) doc_format = - let format = - match doc_format with - | Some format -> format - | None -> MarkupKind.PlainText - in - let yojson_of_type_search_result (res : string Query_protocol.type_search_result) = - `Assoc - [ "name", `String res.name - ; "typ", `String res.typ - ; "loc", Range.yojson_of_t (Range.of_loc res.loc) - ; ( "doc" - , match res.doc with - | Some value -> - doc_to_markupContent ~kind:format ~value |> MarkupContent.yojson_of_t - | None -> `Null ) - ; "cost", `Int res.cost - ; "constructible", `String res.constructible - ] - in - `List (List.map ~f:yojson_of_type_search_result t) - ;; -end - -type t = TypeSearch.t - -module Request_params = struct - type t = TypeSearchParams.t - - let yojson_of_t t = TypeSearchParams.yojson_of_t t - - let create text_document position limit query with_doc doc_format : t = - { text_document; position; limit; query; with_doc; doc_format } - ;; -end - -let dispatch merlin position limit query with_doc doc_format = - Document.Merlin.with_pipeline_exn merlin (fun pipeline -> - let position = Position.logical position in - let query = Query_protocol.Type_search (query, position, limit, with_doc) in - let results = Query_commands.dispatch pipeline query in - TypeSearch.yojson_of_t results doc_format) -;; - -let on_request ~params state = - Fiber.of_thunk (fun () -> - let params = (Option.value ~default:(`Assoc []) params :> Yojson.Safe.t) in - let TypeSearchParams.{ text_document; position; limit; query; with_doc; doc_format } = - TypeSearchParams.t_of_yojson params - in - let uri = text_document.uri in - let doc = Document_store.get state.State.store uri in - match Document.kind doc with - | `Other -> Fiber.return `Null - | `Merlin merlin -> dispatch merlin position limit query with_doc doc_format) -;; diff --git a/ocaml-lsp-server/src/custom_requests/req_type_search.mli b/ocaml-lsp-server/src/custom_requests/req_type_search.mli deleted file mode 100644 index d17e5a82d..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_type_search.mli +++ /dev/null @@ -1,22 +0,0 @@ -open Import - -module Request_params : sig - type t - - val yojson_of_t : t -> Json.t - - val create - : TextDocumentIdentifier.t - -> Position.t - -> int - -> string - -> bool - -> MarkupKind.t option - -> t -end - -type t - -val meth : string -val capability : string * [> `Bool of bool ] -val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_typed_holes.ml b/ocaml-lsp-server/src/custom_requests/req_typed_holes.ml deleted file mode 100644 index c3b55d387..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_typed_holes.ml +++ /dev/null @@ -1,76 +0,0 @@ -open Import -open Fiber.O - -let capability = "handleTypedHoles", `Bool true -let meth = "ocamllsp/typedHoles" - -module Request_params = struct - type t = Uri.t - - (* Request params must have the form as in the given string. *) - let expected_params = `Assoc [ "uri", `String "" ] - let create uri = uri - - let t_of_structured_json params : t option = - match params with - | `Assoc [ ("uri", uri) ] -> - let uri = Uri.t_of_yojson uri in - Some uri - | _ -> None - ;; - - let parse_exn (params : Jsonrpc.Structured.t option) : t = - let raise_invalid_params ?data ~message () = - Jsonrpc.Response.Error.raise - @@ Jsonrpc.Response.Error.make - ?data - ~code:Jsonrpc.Response.Error.Code.InvalidParams - ~message - () - in - match params with - | None -> raise_invalid_params ~message:"Expected params but received none" () - | Some params -> - (match t_of_structured_json params with - | Some uri -> uri - | None -> - let error_json = - `Assoc - [ "params_expected", expected_params; "params_received", (params :> Json.t) ] - in - raise_invalid_params ~message:"Unxpected parameter format" ~data:error_json ()) - ;; - - let yojson_of_t = Uri.yojson_of_t -end - -type t = Range.t list - -let yojson_of_t holes = Json.yojson_of_list Range.yojson_of_t holes - -let t_of_yojson list = - let open Yojson.Safe.Util in - list |> to_list |> List.map ~f:(fun range -> range |> Range.t_of_yojson) -;; - -let on_request ~(params : Jsonrpc.Structured.t option) (state : State.t) = - Fiber.of_thunk (fun () -> - let uri = Request_params.parse_exn params in - let store = state.store in - let doc = Document_store.get_opt store uri in - match doc with - | None -> - Jsonrpc.Response.Error.raise - @@ Jsonrpc.Response.Error.make - ~code:Jsonrpc.Response.Error.Code.InvalidParams - ~message: - (Printf.sprintf - "Document %s wasn't found in the document store" - (Uri.to_string uri)) - () - | Some doc -> - let+ holes = - Typed_hole.all ~pipeline_name:"typed-holes" (Document.merlin_exn doc) - in - yojson_of_t holes) -;; diff --git a/ocaml-lsp-server/src/custom_requests/req_typed_holes.mli b/ocaml-lsp-server/src/custom_requests/req_typed_holes.mli deleted file mode 100644 index c6ae69590..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_typed_holes.mli +++ /dev/null @@ -1,15 +0,0 @@ -open Import - -module Request_params : sig - type t - - val create : Uri.t -> t - val yojson_of_t : t -> Json.t -end - -type t - -val t_of_yojson : Json.t -> t -val capability : string * Json.t -val meth : string -val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_wrapping_ast_node.mli b/ocaml-lsp-server/src/custom_requests/req_wrapping_ast_node.mli deleted file mode 100644 index 4afe187cb..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_wrapping_ast_node.mli +++ /dev/null @@ -1,5 +0,0 @@ -open Import - -val capability : string * Json.t -val meth : string -val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/util.ml b/ocaml-lsp-server/src/custom_requests/util.ml deleted file mode 100644 index bd56e7478..000000000 --- a/ocaml-lsp-server/src/custom_requests/util.ml +++ /dev/null @@ -1,30 +0,0 @@ -open Import - -type 't req_params_spec = - { params_schema : Jsonrpc.Structured.t - ; of_jsonrpc_params : Jsonrpc.Structured.t -> 't option - } - -let of_jsonrpc_params_exn spec params = - let raise_invalid_params ?data ~message () = - Jsonrpc.Response.Error.raise - @@ Jsonrpc.Response.Error.make - ?data - ~code:Jsonrpc.Response.Error.Code.InvalidParams - ~message - () - in - match params with - | None -> raise_invalid_params ~message:"Expected params but received none" () - | Some params -> - (match spec.of_jsonrpc_params params with - | Some t -> t - | None -> - let error_json = - `Assoc - [ "params_expected", (spec.params_schema :> Json.t) - ; "params_received", (params :> Json.t) - ] - in - raise_invalid_params ~message:"Unexpected parameter format" ~data:error_json ()) -;; diff --git a/ocaml-lsp-server/src/custom_requests/util.mli b/ocaml-lsp-server/src/custom_requests/util.mli deleted file mode 100644 index 3b50f9b1c..000000000 --- a/ocaml-lsp-server/src/custom_requests/util.mli +++ /dev/null @@ -1,13 +0,0 @@ -type 't req_params_spec = - { params_schema : Jsonrpc.Structured.t - (** used to document the structure of the params; example: - [`Assoc [ "uri" , `String "" ]]; *) - ; of_jsonrpc_params : Jsonrpc.Structured.t -> 't option - (** parses given structured JSON if it's of the expected schema; - otherwise, return [None] *) - } - -val of_jsonrpc_params_exn - : 'req_params req_params_spec - -> Jsonrpc.Structured.t option - -> 'req_params diff --git a/ocaml-lsp-server/src/definition_query.ml b/ocaml-lsp-server/src/definition_query.ml index e836f3e3b..f88de1796 100644 --- a/ocaml-lsp-server/src/definition_query.ml +++ b/ocaml-lsp-server/src/definition_query.ml @@ -2,20 +2,19 @@ open Import open Fiber.O let location_of_merlin_loc uri : _ -> (_, string) result = function - | `At_origin -> Error "Already at definition point" - | `Builtin s -> - Error (sprintf "%S is a builtin, it is not possible to jump to its definition" s) + | `At_origin -> Ok None + | `Builtin _ -> Ok None | `File_not_found s -> Error (sprintf "File_not_found: %s" s) - | `Invalid_context -> Error "Not a valid identifier" + | `Invalid_context -> Ok None | `Not_found (ident, where) -> let msg = - let msg = sprintf "%S not found." ident in + let msg = sprintf "%s not found." ident in match where with | None -> msg | Some w -> sprintf "%s last looked in %s" msg w in Error msg - | `Not_in_env m -> Error (sprintf "Not in environment: %s" m) + | `Not_in_env m -> Error (sprintf "not in environment: %s" m) | `Found (path, lex_position) -> Ok (Position.of_lexical_position lex_position @@ -30,20 +29,20 @@ let location_of_merlin_loc uri : _ -> (_, string) result = function `Location locs)) ;; -let run kind (state : State.t) uri position = +let run ~log_info kind (state : State.t) uri position = let* () = Fiber.return () in let doc = Document_store.get state.store uri in match Document.kind doc with | `Other -> Fiber.return None | `Merlin doc -> - let command, name = + let command = let pos = Position.logical position in match kind with - | `Definition -> Query_protocol.Locate (None, `ML, pos), "definition" - | `Declaration -> Query_protocol.Locate (None, `MLI, pos), "declaration" - | `Type_definition -> Query_protocol.Locate_type pos, "type definition" + | `Definition -> Query_protocol.Locate (None, `ML, pos, None) + | `Declaration -> Query_protocol.Locate (None, `MLI, pos, None) + | `Type_definition -> Query_protocol.Locate_type pos in - let* result = Document.Merlin.dispatch_exn ~name doc command in + let* result = Document.Merlin.dispatch_exn ~log_info doc command in (match location_of_merlin_loc uri result with | Ok s -> Fiber.return s | Error err_msg -> @@ -57,6 +56,7 @@ let run kind (state : State.t) uri position = (Jsonrpc.Response.Error.make ~code:Jsonrpc.Response.Error.Code.RequestFailed ~message:(sprintf "Request \"Jump to %s\" failed." kind) - ~data:(`String (sprintf "Locate: %s" err_msg)) + ~data: + (`String (sprintf "'Locate' query to merlin returned error: %s" err_msg)) ())) ;; diff --git a/ocaml-lsp-server/src/definition_query.mli b/ocaml-lsp-server/src/definition_query.mli index b1024439a..1e95743bc 100644 --- a/ocaml-lsp-server/src/definition_query.mli +++ b/ocaml-lsp-server/src/definition_query.mli @@ -1,7 +1,8 @@ open Import val run - : [ `Definition | `Declaration | `Type_definition ] + : log_info:Lsp_timing_logger.t + -> [ `Definition | `Declaration | `Type_definition ] -> State.t -> Uri.t -> Position.t diff --git a/ocaml-lsp-server/src/code_actions/diagnostic_util.ml b/ocaml-lsp-server/src/diagnostic_util.ml similarity index 100% rename from ocaml-lsp-server/src/code_actions/diagnostic_util.ml rename to ocaml-lsp-server/src/diagnostic_util.ml diff --git a/ocaml-lsp-server/src/diagnostics.ml b/ocaml-lsp-server/src/diagnostics.ml index c29c1de21..15714ca66 100644 --- a/ocaml-lsp-server/src/diagnostics.ml +++ b/ocaml-lsp-server/src/diagnostics.ml @@ -13,33 +13,12 @@ module Uri_c = Comparable.Make (Uri) module Uri_set = Uri_c.Set module Id = struct - include Drpc.Diagnostic.Id + include Drpc.V1.Diagnostic.Id let equal x y = compare x y = Eq let to_dyn = Dyn.opaque end -module Dune = struct - module Id = Stdune.Id.Make () - - module T = struct - type t = - { pid : Pid.t - ; id : Id.t - } - - let compare = Poly.compare - let equal x y = Ordering.is_eq (compare x y) - let hash = Poly.hash - let to_dyn = Dyn.opaque - end - - include T - module C = Comparable.Make (T) - - let gen pid = { pid; id = Id.gen () } -end - let equal_message = (* because the compiler and merlin wrap messages differently *) let is_space = function @@ -51,7 +30,19 @@ let equal_message = incr i done in + let remove_errno msg = + (* Sometimes errors (in my testing, specifically from Merlin) are prefixed with + "Error (warning ..): ..." while Dune errors are not. Perhaps it may be better + to investigate why this is, but it doesn't hurt to just filter that out. *) + match Re.Str.bounded_split (Re.Str.regexp "^Error (warning [0-9]+): ") msg 2 with + | [ rest ] -> rest + | _ -> msg + in fun m1 m2 -> + (* Merlin errors that are warnings start with a message of the form Error (warning ..) + while Dune errors omit that part - filter that out for the messages *) + let m1 = remove_errno m1 in + let m2 = remove_errno m2 in let i = ref 0 in let j = ref 0 in try @@ -79,21 +70,23 @@ let equal_message = ;; type t = - { dune : (Dune.t, (Drpc.Diagnostic.Id.t, Uri.t * Diagnostic.t) Table.t) Table.t + { dune : (Id.t, Uri.t * Diagnostic.t) Table.t ; merlin : (Uri.t, Diagnostic.t list) Table.t ; send : PublishDiagnosticsParams.t list -> unit Fiber.t ; mutable dirty_uris : Uri_set.t ; related_information : bool ; tags : DiagnosticTag.t list - ; mutable report_dune_diagnostics : bool + ; mutable display_merlin_diagnostics : bool ; mutable shorten_merlin_diagnostics : bool + ; client_name : string } let create - (capabilities : PublishDiagnosticsClientCapabilities.t option) - send - ~report_dune_diagnostics - ~shorten_merlin_diagnostics + (capabilities : PublishDiagnosticsClientCapabilities.t option) + send + ~display_merlin_diagnostics + ~shorten_merlin_diagnostics + ~client_name = let related_information, tags = match capabilities with @@ -104,46 +97,57 @@ let create | None -> [] | Some { valueSet } -> valueSet) ) in - { dune = Table.create (module Dune) 32 + { dune = Table.create (module Id) 32 ; merlin = Table.create (module Uri) 32 ; dirty_uris = Uri_set.empty ; send ; related_information ; tags - ; report_dune_diagnostics + ; display_merlin_diagnostics ; shorten_merlin_diagnostics + ; client_name = String.lowercase client_name } ;; let send = let module Range_map = Map.Make (Range) in (* TODO deduplicate related errors as well *) - let add_dune_diagnostic pending uri (diagnostic : Diagnostic.t) = - let value = - match Table.find pending uri with - | None -> Range_map.singleton diagnostic.range [ diagnostic ] - | Some map -> - Range_map.update map diagnostic.range ~f:(fun diagnostics -> - Some - (match diagnostics with - | None -> [ diagnostic ] - | Some diagnostics -> - if - List.exists diagnostics ~f:(fun (d : Diagnostic.t) -> - match d.source with - | None -> assert false - | Some source -> - String.equal ocamllsp_source source - && - (match d.message, diagnostic.message with - | `String m1, `String m2 -> equal_message m1 m2 - | `MarkupContent { kind; value }, `MarkupContent mc -> - Poly.equal kind mc.kind && equal_message value mc.value - | _, _ -> false)) - then diagnostics - else diagnostic :: diagnostics)) + (* Adds the provided diagnostic if and only if it's not one of the dune diagnostics at + that location *) + let add_merlin_diagnostic + t + ~dune_diagnostics_table + ~merlin_diagnostics_table + uri + (diagnostic : Diagnostic.t) + = + let merlin_diagnostics_for_file = + Table.find_or_add merlin_diagnostics_table uri ~f:(fun _ -> []) + in + let merlin_diagnostics_for_file = + let dune_map = + Table.find dune_diagnostics_table uri |> Option.value ~default:Range_map.empty + in + match Range_map.find dune_map diagnostic.range with + | None -> diagnostic :: merlin_diagnostics_for_file + | Some dune_diagnostics -> + if String.starts_with ~prefix:"vscode" t.client_name + && List.exists dune_diagnostics ~f:(fun (d : Diagnostic.t) -> + match d.source with + | None -> + failwith "BUG: source of a diagnostic was not set, when it should be" + | Some source -> + String.equal dune_source source + && + (match d.message, diagnostic.message with + | `String m1, `String m2 -> equal_message m1 m2 + | `MarkupContent { kind; value }, `MarkupContent mc -> + Poly.equal kind mc.kind && equal_message value mc.value + | _, _ -> false)) + then merlin_diagnostics_for_file + else diagnostic :: merlin_diagnostics_for_file in - Table.set pending uri value + Table.set merlin_diagnostics_table uri merlin_diagnostics_for_file in let range_map_of_unduplicated_diagnostics diagnostics = List.rev_map diagnostics ~f:(fun (d : Diagnostic.t) -> d.range, d) @@ -156,36 +160,39 @@ let send = | `All -> t.dirty_uris | `One uri -> Uri_set.singleton uri in - let pending = Table.create (module Uri) 4 in + let dune_diagnostics_table = Table.create (module Uri) 4 in + let merlin_diagnostics_table = Table.create (module Uri) 4 in Uri_set.iter dirty_uris ~f:(fun uri -> - let diagnostics = Table.Multi.find t.merlin uri in - Table.set pending uri (range_map_of_unduplicated_diagnostics diagnostics)); - let set_dune_source = - let annotate_dune_pid = Table.length t.dune > 1 in - if annotate_dune_pid + let just_uri = Uri_set.singleton uri in + let dune_diagnostics = + Table.fold + ~init:[] + ~f:(fun (diagnostic_uri, diagnostic) acc -> + if Uri_set.mem just_uri diagnostic_uri then diagnostic :: acc else acc) + t.dune + in + Table.set + dune_diagnostics_table + uri + (range_map_of_unduplicated_diagnostics dune_diagnostics); + Table.set merlin_diagnostics_table uri []); + Table.foldi ~init:() t.merlin ~f:(fun uri diagnostics () -> + if Uri_set.mem dirty_uris uri then - fun pid (d : Diagnostic.t) -> - let source = Some (sprintf "dune (pid=%d)" (Pid.to_int pid)) in - { d with source } - else fun _pid x -> x - in - if t.report_dune_diagnostics - then - Table.foldi ~init:() t.dune ~f:(fun dune per_dune () -> - Table.iter per_dune ~f:(fun (uri, diagnostic) -> - if Uri_set.mem dirty_uris uri - then ( - let diagnostic = set_dune_source dune.pid diagnostic in - add_dune_diagnostic pending uri diagnostic))); + List.iter diagnostics ~f:(fun diagnostic -> + add_merlin_diagnostic + t + ~dune_diagnostics_table + ~merlin_diagnostics_table + uri + diagnostic)); t.dirty_uris <- (match which with | `All -> Uri_set.empty | `One uri -> Uri_set.remove t.dirty_uris uri); - Table.foldi pending ~init:[] ~f:(fun uri diagnostics acc -> - let diagnostics = List.flatten (Range_map.values diagnostics) in - (* we don't include a version because some of the diagnostics might - come from dune which reads from the file system and not from the - editor's view *) + Table.foldi merlin_diagnostics_table ~init:[] ~f:(fun uri diagnostics acc -> + (* we don't include a version because some of the diagnostics might come from + dune which reads from the file system and not from the editor's view *) PublishDiagnosticsParams.create ~uri ~diagnostics () :: acc) |> t.send) ;; @@ -193,40 +200,26 @@ let send = let set t what = let uri = match what with - | `Dune (_, _, uri, _) -> uri + | `Dune (_, uri, _) -> uri | `Merlin (uri, _) -> uri in t.dirty_uris <- Uri_set.add t.dirty_uris uri; match what with | `Merlin (uri, diagnostics) -> Table.set t.merlin uri diagnostics - | `Dune (dune, id, uri, diagnostics) -> - let dune_table = - Table.find_or_add t.dune dune ~f:(fun _ -> Table.create (module Id) 16) - in - Table.set dune_table id (uri, diagnostics) + | `Dune (id, uri, diagnostics) -> Table.set t.dune id (uri, diagnostics) ;; let remove t = function - | `Dune (dune, diagnostic) -> - Table.find t.dune dune - |> Option.iter ~f:(fun dune -> - Table.find dune diagnostic - |> Option.iter ~f:(fun (uri, _) -> - Table.remove dune diagnostic; - t.dirty_uris <- Uri_set.add t.dirty_uris uri)) + | `Dune diagnostic -> + Table.find t.dune diagnostic + |> Option.iter ~f:(fun (uri, _) -> + Table.remove t.dune diagnostic; + t.dirty_uris <- Uri_set.add t.dirty_uris uri) | `Merlin uri -> t.dirty_uris <- Uri_set.add t.dirty_uris uri; Table.remove t.merlin uri ;; -let disconnect t dune = - Table.find t.dune dune - |> Option.iter ~f:(fun dune_diagnostics -> - Table.iter dune_diagnostics ~f:(fun (uri, _) -> - t.dirty_uris <- Uri_set.add t.dirty_uris uri); - Table.remove t.dune dune) -;; - let tags_of_message = let tags_of_message ~src message : DiagnosticTag.t option = match src with @@ -289,16 +282,16 @@ let extract_related_errors uri raw_message = | _ -> raw_message, None ;; -let first_n_lines_of_range (range : Range.t) n = +let first_n_lines_of_range (range : Range.t) n : Range.t = if range.end_.line - range.start.line < n then range - else ( - let start = Position.create ~character:range.start.character ~line:range.start.line - and end_ = Position.create ~character:0 ~line:(range.start.line + n) in - Range.create ~start ~end_) + else + { start = { character = range.start.character; line = range.start.line } + ; end_ = { character = 0; line = range.start.line + n } + } ;; -let error_to_diagnostics ~diagnostics ~merlin error = +let default_error_to_diagnostic ~diagnostics ~merlin ~error = let doc = Document.Merlin.to_doc merlin in let create_diagnostic = Diagnostic.create ~source:ocamllsp_source in let uri = Document.uri doc in @@ -316,7 +309,7 @@ let error_to_diagnostics ~diagnostics ~merlin error = in let make_message ppf m = String.trim (Format.asprintf "%a@." ppf m) in let message = make_message Loc.print_main error in - let message, related_information = + let message, relatedInformation = match diagnostics.related_information with | false -> message, None | true -> @@ -337,6 +330,11 @@ let error_to_diagnostics ~diagnostics ~merlin error = match diagnostics.shorten_merlin_diagnostics with | false -> None | true -> + (* NOTE: in VSCode, the message displayed for related information currently shows + only the start of the span. It's still possible to find the full span, so we've + opted not to send a second related-information with the end of the range, but in + the future we could look into changing how VSCode displays relatedInformation + ranges. *) let start_location = Location.create ~range:original_range ~uri in Some [ DiagnosticRelatedInformation.create @@ -345,7 +343,7 @@ let error_to_diagnostics ~diagnostics ~merlin error = ] in let relatedInformation = - Option.merge maybe_extra_range_information related_information ~f:( @ ) + Option.merge maybe_extra_range_information relatedInformation ~f:( @ ) in let tags = tags_of_message diagnostics ~src:`Merlin message in create_diagnostic @@ -357,72 +355,85 @@ let error_to_diagnostics ~diagnostics ~merlin error = () ;; -let merlin_diagnostics diagnostics merlin = +let query_merlin_for_diagnostics ~log_info diagnostics merlin = + let create_diagnostic ~message = + Diagnostic.create ~source:ocamllsp_source ~message:(`String message) + in + let command = Query_protocol.Errors { lexing = true; parsing = true; typing = true } in + Document.Merlin.with_pipeline_exn ~log_info merlin (fun pipeline -> + match Query_commands.dispatch pipeline command with + | exception Merlin_extend.Extend_main.Handshake.Error error -> + let message = + sprintf "%s.\nHint: install the following packages: merlin-extend, reason" error + in + [ create_diagnostic ~range:Range.first_line ~message () ] + | all_errors -> + let merlin_diagnostics = + match (Mpipeline.final_config pipeline).merlin.failures with + | [] -> + let syntax_diagnostics, typer_diagnostics = + Base.List.partition_map all_errors ~f:(fun (error : Loc.error) -> + let diagnostic = default_error_to_diagnostic ~diagnostics ~merlin ~error in + match error.source with + | Lexer | Parser -> First diagnostic + | _ -> Second diagnostic) + in + (* Only show syntax errors if there are any, otherwise show the other + diagnostics *) + (match syntax_diagnostics with + | [] -> + let holes_as_err_diags = + Query_commands.dispatch pipeline Holes + |> List.rev_map ~f:(fun (loc, typ) -> + let range = Range.of_loc loc in + let severity = DiagnosticSeverity.Error in + let message = + "This typed hole should be replaced with an expression of type " ^ typ + in + (* we set specific diagnostic code = "hole" to be able to filter + through diagnostics easily *) + create_diagnostic ~code:(`String "hole") ~range ~message ~severity ()) + in + (* Can we use [List.merge] instead? *) + List.rev_append holes_as_err_diags typer_diagnostics + | _ -> syntax_diagnostics) + | config_failures -> + List.map config_failures ~f:(fun failure -> + create_diagnostic ~range:Range.first_line ~message:failure ()) + in + List.sort + merlin_diagnostics + ~compare:(fun (d1 : Diagnostic.t) (d2 : Diagnostic.t) -> + Range.compare d1.range d2.range)) +;; + +let merlin_diagnostics ~log_info diagnostics merlin = + let open Fiber.O in let doc = Document.Merlin.to_doc merlin in let uri = Document.uri doc in - let create_diagnostic = Diagnostic.create ~source:ocamllsp_source in - let open Fiber.O in - let+ all_diagnostics = - let command = - Query_protocol.Errors { lexing = true; parsing = true; typing = true } - in - Document.Merlin.with_pipeline_exn ~name:"diagnostics" merlin (fun pipeline -> - match Query_commands.dispatch pipeline command with - | exception Merlin_extend.Extend_main.Handshake.Error error -> - let message = - `String - (sprintf - "%s.\nHint: install the following packages: merlin-extend, reason" - error) - in - [ create_diagnostic ~range:Range.first_line ~message () ] - | errors -> - let merlin_diagnostics = - List.rev_map errors ~f:(error_to_diagnostics ~diagnostics ~merlin) - in - let holes_as_err_diags = - Query_commands.dispatch pipeline Holes - |> List.rev_map ~f:(fun (loc, typ) -> - let range = Range.of_loc loc in - let severity = DiagnosticSeverity.Error in - let message = - "This typed hole should be replaced with an expression of type " ^ typ - in - (* we set specific diagnostic code = "hole" to be able to - filter through diagnostics easily *) - create_diagnostic - ~code:(`String "hole") - ~range - ~message:(`String message) - ~severity - ()) - in - (* Can we use [List.merge] instead? *) - List.rev_append holes_as_err_diags merlin_diagnostics - |> List.sort ~compare:(fun (d1 : Diagnostic.t) (d2 : Diagnostic.t) -> - Range.compare d1.range d2.range)) + let+ diagnostics_to_display = + match diagnostics.display_merlin_diagnostics with + | true -> query_merlin_for_diagnostics ~log_info diagnostics merlin + | false -> Fiber.return [] + in + set diagnostics (`Merlin (uri, diagnostics_to_display)) +;; + +let has_cached_errors diagnostics merlin = + let cached_diagnostics = + Document.Merlin.to_doc merlin |> Document.uri |> Table.find diagnostics.merlin in - set diagnostics (`Merlin (uri, all_diagnostics)) + match cached_diagnostics with + | None | Some [] -> false + | _ -> true ;; -let set_report_dune_diagnostics t ~report_dune_diagnostics = - if t.report_dune_diagnostics = report_dune_diagnostics - then Fiber.return () - else ( - t.report_dune_diagnostics <- report_dune_diagnostics; - Table.iter t.dune ~f:(fun per_dune -> - Table.iter per_dune ~f:(fun (uri, _diagnostic) -> - t.dirty_uris <- Uri_set.add t.dirty_uris uri)); - send t `All) +let set_display_merlin_diagnostics t ~display_merlin_diagnostics = + t.display_merlin_diagnostics <- display_merlin_diagnostics ;; let set_shorten_merlin_diagnostics t ~shorten_merlin_diagnostics = - if t.shorten_merlin_diagnostics = shorten_merlin_diagnostics - then Fiber.return () - else ( - t.shorten_merlin_diagnostics <- shorten_merlin_diagnostics; - Table.iter t.dune ~f:(fun per_dune -> - Table.iter per_dune ~f:(fun (uri, _diagnostic) -> - t.dirty_uris <- Uri_set.add t.dirty_uris uri)); - send t `All) + (* The ocaml-lsp ChangeConfiguration command handles re-sending diagnostics on configuration + changes *) + t.shorten_merlin_diagnostics <- shorten_merlin_diagnostics ;; diff --git a/ocaml-lsp-server/src/diagnostics.mli b/ocaml-lsp-server/src/diagnostics.mli index 618c02943..30fc1958e 100644 --- a/ocaml-lsp-server/src/diagnostics.mli +++ b/ocaml-lsp-server/src/diagnostics.mli @@ -8,27 +8,21 @@ type t val create : PublishDiagnosticsClientCapabilities.t option -> (PublishDiagnosticsParams.t list -> unit Fiber.t) - -> report_dune_diagnostics:bool + -> display_merlin_diagnostics:bool -> shorten_merlin_diagnostics:bool + -> client_name:string -> t val send : t -> [ `All | `One of Uri.t ] -> unit Fiber.t -module Dune : sig - type t - - val gen : Pid.t -> t -end - val set : t - -> [ `Dune of Dune.t * Drpc.Diagnostic.Id.t * Uri.t * Diagnostic.t + -> [ `Dune of Drpc.V1.Diagnostic.Id.t * Uri.t * Diagnostic.t | `Merlin of Uri.t * Diagnostic.t list ] -> unit -val remove : t -> [ `Dune of Dune.t * Drpc.Diagnostic.Id.t | `Merlin of Uri.t ] -> unit -val disconnect : t -> Dune.t -> unit +val remove : t -> [ `Dune of Drpc.V1.Diagnostic.Id.t | `Merlin of Uri.t ] -> unit val tags_of_message : t @@ -36,9 +30,22 @@ val tags_of_message -> string -> DiagnosticTag.t list option -val merlin_diagnostics : t -> Document.Merlin.t -> unit Fiber.t -val set_report_dune_diagnostics : t -> report_dune_diagnostics:bool -> unit Fiber.t -val set_shorten_merlin_diagnostics : t -> shorten_merlin_diagnostics:bool -> unit Fiber.t +(** Queries Merlin for diagnostics if [display_merlin_diagnostics] has been set to true + either in [create] or with [set_display_merlin_diagnostics]; otherwise, acts as if + Merlin returns [] *) +val merlin_diagnostics + : log_info:Lsp_timing_logger.t + -> t + -> Document.Merlin.t + -> unit Fiber.t + +val set_display_merlin_diagnostics : t -> display_merlin_diagnostics:bool -> unit + +(** Checks if there was a previous call to [set] with this [t] that returned a nonempty + list of [Diagnostic.t]s. *) +val has_cached_errors : t -> Document.Merlin.t -> bool + +val set_shorten_merlin_diagnostics : t -> shorten_merlin_diagnostics:bool -> unit (** Exposed for testing *) diff --git a/ocaml-lsp-server/src/doc_to_md.ml b/ocaml-lsp-server/src/doc_to_md.ml index 7e08c22e5..18150c8dc 100644 --- a/ocaml-lsp-server/src/doc_to_md.ml +++ b/ocaml-lsp-server/src/doc_to_md.ml @@ -38,7 +38,7 @@ let style_inline ~meta (style : Odoc_parser.Ast.style) inline = ;; let rec inline_element_to_inline - (inline : Odoc_parser.Ast.inline_element Odoc_parser.Loc.with_location) + (inline : Odoc_parser.Ast.inline_element Odoc_parser.Loc.with_location) : Inline.t = match inline with @@ -96,8 +96,7 @@ and inline_element_list_to_inlines inlines = ;; let rec nestable_block_element_to_block - (nestable : - Odoc_parser.Ast.nestable_block_element Odoc_parser.Loc.with_location) + (nestable : Odoc_parser.Ast.nestable_block_element Odoc_parser.Loc.with_location) = match nestable with | { value = `Paragraph text; location } -> @@ -109,36 +108,38 @@ let rec nestable_block_element_to_block Block.Paragraph (paragraph, meta) | { value = `Table ((grid, alignment), _); location } -> let meta = loc_to_meta location in - let tbl = - let rows = - let alignment_row = - match alignment with - | None -> [] - | Some alignment -> - let alignment = - List.map ~f:(fun x -> (x, 1 (* nb of separator *)), Meta.none) alignment - in - [ (`Sep alignment, Meta.none), "" ] - in - let cell ((c, _) : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.cell) = - let c = nestable_block_element_list_to_inlines c in - c, (" ", " ") - (* Initial and trailing blanks *) - in - let data_row (row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row) = - let row = List.map ~f:cell row in - (`Data row, Meta.none), "" - in - let header_row (row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row) = - let row = List.map ~f:cell row in - (`Header row, Meta.none), "" + let cell + ((c, _) : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.cell) = + let c = nestable_block_element_list_to_inlines c in + (c, (" ", " ") (* Initial and trailing blanks *)) + in + let header_row + (row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row) = + let row = List.map ~f:cell row in + ((`Header row, Meta.none), "") + in + let data_row + (row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row) = + let row = List.map ~f:cell row in + ((`Data row, Meta.none), "") + in + let alignment_row = + match alignment with + | None -> [] + | Some alignment -> + let alignment = + List.map + ~f:(fun x -> ((x, 1 (* nb of separator *)), Meta.none)) + alignment in - match grid with - | [] -> assert false - | h :: t -> (header_row h :: alignment_row) @ List.map ~f:data_row t - in - Block.Table.make rows + [ ((`Sep alignment, Meta.none), "") ] + in + let rows = + match grid with + | [] -> assert false + | h :: t -> (header_row h :: alignment_row) @ List.map ~f:data_row t in + let tbl = Block.Table.make rows in Block.Ext_table (tbl, meta) | { value = `List (kind, style, xs); location } -> let l = @@ -182,15 +183,7 @@ let rec nestable_block_element_to_block in let meta = loc_to_meta location in Block.List (l, meta) - | { value = - `Code_block - { meta = metadata - ; delimiter = _ - ; content = { value = code; location = code_loc } - ; output - } - ; location - } -> + | { value = `Code_block { meta = metadata; delimiter = _; content = { value = code; location = code_loc }; output }; location } -> let meta = loc_to_meta location in let main_block = let code_block = @@ -208,9 +201,9 @@ let rec nestable_block_element_to_block let output_block = match output with | None -> [] - | Some output -> [ nestable_block_element_list_to_block output ] + | Some output -> [nestable_block_element_list_to_block output] in - Block.Blocks (main_block :: output_block, meta) + Block.Blocks ( main_block :: output_block , meta) | { value = `Verbatim code; location } -> let code_block = let info_string = Some ("verb", Meta.none) in @@ -226,15 +219,21 @@ let rec nestable_block_element_to_block in let meta = loc_to_meta location in Block.Ext_math_block (code_block, meta) + | { value = `Media _; location } -> + let meta = loc_to_meta location in + let p = Block.Paragraph.make (Inline.Text ("(media)", meta)) in + Block.Paragraph (p, meta) and nestable_block_element_to_inlines - (nestable : Odoc_parser.Ast.nestable_block_element Odoc_parser.Loc.with_location) - = + (nestable : + Odoc_parser.Ast.nestable_block_element Odoc_parser.Loc.with_location) = match nestable with - | { value = `Paragraph text; location = _ } -> inline_element_list_to_inlines text + | { value = `Paragraph text; location = _ } -> + inline_element_list_to_inlines text | { value = `Table ((grid, _), _); location } -> let meta = loc_to_meta location in - let cell ((c, _) : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.cell) = + let cell + ((c, _) : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.cell) = nestable_block_element_list_to_inlines c in let row (row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row) = @@ -245,8 +244,8 @@ and nestable_block_element_to_inlines Inline.Inlines (rows, meta) | { value = `List (_, _, xs); location } -> let meta = loc_to_meta location in + let item i = nestable_block_element_list_to_inlines i in let items = - let item i = nestable_block_element_list_to_inlines i in let sep = Inline.Text (" - ", Meta.none) in List.concat_map ~f:(fun i -> [ sep; item i ]) xs in @@ -265,19 +264,26 @@ and nestable_block_element_to_inlines ; location } -> let meta = loc_to_meta location in + let meta_code = loc_to_meta code_loc in let code_span = - let meta_code = loc_to_meta code_loc in - Inline.Code_span.make ~backtick_count:1 [ "", (code, meta_code) ] + Inline.Code_span.make ~backtick_count:1 [ ("", (code, meta_code)) ] in Inline.Code_span (code_span, meta) | { value = `Verbatim code; location } -> let meta = loc_to_meta location in - let code_span = Inline.Code_span.make ~backtick_count:1 [ "", (code, Meta.none) ] in + let code_span = + Inline.Code_span.make ~backtick_count:1 [ ("", (code, Meta.none)) ] + in Inline.Code_span (code_span, meta) | { value = `Math_block code; location } -> let meta = loc_to_meta location in - let code_span = Inline.Math_span.make ~display:true [ "", (code, Meta.none) ] in + let code_span = + Inline.Math_span.make ~display:true [ ("", (code, Meta.none)) ] + in Inline.Ext_math_span (code_span, meta) + | { value = `Media _; location } -> + let meta = loc_to_meta location in + Inline.Text ("(media)", meta) and nestable_block_element_list_to_inlines l = let inlines = List.map ~f:nestable_block_element_to_inlines l in @@ -380,10 +386,22 @@ let tag_to_block ~meta (tag : Odoc_parser.Ast.tag) = | `Open -> format_tag_empty "@open" | `Closed -> format_tag_empty "@closed" | `Hidden -> format_tag_empty "@hidden" + | `Order_category oc -> + let block = nestable_block_element_list_to_block oc in + format_tag_block "@order_category" block + | `Short_title oc -> + let block = nestable_block_element_list_to_block oc in + format_tag_block "@short_title" block + | `Toc_status oc -> + let block = nestable_block_element_list_to_block oc in + format_tag_block "@toc_status" block + | `Children_order oc -> + let block = nestable_block_element_list_to_block oc in + format_tag_block "@children_order" block ;; let rec block_element_to_block - (block_element : Odoc_parser.Ast.block_element Odoc_parser.Loc.with_location) + (block_element : Odoc_parser.Ast.block_element Odoc_parser.Loc.with_location) = match block_element with | { value = `Heading (level, _, content); location } -> @@ -397,13 +415,7 @@ let rec block_element_to_block let meta = loc_to_meta location in tag_to_block ~meta t | { value = - ( `Paragraph _ - | `List _ - | `Modules _ - | `Code_block _ - | `Verbatim _ - | `Table _ - | `Math_block _ ) + `Paragraph _ | `List _ | `Modules _ | `Code_block _ | `Verbatim _ | `Table _ | `Math_block _ | `Media _ ; location = _ } as nestable -> nestable_block_element_to_block nestable diff --git a/ocaml-lsp-server/src/document.ml b/ocaml-lsp-server/src/document.ml index ec1ec2956..a83804827 100644 --- a/ocaml-lsp-server/src/document.ml +++ b/ocaml-lsp-server/src/document.ml @@ -129,16 +129,16 @@ module Single_pipeline : sig val create : Lev_fiber.Thread.t -> t val use - : ?name:string - -> t + : t + -> log_info:Lsp_timing_logger.t -> doc:Text_document.t -> config:Merlin_config.t -> f:(Mpipeline.t -> 'a) -> ('a, Exn_with_backtrace.t) result Fiber.t val use_with_config - : ?name:string - -> t + : t + -> log_info:Lsp_timing_logger.t -> doc:Text_document.t -> config:Mconfig.t -> f:(Mpipeline.t -> 'a) @@ -148,7 +148,7 @@ end = struct let create thread = { thread } - let use_with_config ?name t ~doc ~config ~f = + let use_with_config t ~(log_info : Lsp_timing_logger.t) ~doc ~config ~f = let make_pipeline = let source = Msource.make (Text_document.text doc) in fun () -> Mpipeline.make config source @@ -156,11 +156,11 @@ end = struct let task = match Lev_fiber.Thread.task t.thread ~f:(fun () -> - let start = Unix.time () in + let start = Unix.gettimeofday () in let pipeline = make_pipeline () in let res = Mpipeline.with_pipeline pipeline (fun () -> f pipeline) in - let stop = Unix.time () in - res, start, stop) + let stop = Unix.gettimeofday () in + res, start, stop, Mpipeline.timing_information pipeline) with | Error `Stopped -> assert false | Ok task -> task @@ -168,27 +168,33 @@ end = struct let* res = await task in match res with | Error exn -> Fiber.return (Error exn) - | Ok (res, start, stop) -> + | Ok (res, start, stop, timing_breakdown) -> let event = let module Event = Chrome_trace.Event in let dur = Event.Timestamp.of_float_seconds (stop -. start) in let fields = - let name = Option.value name ~default:"unknown" in Event.common_fields ~cat:[ "merlin" ] ~ts:(Event.Timestamp.of_float_seconds start) - ~name + ~name:log_info.action () in Event.complete ~dur fields in + (* Convert the total time to milliseconds to be consistent with the merlin timing *) + let () = + Lsp_timing_logger.log_merlin_timing + ~wall_time:((stop -. start) *. 1000.) + ~timing_breakdown + log_info + in let+ () = Metrics.report event in Ok res ;; - let use ?name t ~doc ~config ~f = + let use t ~log_info ~doc ~config ~f = let* config = Merlin_config.config config in - use_with_config ?name t ~doc ~config ~f + use_with_config t ~log_info ~doc ~config ~f ;; end @@ -291,36 +297,37 @@ module Merlin = struct | None -> Kind.unsupported (Text_document.documentUri t.tdoc) ;; - let with_pipeline ?name (t : t) f = - Single_pipeline.use ?name t.pipeline ~doc:t.tdoc ~config:t.merlin_config ~f + let with_pipeline ~log_info (t : t) f = + Single_pipeline.use ~log_info t.pipeline ~doc:t.tdoc ~config:t.merlin_config ~f ;; - let with_configurable_pipeline ?name ~config (t : t) f = - Single_pipeline.use_with_config ?name t.pipeline ~doc:t.tdoc ~config ~f + let with_configurable_pipeline ~log_info ~config (t : t) f = + Single_pipeline.use_with_config ~log_info t.pipeline ~doc:t.tdoc ~config ~f ;; let mconfig (t : t) = Merlin_config.config t.merlin_config - let with_pipeline_exn ?name doc f = - let+ res = with_pipeline ?name doc f in + let with_pipeline_exn ~log_info doc f = + let+ res = with_pipeline ~log_info doc f in match res with | Ok s -> s | Error exn -> Exn_with_backtrace.reraise exn ;; - let with_configurable_pipeline_exn ?name ~config doc f = - let+ res = with_configurable_pipeline ?name ~config doc f in + let with_configurable_pipeline_exn ~log_info ~config doc f = + let+ res = with_configurable_pipeline ~log_info ~config doc f in match res with | Ok s -> s | Error exn -> Exn_with_backtrace.reraise exn ;; - let dispatch ?name t command = - with_pipeline ?name t (fun pipeline -> Query_commands.dispatch pipeline command) + let dispatch ~log_info t command = + with_pipeline ~log_info t (fun pipeline -> Query_commands.dispatch pipeline command) ;; - let dispatch_exn ?name t command = - with_pipeline_exn ?name t (fun pipeline -> Query_commands.dispatch pipeline command) + let dispatch_exn ~log_info t command = + with_pipeline_exn ~log_info t (fun pipeline -> + Query_commands.dispatch pipeline command) ;; let doc_comment pipeline pos = @@ -333,6 +340,10 @@ module Merlin = struct | _ -> None ;; + (* TODO: If we actually start using this, we should update this function to call + log_merlin_timing (and refactor Single_pipeline.use_with_config to pull out the code + that grabs the timing info so this can call it). Right now this it's only being used + in the type_enclosing call below, so we just log it there. *) let syntax_doc pipeline pos = let res = let command = Query_protocol.Syntax_document pos in @@ -343,15 +354,31 @@ module Merlin = struct | `No_documentation -> None ;; + let stack_or_heap_enclosing pipeline pos loc = + let res = + (* passing [true] here makes the request in "lsp compatibility" mode, which adjusts + some ranges to better align with type-enclosing behavior *) + let command = Query_protocol.Stack_or_heap_enclosing (pos, true, Some 0) in + Query_commands.dispatch pipeline command + in + List.find_map res ~f:(fun (loc', stack_or_heap) -> + match Loc.compare loc loc', stack_or_heap with + | 0, `String msg -> + (* matches type-enclosing range and has a stack-or-heap message*) + Some msg + | _ -> None) + ;; + type type_enclosing = { loc : Loc.t ; typ : string ; doc : string option - ; syntax_doc : Query_protocol.syntax_doc_result option + ; stack_or_heap : string option + ; syntax_doc : Query_protocol.Syntax_doc_result.t option } - let type_enclosing ?name doc pos verbosity ~with_syntax_doc = - with_pipeline_exn ?name doc (fun pipeline -> + let type_enclosing ~(log_info : Lsp_timing_logger.t) doc pos verbosity ~with_syntax_doc = + with_pipeline_exn ~log_info doc (fun pipeline -> let command = Query_protocol.Type_enclosing (None, pos, Some 0) in let pipeline = match verbosity with @@ -369,16 +396,17 @@ module Merlin = struct | [] | (_, `Index _, _) :: _ -> None | (loc, `String typ, _) :: _ -> let doc = doc_comment pipeline pos in + let stack_or_heap = stack_or_heap_enclosing pipeline pos loc in let syntax_doc = match with_syntax_doc with | true -> syntax_doc pipeline pos | false -> None in - Some { loc; typ; doc; syntax_doc }) + Some { loc; typ; doc; stack_or_heap; syntax_doc }) ;; - let doc_comment ?name doc pos = - with_pipeline_exn ?name doc (fun pipeline -> doc_comment pipeline pos) + let doc_comment ~(log_info : Lsp_timing_logger.t) doc pos = + with_pipeline_exn ~log_info doc (fun pipeline -> doc_comment pipeline pos) ;; end diff --git a/ocaml-lsp-server/src/document.mli b/ocaml-lsp-server/src/document.mli index 735bfd659..2e170292a 100644 --- a/ocaml-lsp-server/src/document.mli +++ b/ocaml-lsp-server/src/document.mli @@ -48,49 +48,57 @@ module Merlin : sig val source : t -> Msource.t val timer : t -> Lev_fiber.Timer.Wheel.task - (** uses a single pipeline, provisioned by the configuration attached to the - merlin document (via {!type:t}). *) - val with_pipeline_exn : ?name:string -> t -> (Mpipeline.t -> 'a) -> 'a Fiber.t + (** uses a single pipeline, provisioned by the configuration attached to the merlin + document (via {!type:t}). *) + val with_pipeline_exn + : log_info:Lsp_timing_logger.t + -> t + -> (Mpipeline.t -> 'a) + -> 'a Fiber.t - (** Like {!val:with_pipeline_exn} but where the merlin configuration is - supplied manually. If, for example, it is computed outside the execution - of the pipeline.*) + (** Like {!val:with_pipeline_exn} but where the merlin configuration is supplied + manually. If, for example, it is computed outside the execution of the pipeline. *) val with_configurable_pipeline_exn - : ?name:string + : log_info:Lsp_timing_logger.t -> config:Mconfig.t -> t -> (Mpipeline.t -> 'a) -> 'a Fiber.t val dispatch - : ?name:string + : log_info:Lsp_timing_logger.t -> t -> 'a Query_protocol.t -> ('a, Exn_with_backtrace.t) result Fiber.t - val dispatch_exn : ?name:string -> t -> 'a Query_protocol.t -> 'a Fiber.t + val dispatch_exn + : log_info:Lsp_timing_logger.t + -> t + -> 'a Query_protocol.t + -> 'a Fiber.t val doc_comment - : ?name:string + : log_info:Lsp_timing_logger.t -> t -> Msource.position -> (* doc string *) - string option Fiber.t + string option Fiber.t val syntax_doc : Mpipeline.t -> Msource.position - -> Query_protocol.syntax_doc_result option + -> Query_protocol.Syntax_doc_result.t option type type_enclosing = { loc : Loc.t ; typ : string ; doc : string option - ; syntax_doc : Query_protocol.syntax_doc_result option + ; stack_or_heap : string option + ; syntax_doc : Query_protocol.Syntax_doc_result.t option } val type_enclosing - : ?name:string + : log_info:Lsp_timing_logger.t -> t -> Msource.position -> (* verbosity *) int @@ -108,18 +116,18 @@ val version : t -> int val update_text : ?version:int -> t -> TextDocumentContentChangeEvent.t list -> t val close : t -> unit Fiber.t -(** [get_impl_intf_counterparts uri] returns the implementation/interface - counterparts for the URI [uri]. +(** [get_impl_intf_counterparts uri] returns the implementation/interface counterparts for + the URI [uri]. For instance, the counterparts of the file [/file.ml] are [/file.mli]. *) val get_impl_intf_counterparts : Merlin.t option -> Uri.t -> Uri.t list -(** [edits t edits] creates a [WorkspaceEdit.t] that applies edits [edits] to - the document [t]. *) +(** [edits t edits] creates a [WorkspaceEdit.t] that applies edits [edits] to the document + [t]. *) val edit : t -> TextEdit.t list -> WorkspaceEdit.t -(** [substring t range] returns the substring of the document [t] that - corresponds to the range [range]. +(** [substring t range] returns the substring of the document [t] that corresponds to the + range [range]. Returns [None] when there is no corresponding substring. *) val substring : t -> Range.t -> string option diff --git a/ocaml-lsp-server/src/document_store.ml b/ocaml-lsp-server/src/document_store.ml index 825e6bb6c..bdf95ca5d 100644 --- a/ocaml-lsp-server/src/document_store.ml +++ b/ocaml-lsp-server/src/document_store.ml @@ -8,14 +8,14 @@ type semantic_tokens_cache = ; tokens : int array } -(** The following code attempts to resolve the issue of displaying code actions - for unopened document. +(** The following code attempts to resolve the issue of displaying code actions for + unopened document. - Unopened documents require a dynamic registration (DR) for code actions, - while open documents do not. + Unopened documents require a dynamic registration (DR) for code actions, while open + documents do not. - Here are the four states of the documents and the DR status they require. - "X" marks that DR is required while "O" marks that no Dr should be present + Here are the four states of the documents and the DR status they require. "X" marks + that DR is required while "O" marks that no Dr should be present {v | Open | Closed | @@ -24,8 +24,8 @@ type semantic_tokens_cache = No Promotions | O | O | v} - From the above, we see that we need to unregister when transitioning from X - to O and to register while transitioning from X to O. *) + From the above, we see that we need to unregister when transitioning from X to O and + to register while transitioning from O to X. *) type doc = { (* invariant: if [document <> None], then no promotions are active *) @@ -197,12 +197,28 @@ let get_semantic_tokens_cache : t -> Uri.t -> semantic_tokens_cache option = !doc.semantic_tokens_cache ;; -let parallel_iter t ~f = - let all = Table.fold ~init:[] t.db ~f:(fun doc acc -> doc :: acc) in - Fiber.parallel_iter all ~f:(fun doc -> - match !doc.document with - | None -> Fiber.return () - | Some document -> f document) +let docs_to_iter ?max_docs ~filter t = + (* NOTE: it would be nice to also have a criterion to sort the list by. That could be + used to ensure that when we refresh diagnositics on a subset of documents, we + prioritize the most-recently updated ones. But there's not much point in adding the + sort-criterion here without also doing the larger refactor to track recency. *) + let docs : Document.t list = + Table.fold ~init:[] t.db ~f:(fun doc acc -> !doc.document :: acc) + |> Core.List.filter_map ~f:(function + | Some doc as d when filter doc -> d + | _ -> None) + in + match max_docs with + | None -> docs + | Some m -> Core.List.take docs m +;; + +let parallel_iter ?max_docs ?(filter = fun _ -> true) t ~f = + Fiber.parallel_iter (docs_to_iter ?max_docs ~filter t) ~f +;; + +let sequential_iter ?max_docs ?(filter = fun _ -> true) t ~f = + Fiber.sequential_iter (docs_to_iter ?max_docs ~filter t) ~f ;; let fold t ~init ~f = diff --git a/ocaml-lsp-server/src/document_store.mli b/ocaml-lsp-server/src/document_store.mli index 9b98abca5..7559df504 100644 --- a/ocaml-lsp-server/src/document_store.mli +++ b/ocaml-lsp-server/src/document_store.mli @@ -25,5 +25,23 @@ val update_semantic_tokens_cache val get_semantic_tokens_cache : t -> Uri.t -> semantic_tokens_cache option val close_document : t -> Uri.t -> unit Fiber.t val fold : t -> init:'acc -> f:(Document.t -> 'acc -> 'acc) -> 'acc -val parallel_iter : t -> f:(Document.t -> unit Fiber.t) -> unit Fiber.t + +(** Since iterating over all documents can be a source of slowness, we allow the caller to + specify a way of filtering and a max number of documents to iterate over. *) +val docs_to_iter : ?max_docs:int -> filter:(Document.t -> bool) -> t -> Document.t list + +val parallel_iter + : ?max_docs:int + -> ?filter:(Document.t -> bool) + -> t + -> f:(Document.t -> unit Fiber.t) + -> unit Fiber.t + +val sequential_iter + : ?max_docs:int + -> ?filter:(Document.t -> bool) + -> t + -> f:(Document.t -> unit Fiber.t) + -> unit Fiber.t + val close_all : t -> unit Fiber.t diff --git a/ocaml-lsp-server/src/document_symbol.ml b/ocaml-lsp-server/src/document_symbol.ml index 390363ddd..1e17aedf4 100644 --- a/ocaml-lsp-server/src/document_symbol.ml +++ b/ocaml-lsp-server/src/document_symbol.ml @@ -135,68 +135,11 @@ let module_binding_document_symbol (pmod : Parsetree.module_binding) ~children = () ;; -let visit_class_sig (desc : Parsetree.class_type) = - match desc.pcty_desc with - | Pcty_signature cs -> - List.filter_map - ~f:(fun field -> - match field.pctf_desc with - | Pctf_val (label, _, _, _) -> - DocumentSymbol.create - ~name:label.txt - ~kind:Property - ~range:(Range.of_loc field.pctf_loc) - ~selectionRange:(Range.of_loc label.loc) - () - |> Option.some - | Pctf_method (label, _, _, _) -> - DocumentSymbol.create - ~name:label.txt - ~kind:Method - ~range:(Range.of_loc field.pctf_loc) - ~selectionRange:(Range.of_loc label.loc) - () - |> Option.some - | _ -> None) - cs.pcsig_fields - | _ -> [] -;; - -let class_description_symbol (decl : Parsetree.class_description) = - DocumentSymbol.create - ~name:decl.pci_name.txt - ~kind:Class - ~range:(Range.of_loc decl.pci_loc) - ~selectionRange:(Range.of_loc decl.pci_name.loc) - ~children:(visit_class_sig decl.pci_expr) - () -;; - -let class_declaration_symbol (decl : Parsetree.class_declaration) ~children = - DocumentSymbol.create - ~name:decl.pci_name.txt - ~kind:Class - ~range:(Range.of_loc decl.pci_loc) - ~selectionRange:(Range.of_loc decl.pci_name.loc) - ~children - () -;; - -let class_type_declaration_symbol (decl : Parsetree.class_type_declaration) = - DocumentSymbol.create - ~name:decl.pci_name.txt - ~kind:Interface - ~range:(Range.of_loc decl.pci_loc) - ~selectionRange:(Range.of_loc decl.pci_name.loc) - ~children:(visit_class_sig decl.pci_expr) - () -;; - let binding_document_symbol - (binding : Parsetree.value_binding) - ~ppx - ~is_top_level - ~children + (binding : Parsetree.value_binding) + ~ppx + ~is_top_level + ~children = let variables_in_pattern (pattern : Parsetree.pattern) = let symbols = ref [] in @@ -240,7 +183,7 @@ let binding_document_symbol in let detail = None - (* CR-rgrinberg: Re-enable in 5.0: {[ + (* TODO: Re-enable in 5.0: {[ Option.map binding.pvb_constraint ~f:(function | Pvc_constraint { typ; _ } -> core_type_to_string typ | Pvc_coercion { coercion; _ } -> core_type_to_string coercion) @@ -262,8 +205,8 @@ let binding_document_symbol let symbols_from_parsetree parsetree = let current = ref [] in let descend - (iter : unit -> unit) - (get_current_symbol : children:DocumentSymbol.t list -> DocumentSymbol.t) + (iter : unit -> unit) + (get_current_symbol : children:DocumentSymbol.t list -> DocumentSymbol.t) = let outer = !current in current := []; @@ -285,16 +228,12 @@ let symbols_from_parsetree parsetree = descend (fun () -> Ast_iterator.default_iterator.module_type_declaration iterator decl) (module_type_decl_symbol decl) - | Psig_class classes -> - current := !current @ List.map classes ~f:class_description_symbol - | Psig_class_type classes -> - current := !current @ List.map classes ~f:class_type_declaration_symbol | _ -> Ast_iterator.default_iterator.signature_item iterator item in let rec structure_item - ~ppx - (iterator : Ast_iterator.iterator) - (item : Parsetree.structure_item) + ~ppx + (iterator : Ast_iterator.iterator) + (item : Parsetree.structure_item) = match item.pstr_desc with | Pstr_type (_, decls) -> current := !current @ List.map decls ~f:type_document_symbol @@ -318,58 +257,11 @@ let symbols_from_parsetree parsetree = binding_document_symbol binding ~ppx ~is_top_level:true ~children:!current) | Pstr_extension ((name, PStr items), _) -> List.iter items ~f:(fun item -> structure_item ~ppx:(Some name.txt) iterator item) - | Pstr_class classes -> - List.iter - ~f:(fun (klass : Parsetree.class_declaration) -> - descend - (fun () -> - match klass.pci_expr.pcl_desc with - | Pcl_structure cs -> - Ast_iterator.default_iterator.class_structure iterator cs - | _ -> ()) - (class_declaration_symbol klass)) - classes - | Pstr_class_type classes -> - current := !current @ List.map classes ~f:class_type_declaration_symbol | _ -> Ast_iterator.default_iterator.structure_item iterator item in - let class_structure - (iterator : Ast_iterator.iterator) - (item : Parsetree.class_structure) - = - List.iter ~f:(Ast_iterator.default_iterator.class_field iterator) item.pcstr_fields - in - let class_field (iterator : Ast_iterator.iterator) (item : Parsetree.class_field) = - let mk_symbol ?children ~kind (label : string Asttypes.loc) = - DocumentSymbol.create - ~name:label.txt - ~kind - ~range:(Range.of_loc item.pcf_loc) - ~selectionRange:(Range.of_loc label.loc) - ?children - () - in - match item.pcf_desc with - | Pcf_val (label, _, Parsetree.Cfk_virtual _) -> - let symbol = mk_symbol ~kind:Property label in - current := !current @ [ symbol ] - | Pcf_val (label, _, Parsetree.Cfk_concrete (_, expr)) -> - descend - (fun () -> Ast_iterator.default_iterator.expr iterator expr) - (fun ~children -> mk_symbol ~kind:Property label ~children) - | Pcf_method (label, _, Parsetree.Cfk_virtual _) -> - let symbol = mk_symbol ~kind:Method label in - current := !current @ [ symbol ] - | Pcf_method (label, _, Parsetree.Cfk_concrete (_, expr)) -> - descend - (fun () -> Ast_iterator.default_iterator.expr iterator expr) - (fun ~children -> mk_symbol ~kind:Method label ~children) - | _ -> Ast_iterator.default_iterator.class_field iterator item - in let expr (iterator : Ast_iterator.iterator) (item : Parsetree.expression) = match item.pexp_desc with - | Pexp_object cs -> Ast_iterator.default_iterator.class_structure iterator cs - | Pexp_let (_, bindings, inner) -> + | Pexp_let (_, _, bindings, inner) -> let outer = !current in let bindings = List.concat_map bindings ~f:(fun (binding : Parsetree.value_binding) -> @@ -385,8 +277,6 @@ let symbols_from_parsetree parsetree = { Ast_iterator.default_iterator with signature_item ; structure_item = structure_item ~ppx:None - ; class_structure - ; class_field ; expr } in @@ -417,13 +307,13 @@ let rec flatten_document_symbols ~uri ~container_name (symbols : DocumentSymbol. symbol_information :: children) ;; -let run (client_capabilities : ClientCapabilities.t) doc uri = +let run ~log_info (client_capabilities : ClientCapabilities.t) doc uri = match Document.kind doc with | `Other -> Fiber.return None | `Merlin _ -> let+ symbols = Document.Merlin.with_pipeline_exn - ~name:"document-symbols" + ~log_info (Document.merlin_exn doc) (fun pipeline -> Mpipeline.reader_parsetree pipeline |> symbols_from_parsetree) in diff --git a/ocaml-lsp-server/src/document_symbol.mli b/ocaml-lsp-server/src/document_symbol.mli index 6efd8f058..5893efd35 100644 --- a/ocaml-lsp-server/src/document_symbol.mli +++ b/ocaml-lsp-server/src/document_symbol.mli @@ -1,7 +1,8 @@ open Import val run - : ClientCapabilities.t + : log_info:Lsp_timing_logger.t + -> ClientCapabilities.t -> Document.t -> Uri.t -> [> `DocumentSymbol of DocumentSymbol.t list diff --git a/ocaml-lsp-server/src/dune b/ocaml-lsp-server/src/dune index 129c9d8a9..0607fc00f 100644 --- a/ocaml-lsp-server/src/dune +++ b/ocaml-lsp-server/src/dune @@ -1,45 +1,79 @@ (library (name ocaml_lsp_server) (libraries - dyn - xdg - unix + async + async_log + base + chrome-trace + cmarkit + core + core_unix + csexp dune-build-info + dune-rpc + dyn fiber - chrome-trace - lev - lev_fiber - lev_fiber_csexp + fiber_async jsonrpc - spawn + lev_fiber_async lsp lsp_fiber - merlin-lib.dot_protocol merlin-lib.analysis + merlin-lib.commands + merlin-lib.dot_protocol + merlin-lib.extend merlin-lib.kernel - merlin-lib.ocaml_parsing - merlin-lib.query_commands - merlin-lib.query_protocol merlin-lib.ocaml_merlin_specific + merlin-lib.ocaml_parsing + merlin-lib.ocaml_preprocess merlin-lib.ocaml_typing merlin-lib.ocaml_utils + merlin-lib.query_commands + merlin-lib.query_protocol merlin-lib.utils - merlin-lib.extend - merlin-lib.commands - cmarkit - odoc_parser + ocamlc-loc + ocamlformat-rpc-lib + odoc-parser + ordering + ppx_string ppx_yojson_conv_lib + ppxlib re + re2 + spawn stdune - ordering - csexp - yojson - dune-rpc - ocamlformat-rpc-lib - ocamlc-loc - base) - (lint - (pps ppx_yojson_conv)) + unix + yojson) + (preprocess ( + pps + ppx_let + ppx_log + ppx_yojson_conv + -no-locations-check + ppx_expect + ppx_here + ppx_sexp_conv + ppx_sexp_message)) +;; (preprocess +;; (pps ppx_let ppx_log ppx_yojson_conv ppx_sexp_conv)) + (flags ( + :standard + -open + Cmarkit + -open + Lev_fiber_async + -open + Ocaml_preprocess + -open + Query_protocol + -open + Query_commands + -open + Ppx_yojson_conv_lib.Yojson_conv + -alert + -unstable + -w + -60)) (instrumentation (backend bisect_ppx))) diff --git a/ocaml-lsp-server/src/dune.ml b/ocaml-lsp-server/src/dune.ml deleted file mode 100644 index 9ebacc37b..000000000 --- a/ocaml-lsp-server/src/dune.ml +++ /dev/null @@ -1,943 +0,0 @@ -open! Import -open Fiber.O -module Registry = Drpc.Registry - -let view_promotion_capability = "diagnostic_promotions", `Bool true - -module For_diff = struct - module Diff = struct - type t = - { in_source : string - ; in_build : string - } - - let of_promotion p = - let module D = Drpc.Diagnostic in - { in_build = D.Promotion.in_build p; in_source = D.Promotion.in_source p } - ;; - - let yojson_of_t { in_source; in_build } = - `Assoc [ "in_build", `String in_build; "in_source", `String in_source ] - ;; - end - - type t = Diff.t list - - let yojson_of_t : t -> Json.t = Json.yojson_of_list Diff.yojson_of_t - let diagnostic_data t = fst view_promotion_capability, yojson_of_t t -end - -module Chan : sig - type t - - val create : Lev_fiber_csexp.Session.t -> t - val write : t -> Csexp.t list option -> unit Fiber.t - val read : t -> Csexp.t option Fiber.t - val stop : t -> unit Fiber.t - val run : t -> unit Fiber.t -end = struct - open Fiber.O - - type t = - { session : Lev_fiber_csexp.Session.t - ; finished : unit Fiber.Ivar.t - } - - let stop t = - let+ () = Fiber.return () in - Lev_fiber_csexp.Session.close t.session - ;; - - let write t sexp = - match sexp with - | None -> stop t - | Some sexp -> Lev_fiber_csexp.Session.write t.session sexp - ;; - - let read t = - let* read = Lev_fiber_csexp.Session.read t.session in - match read with - | Some _ -> Fiber.return read - | None -> - let+ () = Fiber.Ivar.fill t.finished () in - read - ;; - - let create session = - let finished = Fiber.Ivar.create () in - { session; finished } - ;; - - let run t = Fiber.Ivar.read t.finished -end - -module Client = - Drpc.Client.Make - (struct - include Fiber - - let parallel_iter t ~f = - let stream = Fiber.Stream.In.create t in - Fiber.Stream.In.parallel_iter stream ~f - ;; - end) - (Chan) - -module Poll = - Drpc.Registry.Poll - (Fiber) - (struct - let scandir s = - Fiber.of_thunk (fun () -> - Fiber.return - (match Sys.readdir s with - | s -> Ok (Array.to_list s) - | exception Sys_error _ -> Ok [] - | exception exn -> Error exn)) - ;; - - let is_414 = String.is_prefix Sys.ocaml_version ~prefix:"4.14.0" - - let stat s = - let+ () = Fiber.return () in - match - if Sys.win32 && is_414 && not (Sys.file_exists s) - then - (* Mitigate issue ocaml/ocaml#11737; see ocaml/ocaml-lsp#929. Should - be reverted as soon as "ocaml 4.14.0" is no longer supported. *) - raise (Unix.Unix_error (ENOENT, "stat", s)) - else Unix.stat s - with - | exception exn -> Error exn - | s -> Ok (`Mtime s.st_mtime) - ;; - - let read_file s = - Fiber.of_thunk (fun () -> - Fiber.return (Result.try_with (fun () -> Io.String_path.read_file s))) - ;; - end) - -type config = - { diagnostics : Diagnostics.t - ; document_store : Document_store.t - ; include_promotions : bool - ; progress : Progress.t - ; log : type_:MessageType.t -> message:string -> unit Fiber.t - } - -module Instance : sig - type t - - val format_dune_file : t -> Document.t -> string Fiber.t - val stop : t -> unit Fiber.t - val run : t -> unit Fiber.t - val connect : t -> (unit, unit) result Fiber.t - val source : t -> Registry.Dune.t - val create : Registry.Dune.t -> config -> t - val promotions : t -> Drpc.Diagnostic.Promotion.t String.Map.t - val client : t -> Client.t option -end = struct - module Id = Stdune.Id.Make () - - type running = - { chan : Chan.t - ; finish : unit Fiber.Ivar.t - ; diagnostics_id : Diagnostics.Dune.t - ; id : Id.t - ; mutable client : Client.t option - ; mutable promotions : - (* TODO we need to clean these up in the finalizer *) - Drpc.Diagnostic.Promotion.t String.Map.t - } - - type state = - | Idle - | Connected of Lev_fiber_csexp.Session.t * Drpc.Where.t - | Running of running - | Finished - - type t = - { config : config - ; source : Drpc.Registry.Dune.t - ; mutable state : state - } - - let client t = - match t.state with - | Connected _ | Idle | Finished -> None - | Running r -> r.client - ;; - - let promotions t = - match t.state with - | Connected _ | Idle | Finished -> String.Map.empty - | Running r -> r.promotions - ;; - - let source t = t.source - - let lsp_of_dune diagnostics ~include_promotions diagnostic = - let module D = Drpc.Diagnostic in - let range_of_loc loc = - let loc = - let loc_start = Drpc.Loc.start loc in - let loc_end = Drpc.Loc.stop loc in - { Loc.loc_start; loc_end; loc_ghost = false } - in - Range.of_loc loc - in - let range = - match D.loc diagnostic with - | None -> Range.first_line - | Some loc -> range_of_loc loc - in - let severity = - D.severity diagnostic - |> Option.map ~f:(function - | D.Error -> DiagnosticSeverity.Error - | Warning -> DiagnosticSeverity.Warning) - in - let make_message message = String.trim (Format.asprintf "%a@." Pp.to_fmt message) in - let relatedInformation = - match D.related diagnostic with - | [] -> None - | related -> - Some - (List.map related ~f:(fun related -> - let message = make_message (D.Related.message related) in - let loc = D.Related.loc related in - let uri = - let start = Drpc.Loc.start loc in - Uri.of_path start.pos_fname - in - let location = - let range = range_of_loc loc in - Location.create ~uri ~range - in - DiagnosticRelatedInformation.create ~location ~message)) - in - let message = make_message (D.message diagnostic) in - let tags = Diagnostics.tags_of_message diagnostics ~src:`Dune message in - let data = - match include_promotions with - | false -> None - | true -> - (match D.promotion diagnostic with - | [] -> None - | promotions -> - let promotions = List.map promotions ~f:For_diff.Diff.of_promotion in - Some (`Assoc [ For_diff.diagnostic_data promotions ])) - in - Diagnostic.create - ?relatedInformation - ~range - ?severity - ~source:Diagnostics.dune_source - ~message:(`String message) - ?tags - ?data - () - ;; - - let progress_loop client diagnostics document_store progress = - (* We get all the progress updates even if the user can't see them to - refresh the merlin config at the end of every build. Not very clean, but - the assumption is that most good lsp clients will have progress reporting - anyway *) - let* res = Client.poll client Drpc.Sub.progress in - match res with - | Error v -> raise (Drpc.Version_error.E v) - | Ok poll -> - Fiber.repeat_while ~init:() ~f:(fun () -> - let* res = Client.Stream.next poll in - match res with - | None -> Fiber.return None - | Some p -> - let+ () = - Fiber.fork_and_join_unit - (fun () -> Progress.build_progress progress p) - (fun () -> - match p with - | Failed | Interrupted | Success -> - let* () = - Document_store.parallel_iter document_store ~f:(fun doc -> - match Document.kind doc with - | `Other -> Fiber.return () - | `Merlin merlin -> - Diagnostics.merlin_diagnostics diagnostics merlin) - in - Diagnostics.send diagnostics `All - | _ -> Fiber.return ()) - in - Some ()) - ;; - - let diagnostic_loop ~dune_root client config (running : running) diagnostics = - let* res = Client.poll client Drpc.Sub.diagnostic in - let send_diagnostics evs = - let promotions, add, remove = - List.fold_left - evs - ~init:(running.promotions, [], []) - ~f:(fun (promotions, add, remove) (ev : Drpc.Diagnostic.Event.t) -> - let diagnostic = - match ev with - | Add x -> x - | Remove x -> x - in - let id = Drpc.Diagnostic.id diagnostic in - let promotion = Drpc.Diagnostic.promotion diagnostic in - match ev with - | Remove _ -> - let promotions, requests = - List.fold_left - promotion - ~init:(promotions, []) - ~f:(fun (ps, acc) promotion -> - let source = Drpc.Diagnostic.Promotion.in_source promotion in - match String.Map.find ps source with - | Some _ -> String.Map.remove ps source, promotion :: acc - | None -> - Log.log ~section:"warning" (fun () -> - Log.msg - "removing non existant promotion" - [ ( "promotion" - , `String (Drpc.Diagnostic.Promotion.in_source promotion) ) - ]); - ps, acc) - in - Diagnostics.remove diagnostics (`Dune (running.diagnostics_id, id)); - promotions, add, requests :: remove - | Add d -> - let promotions, requests = - List.fold_left - promotion - ~init:(promotions, []) - ~f:(fun (ps, acc) promotion -> - let source = Drpc.Diagnostic.Promotion.in_source promotion in - match String.Map.find ps source with - | Some _ -> - (* TODO it should not be possible to offer more than one - promotion for a file in dune *) - assert false - | None -> String.Map.add_exn ps source promotion, promotion :: acc) - in - let uri : Uri.t = - match Drpc.Diagnostic.loc d with - | None -> dune_root - | Some loc -> - let { Lexing.pos_fname; _ } = Drpc.Loc.start loc in - Uri.of_path pos_fname - in - Diagnostics.set - diagnostics - (`Dune - ( running.diagnostics_id - , id - , uri - , lsp_of_dune - diagnostics - ~include_promotions:config.include_promotions - d )); - promotions, requests :: add, remove) - in - promotions, List.flatten add, List.flatten remove - in - match res with - | Error v -> raise (Drpc.Version_error.E v) - | Ok poll -> - Fiber.repeat_while ~init:() ~f:(fun () -> - let* res = Client.Stream.next poll in - match res with - | None -> Fiber.return None - | Some p -> - let promotions, add, remove = send_diagnostics p in - let uris = - List.rev_map ~f:(fun promotion -> - Drpc.Diagnostic.Promotion.in_source promotion |> Uri.of_path) - in - running.promotions <- promotions; - let* () = Diagnostics.send diagnostics `All in - let+ () = - Fiber.fork_and_join_unit - (fun () -> - Document_store.unregister_promotions config.document_store (uris remove)) - (fun () -> - Document_store.register_promotions config.document_store (uris add)) - in - Some ()) - ;; - - let stop t = - match t.state with - | Running { chan; _ } -> Chan.stop chan - | _ -> Fiber.return () - ;; - - let create source config = { config; source; state = Idle } - - let connect ({ config; source; _ } as t) = - let* () = - Fiber.of_thunk (fun () -> - assert ( - match t.state with - | Idle -> true - | _ -> false); - Fiber.return ()) - in - let where = Registry.Dune.where source in - let sockaddr = - match where with - | `Unix s -> Unix.ADDR_UNIX s - | `Ip (`Host h, `Port p) -> Unix.ADDR_INET (Unix.inet_addr_of_string h, p) - in - let sock = - let domain = Unix.domain_of_sockaddr sockaddr in - let socket = Unix.socket ~cloexec:true domain Unix.SOCK_STREAM 0 in - Lev_fiber.Fd.create socket (`Non_blocking false) - in - let* session = - Fiber.map_reduce_errors - (module Monoid.List (Exn_with_backtrace)) - (fun () -> Lev_fiber_csexp.connect sock sockaddr) - ~on_error:(fun exn -> - match exn with - | { Exn_with_backtrace.exn = Unix.Unix_error ((ECONNREFUSED | ENOENT), _, _) - ; _ - } -> Fiber.return [] - | _ -> Fiber.return [ exn ]) - in - match session with - | Error exns -> - Lev_fiber.Fd.close sock; - let+ () = - match exns with - | [] -> Fiber.return () - | exn :: _ -> - let message = - Format.asprintf - "unable to connect to dune at %s@.%a" - (Registry.Dune.root source) - Exn_with_backtrace.pp_uncaught - exn - in - t.config.log ~type_:Error ~message - in - t.state <- Finished; - Error () - | Ok session -> - let* () = - let message = - sprintf - "Connected to dune %s (%s)" - (Registry.Dune.root source) - (match Registry.Dune.where source with - | `Unix s -> s - | `Ip (`Host h, `Port p) -> sprintf "%s:%d" h p) - in - config.log ~type_:Info ~message - in - t.state <- Connected (session, where); - Fiber.return (Ok ()) - ;; - - let run ({ config; source; _ } as t) = - let* () = Fiber.return () in - let session, where = - match t.state with - | Connected (session, where) -> session, where - | _ -> assert false - in - let chan = Chan.create session in - let finish = Fiber.Ivar.create () in - let running = - { chan - ; finish - ; promotions = String.Map.empty - ; client = None - ; diagnostics_id = Diagnostics.Dune.gen (Pid.of_int (Registry.Dune.pid source)) - ; id = Id.gen () - } - in - t.state <- Running running; - let { progress; diagnostics; include_promotions = _; log = _; document_store } = - config - in - let* () = - Fiber.all_concurrently_unit - [ (let* () = Chan.run chan in - t.state <- Finished; - Diagnostics.disconnect diagnostics running.diagnostics_id; - let* () = Diagnostics.send diagnostics `All in - Fiber.Ivar.fill finish ()) - ; (let init = - let id = - Drpc.Id.make - (List [ Atom "ocamllsp"; Atom (Int.to_string (Id.to_int running.id)) ]) - in - Drpc.Initialize.create ~id - in - let where = - match where with - | `Unix s -> sprintf "unix://%s" s - | `Ip (`Host h, `Port p) -> sprintf "%s:%d" h p - in - let* () = - let message = sprintf "client %d: connecting..." (Id.to_int running.id) in - config.log ~type_:Info ~message - in - (* TODO put timeouts establishing a connection *) - Client.connect chan init ~f:(fun client -> - running.client <- Some client; - t.state <- Running running; - let* () = - let message = - sprintf "client %d: connected to dune at %s" (Id.to_int running.id) where - in - config.log ~type_:Info ~message - in - let progress = progress_loop client diagnostics document_store progress in - let diagnostics = - let dune_root = DocumentUri.of_path (Registry.Dune.root source) in - diagnostic_loop ~dune_root client config running diagnostics - in - Fiber.all_concurrently_unit [ progress; diagnostics; Fiber.Ivar.read finish ])) - ] - in - Progress.end_build_if_running progress - ;; - - let format_dune_file t doc = - match t.state with - | Running { client = Some client; _ } -> - let* req = Client.Versioned.prepare_request client Drpc.Request.format_dune_file in - let req = - match req with - | Error _ -> assert false - | Ok req -> req - in - let+ res = - let path = Document.uri doc |> Uri.to_path |> Drpc.Path.absolute in - Client.request client req (path, `Contents (Document.text doc)) - in - (match res with - | Ok res -> res - | Error _ -> - Jsonrpc.Response.Error.( - raise (make ~message:"dune failed to format" ~code:InternalError ()))) - | Connected _ | Idle | Finished | Running _ -> assert false - ;; -end - -module Dune_map = Map.Make (Registry.Dune) - -type active = - { mutable instances : Instance.t String.Map.t (* keyed by root *) - ; mutable workspaces : Workspaces.t - ; registry : Registry.t - ; config : config - ; pool : Fiber.Pool.t - } - -let cwd = lazy (Sys.getcwd ()) - -let uri_dune_overlap = - (* Copy pasted from dune. - - All of this is really hacky and error prone. We should let the user - associate dune instances with workspace folders somehow *) - let is_dir_sep = - if Sys.win32 || Sys.cygwin - then fun c -> c = '/' || c = '\\' || c = ':' - else fun c -> c = '/' - in - let explode_path = - let rec start acc path i = - if i < 0 - then acc - else if is_dir_sep (String.unsafe_get path i) - then start acc path (i - 1) - else component acc path i (i - 1) - and component acc path end_ i = - if i < 0 - then String.take path (end_ + 1) :: acc - else if is_dir_sep (String.unsafe_get path i) - then start (String.sub path ~pos:(i + 1) ~len:(end_ - i) :: acc) path (i - 1) - else component acc path end_ (i - 1) - in - fun path -> - if path = Filename.current_dir_name - then [ path ] - else ( - match start [] path (String.length path - 1) with - | "." :: xs -> xs - | xs -> xs) - in - let normalize = if Sys.win32 then String.lowercase_ascii else fun x -> x in - fun (uri : Uri.t) (dune : Registry.Dune.t) -> - let dune_root = Registry.Dune.root dune in - let path = - let path = Uri.to_path uri in - if Filename.is_relative path then Filename.concat (Lazy.force cwd) path else path - in - let rec loop xs ys = - match xs, ys with - | x :: xs, y :: ys -> normalize x = normalize y && loop xs ys - | [], _ | _, [] -> true - in - loop (explode_path dune_root) (explode_path path) -;; - -let make_finalizer active (instance : Instance.t) = - Lazy_fiber.create (fun () -> - active.instances - <- String.Map.remove active.instances (Registry.Dune.root (Instance.source instance)); - let to_unregister = - Instance.promotions instance - |> String.Map.to_list_map ~f:(fun _ promotion -> - let path = Drpc.Diagnostic.Promotion.in_source promotion in - Uri.of_path path) - in - Document_store.unregister_promotions active.config.document_store to_unregister) -;; - -let poll active last_error = - (* a single workspaces value for one iteration of the loop *) - let workspaces = active.workspaces in - let workspace_folders = Workspaces.workspace_folders workspaces in - let* res = Poll.poll active.registry in - match res with - | Error exn -> - let+ () = - match - match last_error with - | `No_error -> `Print - | `Exn exn' -> if Poly.equal exn exn' then `Skip else `Print - with - | `Skip -> Fiber.return () - | `Print -> - let message = - sprintf - "failed to poll dune registry.\n\ - %s\n\ - Maybe you are not running dune in watch mode?\n\ - Hint: $ dune build -w" - (Printexc.to_string exn) - in - active.config.log ~type_:MessageType.Warning ~message - in - `Exn exn - | Ok _refresh -> - let remaining, to_kill = - String.Map.partition active.instances ~f:(fun (running : Instance.t) -> - let source = Instance.source running in - List.exists workspace_folders ~f:(fun (wsf : WorkspaceFolder.t) -> - uri_dune_overlap wsf.uri source)) - in - let to_kill = String.Map.values to_kill in - active.instances <- remaining; - let* connected = - let to_create = - (* won't work very well with large workspaces and many instances of - dune *) - let is_running dune = String.Map.mem active.instances (Registry.Dune.root dune) in - Registry.current active.registry - |> List.fold_left ~init:[] ~f:(fun acc dune -> - if - (not (is_running dune)) - && List.exists workspace_folders ~f:(fun (wsf : WorkspaceFolder.t) -> - uri_dune_overlap wsf.uri dune) - then Instance.create dune active.config :: acc - else acc) - in - List.map to_create ~f:(fun instance -> - let source = Instance.source instance in - let root = Registry.Dune.root source in - root, instance) - |> String.Map.of_list_multi - |> String.Map.values - |> Fiber.parallel_map ~f:(fun instances -> - (* TODO put timeouts on all this stuff *) - let rec loop = function - | [] -> Fiber.return None - | instance :: xs -> - let* res = Instance.connect instance in - (match res with - | Error () -> loop xs - | Ok () -> - let+ () = - match xs with - | [] -> Fiber.return () - | _ -> - let message = - Format.asprintf - (* TODO print the actual intsances skipped instead - once the RPC gives us access to the pid's *) - "workspace %s ignores %d dune instances" - (Instance.source instance |> Registry.Dune.root) - (List.length xs) - in - active.config.log ~type_:Error ~message - in - Some instance) - in - loop instances) - |> Fiber.map ~f:List.filter_opt - in - let* () = - let send f x = - if x = [] - then Fiber.return () - else - let* running = Fiber.Pool.running active.pool in - match running with - | false -> Fiber.return () - | true -> Fiber.Pool.task active.pool ~f:(fun () -> f x) - in - send (Fiber.parallel_iter ~f:Instance.stop) to_kill - in - let+ () = - match connected with - | [] -> Fiber.return () - | _ -> - active.instances - <- List.fold_left - connected - ~init:active.instances - ~f:(fun acc (instance : Instance.t) -> - let source = Instance.source instance in - (* this is guaranteed not to raise since we don't connect to more - than one dune instance per workspace *) - String.Map.add_exn acc (Registry.Dune.root source) instance); - Fiber.parallel_iter connected ~f:(fun (instance : Instance.t) -> - let cleanup = make_finalizer active instance in - let* (_ : (unit, unit) result) = - Fiber.map_reduce_errors - (module Monoid.Unit) - (fun () -> Instance.run instance) - ~on_error:(fun exn -> - let message = - Format.asprintf - "disconnected %s:@.%a" - (Registry.Dune.root (Instance.source instance)) - Exn_with_backtrace.pp_uncaught - exn - in - let* () = active.config.log ~type_:Error ~message in - Lazy_fiber.force cleanup) - in - Lazy_fiber.force cleanup) - in - `No_error -;; - -type state = - | Closed - | Active of active - -type t = state ref - -let stop (t : t) = - Fiber.of_thunk (fun () -> - match !t with - | Closed -> Fiber.return () - | Active active -> - t := Closed; - Fiber.fork_and_join_unit - (fun () -> Fiber.Pool.stop active.pool) - (fun () -> - String.Map.values active.instances |> Fiber.parallel_iter ~f:Instance.stop)) -;; - -let env = Sys.getenv_opt - -let create - workspaces - (client_capabilities : ClientCapabilities.t) - diagnostics - progress - document_store - ~log - = - let config = - let include_promotions = - (let open Option.O in - let* td = client_capabilities.textDocument in - let* diagnostics = td.publishDiagnostics in - diagnostics.dataSupport) - |> Option.value ~default:false - && - match client_capabilities.experimental with - | Some (`Assoc xs) -> - (match List.assoc xs (fst view_promotion_capability) with - | Some (`Bool b) -> b - | _ -> false) - | _ -> false - in - { document_store; diagnostics; progress; include_promotions; log } - in - let registry = Registry.create (Registry.Config.create (Xdg.create ~env ())) in - ref - (Active - { pool = Fiber.Pool.create () - ; instances = String.Map.empty - ; config - ; registry - ; workspaces - }) -;; - -let create - workspaces - (client_capabilities : ClientCapabilities.t) - diagnostics - progress - document_store - ~log - = - if inside_test - then ref Closed - else create workspaces client_capabilities diagnostics progress document_store ~log -;; - -let run_loop t = - Fiber.repeat_while ~init:`No_error ~f:(fun state -> - match !t with - | Closed -> Fiber.return None - | Active active -> - let* state = poll active state in - (* TODO make this a bit more dynamic. if poll completes fast, wait more, - if it's slow, then wait less *) - let+ () = Lev_fiber.Timer.sleepf 0.25 in - Some state) -;; - -let run t : unit Fiber.t = - Fiber.of_thunk (fun () -> - match !t with - | Closed -> Fiber.return () - | Active active -> - Fiber.fork_and_join_unit - (fun () -> run_loop t) - (fun () -> Fiber.Pool.run active.pool)) -;; - -let update_workspaces t workspaces = - match !t with - | Closed -> Code_error.raise "dune is already closed" [] - | Active active -> active.workspaces <- workspaces -;; - -module Promote = struct - module Input = struct - type t = - { dune : string - ; in_source : string - } - - let yojson_of_t { dune; in_source } : Json.t = - `Assoc [ "dune", `String dune; "in_source", Json.Conv.yojson_of_string in_source ] - ;; - - let t_of_yojson = function - | `Assoc fields -> - let dune = Json.field_exn fields "dune" Json.Conv.string_of_yojson in - let in_source = Json.field_exn fields "in_source" Json.Conv.string_of_yojson in - { dune; in_source } - | json -> Json.error "invalid promote data" json - ;; - - let create (dune : Registry.Dune.t) (promotion : Drpc.Diagnostic.Promotion.t) = - { dune = Registry.Dune.root dune - ; in_source = Drpc.Diagnostic.Promotion.in_source promotion - } - ;; - end - - let name = "dune/promote" - - let run t (command : ExecuteCommandParams.t) = - Fiber.of_thunk (fun () -> - match !t with - | Closed -> Fiber.return () - | Active active -> - let promote = - match command.arguments with - | Some [ arg ] -> Input.t_of_yojson arg - | _ -> assert false - in - (match String.Map.find active.instances promote.dune with - | None -> - let message = sprintf "dune %S already disconected" promote.dune in - Jsonrpc.Response.Error.raise - (Jsonrpc.Response.Error.make ~code:InternalError ~message ()) - | Some instance -> - (match Instance.client instance with - | None -> - (* we can also just wait for initialization? *) - let message = sprintf "dune %S is not initialized" promote.dune in - Jsonrpc.Response.Error.raise - (Jsonrpc.Response.Error.make ~code:InternalError ~message ()) - | Some client -> - let+ res = - let* req = Client.Versioned.prepare_request client Drpc.Request.promote in - let req = - match req with - | Error _ -> assert false - | Ok req -> req - in - Client.request client req (Drpc.Path.absolute promote.in_source) - in - (match res with - | Ok () -> () - | Error _ -> ())))) - ;; -end - -let commands = [ Promote.name ] - -let code_actions (t : t) (uri : Uri.t) = - match !t with - | Closed -> [] - | Active active -> - let path = Uri.to_path uri in - String.Map.fold active.instances ~init:[] ~f:(fun dune acc -> - match - let promotions = Instance.promotions dune in - String.Map.find promotions path - with - | None -> acc - | Some promotion -> - let command = - let promote = Promote.Input.create (Instance.source dune) promotion in - Command.create - ~title:"Promote" - ~command:Promote.name - ~arguments:[ Promote.Input.yojson_of_t promote ] - () - in - let action = - CodeAction.create ~title:"Promote" ~kind:CodeActionKind.QuickFix ~command () - in - action :: acc) -;; - -let on_command t (cmd : ExecuteCommandParams.t) = - Fiber.of_thunk (fun () -> - if cmd.command <> Promote.name - then - Jsonrpc.Response.Error.raise - (Jsonrpc.Response.Error.make ~code:InvalidRequest ~message:"invalid command" ()); - let* () = Promote.run t cmd in - Fiber.return `Null) -;; - -let for_doc t doc = - match !t with - | Closed -> [] - | Active t -> - let uri = Document.uri doc in - String.Map.fold ~init:[] t.instances ~f:(fun instance acc -> - if uri_dune_overlap uri (Instance.source instance) then instance :: acc else acc) -;; diff --git a/ocaml-lsp-server/src/dune.mli b/ocaml-lsp-server/src/dune.mli deleted file mode 100644 index 721ff9c57..000000000 --- a/ocaml-lsp-server/src/dune.mli +++ /dev/null @@ -1,28 +0,0 @@ -open! Import - -module Instance : sig - type t - - val format_dune_file : t -> Document.t -> string Fiber.t -end - -type t - -val view_promotion_capability : string * Json.t -val run : t -> unit Fiber.t - -val create - : Workspaces.t - -> ClientCapabilities.t - -> Diagnostics.t - -> Progress.t - -> Document_store.t - -> log:(type_:MessageType.t -> message:string -> unit Fiber.t) - -> t - -val update_workspaces : t -> Workspaces.t -> unit -val stop : t -> unit Fiber.t -val commands : string list -val on_command : t -> ExecuteCommandParams.t -> Json.t Fiber.t -val code_actions : t -> Uri.t -> CodeAction.t list -val for_doc : t -> Document.t -> Instance.t list diff --git a/ocaml-lsp-server/src/folding_range.ml b/ocaml-lsp-server/src/folding_range.ml index 089e41548..2d31f405b 100644 --- a/ocaml-lsp-server/src/folding_range.ml +++ b/ocaml-lsp-server/src/folding_range.ml @@ -19,14 +19,14 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = in let iterator = let type_declaration - (_self : Ast_iterator.iterator) - (typ_decl : Parsetree.type_declaration) + (_self : Ast_iterator.iterator) + (typ_decl : Parsetree.type_declaration) = Range.of_loc typ_decl.ptype_loc |> push in let type_extension - (_self : Ast_iterator.iterator) - (typ_ext : Parsetree.type_extension) + (_self : Ast_iterator.iterator) + (typ_ext : Parsetree.type_extension) = let loc = typ_ext.ptyext_path.loc in let last_constr = List.last typ_ext.ptyext_constructors in @@ -38,8 +38,8 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = Range.of_loc loc |> push in let module_type_declaration - (self : Ast_iterator.iterator) - (mod_typ_decl : Parsetree.module_type_declaration) + (self : Ast_iterator.iterator) + (mod_typ_decl : Parsetree.module_type_declaration) = Range.of_loc mod_typ_decl.pmtd_loc |> push; Option.iter mod_typ_decl.pmtd_type ~f:(fun mod_typ -> self.module_type self mod_typ) @@ -50,12 +50,13 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = let range = Range.of_loc module_type.pmty_loc in push range; Ast_iterator.default_iterator.module_type self module_type - | Pmty_ident _ | Pmty_with _ | Pmty_typeof _ | Pmty_extension _ | Pmty_alias _ -> + | Pmty_ident _ | Pmty_with _ | Pmty_typeof _ | Pmty_extension _ | Pmty_alias _ + | Pmty_strengthen (_, _) -> Ast_iterator.default_iterator.module_type self module_type in let module_declaration - (self : Ast_iterator.iterator) - (module_declaration : Parsetree.module_declaration) + (self : Ast_iterator.iterator) + (module_declaration : Parsetree.module_declaration) = let range = Range.of_loc module_declaration.pmd_loc in push range; @@ -73,15 +74,15 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = Ast_iterator.default_iterator.module_expr self module_expr in let class_declaration - (self : Ast_iterator.iterator) - (class_decl : Parsetree.class_declaration) + (self : Ast_iterator.iterator) + (class_decl : Parsetree.class_declaration) = class_decl.Parsetree.pci_loc |> Range.of_loc |> push; self.class_expr self class_decl.pci_expr in let class_description - (self : Ast_iterator.iterator) - (class_desc : Parsetree.class_description) + (self : Ast_iterator.iterator) + (class_desc : Parsetree.class_description) = class_desc.pci_loc |> Range.of_loc |> push; self.class_type self class_desc.pci_expr @@ -99,22 +100,22 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = Ast_iterator.default_iterator.class_type self class_type in let class_type_declaration - (self : Ast_iterator.iterator) - (class_type_decl : Parsetree.class_type_declaration) + (self : Ast_iterator.iterator) + (class_type_decl : Parsetree.class_type_declaration) = Range.of_loc class_type_decl.pci_loc |> push; Ast_iterator.default_iterator.class_type_declaration self class_type_decl in let class_type_field - (self : Ast_iterator.iterator) - (class_type_field : Parsetree.class_type_field) + (self : Ast_iterator.iterator) + (class_type_field : Parsetree.class_type_field) = Range.of_loc class_type_field.pctf_loc |> push; Ast_iterator.default_iterator.class_type_field self class_type_field in let value_binding - (self : Ast_iterator.iterator) - (value_binding : Parsetree.value_binding) + (self : Ast_iterator.iterator) + (value_binding : Parsetree.value_binding) = let range = Range.of_loc value_binding.pvb_loc in push range; @@ -137,17 +138,14 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = let pat (self : Ast_iterator.iterator) (p : Parsetree.pattern) = let open Parsetree in match p.ppat_desc with - | Ppat_record (bdgs, _) -> + | Ppat_record (bdgs, _) | Ppat_record_unboxed_product (bdgs, _) -> Range.of_loc p.ppat_loc |> push; List.iter bdgs ~f:(fun (lident, pat) -> let lident_range = Range.of_loc lident.Asttypes.loc in let pat_range = Range.of_loc pat.Parsetree.ppat_loc in push { Range.start = lident_range.end_; end_ = pat_range.end_ }) - | Ppat_var _ - | Ppat_alias _ - | Ppat_constant _ - | Ppat_interval _ - | Ppat_tuple _ + | Ppat_var _ | Ppat_alias _ | Ppat_constant _ | Ppat_interval _ | Ppat_tuple _ + | Ppat_unboxed_tuple (_, _) | Ppat_construct _ | Ppat_variant _ | Ppat_array _ @@ -159,8 +157,7 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = | Ppat_exception _ | Ppat_extension _ | Ppat_open _ - | Ppat_any - | _ -> Ast_iterator.default_iterator.pat self p + | Ppat_any -> Ast_iterator.default_iterator.pat self p in let expr (self : Ast_iterator.iterator) (expr : Parsetree.expression) = match expr.pexp_desc with @@ -174,7 +171,7 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = let range = Range.of_loc letop.let_.pbop_loc in push range; Ast_iterator.default_iterator.expr self expr - | Pexp_record (bdgs, old_record) -> + | Pexp_record (bdgs, old_record) | Pexp_record_unboxed_product (bdgs, old_record) -> Range.of_loc expr.pexp_loc |> push; Option.iter old_record ~f:(self.expr self); List.iter bdgs ~f:(fun (lident, expr) -> @@ -205,38 +202,45 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = | Pexp_lazy _ | Pexp_letexception _ | Pexp_tuple _ + | Pexp_unboxed_tuple _ | Pexp_construct _ | Pexp_ident _ | Pexp_constant _ | Pexp_variant _ | Pexp_field _ + | Pexp_unboxed_field _ | Pexp_setfield _ | Pexp_array _ | Pexp_coerce _ | Pexp_send _ | Pexp_new _ - | Pexp_setinstvar _ + | Pexp_setvar _ | Pexp_override _ | Pexp_assert _ - | Pexp_unreachable -> Ast_iterator.default_iterator.expr self expr + | Pexp_stack _ + | Pexp_comprehension _ + | Pexp_unreachable + | Pexp_hole + | Pexp_overwrite _ + | Pexp_idx _ -> Ast_iterator.default_iterator.expr self expr in let module_binding - (self : Ast_iterator.iterator) - (module_binding : Parsetree.module_binding) + (self : Ast_iterator.iterator) + (module_binding : Parsetree.module_binding) = Range.of_loc module_binding.pmb_loc |> push; self.module_expr self module_binding.pmb_expr in let open_declaration - (self : Ast_iterator.iterator) - (open_decl : Parsetree.open_declaration) + (self : Ast_iterator.iterator) + (open_decl : Parsetree.open_declaration) = Range.of_loc open_decl.popen_loc |> push; self.module_expr self open_decl.popen_expr in let value_description - (_self : Ast_iterator.iterator) - (value_desc : Parsetree.value_description) + (_self : Ast_iterator.iterator) + (value_desc : Parsetree.value_description) = Range.of_loc value_desc.pval_loc |> push in @@ -246,6 +250,7 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = | Pstr_class _ | Pstr_modtype _ | Pstr_type _ + | Pstr_kind_abbrev _ | Pstr_module _ | Pstr_eval _ | Pstr_recmodule _ @@ -255,7 +260,7 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = | Pstr_extension _ -> Range.of_loc structure_item.pstr_loc |> push; Ast_iterator.default_iterator.structure_item self structure_item - | Pstr_include { pincl_loc; pincl_mod; pincl_attributes } -> + | Pstr_include { pincl_loc; pincl_mod; pincl_attributes; pincl_kind = _ } -> push @@ Range.of_loc pincl_loc; self.module_expr self pincl_mod; self.attributes self pincl_attributes @@ -294,14 +299,14 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) = List.rev_map !ranges ~f:folding_range ;; -let compute (state : State.t) (params : FoldingRangeParams.t) = +let compute ~log_info (state : State.t) (params : FoldingRangeParams.t) = Fiber.of_thunk (fun () -> let doc = Document_store.get state.store params.textDocument.uri in match Document.kind doc with | `Other -> Fiber.return None | `Merlin m -> let+ ranges = - Document.Merlin.with_pipeline_exn ~name:"folding range" m (fun pipeline -> + Document.Merlin.with_pipeline_exn ~log_info m (fun pipeline -> let parsetree = Mpipeline.reader_parsetree pipeline in fold_over_parsetree parsetree) in diff --git a/ocaml-lsp-server/src/folding_range.mli b/ocaml-lsp-server/src/folding_range.mli index e6b9a9abd..0d10da126 100644 --- a/ocaml-lsp-server/src/folding_range.mli +++ b/ocaml-lsp-server/src/folding_range.mli @@ -3,4 +3,8 @@ open Import (** Compute the folding range *) -val compute : State.t -> FoldingRangeParams.t -> FoldingRange.t list option Fiber.t +val compute + : log_info:Lsp_timing_logger.t + -> State.t + -> FoldingRangeParams.t + -> FoldingRange.t list option Fiber.t diff --git a/ocaml-lsp-server/src/hover_req.ml b/ocaml-lsp-server/src/hover_req.ml index 3ad6eb739..c65c73711 100644 --- a/ocaml-lsp-server/src/hover_req.ml +++ b/ocaml-lsp-server/src/hover_req.ml @@ -6,6 +6,12 @@ type mode = | Extended_fixed of int | Extended_variable +type extended_hover = + { hover : Hover.t + ; verbosity : int + ; can_increase_verbosity : bool + } + (* possibly overwrite the default mode using an environment variable *) let environment_mode = match Env_vars._IS_HOVER_EXTENDED () with @@ -13,21 +19,9 @@ let environment_mode = | Some false | None -> Default ;; -let hover_at_cursor parsetree (`Logical (cursor_line, cursor_col)) = +let hover_at_cursor parsetree position = let result = ref None in - let is_at_cursor ({ loc_start; loc_end; _ } : Ocaml_parsing.Location.t) = - let start_col = loc_start.pos_cnum - loc_start.pos_bol in - let end_col = loc_end.pos_cnum - loc_end.pos_bol in - let at_or_after_start = - loc_start.pos_lnum < cursor_line - || (loc_start.pos_lnum = cursor_line && start_col <= cursor_col) - in - let before_or_at_end = - loc_end.pos_lnum > cursor_line - || (loc_end.pos_lnum = cursor_line && end_col >= cursor_col) - in - at_or_after_start && before_or_at_end - in + let is_at_cursor = Util.is_at_cursor position in (* Hover location matches a variable binding *) let pat (self : Ast_iterator.iterator) (pattern : Parsetree.pattern) = if is_at_cursor pattern.ppat_loc @@ -57,40 +51,48 @@ let hover_at_cursor parsetree (`Logical (cursor_line, cursor_col)) = if is_at_cursor expr.pexp_loc then ( match expr.pexp_desc with - | Pexp_constant _ | Pexp_variant _ | Pexp_pack _ -> result := Some `Type_enclosing + | Pexp_constant _ | Pexp_variant _ | Pexp_pack _ | Pexp_record _ -> + result := Some `Type_enclosing | Pexp_ident { loc; _ } | Pexp_construct ({ loc; _ }, _) | Pexp_field (_, { loc; _ }) -> if is_at_cursor loc then result := Some `Type_enclosing else Ast_iterator.default_iterator.expr self expr - | Pexp_record (fields, _) -> - (* On a record, each field may be hovered. *) - let is_on_field = - List.exists fields ~f:(fun (({ loc; _ } : _ Asttypes.loc), _) -> - is_at_cursor loc) - in - if is_on_field - then result := Some `Type_enclosing - else Ast_iterator.default_iterator.expr self expr | Pexp_function _ | Pexp_lazy _ -> (* Anonymous function expressions can be hovered on the keyword [fun] or [function]. Lazy expressions can also be hovered on the [lazy] keyword. *) - let is_at_keyword = + let is_at_keyword ~keyword ~(keyword_loc : Loc.t) = let keyword_len = - match expr.pexp_desc with - | Pexp_function _ -> 8 - | Pexp_lazy _ -> 4 - | _ -> 0 + match keyword with + | `Fun -> 3 + | `Function -> 8 + | `Lazy -> 4 in - let pos_cnum = expr.pexp_loc.loc_start.pos_cnum + keyword_len in - let end_of_keyword = { expr.pexp_loc.loc_start with pos_cnum } in + let pos_cnum = keyword_loc.loc_start.pos_cnum + keyword_len in + let end_of_keyword = { keyword_loc.loc_start with pos_cnum } in is_at_cursor - { loc_start = expr.pexp_loc.loc_start + { loc_start = keyword_loc.loc_start ; loc_end = end_of_keyword ; loc_ghost = false } in + let is_at_keyword = + match expr.pexp_desc with + | Pexp_lazy _ -> is_at_keyword ~keyword:`Lazy ~keyword_loc:expr.pexp_loc + | Pexp_function (_, _, body) -> + let is_at_fun_keyword = + is_at_keyword ~keyword:`Fun ~keyword_loc:expr.pexp_loc + in + let is_at_function_keyword = + match body with + | Pfunction_cases (_, cases_loc, _) -> + is_at_keyword ~keyword:`Function ~keyword_loc:cases_loc + | Pfunction_body _ -> false + in + is_at_fun_keyword || is_at_function_keyword + | _ -> false + in if is_at_keyword then result := Some `Type_enclosing else Ast_iterator.default_iterator.expr self expr @@ -100,8 +102,8 @@ let hover_at_cursor parsetree (`Logical (cursor_line, cursor_col)) = in (* Hover a value declaration in a signature *) let value_description - (self : Ast_iterator.iterator) - (desc : Parsetree.value_description) + (self : Ast_iterator.iterator) + (desc : Parsetree.value_description) = if is_at_cursor desc.pval_name.loc then result := Some `Type_enclosing; Ast_iterator.default_iterator.value_description self desc @@ -135,10 +137,7 @@ let hover_at_cursor parsetree (`Logical (cursor_line, cursor_col)) = | Pmod_ident { loc; _ } -> if is_at_cursor loc then result := Some `Type_enclosing | Pmod_structure _ -> let is_at_keyword = - let keyword_len = - 6 - (* struct *) - in + let keyword_len = 6 (* struct *) in let pos_cnum = expr.pmod_loc.loc_start.pos_cnum + keyword_len in is_at_cursor { loc_start = expr.pmod_loc.loc_start @@ -205,22 +204,28 @@ let format_as_code_block ~highlighter strings = ;; let format_type_enclosing - ~syntax - ~markdown - ~typ - ~doc - ~(syntax_doc : Query_protocol.syntax_doc_result option) + ~syntax + ~markdown + ~typ + ~doc + ~stack_or_heap + ~(syntax_doc : Query_protocol.Syntax_doc_result.t option) = (* TODO for vscode, we should just use the language id. But that will not work for all editors *) let syntax_doc = Option.map syntax_doc ~f:(fun syntax_doc -> + let manual_sentence = + Option.value_map syntax_doc.documentation ~default:"" + ~f:(fun doc_link -> sprintf " See [Manual](%s)" doc_link) + in sprintf - "`syntax` %s: %s. See [Manual](%s)" + "`syntax` %s: %s.%s" syntax_doc.name syntax_doc.description - syntax_doc.documentation) + manual_sentence) in + let stack_or_heap = Option.map ~f:(( ^ ) "Allocation: ") stack_or_heap in `MarkupContent (if markdown then ( @@ -233,11 +238,13 @@ let format_type_enclosing | Raw d -> d | Markdown d -> d) in - print_dividers (List.filter_opt [ type_info; syntax_doc; doc ]) + print_dividers (List.filter_opt [ type_info; syntax_doc; doc; stack_or_heap ]) in { MarkupContent.value; kind = MarkupKind.Markdown }) else ( - let value = print_dividers (List.filter_opt [ Some typ; syntax_doc; doc ]) in + let value = + print_dividers (List.filter_opt [ Some typ; syntax_doc; doc; stack_or_heap ]) + in { MarkupContent.value; kind = MarkupKind.PlainText })) ;; @@ -247,13 +254,14 @@ let format_ppx_expansion ~ppx ~expansion = ;; let type_enclosing_hover - ~(server : State.t Server.t) - ~(doc : Document.t) - ~with_syntax_doc - ~merlin - ~mode - ~uri - ~position + ~log_info + ~(server : State.t Server.t) + ~(doc : Document.t) + ~with_syntax_doc + ~merlin + ~mode + ~uri + ~position = let state = Server.state server in let verbosity = @@ -281,7 +289,7 @@ let type_enclosing_hover in let* type_enclosing = Document.Merlin.type_enclosing - ~name:"hover-enclosing" + ~log_info merlin (Position.logical position) verbosity @@ -289,7 +297,7 @@ let type_enclosing_hover in match type_enclosing with | None -> Fiber.return None - | Some { Document.Merlin.loc; typ; doc = documentation; syntax_doc } -> + | Some { Document.Merlin.loc; typ; doc = documentation; stack_or_heap; syntax_doc } -> let syntax = Document.syntax doc in let* typ = (* We ask Ocamlformat to format this type *) @@ -318,17 +326,23 @@ let type_enclosing_hover ClientCapabilities.markdown_support client_capabilities ~field:(fun td -> Option.map td.hover ~f:(fun h -> h.contentFormat)) in - format_type_enclosing ~syntax ~markdown ~typ ~doc:documentation ~syntax_doc + format_type_enclosing + ~syntax + ~markdown + ~typ + ~doc:documentation + ~stack_or_heap + ~syntax_doc in let range = Range.of_loc loc in let hover = Hover.create ~contents ~range () in - Fiber.return (Some hover) + Fiber.return (Some (`Type (typ, verbosity), hover)) ;; let ppx_expression_hover - ~ppx_parsetree - ~(expr : Parsetree.expression) - ~(ppx : string Asttypes.loc) + ~ppx_parsetree + ~(expr : Parsetree.expression) + ~(ppx : string Asttypes.loc) = let expanded_ppx = ref None in let at_expr_location (loc : Ocaml_parsing.Location.t) = @@ -359,13 +373,14 @@ let ppx_expression_hover ~ppx:ppx.txt ~expansion:(Ocaml_parsing.Pprintast.string_of_expression expr) in - Hover.create ~contents ~range ()) + let hover = Hover.create ~contents ~range () in + `Ppx, hover) ;; let typedef_attribute_hover - ~ppx_parsetree - ~(decl : Parsetree.type_declaration) - ~(attr : Parsetree.attribute) + ~ppx_parsetree + ~(decl : Parsetree.type_declaration) + ~(attr : Parsetree.attribute) = match attr.attr_name.txt with | "deriving" -> @@ -410,7 +425,14 @@ let typedef_attribute_hover | [], [] -> None | signature, [] -> ignore (Format.flush_str_formatter ()); - Pprintast.signature Format.str_formatter (List.rev signature); + let modalities = + match ppx_parsetree with + | `Interface (signature : Parsetree.signature) -> signature.psg_modalities + | `Implementation _ -> [] + in + Pprintast.signature + Format.str_formatter + (Ast_helper.Sg.mk ~modalities (List.rev signature)); Some (Format.flush_str_formatter ()) | [], structure -> Some (Pprintast.string_of_structure (List.rev structure)) | _ :: _, _ :: _ -> @@ -422,11 +444,17 @@ let typedef_attribute_hover Option.map expansion ~f:(fun expansion -> let range = Range.of_loc attr.attr_loc in let contents = format_ppx_expansion ~ppx:attr.attr_name.txt ~expansion in - Hover.create ~contents ~range ()) + let hover = Hover.create ~contents ~range () in + `Deriving, hover) | _ -> None ;; -let handle server { HoverParams.textDocument = { uri }; position; _ } mode = +let handle_internal + ~log_info + server + { HoverParams.textDocument = { uri }; position; _ } + mode + = Fiber.of_thunk (fun () -> let state : State.t = Server.state server in let doc = @@ -438,11 +466,11 @@ let handle server { HoverParams.textDocument = { uri }; position; _ } mode = | `Merlin merlin -> let* parsetree = Document.Merlin.with_pipeline_exn - ~name:"hover" + ~log_info (Document.merlin_exn doc) (fun pipeline -> Mpipeline.reader_parsetree pipeline) in - (match hover_at_cursor parsetree (Position.logical position) with + (match hover_at_cursor parsetree position with | None -> Fiber.return None | Some `Type_enclosing -> let with_syntax_doc = @@ -450,11 +478,19 @@ let handle server { HoverParams.textDocument = { uri }; position; _ } mode = | Some { enable = true } -> true | Some _ | None -> false in - type_enclosing_hover ~server ~doc ~merlin ~mode ~uri ~position ~with_syntax_doc + type_enclosing_hover + ~log_info + ~server + ~doc + ~merlin + ~mode + ~uri + ~position + ~with_syntax_doc | Some ((`Ppx_expr _ | `Ppx_typedef_attr _) as ppx_kind) -> let+ ppx_parsetree = Document.Merlin.with_pipeline_exn - ~name:"expand-ppx" + ~log_info (Document.merlin_exn doc) (fun pipeline -> Mpipeline.ppx_parsetree pipeline) in @@ -463,3 +499,44 @@ let handle server { HoverParams.textDocument = { uri }; position; _ } mode = | `Ppx_typedef_attr (decl, attr) -> typedef_attribute_hover ~ppx_parsetree ~decl ~attr))) ;; + +let handle ~log_info server params = + let mode = + let { State.configuration; _ } = Server.state server in + match configuration.data.extended_hover with + | Some { enable = true } -> Extended_variable + | Some _ | None -> environment_mode + in + let+ hover = handle_internal ~log_info server params mode in + Option.map hover ~f:snd +;; + +let handle_extended ~log_info server params ~verbosity = + let* hover = + let mode = + match verbosity with + | Some verbosity -> Extended_fixed verbosity + | None -> Extended_variable + in + handle_internal ~log_info server params mode + in + match hover with + | Some (`Type (unformatted_hover_text, verbosity), hover) -> + let+ can_increase_verbosity = + let next_verbosity = verbosity + 1 in + let state = Server.state server in + let hover_history = state.hover_extended.history in + let+ hover_next = + handle_internal ~log_info server params (Extended_fixed next_verbosity) + in + state.hover_extended.history <- hover_history; + match hover_next with + | Some (`Type (more_verbose_text, _), _) -> + not (String.equal unformatted_hover_text more_verbose_text) + | _ -> false + in + Some { hover; verbosity; can_increase_verbosity } + | Some (_, hover) -> + Fiber.return (Some { hover; verbosity = 0; can_increase_verbosity = false }) + | None -> Fiber.return None +;; diff --git a/ocaml-lsp-server/src/hover_req.mli b/ocaml-lsp-server/src/hover_req.mli index 2d69dba42..0ca7561ad 100644 --- a/ocaml-lsp-server/src/hover_req.mli +++ b/ocaml-lsp-server/src/hover_req.mli @@ -1,13 +1,23 @@ open Import -(** This module contains functionality to handle `textDocument/hover` LSP - request. *) +(** This module contains functionality to handle `textDocument/hover` LSP request. *) -type mode = - | Default - | Extended_fixed of int - | Extended_variable +type extended_hover = + { hover : Hover.t + ; verbosity : int + ; can_increase_verbosity : bool + } -(** [handle server hover_params] provides a response for LSP request - `textDocument/hover` *) -val handle : State.t Server.t -> HoverParams.t -> mode -> Hover.t option Fiber.t +(** [handle server hover_params] provides a response for LSP request `textDocument/hover` *) +val handle + : log_info:Lsp_timing_logger.t + -> State.t Server.t + -> HoverParams.t + -> Hover.t option Fiber.t + +val handle_extended + : log_info:Lsp_timing_logger.t + -> State.t Server.t + -> HoverParams.t + -> verbosity:int option + -> extended_hover option Fiber.t diff --git a/ocaml-lsp-server/src/import.ml b/ocaml-lsp-server/src/import.ml index e02857103..969fa724a 100644 --- a/ocaml-lsp-server/src/import.ml +++ b/ocaml-lsp-server/src/import.ml @@ -6,6 +6,8 @@ include struct module Code_error = Code_error module Comparable = Comparable module Exn_with_backtrace = Exn_with_backtrace + module Fdecl = Fdecl + module Fpath = Path module Int = Int module Table = Table module Tuple = Tuple @@ -64,50 +66,20 @@ module Option = struct end module String = struct - type t = string + include Stdune.String - include struct - open Stdune.String - module Map = Map - end - - let to_dyn = Dyn.string + let strip = trim include struct open Base.String - let unsafe_get = unsafe_get - let get = get - let split_lines = split_lines - let sub = sub - let equal = equal - let rsplit2 = rsplit2 - let concat = concat - let length = length - let strip = strip - let trim = strip - let drop = drop_prefix - let hash = hash - let drop_prefix = chop_prefix - let is_prefix = is_prefix - let map = map - let lowercase_ascii = lowercase - let capitalize_ascii = capitalize - let capitalize = capitalize - let split_on_char t ~sep = split t ~on:sep - let is_empty = is_empty - let split = split let chop_prefix_if_exists = chop_prefix_if_exists let chop_suffix_if_exists = chop_suffix_if_exists - let drop_prefix_if_exists = chop_prefix_if_exists - let take = prefix let substr_index_exn = substr_index_exn let substr_index = substr_index let prefix = prefix let lfindi = lfindi let filter = filter - let is_suffix = is_suffix - let extract_words = Stdune.String.extract_words end let findi = @@ -160,16 +132,16 @@ include struct include Uri let to_dyn t = Dyn.string (to_string t) - - module Map = Stdlib.Map.Make (Uri) end end (* Misc modules *) -module Drpc = Dune_rpc.V1 +module Drpc = Dune_rpc (* OCaml frontend *) module Ast_iterator = Ocaml_parsing.Ast_iterator +module Ast_helper = Ocaml_parsing.Ast_helper +module Ast_mapper = Ocaml_parsing.Ast_mapper module Asttypes = Ocaml_parsing.Asttypes module Cmt_format = Ocaml_typing.Cmt_format module Ident = Ocaml_typing.Ident @@ -242,7 +214,6 @@ module Format = Merlin_utils.Std.Format include struct open Lsp_fiber module Log = Private.Log - module Fdecl = Private.Fdecl module Reply = Rpc.Reply module Server = Server module Lazy_fiber = Lsp_fiber.Lazy_fiber @@ -269,6 +240,12 @@ include struct ;; end + module CallHierarchyIncomingCall = CallHierarchyIncomingCall + module CallHierarchyIncomingCallsParams = CallHierarchyIncomingCallsParams + module CallHierarchyItem = CallHierarchyItem + module CallHierarchyOutgoingCallsParams = CallHierarchyOutgoingCallsParams + module CallHierarchyOutgoingCall = CallHierarchyOutgoingCall + module CallHierarchyPrepareParams = CallHierarchyPrepareParams module CodeAction = CodeAction module CodeActionKind = CodeActionKind module CodeActionOptions = CodeActionOptions diff --git a/ocaml-lsp-server/src/inference.ml b/ocaml-lsp-server/src/inference.ml index d51401e31..f24200425 100644 --- a/ocaml-lsp-server/src/inference.ml +++ b/ocaml-lsp-server/src/inference.ml @@ -2,8 +2,8 @@ open Import open Fiber.O module Printtyp = Merlin_analysis.Type_utils.Printtyp -let get_typer doc = - Document.Merlin.with_pipeline_exn ~name:"infer interface" doc (fun pipeline -> +let get_typer ~log_info doc = + Document.Merlin.with_pipeline_exn ~log_info doc (fun pipeline -> Mpipeline.typer_result pipeline) ;; @@ -15,7 +15,7 @@ let get_doc_signature typer = ;; (** Called by the code action for insert-interface. *) -let infer_missing_intf_for_impl impl_doc intf_doc = +let infer_missing_intf_for_impl ~log_info impl_doc intf_doc = match Document.kind impl_doc, Document.kind intf_doc with | `Merlin impl, `Merlin intf when Document.Merlin.kind impl = Impl && Document.Merlin.kind intf = Intf -> @@ -27,7 +27,7 @@ let infer_missing_intf_for_impl impl_doc intf_doc = not (List.mem existing_ids id ~equal:Ident.equal)) full_sig in - let* typers = Fiber.parallel_map ~f:get_typer [ impl; intf ] in + let* typers = Fiber.parallel_map ~f:(get_typer ~log_info) [ impl; intf ] in (match typers with | [ impl_typer; intf_typer ] -> let full_sig = get_doc_signature impl_typer in @@ -45,14 +45,14 @@ let infer_missing_intf_for_impl impl_doc intf_doc = (* No longer involved in the insert-interface code action, but still used by the [ocamllsp/inferIntf] custom request. *) -let infer_intf_for_impl doc = +let infer_intf_for_impl ~log_info doc = match Document.kind doc with | `Other -> Code_error.raise "expected an implementation document, got a non merlin document" [] | `Merlin m when Document.Merlin.kind m = Intf -> Code_error.raise "expected an implementation document, got an interface instead" [] | `Merlin doc -> - Document.Merlin.with_pipeline_exn ~name:"infer-interface" doc (fun pipeline -> + Document.Merlin.with_pipeline_exn ~log_info doc (fun pipeline -> let typer = Mpipeline.typer_result pipeline in let sig_ : Types.signature = let typedtree = Mtyper.get_typedtree typer in @@ -66,41 +66,7 @@ let infer_intf_for_impl doc = Format.asprintf "%a@." Printtyp.signature sig_)) ;; -let language_id_of_fname s = - match Filename.extension s with - | ".mli" | ".eliomi" -> "ocaml.interface" - | ".ml" | ".eliom" -> "ocaml" - | ".rei" | ".re" -> "reason" - | ".mll" -> "ocaml.ocamllex" - | ".mly" -> "ocaml.menhir" - | ext -> Code_error.raise "unsupported file extension" [ "extension", String ext ] -;; - -let open_document_from_file (state : State.t) uri = - let filename = Uri.to_path uri in - Fiber.of_thunk (fun () -> - match Io.String_path.read_file filename with - | exception Sys_error _ -> - Log.log ~section:"debug" (fun () -> - Log.msg "Unable to open file" [ "filename", `String filename ]); - Fiber.return None - | text -> - let languageId = language_id_of_fname filename in - let text_document = TextDocumentItem.create ~uri ~languageId ~version:0 ~text in - let params = DidOpenTextDocumentParams.create ~textDocument:text_document in - let+ doc = - let position_encoding = State.position_encoding state in - Document.make - ~position_encoding - (State.wheel state) - state.merlin_config - state.merlin - params - in - Some doc) -;; - -let infer_intf (state : State.t) intf_doc = +let infer_intf ~log_info (state : State.t) intf_doc = match Document.kind intf_doc with | `Other -> Code_error.raise "the provided document is not a merlin source." [] | `Merlin m when Document.Merlin.kind m = Impl -> @@ -114,34 +80,47 @@ let infer_intf (state : State.t) intf_doc = let* impl_opt = match Document_store.get_opt state.store impl_uri with | Some impl -> Fiber.return (Some impl) - | None -> open_document_from_file state impl_uri + | None -> Util.open_document_from_file state impl_uri in match impl_opt with | None -> Fiber.return None | Some impl_doc -> - let+ res = infer_missing_intf_for_impl impl_doc intf_doc in + let+ res = infer_missing_intf_for_impl ~log_info impl_doc intf_doc in Some res) ;; -(** Extracts an [Ident.t] from all variants that have one at the top level. For - many of the other variants, it would be possible to extract a list of IDs, - but that's not needed for the update-signatures code action. *) -let top_level_id item = - match Merlin_analysis.Typedtree_utils.extract_toplevel_identifier item with - | [ ident ] -> Some ident - | _ -> None +(** Extracts an [Ident.t] from all variants that have one at the top level. For many of + the other variants, it would be possible to extract a list of IDs, but that's not + needed for the update-signatures code action. *) +let top_level_id (item : Typedtree.signature_item) = + match item.sig_desc with + | Typedtree.Tsig_value { val_id; _ } -> Some val_id + | Typedtree.Tsig_module { md_id; _ } -> md_id + | Typedtree.Tsig_modsubst { ms_id; _ } -> Some ms_id + | Typedtree.Tsig_modtype { mtd_id; _ } -> Some mtd_id + | Typedtree.Tsig_modtypesubst { mtd_id; _ } -> Some mtd_id + | Typedtree.Tsig_type _ + | Typedtree.Tsig_typesubst _ + | Typedtree.Tsig_typext _ + | Typedtree.Tsig_exception _ + | Typedtree.Tsig_recmodule _ + | Typedtree.Tsig_open _ + | Typedtree.Tsig_include _ + | Typedtree.Tsig_class _ + | Typedtree.Tsig_class_type _ + | Typedtree.Tsig_attribute _ -> None ;; -(** Represents an item that's present in the existing interface and has a - (possibly differing) signature inferred from the implementation. *) +(** Represents an item that's present in the existing interface and has a (possibly + differing) signature inferred from the implementation. *) type shared_signature = { range : Range.t (* location in the interface *) ; old_sig : Types.signature_item (* found in the interface *) ; new_sig : Types.signature_item (* inferred from the implementation *) } -(** Try to make a [shared_signature], if an ID can be extracted from the - [tree_item] and a matching ID can be found in both signature lists. *) +(** Try to make a [shared_signature], if an ID can be extracted from the [tree_item] and a + matching ID can be found in both signature lists. *) let find_shared_signature tree_item ~old_sigs ~new_sigs = let open Option.O in let* id = top_level_id tree_item in @@ -152,15 +131,14 @@ let find_shared_signature tree_item ~old_sigs ~new_sigs = Some { range; old_sig; new_sig } ;; -(** Slices out the signatures between [first] and [last] to speed up future - searches. This assumes that [first] and [last] came from the [sig_items] - field on a [Typedtree.signature], and [sig_type_list] is the [sig_type] - field on the same [Typedtree.signature], meaning that the lists will be in - the same order. *) +(** Slices out the signatures between [first] and [last] to speed up future searches. This + assumes that [first] and [last] came from the [sig_items] field on a + [Typedtree.signature], and [sig_type_list] is the [sig_type] field on the same + [Typedtree.signature], meaning that the lists will be in the same order. *) let select_matching_range ~first ~last sig_type_list = let index_of item = let open Option.O in - let* item in + let* item = item in let* id = top_level_id item in let* i, _ = List.findi sig_type_list ~f:(fun _ item -> @@ -175,14 +153,13 @@ let select_matching_range ~first ~last sig_type_list = List.sub sig_type_list ~pos:start_index ~len:(end_index + 1 - start_index) ;; -(** Formats both the old and new signatures as they would appear in the - interface. If they differ, create a text edit that updates to the new - signature. *) +(** Formats both the old and new signatures as they would appear in the interface. If they + differ, create a text edit that updates to the new signature. *) let text_edit_opt shared_signature ~formatter = - (* CR-someday bwiedenbeck: We're relying on string equivalence of how the two signatures - are printed to decide if there's been an update. It'd be nice to check some sort of - logical equivalence on the actual types and then only format the ones that differ, - but that's not practical with the type information we have easy access to. *) + (* NOTE: We're relying on string equivalence of how the two signatures are printed to + decide if there's been an update. It'd be nice to check some sort of logical + equivalence on the actual types and then only format the ones that differ, but that's + not practical with the type information we have easy access to. *) let+ sig_strings = Fiber.parallel_map ~f:formatter [ shared_signature.old_sig; shared_signature.new_sig ] in @@ -192,17 +169,16 @@ let text_edit_opt shared_signature ~formatter = | _ -> None ;; -(** Produces text edits for every signature where the [formatter] produces a - different string on the [signature_item]s from the old interface and the new - implementation. *) +(** Produces text edits for every signature where the [formatter] produces a different + string on the [signature_item]s from the old interface and the new implementation. *) let build_signature_edits - ~(old_intf : Typedtree.signature) - ~(* Extracted by Merlin from the interface. *) - (range : Range.t) - ~(* Selected range in the interface. *) - (new_sigs : Types.signature) - ~(* Inferred by Merlin from the implementation. *) - (formatter : Types.signature_item -> string Fiber.t) + ~(old_intf : Typedtree.signature) + ~((* Extracted by Merlin from the interface. *) + range : Range.t) + ~((* Selected range in the interface. *) + new_sigs : Types.signature) + ~((* Inferred by Merlin from the implementation. *) + formatter : Types.signature_item -> string Fiber.t) = (* These are [Typedtree.signature_item]s, and we need them for the location. *) let in_range_tree_items = @@ -232,10 +208,11 @@ let build_signature_edits (** Called by the code action for update-signatures. *) let update_signatures - ~(state : State.t) - ~(intf_merlin : Document.Merlin.t) - ~(doc : Document.t) - ~(range : Range.t) + ~log_info + ~(state : State.t) + ~(intf_merlin : Document.Merlin.t) + ~(doc : Document.t) + ~(range : Range.t) = Fiber.of_thunk (fun () -> let intf_uri = Document.uri doc in @@ -245,20 +222,22 @@ let update_signatures let* impl_doc = match Document_store.get_opt state.store impl_uri with | Some impl -> Fiber.return (Some impl) - | None -> open_document_from_file state impl_uri + | None -> Util.open_document_from_file state impl_uri in match impl_doc with | None -> Fiber.return [] | Some impl_doc -> let impl_merlin = Document.merlin_exn impl_doc in - (* CR-someday bwiedenbeck: These calls to Merlin to get the type information (and - the subsequent processing we do with it) are expensive on large documents. - This can cause problems if someone is trying to invoke some other code action, - because the LSP currently determines which CAs are possible by trying them all. - We've decided for now to allow slow code actions (especially since users are - less likely to be doing lots of little CAs in the mli file) and think more - about the broader CA protocol in the future. *) - let* typers = Fiber.parallel_map [ intf_merlin; impl_merlin ] ~f:get_typer in + (* NOTE: These calls to Merlin to get the type information (and the subsequent + processing we do with it) are expensive on large documents. This can cause + problems if someone is trying to invoke some other code action, because the LSP + currently determines which CAs are possible by trying them all. We've decided for + now to allow slow code actions (especially since users are less likely to be + doing lots of little CAs in the mli file) and think more about the broader CA + protocol in the future. *) + let* typers = + Fiber.parallel_map [ intf_merlin; impl_merlin ] ~f:(get_typer ~log_info) + in let intf_typer = List.hd_exn typers in let impl_typer = List.nth_exn typers 1 in (match Mtyper.get_typedtree intf_typer with diff --git a/ocaml-lsp-server/src/inference.mli b/ocaml-lsp-server/src/inference.mli index be37d4235..09f9957f6 100644 --- a/ocaml-lsp-server/src/inference.mli +++ b/ocaml-lsp-server/src/inference.mli @@ -1,24 +1,29 @@ -val infer_intf_for_impl : Document.t -> string Fiber.t +val infer_intf_for_impl : log_info:Lsp_timing_logger.t -> Document.t -> string Fiber.t -(** Called by the code action "insert inferred interface". Gets the Merlin - typer_result for both the implementation and interface documents, and uses - the diff between them to produce the updated interface. Any names present in - the existing interface are omitted from the inserted code (regardless of - whether their signatures have changed). *) +(** Called by the code action "insert inferred interface". Gets the Merlin typer_result + for both the implementation and interface documents, and uses the diff between them to + produce the updated interface. Any names present in the existing interface are omitted + from the inserted code (regardless of whether their signatures have changed). *) val infer_missing_intf_for_impl - : Document.t (** implementation *) + : log_info:Lsp_timing_logger.t + -> Document.t (** implementation *) -> Document.t (** interface *) -> string Fiber.t (** code to be inserted in the interface *) -val infer_intf : State.t -> Document.t -> string option Fiber.t +val infer_intf + : log_info:Lsp_timing_logger.t + -> State.t + -> Document.t + -> string option Fiber.t -(** Called by the code action "update signature(s) to match implementation". - Compares signatures found in the selected range of the interface document - with ones inferred from the corresponding implementation document, and - produces text edits for any that can be updated. *) +(** Called by the code action "update signature(s) to match implementation". Compares + signatures found in the selected range of the interface document with ones inferred + from the corresponding implementation document, and produces text edits for any that + can be updated. *) val update_signatures - : state:State.t + : log_info:Lsp_timing_logger.t + -> state:State.t -> intf_merlin:Document.Merlin.t -> doc:Document.t -> range:Range.t diff --git a/ocaml-lsp-server/src/inlay_hints.ml b/ocaml-lsp-server/src/inlay_hints.ml index daf085a39..955476b52 100644 --- a/ocaml-lsp-server/src/inlay_hints.ml +++ b/ocaml-lsp-server/src/inlay_hints.ml @@ -1,16 +1,235 @@ open Import open Fiber.O -let outline_type typ = - typ - |> Format.asprintf "@[: %s@]" +let range_overlaps_loc range loc = + match Range.of_loc_opt loc with + | Some range' -> Range.overlaps range range' + | None -> false +;; + +let outline_type ~env typ = + Ocaml_typing.Printtyp.wrap_printing_env env (fun () -> + Format.asprintf "@[: %a@]" Ocaml_typing.Printtyp.type_scheme typ) |> String.extract_words ~is_word_char:(function | ' ' | '\t' | '\n' -> false | _ -> true) |> String.concat ~sep:" " ;; -let compute (state : State.t) { InlayHintParams.range; textDocument = { uri }; _ } = +let hint_binding_iter + ?(hint_let_bindings = false) + ?(hint_pattern_variables = false) + ?(hint_function_params = false) + typedtree + range + k + = + let module I = Ocaml_typing.Tast_iterator in + (* to be used for pattern variables in match cases, but not for function + arguments *) + let case hint_lhs (iter : I.iterator) (case : _ Typedtree.case) = + if hint_lhs then iter.pat iter case.c_lhs; + Option.iter case.c_guard ~f:(iter.expr iter); + iter.expr iter case.c_rhs + in + let value_binding hint_lhs (iter : I.iterator) (vb : Typedtree.value_binding) = + if range_overlaps_loc range vb.vb_loc + then + if not hint_lhs + then iter.expr iter vb.vb_expr + else ( + match vb.vb_expr.exp_desc with + | Texp_function _ -> iter.expr iter vb.vb_expr + | _ -> I.default_iterator.value_binding iter vb) + in + let expr (iter : I.iterator) (e : Typedtree.expression) = + if range_overlaps_loc range e.exp_loc + then ( + match e.exp_desc with + | Texp_function { body; params; _ } -> + (match body with + | Tfunction_cases { fc_cases; _ } -> + if hint_function_params + then + List.iter params ~f:(fun (param : Typedtree.function_param) -> + match param.fp_kind with + | Tparam_pat pat -> iter.pat iter pat + | Tparam_optional_default (pat, _, _) -> iter.pat iter pat); + List.iter fc_cases ~f:(fun { Typedtree.c_lhs; c_rhs; _ } -> + if hint_pattern_variables then iter.pat iter c_lhs; + iter.expr iter c_rhs) + | Tfunction_body body when not hint_function_params -> iter.expr iter body + | _ -> I.default_iterator.expr iter e) + | Texp_let (_, vbs, body) -> + List.iter vbs ~f:(value_binding hint_let_bindings iter); + iter.expr iter body + | Texp_letop { body; _ } -> case hint_let_bindings iter body + | Texp_match (expr, _, cases, _) -> + iter.expr iter expr; + List.iter cases ~f:(case hint_pattern_variables iter) + (* Stop iterating when we see a ghost location to avoid annotating generated code *) + | _ when e.exp_loc.loc_ghost && not inside_test -> () + | _ -> I.default_iterator.expr iter e) + in + let structure_item (iter : I.iterator) (item : Typedtree.structure_item) = + if range_overlaps_loc range item.str_loc + then ( + match item.str_desc with + | Typedtree.Tstr_value (_, vbs) -> + List.iter vbs ~f:(fun (vb : Typedtree.value_binding) -> expr iter vb.vb_expr) + (* Stop iterating when we see a ghost location to avoid annotating generated code *) + | _ when item.str_loc.loc_ghost && not inside_test -> () + | _ -> I.default_iterator.structure_item iter item) + in + let pat (type k) iter (pat : k Typedtree.general_pattern) = + if range_overlaps_loc range pat.pat_loc + then ( + let has_constraint = + List.exists pat.pat_extra ~f:(fun (extra, _, _) -> + match extra with + | Typedtree.Tpat_constraint _ -> true + | _ -> false) + in + if not has_constraint + then ( + I.default_iterator.pat iter pat; + match pat.pat_desc with + | Tpat_var _ when not pat.pat_loc.loc_ghost -> + k pat.pat_env pat.pat_type pat.pat_loc + | _ -> ())) + in + let iterator = + { I.default_iterator with + expr + ; structure_item + ; pat + ; value_binding = value_binding true + } + in + iterator.structure iterator typedtree +;; + +let let_syntax_at typer pos = + let drop_library_name_if_in_scope + (env : Env.t) + (decl : Types.module_declaration) + (path : Path.t) + = + let rec to_lident (path : Path.t) : Longident.t = + match path with + | Pident ident -> Lident (Ident.name ident) + | Pdot (path, name) -> Ldot (to_lident path, name) + | Papply (lhs, rhs) -> Lapply (to_lident lhs, to_lident rhs) + | Pextra_ty (path, _) -> to_lident path + in + let rec drop_libname (path : Path.t) : Longident.t option = + match path with + | Pident _ -> None + | Pdot (Pident _, name) -> Some (Lident name) + | Pdot (path, name) -> + Option.map (drop_libname path) ~f:(fun ident -> Longident.Ldot (ident, name)) + | Papply _ | Pextra_ty _ -> None + in + match drop_libname path with + | Some ident -> + (try + let let_syntax : Longident.t = Ldot (Ldot (ident, "Let_syntax"), "Let_syntax") in + let _, decl' = Env.find_module_by_name let_syntax env in + if Ocaml_typing.Shape.Uid.equal decl.md_uid decl'.md_uid + then ident + else to_lident path + with + | _ -> to_lident path) + | None -> to_lident path + in + List.find_map (Mtyper.node_at typer pos) ~f:(fun (env, _) -> + try + let path, decl = Env.find_module_by_name (Lident "Let_syntax") env in + match path with + | Pdot (Pdot (path, "Let_syntax"), "Let_syntax") -> + Some (drop_library_name_if_in_scope env decl path) + | single_let_syntax -> + (* The [Let_syntax] module is avialable via an alias (e.g. like it would be when + there is an [open Async] or similar). Try to resolve the original name of the + module. *) + let rec strip_let_syntax_suffix = function + | Path.Pdot (path, "Let_syntax") -> strip_let_syntax_suffix path + | path -> path + in + let normalized = + strip_let_syntax_suffix (Env.normalize_module_path None env single_let_syntax) + in + let short = + Ocaml_typing.Short_paths.find_module (Env.short_paths env) normalized + in + Some (drop_library_name_if_in_scope env decl short) + with + | _ -> None) +;; + +let hint_let_syntax_ppx_iter typer parsetree range create_inlay_hint = + let current_let_syntax = ref [] in + let push_let_syntax pos = + match let_syntax_at typer pos with + | Some path -> + let syntax = "." ^ Format.asprintf "%a" Pprintast.longident path in + current_let_syntax := syntax :: !current_let_syntax + | None -> + (match !current_let_syntax with + | hd :: _ -> current_let_syntax := hd :: !current_let_syntax + | [] -> ()) + in + let pop_let_syntax () = + current_let_syntax + := match !current_let_syntax with + | [] -> [] + | _ :: tl -> tl + in + let structure (iter : Ast_iterator.iterator) (items : Parsetree.structure) = + let prev_let_syntax = !current_let_syntax in + let (_ : bool) = + List.fold_left + items + ~init:false + ~f:(fun should_push (item : Parsetree.structure_item) -> + if should_push then push_let_syntax item.pstr_loc.loc_start; + iter.structure_item iter item; + match item.pstr_desc with + | Pstr_open _ | Pstr_include _ -> true + | _ -> false) + in + current_let_syntax := prev_let_syntax + in + let expr (iter : Ast_iterator.iterator) (expr : Parsetree.expression) = + match expr.pexp_desc with + | Pexp_open (decl, body) -> + iter.open_declaration iter decl; + push_let_syntax expr.pexp_loc.loc_start; + iter.expr iter body; + pop_let_syntax () + | Pexp_extension (name, payload) -> + (* Generate annotation for [bind] and [map] extensions. *) + (match name.txt with + | "bind" | "map" -> + (match !current_let_syntax with + | syntax :: _ when range_overlaps_loc range name.loc -> + create_inlay_hint syntax name.loc + | _ -> ()) + | _ -> ()); + iter.payload iter payload + | _ -> Ast_iterator.default_iterator.expr iter expr + in + let iterator = { Ast_iterator.default_iterator with structure; expr } in + match parsetree with + | `Interface signature -> iterator.signature iterator signature + | `Implementation structure -> iterator.structure iterator structure +;; + +let compute + ~log_info + (state : State.t) + { InlayHintParams.range; textDocument = { uri }; _ } + = let doc = let store = state.store in Document_store.get store uri @@ -22,44 +241,64 @@ let compute (state : State.t) { InlayHintParams.range; textDocument = { uri }; _ let+ hints = let hint_let_bindings = Option.map state.configuration.data.inlay_hints ~f:(fun c -> c.hint_let_bindings) - |> Option.value ~default:false in let hint_pattern_variables = Option.map state.configuration.data.inlay_hints ~f:(fun c -> c.hint_pattern_variables) - |> Option.value ~default:false in let hint_function_params = Option.map state.configuration.data.inlay_hints ~f:(fun c -> c.hint_function_params) - |> Option.value ~default:false in - Document.Merlin.with_pipeline_exn ~name:"inlay-hints" doc (fun pipeline -> - let start = range.start |> Position.logical - and stop = range.end_ |> Position.logical in - let command = - Query_protocol.Inlay_hints - ( start - , stop - , hint_let_bindings - , hint_pattern_variables - , hint_function_params - , not inside_test ) - in - let hints = Query_commands.dispatch pipeline command in - List.filter_map - ~f:(fun (pos, label) -> - let open Option.O in - let+ position = Position.of_lexical_position pos in - let label = `String (outline_type label) in - InlayHint.create - ~kind:Type - ~position - ~label - ~paddingLeft:false - ~paddingRight:false - ()) - hints) + let hint_let_syntax_ppx = + Option.map state.configuration.data.inlay_hints ~f:(fun c -> + c.hint_let_syntax_ppx) + in + Document.Merlin.with_pipeline_exn ~log_info doc (fun pipeline -> + let hints = ref [] in + (match Mtyper.get_typedtree (Mpipeline.typer_result pipeline) with + | `Interface _ -> () + | `Implementation typedtree -> + hint_binding_iter + ?hint_let_bindings + ?hint_pattern_variables + ?hint_function_params + typedtree + range + (fun env type_ loc -> + let hint = + let label = outline_type ~env type_ in + let open Option.O in + let+ position = Position.of_lexical_position loc.loc_end in + InlayHint.create + ~kind:Type + ~position + ~label:(`String label) + ~paddingLeft:false + ~paddingRight:false + () + in + Option.iter hint ~f:(fun hint -> hints := hint :: !hints)); + if Option.value ~default:false hint_let_syntax_ppx + then + hint_let_syntax_ppx_iter + (Mpipeline.typer_result pipeline) + (Mpipeline.reader_parsetree pipeline) + range + (fun syntax loc -> + let open Option.O in + let hint = + let+ position = Position.of_lexical_position loc.loc_end in + InlayHint.create + ~kind:Type + ~position + ~label:(`String syntax) + ~paddingLeft:false + ~paddingRight:false + () + in + Option.iter hint ~f:(fun hint -> hints := hint :: !hints))); + !hints) in Some hints ;; diff --git a/ocaml-lsp-server/src/inlay_hints.mli b/ocaml-lsp-server/src/inlay_hints.mli index be8c76265..c0b1b0016 100644 --- a/ocaml-lsp-server/src/inlay_hints.mli +++ b/ocaml-lsp-server/src/inlay_hints.mli @@ -1,3 +1,7 @@ open Import -val compute : State.t -> InlayHintParams.t -> InlayHint.t list option Fiber.t +val compute + : log_info:Lsp_timing_logger.t + -> State.t + -> InlayHintParams.t + -> InlayHint.t list option Fiber.t diff --git a/ocaml-lsp-server/src/lsp_timing_logger.ml b/ocaml-lsp-server/src/lsp_timing_logger.ml new file mode 100644 index 000000000..1de370a66 --- /dev/null +++ b/ocaml-lsp-server/src/lsp_timing_logger.ml @@ -0,0 +1,113 @@ +open Core +open Async + +type t = + { event_index : int + ; action : string + ; file : string list + ; lines : int list + ; hash : int list + ; position : (int * int) list + } +[@@deriving sexp] + +let make + ~event_index + ~action + ~uris + ~texts + ~(positions : Position.t list) + ?(analyze_files = true) + () + : t + = + (* We now do the line-counting up-front to avoid duplicating work. *) + let lines, hash = + match analyze_files with + | true -> + List.map ~f:(String.count ~f:(Char.( = ) '\n')) texts, List.map ~f:Base.String.hash texts + | false -> [], [] + in + let position = List.map positions ~f:(fun p -> p.line, p.character) in + let file = List.map ~f:Lsp.Uri.to_path uris in + { event_index; action; file; lines; hash; position } +;; + +let log_lsp_timing ~wall_time (t : t) = + if not am_running_test + then + [%log.global.info + "lsp timing" + (wall_time : float) + ~event_index:(t.event_index : int) + ~action:(t.action : string) + ~file:(t.file : string list) + ~lines:(t.lines : int list) + ~hash:(t.hash : int list) + ~position:(t.position : (int * int) list)] +;; + +let with_logging ~f t = + let start_time = Core_unix.gettimeofday () in + let res = f () in + let stop_time = Core_unix.gettimeofday () in + let wall_time = (stop_time -. start_time) *. 1000. in + log_lsp_timing ~wall_time t; + res +;; + +let with_fiber_logging ~f t = + let open Fiber.O in + let start_time = Core_unix.gettimeofday () in + let+ res = f () in + let stop_time = Core_unix.gettimeofday () in + let wall_time = (stop_time -. start_time) *. 1000. in + log_lsp_timing ~wall_time t; + res +;; + +let log_merlin_timing ~wall_time ~timing_breakdown t = + if not am_running_test + then ( + let total_time = + List.fold ~f:(fun total ((_ : string), t) -> total +. t) ~init:0. timing_breakdown + in + let extract component = + Option.value + ~default:Float.nan + (List.Assoc.find timing_breakdown ~equal:String.equal component) + in + let error = extract "error" in + let pp = extract "pp" in + let ppx = extract "ppx" in + let reader = extract "reader" in + let typer = extract "typer" in + [%log.global.info + "merlin timing" + (wall_time : float) + (total_time : float) + (error : float) + (pp : float) + (ppx : float) + (reader : float) + (typer : float) + ~event_index:(t.event_index : int) + ~action:(t.action : string) + ~file:(t.file : string list) + ~lines:(t.lines : int list) + ~hash:(t.hash : int list) + ~position:(t.position : (int * int) list)]) +;; + +let log_event_start t = + if not am_running_test + then + [%log.global.info + "lsp event" + ~event_index:(t.event_index : int) + ~action:(t.action : string) + ~file:(t.file : string list) + ~lines:(t.lines : int list) + ~hash:(t.hash : int list) + ~position:(t.position : (int * int) list)] +;; diff --git a/ocaml-lsp-server/src/lsp_timing_logger.mli b/ocaml-lsp-server/src/lsp_timing_logger.mli new file mode 100644 index 000000000..ae338b0a4 --- /dev/null +++ b/ocaml-lsp-server/src/lsp_timing_logger.mli @@ -0,0 +1,62 @@ +(** Provides logging of timing information for LSP requests. *) + +(** Carries the data needed for the various logging functions. Outside this module, an + [Lsp_timing_logger.t] instance is always called [log_info]. + + Many of the fields could be represented by an option instead of a list most of the + time, but we allow for the possibility that a request involves multiple positions, + or files. In the case of 0- or 1-entry lists, the resulting sexp is the same as if we + used an option. *) +type t = + { event_index : int + (** Global index tracked in the lsp-server state; lets us associate multiple log entries + to the same lsp request. *) + ; action : string (** Name of the request/notification/etc. the lsp is handling. *) + ; file : string list (** Absolute path(s). *) + ; lines : int list (** Number of lines in the file(s). *) + ; hash : int list (** A [String.hash] of the contents of the file(s). *) + ; position : (int * int) list + (** (line,col) for the position(s) in the request. There need not be any correspondence + between the lists of positions and files. *) + } +[@@deriving sexp] + +(** Pack most of up the data that will be logged to CLM. + @param in_jane The LSP server's best guess as to whether we're in a jane/... repo. + @param uris Identifiers for the documents being acted on. + @param texts + Contents of the documents being acted on; used to log the number of lines and + characters in each file. + @param analyze_files + Set to [false] to skip computing file lengths and hashes + + Other parameters are explained on the [t] type. *) +val make + : event_index:int + -> action:string + -> uris:Lsp.Uri.t list + -> texts:string list + -> positions:Position.t list + -> ?analyze_files:bool + -> unit + -> t + +(** Times the execution of function f and logs the result as an "lsp timing" entry. + @param f a synchronous function to be timed *) +val with_logging : f:(unit -> 'a) -> t -> 'a + +(** Times the execution of Fiber f and logs the result as an "lsp timing" entry. + @param f an asynchronous fiber to be timed *) +val with_fiber_logging : f:(unit -> 'a Fiber.t) -> t -> 'a Fiber.t + +(** Logs the timings produced by a Merlin pipeline as a "merlin timing" entry. + @param wall_time time in miliseconds recorded by Single_pipeline.use + @param timing_breakdown list of sub-timings in ms from Mpipeline.timing_information *) +val log_merlin_timing + : wall_time:float + -> timing_breakdown:(string * float) list + -> t + -> unit + +(** Logs the receipt of a notification or request as an "lsp event" entry. *) +val log_event_start : t -> unit diff --git a/ocaml-lsp-server/src/merlin_config.ml b/ocaml-lsp-server/src/merlin_config.ml index a9d152a03..070760cd5 100644 --- a/ocaml-lsp-server/src/merlin_config.ml +++ b/ocaml-lsp-server/src/merlin_config.ml @@ -30,318 +30,48 @@ open Fiber.O module Std = Merlin_utils.Std module Misc = Merlin_utils.Misc -let empty = Mconfig_dot.empty_config +let dot_merlin = ref None -module Process = struct - type nonrec t = - { pid : Pid.t - ; initial_cwd : string - ; stdin : Lev_fiber.Io.output Lev_fiber.Io.t - ; stdout : Lev_fiber.Io.input Lev_fiber.Io.t - ; session : Lev_fiber_csexp.Session.t - } - - let to_dyn { pid; initial_cwd; _ } = - let open Dyn in - record [ "pid", Pid.to_dyn pid; "initial_cwd", string initial_cwd ] - ;; - - let waitpid t = - let+ status = Lev_fiber.waitpid ~pid:(Pid.to_int t.pid) in - (match status with - | Unix.WEXITED n -> - (match n with - | 0 -> () - | n -> Format.eprintf "dune finished with code = %d@.%!" n) - | WSIGNALED s -> Format.eprintf "dune finished signal = %d@.%!" s - | WSTOPPED _ -> ()); - Format.eprintf "closed merlin process@.%s@." (Dyn.to_string @@ to_dyn t); - Lev_fiber.Io.close t.stdin; - Lev_fiber.Io.close t.stdout - ;; - - let start ~dir = - match Bin.which "dune" with - | None -> - Jsonrpc.Response.Error.raise - (Jsonrpc.Response.Error.make - ~code:InternalError - ~message:"dune binary not found" - ()) - | Some prog -> - let stdin_r, stdin_w = Unix.pipe () in - let stdout_r, stdout_w = Unix.pipe () in - Unix.set_close_on_exec stdin_w; - let pid = - let argv = [ prog; "ocaml-merlin"; "--no-print-directory" ] in - Pid.of_int - (Spawn.spawn ~cwd:(Path dir) ~prog ~argv ~stdin:stdin_r ~stdout:stdout_w ()) - in - Unix.close stdin_r; - Unix.close stdout_w; - let blockity = - if Sys.win32 - then `Blocking - else ( - Unix.set_nonblock stdin_w; - Unix.set_nonblock stdout_r; - `Non_blocking true) - in - let make fd what = - let fd = Lev_fiber.Fd.create fd blockity in - Lev_fiber.Io.create fd what - in - let* stdin = make stdin_w Output in - let+ stdout = make stdout_r Input in - let session = Lev_fiber_csexp.Session.create ~socket:false stdout stdin in - { pid; initial_cwd = dir; stdin; stdout; session } - ;; -end - -module Dot_protocol_io = - Merlin_dot_protocol.Make - (Fiber) - (struct - include Lev_fiber_csexp.Session - - type in_chan = t - type out_chan = t - - let read t = - let open Fiber.O in - let+ opt = read t in - match opt with - | Some r -> Result.return r - | None -> Error "Read error" - ;; - - let write t x = write t [ x ] - end) - -let should_read_dot_merlin = ref false - -type db = - { running : (string, entry) Table.t - ; pool : Fiber.Pool.t - } - -and entry = - { db : db - ; process : Process.t - ; mutable ref_count : int - } - -module Entry = struct - type t = entry - - let create db process = { db; process; ref_count = 0 } - let equal = ( == ) - let incr t = t.ref_count <- t.ref_count + 1 - - let destroy (t : t) = - assert (t.ref_count > 0); - t.ref_count <- t.ref_count - 1; - if t.ref_count > 0 - then Fiber.return () - else ( - Table.remove t.db.running t.process.initial_cwd; - Format.eprintf - "halting dune merlin process@.%s@." - (Dyn.to_string (Process.to_dyn t.process)); - Dot_protocol_io.Commands.halt t.process.session) - ;; -end - -let get_process t ~dir = - match Table.find t.running dir with - | Some p -> Fiber.return p - | None -> - let* process = Process.start ~dir in - let entry = Entry.create t process in - Table.add_exn t.running dir entry; - let+ () = Fiber.Pool.task t.pool ~f:(fun () -> Process.waitpid process) in - entry -;; - -type context = - { workdir : string - ; process_dir : string - } - -let get_config (p : Process.t) ~workdir path_abs = - let query path (p : Process.t) = - let* () = Dot_protocol_io.Commands.send_file p.session path in - Dot_protocol_io.read p.session - in - (* Both [p.initial_cwd] and [path_abs] have gone through - [canonicalize_filename] *) - let path_rel = - String.drop_prefix ~prefix:p.initial_cwd path_abs - |> Option.map ~f:(fun path -> - (* We need to remove the leading path separator after chopping. There - is one case where no separator is left: when [initial_cwd] was the - root of the filesystem *) - if String.length path > 0 && path.[0] = Filename.dir_sep.[0] - then String.drop path 1 - else path) - in - let path = - match path_rel with - | Some path_rel -> path_rel - | _ -> path_abs - in - (* Starting with Dune 2.8.3 relative paths are prefered. However to maintain - compatibility with 2.8 <= Dune <= 2.8.2 we always retry with an absolute - path if using a relative one failed *) - let+ answer = - let* query_path = query path p in - match query_path with - | Ok [ `ERROR_MSG _ ] -> query path_abs p - | answer -> Fiber.return answer - in - match answer with - | Ok directives -> - let cfg, failures = - Mconfig_dot.prepend_config - ~dir:workdir - Mconfig_dot.Configurator.Dune - directives - empty - in - Mconfig_dot.postprocess_config cfg, failures - | Error (Merlin_dot_protocol.Unexpected_output msg) -> empty, [ msg ] - | Error (Csexp_parse_error _) -> - ( empty - , [ "ocamllsp could not load its configuration from the external reader. Building \ - your project with `dune` might solve this issue." - ] ) -;; - -let file_exists fname = - match Unix.stat fname with - | exception Unix.Unix_error (Unix.ENOENT, _, _) -> false - | s -> s.st_kind <> S_DIR -;; - -let find_project_context start_dir = - (* The workdir is the first directory we find which contains a [dune] file. We - need to keep track of this folder because [dune ocaml-merlin] might be - started from a folder that is a parent of the [workdir]. Thus we cannot - always use that starting folder as the workdir. *) - let map_workdir dir = function - | Some dir -> Some dir - | None -> - (* XXX what's ["dune-file"]? *) - let fnames = List.map ~f:(Filename.concat dir) [ "dune"; "dune-file" ] in - if List.exists ~f:file_exists fnames then Some dir else None - in - let rec loop workdir dir = - match - List.find_map [ "dune-project"; "dune-workspace" ] ~f:(fun f -> - let fname = Filename.concat dir f in - if file_exists fname - then ( - let workdir = Misc.canonicalize_filename (Option.value ~default:dir workdir) in - Some ({ workdir; process_dir = dir }, fname)) - else None) - with - | Some s -> Some s - | None -> - let parent = Filename.dirname dir in - if parent <> dir - then ( - (* Was this directory the workdir ? *) - let workdir = map_workdir dir workdir in - loop workdir parent) - else None - in - loop None start_dir -;; - -type nonrec t = +type t = { path : string - ; directory : string ; initial : Mconfig.t - ; mutable entry : Entry.t option - ; db : db } -let destroy t = - let* () = Fiber.return () in - match t.entry with - | None -> Fiber.return () - | Some entry -> - t.entry <- None; - Entry.destroy entry -;; +let destroy (_ : t) = Fiber.return () -let create db path = - let path = - let path = Uri.to_path path in - Misc.canonicalize_filename path - in - let directory = Filename.dirname path in +let create () path = let initial = - let filename = Filename.basename path in - let init = Mconfig.initial in - { init with - ocaml = { init.ocaml with real_paths = false } - ; query = { init.query with filename; directory; verbosity = Mconfig.Verbosity.Smart } + let initial = Mconfig.initial in + { initial with + ocaml = { initial.ocaml with real_paths = false } + ; query = { initial.query with verbosity = Smart } } in - { path; directory; initial; db; entry = None } + match !dot_merlin with + | Some path -> { path; initial } + | None -> + let path = + let path = Uri.to_path path in + Misc.canonicalize_filename path + in + let initial = + let filename = Filename.basename path in + let directory = Filename.dirname path in + { initial with query = { initial.query with filename; directory } } + in + { path; initial } ;; let config (t : t) : Mconfig.t Fiber.t = - let use_entry entry = - Entry.incr entry; - t.entry <- Some entry - in - let* () = Fiber.return () in - if !should_read_dot_merlin - then Fiber.return (Mconfig.get_external_config t.path t.initial) - else ( - match find_project_context t.directory with - | None -> - let+ () = destroy t in - t.initial - | Some (ctx, config_path) -> - let* entry = get_process t.db ~dir:ctx.process_dir in - let* () = - match t.entry with - | None -> - use_entry entry; - Fiber.return () - | Some entry' -> - if Entry.equal entry entry' - then Fiber.return () - else - let+ () = destroy t in - use_entry entry - in - let+ dot, failures = get_config entry.process ~workdir:ctx.workdir t.path in - let merlin = - Mconfig.merge_merlin_config dot t.initial.merlin ~failures ~config_path - in - Mconfig.normalize { t.initial with merlin }) + let+ () = Fiber.return () in + Mconfig.get_external_config t.path t.initial ;; module DB = struct - type t = db + type t = unit let get t uri = create t uri - - let create () = - { running = Table.create (module String) 0; pool = Fiber.Pool.create () } - ;; - - let run t = Fiber.Pool.run t.pool - - let stop t = - let* () = Fiber.return () in - Table.iter t.running ~f:(fun running -> - let pid = Pid.to_int running.process.pid in - Unix.kill pid (if Sys.win32 then Sys.sigkill else Sys.sigterm)); - Fiber.Pool.stop t.pool - ;; + let create () = () + let run () = Fiber.return () + let stop () = Fiber.return () end diff --git a/ocaml-lsp-server/src/merlin_config.mli b/ocaml-lsp-server/src/merlin_config.mli index bc057f038..5f4bb5de6 100644 --- a/ocaml-lsp-server/src/merlin_config.mli +++ b/ocaml-lsp-server/src/merlin_config.mli @@ -4,7 +4,7 @@ open Import type t -val should_read_dot_merlin : bool ref +val dot_merlin : string option ref val config : t -> Mconfig.t Fiber.t val destroy : t -> unit Fiber.t diff --git a/ocaml-lsp-server/src/ocaml_lsp_server.ml b/ocaml-lsp-server/src/ocaml_lsp_server.ml index ec7f8e119..4621016d4 100644 --- a/ocaml-lsp-server/src/ocaml_lsp_server.ml +++ b/ocaml-lsp-server/src/ocaml_lsp_server.ml @@ -42,7 +42,6 @@ let initialize_info (client_capabilities : ClientCapabilities.t) : InitializeRes ~f:(fun (c : Code_action.t) -> c.kind) [ Action_type_annotate.t ; Action_remove_type_annotation.t - ; Action_construct.t ; Action_refactor_open.unqualify ; Action_refactor_open.qualify ; Action_add_rec.t @@ -89,34 +88,28 @@ let initialize_info (client_capabilities : ClientCapabilities.t) : InitializeRes ; Req_switch_impl_intf.capability ; Req_infer_intf.capability ; Req_typed_holes.capability - ; Req_jump_to_typed_hole.capability + ; Req_typed_holes.jump_capability ; Req_wrapping_ast_node.capability - ; Dune.view_promotion_capability ; Req_hover_extended.capability ; Req_merlin_call_compatible.capability ; Req_type_enclosing.capability ; Req_get_documentation.capability - ; Req_construct.capability - ; Req_type_search.capability - ; Req_merlin_jump.capability ] ) ] in let executeCommandProvider = let commands = - if - Action_open_related.available - (let open Option.O in - let* window = client_capabilities.window in - window.showDocument) + if Action_open_related.available + (let open Option.O in + let* window = client_capabilities.window in + window.showDocument) then - view_metrics_command_name - :: Action_open_related.command_name - :: Action_jump.command_name - :: Document_text_command.command_name - :: Merlin_config_command.command_name - :: Dune.commands - else Dune.commands + [ view_metrics_command_name + ; Action_open_related.command_name + ; Document_text_command.command_name + ; Merlin_config_command.command_name + ] + else [] in ExecuteCommandOptions.create ~commands () in @@ -135,6 +128,7 @@ let initialize_info (client_capabilities : ClientCapabilities.t) : InitializeRes Option.some_if (List.mem options ~equal:Poly.equal encoding) encoding) in ServerCapabilities.create + ~callHierarchyProvider:(`Bool true) ~textDocumentSync ~hoverProvider:(`Bool true) ~declarationProvider:(`Bool true) @@ -146,7 +140,7 @@ let initialize_info (client_capabilities : ClientCapabilities.t) : InitializeRes ~codeLensProvider ~referencesProvider:(`Bool true) ~documentHighlightProvider:(`Bool true) - ~documentFormattingProvider:(`Bool true) + ~documentFormattingProvider:(`Bool false) ~selectionRangeProvider:(`Bool true) ~documentSymbolProvider:(`Bool true) ~workspaceSymbolProvider:(`Bool true) @@ -157,6 +151,7 @@ let initialize_info (client_capabilities : ClientCapabilities.t) : InitializeRes ~inlayHintProvider:(`Bool true) ~workspace ~executeCommandProvider + ~colorProvider:(`Bool true) ?positionEncoding () in @@ -169,59 +164,85 @@ let initialize_info (client_capabilities : ClientCapabilities.t) : InitializeRes let ocamlmerlin_reason = "ocamlmerlin-reason" -let set_diagnostics detached diagnostics doc = +(** The debounce flag controls whether to include delay (250ms with default config). This + delay appears to have been implemented to avoid spamming updates while typing, but + shouldn't be necessary on file open/save. *) +let set_diagnostics ?(debounce = false) ~(log_info : Lsp_timing_logger.t) state doc = + let diagnostics = State.diagnostics state in + let detached = state.detached in let uri = Document.uri doc in match Document.kind doc with | `Other -> Fiber.return () | `Merlin merlin -> - let async send = - let+ () = - task_if_running detached ~f:(fun () -> - let timer = Document.Merlin.timer merlin in - let* () = Lev_fiber.Timer.Wheel.cancel timer in - let* () = Lev_fiber.Timer.Wheel.reset timer in - let* res = Lev_fiber.Timer.Wheel.await timer in - match res with - | `Cancelled -> Fiber.return () - | `Ok -> send ()) + let send_with_debounce ~update_diagnostics = + let log_info = { log_info with action = log_info.action ^ "-sending" } in + let send () = + Lsp_timing_logger.with_fiber_logging + ~f:(fun () -> + let* () = update_diagnostics () in + Diagnostics.send diagnostics (`One uri)) + log_info in - () + match debounce with + | false -> send () + | true -> + let log_info = { log_info with action = log_info.action ^ "-waiting" } in + task_if_running detached ~f:(fun () -> + Lsp_timing_logger.with_fiber_logging + ~f:(fun () -> + let timer = Document.Merlin.timer merlin in + let* () = Lev_fiber.Timer.Wheel.cancel timer in + let* () = Lev_fiber.Timer.Wheel.reset timer in + let* res = Lev_fiber.Timer.Wheel.await timer in + match res with + | `Cancelled -> Fiber.return () + | `Ok -> send ()) + log_info) in (match Document.syntax doc with | Dune | Cram | Menhir | Ocamllex -> Fiber.return () | Reason when Option.is_none (Bin.which ocamlmerlin_reason) -> - let no_reason_merlin = - let message = - `String - (sprintf "Could not detect %s. Please install reason" ocamlmerlin_reason) + let update_diagnostics () = + let no_reason_merlin = + let message = + `String + (sprintf "Could not detect %s. Please install reason" ocamlmerlin_reason) + in + Diagnostic.create + ~source:Diagnostics.ocamllsp_source + ~range:Range.first_line + ~message + () in - Diagnostic.create - ~source:Diagnostics.ocamllsp_source - ~range:Range.first_line - ~message - () + Diagnostics.set diagnostics (`Merlin (uri, [ no_reason_merlin ])); + Fiber.return () in - Diagnostics.set diagnostics (`Merlin (uri, [ no_reason_merlin ])); - async (fun () -> Diagnostics.send diagnostics (`One uri)) + send_with_debounce ~update_diagnostics | Reason | Ocaml -> - async (fun () -> - let* () = Diagnostics.merlin_diagnostics diagnostics merlin in - Diagnostics.send diagnostics (`One uri))) + let update_diagnostics () = + Diagnostics.merlin_diagnostics ~log_info diagnostics merlin + in + send_with_debounce ~update_diagnostics) ;; let on_initialize server (ip : InitializeParams.t) = + let client_name, _ = + Option.map ip.clientInfo ~f:InitializeParams.get_editor + |> Option.value ~default:("", "") + in let state : State.t = Server.state server in let workspaces = Workspaces.create ip in let diagnostics = - let report_dune_diagnostics = - Configuration.report_dune_diagnostics state.configuration + let display_merlin_diagnostics = + Configuration.display_merlin_diagnostics state.configuration in let shorten_merlin_diagnostics = Configuration.shorten_merlin_diagnostics state.configuration in Diagnostics.create - ~report_dune_diagnostics + ~display_merlin_diagnostics ~shorten_merlin_diagnostics + ~client_name (let open Option.O in let* td = ip.capabilities.textDocument in td.publishDiagnostics) @@ -235,27 +256,6 @@ let on_initialize server (ip : InitializeParams.t) = Server.Batch.notification batch (PublishDiagnostics d)); Server.Batch.submit batch)) in - let+ dune = - let progress = - Progress.create - ip.capabilities - ~report_progress:(fun progress -> - Server.notification server (Server_notification.WorkDoneProgress progress)) - ~create_task:(fun task -> - Server.request server (Server_request.WorkDoneProgressCreate task)) - in - let dune = - Dune.create - workspaces - ip.capabilities - diagnostics - progress - state.store - ~log:(State.log_msg server) - in - let+ () = Fiber.Pool.task state.detached ~f:(fun () -> Dune.run dune) in - dune - in let initialize_info = initialize_info ip.capabilities in let state = let position_encoding = @@ -264,7 +264,7 @@ let on_initialize server (ip : InitializeParams.t) = | Some UTF8 -> `UTF8 | Some UTF32 | Some (Other _) -> assert false in - State.initialize state ~position_encoding ip workspaces dune diagnostics + State.initialize state ~position_encoding ip workspaces diagnostics in let state = match ip.trace with @@ -302,7 +302,7 @@ let on_initialize server (ip : InitializeParams.t) = Server.request server (Server_request.ClientRegisterCapability register)) | _ -> Reply.now initialize_info in - resp, state + Fiber.return (resp, state) ;; module Formatter = struct @@ -317,7 +317,6 @@ module Formatter = struct ;; let run rpc doc = - let state : State.t = Server.state rpc in match Document.kind doc with | `Merlin _ -> let* res = @@ -337,40 +336,22 @@ module Formatter = struct Server.notification rpc (ShowMessage msg)) in Jsonrpc.Response.Error.raise (jsonrpc_error e)) - | `Other -> - (match Dune.for_doc (State.dune state) doc with - | [] -> - let message = - sprintf - "No dune instance found. Please run dune in watch mode for %s" - (Uri.to_path (Document.uri doc)) - in - Jsonrpc.Response.Error.raise (make_error ~code:InvalidRequest ~message ()) - | dune :: rest -> - let* () = - match rest with - | [] -> Fiber.return () - | _ :: _ -> - let message = - sprintf - "More than one dune instance detected for %s. Selecting one at random" - (Uri.to_path (Document.uri doc)) - in - State.log_msg rpc ~type_:MessageType.Warning ~message - in - let+ to_ = Dune.Instance.format_dune_file dune doc in - Some (Diff.edit ~from:(Document.text doc) ~to_)) + | `Other -> Fiber.return None ;; end -let text_document_lens (state : State.t) { CodeLensParams.textDocument = { uri }; _ } = +let text_document_lens + ~log_info + (state : State.t) + { CodeLensParams.textDocument = { uri }; _ } + = let store = state.store in let doc = Document_store.get store uri in match Document.kind doc with | `Other -> Fiber.return [] | `Merlin m when Document.Merlin.kind m = Intf -> Fiber.return [] - | `Merlin doc -> - let+ outline = Document.Merlin.dispatch_exn ~name:"outline" doc Outline in + | `Merlin merlin_doc -> + let+ outline = Document.Merlin.dispatch_exn ~log_info merlin_doc (Outline {include_types = true }) in let rec symbol_info_of_outline_item (item : Query_protocol.item) = let children = List.concat_map item.children ~f:symbol_info_of_outline_item in match item.outline_type with @@ -388,60 +369,79 @@ let text_document_lens (state : State.t) { CodeLensParams.textDocument = { uri } ;; let selection_range - (state : State.t) - { SelectionRangeParams.textDocument = { uri }; positions; _ } + ~log_info + (state : State.t) + { SelectionRangeParams.textDocument = { uri }; positions; _ } = let doc = Document_store.get state.store uri in match Document.kind doc with | `Other -> Fiber.return [] | `Merlin merlin -> - let selection_range_of_enclosings (enclosings : Warnings.loc list) + let selection_range_of_shapes + (cursor_position : Position.t) + (shapes : Query_protocol.shape list) : SelectionRange.t option = - let ranges_of_enclosing parent (enclosing : Warnings.loc) = - let range = Range.of_loc enclosing in - { SelectionRange.range; parent } + let rec ranges_of_shape parent (s : Query_protocol.shape) = + let selectionRange = + let range = Range.of_loc s.shape_loc in + { SelectionRange.range; parent } + in + match s.shape_sub with + | [] -> [ selectionRange ] + | xs -> List.concat_map xs ~f:(ranges_of_shape (Some selectionRange)) + in + (* try to find the nearest range inside first, then outside *) + let nearest_range = + let ranges = List.concat_map ~f:(ranges_of_shape None) shapes in + List.min ranges ~f:(fun r1 r2 -> + let inc (r : SelectionRange.t) = + Position.compare_inclusion cursor_position r.range + in + match inc r1, inc r2 with + | `Outside x, `Outside y -> Position.compare x y + | `Outside _, `Inside -> Gt + | `Inside, `Outside _ -> Lt + | `Inside, `Inside -> Range.compare_size r1.range r2.range) in - List.fold_left - ~f:(fun parent enclosing -> Some (ranges_of_enclosing parent enclosing)) - ~init:None - @@ List.rev enclosings + nearest_range in let+ ranges = - Fiber.sequential_map positions ~f:(fun x -> - let+ enclosings = - Document.Merlin.dispatch_exn - ~name:"shape" - merlin - (Enclosing (Position.logical x)) + Fiber.sequential_map positions ~f:(fun p -> + let+ shapes = + Document.Merlin.dispatch_exn ~log_info merlin (Shape (Position.logical p)) in - selection_range_of_enclosings enclosings) + selection_range_of_shapes p shapes) in List.filter_opt ranges ;; let references - rpc - (state : State.t) - { ReferenceParams.textDocument = { uri }; position; _ } + rpc + ~log_info + (state : State.t) + { ReferenceParams.textDocument = { uri }; position; _ } = let doc = Document_store.get state.store uri in match Document.kind doc with | `Other -> Fiber.return None - | `Merlin doc -> - let* occurrences, synced = + | `Merlin merlin_doc -> + let* occurences, synced = Document.Merlin.dispatch_exn - ~name:"occurrences" - doc + ~log_info + merlin_doc (Occurrences (`Ident_at (Position.logical position), `Project)) in let+ () = + (* NOTE: I have not been able to trigger this when I know the index is out-of-date, + so it's not entirely clear what the best error message would be, or what merlin + is actually doing. For now I'm updating the message to just not be actively wrong + for internal users. *) match synced with | `Out_of_sync _ -> let msg = let message = - "The index might be out-of-sync. If you use Dune you can build the target \ - `@ocaml-index` to refresh the index." + "The index might be out-of-sync. Make sure you are building the index file." in ShowMessageParams.create ~message ~type_:Warning in @@ -450,27 +450,26 @@ let references | _ -> Fiber.return () in Some - (List.filter_map occurrences ~f:(function - | { loc = _; is_stale = true } -> None - | { loc; is_stale = false } -> - let range = Range.of_loc loc in - let uri = - match loc.loc_start.pos_fname with - | "" -> uri - | path -> Uri.of_path path - in - Log.log ~section:"debug" (fun () -> - Log.msg - "merlin returned fname %a" - [ "pos_fname", `String loc.loc_start.pos_fname - ; "uri", `String (Uri.to_string uri) - ]); - Some { Location.uri; range })) + (List.map occurences ~f:(fun { loc; is_stale = _ } -> + let range = Range.of_loc loc in + let uri = + match loc.loc_start.pos_fname with + | "" -> uri + | path -> Uri.of_path path + in + Log.log ~section:"debug" (fun () -> + Log.msg + "merlin returned fname %a" + [ "pos_fname", `String loc.loc_start.pos_fname + ; "uri", `String (Uri.to_string uri) + ]); + { Location.uri; range })) ;; let highlight - (state : State.t) - { DocumentHighlightParams.textDocument = { uri }; position; _ } + ~log_info + (state : State.t) + { DocumentHighlightParams.textDocument = { uri }; position; _ } = let store = state.store in let doc = Document_store.get store uri in @@ -479,13 +478,12 @@ let highlight | `Merlin m -> let+ occurrences, _synced = Document.Merlin.dispatch_exn - ~name:"occurrences" + ~log_info m (Occurrences (`Ident_at (Position.logical position), `Buffer)) in let lsp_locs = - List.filter_map occurrences ~f:(fun (occurrence : Query_protocol.occurrence) -> - let loc = occurrence.loc in + List.filter_map occurrences ~f:(fun { loc; is_stale = _ } -> let range = Range.of_loc loc in (* filter out multi-line ranges, since those are very noisy and happen a lot with certain PPXs *) @@ -499,13 +497,56 @@ let highlight Some lsp_locs ;; -let document_symbol (state : State.t) uri = +let document_symbol ~log_info (state : State.t) uri = let doc = let store = state.store in Document_store.get store uri in let client_capabilities = State.client_capabilities state in - Document_symbol.run client_capabilities doc uri + Document_symbol.run ~log_info client_capabilities doc uri +;; + +let unkown_request_uri ~(meth : string) ~(params : Jsonrpc.Structured.t option) = + let getters = + [ Req_switch_impl_intf.meth, Req_switch_impl_intf.get_doc_id + ; Req_infer_intf.meth, Req_infer_intf.get_doc_id + ; Req_typed_holes.meth, Req_typed_holes.get_doc_id + ; Req_typed_holes.jump, Req_typed_holes.get_doc_id + ; Req_merlin_call_compatible.meth, Req_merlin_call_compatible.get_doc_id + ; Req_type_enclosing.meth, Req_type_enclosing.get_doc_id + ; Req_wrapping_ast_node.meth, Req_wrapping_ast_node.get_doc_id + ; ( Semantic_highlighting.Debug.meth_request_full + , Semantic_highlighting.Debug.get_doc_id ) + ; Req_hover_extended.meth, Req_hover_extended.get_doc_id + ] + in + let%bind.Option getter = List.assoc_opt meth getters in + getter ~params +;; + +let unkown_request_positions ~(meth : string) ~(params : Jsonrpc.Structured.t option) = + let no_pos ~params:_ = None in + let getters = + [ Req_typed_holes.jump, Req_typed_holes.get_pos + ; Req_type_enclosing.meth, Req_type_enclosing.get_pos + ; Req_wrapping_ast_node.meth, Req_wrapping_ast_node.get_pos + ; Req_hover_extended.meth, Req_hover_extended.get_pos + ; Req_switch_impl_intf.meth, no_pos + ; Req_infer_intf.meth, no_pos + ; Req_typed_holes.meth, no_pos + ; Req_merlin_call_compatible.meth, no_pos + ; Semantic_highlighting.Debug.meth_request_full, no_pos + ] + in + match List.assoc_opt meth getters with + | None -> [] + | Some getter -> getter ~params |> Option.to_list +;; + +let get_texts store uris = + List.map ~f:(fun uri -> Document_store.get_opt store uri) uris + |> List.filter_opt + |> List.map ~f:Document.text ;; let on_request @@ -515,12 +556,31 @@ let on_request fun server req -> let rpc = server in let state : State.t = Server.state server in + state.event_index <- state.event_index + 1; + let uris = Client_request.all_uris req ~fallback:unkown_request_uri in let store = state.store in - let now res = Fiber.return (Reply.now res, state) in + let texts = get_texts store uris in + let positions = Client_request.positions req ~fallback:unkown_request_positions in + let log_info = + Lsp_timing_logger.make + ~event_index:state.event_index + ~action:[%string "request:%{Client_request.method_ req}"] + ~uris + ~texts + ~positions + () + in + Lsp_timing_logger.log_event_start log_info; + let now res = + Fiber.return + (Lsp_timing_logger.with_logging ~f:(fun () -> Reply.now res) log_info, state) + in let later f req = Fiber.return ( Reply.later (fun k -> - let* resp = f state req in + let* resp = + Lsp_timing_logger.with_fiber_logging ~f:(fun () -> f state req) log_info + in k resp) , state ) in @@ -531,20 +591,17 @@ let on_request , fun ~params state -> Fiber.of_thunk (fun () -> Fiber.return (Req_switch_impl_intf.on_request ~params state)) ) - ; Req_infer_intf.meth, Req_infer_intf.on_request - ; Req_typed_holes.meth, Req_typed_holes.on_request - ; Req_jump_to_typed_hole.meth, Req_jump_to_typed_hole.on_request - ; Req_merlin_call_compatible.meth, Req_merlin_call_compatible.on_request - ; Req_type_enclosing.meth, Req_type_enclosing.on_request - ; Req_get_documentation.meth, Req_get_documentation.on_request - ; Req_merlin_jump.meth, Req_merlin_jump.on_request - ; Req_wrapping_ast_node.meth, Req_wrapping_ast_node.on_request - ; Req_type_search.meth, Req_type_search.on_request - ; Req_construct.meth, Req_construct.on_request + ; Req_infer_intf.meth, Req_infer_intf.on_request ~log_info + ; Req_typed_holes.meth, Req_typed_holes.on_request ~log_info + ; Req_typed_holes.jump, Req_typed_holes.on_jump_request ~log_info + ; Req_merlin_call_compatible.meth, Req_merlin_call_compatible.on_request ~log_info + ; Req_type_enclosing.meth, Req_type_enclosing.on_request ~log_info + ; Req_get_documentation.meth, Req_get_documentation.on_request ~log_info + ; Req_wrapping_ast_node.meth, Req_wrapping_ast_node.on_request ~log_info ; ( Semantic_highlighting.Debug.meth_request_full - , Semantic_highlighting.Debug.on_request_full ) + , Semantic_highlighting.Debug.on_request_full ~log_info ) ; ( Req_hover_extended.meth - , fun ~params _ -> Req_hover_extended.on_request ~params rpc ) + , fun ~params _ -> Req_hover_extended.on_request ~log_info ~params rpc ) ] |> List.assoc_opt meth with @@ -558,16 +615,20 @@ let on_request | Some handler -> Fiber.return ( Reply.later (fun send -> - let* res = handler ~params state in + let* res = + Lsp_timing_logger.with_fiber_logging + ~f:(fun () -> handler ~params state) + log_info + in send res) , state )) - | Initialize ip -> - let+ res, state = on_initialize server ip in - res, state + | Initialize ip -> on_initialize server ip | DebugTextDocumentGet { textDocument = { uri }; position = _ } -> (match Document_store.get_opt store uri with | None -> now None - | Some doc -> now (Some (Msource.text (Document.source doc)))) + | Some doc -> + let text = Msource.text (Document.source doc) in + now (Some text)) | DebugEcho params -> now params | Shutdown -> Fiber.return (Reply.now (), state) | WorkspaceSymbol req -> @@ -577,136 +638,139 @@ let on_request if String.equal command.command Merlin_config_command.command_name then later - (fun state server -> - let store = state.store in - let+ () = Merlin_config_command.command_run server store in - `Null) + (fun _state server -> + let+ () = Merlin_config_command.command_run server store in + `Null) server else if String.equal command.command Document_text_command.command_name then later (fun state server -> - let store = state.store in - let+ () = Document_text_command.command_run server store command.arguments in - `Null) + let store = state.store in + let+ () = Document_text_command.command_run server store command.arguments in + `Null) server else if String.equal command.command view_metrics_command_name then later (fun _state server -> view_metrics server) server else if String.equal command.command Action_open_related.command_name then later (fun _state server -> Action_open_related.command_run server command) server - else if String.equal command.command Action_jump.command_name - then later (fun _state server -> Action_jump.command_run server command) server else - later - (fun state () -> - let dune = State.dune state in - Dune.on_command dune command) - () + Jsonrpc.Response.Error.raise + (make_error + ~code:RequestFailed + ~message:"Unknown command" + ~data:(`String command.command) + ()) | CompletionItemResolve ci -> later (fun state () -> - let markdown = - ClientCapabilities.markdown_support - (State.client_capabilities state) - ~field:(fun d -> - let open Option.O in - let+ completion = d.completion in - let* completion_item = completion.completionItem in - completion_item.documentationFormat) - in - let resolve = Compl.Resolve.of_completion_item ci in - match resolve with - | None -> Fiber.return ci - | Some resolve -> - let doc = - let uri = Compl.Resolve.uri resolve in - Document_store.get state.store uri - in - (match Document.kind doc with - | `Other -> Fiber.return ci - | `Merlin doc -> - Compl.resolve - doc - ci - resolve - (Document.Merlin.doc_comment ~name:"completion-resolve") - ~markdown)) + let markdown = + ClientCapabilities.markdown_support + (State.client_capabilities state) + ~field:(fun d -> + let open Option.O in + let+ completion = d.completion in + let* completion_item = completion.completionItem in + completion_item.documentationFormat) + in + let resolve = Compl.Resolve.of_completion_item ci in + match resolve with + | None -> Fiber.return ci + | Some resolve -> + let doc = + let uri = Compl.Resolve.uri resolve in + Document_store.get state.store uri + in + (match Document.kind doc with + | `Other -> Fiber.return ci + | `Merlin doc -> + Compl.resolve + doc + ci + resolve + (Document.Merlin.doc_comment ~log_info) + ~markdown)) () - | CodeAction params -> Code_actions.compute server params - | InlayHint params -> later (fun state () -> Inlay_hints.compute state params) () + | CodeAction params -> + Lsp_timing_logger.with_fiber_logging + ~f:(fun () -> Code_actions.compute ~log_info server params) + log_info + | InlayHint params -> + later (fun state () -> Inlay_hints.compute ~log_info state params) () | TextDocumentColor _ -> now [] | TextDocumentColorPresentation _ -> now [] | TextDocumentHover req -> - (match state.configuration.data.standard_hover with - | Some { enable = false } -> now None - | Some { enable = true } | None -> - let mode = - match state.configuration.data.extended_hover with - | Some { enable = true } -> Hover_req.Extended_variable - | Some _ | None -> Hover_req.Default - in - later (fun (_ : State.t) () -> Hover_req.handle rpc req mode) ()) - | TextDocumentReferences req -> later (references rpc) req + later (fun (_ : State.t) () -> Hover_req.handle ~log_info rpc req) () + | TextDocumentReferences req -> later (references rpc ~log_info) req | TextDocumentCodeLensResolve codeLens -> now codeLens | TextDocumentCodeLens req -> (match state.configuration.data.codelens with - | Some { enable = true } -> later text_document_lens req + | Some { enable = true } -> later (text_document_lens ~log_info) req | _ -> now []) - | TextDocumentHighlight req -> later highlight req - | DocumentSymbol { textDocument = { uri }; _ } -> later document_symbol uri + | TextDocumentHighlight req -> later (highlight ~log_info) req + | DocumentSymbol { textDocument = { uri }; _ } -> later (document_symbol ~log_info) uri | TextDocumentDeclaration { textDocument = { uri }; position } -> - later (fun state () -> Definition_query.run `Declaration state uri position) () + later + (fun state () -> Definition_query.run ~log_info `Declaration state uri position) + () | TextDocumentDefinition { textDocument = { uri }; position; _ } -> - later (fun state () -> Definition_query.run `Definition state uri position) () + later + (fun state () -> Definition_query.run ~log_info `Definition state uri position) + () | TextDocumentTypeDefinition { textDocument = { uri }; position; _ } -> - later (fun state () -> Definition_query.run `Type_definition state uri position) () - | TextDocumentCompletion params -> later (fun _ () -> Compl.complete state params) () + later + (fun state () -> Definition_query.run ~log_info `Type_definition state uri position) + () + | TextDocumentCompletion params -> + later (fun _ () -> Compl.complete ~log_info state params) () | TextDocumentPrepareRename { textDocument = { uri }; position; workDoneToken = _ } -> later (fun _ () -> - let doc = Document_store.get store uri in - match Document.kind doc with - | `Other -> Fiber.return None - | `Merlin doc -> - let+ occurrences, _synced = - Document.Merlin.dispatch_exn - ~name:"occurrences" - doc - (Occurrences (`Ident_at (Position.logical position), `Buffer)) - in - let loc = - List.find_map occurrences ~f:(fun (occurrence : Query_protocol.occurrence) -> - let loc = occurrence.loc in - let range = Range.of_loc loc in - match occurrence.is_stale, Position.compare_inclusion position range with - | false, `Inside -> Some loc - | true, _ | _, `Outside _ -> None) - in - Option.map loc ~f:Range.of_loc) + let doc = Document_store.get store uri in + match Document.kind doc with + | `Other -> Fiber.return None + | `Merlin merlin_doc -> + let+ occurrences, _synced = + Document.Merlin.dispatch_exn + ~log_info + merlin_doc + (Occurrences (`Ident_at (Position.logical position), `Buffer)) + in + let locs = List.map occurrences ~f:(fun { loc; is_stale = _ } -> loc) in + let loc = + List.find_opt locs ~f:(fun loc -> + let range = Range.of_loc loc in + Position.compare_inclusion position range = `Inside) + in + Option.map loc ~f:Range.of_loc) () - | TextDocumentRename req -> later Rename.rename req - | TextDocumentFoldingRange req -> later Folding_range.compute req - | SignatureHelp req -> later Signature_help.run req + | TextDocumentRename req -> later (Rename.rename ~log_info) req + | TextDocumentFoldingRange req -> later (Folding_range.compute ~log_info) req + | SignatureHelp req -> later (Signature_help.run ~log_info) req | TextDocumentLinkResolve l -> now l | TextDocumentLink _ -> now None | WillSaveWaitUntilTextDocument _ -> now None | TextDocumentFormatting { textDocument = { uri }; options = _; _ } -> later (fun _ () -> - let doc = Document_store.get store uri in - Formatter.run rpc doc) + let doc = Document_store.get store uri in + Formatter.run rpc doc) () | TextDocumentOnTypeFormatting _ -> now None - | SelectionRange req -> later selection_range req + | SelectionRange req -> later (selection_range ~log_info) req | TextDocumentImplementation _ -> not_supported () - | SemanticTokensFull p -> later Semantic_highlighting.on_request_full p - | SemanticTokensDelta p -> later Semantic_highlighting.on_request_full_delta p + | SemanticTokensFull p -> later (Semantic_highlighting.on_request_full ~log_info) p + | SemanticTokensDelta p -> + later (Semantic_highlighting.on_request_full_delta ~log_info) p | TextDocumentMoniker _ -> not_supported () - | TextDocumentPrepareCallHierarchy _ -> not_supported () + | TextDocumentPrepareCallHierarchy req -> + later (fun (_ : State.t) () -> Call_hierarchy.handle_prepare ~log_info rpc req) () | TextDocumentRangeFormatting _ -> not_supported () - | CallHierarchyIncomingCalls _ -> not_supported () - | CallHierarchyOutgoingCalls _ -> not_supported () + | CallHierarchyIncomingCalls req -> + later (fun (_ : State.t) () -> Call_hierarchy.handle_incoming ~log_info rpc req) () + | CallHierarchyOutgoingCalls req -> + later (fun (_ : State.t) () -> Call_hierarchy.handle_outgoing ~log_info rpc req) () | SemanticTokensRange _ -> not_supported () | LinkedEditingRange _ -> not_supported () | WillCreateFiles _ -> not_supported () @@ -726,94 +790,138 @@ let on_request let on_notification server (notification : Client_notification.t) : State.t Fiber.t = let state : State.t = Server.state server in + state.event_index <- state.event_index + 1; let store = state.store in - match notification with - | TextDocumentDidOpen params -> - let* doc = - let position_encoding = State.position_encoding state in - Document.make - ~position_encoding - (State.wheel state) - state.merlin_config - state.merlin - params - in - let* () = Document_store.open_document store doc in - let+ () = set_diagnostics state.detached (State.diagnostics state) doc in - state - | TextDocumentDidClose { textDocument = { uri } } -> - let+ () = - Diagnostics.remove (State.diagnostics state) (`Merlin uri); - let* () = Document_store.close_document store uri in - task_if_running state.detached ~f:(fun () -> - Diagnostics.send (State.diagnostics state) (`One uri)) - in - state - | TextDocumentDidChange { textDocument = { uri; version }; contentChanges } -> - let doc = - Document_store.change_document store uri ~f:(fun prev_doc -> - Document.update_text ~version prev_doc contentChanges) - in - let+ () = set_diagnostics state.detached (State.diagnostics state) doc in - state - | CancelRequest _ -> Fiber.return state - | ChangeConfiguration req -> - let* configuration = Configuration.update state.configuration req in - let* () = - let report_dune_diagnostics = Configuration.report_dune_diagnostics configuration in - Diagnostics.set_report_dune_diagnostics - ~report_dune_diagnostics - (State.diagnostics state) - in - let+ () = + let uris = Client_notification.all_uris notification in + let texts = get_texts store uris in + let analyze_files = + match notification with + | Client_notification.NotebookDocumentDidOpen _ + | Client_notification.NotebookDocumentDidSave _ + | Client_notification.NotebookDocumentDidClose _ -> true + | _ -> false + in + let log_info = + Lsp_timing_logger.make + ~event_index:state.event_index + ~action:[%string "notification:%{Client_notification.method_ notification}"] + ~uris + ~texts + ~positions:[] + ~analyze_files + () + in + Lsp_timing_logger.log_event_start log_info; + Lsp_timing_logger.with_fiber_logging log_info ~f:(fun () -> + match notification with + | TextDocumentDidOpen params -> + let* doc = + let position_encoding = State.position_encoding state in + Document.make + ~position_encoding + (State.wheel state) + state.merlin_config + state.merlin + params + in + let* () = Document_store.open_document store doc in + let+ () = set_diagnostics ~log_info state doc in + state + | TextDocumentDidClose { textDocument = { uri } } -> + let+ () = + Diagnostics.remove (State.diagnostics state) (`Merlin uri); + let* () = Document_store.close_document store uri in + task_if_running state.detached ~f:(fun () -> + Diagnostics.send (State.diagnostics state) (`One uri)) + in + state + | TextDocumentDidChange { textDocument = { uri; version }; contentChanges } -> + let doc = + Document_store.change_document store uri ~f:(fun prev_doc -> + Document.update_text ~version prev_doc contentChanges) + in + let+ () = set_diagnostics ~log_info ~debounce:true state doc in + state + | CancelRequest _ -> Fiber.return state + | ChangeConfiguration req -> + let prev_merlin_diagnostics = state.configuration.data.merlin_diagnostics in + let prev_shorten_merlin = + match state.configuration.data.shorten_merlin_diagnostics with + | None -> false + | Some { enable } -> enable + in + let* configuration = Configuration.update state.configuration req in + let display_merlin_diagnostics = + Configuration.display_merlin_diagnostics configuration + in let shorten_merlin_diagnostics = Configuration.shorten_merlin_diagnostics configuration in - Diagnostics.set_shorten_merlin_diagnostics - ~shorten_merlin_diagnostics - (State.diagnostics state) - in - { state with configuration } - | DidSaveTextDocument { textDocument = { uri }; _ } -> - let state = Server.state server in - (match Document_store.get_opt state.store uri with - | None -> - (Log.log ~section:"on receive DidSaveTextDocument" - @@ fun () -> Log.msg "saved document is not in the store" []); - Fiber.return state - | Some doc -> - let+ () = set_diagnostics state.detached (State.diagnostics state) doc in - state) - | ChangeWorkspaceFolders change -> - let state = - State.modify_workspaces state ~f:(fun ws -> Workspaces.on_change ws change) - in - Dune.update_workspaces (State.dune state) (State.workspaces state); - Fiber.return state - | DidChangeWatchedFiles _ - | DidCreateFiles _ - | DidDeleteFiles _ - | DidRenameFiles _ - | WillSaveTextDocument _ - | Initialized - | WorkDoneProgressCancel _ - | WorkDoneProgress _ - | NotebookDocumentDidOpen _ - | NotebookDocumentDidChange _ - | NotebookDocumentDidSave _ - | NotebookDocumentDidClose _ - | Exit -> Fiber.return state - | SetTrace { value } -> Fiber.return { state with trace = value } - | UnknownNotification req -> - let+ () = - State.log_msg server ~type_:Error ~message:("Unknown notication " ^ req.method_) - in - state + let shorten_merlin_changed = prev_shorten_merlin <> shorten_merlin_diagnostics in + let merlin_enabled_changed = + match prev_merlin_diagnostics, configuration.data.merlin_diagnostics with + | None, None + | Some { enable = true }, Some { enable = true } + | Some { enable = false }, Some { enable = false } -> false + | _ -> true + in + let () = + Diagnostics.set_display_merlin_diagnostics + ~display_merlin_diagnostics + (State.diagnostics state) + in + let () = + Diagnostics.set_shorten_merlin_diagnostics + ~shorten_merlin_diagnostics + (State.diagnostics state) + in + let state = { state with configuration } in + if shorten_merlin_changed || merlin_enabled_changed + then + let+ () = + Document_store.parallel_iter store ~f:(set_diagnostics ~log_info state) + in + state + else Fiber.return state + | DidSaveTextDocument { textDocument = { uri }; _ } -> + let state = Server.state server in + (match Document_store.get_opt state.store uri with + | None -> + (Log.log ~section:"on receive DidSaveTextDocument" + @@ fun () -> Log.msg "saved document is not in the store" []); + Fiber.return state + | Some doc -> + let+ () = set_diagnostics ~log_info state doc in + state) + | ChangeWorkspaceFolders change -> + let state = + State.modify_workspaces state ~f:(fun ws -> Workspaces.on_change ws change) + in + Fiber.return state + | DidChangeWatchedFiles _ + | DidCreateFiles _ + | DidDeleteFiles _ + | DidRenameFiles _ + | WillSaveTextDocument _ + | Initialized + | WorkDoneProgressCancel _ + | WorkDoneProgress _ + | NotebookDocumentDidOpen _ + | NotebookDocumentDidChange _ + | NotebookDocumentDidSave _ + | NotebookDocumentDidClose _ + | Exit -> Fiber.return state + | SetTrace { value } -> Fiber.return { state with trace = value } + | UnknownNotification req -> + let+ () = + State.log_msg server ~type_:Error ~message:("Unknown notication " ^ req.method_) + in + state) ;; let start stream = let detached = Fiber.Pool.create () in - let server = Fdecl.create () in + let server = Fdecl.create Dyn.opaque in let store = Document_store.make server detached in let handler = let on_request = { Server.Handler.on_request } in @@ -843,10 +951,7 @@ let start stream = let state = Server.state server in let with_log_errors what f = let+ (_ : (unit, unit) result) = - Fiber.map_reduce_errors - (module Monoid.Unit) - f - ~on_error:(fun exn -> + Fiber.map_reduce_errors (module Monoid.Unit) f ~on_error:(fun exn -> Format.eprintf "%s: %a@." what Exn_with_backtrace.pp_uncaught exn; Fiber.return ()) in @@ -889,11 +994,6 @@ let start stream = Fiber.return ()) ] in - let finalize = - match (Server.state server).init with - | Uninitialized -> finalize - | Initialized init -> Dune.stop init.dune :: finalize - in Fiber.all_concurrently_unit finalize) ; with_log_errors "ocamlformat-rpc" run_ocamlformat_rpc ] @@ -978,7 +1078,6 @@ let run_in_directory ~prog ~prog_is_quoted:_ ~args ~cwd ?stdin ?stdout ?stderr ( in Unix.close stdin; if should_close_stdout then Unix.close stdout; - Option.iter stderr ~f:Unix.close; `Finished res ;; @@ -988,15 +1087,18 @@ let run_in_directory = fun () -> if Sys.win32 then for_windows else run_in_directory ;; -let run channel ~read_dot_merlin () = +let run channel ~dot_merlin = Merlin_utils.Lib_config.set_program_name "ocamllsp"; Merlin_utils.Lib_config.System.set_run_in_directory (run_in_directory ()); - Merlin_config.should_read_dot_merlin := read_dot_merlin; - Unix.putenv "__MERLIN_MASTER_PID" (string_of_int (Unix.getpid ())); - Lev_fiber.run ~sigpipe:`Ignore (fun () -> - let* input, output = stream_of_channel channel in - start (Lsp_fiber.Fiber_io.make input output)) - |> Lev_fiber.Error.ok_exn + Merlin_config.dot_merlin := dot_merlin; + (Unix.putenv [@alert "-unsafe_multidomain"]) + "__MERLIN_MASTER_PID" (string_of_int (Unix.getpid ())); + let main = + Fiber.of_thunk (fun () -> + let* input, output = stream_of_channel channel in + start (Lsp_fiber.Fiber_io.make input output)) + in + Fiber_async.deferred_of_fiber main () ;; module Custom_request = Custom_request diff --git a/ocaml-lsp-server/src/ocaml_lsp_server.mli b/ocaml-lsp-server/src/ocaml_lsp_server.mli index e74891253..b4283a66e 100644 --- a/ocaml-lsp-server/src/ocaml_lsp_server.mli +++ b/ocaml-lsp-server/src/ocaml_lsp_server.mli @@ -1,4 +1,6 @@ -val run : Lsp.Cli.Channel.t -> read_dot_merlin:bool -> unit -> unit +open Async + +val run : Lsp.Cli.Channel.t -> dot_merlin:string option -> unit Deferred.t module Diagnostics = Diagnostics module Version = Version diff --git a/ocaml-lsp-server/src/ocamlformat.ml b/ocaml-lsp-server/src/ocamlformat.ml index 28437f21f..6ddaf37ad 100644 --- a/ocaml-lsp-server/src/ocamlformat.ml +++ b/ocaml-lsp-server/src/ocamlformat.ml @@ -56,9 +56,9 @@ let run_command cancel prog stdin_value args = Lev_fiber.Io.close stdin_o; Fiber.return ()) (fun () -> - Lev_fiber.Io.with_write stdin_o ~f:(fun w -> - Lev_fiber.Io.Writer.add_string w stdin_value; - Lev_fiber.Io.Writer.flush w)) + Lev_fiber.Io.with_write stdin_o ~f:(fun w -> + Lev_fiber.Io.Writer.add_string w stdin_value; + Lev_fiber.Io.Writer.flush w)) in let read from () = Fiber.finalize @@ -71,8 +71,8 @@ let run_command cancel prog stdin_value args = Fiber.fork_and_join (fun () -> Lev_fiber.waitpid ~pid:(Pid.to_int pid)) (fun () -> - Fiber.fork_and_join_unit stdin (fun () -> - Fiber.fork_and_join (read stdout_i) (read stderr_i))) + Fiber.fork_and_join_unit stdin (fun () -> + Fiber.fork_and_join (read stdout_i) (read stderr_i))) in { stdout; stderr; status }) ;; @@ -136,7 +136,8 @@ let formatter doc = | `Other -> Code_error.raise "unable to format non merlin document" [])) ;; -let exec cancel refmt args stdin = +let exec cancel bin args stdin = + let refmt = Fpath.to_string bin in let+ res, cancel = run_command cancel refmt stdin args in match cancel with | Cancelled () -> diff --git a/ocaml-lsp-server/src/ocamlformat_rpc.ml b/ocaml-lsp-server/src/ocamlformat_rpc.ml index 3fde475df..ecaa26303 100644 --- a/ocaml-lsp-server/src/ocamlformat_rpc.ml +++ b/ocaml-lsp-server/src/ocamlformat_rpc.ml @@ -1,260 +1,9 @@ -open Import -open Fiber.O +(* TODO: Add support for ocamlformat. *) -let type_option = [ "module-item-spacing", "compact"; "margin", "63" ] +type t = unit -module Ocamlformat_rpc = Ocamlformat_rpc_lib.Make (struct - type 'a t = 'a Fiber.t - - let return a = Fiber.return a - let ( >>= ) x f = Fiber.bind x ~f - - type ic = Lev_fiber_csexp.Session.t - type oc = Lev_fiber_csexp.Session.t - - let read = Lev_fiber_csexp.Session.read - let write t s = Lev_fiber_csexp.Session.write t s - end) - -module Process : sig - type t - - val pid : t -> Pid.t - val client : t -> Ocamlformat_rpc.client - - val create - : logger:(type_:MessageType.t -> message:string -> unit Fiber.t) - -> bin:string - -> unit - -> (t, [> `No_process ]) result Fiber.t - - val run : t -> unit Fiber.t -end = struct - type t = - { pid : Pid.t - ; session : Lev_fiber_csexp.Session.t - ; client : Ocamlformat_rpc.client - } - - let pid t = t.pid - let client t = t.client - let supported_versions = [ "v2"; "v1" ] - - let pick_client ~pid session = - Ocamlformat_rpc.pick_client ~pid session session supported_versions - ;; - - let configure ~logger { client; _ } = - (* We ask for 64 columns formatting as this appear to be the maximum size of - VScode popups. TODO We should probably allow some flexibility for other - editors that use the server. *) - match client with - | `V2 _ -> Fiber.return () - | `V1 client -> - let* res = Ocamlformat_rpc.V1.Client.config type_option client in - (match res with - | Ok () -> Fiber.return () - | Error (`Msg msg) -> - let message = - Printf.sprintf "An error occured while configuring ocamlformat: %s" msg - in - logger ~type_:MessageType.Warning ~message) - ;; - - let create ~logger ~bin () = - let* pid, stdout, stdin = - let stdin_i, stdin_o = Unix.pipe ~cloexec:true () in - let stdout_i, stdout_o = Unix.pipe ~cloexec:true () in - let pid = Spawn.spawn ~prog:bin ~argv:[ bin ] ~stdin:stdin_i ~stdout:stdout_o () in - Unix.close stdin_i; - Unix.close stdout_o; - let blockity = - if Sys.win32 - then `Blocking - else ( - Unix.set_nonblock stdin_o; - Unix.set_nonblock stdout_i; - `Non_blocking true) - in - let make fd what = - let fd = Lev_fiber.Fd.create fd blockity in - Lev_fiber.Io.create fd what - in - let* stdin = make stdin_o Output in - let+ stdout = make stdout_i Input in - pid, stdout, stdin - in - let session = Lev_fiber_csexp.Session.create ~socket:false stdout stdin in - let* client = pick_client ~pid session in - match client with - | Error (`Msg msg) -> - (* The process did start but something went wrong when negotiating the - version so we need to kill it *) - Unix.kill pid Sys.sigterm; - let* () = - let message = - Printf.sprintf - "An error happened when negotiating with the OCamlformat-RPC server: %s" - msg - in - logger ~type_:MessageType.Error ~message - in - Fiber.return @@ Error `No_process - | Ok client -> - let process = { pid = Pid.of_int pid; session; client } in - let* () = configure ~logger process in - let+ () = - let message = Printf.sprintf "Ocamlformat-RPC server started with PID %i" pid in - logger ~type_:MessageType.Info ~message - in - Ok process - ;; - - let run { pid; session; _ } = - let+ (_ : Unix.process_status) = Lev_fiber.waitpid ~pid:(Pid.to_int pid) in - Lev_fiber_csexp.Session.close session - ;; -end - -type state = - | Disabled - | Stopped - | Waiting_for_init of - { ask_init : unit Fiber.Ivar.t - ; wait_init : unit Fiber.Ivar.t - } - | Running of Process.t - -type t = state ref - -let maybe_fill ivar x = - let* v = Fiber.Ivar.peek ivar in - match v with - | Some _ -> Fiber.return () - | None -> Fiber.Ivar.fill ivar x -;; - -let get_process t = - match !t with - | Running p -> Fiber.return @@ Ok p - | Disabled | Stopped -> Fiber.return @@ Error `No_process - | Waiting_for_init { ask_init; wait_init } -> - let* () = maybe_fill ask_init () in - let+ () = Fiber.Ivar.read wait_init in - (match !t with - | Running p -> Ok p - | Disabled | Stopped -> Error `No_process - | Waiting_for_init _ -> - Code_error.raise - "Expected to receive `Started` or `Stopped` after mailing `Start`" - []) -;; - -let format_type t ~typ = - let* p = get_process t in - match p with - | Error `No_process -> Fiber.return @@ Error `No_process - | Ok p -> - (match Process.client p with - | `V1 p -> Ocamlformat_rpc.V1.Client.format typ p - | `V2 p -> - let config = Some type_option in - Ocamlformat_rpc.V2.Client.format - ~format_args:{ Ocamlformat_rpc_lib.empty_args with config } - typ - p) -;; - -let format_doc t doc = - let txt = Document.source doc |> Msource.text in - let path = Some (Document.uri doc |> Uri.to_path) in - let* p = get_process t in - match p with - | Error `No_process -> Fiber.return @@ Error `No_process - | Ok p -> - (match Process.client p with - | `V2 p -> - let+ res = - Ocamlformat_rpc.V2.Client.format - ~format_args:Ocamlformat_rpc_lib.{ empty_args with path } - txt - p - in - Result.map res ~f:(fun to_ -> Diff.edit ~from:txt ~to_) - | `V1 _ -> Fiber.return @@ Error `No_V2) -;; - -let create_state () = - Waiting_for_init { ask_init = Fiber.Ivar.create (); wait_init = Fiber.Ivar.create () } -;; - -let create () = ref (if Sys.win32 then Disabled else create_state ()) - -let stop t = - match !t with - | Disabled | Stopped -> Fiber.return () - | Waiting_for_init { wait_init; ask_init } -> - (* If the server was never started we still need to fill the ivar for the - fiber to finish *) - t := Stopped; - Fiber.fork_and_join_unit (maybe_fill wait_init) (maybe_fill ask_init) - | Running process -> - let pid = Pid.to_int (Process.pid process) in - t := Stopped; - Unix.kill pid Sys.sigkill; - Fiber.return () -;; - -let run_rpc ~logger ~bin t = - match !t with - | Disabled -> assert false - | Stopped -> Code_error.raise "ocamlformat already stopped" [] - | Running _ -> Code_error.raise "ocamlformat already running" [] - | Waiting_for_init { ask_init; wait_init } -> - let* () = Fiber.Ivar.read ask_init in - (match !t with - | Disabled | Stopped -> Fiber.return () - | Running _ -> assert false - | Waiting_for_init _ -> - let* process = Process.create ~logger ~bin () in - let* () = Fiber.Ivar.fill wait_init () in - (match process with - | Error `No_process -> - t := Stopped; - Fiber.return () - | Ok process -> - t := Running process; - let+ () = Process.run process in - (match !t with - | Running _ -> t := create_state () - | _ -> ()))) -;; - -let run ~logger t = - match !t with - | Disabled -> Fiber.return (Error `Disabled) - | _ -> - (match Bin.which "ocamlformat-rpc" with - | None -> - t := Stopped; - Fiber.return (Error `Binary_not_found) - | Some bin -> - let rec loop () = - match !t with - | Disabled -> assert false - | Stopped -> Fiber.return (Ok ()) - | Running _ -> assert false - | Waiting_for_init { ask_init; wait_init = _ } -> - (* We wait for the first query to start the server or for ocamllsp to - exit *) - let* () = Fiber.Ivar.read ask_init in - (match !t with - | Waiting_for_init _ -> - let* () = run_rpc ~logger ~bin t in - (* We loop to automatically restart the server if it stopped *) - loop () - | Disabled | Running _ -> assert false - | Stopped -> Fiber.return (Ok ())) - in - loop ()) -;; +let create () = () +let stop () = Fiber.return () +let format_type () ~typ:_ = Fiber.return (Error `No_process) +let format_doc () _doc = Fiber.return (Error `No_process) +let run ~logger:_ () = Fiber.return (Error `Disabled) diff --git a/ocaml-lsp-server/src/prefix_parser.ml b/ocaml-lsp-server/src/prefix_parser.ml index 7f01116f3..27d8ec16d 100644 --- a/ocaml-lsp-server/src/prefix_parser.ml +++ b/ocaml-lsp-server/src/prefix_parser.ml @@ -24,15 +24,6 @@ include struct ]) ;; - (* When completing module paths or record fields Merlin expects the - beginning of the path and the `.` to be part of the prefix. But when - accessing an object's methods, the prefix should not contain the `#` - sign. We use a sub-matching group to that effect. - - - Prefix for [my_record.|] is ["my_record."] (handled by [name_or_label]) - - Prefix for [my_object#|] is [""] (handled by [method_call]) *) - let method_call = compile (seq [ char '#'; Re.group (rep name_char); stop ]) - (** matches let%lwt and let* style expressions. See here:https://v2.ocaml.org/manual/bindingops.html *) let monadic_bind = @@ -51,11 +42,8 @@ let parse ~pos ~len text = (*Attempt to match each of our possible prefix types, the order is important because there is some overlap between the regexs*) let matched = - List.find_map - [ name_or_label; method_call; monadic_bind; infix_operator ] - ~f:(fun regex -> Re.exec_opt ~pos ~len regex text) + List.find_map [ name_or_label; monadic_bind; infix_operator ] ~f:(fun regex -> + Re.exec_opt ~pos ~len regex text) in - matched - |> Option.map ~f:(fun x -> - if Re.Group.test x 1 then Re.Group.get x 1 else Re.Group.get x 0) + matched |> Option.map ~f:(fun x -> Re.Group.get x 0) ;; diff --git a/ocaml-lsp-server/src/prefix_parser.mli b/ocaml-lsp-server/src/prefix_parser.mli index 8d586d98e..8b48325d3 100644 --- a/ocaml-lsp-server/src/prefix_parser.mli +++ b/ocaml-lsp-server/src/prefix_parser.mli @@ -1,4 +1,3 @@ -(** Tries the parse the incoming string for a prefix. The string should be the - source code ending at the prefix position. pos and len set the range for the - regex to operate on *) +(** Tries the parse the incoming string for a prefix. The string should be the source code + ending at the prefix position. pos and len set the range for the regex to operate on *) val parse : pos:int -> len:int -> string -> string option diff --git a/ocaml-lsp-server/src/progress.ml b/ocaml-lsp-server/src/progress.ml index 69913a6d4..60a49acf2 100644 --- a/ocaml-lsp-server/src/progress.ml +++ b/ocaml-lsp-server/src/progress.ml @@ -1,5 +1,4 @@ open Import -open Fiber.O module Progress = Lsp.Progress type enabled = @@ -38,55 +37,3 @@ let end_build_if_running = function | Enabled e -> end_build e ~message:"Build interrupted" ;; -let start_build (t : enabled) = - let* () = end_build t ~message:"Starting new build" in - let token = `String ("dune-build-" ^ Int.to_string t.build_counter) in - t.token <- Some token; - t.build_counter <- t.build_counter + 1; - let* () = t.create_task (WorkDoneProgressCreateParams.create ~token) in - t.token <- Some token; - let+ () = - t.report_progress - (ProgressParams.create - ~token - ~value: - (Progress.Begin - (WorkDoneProgressBegin.create ~title:"Build" ~message:"started" ()))) - in - token -;; - -let build_progress t (progress : Drpc.Progress.t) = - Fiber.of_thunk (fun () -> - match t with - | Disabled -> Code_error.raise "progress reporting is not supported" [] - | Enabled ({ token; report_progress; _ } as t) -> - (match progress with - | Success -> end_build t ~message:"Build finished" - | Failed -> end_build t ~message:"Build failed" - | Interrupted -> end_build t ~message:"Build interrupted" - | Waiting -> end_build t ~message:"Waiting for changes" - | In_progress progress -> - let* token = - match token with - | Some token -> Fiber.return token - | None -> - (* This can happen when we connect to dune in the middle of a - build. *) - start_build t - in - let total = progress.complete + progress.remaining in - (* The percentage is useless as it isn't monotinically increasing as - the spec requires, but it's the best we can do. *) - let percentage = - let fraction = float_of_int progress.complete /. float_of_int total in - int_of_float (fraction *. 100.) - in - report_progress - (ProgressParams.create - ~token - ~value: - (Progress.Report - (let message = sprintf "Building [%d/%d]" progress.complete total in - WorkDoneProgressReport.create ~percentage ~message ()))))) -;; diff --git a/ocaml-lsp-server/src/progress.mli b/ocaml-lsp-server/src/progress.mli index 935ba2ed4..8a35adf96 100644 --- a/ocaml-lsp-server/src/progress.mli +++ b/ocaml-lsp-server/src/progress.mli @@ -9,4 +9,3 @@ val create -> t val end_build_if_running : t -> unit Fiber.t -val build_progress : t -> Drpc.Progress.t -> unit Fiber.t diff --git a/ocaml-lsp-server/src/range.ml b/ocaml-lsp-server/src/range.ml index e88597cb2..d248d2d4f 100644 --- a/ocaml-lsp-server/src/range.ml +++ b/ocaml-lsp-server/src/range.ml @@ -7,6 +7,8 @@ let compare (x : t) (y : t) = | Ordering.Eq -> Position.compare x.end_ y.end_ ;; +let equal x y = Ordering.is_eq (compare x y) + let to_dyn { start; end_ } = Dyn.record [ "start", Position.to_dyn start; "end_", Position.to_dyn end_ ] ;; diff --git a/ocaml-lsp-server/src/range.mli b/ocaml-lsp-server/src/range.mli index 2db752c5d..75201a62c 100644 --- a/ocaml-lsp-server/src/range.mli +++ b/ocaml-lsp-server/src/range.mli @@ -1,10 +1,11 @@ open Import include module type of Lsp.Types.Range with type t = Lsp.Types.Range.t -(** [compare r1 r2] compares first start positions, if equal compares the end - positions. *) +(** [compare r1 r2] compares first start positions, if equal compares the end positions. *) val compare : t -> t -> Ordering.t +val equal : t -> t -> bool + (** [contains r1 r2] returns true if [r1] contains [r2]. *) val contains : t -> t -> bool @@ -13,14 +14,13 @@ val compare_size : t -> t -> Ordering.t val first_line : t val of_loc_opt : Loc.t -> t option -(** [of_loc loc] if fails to convert [loc] to [t] will return the first (or top) - line in the document *) +(** [of_loc loc] if fails to convert [loc] to [t] will return the first (or top) line in + the document *) val of_loc : Loc.t -> t -(** [resize_for_edit edit] returns shrunk, unchanged, or extended [edit.range] - depending on the size of [edit.newText], e.g., if [edit.newText] contains - less characters than [edit.range], the new range is shrunk to fit - [edit.newText] only. *) +(** [resize_for_edit edit] returns shrunk, unchanged, or extended [edit.range] depending + on the size of [edit.newText], e.g., if [edit.newText] contains less characters than + [edit.range], the new range is shrunk to fit [edit.newText] only. *) val resize_for_edit : TextEdit.t -> t (** [overlaps r1 r2] is true if [r1] and [r2] overlap. *) diff --git a/ocaml-lsp-server/src/rename.ml b/ocaml-lsp-server/src/rename.ml index 2f3815069..ca44e20a1 100644 --- a/ocaml-lsp-server/src/rename.ml +++ b/ocaml-lsp-server/src/rename.ml @@ -1,70 +1,48 @@ open Import open Fiber.O -let rename (state : State.t) { RenameParams.textDocument = { uri }; position; newName; _ } +let rename + ~log_info + (state : State.t) + { RenameParams.textDocument = { uri }; position; newName; _ } = let doc = Document_store.get state.store uri in match Document.kind doc with | `Other -> Fiber.return (WorkspaceEdit.create ()) | `Merlin merlin -> let command = - Query_protocol.Occurrences (`Ident_at (Position.logical position), `Renaming) - in - let+ occurrences, _desync = - Document.Merlin.dispatch_exn ~name:"rename" merlin command - in - let locs = - List.filter_map occurrences ~f:(fun (occurrence : Query_protocol.occurrence) -> - match occurrence.is_stale with - | true -> None - | false -> Some occurrence.loc) + Query_protocol.Occurrences (`Ident_at (Position.logical position), `Buffer) in + let+ occurences, _desync = Document.Merlin.dispatch_exn ~log_info merlin command in let version = Document.version doc in - let uri = Document.uri doc in + let source = Document.source doc in let edits = - List.fold_left locs ~init:Uri.Map.empty ~f:(fun acc (loc : Warnings.loc) -> + List.map occurences ~f:(fun {loc; is_stale = _ } -> let range = Range.of_loc loc in - let edit = TextEdit.create ~range ~newText:newName in - let uri = - match loc.loc_start.pos_fname with - | "" -> uri - | path -> Uri.of_path path - in - Uri.Map.add_to_list uri edit acc) - in - let edits = - Uri.Map.mapi - (fun doc_uri edits -> - let source = - match Document_store.get_opt state.store doc_uri with - | Some doc when DocumentUri.equal doc_uri (Document.uri doc) -> - Document.source doc - | Some _ | None -> - let source_path = Uri.to_path doc_uri in - In_channel.with_open_text source_path In_channel.input_all |> Msource.make - in - List.map edits ~f:(fun (edit : TextEdit.t) -> - let start_position = edit.range.start in - match start_position with - | { character = 0; _ } -> edit - | pos -> - let mpos = Position.logical pos in - let (`Offset index) = Msource.get_offset source mpos in - assert (index > 0) - (* [index = 0] if we pass [`Logical (1, 0)], but we handle the case - when [character = 0] in a separate matching branch *); - let source_txt = Msource.text source in - (* TODO: handle record field puning *) - (match source_txt.[index - 1] with - | '~' (* the occurrence is a named argument *) - | '?' (* is an optional argument *) -> - let empty_range_at_occur_end = - let occur_end_pos = edit.range.end_ in - { edit.range with start = occur_end_pos } - in - TextEdit.create ~range:empty_range_at_occur_end ~newText:(":" ^ newName) - | _ -> edit))) - edits + let make_edit () = TextEdit.create ~range ~newText:newName in + match + let occur_start_pos = + Position.of_lexical_position loc.loc_start |> Option.value_exn + in + occur_start_pos + with + | { character = 0; _ } -> make_edit () + | pos -> + let mpos = Position.logical pos in + let (`Offset index) = Msource.get_offset source mpos in + assert (index > 0) + (* [index = 0] if we pass [`Logical (1, 0)], but we handle the case + when [character = 0] in a separate matching branch *); + let source_txt = Msource.text source in + (match source_txt.[index - 1] with + | '~' (* the occurrence is a named argument *) + | '?' (* is an optional argument *) -> + let empty_range_at_occur_end = + let occur_end_pos = range.Range.end_ in + { range with start = occur_end_pos } + in + TextEdit.create ~range:empty_range_at_occur_end ~newText:(":" ^ newName) + | _ -> make_edit ())) in let workspace_edits = let documentChanges = @@ -78,19 +56,15 @@ let rename (state : State.t) { RenameParams.textDocument = { uri }; position; ne in if documentChanges then ( - let documentChanges = - Uri.Map.to_list edits - |> List.map ~f:(fun (uri, edits) -> - let textDocument = - OptionalVersionedTextDocumentIdentifier.create ~uri ~version () - in - let edits = List.map edits ~f:(fun e -> `TextEdit e) in - `TextDocumentEdit (TextDocumentEdit.create ~textDocument ~edits)) + let textDocument = + OptionalVersionedTextDocumentIdentifier.create ~uri ~version () in - WorkspaceEdit.create ~documentChanges ()) - else ( - let changes = Uri.Map.to_list edits in - WorkspaceEdit.create ~changes ()) + let edits = List.map edits ~f:(fun e -> `TextEdit e) in + WorkspaceEdit.create + ~documentChanges: + [ `TextDocumentEdit (TextDocumentEdit.create ~textDocument ~edits) ] + ()) + else WorkspaceEdit.create ~changes:[ uri, edits ] () in workspace_edits ;; diff --git a/ocaml-lsp-server/src/rename.mli b/ocaml-lsp-server/src/rename.mli index 770b72ed4..8d6a253f1 100644 --- a/ocaml-lsp-server/src/rename.mli +++ b/ocaml-lsp-server/src/rename.mli @@ -1,3 +1,7 @@ open Import -val rename : State.t -> RenameParams.t -> WorkspaceEdit.t Fiber.t +val rename + : log_info:Lsp_timing_logger.t + -> State.t + -> RenameParams.t + -> WorkspaceEdit.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_get_documentation.ml b/ocaml-lsp-server/src/req_get_documentation.ml similarity index 92% rename from ocaml-lsp-server/src/custom_requests/req_get_documentation.ml rename to ocaml-lsp-server/src/req_get_documentation.ml index 5000c3a3c..2591f494f 100644 --- a/ocaml-lsp-server/src/custom_requests/req_get_documentation.ml +++ b/ocaml-lsp-server/src/req_get_documentation.ml @@ -92,8 +92,8 @@ module Request_params = struct ;; end -let dispatch ~merlin ~position ~identifier ~contentFormat = - Document.Merlin.with_pipeline_exn merlin (fun pipeline -> +let dispatch ~log_info ~merlin ~position ~identifier ~contentFormat = + Document.Merlin.with_pipeline_exn ~log_info merlin (fun pipeline -> let position = Position.logical position in let query = Query_protocol.Document (identifier, position) in let result = Query_commands.dispatch pipeline query in @@ -108,7 +108,7 @@ let dispatch ~merlin ~position ~identifier ~contentFormat = GetDoc.yojson_of_t { doc = GetDoc.create ~kind ~value }) ;; -let on_request ~params state = +let on_request ~log_info ~params state = Fiber.of_thunk (fun () -> let params = (Option.value ~default:(`Assoc []) params :> Yojson.Safe.t) in let GetDocParams.{ text_document; position; identifier; contentFormat } = @@ -118,5 +118,5 @@ let on_request ~params state = let doc = Document_store.get state.State.store uri in match Document.kind doc with | `Other -> Fiber.return `Null - | `Merlin merlin -> dispatch ~merlin ~position ~identifier ~contentFormat) + | `Merlin merlin -> dispatch ~log_info ~merlin ~position ~identifier ~contentFormat) ;; diff --git a/ocaml-lsp-server/src/custom_requests/req_get_documentation.mli b/ocaml-lsp-server/src/req_get_documentation.mli similarity index 75% rename from ocaml-lsp-server/src/custom_requests/req_get_documentation.mli rename to ocaml-lsp-server/src/req_get_documentation.mli index 66ad7da8d..23a997aac 100644 --- a/ocaml-lsp-server/src/custom_requests/req_get_documentation.mli +++ b/ocaml-lsp-server/src/req_get_documentation.mli @@ -19,4 +19,9 @@ type t val t_of_yojson : Json.t -> t val meth : string val capability : string * [> `Bool of bool ] -val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t + +val on_request + : log_info:Lsp_timing_logger.t + -> params:Jsonrpc.Structured.t option + -> State.t + -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/req_hover_extended.ml b/ocaml-lsp-server/src/req_hover_extended.ml new file mode 100644 index 000000000..605824ca7 --- /dev/null +++ b/ocaml-lsp-server/src/req_hover_extended.ml @@ -0,0 +1,103 @@ +open Import +open Fiber.O + +let capability = "handleHoverExtended", `Bool true +let meth = "ocamllsp/hoverExtended" + +let get_doc_id ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`Assoc params) -> + List.assoc_opt "textDocument" params + |> Option.map ~f:TextDocumentIdentifier.t_of_yojson + | _ -> None +;; + +let get_pos ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`Assoc params) -> + List.assoc_opt "position" params |> Option.map ~f:Position.t_of_yojson + | _ -> None +;; + +module Request_params = struct + open Json.Conv + + type t = + { text_document : TextDocumentIdentifier.t [@key "textDocument"] + ; cursor_position : Position.t [@key "position"] + ; verbosity : int Json.Nullable_option.t [@default None] [@yojson_drop_default ( = )] + } + [@@deriving yojson] [@@yojson.allow_extra_fields] + + let create ?verbosity ~text_document ~cursor_position () = + { text_document; cursor_position; verbosity } + ;; + + let params_schema = + `Assoc + [ "textDocument", `String "" + ; "position", `String "" + ; "verbosity", `String "" + ] + ;; + + let of_jsonrpc_params params = + try Some (t_of_yojson (Jsonrpc.Structured.yojson_of_t params)) with + | _exn -> None + ;; + + let of_jsonrpc_params_exn params : t = + let params_spec = Util.{ params_schema; of_jsonrpc_params } in + Util.of_jsonrpc_params_exn params_spec params + ;; +end + +type t = Hover.t + +let t_of_yojson = Hover.t_of_yojson + +module Response_json = struct + open Lsp.Types + + type t = Hover_req.extended_hover = + { hover : Hover.t (* Extended hover extensions *) + ; verbosity : int + ; can_increase_verbosity : bool + } + + let yojson_of_t { hover; verbosity; can_increase_verbosity } = + match Hover.yojson_of_t hover with + | `Assoc fields -> + let extended = + ("verbosity", yojson_of_int verbosity) + :: ("canIncreaseVerbosity", `Bool can_increase_verbosity) + :: ("canDecreaseVerbosity", `Bool (verbosity > 0)) + :: fields + in + `Assoc extended + | _ -> failwith "Couldn't create yojson for extended hover." + ;; +end + +let on_request + ~log_info + ~(params : Jsonrpc.Structured.t option) + (server : State.t Server.t) + = + let { Request_params.text_document; cursor_position; verbosity } = + Request_params.of_jsonrpc_params_exn params + in + let+ res = + Hover_req.handle_extended + ~log_info + server + { HoverParams.textDocument = text_document + ; position = cursor_position + ; workDoneToken = None + } + ~verbosity + in + match res with + | None -> `Null + | Some res -> Response_json.yojson_of_t res +;; diff --git a/ocaml-lsp-server/src/req_hover_extended.mli b/ocaml-lsp-server/src/req_hover_extended.mli new file mode 100644 index 000000000..c89b145bd --- /dev/null +++ b/ocaml-lsp-server/src/req_hover_extended.mli @@ -0,0 +1,36 @@ +open Import + +module Request_params : sig + type t = + { text_document : Import.TextDocumentIdentifier.t + ; cursor_position : Position.t + ; verbosity : int Import.Json.Nullable_option.t + } + + val create + : ?verbosity:int + -> text_document:Lsp.Types.TextDocumentIdentifier.t + -> cursor_position:Position.t + -> unit + -> t + + val t_of_yojson : Yojson.Safe.t -> t + val yojson_of_t : t -> Yojson.Safe.t + val params_schema : [> `Assoc of (string * [> `String of string ]) list ] + val of_jsonrpc_params : Jsonrpc.Structured.t -> t option + val of_jsonrpc_params_exn : Jsonrpc.Structured.t option -> t +end + +type t + +val t_of_yojson : Json.t -> t +val capability : string * Json.t +val meth : string +val get_doc_id : params:Jsonrpc.Structured.t option -> TextDocumentIdentifier.t option +val get_pos : params:Jsonrpc.Structured.t option -> Position.t option + +val on_request + : log_info:Lsp_timing_logger.t + -> params:Jsonrpc.Structured.t option + -> State.t Server.t + -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_infer_intf.ml b/ocaml-lsp-server/src/req_infer_intf.ml similarity index 75% rename from ocaml-lsp-server/src/custom_requests/req_infer_intf.ml rename to ocaml-lsp-server/src/req_infer_intf.ml index 289c190e5..31f99df7d 100644 --- a/ocaml-lsp-server/src/custom_requests/req_infer_intf.ml +++ b/ocaml-lsp-server/src/req_infer_intf.ml @@ -4,7 +4,15 @@ open Fiber.O let capability = "handleInferIntf", `Bool true let meth = "ocamllsp/inferIntf" -let on_request ~(params : Jsonrpc.Structured.t option) (state : State.t) = +let get_doc_id ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`List [ json_uri ]) -> + let uri = DocumentUri.t_of_yojson json_uri in + Some { TextDocumentIdentifier.uri } + | _ -> None +;; + +let on_request ~log_info ~(params : Jsonrpc.Structured.t option) (state : State.t) = Fiber.of_thunk (fun () -> match params with | Some (`List [ json_uri ]) -> @@ -19,7 +27,7 @@ let on_request ~(params : Jsonrpc.Structured.t option) (state : State.t) = first." ()) | Some impl -> - let+ intf = Inference.infer_intf_for_impl impl in + let+ intf = Inference.infer_intf_for_impl ~log_info impl in Json.t_of_yojson (`String intf)) | Some json -> Jsonrpc.Response.Error.raise diff --git a/ocaml-lsp-server/src/req_infer_intf.mli b/ocaml-lsp-server/src/req_infer_intf.mli new file mode 100644 index 000000000..6b77f701d --- /dev/null +++ b/ocaml-lsp-server/src/req_infer_intf.mli @@ -0,0 +1,11 @@ +open Import + +val capability : string * Json.t +val meth : string +val get_doc_id : params:Jsonrpc.Structured.t option -> TextDocumentIdentifier.t option + +val on_request + : log_info:Lsp_timing_logger.t + -> params:Jsonrpc.Structured.t option + -> State.t + -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_merlin_call_compatible.ml b/ocaml-lsp-server/src/req_merlin_call_compatible.ml similarity index 87% rename from ocaml-lsp-server/src/custom_requests/req_merlin_call_compatible.ml rename to ocaml-lsp-server/src/req_merlin_call_compatible.ml index 41ec7633c..279ed9d98 100644 --- a/ocaml-lsp-server/src/custom_requests/req_merlin_call_compatible.ml +++ b/ocaml-lsp-server/src/req_merlin_call_compatible.ml @@ -3,6 +3,14 @@ open Import let capability = "handleMerlinCallCompatible", `Bool true let meth = "ocamllsp/merlinCallCompatible" +let get_doc_id ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`Assoc params) -> + List.assoc_opt "textDocument" params + |> Option.map ~f:TextDocumentIdentifier.t_of_yojson + | _ -> None +;; + module Request_params = struct type t = { text_document : TextDocumentIdentifier.t @@ -33,7 +41,7 @@ module Request_params = struct let+ args = List.fold_left ~f:(fun acc x -> - let* acc in + let* acc = acc in let+ x = stringish_of_yojson x in x :: acc) ~init:(Some []) @@ -48,7 +56,7 @@ module Request_params = struct List.fold_left ~f:(fun acc (key, value) -> let key = "-" ^ key in - let* acc in + let* acc = acc in let+ x = stringish_of_yojson value in x :: key :: acc) ~init:(Some []) @@ -101,7 +109,7 @@ let t_of_yojson json = { result_as_sexp; result } ;; -let with_pipeline state uri specs raw_args cmd_args f = +let with_pipeline ~log_info state uri specs raw_args cmd_args f = let doc = Document_store.get state.State.store uri in match Document.kind doc with | `Other -> Fiber.return `Null @@ -118,7 +126,7 @@ let with_pipeline state uri specs raw_args cmd_args f = config cmd_args in - Document.Merlin.with_configurable_pipeline_exn ~config merlin (f args) + Document.Merlin.with_configurable_pipeline_exn ~log_info ~config merlin (f args) ;; let raise_invalid_params ?data ~message () = @@ -139,17 +147,20 @@ let perform_query action params pipeline = `Assoc [ "class", `String class_; "value", output ] ;; -let on_request ~params state = +let on_request ~(log_info : Lsp_timing_logger.t) ~params state = Fiber.of_thunk (fun () -> let params = (Option.value ~default:(`Assoc []) params :> Json.t) in let Request_params.{ result_as_sexp; command; args; text_document } = Request_params.t_of_yojson params in + let log_info = { log_info with action = log_info.action ^ "-" ^ command } in match Merlin_commands.New_commands.(find_command command all_commands) with | Merlin_commands.New_commands.Command (_name, _doc, specs, params, action) -> let open Fiber.O in let uri = text_document.uri in - let+ json = with_pipeline state uri specs args params @@ perform_query action in + let+ json = + with_pipeline ~log_info state uri specs args params @@ perform_query action + in let result = if result_as_sexp then Merlin_utils.(json |> Sexp.of_json |> Sexp.to_string) diff --git a/ocaml-lsp-server/src/custom_requests/req_merlin_call_compatible.mli b/ocaml-lsp-server/src/req_merlin_call_compatible.mli similarity index 60% rename from ocaml-lsp-server/src/custom_requests/req_merlin_call_compatible.mli rename to ocaml-lsp-server/src/req_merlin_call_compatible.mli index fa6a0c1ea..01b8fe258 100644 --- a/ocaml-lsp-server/src/custom_requests/req_merlin_call_compatible.mli +++ b/ocaml-lsp-server/src/req_merlin_call_compatible.mli @@ -18,4 +18,10 @@ type t val t_of_yojson : Json.t -> t val capability : string * Json.t val meth : string -val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t +val get_doc_id : params:Jsonrpc.Structured.t option -> TextDocumentIdentifier.t option + +val on_request + : log_info:Lsp_timing_logger.t + -> params:Jsonrpc.Structured.t option + -> State.t + -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.ml b/ocaml-lsp-server/src/req_switch_impl_intf.ml similarity index 87% rename from ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.ml rename to ocaml-lsp-server/src/req_switch_impl_intf.ml index e9c27d844..efcdd0317 100644 --- a/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.ml +++ b/ocaml-lsp-server/src/req_switch_impl_intf.ml @@ -9,6 +9,14 @@ let switch merlin_doc (param : DocumentUri.t) : Json.t = Json.yojson_of_list Uri.yojson_of_t files_to_switch_to ;; +let get_doc_id ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`List [ json_uri ]) -> + let uri = DocumentUri.t_of_yojson json_uri in + Some { TextDocumentIdentifier.uri } + | _ -> None +;; + let on_request ~(params : Jsonrpc.Structured.t option) (state : State.t) = match params with | Some (`List [ json_uri ]) -> diff --git a/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.mli b/ocaml-lsp-server/src/req_switch_impl_intf.mli similarity index 61% rename from ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.mli rename to ocaml-lsp-server/src/req_switch_impl_intf.mli index 716c81426..797d2b23a 100644 --- a/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.mli +++ b/ocaml-lsp-server/src/req_switch_impl_intf.mli @@ -2,4 +2,5 @@ open Import val capability : string * Json.t val meth : string +val get_doc_id : params:Jsonrpc.Structured.t option -> TextDocumentIdentifier.t option val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t diff --git a/ocaml-lsp-server/src/custom_requests/req_type_enclosing.ml b/ocaml-lsp-server/src/req_type_enclosing.ml similarity index 88% rename from ocaml-lsp-server/src/custom_requests/req_type_enclosing.ml rename to ocaml-lsp-server/src/req_type_enclosing.ml index da736cc3a..3557ec626 100644 --- a/ocaml-lsp-server/src/custom_requests/req_type_enclosing.ml +++ b/ocaml-lsp-server/src/req_type_enclosing.ml @@ -3,6 +3,14 @@ open Import let capability = "handleTypeEnclosing", `Bool true let meth = "ocamllsp/typeEnclosing" +let get_doc_id ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`Assoc params) -> + List.assoc_opt "textDocument" params + |> Option.map ~f:TextDocumentIdentifier.t_of_yojson + | _ -> None +;; + module Request_params = struct type t = { text_document : TextDocumentIdentifier.t @@ -49,6 +57,16 @@ module Request_params = struct ;; end +let get_pos ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`Assoc [ ("index", _); ("verbosity", _); ("textDocument", _); ("at", at_json) ]) + -> + (match Request_params.at_of_yojson at_json with + | `Position p -> Some p + | `Range r -> Some r.end_) + | _ -> None +;; + type t = { index : int ; type_ : string @@ -78,7 +96,7 @@ let config_with_given_verbosity config verbosity = { config with query = { config.query with verbosity } } ;; -let with_pipeline state uri verbosity with_pipeline = +let with_pipeline ~log_info state uri verbosity with_pipeline = let doc = Document_store.get state.State.store uri in match Document.kind doc with | `Other -> Fiber.return `Null @@ -87,6 +105,7 @@ let with_pipeline state uri verbosity with_pipeline = let* config = Document.Merlin.mconfig merlin in Document.Merlin.with_configurable_pipeline_exn ~config:(config_with_given_verbosity config verbosity) + ~log_info merlin with_pipeline ;; @@ -160,7 +179,7 @@ let dispatch_type_enclosing position index range_end pipeline = yojson_of_t { index; type_; enclosings } ;; -let on_request ~params state = +let on_request ~log_info ~params state = Fiber.of_thunk (fun () -> let params = (Option.value ~default:(`Assoc []) params :> Json.t) in let Request_params.{ index; verbosity; text_document; at } = @@ -173,5 +192,6 @@ let on_request ~params state = in let uri = text_document.uri in let verbosity = Mconfig.Verbosity.Lvl verbosity in - with_pipeline state uri verbosity @@ dispatch_type_enclosing position index range_end) + with_pipeline ~log_info state uri verbosity + @@ dispatch_type_enclosing position index range_end) ;; diff --git a/ocaml-lsp-server/src/custom_requests/req_type_enclosing.mli b/ocaml-lsp-server/src/req_type_enclosing.mli similarity index 56% rename from ocaml-lsp-server/src/custom_requests/req_type_enclosing.mli rename to ocaml-lsp-server/src/req_type_enclosing.mli index 4f2b55e12..952e25e0d 100644 --- a/ocaml-lsp-server/src/custom_requests/req_type_enclosing.mli +++ b/ocaml-lsp-server/src/req_type_enclosing.mli @@ -19,4 +19,11 @@ type t val t_of_yojson : Json.t -> t val capability : string * Json.t val meth : string -val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t +val get_doc_id : params:Jsonrpc.Structured.t option -> TextDocumentIdentifier.t option +val get_pos : params:Jsonrpc.Structured.t option -> Position.t option + +val on_request + : log_info:Lsp_timing_logger.t + -> params:Jsonrpc.Structured.t option + -> State.t + -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/req_typed_holes.ml b/ocaml-lsp-server/src/req_typed_holes.ml new file mode 100644 index 000000000..d74ef6735 --- /dev/null +++ b/ocaml-lsp-server/src/req_typed_holes.ml @@ -0,0 +1,156 @@ +open Import +open Fiber.O + +let capability = "handleTypedHoles", `Bool true +let jump_capability = "jumpToHole", `Bool true +let meth = "ocamllsp/typedHoles" +let jump = "ocamllsp/jumpToHole" + +let get_doc_id ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`Assoc params) -> + List.assoc_opt "uri" params + |> Option.map ~f:(fun (param : Json.t) -> + let uri = DocumentUri.t_of_yojson param in + { TextDocumentIdentifier.uri }) + | _ -> None +;; + +let get_pos ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`Assoc params) -> + List.assoc_opt "position" params |> Option.map ~f:Position.t_of_yojson + | _ -> None +;; + +let raise_invalid_params ?data ~message () = + Jsonrpc.Response.Error.raise + @@ Jsonrpc.Response.Error.make + ?data + ~code:Jsonrpc.Response.Error.Code.InvalidParams + ~message + () +;; + +module Request_params = struct + type t = Uri.t + + (* Request params must have the form as in the given string. *) + let expected_params = `Assoc [ "uri", `String "" ] + let create uri = uri + + let t_of_structured_json params : t option = + match params with + | `Assoc [ ("uri", uri) ] -> + let uri = Uri.t_of_yojson uri in + Some uri + | _ -> None + ;; + + let parse_exn (params : Jsonrpc.Structured.t option) : t = + match params with + | None -> raise_invalid_params ~message:"Expected params but received none" () + | Some params -> + (match t_of_structured_json params with + | Some uri -> uri + | None -> + let error_json = + `Assoc + [ "params_expected", expected_params; "params_received", (params :> Json.t) ] + in + raise_invalid_params ~message:"Unxpected parameter format" ~data:error_json ()) + ;; + + let yojson_of_t = Uri.yojson_of_t +end + +type t = Range.t list + +let t_of_yojson list = + let open Yojson.Safe.Util in + list |> to_list |> List.map ~f:(fun range -> range |> Range.t_of_yojson) +;; + +let get_holes_from_merlin ~log_info ~uri ~(state : State.t) = + let doc = Document_store.get_opt state.store uri in + match doc with + | None -> + let message = + Printf.sprintf "Document %s wasn't found in the document store" (Uri.to_string uri) + in + raise_invalid_params ~message () + | Some doc -> + let+ holes = Document.Merlin.dispatch_exn ~log_info (Document.merlin_exn doc) Holes in + List.map ~f:(fun (loc, _type) -> Range.of_loc loc) holes +;; + +let on_request ~log_info ~(params : Jsonrpc.Structured.t option) (state : State.t) = + Fiber.of_thunk (fun () -> + let uri = Request_params.parse_exn params in + let+ holes = get_holes_from_merlin ~log_info ~uri ~state in + Json.yojson_of_list Range.yojson_of_t holes) +;; + +module Jump_request_params = struct + type dir = + | Next + | Prev + + type t = + { text_document_uri : Uri.t + ; cursor_position : Position.t + ; direction : dir + } + + let expected_params = + `Assoc + [ "uri", `String "" + ; "position", `String "" + ; "direction", `String "prev|next" + ] + ;; + + let parse_exn (params : Jsonrpc.Structured.t option) : t = + match params with + | None -> + raise_invalid_params ~message:"Expected params for jumpToHole but received none" () + | Some params -> + (match params with + | `Assoc [ ("uri", uri); ("position", position); ("direction", `String direction) ] + -> + let text_document_uri = Uri.t_of_yojson uri in + let cursor_position = Position.t_of_yojson position in + let direction = + match direction with + | "next" -> Next + | "prev" -> Prev + | _ -> raise_invalid_params ~message:("Invalid direction: " ^ direction) () + in + { text_document_uri; cursor_position; direction } + | _ -> + let error_json = + `Assoc + [ "params_expected", expected_params; "params_received", (params :> Json.t) ] + in + raise_invalid_params + ~message:"Unxpected parameter format in jumpToHole" + ~data:error_json + ()) + ;; +end + +let on_jump_request ~log_info ~(params : Jsonrpc.Structured.t option) (state : State.t) = + Fiber.of_thunk (fun () -> + let params = Jump_request_params.parse_exn params in + let uri = params.text_document_uri in + let+ holes = get_holes_from_merlin ~log_info ~uri ~state in + let cursor = params.cursor_position in + let jump_dest = + match params.direction with + | Next -> Typed_hole.next_hole ~holes ~cursor + | Prev -> Typed_hole.prev_hole ~holes ~cursor + in + match jump_dest with + | None -> `Null + | Some jump_dest -> Range.yojson_of_t jump_dest) +;; diff --git a/ocaml-lsp-server/src/req_typed_holes.mli b/ocaml-lsp-server/src/req_typed_holes.mli new file mode 100644 index 000000000..0a6dadadc --- /dev/null +++ b/ocaml-lsp-server/src/req_typed_holes.mli @@ -0,0 +1,35 @@ +open Import + +module Request_params : sig + type t + + val create : Uri.t -> t + val yojson_of_t : t -> Json.t +end + +val get_doc_id : params:Jsonrpc.Structured.t option -> TextDocumentIdentifier.t option +val get_pos : params:Jsonrpc.Structured.t option -> Position.t option + +type t + +val t_of_yojson : Json.t -> t +val capability : string * Json.t +val jump_capability : string * Json.t +val meth : string +val jump : string + +(** Sends back a list of typed-hole locations. + @param params [{ "uri": }] *) +val on_request + : log_info:Lsp_timing_logger.t + -> params:Jsonrpc.Structured.t option + -> State.t + -> Json.t Fiber.t + +(** Sends back a range, allowing the client to jump to the next/previous typed hole. + @param params [{ "uri":, "position":, "direction":"prev"|"next" }] *) +val on_jump_request + : log_info:Lsp_timing_logger.t + -> params:Jsonrpc.Structured.t option + -> State.t + -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/custom_requests/req_wrapping_ast_node.ml b/ocaml-lsp-server/src/req_wrapping_ast_node.ml similarity index 80% rename from ocaml-lsp-server/src/custom_requests/req_wrapping_ast_node.ml rename to ocaml-lsp-server/src/req_wrapping_ast_node.ml index 5908ee8e4..3fba5f60f 100644 --- a/ocaml-lsp-server/src/custom_requests/req_wrapping_ast_node.ml +++ b/ocaml-lsp-server/src/req_wrapping_ast_node.ml @@ -4,6 +4,23 @@ open Fiber.O let capability = "handleWrappingAstNode", `Bool true let meth = "ocamllsp/wrappingAstNode" +let get_doc_id ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`Assoc params) -> + List.assoc_opt "uri" params + |> Option.map ~f:(fun (param : Json.t) -> + let uri = DocumentUri.t_of_yojson param in + { TextDocumentIdentifier.uri }) + | _ -> None +;; + +let get_pos ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`Assoc params) -> + List.assoc_opt "position" params |> Option.map ~f:Position.t_of_yojson + | _ -> None +;; + module Request_params = struct type t = { text_document_uri : Uri.t @@ -29,7 +46,7 @@ module Request_params = struct ;; end -let on_request ~params state = +let on_request ~log_info ~params state = Fiber.of_thunk (fun () -> let { Request_params.text_document_uri; cursor_position } = Request_params.of_jsonrpc_params_exn params @@ -45,7 +62,7 @@ let on_request ~params state = | `Merlin doc -> let pos = Position.logical cursor_position in let+ node = - Document.Merlin.with_pipeline_exn ~name:"wrapping-ast-node" doc (fun pipeline -> + Document.Merlin.with_pipeline_exn ~log_info doc (fun pipeline -> let typer = Mpipeline.typer_result pipeline in let pos = Mpipeline.get_lexing_pos pipeline pos in let enclosing_nodes (* from smallest node to largest *) = diff --git a/ocaml-lsp-server/src/req_wrapping_ast_node.mli b/ocaml-lsp-server/src/req_wrapping_ast_node.mli new file mode 100644 index 000000000..c69854cca --- /dev/null +++ b/ocaml-lsp-server/src/req_wrapping_ast_node.mli @@ -0,0 +1,12 @@ +open Import + +val capability : string * Json.t +val meth : string +val get_doc_id : params:Jsonrpc.Structured.t option -> TextDocumentIdentifier.t option +val get_pos : params:Jsonrpc.Structured.t option -> Position.t option + +val on_request + : log_info:Lsp_timing_logger.t + -> params:Jsonrpc.Structured.t option + -> State.t + -> Json.t Fiber.t diff --git a/ocaml-lsp-server/src/semantic_highlighting.ml b/ocaml-lsp-server/src/semantic_highlighting.ml index c48a34e9f..5a179fb21 100644 --- a/ocaml-lsp-server/src/semantic_highlighting.ml +++ b/ocaml-lsp-server/src/semantic_highlighting.ml @@ -1,7 +1,6 @@ open Import open Fiber.O module Array_view = Lsp.Private.Array_view -module Parsetree_utils = Merlin_analysis.Parsetree_utils (* TODO: @@ -208,13 +207,13 @@ end = struct ;; let set_token - arr - ~delta_line_index - ~delta_line - ~delta_start - ~length - ~token_type - ~token_modifiers + arr + ~delta_line_index + ~delta_line + ~delta_start + ~length + ~token_type + ~token_modifiers = arr.(delta_line_index) <- delta_line; arr.(delta_line_index + 1) <- delta_start; @@ -277,6 +276,7 @@ end (** To traverse OCaml parsetree and produce semantic tokens. *) module Parsetree_fold (M : sig val source : string + val mconfig : Mconfig.t end) : sig val apply : Mreader.parsetree -> Tokens.t end = struct @@ -300,10 +300,10 @@ end = struct (* TODO: make sure we follow specs when parsing - https://v2.ocaml.org/manual/names.html#sss:refer-named *) let lident - ({ loc; _ } : Longident.t Loc.loc) - rightmost_name - ?(modifiers = Token_modifiers_set.empty) - () + ({ loc; _ } : Longident.t Loc.loc) + rightmost_name + ?(modifiers = Token_modifiers_set.empty) + () = if loc.loc_ghost then () @@ -351,17 +351,19 @@ end = struct ;; let constructor_arguments - (self : Ast_iterator.iterator) - (ca : Parsetree.constructor_arguments) + (self : Ast_iterator.iterator) + (ca : Parsetree.constructor_arguments) = match ca with - | Pcstr_tuple l -> List.iter l ~f:(fun ct -> self.typ self ct) + | Pcstr_tuple l -> + List.iter l ~f:(fun (ca : Ocaml_parsing.Parsetree.constructor_argument) -> + self.typ self ca.pca_type) | Pcstr_record l -> List.iter l ~f:(fun r -> self.label_declaration self r) ;; let module_binding - (self : Ast_iterator.iterator) - ({ pmb_name; pmb_expr; pmb_attributes; pmb_loc = _ } : Parsetree.module_binding) + (self : Ast_iterator.iterator) + ({ pmb_name; pmb_expr; pmb_attributes; pmb_loc = _ } : Parsetree.module_binding) = add_token pmb_name.loc Token_type.module_ (Token_modifiers_set.singleton Definition); self.module_expr self pmb_expr; @@ -369,9 +371,9 @@ end = struct ;; let typ - (self : Ast_iterator.iterator) - ({ ptyp_desc; ptyp_attributes; ptyp_loc; ptyp_loc_stack = _ } as ct : - Parsetree.core_type) + (self : Ast_iterator.iterator) + ({ ptyp_desc; ptyp_attributes; ptyp_loc; ptyp_loc_stack = _ } as ct : + Parsetree.core_type) = let iter = match ptyp_desc with @@ -383,19 +385,16 @@ end = struct lident name (Token_type.of_builtin Type) (); `Custom_iterator | Ptyp_poly (tps, ct) -> - List.iter tps ~f:(fun (tp : _ Asttypes.loc) -> + List.iter tps ~f:(fun ((tp : _ Asttypes.loc), _) -> add_token tp.loc (Token_type.of_builtin TypeParameter) Token_modifiers_set.empty); self.typ self ct; `Custom_iterator - | Ptyp_any -> `Custom_iterator + | Ptyp_any _ -> `Custom_iterator | Ptyp_variant (_, _, _) - | Ptyp_alias (_, _) - | Ptyp_arrow _ - | Ptyp_extension _ - | Ptyp_package _ - | Ptyp_object _ - | Ptyp_tuple _ - | Ptyp_open _ -> `Default_iterator + | Ptyp_alias (_, _, _) + | Ptyp_arrow _ | Ptyp_extension _ | Ptyp_package _ | Ptyp_object _ + | Ptyp_open (_, _) | Ptyp_of_kind _ + | Ptyp_tuple _ | Ptyp_unboxed_tuple _ -> `Default_iterator in match iter with | `Default_iterator -> Ast_iterator.default_iterator.typ self ct @@ -403,15 +402,15 @@ end = struct ;; let constructor_declaration - (self : Ast_iterator.iterator) - ({ pcd_name; pcd_vars; pcd_args; pcd_res; pcd_loc = _; pcd_attributes } : - Parsetree.constructor_declaration) + (self : Ast_iterator.iterator) + ({ pcd_name; pcd_vars; pcd_args; pcd_res; pcd_loc = _; pcd_attributes } : + Parsetree.constructor_declaration) = add_token pcd_name.loc (Token_type.of_builtin EnumMember) (Token_modifiers_set.singleton Declaration); - List.iter pcd_vars ~f:(fun (var : _ Asttypes.loc) -> + List.iter pcd_vars ~f:(fun ((var : _ Asttypes.loc), _) -> add_token var.loc (Token_type.of_builtin TypeParameter) Token_modifiers_set.empty); constructor_arguments self pcd_args; Option.iter pcd_res ~f:(fun ct -> self.typ self ct); @@ -419,9 +418,15 @@ end = struct ;; let label_declaration - (self : Ast_iterator.iterator) - ({ pld_name; pld_mutable = _; pld_type; pld_loc = _; pld_attributes } : - Parsetree.label_declaration) + (self : Ast_iterator.iterator) + ({ pld_name + ; pld_mutable = _ + ; pld_type + ; pld_loc = _ + ; pld_attributes + ; pld_modalities = _ + } : + Parsetree.label_declaration) = add_token pld_name.loc (Token_type.of_builtin Property) Token_modifiers_set.empty; self.typ self pld_type; @@ -429,8 +434,8 @@ end = struct ;; let value_binding - (self : Ast_iterator.iterator) - ({ pvb_pat; pvb_expr; pvb_attributes; _ } as vb : Parsetree.value_binding) + (self : Ast_iterator.iterator) + ({ pvb_pat; pvb_expr; pvb_attributes; _ } as vb : Parsetree.value_binding) = match match pvb_pat.ppat_desc, pvb_expr.pexp_desc with @@ -444,8 +449,8 @@ end = struct self.expr self pvb_expr; `Custom_iterator | _ -> `Default_iterator) - | ( Ppat_constraint ({ ppat_desc = Ppat_var n; _ }, pat_ct) - , Pexp_constraint (e, exp_ct) ) + | ( Ppat_constraint ({ ppat_desc = Ppat_var n; _ }, Some pat_ct, _) + , Pexp_constraint (e, Some exp_ct, _) ) when Loc.compare pat_ct.ptyp_loc exp_ct.ptyp_loc = 0 -> (* handles [let f : t -> unit = fun t -> ()] *) add_token @@ -465,17 +470,18 @@ end = struct ;; let type_declaration - (self : Ast_iterator.iterator) - ({ ptype_name - ; ptype_params - ; ptype_cstrs - ; ptype_kind - ; ptype_private = _ - ; ptype_manifest - ; ptype_attributes - ; ptype_loc = _ - } : - Parsetree.type_declaration) + (self : Ast_iterator.iterator) + ({ ptype_name + ; ptype_params + ; ptype_cstrs + ; ptype_kind + ; ptype_private = _ + ; ptype_manifest + ; ptype_attributes + ; ptype_loc = _ + ; ptype_jkind_annotation = _ + } : + Parsetree.type_declaration) = List.iter ptype_params @@ -493,7 +499,7 @@ end = struct (match ptype_kind with | Parsetree.Ptype_abstract | Ptype_open -> Token_type.of_builtin Type | Ptype_variant _ -> Token_type.of_builtin Enum - | Ptype_record _ -> Token_type.of_builtin Struct) + | Ptype_record _ | Ptype_record_unboxed_product _ -> Token_type.of_builtin Struct) (Token_modifiers_set.singleton Declaration); List.iter ptype_cstrs ~f:(fun (ct0, ct1, (_ : Loc.t)) -> self.typ self ct0; @@ -503,17 +509,18 @@ end = struct | Parsetree.Ptype_abstract | Parsetree.Ptype_open -> () | Ptype_variant cds -> List.iter cds ~f:(fun cd -> self.constructor_declaration self cd) - | Ptype_record lds -> List.iter lds ~f:(fun ld -> self.label_declaration self ld)); + | Ptype_record lds | Ptype_record_unboxed_product lds -> + List.iter lds ~f:(fun ld -> self.label_declaration self ld)); self.attributes self ptype_attributes ;; let const loc (constant : Parsetree.constant) = - let token_type = - match Parsetree_utils.constant_desc constant with - | Parsetree.Pconst_integer _ | Pconst_float _ -> Token_type.of_builtin Number - | Pconst_char _ | Pconst_string _ -> Token_type.of_builtin String - in - add_token loc token_type Token_modifiers_set.empty + match constant with + | Parsetree.Pconst_integer _ | Pconst_float _ + | Pconst_unboxed_integer (_, _) + | Pconst_unboxed_float (_, _) -> + add_token loc (Token_type.of_builtin Number) Token_modifiers_set.empty + | Pconst_char _ | Pconst_untagged_char _ | Pconst_string _ -> () ;; let pexp_apply (self : Ast_iterator.iterator) (expr : Parsetree.expression) args = @@ -546,10 +553,102 @@ end = struct | _ -> `Default_iterator ;; + let ppx_string_extension ~string ~string_loc ~delimiter + : Parsetree.expression list = + let parse_result = + (* NOTE: This awkward dance is required as ppxlib's and ocamllsp's AST types + (including their locations!) are not type equal to each other. *) + let ({ loc_start; loc_end; loc_ghost } : Loc.t) = string_loc in + Ppx_string.parse + ~config:(Ppx_string.config_for_string Local_input_heap_output) + ~string_loc:{ loc_start; loc_end; loc_ghost } + ~delimiter + string + in + match parse_result.locations_are_precise with + | false -> [] + | true -> + (* We go through each interpolated part of the ppx, re-parse the contents using + merlin, correct the locations in the parsed AST using the location we get from + [Ppx_string], and then return the list of parsed expressions to be recursively + highlighted. *) + List.filter_map parse_result.parts ~f:(function + | Ppx_string.Part.Literal _ -> None + | Interpreted + { value = { pexp_loc = { loc_start = offset_start; _ }; _ } + ; interpreted_string + ; _ + } -> + let offset ({ loc_start; loc_end; loc_ghost } : Loc.t) : Loc.t = + let add_positions (a : Lexing.position) (b : Lexing.position) = + { a with + (* Subtract 1 because line numbers start at 1 *) + pos_lnum = a.pos_lnum - 1 + b.pos_lnum + ; pos_bol = a.pos_bol + b.pos_bol + ; pos_cnum = a.pos_cnum + b.pos_cnum + } + in + let loc_start = add_positions loc_start offset_start in + let loc_end = add_positions loc_end offset_start in + { loc_start; loc_end; loc_ghost } + in + let map_offset (self : Ast_mapper.mapper) (expr : Parsetree.expression) = + let pexp_desc : Parsetree.expression_desc = + match expr.pexp_desc with + | Pexp_apply (lhs, args) -> + let lhs = self.expr self lhs in + let args = List.map args ~f:(fun (label, e) -> label, self.expr self e) in + Pexp_apply (lhs, args) + | Pexp_ident { txt; loc } -> Pexp_ident { txt; loc = offset loc } + | Pexp_tuple parts -> + Pexp_tuple + (List.map parts ~f:(fun (label, exp) -> label, self.expr self exp)) + | Pexp_construct ({ txt; loc }, e) -> + Pexp_construct + ({ txt; loc = offset loc }, Option.map e ~f:(self.expr self)) + | Pexp_variant (label, e) -> + Pexp_variant (label, Option.map e ~f:(self.expr self)) + | Pexp_field (e, { txt; loc }) -> + Pexp_field (self.expr self e, { txt; loc = offset loc }) + | _ -> expr.pexp_desc + in + { expr with pexp_desc; pexp_loc = offset expr.pexp_loc } + in + let mapper = { Ast_mapper.default_mapper with expr = map_offset } in + (* We'll recursively semantic highlight the interpolated expression (without the + #Module annotation) *) + let source = + Msource.make (String.split interpreted_string ~on:'#' |> List.hd_exn) + in + let ({ parsetree; _ } : Mreader.result) = + Mreader.parse M.mconfig (source, None) + in + (match parsetree with + | `Interface _ -> None + | `Implementation structure -> + let structure = mapper.structure mapper structure in + (match structure with + | [] -> None + | items -> + let exprs = + List.filter_map + items + ~f:(fun ({ pstr_desc; _ } : Parsetree.structure_item) -> + match pstr_desc with + | Pstr_eval (expr, _) -> + Some expr + (* A standalone expression is the only relevant kind node for the + interpolated part of ppx_string *) + | _ -> None) + in + Some exprs))) + |> List.concat + ;; + let expr - (self : Ast_iterator.iterator) - ({ pexp_desc; pexp_loc; pexp_loc_stack = _; pexp_attributes } as exp : - Parsetree.expression) + (self : Ast_iterator.iterator) + ({ pexp_desc; pexp_loc; pexp_loc_stack = _; pexp_attributes } as exp : + Parsetree.expression) = match match pexp_desc with @@ -569,21 +668,64 @@ end = struct Option.iter vo ~f:(fun v -> self.expr self v)); `Custom_iterator | Pexp_apply (expr, args) -> pexp_apply self expr args - | Pexp_function _ | Pexp_let (_, _, _) -> `Default_iterator + | Pexp_let (_, _, _, _) -> `Default_iterator + | Pexp_function (params, constraint_, function_body) -> + List.iter params ~f:(fun (param : Ocaml_parsing.Parsetree.function_param) -> + match param.pparam_desc with + (* handles types like [type a] in [let f (type a) x y z = ...] *) + | Pparam_newtype (t, _) -> + add_token + t.loc + (Token_type.of_builtin TypeParameter) + Token_modifiers_set.empty + (* handles value parameters and optional args *) + | Pparam_val (_, expr_opt, pat) -> + (match expr_opt with + | None -> self.pat self pat + | Some e -> + if Loc.compare e.pexp_loc pat.ppat_loc < 0 + then ( + self.expr self e; + self.pat self pat) + else ( + self.pat self pat; + self.expr self e))); + (* handles type constraints like [let f () : ty = ...] *) + Option.iter constraint_.ret_type_constraint ~f:(fun constraint_ -> + match constraint_ with + | Pconstraint ct -> self.typ self ct + | Pcoerce (ct1, ct2) -> + Option.iter ct1 ~f:(self.typ self); + self.typ self ct2); + (match function_body with + | Pfunction_body e -> self.expr self e + | Pfunction_cases (cases, loc, attributes) -> + self.cases self cases; + self.location self loc; + self.attributes self attributes); + `Custom_iterator | Pexp_try (_, _) - | Pexp_tuple _ + | Pexp_tuple _ | Pexp_unboxed_tuple _ | Pexp_variant (_, _) (* ^ label for a poly variant is missing location info -- we could have a workaround by "parsing" this part of code ourselves*) | Pexp_match (_, _) -> `Default_iterator - | Pexp_record (props, exp) -> + | Pexp_record (props, exp) | Pexp_record_unboxed_product (props, exp) -> Option.iter exp ~f:(fun e -> self.expr self e); List.iter props ~f:(fun (lid, (exp : Parsetree.expression)) -> lident lid (Token_type.of_builtin Property) (); if Loc.compare lid.loc exp.pexp_loc <> 0 (* handles field punning *) then self.expr self exp); `Custom_iterator - | Pexp_field (e, l) -> + | Pexp_idx (block_access, unboxed_accesses) -> + (match block_access with + | Baccess_field l -> lident l (Token_type.of_builtin Property) () + | Baccess_array (_, _, e) + | Baccess_block (_, e) -> self.expr self e ); + List.iter unboxed_accesses ~f:(fun (Parsetree.Uaccess_unboxed_field l) -> + lident l (Token_type.of_builtin Property) ()); + `Custom_iterator + | Pexp_field (e, l) | Pexp_unboxed_field (e, l) -> self.expr self e; lident l (Token_type.of_builtin Property) (); `Custom_iterator @@ -599,7 +741,7 @@ end = struct | Pexp_new l -> lident l (Token_type.of_builtin Class) (); `Custom_iterator - | Pexp_newtype (t, e) -> + | Pexp_newtype (t, _, e) -> add_token t.loc (Token_type.of_builtin TypeParameter) Token_modifiers_set.empty; self.expr self e; `Custom_iterator @@ -616,50 +758,64 @@ end = struct self.expr self e0; self.expr self e1; `Custom_iterator - | Pexp_constraint (e, ct) -> - (* handles [let f () : int = 1] and [let f () = (1 : int)] *) - if Loc.compare e.pexp_loc ct.ptyp_loc > 0 - then ( - self.typ self ct; - self.expr self e) - else ( - self.expr self e; - self.typ self ct); + | Pexp_constraint (e, ct, _) -> + self.expr self e; + Option.iter ct ~f:(self.typ self); + `Custom_iterator + | Pexp_stack e -> + self.expr self e; `Custom_iterator | Pexp_letop { let_; ands; body } -> List.iter (let_ :: ands) ~f:(fun { Parsetree.pbop_op = _; pbop_pat; pbop_exp; pbop_loc = _ } -> self.pat self pbop_pat; - if - Loc.compare pbop_pat.ppat_loc pbop_exp.pexp_loc - <> 0 (* handles punning as in e.g. [let* foo in ]*) + if Loc.compare pbop_pat.ppat_loc pbop_exp.pexp_loc + <> 0 (* handles punning as in e.g. [let* foo in ]*) then self.expr self pbop_exp); self.expr self body; `Custom_iterator + | Pexp_extension + ( { txt = ("string" | "string.global"); loc = _ } + , PStr + [ { pstr_desc = + Pstr_eval + ( { pexp_desc = Pexp_constant (Pconst_string (string, _, delimiter)) + ; pexp_loc = string_loc + ; _ + } + , _ ) + ; _ + } + ] ) -> + List.iter + (ppx_string_extension ~string ~string_loc ~delimiter) + ~f:(self.expr self); + `Custom_iterator | Pexp_unreachable -> `Custom_iterator | Pexp_array _ | Pexp_ifthenelse (_, _, _) | Pexp_while (_, _) | Pexp_for (_, _, _, _, _) | Pexp_coerce (_, _, _) - | Pexp_setinstvar (_, _) + | Pexp_setvar (_, _) | Pexp_override _ | Pexp_letexception (_, _) | Pexp_assert _ | Pexp_lazy _ | Pexp_poly (_, _) | Pexp_object _ | Pexp_pack _ | Pexp_open (_, _) - | Pexp_extension _ -> `Default_iterator + | Pexp_extension _ | Pexp_comprehension _ | Pexp_hole + | Pexp_overwrite (_, _) -> `Default_iterator with | `Default_iterator -> Ast_iterator.default_iterator.expr self exp | `Custom_iterator -> self.attributes self pexp_attributes ;; let pat - (self : Ast_iterator.iterator) - ({ ppat_desc; ppat_loc; ppat_loc_stack = _; ppat_attributes } as pat : - Parsetree.pattern) + (self : Ast_iterator.iterator) + ({ ppat_desc; ppat_loc; ppat_loc_stack = _; ppat_attributes } as pat : + Parsetree.pattern) = match match ppat_desc with @@ -673,7 +829,7 @@ end = struct | Ppat_construct (c, args) -> let process_args () = Option.iter args ~f:(fun (tvs, pat) -> - List.iter tvs ~f:(fun (tv : _ Asttypes.loc) -> + List.iter tvs ~f:(fun ((tv : _ Asttypes.loc), _) -> add_token tv.loc (Token_type.of_builtin TypeParameter) @@ -702,15 +858,15 @@ end = struct | Ppat_type t -> lident t (Token_type.of_builtin Type) (); `Custom_iterator - | Ppat_record (flds, _) -> + | Ppat_record (flds, _) | Ppat_record_unboxed_product (flds, _) -> List.iter flds ~f:(fun (fld, (pat : Parsetree.pattern)) -> lident fld (Token_type.of_builtin Property) (); if Loc.compare fld.loc pat.ppat_loc <> 0 (* handles field punning *) then self.pat self pat); `Custom_iterator - | Ppat_constraint (p, ct) -> + | Ppat_constraint (p, ct, _) -> self.pat self p; - self.typ self ct; + Option.iter ct ~f:(self.typ self); `Custom_iterator | Ppat_or _ | Ppat_exception _ @@ -718,18 +874,18 @@ end = struct | Ppat_array _ | Ppat_extension _ | Ppat_tuple _ + | Ppat_unboxed_tuple _ | Ppat_lazy _ | Ppat_any - | Ppat_interval _ - | _ -> `Default_iterator + | Ppat_interval _ -> `Default_iterator with | `Default_iterator -> Ast_iterator.default_iterator.pat self pat | `Custom_iterator -> self.attributes self ppat_attributes ;; let module_expr - (self : Ast_iterator.iterator) - ({ pmod_desc; pmod_loc = _; pmod_attributes } as me : Parsetree.module_expr) + (self : Ast_iterator.iterator) + ({ pmod_desc; pmod_loc = _; pmod_attributes } as me : Parsetree.module_expr) = match match pmod_desc with @@ -739,19 +895,24 @@ end = struct | Pmod_functor (fp, me) -> (match fp with | Unit -> () - | Named (n, mt) -> + | Named (n, mt, modes) -> add_token n.loc Token_type.module_ Token_modifiers_set.empty; - self.module_type self mt); + self.module_type self mt; + self.modes self modes); self.module_expr self me; `Custom_iterator - | Pmod_constraint (me, mt) -> - if Loc.compare me.pmod_loc mt.pmty_loc > 0 - then ( - self.module_type self mt; - self.module_expr self me) - else ( - self.module_expr self me; - self.module_type self mt); + | Pmod_constraint (me, mt, modes) -> + (match mt with + | Some mt -> + if Loc.compare me.pmod_loc mt.pmty_loc > 0 + then ( + self.module_type self mt; + self.module_expr self me) + else ( + self.module_expr self me; + self.module_type self mt) + | None -> self.module_expr self me); + self.modes self modes; `Custom_iterator | Pmod_extension _ -> `Custom_iterator | _ -> @@ -764,9 +925,9 @@ end = struct ;; let module_type_declaration - (self : Ast_iterator.iterator) - ({ pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc = _ } : - Parsetree.module_type_declaration) + (self : Ast_iterator.iterator) + ({ pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc = _ } : + Parsetree.module_type_declaration) = add_token pmtd_name.loc Token_type.module_type Token_modifiers_set.empty; Option.iter pmtd_type ~f:(fun mdtt -> self.module_type self mdtt); @@ -774,23 +935,30 @@ end = struct ;; let value_description - (self : Ast_iterator.iterator) - ({ pval_name; pval_type; pval_prim = _; pval_attributes; pval_loc = _ } : - Parsetree.value_description) + (self : Ast_iterator.iterator) + ({ pval_name + ; pval_type + ; pval_prim = _ + ; pval_attributes + ; pval_loc = _ + ; pval_modalities = _ + } : + Parsetree.value_description) = add_token pval_name.loc (match pval_type.ptyp_desc with - | Ptyp_arrow (_, _, _) -> Token_type.of_builtin Function + | Ptyp_arrow (_, _, _, _, _) -> Token_type.of_builtin Function | Ptyp_class (_, _) -> Token_type.of_builtin Class | Ptyp_package _ -> Token_type.module_ | Ptyp_extension _ | Ptyp_constr (_, _) | Ptyp_object (_, _) - | Ptyp_alias (_, _) + | Ptyp_alias (_, _, _) | Ptyp_variant (_, _, _) | Ptyp_poly (_, _) - | Ptyp_tuple _ | Ptyp_any | Ptyp_var _ | Ptyp_open _ -> + | Ptyp_open (_, _) + | Ptyp_of_kind _ | Ptyp_tuple _ | Ptyp_unboxed_tuple _ | Ptyp_any _ | Ptyp_var _ -> Token_type.of_builtin Variable) (Token_modifiers_set.singleton Declaration); self.typ self pval_type; @@ -799,12 +967,13 @@ end = struct ;; let module_declaration - (self : Ast_iterator.iterator) - ({ pmd_name; pmd_type; pmd_attributes; pmd_loc = _ } : - Parsetree.module_declaration) + (self : Ast_iterator.iterator) + ({ pmd_name; pmd_type; pmd_modalities; pmd_attributes; pmd_loc = _ } : + Parsetree.module_declaration) = add_token pmd_name.loc Token_type.module_ (Token_modifiers_set.singleton Declaration); self.module_type self pmd_type; + self.modalities self pmd_modalities; self.attributes self pmd_attributes ;; @@ -814,21 +983,24 @@ end = struct | Pmty_ident l -> lident l Token_type.module_type (); `Custom_iterator - | Pmty_functor (fp, mt) -> + | Pmty_functor (fp, mt, functor_modes) -> (match fp with | Unit -> () - | Named (n, mt) -> + | Named (n, mt, fp_modes) -> add_token n.loc Token_type.module_ Token_modifiers_set.empty; - self.module_type self mt); + self.module_type self mt; + self.modes self fp_modes); self.module_type self mt; + self.modes self functor_modes; `Custom_iterator | Pmty_alias m -> lident m Token_type.module_ (); `Custom_iterator | Pmty_signature sis -> - List.iter sis ~f:(fun si -> self.signature_item self si); + List.iter sis.psg_items ~f:(fun si -> self.signature_item self si); `Custom_iterator - | Pmty_with (_, _) | Pmty_typeof _ | Pmty_extension _ -> `Default_iterator + | Pmty_with (_, _) | Pmty_typeof _ | Pmty_extension _ | Pmty_strengthen _ -> + `Default_iterator with | `Custom_iterator -> () | `Default_iterator -> Ast_iterator.default_iterator.module_type self mt @@ -868,8 +1040,8 @@ end = struct ;; end -(** File-wide mutable state that allows to generate unique IDs for semantic - tokens requests (both [full] and [full/delta]) *) +(** File-wide mutable state that allows to generate unique IDs for semantic tokens + requests (both [full] and [full/delta]) *) let gen_new_id = let i = ref 0 in fun () -> @@ -878,31 +1050,44 @@ let gen_new_id = string_of_int x ;; -let compute_tokens doc = - let+ parsetree, source = - Document.Merlin.with_pipeline_exn ~name:"semantic highlighting" doc (fun p -> +let compute_tokens ~log_info doc = + let* parsetree, source = + Document.Merlin.with_pipeline_exn ~log_info doc (fun p -> Mpipeline.reader_parsetree p, Mpipeline.input_source p) in + let+ config = Document.Merlin.mconfig doc in let module Fold = Parsetree_fold (struct let source = Msource.text source + let mconfig = config end) in Fold.apply parsetree ;; -let compute_encoded_tokens doc = - let+ tokens = compute_tokens doc in +let compute_encoded_tokens ~log_info doc = + let+ tokens = compute_tokens ~log_info doc in Tokens.encode tokens ;; -(** Contains implementation of a custom request that provides human-readable - tokens representation *) +(** Contains implementation of a custom request that provides human-readable tokens + representation *) module Debug = struct let meth_request_full = "ocamllsp/textDocument/semanticTokens/full" - let on_request_full : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t = - fun ~params state -> + let get_doc_id ~(params : Jsonrpc.Structured.t option) = + match params with + | Some (`Assoc _ as json) | Some (`List _ as json) -> + let params = SemanticTokensParams.t_of_yojson json in + Some params.textDocument + | None -> None + ;; + + let on_request_full + : log_info:Lsp_timing_logger.t -> params:Jsonrpc.Structured.t option -> State.t + -> Json.t Fiber.t + = + fun ~log_info ~params state -> Fiber.of_thunk (fun () -> match params with | None -> @@ -924,14 +1109,16 @@ module Debug = struct ~message:"expected a merlin document" () | `Merlin merlin -> - let+ tokens = compute_tokens merlin in + let+ tokens = compute_tokens ~log_info merlin in Tokens.yojson_of_t tokens)) ;; end -let on_request_full : State.t -> SemanticTokensParams.t -> SemanticTokens.t option Fiber.t +let on_request_full + : log_info:Lsp_timing_logger.t -> State.t -> SemanticTokensParams.t + -> SemanticTokens.t option Fiber.t = - fun state params -> + fun ~log_info state params -> Fiber.of_thunk (fun () -> let store = state.store in let uri = params.textDocument.uri in @@ -939,7 +1126,7 @@ let on_request_full : State.t -> SemanticTokensParams.t -> SemanticTokens.t opti match Document.kind doc with | `Other -> Fiber.return None | `Merlin doc -> - let+ tokens = compute_encoded_tokens doc in + let+ tokens = compute_encoded_tokens ~log_info doc in let resultId = gen_new_id () in Document_store.update_semantic_tokens_cache store uri ~resultId ~tokens; Some { SemanticTokens.resultId = Some resultId; data = tokens }) @@ -989,15 +1176,14 @@ let find_diff ~(old : int array) ~(new_ : int array) : SemanticTokensEdit.t list ;; let on_request_full_delta - : State.t - -> SemanticTokensDeltaParams.t + : log_info:Lsp_timing_logger.t -> State.t -> SemanticTokensDeltaParams.t -> [ `SemanticTokens of SemanticTokens.t | `SemanticTokensDelta of SemanticTokensDelta.t ] option Fiber.t = - fun state params -> + fun ~log_info state params -> Fiber.of_thunk (fun () -> let store = state.store in let uri = params.textDocument.uri in @@ -1005,7 +1191,7 @@ let on_request_full_delta match Document.kind doc with | `Other -> Fiber.return None | `Merlin doc -> - let+ tokens = compute_encoded_tokens doc in + let+ tokens = compute_encoded_tokens ~log_info doc in let resultId = gen_new_id () in let cached_token_info = Document_store.get_semantic_tokens_cache state.store params.textDocument.uri diff --git a/ocaml-lsp-server/src/semantic_highlighting.mli b/ocaml-lsp-server/src/semantic_highlighting.mli index e4fe87575..19c0351fe 100644 --- a/ocaml-lsp-server/src/semantic_highlighting.mli +++ b/ocaml-lsp-server/src/semantic_highlighting.mli @@ -1,10 +1,16 @@ open Import val legend : SemanticTokensLegend.t -val on_request_full : State.t -> SemanticTokensParams.t -> SemanticTokens.t option Fiber.t + +val on_request_full + : log_info:Lsp_timing_logger.t + -> State.t + -> SemanticTokensParams.t + -> SemanticTokens.t option Fiber.t val on_request_full_delta - : State.t + : log_info:Lsp_timing_logger.t + -> State.t -> SemanticTokensDeltaParams.t -> [ `SemanticTokens of SemanticTokens.t | `SemanticTokensDelta of SemanticTokensDelta.t @@ -14,5 +20,11 @@ val on_request_full_delta module Debug : sig val meth_request_full : string - val on_request_full : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t + val get_doc_id : params:Jsonrpc.Structured.t option -> TextDocumentIdentifier.t option + + val on_request_full + : log_info:Lsp_timing_logger.t + -> params:Jsonrpc.Structured.t option + -> State.t + -> Json.t Fiber.t end diff --git a/ocaml-lsp-server/src/signature_help.ml b/ocaml-lsp-server/src/signature_help.ml index 61f6c026c..2c9d9e3a3 100644 --- a/ocaml-lsp-server/src/signature_help.ml +++ b/ocaml-lsp-server/src/signature_help.ml @@ -10,6 +10,178 @@ open struct module Btype = Btype end +type parameter_info = + { label : Typedtree.arg_label + ; param_start : int + ; param_end : int + ; argument : Typedtree.expression option + } + +type application_signature = + { function_name : string option + ; function_position : Msource.position + ; signature : string + ; parameters : parameter_info list + ; active_param : int option + } + +(* extract a properly parenthesized identifier from (expression_desc (Texp_ident + (Longident))) *) +let extract_ident (exp_desc : Typedtree.expression_desc) = + let rec longident ppf : Longident.t -> unit = function + | Lident s -> Format.fprintf ppf "%s" (Misc_utils.parenthesize_name s) + | Ldot (p, s) -> + Format.fprintf ppf "%a.%s" longident p (Misc_utils.parenthesize_name s) + | Lapply (p1, p2) -> Format.fprintf ppf "%a(%a)" longident p1 longident p2 + in + match exp_desc with + | Texp_ident (_, { txt = li; _ }, _, _, _) -> + let ppf, to_string = Format.to_string () in + longident ppf li; + Some (to_string ()) + | _ -> None +;; + +(* Type variables shared across arguments should all be printed with the same + name. [Printtyp.type_scheme] ensure that a name is unique within a given + type, but not across different invocations. [reset] followed by calls to + [mark_loops] and [type_sch] provide that *) +let pp_type env ppf ty = + let module Printtyp = Type_utils.Printtyp in + Printtyp.wrap_printing_env env ~verbosity:(Lvl 0) (fun () -> + Printtyp.shared_type_scheme ppf ty) +;; + +let rec type_is_arrow ty = + match Types.get_desc ty with + | Tarrow _ -> true + | Tlink ty -> type_is_arrow ty + | Tpoly (ty, _) -> type_is_arrow ty + | _ -> false +;; + +(* surround function types in parentheses *) +let pp_parameter_type env ppf ty = + if type_is_arrow ty + then Format.fprintf ppf "(%a)" (pp_type env) ty + else pp_type env ppf ty +;; + +(* print parameter labels and types *) +let pp_parameter env label ppf ty = + match (label : Typedtree.arg_label) with + | Nolabel -> pp_parameter_type env ppf ty + | Labelled l -> Format.fprintf ppf "%s:%a" l (pp_parameter_type env) ty + | Optional l -> + (* unwrap option for optional labels the same way as + [Raw_compat.labels_of_application] *) + let unwrap_option ty = + match Types.get_desc ty with + | Types.Tconstr (path, [ ty ], _) when Path.same path Predef.path_option -> ty + | _ -> ty + in + Format.fprintf ppf "?%s:%a" l (pp_parameter_type env) (unwrap_option ty) + | Position l -> Format.fprintf ppf "%s:[%%call_pos]" l +;; + +(* record buffer offsets to be able to underline parameter types *) +let print_parameter_offset ?arg:argument ppf buffer env label ty = + let param_start = Buffer.length buffer in + Format.fprintf ppf "%a%!" (pp_parameter env label) ty; + let param_end = Buffer.length buffer in + Format.pp_print_string ppf " -> "; + Format.pp_print_flush ppf (); + { label; param_start; param_end; argument } +;; + +let separate_function_signature ~args (e : Typedtree.expression) = + Type_utils.Printtyp.reset (); + let buffer = Buffer.create 16 in + let ppf = Format.formatter_of_buffer buffer in + let rec separate ?(i = 0) ?(parameters = []) args ty = + match args, Types.get_desc ty with + | (_l, arg) :: args, Tarrow ((label, _, _), ty1, ty2, _) -> + let arg = + match arg with + | Typedtree.Arg (e, _sort) -> Some e + | Omitted _ -> None + in + let parameter = print_parameter_offset ppf buffer e.exp_env label ty1 ?arg in + separate args ty2 ~i:(succ i) ~parameters:(parameter :: parameters) + | [], Tarrow ((label, _, _), ty1, ty2, _) -> + let parameter = print_parameter_offset ppf buffer e.exp_env label ty1 in + separate args ty2 ~i:(succ i) ~parameters:(parameter :: parameters) + (* end of function type, print remaining type without recording offsets *) + | _ -> + Format.fprintf ppf "%a%!" (pp_type e.exp_env) ty; + { function_name = extract_ident e.exp_desc + ; function_position = `Offset e.exp_loc.loc_end.pos_cnum + ; signature = Buffer.contents buffer + ; parameters = List.rev parameters + ; active_param = None + } + in + separate args e.exp_type +;; + +let active_parameter_by_arg ~arg params = + let find_by_arg = function + | { argument = Some a; _ } when a == arg -> true + | _ -> false + in + try Some (List.index params ~f:find_by_arg) with + | Not_found -> None +;; + +let active_parameter_by_prefix ~prefix params = + let common = function + | Typedtree.Nolabel -> Some 0 + | l when String.is_prefixed ~by:"~" prefix || String.is_prefixed ~by:"?" prefix -> + Some (String.common_prefix_len (Btype.prefixed_label_name l) prefix) + | _ -> None + in + let rec find_by_prefix ?(i = 0) ?longest_len ?longest_i = function + | [] -> longest_i + | p :: ps -> + (match common p.label, longest_len with + | Some common_len, Some longest_len when common_len > longest_len -> + find_by_prefix ps ~i:(succ i) ~longest_len:common_len ~longest_i:i + | Some common_len, None -> + find_by_prefix ps ~i:(succ i) ~longest_len:common_len ~longest_i:i + | _ -> find_by_prefix ps ~i:(succ i) ?longest_len ?longest_i) + in + find_by_prefix params +;; + +let is_arrow t = + match Types.get_desc t with + | Tarrow _ -> true + | _ -> false +;; + +let application_signature ~prefix = function + (* provide signature information for applied functions *) + | (_, Browse_raw.Expression arg) + :: (_, Expression { exp_desc = Texp_apply (({ exp_type; _ } as e), args, _, _, _); _ }) + :: _ + when is_arrow exp_type -> + let result = separate_function_signature e ~args in + let active_param = active_parameter_by_arg ~arg result.parameters in + let active_param = + match active_param with + | Some _ as ap -> ap + | None -> active_parameter_by_prefix ~prefix result.parameters + in + Some { result with active_param } + (* provide signature information directly after an unapplied function-type + value *) + | (_, Expression ({ exp_type; _ } as e)) :: _ when is_arrow exp_type -> + let result = separate_function_signature e ~args:[] in + let active_param = active_parameter_by_prefix ~prefix result.parameters in + Some { result with active_param } + | _ -> None +;; + let format_doc ~markdown ~doc = `MarkupContent (if markdown @@ -23,7 +195,11 @@ let format_doc ~markdown ~doc = else { MarkupContent.value = doc; kind = MarkupKind.PlainText }) ;; -let run (state : State.t) { SignatureHelpParams.textDocument = { uri }; position; _ } = +let run + ~log_info + (state : State.t) + { SignatureHelpParams.textDocument = { uri }; position; _ } + = let open Fiber.O in let doc = let store = state.store in @@ -43,15 +219,17 @@ let run (state : State.t) { SignatureHelpParams.textDocument = { uri }; position Fiber.return help | `Merlin merlin -> let* application_signature = - let* inside_comment = Check_for_comments.position_in_comment ~position ~merlin in + let* inside_comment = + Check_for_comments.position_in_comment ~log_info ~position ~merlin + in match inside_comment with | true -> Fiber.return None | false -> - Document.Merlin.with_pipeline_exn ~name:"signature-help" merlin (fun pipeline -> + Document.Merlin.with_pipeline_exn ~log_info merlin (fun pipeline -> let typer = Mpipeline.typer_result pipeline in let pos = Mpipeline.get_lexing_pos pipeline pos in let node = Mtyper.node_at typer pos in - Merlin_analysis.Signature_help.application_signature node ~prefix ~cursor:pos) + application_signature node ~prefix) in (match application_signature with | None -> @@ -65,21 +243,19 @@ let run (state : State.t) { SignatureHelpParams.textDocument = { uri }; position let offset = String.length prefix in let+ doc = Document.Merlin.doc_comment - ~name:"signature help-position" + ~log_info merlin application_signature.function_position in let info = let parameters = - List.map - application_signature.parameters - ~f:(fun (p : Merlin_analysis.Signature_help.parameter_info) -> - let label = `Offset (offset + p.param_start, offset + p.param_end) in - ParameterInformation.create ~label ()) + List.map application_signature.parameters ~f:(fun (p : parameter_info) -> + let label = `Offset (offset + p.param_start, offset + p.param_end) in + ParameterInformation.create ~label ()) in let documentation = let open Option.O in - let+ doc in + let+ doc = doc in let markdown = ClientCapabilities.markdown_support (State.client_capabilities state) diff --git a/ocaml-lsp-server/src/signature_help.mli b/ocaml-lsp-server/src/signature_help.mli index 0f9377c27..b51c457b6 100644 --- a/ocaml-lsp-server/src/signature_help.mli +++ b/ocaml-lsp-server/src/signature_help.mli @@ -1,3 +1,7 @@ open Import -val run : State.t -> SignatureHelpParams.t -> SignatureHelp.t Fiber.t +val run + : log_info:Lsp_timing_logger.t + -> State.t + -> SignatureHelpParams.t + -> SignatureHelp.t Fiber.t diff --git a/ocaml-lsp-server/src/state.ml b/ocaml-lsp-server/src/state.ml index 4745879f3..95ad104a4 100644 --- a/ocaml-lsp-server/src/state.ml +++ b/ocaml-lsp-server/src/state.ml @@ -5,7 +5,6 @@ type init = | Initialized of { params : InitializeParams.t ; workspaces : Workspaces.t - ; dune : Dune.t ; exp_client_caps : Client.Experimental_capabilities.t ; diagnostics : Diagnostics.t ; position_encoding : [ `UTF16 | `UTF8 ] @@ -25,9 +24,17 @@ type t = ; symbols_thread : Lev_fiber.Thread.t Lazy_fiber.t ; wheel : Lev_fiber.Timer.Wheel.t ; hover_extended : hover_extended + ; mutable event_index : int } -let create ~store ~merlin ~detached ~configuration ~ocamlformat_rpc ~symbols_thread ~wheel +let create + ~store + ~merlin + ~detached + ~configuration + ~ocamlformat_rpc + ~symbols_thread + ~wheel = { init = Uninitialized ; merlin_config = Merlin_config.DB.create () @@ -40,6 +47,7 @@ let create ~store ~merlin ~detached ~configuration ~ocamlformat_rpc ~symbols_thr ; symbols_thread ; wheel ; hover_extended = { history = None } + ; event_index = 0 } ;; @@ -66,12 +74,6 @@ let workspace_root t = | Some uri -> uri) ;; -let dune t = - match t.init with - | Uninitialized -> assert false - | Initialized init -> init.dune -;; - let position_encoding t = match t.init with | Uninitialized -> assert false @@ -84,21 +86,13 @@ let diagnostics t = | Initialized init -> init.diagnostics ;; -let initialize - t - ~position_encoding - (params : InitializeParams.t) - workspaces - dune - diagnostics - = +let initialize t ~position_encoding (params : InitializeParams.t) workspaces diagnostics = assert (t.init = Uninitialized); { t with init = Initialized { params ; workspaces - ; dune ; diagnostics ; position_encoding ; exp_client_caps = @@ -130,3 +124,13 @@ let log_msg server ~type_ ~message = let log = LogMessageParams.create ~type_ ~message in Server.notification server (Server_notification.LogMessage log)) ;; + +(* extracts editor name and version *) +let get_editor (state : t) = + match state.init with + | Uninitialized -> "unknown", "unknown" + | Initialized s -> + (match s.params.clientInfo with + | None -> "unknown", "unknown" + | Some i -> InitializeParams.get_editor i) +;; diff --git a/ocaml-lsp-server/src/state.mli b/ocaml-lsp-server/src/state.mli index 0cecbe122..d10472d34 100644 --- a/ocaml-lsp-server/src/state.mli +++ b/ocaml-lsp-server/src/state.mli @@ -5,7 +5,6 @@ type init = | Initialized of { params : InitializeParams.t ; workspaces : Workspaces.t - ; dune : Dune.t ; exp_client_caps : Client.Experimental_capabilities.t ; diagnostics : Diagnostics.t ; position_encoding : [ `UTF16 | `UTF8 ] @@ -14,9 +13,8 @@ type init = (** State specific to the hoverExtended request. *) type hover_extended = { mutable history : (Uri.t * Position.t * int) option - (** File, position, and verbosity level of the last call to - hoverExtended. This value is used to pick a verbosity level when it - is not specific by the client. *) + (** File, position, and verbosity level of the last call to hoverExtended. This value is + used to pick a verbosity level when it is not specific by the client. *) } type t = @@ -31,6 +29,7 @@ type t = ; symbols_thread : Lev_fiber.Thread.t Lazy_fiber.t ; wheel : Lev_fiber.Timer.Wheel.t ; hover_extended : hover_extended + ; mutable event_index : int } val create @@ -52,13 +51,11 @@ val initialize -> position_encoding:[ `UTF16 | `UTF8 ] -> InitializeParams.t -> Workspaces.t - -> Dune.t -> Diagnostics.t -> t val workspace_root : t -> Uri.t val workspaces : t -> Workspaces.t -val dune : t -> Dune.t val modify_workspaces : t -> f:(Workspaces.t -> Workspaces.t) -> t (** @return @@ -72,3 +69,6 @@ val experimental_client_capabilities : t -> Client.Experimental_capabilities.t val diagnostics : t -> Diagnostics.t val log_msg : t Server.t -> type_:MessageType.t -> message:string -> unit Fiber.t + +(** @return (name,version) of the editor that initialized this LSP instance. *) +val get_editor : t -> string * string diff --git a/ocaml-lsp-server/src/testing.ml b/ocaml-lsp-server/src/testing.ml index cbdeb01d9..8608e2632 100644 --- a/ocaml-lsp-server/src/testing.ml +++ b/ocaml-lsp-server/src/testing.ml @@ -1,4 +1,4 @@ -(**WARNING: This is for internal use in testing only *) +(** WARNING: This is for internal use in testing only *) module Compl = Compl module Merlin_kernel = Merlin_kernel diff --git a/ocaml-lsp-server/src/typed_hole.ml b/ocaml-lsp-server/src/typed_hole.ml index f34d39f1f..e77a00d1c 100644 --- a/ocaml-lsp-server/src/typed_hole.ml +++ b/ocaml-lsp-server/src/typed_hole.ml @@ -1,47 +1,48 @@ open Import +open Core +include Merlin_analysis.Typed_hole -let in_range range holes = - match range with - | None -> holes - | Some range -> List.filter ~f:(Range.contains range) holes +let next_hole_cmd ~state ~(edit : TextEdit.t) = + let supportsJumpToNextHole = + State.experimental_client_capabilities state + |> Client.Experimental_capabilities.supportsJumpToNextHole + in + if supportsJumpToNextHole + then + Some + (Client.Custom_commands.next_hole + ~in_range:(Range.resize_for_edit edit) + ~notify_if_no_hole:false + ()) + else None ;; -let find_prev ~range ~position holes = - let holes = in_range range holes in - Base.List.fold_until - ~init:None - ~f:(fun prev hole -> - match Position.compare hole.end_ position with - | Lt -> Continue (Some hole) - | Gt | Eq -> Stop prev) - ~finish:Fun.id - holes - |> function - | None -> Base.List.last holes - | hole -> hole +let next_hole ~(holes : Range.t list) ~(cursor : Position.t) = + (* Find the first hole after the cursor, or default to the first *) + let hole = + List.find holes ~f:(fun hole -> + match Position.compare hole.start cursor with + | Lt | Eq -> false + | Gt -> true) + in + match hole with + | None -> List.hd holes + | Some _ as hole -> hole ;; -let find_next ~range ~position holes = - let holes = in_range range holes in - List.find - ~f:(fun hole -> - match Position.compare hole.start position with - | Gt -> true - | Lt | Eq -> false) - holes - |> function - | None -> Base.List.hd holes - | hole -> hole -;; - -let find ~range ~position ~direction holes = - match direction with - | `Prev -> find_prev ~range ~position holes - | `Next -> find_next ~range ~position holes -;; - -let all ?(pipeline_name = "typed-holes") merlin = - Holes - |> Document.Merlin.dispatch_exn ~name:pipeline_name merlin - |> Fiber.map ~f:(List.map ~f:(fun (loc, _ty) -> Range.of_loc loc)) +let prev_hole ~(holes : Range.t list) ~(cursor : Position.t) = + (* Find the last hole before the cursor, or default to the last *) + let hole = + List.fold_until + holes + ~init:None + ~f:(fun prev_hole hole -> + match Position.compare hole.end_ cursor with + | Lt -> Continue (Some hole) + | Gt | Eq -> Stop prev_hole) + ~finish:Fn.id + in + match hole with + | None -> List.last holes (* still only one scan, since we stopped on the first hole *) + | Some _ as hole -> hole ;; diff --git a/ocaml-lsp-server/src/typed_hole.mli b/ocaml-lsp-server/src/typed_hole.mli index eca4e3b87..d50068111 100644 --- a/ocaml-lsp-server/src/typed_hole.mli +++ b/ocaml-lsp-server/src/typed_hole.mli @@ -1,8 +1,14 @@ -val find - : range:Range.t option - -> position:Position.t - -> direction:[< `Next | `Prev ] - -> Range.t list - -> Range.t option +open! Import +include module type of Merlin_analysis.Typed_hole -val all : ?pipeline_name:string -> Document.Merlin.t -> Range.t list Fiber.t +(** Creates the command used to jump to a hole within the new text. Used by construct and + destruct-line. *) +val next_hole_cmd : state:State.t -> edit:Import.TextEdit.t -> Import.Command.t option + +(** Finds the next typed hole location after [cursor] in [holes]. Called when handling the + [jumpToHole] request. *) +val next_hole : holes:Range.t list -> cursor:Position.t -> Range.t option + +(** Finds the previous typed hole location before [cursor] in [holes]. Called when + handling the [jumpToHole] request. *) +val prev_hole : holes:Range.t list -> cursor:Position.t -> Range.t option diff --git a/ocaml-lsp-server/src/util.ml b/ocaml-lsp-server/src/util.ml new file mode 100644 index 000000000..580396620 --- /dev/null +++ b/ocaml-lsp-server/src/util.ml @@ -0,0 +1,78 @@ +open Import + +type 't req_params_spec = + { params_schema : Jsonrpc.Structured.t + ; of_jsonrpc_params : Jsonrpc.Structured.t -> 't option + } + +let of_jsonrpc_params_exn spec params = + let raise_invalid_params ?data ~message () = + Jsonrpc.Response.Error.raise + @@ Jsonrpc.Response.Error.make + ?data + ~code:Jsonrpc.Response.Error.Code.InvalidParams + ~message + () + in + match params with + | None -> raise_invalid_params ~message:"Expected params but received none" () + | Some params -> + (match spec.of_jsonrpc_params params with + | Some t -> t + | None -> + let error_json = + `Assoc + [ "params_expected", (spec.params_schema :> Json.t) + ; "params_received", (params :> Json.t) + ] + in + raise_invalid_params ~message:"Unexpected parameter format" ~data:error_json ()) +;; + +let language_id_of_fname s = + match Filename.extension s with + | ".mli" | ".eliomi" -> "ocaml.interface" + | ".ml" | ".eliom" -> "ocaml" + | ".rei" | ".re" -> "reason" + | ".mll" -> "ocaml.ocamllex" + | ".mly" -> "ocaml.menhir" + | ext -> Code_error.raise "unsupported file extension" [ "extension", String ext ] +;; + +let open_document_from_file (state : State.t) uri = + let open Fiber.O in + let filename = Uri.to_path uri in + Fiber.of_thunk (fun () -> + let text = Io.String_path.read_file filename in + let languageId = language_id_of_fname filename in + let text_document = TextDocumentItem.create ~uri ~languageId ~version:0 ~text in + let params = DidOpenTextDocumentParams.create ~textDocument:text_document in + let+ doc = + let position_encoding = State.position_encoding state in + Document.make + ~position_encoding + (State.wheel state) + state.merlin_config + state.merlin + params + in + Some doc) +;; + +let is_at_cursor position = + let (`Logical (cursor_line, cursor_col)) = Position.logical position in + let is_at_cursor ({ loc_start; loc_end; _ } : Ocaml_parsing.Location.t) = + let start_col = loc_start.pos_cnum - loc_start.pos_bol in + let end_col = loc_end.pos_cnum - loc_end.pos_bol in + let at_or_after_start = + loc_start.pos_lnum < cursor_line + || (loc_start.pos_lnum = cursor_line && start_col <= cursor_col) + in + let before_or_at_end = + loc_end.pos_lnum > cursor_line + || (loc_end.pos_lnum = cursor_line && end_col >= cursor_col) + in + at_or_after_start && before_or_at_end + in + is_at_cursor +;; diff --git a/ocaml-lsp-server/src/util.mli b/ocaml-lsp-server/src/util.mli new file mode 100644 index 000000000..1c7bea3c4 --- /dev/null +++ b/ocaml-lsp-server/src/util.mli @@ -0,0 +1,18 @@ +open Import + +type 't req_params_spec = + { params_schema : Jsonrpc.Structured.t + (** used to document the structure of the params; example: + [`Assoc [ "uri" , `String "" ]]; *) + ; of_jsonrpc_params : Jsonrpc.Structured.t -> 't option + (** parses given structured JSON if it's of the expected schema; otherwise, return + [None] *) + } + +val of_jsonrpc_params_exn + : 'req_params req_params_spec + -> Jsonrpc.Structured.t option + -> 'req_params + +val open_document_from_file : State.t -> DocumentUri.t -> Document.t option Fiber.t +val is_at_cursor : Position.t -> Loc.t -> bool diff --git a/ocaml-lsp-server/src/workspace_symbol.ml b/ocaml-lsp-server/src/workspace_symbol.ml index 60bed61de..c74c0dde9 100644 --- a/ocaml-lsp-server/src/workspace_symbol.ml +++ b/ocaml-lsp-server/src/workspace_symbol.ml @@ -71,7 +71,7 @@ end = struct open Browse_tree let id_of_patt = function - | { pat_desc = Tpat_var (id, _, _); _ } -> Some id + | { pat_desc = Tpat_var (id, _, _, _, _); _ } -> Some id | _ -> None ;; @@ -299,9 +299,9 @@ let find_cm_files dir = ;; let run - ({ query; _ } : WorkspaceSymbolParams.t) - (workspace_folders : WorkspaceFolder.t list) - (cancel : Fiber.Cancel.t option) + ({ query; _ } : WorkspaceSymbolParams.t) + (workspace_folders : WorkspaceFolder.t list) + (cancel : Fiber.Cancel.t option) = let filter = match query with @@ -375,7 +375,7 @@ let run server (state : State.t) (params : WorkspaceSymbolParams.t) = let msg = let message = List.map errors ~f:(function Build_dir_not_found workspace_name -> - workspace_name) + workspace_name) |> String.concat ~sep:", " |> sprintf "No build directory found in workspace(s): %s" in diff --git a/ocaml-lsp-server/test/dune b/ocaml-lsp-server/test/dune index 34bfff3c6..8bb167d6a 100644 --- a/ocaml-lsp-server/test/dune +++ b/ocaml-lsp-server/test/dune @@ -15,9 +15,9 @@ ;; This is because of the (implicit_transitive_deps false) ;; in dune-project base - ppx_expect ppx_expect.config ppx_expect.config_types + ppx_expect.runtime_types ppx_inline_test.config) (preprocess (pps ppx_expect))) diff --git a/ocaml-lsp-server/test/e2e-new/action_extract.ml b/ocaml-lsp-server/test/e2e-new/action_extract.ml index dcef2d2e4..394125b42 100644 --- a/ocaml-lsp-server/test/e2e-new/action_extract.ml +++ b/ocaml-lsp-server/test/e2e-new/action_extract.ml @@ -1,191 +1,231 @@ +open Async + let extract_local_test = Code_actions.code_action_test ~title:"Extract local" let extract_function_test = Code_actions.code_action_test ~title:"Extract function" let%expect_test "extract local constant" = - extract_local_test - {| + let%map () = + extract_local_test + {| let f = 0 + $1$ -|}; +|} + in [%expect {| let f = let var_name = 1 in - 0 + var_name |}] + 0 + var_name + |}] ;; let%expect_test "extract local expression" = - extract_local_test - {| + let%map () = + extract_local_test + {| let f = let x = 2 in $0 + 1 + x$ + 1 -|}; +|} + in [%expect {| let f = let x = 2 in let var_name = 0 + 1 + x in - var_name + 1 |}] + var_name + 1 + |}] ;; let%expect_test "extract function single parameter" = - extract_function_test - {| + let%map () = + extract_function_test + {| let f x = $(x * 2)$ + 3 -|}; +|} + in [%expect {| let fun_name x = (x * 2) let f x = - fun_name x + 3 |}] + fun_name x + 3 + |}] ;; let%expect_test "extract function multiple parameter" = - extract_function_test - {| + let%map () = + extract_function_test + {| let f x = let y = 0 in $(x * y)$ + 3 -|}; +|} + in [%expect {| let fun_name y x = (x * y) let f x = let y = 0 in - fun_name y x + 3 |}] + fun_name y x + 3 + |}] ;; let%expect_test "extract function with local module" = - extract_function_test - {| + let%map () = + extract_function_test + {| let f x = let module M = struct let y = 0 end in $(x * M.y)$ + 3 -|}; - [%expect {||}] +|} + in + [%expect {| |}] ;; (* TODO: This extraction shouldn't be allowed. *) let%expect_test "extract function with local exception" = - extract_function_test - {| + let%map () = + extract_function_test + {| let f x = let exception Local in $raise Local$ -|}; +|} + in [%expect {| let fun_name () = raise Local let f x = let exception Local in - fun_name () |}] + fun_name () + |}] ;; let%expect_test "extract function with shadowed parameter" = - extract_function_test - {| + let%map () = + extract_function_test + {| let x = 0 let f x = $x + 1$ -|}; +|} + in [%expect {| let x = 0 let fun_name x = x + 1 - let f x = fun_name x |}] + let f x = fun_name x + |}] ;; let%expect_test "extract function with bound variable" = - extract_function_test - {| + let%map () = + extract_function_test + {| let x = 0 let y = 1 let f x = $x + y$ -|}; +|} + in [%expect {| let x = 0 let y = 1 let fun_name x = x + y - let f x = fun_name x |}] + let f x = fun_name x + |}] ;; let%expect_test "extract higher order function" = - extract_function_test - {| + let%map () = + extract_function_test + {| let f x = $List.map (fun y -> y + 1) x$ -|}; +|} + in [%expect {| let fun_name x = List.map (fun y -> y + 1) x let f x = - fun_name x |}] + fun_name x + |}] ;; let%expect_test "extract higher order function" = - extract_function_test - {| + let%map () = + extract_function_test + {| let f y = $List.map (fun y -> y + 1) y$ -|}; +|} + in [%expect {| let fun_name y = List.map (fun y -> y + 1) y let f y = - fun_name y |}] + fun_name y + |}] ;; let%expect_test "extract higher order function" = - extract_function_test - {| + let%map () = + extract_function_test + {| let f y = $List.map (fun y -> y + 1) y$ -|}; +|} + in [%expect {| let fun_name y = List.map (fun y -> y + 1) y let f y = - fun_name y |}] + fun_name y + |}] ;; let%expect_test "extract inside let binding" = - extract_function_test - {| + let%map () = + extract_function_test + {| let f y = let y = y + 1 in $y + 2$ -|}; +|} + in [%expect {| let fun_name y = y + 2 let f y = let y = y + 1 in - fun_name y |}] + fun_name y + |}] ;; let%expect_test "extract free variable" = - extract_function_test - {| + let%map () = + extract_function_test + {| let f () = $z + 1$ -|}; +|} + in [%expect {| let fun_name () = z + 1 let f () = - fun_name () |}] + fun_name () + |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/action_inline.ml b/ocaml-lsp-server/test/e2e-new/action_inline.ml index d940d0548..2bd5fe177 100644 --- a/ocaml-lsp-server/test/e2e-new/action_inline.ml +++ b/ocaml-lsp-server/test/e2e-new/action_inline.ml @@ -1,64 +1,77 @@ +open Async + let inline_test = Code_actions.code_action_test ~title:"Inline into uses" let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $x = 0 in x + 1 -|}; +|} + in [%expect {| let _ = let x = 0 in - (0) + 1 |}] + (0) + 1 + |}] ;; let%expect_test "shadow-1" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let y = 1 in let $x = y in let y = 0 in x + 1 -|}; +|} + in [%expect {| |}] ;; let%expect_test "shadow-2" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let y = 1 in let $x y = y in let y = 0 in x y + 1 -|}; +|} + in [%expect {| let _ = let y = 1 in let x y = y in let y = 0 in - (y) + 1 |}] + (y) + 1 + |}] ;; let%expect_test "shadow-3" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let y = 1 in let $x z = y + z in let y = 0 in x y + 1 -|}; +|} + in [%expect {| |}] ;; let%expect_test "shadow-4" = - inline_test - {| + let%map.Deferred () = + inline_test + {| module M = struct let y = 1 end @@ -68,13 +81,15 @@ let _ = let y = 2 end in x -|}; +|} + in [%expect {| |}] ;; let%expect_test "shadow-5" = - inline_test - {| + let%map.Deferred () = + inline_test + {| module M = struct let y = 1 end @@ -84,7 +99,8 @@ let _ = let y = 2 end in x -|}; +|} + in [%expect {| module M = struct @@ -95,459 +111,559 @@ let _ = let module N = struct let y = 2 end in - (M.y) |}] + (M.y) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $x = 0 + 1 in (fun x -> x) x -|}; +|} + in [%expect {| let _ = let x = 0 + 1 in - (fun x -> x) (0 + 1) |}] + (fun x -> x) (0 + 1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $x = 0 + 1 in (fun ~x -> x) ~x -|}; +|} + in [%expect {| let _ = let x = 0 + 1 in - (fun ~x -> x) ~x:(0 + 1) |}] + (fun ~x -> x) ~x:(0 + 1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $x = 0 + 1 in (fun ?(x = 2) -> x) ~x -|}; +|} + in [%expect {| let _ = let x = 0 + 1 in - (fun ?(x = 2) -> x) ~x:(0 + 1) |}] + (fun ?(x = 2) -> x) ~x:(0 + 1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $x = Some 0 in (fun ?(x = 2) -> x) ?x -|}; +|} + in [%expect {| |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $x = 0 in (fun ~x -> x) ~x:(x + 1) -|}; +|} + in [%expect {| let _ = let x = 0 in - (fun ~x -> x) ~x:((0) + 1) |}] + (fun ~x -> x) ~x:((0) + 1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $x = 0 in (fun ?(x = 1) -> x) ~x:(x + 1) -|}; +|} + in [%expect {| let _ = let x = 0 in - (fun ?(x = 1) -> x) ~x:((0) + 1) |}] + (fun ?(x = 1) -> x) ~x:((0) + 1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f x = x in f 1 -|}; +|} + in [%expect {| let _ = let f x = x in - (1) |}] + (1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f _ = 0 in f 1 -|}; +|} + in [%expect {| let _ = let f _ = 0 in - (0) |}] + (0) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f x = x + x in f 1 -|}; +|} + in [%expect {| let _ = let f x = x + x in - (1 + 1) |}] + (1 + 1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f x = x + x in f (g 1) -|}; +|} + in [%expect {| let _ = let f x = x + x in - (let x = g 1 in x + x) |}] + (let x = g 1 in x + x) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f x y = x + y in f 0 -|}; +|} + in [%expect {| let _ = let f x y = x + y in - ((fun x y -> x + y) 0) |}] + ((fun x y -> x + y) 0) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f x ~y = x + y in f ~y:0 -|}; +|} + in [%expect {| let _ = let f x ~y = x + y in - ((fun x ~y -> x + y) ~y:0) |}] + ((fun x ~y -> x + y) ~y:0) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f ~x y = x + y in f ~x:0 -|}; +|} + in [%expect {| let _ = let f ~x y = x + y in - ((fun ~x y -> x + y) ~x:0) |}] + ((fun ~x y -> x + y) ~x:0) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f ~x ~y = x + y in f ~y:0 -|}; +|} + in [%expect {| let _ = let f ~x ~y = x + y in - ((fun ~x ~y -> x + y) ~y:0) |}] + ((fun ~x ~y -> x + y) ~y:0) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f (x : int) = x + 1 in f 0 -|}; +|} + in [%expect {| let _ = let f (x : int) = x + 1 in - (0 + 1) |}] + (0 + 1) + |}] ;; (* TODO: allow beta reduction with locally abstract types *) let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f (type a) (x : a) = x in f 0 -|}; +|} + in [%expect {| let _ = let f (type a) (x : a) = x in - ((fun (type a) (x : a) -> x) 0) |}] + ((fun (type a) (x : a) -> x) 0) + |}] ;; (* FIXME this test broke with the update to OCaml 5.2 *) let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f : int -> int = fun x -> x in f 0 -|}; - [%expect {| |}] +|} + in + [%expect + {| + let _ = + let f : int -> int = fun x -> x in + (0) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f = function Some x -> x | None -> 0 in f (Some 1) -|}; +|} + in [%expect {| let _ = let f = function Some x -> x | None -> 0 in - ((function | Some x -> x | None -> 0) (Some 1)) |}] + ((function | Some x -> x | None -> 0) (Some 1)) + |}] ;; (* TODO: allow beta reduction with `as` *) let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f (x as y) = y + 1 in f 1 -|}; +|} + in [%expect {| let _ = let f (x as y) = y + 1 in - (let x as y = 1 in y + 1) |}] + (let x as y = 1 in y + 1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f 1 = 2 in f 2 -|}; +|} + in [%expect {| let _ = let f 1 = 2 in - (let 1 = 2 in 2) |}] + (let 1 = 2 in 2) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f (x, y) = x + y in f (1, 2) -|}; +|} + in [%expect {| let _ = let f (x, y) = x + y in - (1 + 2) |}] + (1 + 2) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f (x, y) = x + y + y in f (1, 2 + 3) -|}; +|} + in [%expect {| let _ = let f (x, y) = x + y + y in - (let y = 2 + 3 in (1 + y) + y) |}] + (let y = 2 + 3 in (1 + y) + y) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f (x, y) = x + y + y in let z = (1, 2) in f z -|}; +|} + in [%expect {| let _ = let f (x, y) = x + y + y in let z = (1, 2) in - (let (x, y) = z in (x + y) + y) |}] + (let (x, y) = z in (x + y) + y) + |}] ;; (* TODO *) let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| type t = { x : int; y : int } let _ = let $f { x; y } = x + y in f { x = 1; y = 1 } -|}; +|} + in [%expect {| type t = { x : int; y : int } let _ = let f { x; y } = x + y in - (let { x; y } = { x = 1; y = 1 } in x + y) |}] + (let { x; y } = { x = 1; y = 1 } in x + y) + |}] ;; (* TODO: beta reduce record literals as with tuples *) let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| type t = { x : int; y : int } let _ = let $f { x; _ } = x + 1 in f { x = 1; y = 1 } -|}; +|} + in [%expect {| type t = { x : int; y : int } let _ = let f { x; _ } = x + 1 in - (let { x;_} = { x = 1; y = 1 } in x + 1) |}] + (let { x;_} = { x = 1; y = 1 } in x + 1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f x = [%test] x in f 1 -|}; +|} + in [%expect {| let _ = let f x = [%test] x in - (([%test ]) 1) |}] + (([%test ]) 1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f x = x in [%test] (f 1) -|}; +|} + in [%expect {| let _ = let f x = x in - [%test] (1) |}] + [%test] (1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f x = (* test comment *) x in f 1 -|}; +|} + in [%expect {| let _ = let f x = (* test comment *) x in - (1) |}] + (1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f x = x in (* test comment *) f 1 -|}; +|} + in [%expect {| let _ = let f x = x in - (* test comment *) (1) |}] + (* test comment *) (1) + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let $f x = x let g y = f y -|}; +|} + in [%expect {| let f x = x - let g y = (y) |}] + let g y = (y) + |}] ;; (* TODO *) let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| module M = struct let $f x = x let g y = f y end let h = M.f -|}; +|} + in [%expect {| module M = struct let f x = x let g y = (y) end - let h = M.f |}] + let h = M.f + |}] ;; let%expect_test "" = - inline_test - {| + let%map.Deferred () = + inline_test + {| let _ = let $f _ = 0 in f (print_endline "hi") -|}; +|} + in [%expect {| let _ = let f _ = 0 in - (let _ = print_endline "hi" in 0) |}] + (let _ = print_endline "hi" in 0) + |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/action_mark_remove.ml b/ocaml-lsp-server/test/e2e-new/action_mark_remove.ml index a76d71b5c..eb03f3786 100644 --- a/ocaml-lsp-server/test/e2e-new/action_mark_remove.ml +++ b/ocaml-lsp-server/test/e2e-new/action_mark_remove.ml @@ -1,14 +1,16 @@ +open Async open Test.Import let run_test ~title ~message source = let src, range = Code_actions.parse_selection source in - Option.iter - (Code_actions.apply_code_action - ~diagnostics:[ Diagnostic.create ~message:(`String message) ~range () ] - title - src - range) - ~f:print_string + let%map result = + Code_actions.apply_code_action + ~diagnostics:[ Diagnostic.create ~message:(`String message) ~range () ] + title + src + range + in + Option.iter result ~f:print_string ;; let mark_test = function @@ -31,61 +33,73 @@ let remove_test = function ;; let%expect_test "mark value in let" = - mark_test - `Value - {| + let%map () = + mark_test + `Value + {| let f = let $x$ = 1 in 0 -|}; +|} + in [%expect {| let f = let _x = 1 in - 0 |}] + 0 + |}] ;; (* todo *) let%expect_test "mark value in top level let" = - mark_test - `Value - {| + let%map () = + mark_test + `Value + {| let $f$ = let x = 1 in 0 -|}; +|} + in [%expect {| let _f = let x = 1 in - 0 |}] + 0 + |}] ;; let%expect_test "mark value in match" = - mark_test - `Value - {| + let%map () = + mark_test + `Value + {| let f = function | $x$ -> 0 -|}; +|} + in [%expect {| let f = function - | _x -> 0 |}] + | _x -> 0 + |}] ;; let%expect_test "remove value in let" = - remove_test - `Value - {| + let%map () = + remove_test + `Value + {| let f = let $x$ = 1 in 0 -|}; +|} + in [%expect {| let f = - 0 |}] + 0 + |}] ;; (* todo *) @@ -100,38 +114,45 @@ let $f$ = ;; let%expect_test "mark open" = - mark_test - `Open - {| + let%map () = + mark_test + `Open + {| $open M$ -|}; +|} + in [%expect {| open! M |}] ;; let%expect_test "mark for loop index" = - mark_test - `For_loop_index - {| + let%map () = + mark_test + `For_loop_index + {| let () = for $i$ = 0 to 10 do () done -|}; +|} + in [%expect {| let () = for _i = 0 to 10 do () - done |}] + done + |}] ;; let%expect_test "remove open" = - remove_test - `Open - {| + let%map () = + remove_test + `Open + {| open A $open B$ -|}; +|} + in [%expect {| open A |}] ;; @@ -145,97 +166,117 @@ $open! B$ ;; let%expect_test "remove type" = - remove_test - `Type - {| + let%map () = + remove_test + `Type + {| $type t = int$ type s = bool -|}; +|} + in [%expect {| type s = bool |}] ;; let%expect_test "remove module" = - remove_test - `Module - {| + let%map () = + remove_test + `Module + {| $module A = struct end$ module B = struct end -|}; +|} + in [%expect {| module B = struct end |}] ;; let%expect_test "remove case" = - remove_test - `Case - {| + let%map () = + remove_test + `Case + {| let f = function | 0 -> 0 | $0 -> 1$ -|}; +|} + in [%expect {| let f = function - | 0 -> 0 |}] + | 0 -> 0 + |}] ;; let%expect_test "remove rec flag" = - remove_test - `Rec - {| + let%map () = + remove_test + `Rec + {| let rec $f$ = 0 -|}; +|} + in [%expect {| let f = 0 |}] ;; let%expect_test "remove constructor" = - remove_test - `Constructor - {| + let%map () = + remove_test + `Constructor + {| type t = A $| B$ -|}; +|} + in [%expect {| type t = A |}] ;; let%expect_test "remove constructor" = - remove_test - `Constructor - {| + let%map () = + remove_test + `Constructor + {| type t = | A $| B$ -|}; +|} + in [%expect {| type t = - | A |}] + | A + |}] ;; let%expect_test "remove constructor" = - remove_test - `Constructor - {| + let%map () = + remove_test + `Constructor + {| type t = $| A$ | B -|}; +|} + in [%expect {| type t = - | B |}] + | B + |}] ;; let%expect_test "remove constructor" = - remove_test - `Constructor - {| + let%map () = + remove_test + `Constructor + {| type t = $A$ | B -|}; +|} + in [%expect {| type t = - | B |}] + | B + |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/call_hierarchy.ml b/ocaml-lsp-server/test/e2e-new/call_hierarchy.ml new file mode 100644 index 000000000..5d465ab10 --- /dev/null +++ b/ocaml-lsp-server/test/e2e-new/call_hierarchy.ml @@ -0,0 +1,674 @@ +open Async +open Test.Import + +let call_hierachy_prepare client position = + Client.request + client + (TextDocumentPrepareCallHierarchy + { CallHierarchyPrepareParams.position + ; textDocument = TextDocumentIdentifier.create ~uri:Helpers.uri + ; workDoneToken = None + }) +;; + +let call_hierarchy_incoming client item = + Client.request + client + (CallHierarchyIncomingCalls (CallHierarchyIncomingCallsParams.create ~item ())) +;; + +let print_selection_range + ?(indent_spaces = 0) + ?(sourrounding_lines = 1) + source + ({ start; end_ } : Range.t) + = + let lines = String.split_lines source in + List.fold_left lines ~init:(0, []) ~f:(fun (current_line, lines) line -> + let new_lines = + if start.line <= current_line && current_line <= end_.line + then ( + let make = String.make in + let line_length = String.length line in + let start_c, end_c = start.character, end_.character in + let markers = + match start.line = current_line, end_.line = current_line with + | true, false -> make start_c ' ' ^ make (line_length - start_c) '^' + | false, true -> make end_c '^' + | true, true -> make start_c ' ' ^ make (end_c - start_c) '^' + | false, false -> make line_length '^' + in + [ markers; line ]) + else if start.line - sourrounding_lines <= current_line + && current_line <= end_.line + sourrounding_lines + then [ line ] + else [] + in + current_line + 1, new_lines @ lines) + |> snd + |> List.rev + |> List.map ~f:(fun line -> String.make indent_spaces ' ' ^ line) + |> String.concat ~sep:"\n" + |> print_endline +;; + +let%expect_test "print selection range" = + let source = + {ocaml| +let main () = + let baz b = + let a = Bar.bar b in + Foo.foo a + in +baz 5 +;; +|ocaml} + |> String.trim + in + let start = Position.create ~line:1 ~character:2 in + let end_ = Position.create ~line:4 ~character:3 in + print_selection_range source (Range.create ~start ~end_); + [%expect + {| + let main () = + let baz b = + ^^^^^^^^^^^ + let a = Bar.bar b in + ^^^^^^^^^^^^^^^^^^^^^^^^ + Foo.foo a + ^^^^^^^^^^^^^ + in + ^^^ + baz 5 + |}]; + let start = Position.create ~line:2 ~character:12 in + let end_ = Position.create ~line:2 ~character:19 in + print_selection_range source (Range.create ~start ~end_); + [%expect + {| + let baz b = + let a = Bar.bar b in + ^^^^^^^ + Foo.foo a + |}]; + return () +;; + +let print_prepare ?(details = true) prepare source = + match prepare with + | None -> print_endline "no prepare response" + | Some prepare -> + List.iter prepare ~f:(fun (item : CallHierarchyItem.t) -> + if details + then ( + print_endline "Prepare Item:"; + print_endline (" Detail: " ^ Option.value item.detail ~default:""); + print_endline (" Name: " ^ item.name); + print_endline (" Uri: " ^ Uri.to_string item.uri)); + print_endline " Range:"; + print_selection_range ~indent_spaces:4 ~sourrounding_lines:0 source item.range; + print_endline " Selection Range:"; + print_selection_range + ~indent_spaces:4 + ~sourrounding_lines:0 + source + item.selectionRange) +;; + +let print_incoming incoming = + match incoming with + | None -> print_endline "no incoming response" + | Some incoming -> + List.iter incoming ~f:(fun i -> + CallHierarchyIncomingCall.yojson_of_t i + |> Yojson.Safe.pretty_to_string ~std:false + |> print_endline) +;; + +let print_cursor_position source (position : Position.t) = + let range = + Range.create + ~start:position + ~end_:{ position with character = position.character + 1 } + in + print_selection_range ~sourrounding_lines:0 source range +;; + +let call_stack_tree_req client position source = + let format_line name detail line = + name + ^ " -- " + ^ (Option.map detail ~f:(fun d -> d ^ " @ " ^ Int.to_string line) + |> Option.value ~default:"") + in + let format_incoming + { CallHierarchyIncomingCall.from = + { detail; name; range = { start = { line; _ }; _ }; _ } + ; _ + } + = + format_line name detail line + in + let rec resolve item = + let* resp = call_hierarchy_incoming client item in + match resp with + | None -> Fiber.return None + | Some items -> + let fibers = + List.map items ~f:(fun (incoming_item : CallHierarchyIncomingCall.t) -> + let+ from = resolve incoming_item.from in + match from with + | None | Some [] -> Expectree.Leaf (format_incoming incoming_item) + | Some nodes -> Expectree.Branch (format_incoming incoming_item, nodes)) + in + let+ fibers = Fiber.all fibers in + Some fibers + in + let* resp = call_hierachy_prepare client position in + print_prepare ~details:false resp source; + let ({ range = { start = { line; _ }; _ }; _ } as prepare_item) : CallHierarchyItem.t = + resp |> Option.value_exn |> List.hd + in + let+ tree = resolve prepare_item in + let tree = + Expectree.Branch + (format_line prepare_item.name prepare_item.detail line, Option.value_exn tree) + in + Expectree.to_string tree |> print_endline +;; + +let test_prepare source = + let source = String.trim source in + let test ~line ~character = + let position = Position.create ~line ~character in + print_cursor_position source position; + let req client = + let+ resp = call_hierachy_prepare client position in + print_prepare resp source + in + Helpers.test source req + in + test +;; + +let test_incoming source = + let source = source |> String.trim in + let test ~line ~character = + let position = Position.create ~line ~character in + print_cursor_position source position; + print_newline (); + let req client = call_stack_tree_req client position source in + Helpers.test source req + in + test +;; + +let%expect_test "handle prepare" = + let source = + {ocaml| +module Foo = struct + let foo a = a + 1 +end + +module Bar = struct + let bar = fun a -> Foo.foo a + 1 +end + +let main () = + let baz b = + let a = Bar.bar b in + Foo.foo a + in + baz 5 +;; +|ocaml} + in + let test = test_prepare source in + (* Variable a is not a function so we expect no response *) + let%bind () = test ~line:10 ~character:8 in + [%expect + {| + let a = Bar.bar b in + ^ + no prepare response + |}]; + (* Resolve baz as you are on the function defintion *) + let%bind () = test ~line:9 ~character:6 in + [%expect + {| + let baz b = + ^ + Prepare Item: + Detail: test.ml + Name: baz + Uri: file:///test.ml + Range: + let baz b = + ^^^ + Selection Range: + let baz b = + ^^^ + |}]; + (* Resolve Foo.foo as you are on the function defintion *) + let%bind () = test ~line:1 ~character:7 in + [%expect + {| + let foo a = a + 1 + ^ + Prepare Item: + Detail: test.ml + Name: Foo.foo + Uri: file:///test.ml + Range: + let foo a = a + 1 + ^^^ + Selection Range: + let foo a = a + 1 + ^^^ + |}]; + (* We expect to resolve the function baz defined in main *) + let%bind () = test ~line:13 ~character:2 in + [%expect + {| + baz 5 + ^ + Prepare Item: + Detail: test.ml + Name: baz + Uri: file:///test.ml + Range: + let baz b = + ^^^ + Selection Range: + let baz b = + ^^^ + |}]; + (* We expect to resolve the function foo in the Foo module *) + let%bind () = test ~line:11 ~character:9 in + [%expect + {| + Foo.foo a + ^ + Prepare Item: + Detail: test.ml + Name: Foo.foo + Uri: file:///test.ml + Range: + let foo a = a + 1 + ^^^ + Selection Range: + let foo a = a + 1 + ^^^ + |}]; + (* We Expect to resolve the function bar in the Bar module *) + let%bind () = test ~line:10 ~character:17 in + [%expect + {| + let a = Bar.bar b in + ^ + Prepare Item: + Detail: test.ml + Name: Bar.bar + Uri: file:///test.ml + Range: + let bar = fun a -> Foo.foo a + 1 + ^^^ + Selection Range: + let bar = fun a -> Foo.foo a + 1 + ^^^ + |}]; + return () +;; + +let%expect_test "incoming with modules" = + let source = + {ocaml| +module Foo = struct + module Inner_foo = struct + let foo a = a + 1 + end + let foo a = Inner_foo.foo a + 1 + let foo' = Inner_foo.foo +end + +module Bar = struct + let bar = fun a -> Foo.foo a + 1 +end + +let main () = + let baz b = + let a = Bar.bar b in + Foo.foo' a + in + baz 5 +;; + |ocaml} + in + let test = test_incoming source in + let%bind () = test ~line:2 ~character:8 in + [%expect + {| + let foo a = a + 1 + ^ + + Range: + let foo a = a + 1 + ^^^ + Selection Range: + let foo a = a + 1 + ^^^ + Foo.Inner_foo.foo -- test.ml @ 2 + ├─╴Foo.foo -- test.ml @ 4 + │ ╰─╴Bar.bar -- test.ml @ 9 + │ ╰─╴baz -- test.ml @ 13 + │ ╰─╴main -- test.ml @ 12 + ╰─╴Foo.foo' -- test.ml @ 5 + ╰─╴baz -- test.ml @ 13 + ╰─╴main -- test.ml @ 12 + |}]; + let%bind () = test ~line:5 ~character:24 in + [%expect + {| + let foo' = Inner_foo.foo + ^ + + Range: + let foo a = a + 1 + ^^^ + Selection Range: + let foo a = a + 1 + ^^^ + Foo.Inner_foo.foo -- test.ml @ 2 + ├─╴Foo.foo -- test.ml @ 4 + │ ╰─╴Bar.bar -- test.ml @ 9 + │ ╰─╴baz -- test.ml @ 13 + │ ╰─╴main -- test.ml @ 12 + ╰─╴Foo.foo' -- test.ml @ 5 + ╰─╴baz -- test.ml @ 13 + ╰─╴main -- test.ml @ 12 + |}]; + let%bind () = test ~line:5 ~character:6 in + [%expect + {| + let foo' = Inner_foo.foo + ^ + + Range: + let foo' = Inner_foo.foo + ^^^^ + Selection Range: + let foo' = Inner_foo.foo + ^^^^ + Foo.foo' -- test.ml @ 5 + ╰─╴baz -- test.ml @ 13 + ╰─╴main -- test.ml @ 12 + |}]; + let%bind () = test ~line:14 ~character:18 in + [%expect + {| + let a = Bar.bar b in + ^ + + Range: + let bar = fun a -> Foo.foo a + 1 + ^^^ + Selection Range: + let bar = fun a -> Foo.foo a + 1 + ^^^ + Bar.bar -- test.ml @ 9 + ╰─╴baz -- test.ml @ 13 + ╰─╴main -- test.ml @ 12 + |}]; + let%bind () = test ~line:15 ~character:9 in + [%expect + {| + Foo.foo' a + ^ + + Range: + let foo' = Inner_foo.foo + ^^^^ + Selection Range: + let foo' = Inner_foo.foo + ^^^^ + Foo.foo' -- test.ml @ 5 + ╰─╴baz -- test.ml @ 13 + ╰─╴main -- test.ml @ 12 + |}]; + return () +;; + +let%expect_test "incoming" = + let source = + {ocaml| +let foo1 a = a + 1;; +let foo2 a = foo1 a + 1;; +let foo3 a = foo2 a + 1;; +let foo4 a = foo3 a + 1;; +let foo2_3 a = foo2 a + foo3 a;; + |ocaml} + |> String.trim + in + let test = test_incoming source in + let%bind () = test ~line:1 ~character:14 in + [%expect + {| + let foo2 a = foo1 a + 1;; + ^ + + Range: + let foo1 a = a + 1;; + ^^^^ + Selection Range: + let foo1 a = a + 1;; + ^^^^ + foo1 -- test.ml @ 0 + ╰─╴foo2 -- test.ml @ 1 + ├─╴foo3 -- test.ml @ 2 + │ ├─╴foo4 -- test.ml @ 3 + │ ╰─╴foo2_3 -- test.ml @ 4 + ╰─╴foo2_3 -- test.ml @ 4 + |}]; + let%bind () = test ~line:0 ~character:5 in + [%expect + {| + let foo1 a = a + 1;; + ^ + + Range: + let foo1 a = a + 1;; + ^^^^ + Selection Range: + let foo1 a = a + 1;; + ^^^^ + foo1 -- test.ml @ 0 + ╰─╴foo2 -- test.ml @ 1 + ├─╴foo3 -- test.ml @ 2 + │ ├─╴foo4 -- test.ml @ 3 + │ ╰─╴foo2_3 -- test.ml @ 4 + ╰─╴foo2_3 -- test.ml @ 4 + |}]; + return () +;; + +let%expect_test "multiple calls of function in the same parent function" = + let source = + {ocaml| +let a a = + let b b = + let c c = c + 1 in + c b + c a + in + b (a + 1) +;; +|ocaml} + in + let test = test_incoming source in + let%bind () = test ~line:3 ~character:10 in + [%expect + {| + c b + c a + ^ + + Range: + let c c = c + 1 in + ^ + Selection Range: + let c c = c + 1 in + ^ + c -- test.ml @ 2 + ╰─╴b -- test.ml @ 1 + ╰─╴a -- test.ml @ 0 + |}]; + return () +;; + +let%expect_test "works with type constraints" = + let source = + {ocaml| +let f x : int = String.length x +let c : int = f "foo" + f "bar" +let g x : int = f x + c +let h x y: int * int = g x, f y +;; +|ocaml} + in + let test = test_incoming source in + let%bind () = test ~line:0 ~character:4 in + [%expect + {| + let f x : int = String.length x + ^ + + Range: + let f x : int = String.length x + ^ + Selection Range: + let f x : int = String.length x + ^ + f -- test.ml @ 0 + ├─╴c -- test.ml @ 1 + │ ╰─╴g -- test.ml @ 2 + │ ╰─╴h -- test.ml @ 3 + ├─╴g -- test.ml @ 2 + │ ╰─╴h -- test.ml @ 3 + ╰─╴h -- test.ml @ 3 + |}]; + let%bind () = test ~line:1 ~character:14 in + [%expect + {| + let c : int = f "foo" + f "bar" + ^ + + Range: + let f x : int = String.length x + ^ + Selection Range: + let f x : int = String.length x + ^ + f -- test.ml @ 0 + ├─╴c -- test.ml @ 1 + │ ╰─╴g -- test.ml @ 2 + │ ╰─╴h -- test.ml @ 3 + ├─╴g -- test.ml @ 2 + │ ╰─╴h -- test.ml @ 3 + ╰─╴h -- test.ml @ 3 + |}]; + return () +;; + +let%expect_test "aliases" = + let source = + {ocaml| +let f x = x + 1 +let g = f +let h = g +let foo = h 5 +let bar = g 7 +let baz = f 2 +;; +|ocaml} + in + let test = test_incoming source in + let%bind () = test ~line:1 ~character:8 in + [%expect + {| + let g = f + ^ + + Range: + let f x = x + 1 + ^ + Selection Range: + let f x = x + 1 + ^ + f -- test.ml @ 0 + ├─╴g -- test.ml @ 1 + │ ├─╴h -- test.ml @ 2 + │ │ ╰─╴foo -- test.ml @ 3 + │ ╰─╴bar -- test.ml @ 4 + ╰─╴baz -- test.ml @ 5 + |}]; + let%bind () = test ~line:2 ~character:4 in + [%expect + {| + let h = g + ^ + + Range: + let h = g + ^ + Selection Range: + let h = g + ^ + h -- test.ml @ 2 + ╰─╴foo -- test.ml @ 3 + |}]; + let%bind () = test ~line:4 ~character:10 in + [%expect + {| + let bar = g 7 + ^ + + Range: + let g = f + ^ + Selection Range: + let g = f + ^ + g -- test.ml @ 1 + ├─╴h -- test.ml @ 2 + │ ╰─╴foo -- test.ml @ 3 + ╰─╴bar -- test.ml @ 4 + |}]; + return () +;; + +let%expect_test "circular aliases" = + let source = + {ocaml| +let h x = g x +let g x = h x +let h = g +;; +|ocaml} + in + let test = test_incoming source in + let%bind () = test ~line:1 ~character:10 in + [%expect + {| + let g x = h x + ^ + + Range: + let h x = g x + ^ + Selection Range: + let h x = g x + ^ + h -- test.ml @ 0 + ╰─╴g -- test.ml @ 1 + ╰─╴h -- test.ml @ 2 + |}]; + return () +;; diff --git a/ocaml-lsp-server/test/e2e-new/code_actions.ml b/ocaml-lsp-server/test/e2e-new/code_actions.ml index 19bbcd3c9..9bcf1e888 100644 --- a/ocaml-lsp-server/test/e2e-new/code_actions.ml +++ b/ocaml-lsp-server/test/e2e-new/code_actions.ml @@ -1,3 +1,4 @@ +open Async open Test.Import open Lsp_helpers @@ -11,11 +12,11 @@ let iter_code_actions ?prep ?path ?(diagnostics = []) ~source range = ;; let print_code_actions - ?(prep = fun _ -> Fiber.return ()) - ?(path = "foo.ml") - ?(filter = fun _ -> true) - source - range + ?(prep = fun _ -> Fiber.return ()) + ?(path = "foo.ml") + ?(filter = fun _ -> true) + source + range = iter_code_actions ~prep ~path ~source range (function | None -> print_endline "No code actions" @@ -37,7 +38,8 @@ let print_code_actions let find_action action_name action = match action with - | `CodeAction { CodeAction.kind = Some (Other name); _ } -> name = action_name + | `CodeAction { CodeAction.kind = Some (Other name); _ } -> + Core.String.is_prefix ~prefix:action_name name | _ -> false ;; @@ -55,7 +57,7 @@ let foo = 123 let end_ = Position.create ~line:1 ~character:7 in Range.create ~start ~end_ in - print_code_actions source range; + let%map.Deferred () = print_code_actions source range in [%expect {| Code actions: @@ -80,18 +82,7 @@ let foo = 123 "kind": "type-annotate", "title": "Type-annotate" } - { - "command": { - "arguments": [ "file:///foo.mli" ], - "command": "ocamllsp/open-related-source", - "title": "Create foo.mli" - }, - "edit": { - "documentChanges": [ { "kind": "create", "uri": "file:///foo.mli" } ] - }, - "kind": "switch", - "title": "Create foo.mli" - } |}] + |}] ;; let%expect_test "can type-annotate a function argument" = @@ -106,7 +97,7 @@ let f x = Foo x let end_ = Position.create ~line:2 ~character:7 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_annotate_action; + let%map.Deferred () = print_code_actions source range ~filter:find_annotate_action in [%expect {| Code actions: @@ -130,7 +121,8 @@ let f x = Foo x "isPreferred": false, "kind": "type-annotate", "title": "Type-annotate" - } |}] + } + |}] ;; let%expect_test "can type-annotate a toplevel value" = @@ -144,7 +136,7 @@ let iiii = 3 + 4 let end_ = Position.create ~line:1 ~character:5 in Range.create ~start ~end_ in - print_code_actions source range; + let%map.Deferred () = print_code_actions source range in [%expect {| Code actions: @@ -169,19 +161,7 @@ let iiii = 3 + 4 "kind": "type-annotate", "title": "Type-annotate" } - { - "command": { - "arguments": [ "file:///foo.mli" ], - "command": "ocamllsp/open-related-source", - "title": "Create foo.mli" - }, - "edit": { - "documentChanges": [ { "kind": "create", "uri": "file:///foo.mli" } ] - }, - "kind": "switch", - "title": "Create foo.mli" - } - |}] + |}] ;; let%expect_test "does not type-annotate function" = @@ -195,7 +175,7 @@ let my_fun x y = 1 let end_ = Position.create ~line:1 ~character:6 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_annotate_action; + let%map.Deferred () = print_code_actions source range ~filter:find_annotate_action in [%expect {| No code actions |}] ;; @@ -213,7 +193,7 @@ let () = let end_ = Position.create ~line:1 ~character:8 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_annotate_action; + let%map.Deferred () = print_code_actions source range ~filter:find_annotate_action in [%expect {| Code actions: @@ -237,7 +217,8 @@ let () = "isPreferred": false, "kind": "type-annotate", "title": "Type-annotate" - } |}] + } + |}] ;; let%expect_test "can type-annotate a variant with its name only" = @@ -253,7 +234,7 @@ let f (x : t) = x let end_ = Position.create ~line:3 ~character:17 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_annotate_action; + let%map.Deferred () = print_code_actions source range ~filter:find_annotate_action in [%expect {| Code actions: @@ -277,7 +258,8 @@ let f (x : t) = x "isPreferred": false, "kind": "type-annotate", "title": "Type-annotate" - } |}] + } + |}] ;; let%expect_test "does not type-annotate in a non expression context" = @@ -293,7 +275,7 @@ type x = let end_ = Position.create ~line:3 ~character:6 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_annotate_action; + let%map.Deferred () = print_code_actions source range ~filter:find_annotate_action in [%expect {| No code actions |}] ;; @@ -308,7 +290,7 @@ let f (x : int) = 1 let end_ = Position.create ~line:1 ~character:8 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_annotate_action; + let%map.Deferred () = print_code_actions source range ~filter:find_annotate_action in [%expect {| No code actions |}] ;; @@ -323,7 +305,7 @@ let f x = (1 : int) let end_ = Position.create ~line:1 ~character:12 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_annotate_action; + let%map.Deferred () = print_code_actions source range ~filter:find_annotate_action in [%expect {| No code actions |}] ;; @@ -338,7 +320,7 @@ let f x = (1 : int :> int) let end_ = Position.create ~line:1 ~character:12 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_annotate_action; + let%map.Deferred () = print_code_actions source range ~filter:find_annotate_action in [%expect {| No code actions |}] ;; @@ -354,7 +336,9 @@ let f (x : t) = Foo x let end_ = Position.create ~line:2 ~character:8 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_remove_annotation_action; + let%map.Deferred () = + print_code_actions source range ~filter:find_remove_annotation_action + in [%expect {| Code actions: @@ -378,7 +362,8 @@ let f (x : t) = Foo x "isPreferred": false, "kind": "remove type annotation", "title": "Remove type annotation" - } |}] + } + |}] ;; let%expect_test "can remove type annotation from a toplevel value" = @@ -392,7 +377,9 @@ let (iiii : int) = 3 + 4 let end_ = Position.create ~line:1 ~character:6 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_remove_annotation_action; + let%map.Deferred () = + print_code_actions source range ~filter:find_remove_annotation_action + in [%expect {| Code actions: @@ -416,7 +403,8 @@ let (iiii : int) = 3 + 4 "isPreferred": false, "kind": "remove type annotation", "title": "Remove type annotation" - } |}] + } + |}] ;; let%expect_test "can remove type annotation from an argument in a function call" = @@ -433,7 +421,9 @@ let f (x : int) = x + 1 let end_ = Position.create ~line:1 ~character:8 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_remove_annotation_action; + let%map.Deferred () = + print_code_actions source range ~filter:find_remove_annotation_action + in [%expect {| Code actions: @@ -457,7 +447,8 @@ let f (x : int) = x + 1 "isPreferred": false, "kind": "remove type annotation", "title": "Remove type annotation" - } |}] + } + |}] ;; let%expect_test "can remove type annotation from a coerced expression" = @@ -471,7 +462,9 @@ let x = (7 : int :> int) let end_ = Position.create ~line:1 ~character:10 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_remove_annotation_action; + let%map.Deferred () = + print_code_actions source range ~filter:find_remove_annotation_action + in [%expect {| Code actions: @@ -495,7 +488,8 @@ let x = (7 : int :> int) "isPreferred": false, "kind": "remove type annotation", "title": "Remove type annotation" - } |}] + } + |}] ;; let%expect_test "does not remove type annotation from function" = @@ -509,7 +503,9 @@ let my_fun x y : int = 1 let end_ = Position.create ~line:1 ~character:6 in Range.create ~start ~end_ in - print_code_actions source range ~filter:find_remove_annotation_action; + let%map.Deferred () = + print_code_actions source range ~filter:find_remove_annotation_action + in [%expect {| No code actions |}] ;; @@ -525,7 +521,9 @@ let f (x : t) = x let end_ = Position.create ~line:2 ~character:17 in Range.create ~start ~end_ in - print_code_actions source range ~filter:(find_action "destruct (enumerate cases)"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct (enumerate cases)") + in [%expect {| Code actions: @@ -565,10 +563,9 @@ let f (x:bool) = let end_ = Position.create ~line:2 ~character:5 in Range.create ~start ~end_ in - print_code_actions - source - range - ~filter:(find_action "destruct-line (enumerate cases, use existing match)"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") + in [%expect {| Code actions: @@ -607,10 +604,9 @@ let%expect_test "can destruct match-with line" = let end_ = Position.create ~line:1 ~character:0 in Range.create ~start ~end_ in - print_code_actions - source - range - ~filter:(find_action "destruct-line (enumerate cases, use existing match)"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") + in [%expect {| Code actions: @@ -638,6 +634,89 @@ let%expect_test "can destruct match-with line" = |}] ;; +let%expect_test "can destruct match-with line with parentheses" = + let source = + {ocaml| + (match 0 with) +|ocaml} + in + let range = + let start = Position.create ~line:1 ~character:0 in + let end_ = Position.create ~line:1 ~character:0 in + Range.create ~start ~end_ + in + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") + in + [%expect + {| + Code actions: + { + "edit": { + "documentChanges": [ + { + "edits": [ + { + "newText": "match 0 with\n | 0 -> _\n | _ -> _", + "range": { + "end": { "character": 17, "line": 1 }, + "start": { "character": 5, "line": 1 } + } + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } + } + ] + }, + "isPreferred": false, + "kind": "destruct-line (enumerate cases, use existing match)", + "title": "Destruct-line (enumerate cases, use existing match)" + } + |}] +;; + +let%expect_test "can destruct match line with let =" = + let source = + {ocaml| + let x = (match (Ok 0) + ) +|ocaml} + in + let range = + let start = Position.create ~line:1 ~character:0 in + let end_ = Position.create ~line:1 ~character:0 in + Range.create ~start ~end_ + in + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") + in + [%expect + {| + Code actions: + { + "edit": { + "documentChanges": [ + { + "edits": [ + { + "newText": "match Ok 0 with\n | Ok _ -> _\n | Error _ -> _", + "range": { + "end": { "character": 25, "line": 1 }, + "start": { "character": 13, "line": 1 } + } + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } + } + ] + }, + "isPreferred": false, + "kind": "destruct-line (enumerate cases, use existing match)", + "title": "Destruct-line (enumerate cases, use existing match)" + } + |}] +;; + let%expect_test "can destruct case line" = let source = {ocaml| @@ -656,10 +735,9 @@ let f (x: q) = let end_ = Position.create ~line:8 ~character:0 in Range.create ~start ~end_ in - print_code_actions - source - range - ~filter:(find_action "destruct-line (enumerate cases, use existing match)"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") + in [%expect {| Code actions: @@ -700,10 +778,9 @@ let zip (type a b) (xs : a list) (ys : b list) : (a * b) list = let end_ = Position.create ~line:3 ~character:5 in Range.create ~start ~end_ in - print_code_actions - source - range - ~filter:(find_action "destruct-line (enumerate cases, use existing match)"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") + in [%expect {| Code actions: @@ -749,10 +826,9 @@ let f (x: q) = let end_ = Position.create ~line:8 ~character:5 in Range.create ~start ~end_ in - print_code_actions - source - range - ~filter:(find_action "destruct-line (enumerate cases, use existing match)"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") + in [%expect {| Code actions: @@ -798,10 +874,9 @@ let f (x: q) = let end_ = Position.create ~line:8 ~character:2 in Range.create ~start ~end_ in - print_code_actions - source - range - ~filter:(find_action "destruct-line (enumerate cases, use existing match)"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") + in [%expect {| Code actions: @@ -846,35 +921,34 @@ let f (x: t) = let end_ = Position.create ~line:7 ~character:7 in Range.create ~start ~end_ in - print_code_actions - source - range - ~filter:(find_action "destruct-line (enumerate cases, use existing match)"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") + in [%expect {| - Code actions: - { - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "match x with\n | Very_long_name_for_for_the_first_case_so_that_merlin_will_use_multiple_lines -> _\n | Almost_as_long_name_for_for_the_second_case -> _\n | Another_long_name_for_for_the_third_case -> _", - "range": { - "end": { "character": 14, "line": 7 }, - "start": { "character": 2, "line": 7 } - } + Code actions: + { + "edit": { + "documentChanges": [ + { + "edits": [ + { + "newText": "match x with\n | Very_long_name_for_for_the_first_case_so_that_merlin_will_use_multiple_lines -> _\n | Almost_as_long_name_for_for_the_second_case -> _\n | Another_long_name_for_for_the_third_case -> _", + "range": { + "end": { "character": 14, "line": 7 }, + "start": { "character": 2, "line": 7 } } - ], - "textDocument": { "uri": "file:///foo.ml", "version": 0 } - } - ] - }, - "isPreferred": false, - "kind": "destruct-line (enumerate cases, use existing match)", - "title": "Destruct-line (enumerate cases, use existing match)" - } - |}] + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } + } + ] + }, + "isPreferred": false, + "kind": "destruct-line (enumerate cases, use existing match)", + "title": "Destruct-line (enumerate cases, use existing match)" + } + |}] ;; let%expect_test "destruct strips parentheses even on long lines" = @@ -896,52 +970,9 @@ let f (x: q) = let end_ = Position.create ~line:9 ~character:22 in Range.create ~start ~end_ in - print_code_actions - source - range - ~filter:(find_action "destruct-line (enumerate cases, use existing match)"); - [%expect - {| - Code actions: - { - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "\n | Very_long_name_for_for_the_first_case_so_that_merlin_will_be_forced_to_use_multiple_lines -> _\n | Another_long_name_for_for_the_third_case -> _\n | Very_long_name_for_for_the_last_case_so_that_we_can_make_sure_we_handle_both_parens_and_line_breaks\n _ -> _", - "range": { - "end": { "character": 52, "line": 9 }, - "start": { "character": 52, "line": 9 } - } - } - ], - "textDocument": { "uri": "file:///foo.ml", "version": 0 } - } - ] - }, - "isPreferred": false, - "kind": "destruct-line (enumerate cases, use existing match)", - "title": "Destruct-line (enumerate cases, use existing match)" - } - |}] -;; - -let%expect_test "can destruct on sub-expression" = - let source = - {ocaml| -let defered_peek x = if x >= 0 then Some (`Foo x) else None -let job_reader = 10 - -let _ = defered_peek job_reader -|ocaml} - in - let range = - let start = Position.create ~line:4 ~character:8 in - let end_ = Position.create ~line:4 ~character:31 in - Range.create ~start ~end_ + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") in - print_code_actions source range ~filter:(find_action "destruct (enumerate cases)"); [%expect {| Code actions: @@ -951,10 +982,10 @@ let _ = defered_peek job_reader { "edits": [ { - "newText": "match defered_peek job_reader with | None -> _ | Some _ -> _", + "newText": "\n | Very_long_name_for_for_the_first_case_so_that_merlin_will_be_forced_to_use_multiple_lines -> _\n | Another_long_name_for_for_the_third_case -> _\n | Very_long_name_for_for_the_last_case_so_that_we_can_make_sure_we_handle_both_parens_and_line_breaks _ -> _", "range": { - "end": { "character": 31, "line": 4 }, - "start": { "character": 8, "line": 4 } + "end": { "character": 52, "line": 9 }, + "start": { "character": 52, "line": 9 } } } ], @@ -963,27 +994,32 @@ let _ = defered_peek job_reader ] }, "isPreferred": false, - "kind": "destruct (enumerate cases)", - "title": "Destruct (enumerate cases)" + "kind": "destruct-line (enumerate cases, use existing match)", + "title": "Destruct-line (enumerate cases, use existing match)" } |}] ;; -let%expect_test "can destruct on sub-expression that need parenthesis" = +let%expect_test "destruct-line preserves necessary parentheses" = let source = {ocaml| -let defered_peek x = if x >= 0 then Some (`Foo x) else None -let job_reader = 10 +type _t = + | A of int * int + | B of string +;; -let _ = defered_peek job_reader +let f (x:_t) = + match x with |ocaml} in let range = - let start = Position.create ~line:4 ~character:21 in - let end_ = Position.create ~line:4 ~character:31 in + let start = Position.create ~line:7 ~character:2 in + let end_ = Position.create ~line:7 ~character:2 in Range.create ~start ~end_ in - print_code_actions source range ~filter:(find_action "destruct (enumerate cases)"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "destruct-line") + in [%expect {| Code actions: @@ -993,10 +1029,10 @@ let _ = defered_peek job_reader { "edits": [ { - "newText": "(match job_reader with | 0 -> _ | _ -> _)", + "newText": "match x with\n | A (_, _) -> _\n | B _ -> _", "range": { - "end": { "character": 31, "line": 4 }, - "start": { "character": 21, "line": 4 } + "end": { "character": 14, "line": 7 }, + "start": { "character": 2, "line": 7 } } } ], @@ -1005,8 +1041,8 @@ let _ = defered_peek job_reader ] }, "isPreferred": false, - "kind": "destruct (enumerate cases)", - "title": "Destruct (enumerate cases)" + "kind": "destruct-line (enumerate cases, use existing match)", + "title": "Destruct-line (enumerate cases, use existing match)" } |}] ;; @@ -1026,12 +1062,14 @@ let f (x : t) = x let end_ = Position.create ~line:0 ~character:0 in Range.create ~start ~end_ in - print_code_actions - intf_source - range - ~prep - ~path:"foo.mli" - ~filter:(find_action "inferred_intf"); + let%map.Deferred () = + print_code_actions + intf_source + range + ~prep + ~path:"foo.mli" + ~filter:(find_action "inferred_intf") + in [%expect {| Code actions: @@ -1041,7 +1079,7 @@ let f (x : t) = x { "edits": [ { - "newText": "type t = Foo of int | Bar of bool\n\nval f : t -> t\n", + "newText": "type t = Foo of int | Bar of bool\nval f : t -> t\n", "range": { "end": { "character": 0, "line": 0 }, "start": { "character": 0, "line": 0 } @@ -1055,7 +1093,8 @@ let f (x : t) = x "isPreferred": false, "kind": "inferred_intf", "title": "Insert inferred interface" - } |}] + } + |}] ;; let%expect_test "inferred interface excludes existing names" = @@ -1077,12 +1116,14 @@ val f : t -> t let end_ = Position.create ~line:0 ~character:0 in Range.create ~start ~end_ in - print_code_actions - intf_source - range - ~prep - ~path:"foo.mli" - ~filter:(find_action "inferred_intf"); + let%map.Deferred () = + print_code_actions + intf_source + range + ~prep + ~path:"foo.mli" + ~filter:(find_action "inferred_intf") + in [%expect {| Code actions: @@ -1133,12 +1174,14 @@ val f : t -> bool let end_ = Position.create ~line:2 ~character:0 in Range.create ~start ~end_ in - print_code_actions - intf_source - range - ~prep - ~path:"foo.mli" - ~filter:(find_action "update_intf"); + let%map.Deferred () = + print_code_actions + intf_source + range + ~prep + ~path:"foo.mli" + ~filter:(find_action "update_intf") + in [%expect {| Code actions: @@ -1185,37 +1228,39 @@ val f : int -> string -> 'a list -> bool -> bool let end_ = Position.create ~line:1 ~character:10 in Range.create ~start ~end_ in - print_code_actions - intf_source - range - ~prep - ~path:"foo.mli" - ~filter:(find_action "update_intf"); + let%map.Deferred () = + print_code_actions + intf_source + range + ~prep + ~path:"foo.mli" + ~filter:(find_action "update_intf") + in [%expect {| - Code actions: - { - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "val f : int -> string -> bool -> bool\n", - "range": { - "end": { "character": 48, "line": 1 }, - "start": { "character": 0, "line": 1 } + Code actions: + { + "edit": { + "documentChanges": [ + { + "edits": [ + { + "newText": "val f : int -> string -> bool -> bool\n", + "range": { + "end": { "character": 48, "line": 1 }, + "start": { "character": 0, "line": 1 } + } } - } - ], - "textDocument": { "uri": "file:///foo.mli", "version": 0 } - } - ] - }, - "isPreferred": false, - "kind": "update_intf", - "title": "Update signature(s) to match implementation" - } - |}] + ], + "textDocument": { "uri": "file:///foo.mli", "version": 0 } + } + ] + }, + "isPreferred": false, + "kind": "update_intf", + "title": "Update signature(s) to match implementation" + } + |}] ;; let%expect_test "update-signatures updates parameter types" = @@ -1237,12 +1282,14 @@ val f : int -> string -> 'a list -> bool -> bool let end_ = Position.create ~line:1 ~character:12 in Range.create ~start ~end_ in - print_code_actions - intf_source - range - ~prep - ~path:"foo.mli" - ~filter:(find_action "update_intf"); + let%map.Deferred () = + print_code_actions + intf_source + range + ~prep + ~path:"foo.mli" + ~filter:(find_action "update_intf") + in [%expect {| Code actions: @@ -1301,12 +1348,14 @@ val h : int -> bool let end_ = Position.create ~line:10 ~character:19 in Range.create ~start ~end_ in - print_code_actions - intf_source - range - ~prep - ~path:"foo.mli" - ~filter:(find_action "update_intf"); + let%map.Deferred () = + print_code_actions + intf_source + range + ~prep + ~path:"foo.mli" + ~filter:(find_action "update_intf") + in [%expect {| Code actions: @@ -1369,12 +1418,14 @@ module M : sig type t = I of int | B of bool end let end_ = Position.create ~line:1 ~character:0 in Range.create ~start ~end_ in - print_code_actions - intf_source - range - ~prep - ~path:"foo.mli" - ~filter:(find_action "update_intf"); + let%map.Deferred () = + print_code_actions + intf_source + range + ~prep + ~path:"foo.mli" + ~filter:(find_action "update_intf") + in [%expect {| Code actions: @@ -1402,363 +1453,260 @@ module M : sig type t = I of int | B of bool end |}] ;; -let activate_jump client = - let config = - DidChangeConfigurationParams.create - ~settings:(`Assoc [ "merlinJumpCodeActions", `Assoc [ "enable", `Bool true ] ]) - in - change_config ~client config -;; - -let%expect_test "can jump to match target" = +let%expect_test "can combine cases with multiple RHSes" = let source = {ocaml| -type t = Foo of int | Bar of bool -let square x = x * x -let f (x : t) (d : bool) = - match x with - |Bar x -> x - |Foo _ -> d + match card with + | Ace -> _ + | King -> _ + | Queen -> "Face card!" + | Jack -> "Face card?" + | Number _ -> _ |ocaml} in let range = - let start = Position.create ~line:5 ~character:5 in - let end_ = Position.create ~line:5 ~character:5 in + let start = Position.create ~line:3 ~character:3 in + let end_ = Position.create ~line:6 ~character:6 in Range.create ~start ~end_ in - print_code_actions - ~prep:activate_jump - source - range - ~filter:(find_action "merlin-jump-match"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "combine-cases") + in [%expect {| Code actions: { - "command": { - "arguments": [ - "file:///foo.ml", + "edit": { + "documentChanges": [ { - "end": { "character": 2, "line": 4 }, - "start": { "character": 2, "line": 4 } + "edits": [ + { + "newText": " | King | Queen | Jack | Number _ -> _\n", + "range": { + "end": { "character": 0, "line": 7 }, + "start": { "character": 0, "line": 3 } + } + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } } - ], - "command": "ocamllsp/merlin-jump-to-target", - "title": "Match jump" + ] }, - "kind": "merlin-jump-match", - "title": "Match jump" + "isPreferred": false, + "kind": "combine-cases", + "title": "Combine-cases" } - - |}] + |}] ;; -let%expect_test "can jump to match-next-case target" = +let%expect_test "can combine cases with one unique RHS" = let source = {ocaml| -type t = Foo of int | Bar of bool -let square x = x * x -let f (x : t) (d : bool) = - match x with - |Bar x -> x - |Foo _ -> d + match card with + | Ace -> _ + | King -> _ + | Queen -> "Face card!" + | Jack -> "Face card?" + | Number _ -> _ |ocaml} in let range = - let start = Position.create ~line:5 ~character:5 in - let end_ = Position.create ~line:5 ~character:5 in + let start = Position.create ~line:3 ~character:3 in + let end_ = Position.create ~line:4 ~character:4 in Range.create ~start ~end_ in - print_code_actions - ~prep:activate_jump - source - range - ~filter:(find_action "merlin-jump-next-case"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "combine-cases") + in [%expect {| Code actions: { - "command": { - "arguments": [ - "file:///foo.ml", + "edit": { + "documentChanges": [ { - "end": { "character": 3, "line": 6 }, - "start": { "character": 3, "line": 6 } + "edits": [ + { + "newText": " | King | Queen -> \"Face card!\"\n", + "range": { + "end": { "character": 0, "line": 5 }, + "start": { "character": 0, "line": 3 } + } + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } } - ], - "command": "ocamllsp/merlin-jump-to-target", - "title": "Next-case jump" + ] }, - "kind": "merlin-jump-next-case", - "title": "Next-case jump" - } |}] + "isPreferred": false, + "kind": "combine-cases", + "title": "Combine-cases" + } + |}] ;; -let%expect_test "can jump to match-prev-case target" = +let%expect_test "can construct" = let source = {ocaml| -type t = Foo of int | Bar of bool -let square x = x * x -let f (x : t) (d : bool) = - match x with - |Bar x -> x - |Foo _ -> d +let rec zip_shortest (xs : 'a list) (ys : 'b list) : ('a * 'b) list = + match (xs, ys) with + | ([], _) | (_, []) -> [] + | (x::xs, y::ys) -> _ +;; |ocaml} in let range = - let start = Position.create ~line:5 ~character:5 in - let end_ = Position.create ~line:5 ~character:5 in + let start = Position.create ~line:4 ~character:23 in + let end_ = Position.create ~line:4 ~character:23 in Range.create ~start ~end_ in - print_code_actions - ~prep:activate_jump - source - range - ~filter:(find_action "merlin-jump-prev-case"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "construct") + in [%expect {| Code actions: { - "command": { - "arguments": [ - "file:///foo.ml", + "edit": { + "documentChanges": [ { - "end": { "character": 3, "line": 5 }, - "start": { "character": 3, "line": 5 } + "edits": [ + { + "newText": "[]", + "range": { + "end": { "character": 23, "line": 4 }, + "start": { "character": 22, "line": 4 } + } + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } } - ], - "command": "ocamllsp/merlin-jump-to-target", - "title": "Prev-case jump" + ] }, - "kind": "merlin-jump-prev-case", - "title": "Prev-case jump" - } |}] -;; - -let%expect_test "can jump to let target" = - let source = - {ocaml| -type t = Foo of int | Bar of bool -let square x = x * x -let f (x : t) (d : bool) = - match x with - |Bar x -> x - |Foo _ -> d -|ocaml} - in - let range = - let start = Position.create ~line:5 ~character:5 in - let end_ = Position.create ~line:5 ~character:5 in - Range.create ~start ~end_ - in - print_code_actions - ~prep:activate_jump - source - range - ~filter:(find_action "merlin-jump-let"); - [%expect - {| - Code actions: + "isPreferred": false, + "kind": "construct", + "title": "Construct: []" + } { - "command": { - "arguments": [ - "file:///foo.ml", + "edit": { + "documentChanges": [ { - "end": { "character": 0, "line": 3 }, - "start": { "character": 0, "line": 3 } + "edits": [ + { + "newText": "(_ :: _)", + "range": { + "end": { "character": 23, "line": 4 }, + "start": { "character": 22, "line": 4 } + } + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } } - ], - "command": "ocamllsp/merlin-jump-to-target", - "title": "Let jump" + ] }, - "kind": "merlin-jump-let", - "title": "Let jump" - } |}] -;; - -let%expect_test "can jump to fun target" = - let source = - {ocaml| -type t = Foo of int | Bar of bool -let square x = x * x -let f (x : t) (d : bool) = - match x with - |Bar x -> x - |Foo _ -> d -|ocaml} - in - let range = - let start = Position.create ~line:5 ~character:5 in - let end_ = Position.create ~line:5 ~character:5 in - Range.create ~start ~end_ - in - print_code_actions - ~prep:activate_jump - source - range - ~filter:(find_action "merlin-jump-fun"); - [%expect - {| - Code actions: + "isPreferred": false, + "kind": "construct", + "title": "Construct: (_ :: _)" + } { - "command": { - "arguments": [ - "file:///foo.ml", + "edit": { + "documentChanges": [ { - "end": { "character": 0, "line": 3 }, - "start": { "character": 0, "line": 3 } + "edits": [ + { + "newText": "(zip_shortest _ _)", + "range": { + "end": { "character": 23, "line": 4 }, + "start": { "character": 22, "line": 4 } + } + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } } - ], - "command": "ocamllsp/merlin-jump-to-target", - "title": "Fun jump" + ] }, - "kind": "merlin-jump-fun", - "title": "Fun jump" - } |}] + "isPreferred": false, + "kind": "construct", + "title": "Construct: (zip_shortest _ _)" + } + |}] ;; -let%expect_test "can jump to module target" = +(* NOTE: This test is currently demonstrating a bug with Merlin-construct. + It should be updated to remove [x] from the options once that bug is fixed. *) +let%expect_test "can construct with local variables" = let source = {ocaml| -module FooBar = struct - type t = Foo of int | Bar of bool -end -let f (x : t) (d : bool) = - match x with - |Bar x -> x - |Foo _ -> d +let rec zip_shortest (xs : 'a list) (ys : 'b list) : ('a * 'b) list = + match (xs, ys) with + | ([], _) | (_, []) -> [] + | (x::xs, y::ys) -> ((x, y) :: (zip_shortest _ _)) +;; |ocaml} in let range = - let start = Position.create ~line:2 ~character:5 in - let end_ = Position.create ~line:2 ~character:5 in + let start = Position.create ~line:4 ~character:50 in + let end_ = Position.create ~line:4 ~character:50 in Range.create ~start ~end_ in - print_code_actions - ~prep:activate_jump - source - range - ~filter:(find_action "merlin-jump-module"); + let%map.Deferred () = + print_code_actions source range ~filter:(find_action "construct") + in [%expect {| Code actions: { - "command": { - "arguments": [ - "file:///foo.ml", + "edit": { + "documentChanges": [ + { + "edits": [ + { + "newText": "[]", + "range": { + "end": { "character": 50, "line": 4 }, + "start": { "character": 49, "line": 4 } + } + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } + } + ] + }, + "isPreferred": false, + "kind": "construct", + "title": "Construct: []" + } + { + "edit": { + "documentChanges": [ { - "end": { "character": 0, "line": 1 }, - "start": { "character": 0, "line": 1 } + "edits": [ + { + "newText": "(_ :: _)", + "range": { + "end": { "character": 50, "line": 4 }, + "start": { "character": 49, "line": 4 } + } + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } } - ], - "command": "ocamllsp/merlin-jump-to-target", - "title": "Module jump" + ] }, - "kind": "merlin-jump-module", - "title": "Module jump" - } |}] -;; - -let%expect_test "can jump to module-type target" = - let source = - {ocaml| - module type ORDER = sig - type t - val leq : t -> t -> bool - val equal : t -> t -> bool - end - - let f (x : t) (d : bool) = - match x with - |Bar x -> x - |Foo _ -> d - |ocaml} - in - let range = - let start = Position.create ~line:4 ~character:5 in - let end_ = Position.create ~line:4 ~character:5 in - Range.create ~start ~end_ - in - print_code_actions - ~prep:activate_jump - source - range - ~filter:(find_action "merlin-jump-module-type"); - [%expect - {| - Code actions: - { - "command": { - "arguments": [ - "file:///foo.ml", - { - "end": { "character": 2, "line": 1 }, - "start": { "character": 2, "line": 1 } - } - ], - "command": "ocamllsp/merlin-jump-to-target", - "title": "Module-type jump" - }, - "kind": "merlin-jump-module-type", - "title": "Module-type jump" - } |}] -;; - -let%expect_test "shouldn't find the jump target on the same line" = - let source = - {ocaml| - let square x = x * x - let f (x : t) (d : bool) = - match x with - |Bar x -> x - |Foo _ -> d - |ocaml} - in - let range = - let start = Position.create ~line:0 ~character:5 in - let end_ = Position.create ~line:0 ~character:5 in - Range.create ~start ~end_ - in - print_code_actions - ~prep:activate_jump - source - range - ~filter:(find_action "merlin-jump-fun"); - [%expect - {| - No code actions |}] -;; - -let%expect_test "can combine cases with multiple RHSes" = - let source = - {ocaml| - match card with - | Ace -> _ - | King -> _ - | Queen -> "Face card!" - | Jack -> "Face card?" - | Number _ -> _ -|ocaml} - in - let range = - let start = Position.create ~line:3 ~character:3 in - let end_ = Position.create ~line:6 ~character:6 in - Range.create ~start ~end_ - in - print_code_actions source range ~filter:(find_action "combine-cases"); - [%expect - {| - Code actions: + "isPreferred": false, + "kind": "construct", + "title": "Construct: (_ :: _)" + } { "edit": { "documentChanges": [ { "edits": [ { - "newText": " | King | Queen | Jack | Number _ -> _\n", + "newText": "x", "range": { - "end": { "character": 0, "line": 7 }, - "start": { "character": 0, "line": 3 } + "end": { "character": 50, "line": 4 }, + "start": { "character": 49, "line": 4 } } } ], @@ -1767,42 +1715,19 @@ let%expect_test "can combine cases with multiple RHSes" = ] }, "isPreferred": false, - "kind": "combine-cases", - "title": "Combine-cases" + "kind": "construct", + "title": "Construct: x" } - |}] -;; - -let%expect_test "can combine cases with one unique RHS" = - let source = - {ocaml| - match card with - | Ace -> _ - | King -> _ - | Queen -> "Face card!" - | Jack -> "Face card?" - | Number _ -> _ -|ocaml} - in - let range = - let start = Position.create ~line:3 ~character:3 in - let end_ = Position.create ~line:4 ~character:4 in - Range.create ~start ~end_ - in - print_code_actions source range ~filter:(find_action "combine-cases"); - [%expect - {| - Code actions: { "edit": { "documentChanges": [ { "edits": [ { - "newText": " | King | Queen -> \"Face card!\"\n", + "newText": "xs", "range": { - "end": { "character": 0, "line": 5 }, - "start": { "character": 0, "line": 3 } + "end": { "character": 50, "line": 4 }, + "start": { "character": 49, "line": 4 } } } ], @@ -1811,8 +1736,29 @@ let%expect_test "can combine cases with one unique RHS" = ] }, "isPreferred": false, - "kind": "combine-cases", - "title": "Combine-cases" + "kind": "construct", + "title": "Construct: xs" + } + { + "edit": { + "documentChanges": [ + { + "edits": [ + { + "newText": "ys", + "range": { + "end": { "character": 50, "line": 4 }, + "start": { "character": 49, "line": 4 } + } + } + ], + "textDocument": { "uri": "file:///foo.ml", "version": 0 } + } + ] + }, + "isPreferred": false, + "kind": "construct", + "title": "Construct: ys" } |}] ;; @@ -1859,7 +1805,9 @@ let apply_code_action ?diagnostics title source range = let open Option.O in (* collect code action results *) let code_actions = ref None in - iter_code_actions ?diagnostics ~source range (fun ca -> code_actions := Some ca); + let%map () = + iter_code_actions ?diagnostics ~source range (fun ca -> code_actions := Some ca) + in let* m_code_actions = !code_actions in let* code_actions = m_code_actions in let* edit = @@ -1880,5 +1828,6 @@ let apply_code_action ?diagnostics title source range = let code_action_test ~title source = let src, range = parse_selection source in - Option.iter (apply_code_action title src range) ~f:print_string + let%map result = apply_code_action title src range in + Option.iter result ~f:print_string ;; diff --git a/ocaml-lsp-server/test/e2e-new/code_actions.mli b/ocaml-lsp-server/test/e2e-new/code_actions.mli index b22a4ed5f..b408d6f4f 100644 --- a/ocaml-lsp-server/test/e2e-new/code_actions.mli +++ b/ocaml-lsp-server/test/e2e-new/code_actions.mli @@ -1,3 +1,4 @@ +open Async open Test.Import val iter_code_actions @@ -7,7 +8,7 @@ val iter_code_actions -> source:string -> Range.t -> (CodeActionResult.t -> unit) - -> unit + -> unit Deferred.t val parse_selection : string -> string * Range.t @@ -16,8 +17,8 @@ val apply_code_action -> string -> string -> Range.t - -> string option + -> string option Deferred.t -(** [code_action_test title source] runs the code action with title [title] and - prints the resulting source. *) -val code_action_test : title:string -> string -> unit +(** [code_action_test title source] runs the code action with title [title] and prints the + resulting source. *) +val code_action_test : title:string -> string -> unit Deferred.t diff --git a/ocaml-lsp-server/test/e2e-new/completion.ml b/ocaml-lsp-server/test/e2e-new/completion.ml index 5f2f874b3..03afac921 100644 --- a/ocaml-lsp-server/test/e2e-new/completion.ml +++ b/ocaml-lsp-server/test/e2e-new/completion.ml @@ -1,11 +1,12 @@ +open Async open Test.Import let iter_completions - ?prep - ?path - ?(triggerCharacter = "") - ?(triggerKind = CompletionTriggerKind.Invoked) - ~position + ?prep + ?path + ?(triggerCharacter = "") + ?(triggerKind = CompletionTriggerKind.Invoked) + ~position = let makeRequest textDocument = let context = CompletionContext.create ~triggerCharacter ~triggerKind () in @@ -16,12 +17,12 @@ let iter_completions ;; let print_completions - ?(prep = fun _ -> Fiber.return ()) - ?(path = "foo.ml") - ?(limit = 10) - ?(pre_print = fun x -> x) - source - position + ?(prep = fun _ -> Fiber.return ()) + ?(path = "foo.ml") + ?(limit = 10) + ?(pre_print = fun x -> x) + source + position = iter_completions ~prep ~path ~source ~position (function | None -> print_endline "No completion Items" @@ -51,77 +52,79 @@ let print_completions let%expect_test "can start completion at arbitrary position (before the dot)" = let source = {ocaml|Strin.func|ocaml} in let position = Position.create ~line:0 ~character:5 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "", - "kind": 9, - "label": "String", - "sortText": "0000", - "textEdit": { - "newText": "String", - "range": { - "end": { "character": 5, "line": 0 }, - "start": { "character": 0, "line": 0 } - } - } - } - { - "detail": "", - "kind": 9, - "label": "StringLabels", - "sortText": "0001", - "textEdit": { - "newText": "StringLabels", - "range": { - "end": { "character": 5, "line": 0 }, - "start": { "character": 0, "line": 0 } - } - } - } |}] + Completions: + { + "detail": "", + "kind": 9, + "label": "String", + "sortText": "0000", + "textEdit": { + "newText": "String", + "range": { + "end": { "character": 5, "line": 0 }, + "start": { "character": 0, "line": 0 } + } + } + } + { + "detail": "", + "kind": 9, + "label": "StringLabels", + "sortText": "0001", + "textEdit": { + "newText": "StringLabels", + "range": { + "end": { "character": 5, "line": 0 }, + "start": { "character": 0, "line": 0 } + } + } + } + |}] ;; let%expect_test "can start completion at arbitrary position" = let source = {ocaml|StringLabels|ocaml} in let position = Position.create ~line:0 ~character:6 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "", - "kind": 9, - "label": "String", - "sortText": "0000", - "textEdit": { - "newText": "String", - "range": { - "end": { "character": 6, "line": 0 }, - "start": { "character": 0, "line": 0 } - } - } - } - { - "detail": "", - "kind": 9, - "label": "StringLabels", - "sortText": "0001", - "textEdit": { - "newText": "StringLabels", - "range": { - "end": { "character": 6, "line": 0 }, - "start": { "character": 0, "line": 0 } - } - } - } |}] + Completions: + { + "detail": "", + "kind": 9, + "label": "String", + "sortText": "0000", + "textEdit": { + "newText": "String", + "range": { + "end": { "character": 6, "line": 0 }, + "start": { "character": 0, "line": 0 } + } + } + } + { + "detail": "", + "kind": 9, + "label": "StringLabels", + "sortText": "0001", + "textEdit": { + "newText": "StringLabels", + "range": { + "end": { "character": 6, "line": 0 }, + "start": { "character": 0, "line": 0 } + } + } + } + |}] ;; let%expect_test "can start completion at arbitrary position 2" = let source = {ocaml|StringLabels|ocaml} in let position = Position.create ~line:0 ~character:7 in - print_completions source position; + let%map () = print_completions source position in [%expect {| Completions: @@ -137,153 +140,155 @@ let%expect_test "can start completion at arbitrary position 2" = "start": { "character": 0, "line": 0 } } } - } |}] + } + |}] ;; let%expect_test "can start completion after operator without space" = let source = {ocaml|[1;2]|>List.ma|ocaml} in let position = Position.create ~line:0 ~character:14 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "('a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "map", - "sortText": "0000", - "textEdit": { - "newText": "map", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 12, "line": 0 } - } - } - } - { - "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "mapi", - "sortText": "0001", - "textEdit": { - "newText": "mapi", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 12, "line": 0 } - } - } - } - { - "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", - "kind": 12, - "label": "map2", - "sortText": "0002", - "textEdit": { - "newText": "map2", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 12, "line": 0 } - } - } - } |}] + Completions: + { + "detail": "('a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "map", + "sortText": "0000", + "textEdit": { + "newText": "map", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 12, "line": 0 } + } + } + } + { + "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "mapi", + "sortText": "0001", + "textEdit": { + "newText": "mapi", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 12, "line": 0 } + } + } + } + { + "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", + "kind": 12, + "label": "map2", + "sortText": "0002", + "textEdit": { + "newText": "map2", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 12, "line": 0 } + } + } + } + |}] ;; let%expect_test "can start completion after operator with space" = let source = {ocaml|[1;2] |> List.ma|ocaml} in let position = Position.create ~line:0 ~character:16 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "('a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "map", - "sortText": "0000", - "textEdit": { - "newText": "map", - "range": { - "end": { "character": 16, "line": 0 }, - "start": { "character": 14, "line": 0 } - } - } - } - { - "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "mapi", - "sortText": "0001", - "textEdit": { - "newText": "mapi", - "range": { - "end": { "character": 16, "line": 0 }, - "start": { "character": 14, "line": 0 } - } - } - } - { - "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", - "kind": 12, - "label": "map2", - "sortText": "0002", - "textEdit": { - "newText": "map2", - "range": { - "end": { "character": 16, "line": 0 }, - "start": { "character": 14, "line": 0 } - } - } - } - |}] + Completions: + { + "detail": "('a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "map", + "sortText": "0000", + "textEdit": { + "newText": "map", + "range": { + "end": { "character": 16, "line": 0 }, + "start": { "character": 14, "line": 0 } + } + } + } + { + "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "mapi", + "sortText": "0001", + "textEdit": { + "newText": "mapi", + "range": { + "end": { "character": 16, "line": 0 }, + "start": { "character": 14, "line": 0 } + } + } + } + { + "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", + "kind": 12, + "label": "map2", + "sortText": "0002", + "textEdit": { + "newText": "map2", + "range": { + "end": { "character": 16, "line": 0 }, + "start": { "character": 14, "line": 0 } + } + } + } + |}] ;; let%expect_test "can start completion in dot chain with tab" = let source = {ocaml|[1;2] |> List. ma|ocaml} in let position = Position.create ~line:0 ~character:17 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "('a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "map", - "sortText": "0000", - "textEdit": { - "newText": "map", - "range": { - "end": { "character": 17, "line": 0 }, - "start": { "character": 15, "line": 0 } - } - } - } - { - "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "mapi", - "sortText": "0001", - "textEdit": { - "newText": "mapi", - "range": { - "end": { "character": 17, "line": 0 }, - "start": { "character": 15, "line": 0 } - } - } - } - { - "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", - "kind": 12, - "label": "map2", - "sortText": "0002", - "textEdit": { - "newText": "map2", - "range": { - "end": { "character": 17, "line": 0 }, - "start": { "character": 15, "line": 0 } - } - } - } - |}] + Completions: + { + "detail": "('a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "map", + "sortText": "0000", + "textEdit": { + "newText": "map", + "range": { + "end": { "character": 17, "line": 0 }, + "start": { "character": 15, "line": 0 } + } + } + } + { + "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "mapi", + "sortText": "0001", + "textEdit": { + "newText": "mapi", + "range": { + "end": { "character": 17, "line": 0 }, + "start": { "character": 15, "line": 0 } + } + } + } + { + "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", + "kind": 12, + "label": "map2", + "sortText": "0002", + "textEdit": { + "newText": "map2", + "range": { + "end": { "character": 17, "line": 0 }, + "start": { "character": 15, "line": 0 } + } + } + } + |}] ;; let%expect_test "can start completion in dot chain with newline" = @@ -292,99 +297,99 @@ let%expect_test "can start completion in dot chain with newline" = ma|ocaml} in let position = Position.create ~line:1 ~character:2 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "('a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "map", - "sortText": "0000", - "textEdit": { - "newText": "map", - "range": { - "end": { "character": 2, "line": 1 }, - "start": { "character": 0, "line": 1 } - } - } - } - { - "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "mapi", - "sortText": "0001", - "textEdit": { - "newText": "mapi", - "range": { - "end": { "character": 2, "line": 1 }, - "start": { "character": 0, "line": 1 } - } - } - } - { - "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", - "kind": 12, - "label": "map2", - "sortText": "0002", - "textEdit": { - "newText": "map2", - "range": { - "end": { "character": 2, "line": 1 }, - "start": { "character": 0, "line": 1 } - } - } - } - |}] + Completions: + { + "detail": "('a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "map", + "sortText": "0000", + "textEdit": { + "newText": "map", + "range": { + "end": { "character": 2, "line": 1 }, + "start": { "character": 0, "line": 1 } + } + } + } + { + "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "mapi", + "sortText": "0001", + "textEdit": { + "newText": "mapi", + "range": { + "end": { "character": 2, "line": 1 }, + "start": { "character": 0, "line": 1 } + } + } + } + { + "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", + "kind": 12, + "label": "map2", + "sortText": "0002", + "textEdit": { + "newText": "map2", + "range": { + "end": { "character": 2, "line": 1 }, + "start": { "character": 0, "line": 1 } + } + } + } + |}] ;; let%expect_test "can start completion in dot chain with space" = let source = {ocaml|[1;2] |> List. ma|ocaml} in let position = Position.create ~line:0 ~character:17 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "('a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "map", - "sortText": "0000", - "textEdit": { - "newText": "map", - "range": { - "end": { "character": 17, "line": 0 }, - "start": { "character": 15, "line": 0 } - } - } - } - { - "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "mapi", - "sortText": "0001", - "textEdit": { - "newText": "mapi", - "range": { - "end": { "character": 17, "line": 0 }, - "start": { "character": 15, "line": 0 } - } - } - } - { - "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", - "kind": 12, - "label": "map2", - "sortText": "0002", - "textEdit": { - "newText": "map2", - "range": { - "end": { "character": 17, "line": 0 }, - "start": { "character": 15, "line": 0 } - } - } - } - |}] + Completions: + { + "detail": "('a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "map", + "sortText": "0000", + "textEdit": { + "newText": "map", + "range": { + "end": { "character": 17, "line": 0 }, + "start": { "character": 15, "line": 0 } + } + } + } + { + "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "mapi", + "sortText": "0001", + "textEdit": { + "newText": "mapi", + "range": { + "end": { "character": 17, "line": 0 }, + "start": { "character": 15, "line": 0 } + } + } + } + { + "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", + "kind": 12, + "label": "map2", + "sortText": "0002", + "textEdit": { + "newText": "map2", + "range": { + "end": { "character": 17, "line": 0 }, + "start": { "character": 15, "line": 0 } + } + } + } + |}] ;; let%expect_test "can start completion after dereference" = @@ -393,24 +398,24 @@ let%expect_test "can start completion after dereference" = !ap|ocaml} in let position = Position.create ~line:1 ~character:3 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "int ref", - "kind": 12, - "label": "apple", - "sortText": "0000", - "textEdit": { - "newText": "apple", - "range": { - "end": { "character": 3, "line": 1 }, - "start": { "character": 1, "line": 1 } - } - } - } - |}] + Completions: + { + "detail": "int ref", + "kind": 12, + "label": "apple", + "sortText": "0000", + "textEdit": { + "newText": "apple", + "range": { + "end": { "character": 3, "line": 1 }, + "start": { "character": 1, "line": 1 } + } + } + } + |}] ;; let%expect_test "can complete symbol passed as a named argument" = @@ -419,24 +424,37 @@ let%expect_test "can complete symbol passed as a named argument" = g ~f:ig|ocaml} in let position = Position.create ~line:1 ~character:7 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "'a -> unit", - "kind": 12, - "label": "ignore", - "sortText": "0000", - "textEdit": { - "newText": "ignore", - "range": { - "end": { "character": 7, "line": 1 }, - "start": { "character": 5, "line": 1 } - } - } - } - |}] + Completions: + { + "detail": "'a -> unit", + "kind": 12, + "label": "ignore", + "sortText": "0000", + "textEdit": { + "newText": "ignore", + "range": { + "end": { "character": 7, "line": 1 }, + "start": { "character": 5, "line": 1 } + } + } + } + { + "detail": "'a @ local once contended -> unit", + "kind": 12, + "label": "ignore_contended", + "sortText": "0001", + "textEdit": { + "newText": "ignore_contended", + "range": { + "end": { "character": 7, "line": 1 }, + "start": { "character": 5, "line": 1 } + } + } + } + |}] ;; let%expect_test "can complete symbol passed as a named argument - 2" = @@ -446,24 +464,24 @@ let g ~f = f 0 in g ~f:M.ig|ocaml} in let position = Position.create ~line:2 ~character:9 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "'a -> unit", - "kind": 12, - "label": "igfoo", - "sortText": "0000", - "textEdit": { - "newText": "igfoo", - "range": { - "end": { "character": 9, "line": 2 }, - "start": { "character": 7, "line": 2 } - } - } - } - |}] + Completions: + { + "detail": "'a -> unit", + "kind": 12, + "label": "igfoo", + "sortText": "0000", + "textEdit": { + "newText": "igfoo", + "range": { + "end": { "character": 9, "line": 2 }, + "start": { "character": 7, "line": 2 } + } + } + } + |}] ;; let%expect_test "can complete symbol passed as an optional argument" = @@ -474,24 +492,37 @@ g ?f:ig |ocaml} in let position = Position.create ~line:2 ~character:7 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "'a -> unit", - "kind": 12, - "label": "ignore", - "sortText": "0000", - "textEdit": { - "newText": "ignore", - "range": { - "end": { "character": 7, "line": 2 }, - "start": { "character": 5, "line": 2 } - } - } - } - |}] + Completions: + { + "detail": "'a -> unit", + "kind": 12, + "label": "ignore", + "sortText": "0000", + "textEdit": { + "newText": "ignore", + "range": { + "end": { "character": 7, "line": 2 }, + "start": { "character": 5, "line": 2 } + } + } + } + { + "detail": "'a @ local once contended -> unit", + "kind": 12, + "label": "ignore_contended", + "sortText": "0001", + "textEdit": { + "newText": "ignore_contended", + "range": { + "end": { "character": 7, "line": 2 }, + "start": { "character": 5, "line": 2 } + } + } + } + |}] ;; let%expect_test "can complete symbol passed as an optional argument - 2" = @@ -501,24 +532,24 @@ let g ?f = f in g ?f:M.ig|ocaml} in let position = Position.create ~line:2 ~character:9 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "'a -> unit", - "kind": 12, - "label": "igfoo", - "sortText": "0000", - "textEdit": { - "newText": "igfoo", - "range": { - "end": { "character": 9, "line": 2 }, - "start": { "character": 7, "line": 2 } - } - } - } - |}] + Completions: + { + "detail": "'a -> unit", + "kind": 12, + "label": "igfoo", + "sortText": "0000", + "textEdit": { + "newText": "igfoo", + "range": { + "end": { "character": 9, "line": 2 }, + "start": { "character": 7, "line": 2 } + } + } + } + |}] ;; let%expect_test "completes identifier after completion-triggering character" = @@ -533,37 +564,37 @@ let x = Test. |ocaml} in let position = Position.create ~line:6 ~character:13 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "int", - "kind": 12, - "label": "somenum", - "sortText": "0000", - "textEdit": { - "newText": "somenum", - "range": { - "end": { "character": 13, "line": 6 }, - "start": { "character": 13, "line": 6 } - } - } - } - { - "detail": "string", - "kind": 12, - "label": "somestring", - "sortText": "0001", - "textEdit": { - "newText": "somestring", - "range": { - "end": { "character": 13, "line": 6 }, - "start": { "character": 13, "line": 6 } - } - } - } - |}] + Completions: + { + "detail": "int", + "kind": 12, + "label": "somenum", + "sortText": "0000", + "textEdit": { + "newText": "somenum", + "range": { + "end": { "character": 13, "line": 6 }, + "start": { "character": 13, "line": 6 } + } + } + } + { + "detail": "string", + "kind": 12, + "label": "somestring", + "sortText": "0001", + "textEdit": { + "newText": "somestring", + "range": { + "end": { "character": 13, "line": 6 }, + "start": { "character": 13, "line": 6 } + } + } + } + |}] ;; let%expect_test "completes infix operators" = @@ -574,50 +605,50 @@ let y = 1 > |ocaml} in let position = Position.create ~line:2 ~character:11 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "int -> int -> int", - "kind": 12, - "label": ">>|", - "sortText": "0000", - "textEdit": { - "newText": ">>|", - "range": { - "end": { "character": 11, "line": 2 }, - "start": { "character": 10, "line": 2 } - } - } - } - { - "detail": "'a -> 'a -> bool", - "kind": 12, - "label": ">", - "sortText": "0001", - "textEdit": { - "newText": ">", - "range": { - "end": { "character": 11, "line": 2 }, - "start": { "character": 10, "line": 2 } - } - } - } - { - "detail": "'a -> 'a -> bool", - "kind": 12, - "label": ">=", - "sortText": "0002", - "textEdit": { - "newText": ">=", - "range": { - "end": { "character": 11, "line": 2 }, - "start": { "character": 10, "line": 2 } - } - } - } - |}] + Completions: + { + "detail": "int -> int -> int", + "kind": 12, + "label": ">>|", + "sortText": "0000", + "textEdit": { + "newText": ">>|", + "range": { + "end": { "character": 11, "line": 2 }, + "start": { "character": 10, "line": 2 } + } + } + } + { + "detail": "'a -> 'a -> bool", + "kind": 12, + "label": ">", + "sortText": "0001", + "textEdit": { + "newText": ">", + "range": { + "end": { "character": 11, "line": 2 }, + "start": { "character": 10, "line": 2 } + } + } + } + { + "detail": "'a -> 'a -> bool", + "kind": 12, + "label": ">=", + "sortText": "0002", + "textEdit": { + "newText": ">=", + "range": { + "end": { "character": 11, "line": 2 }, + "start": { "character": 10, "line": 2 } + } + } + } + |}] ;; let%expect_test "completes without prefix" = @@ -631,112 +662,112 @@ let plus_42 (x:int) (y:int) = |ocaml} in let position = Position.create ~line:5 ~character:12 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "int -> int -> int", - "kind": 12, - "label": "+", - "sortText": "0000", - "textEdit": { - "newText": "+", - "range": { - "end": { "character": 12, "line": 5 }, - "start": { "character": 11, "line": 5 } - } - } - } - { - "detail": "float -> float -> float", - "kind": 12, - "label": "+.", - "sortText": "0001", - "textEdit": { - "newText": "+.", - "range": { - "end": { "character": 12, "line": 5 }, - "start": { "character": 11, "line": 5 } - } - } - } - |}] + Completions: + { + "detail": "int -> int -> int", + "kind": 12, + "label": "+", + "sortText": "0000", + "textEdit": { + "newText": "+", + "range": { + "end": { "character": 12, "line": 5 }, + "start": { "character": 11, "line": 5 } + } + } + } + { + "detail": "float -> float -> float", + "kind": 12, + "label": "+.", + "sortText": "0001", + "textEdit": { + "newText": "+.", + "range": { + "end": { "character": 12, "line": 5 }, + "start": { "character": 11, "line": 5 } + } + } + } + |}] ;; let%expect_test "completes labels" = let source = {ocaml|let f = ListLabels.map ~|ocaml} in let position = Position.create ~line:0 ~character:24 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "int -> int", - "kind": 12, - "label": "~+", - "sortText": "0000", - "textEdit": { - "newText": "~+", - "range": { - "end": { "character": 24, "line": 0 }, - "start": { "character": 23, "line": 0 } - } - } - } - { - "detail": "float -> float", - "kind": 12, - "label": "~+.", - "sortText": "0001", - "textEdit": { - "newText": "~+.", - "range": { - "end": { "character": 24, "line": 0 }, - "start": { "character": 23, "line": 0 } - } - } - } - { - "detail": "int -> int", - "kind": 12, - "label": "~-", - "sortText": "0002", - "textEdit": { - "newText": "~-", - "range": { - "end": { "character": 24, "line": 0 }, - "start": { "character": 23, "line": 0 } - } - } - } - { - "detail": "float -> float", - "kind": 12, - "label": "~-.", - "sortText": "0003", - "textEdit": { - "newText": "~-.", - "range": { - "end": { "character": 24, "line": 0 }, - "start": { "character": 23, "line": 0 } - } - } - } - { - "detail": "'a -> 'b", - "kind": 5, - "label": "~f", - "sortText": "0004", - "textEdit": { - "newText": "~f", - "range": { - "end": { "character": 24, "line": 0 }, - "start": { "character": 23, "line": 0 } - } - } - } - |}] + Completions: + { + "detail": "int -> int", + "kind": 12, + "label": "~+", + "sortText": "0000", + "textEdit": { + "newText": "~+", + "range": { + "end": { "character": 24, "line": 0 }, + "start": { "character": 23, "line": 0 } + } + } + } + { + "detail": "float -> float", + "kind": 12, + "label": "~+.", + "sortText": "0001", + "textEdit": { + "newText": "~+.", + "range": { + "end": { "character": 24, "line": 0 }, + "start": { "character": 23, "line": 0 } + } + } + } + { + "detail": "int -> int", + "kind": 12, + "label": "~-", + "sortText": "0002", + "textEdit": { + "newText": "~-", + "range": { + "end": { "character": 24, "line": 0 }, + "start": { "character": 23, "line": 0 } + } + } + } + { + "detail": "float -> float", + "kind": 12, + "label": "~-.", + "sortText": "0003", + "textEdit": { + "newText": "~-.", + "range": { + "end": { "character": 24, "line": 0 }, + "start": { "character": 23, "line": 0 } + } + } + } + { + "detail": "'a -> 'b", + "kind": 5, + "label": "~f", + "sortText": "0004", + "textEdit": { + "newText": "~f", + "range": { + "end": { "character": 24, "line": 0 }, + "start": { "character": 23, "line": 0 } + } + } + } + |}] ;; let%expect_test "works for polymorphic variants - function application context - 1" = @@ -748,24 +779,24 @@ let u = f `Str |ocaml} in let position = Position.create ~line:3 ~character:14 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "`String", - "kind": 20, - "label": "`String", - "sortText": "0000", - "textEdit": { - "newText": "`String", - "range": { - "end": { "character": 14, "line": 3 }, - "start": { "character": 10, "line": 3 } - } - } - } - |}] + Completions: + { + "detail": "`String", + "kind": 20, + "label": "`String", + "sortText": "0000", + "textEdit": { + "newText": "`String", + "range": { + "end": { "character": 14, "line": 3 }, + "start": { "character": 10, "line": 3 } + } + } + } + |}] ;; let%expect_test "works for polymorphic variants - function application context - 2" = @@ -777,24 +808,24 @@ let u = f `In |ocaml} in let position = Position.create ~line:3 ~character:13 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "`Int of int", - "kind": 20, - "label": "`Int", - "sortText": "0000", - "textEdit": { - "newText": "`Int", - "range": { - "end": { "character": 13, "line": 3 }, - "start": { "character": 10, "line": 3 } - } - } - } - |}] + Completions: + { + "detail": "`Int of int", + "kind": 20, + "label": "`Int", + "sortText": "0000", + "textEdit": { + "newText": "`Int", + "range": { + "end": { "character": 13, "line": 3 }, + "start": { "character": 10, "line": 3 } + } + } + } + |}] ;; let%expect_test "works for polymorphic variants" = @@ -806,24 +837,24 @@ let x : t = `I |ocaml} in let position = Position.create ~line:3 ~character:15 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "`Int", - "kind": 20, - "label": "`Int", - "sortText": "0000", - "textEdit": { - "newText": "`Int", - "range": { - "end": { "character": 15, "line": 3 }, - "start": { "character": 13, "line": 3 } - } - } - } - |}] + Completions: + { + "detail": "`Int", + "kind": 20, + "label": "`Int", + "sortText": "0000", + "textEdit": { + "newText": "`Int", + "range": { + "end": { "character": 15, "line": 3 }, + "start": { "character": 13, "line": 3 } + } + } + } + |}] ;; let%expect_test "completion for holes" = @@ -833,24 +864,24 @@ let%expect_test "completion for holes" = List.filter ~f:(fun (item : CompletionItem.t) -> not (String.starts_with ~prefix:"__" item.label)) in - print_completions ~pre_print:filter source position; + let%map () = print_completions ~pre_print:filter source position in [%expect {| - Completions: - { - "filterText": "_0", - "kind": 1, - "label": "0", - "sortText": "0000", - "textEdit": { - "newText": "0", - "range": { - "end": { "character": 15, "line": 0 }, - "start": { "character": 14, "line": 0 } - } - } - } - |}] + Completions: + { + "filterText": "_0", + "kind": 1, + "label": "0", + "sortText": "0000", + "textEdit": { + "newText": "0", + "range": { + "end": { "character": 15, "line": 0 }, + "start": { "character": 14, "line": 0 } + } + } + } + |}] ;; let%expect_test "completes identifier at top level" = @@ -864,225 +895,226 @@ let () = |ocaml} in let position = Position.create ~line:5 ~character:6 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "int", - "kind": 12, - "label": "somenum", - "sortText": "0000", - "textEdit": { - "newText": "somenum", - "range": { - "end": { "character": 6, "line": 5 }, - "start": { "character": 2, "line": 5 } - } - } - } - { - "detail": "string", - "kind": 12, - "label": "somestring", - "sortText": "0001", - "textEdit": { - "newText": "somestring", - "range": { - "end": { "character": 6, "line": 5 }, - "start": { "character": 2, "line": 5 } - } - } - } - |}] + Completions: + { + "detail": "int", + "kind": 12, + "label": "somenum", + "sortText": "0000", + "textEdit": { + "newText": "somenum", + "range": { + "end": { "character": 6, "line": 5 }, + "start": { "character": 2, "line": 5 } + } + } + } + { + "detail": "string", + "kind": 12, + "label": "somestring", + "sortText": "0001", + "textEdit": { + "newText": "somestring", + "range": { + "end": { "character": 6, "line": 5 }, + "start": { "character": 2, "line": 5 } + } + } + } + |}] ;; let%expect_test "completes from a module" = let source = {ocaml|let f = List.m|ocaml} in let position = Position.create ~line:0 ~character:14 in - print_completions source position; + let%map () = print_completions source position in [%expect {| - Completions: - { - "detail": "('a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "map", - "sortText": "0000", - "textEdit": { - "newText": "map", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 13, "line": 0 } - } - } - } - { - "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", - "kind": 12, - "label": "map2", - "sortText": "0001", - "textEdit": { - "newText": "map2", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 13, "line": 0 } - } - } - } - { - "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", - "kind": 12, - "label": "mapi", - "sortText": "0002", - "textEdit": { - "newText": "mapi", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 13, "line": 0 } - } - } - } - { - "detail": "'a -> 'a list -> bool", - "kind": 12, - "label": "mem", - "sortText": "0003", - "textEdit": { - "newText": "mem", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 13, "line": 0 } - } - } - } - { - "detail": "'a -> ('a * 'b) list -> bool", - "kind": 12, - "label": "mem_assoc", - "sortText": "0004", - "textEdit": { - "newText": "mem_assoc", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 13, "line": 0 } - } - } - } - { - "detail": "'a -> ('a * 'b) list -> bool", - "kind": 12, - "label": "mem_assq", - "sortText": "0005", - "textEdit": { - "newText": "mem_assq", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 13, "line": 0 } - } - } - } - { - "detail": "'a -> 'a list -> bool", - "kind": 12, - "label": "memq", - "sortText": "0006", - "textEdit": { - "newText": "memq", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 13, "line": 0 } - } - } - } - { - "detail": "('a -> 'a -> int) -> 'a list -> 'a list -> 'a list", - "kind": 12, - "label": "merge", - "sortText": "0007", - "textEdit": { - "newText": "merge", - "range": { - "end": { "character": 14, "line": 0 }, - "start": { "character": 13, "line": 0 } - } - } - }|}] + Completions: + { + "detail": "('a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "map", + "sortText": "0000", + "textEdit": { + "newText": "map", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 13, "line": 0 } + } + } + } + { + "detail": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", + "kind": 12, + "label": "map2", + "sortText": "0001", + "textEdit": { + "newText": "map2", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 13, "line": 0 } + } + } + } + { + "detail": "(int -> 'a -> 'b) -> 'a list -> 'b list", + "kind": 12, + "label": "mapi", + "sortText": "0002", + "textEdit": { + "newText": "mapi", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 13, "line": 0 } + } + } + } + { + "detail": "'a -> 'a list -> bool", + "kind": 12, + "label": "mem", + "sortText": "0003", + "textEdit": { + "newText": "mem", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 13, "line": 0 } + } + } + } + { + "detail": "'a -> ('a * 'b) list -> bool", + "kind": 12, + "label": "mem_assoc", + "sortText": "0004", + "textEdit": { + "newText": "mem_assoc", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 13, "line": 0 } + } + } + } + { + "detail": "'a -> ('a * 'b) list -> bool", + "kind": 12, + "label": "mem_assq", + "sortText": "0005", + "textEdit": { + "newText": "mem_assq", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 13, "line": 0 } + } + } + } + { + "detail": "'a -> 'a list -> bool", + "kind": 12, + "label": "memq", + "sortText": "0006", + "textEdit": { + "newText": "memq", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 13, "line": 0 } + } + } + } + { + "detail": "('a -> 'a -> int) -> 'a list -> 'a list -> 'a list", + "kind": 12, + "label": "merge", + "sortText": "0007", + "textEdit": { + "newText": "merge", + "range": { + "end": { "character": 14, "line": 0 }, + "start": { "character": 13, "line": 0 } + } + } + } + |}] ;; let%expect_test "completes a module name" = let source = {ocaml|let f = L|ocaml} in let position = Position.create ~line:0 ~character:9 in - print_completions ~pre_print:(List.take 5) source position; + let%map () = print_completions ~pre_print:(List.take 5) source position in [%expect {| - Completions: - { - "detail": "", - "kind": 9, - "label": "LargeFile", - "sortText": "0000", - "textEdit": { - "newText": "LargeFile", - "range": { - "end": { "character": 9, "line": 0 }, - "start": { "character": 8, "line": 0 } - } - } - } - { - "detail": "", - "kind": 9, - "label": "Lazy", - "sortText": "0001", - "textEdit": { - "newText": "Lazy", - "range": { - "end": { "character": 9, "line": 0 }, - "start": { "character": 8, "line": 0 } - } - } - } - { - "detail": "", - "kind": 9, - "label": "Lexing", - "sortText": "0002", - "textEdit": { - "newText": "Lexing", - "range": { - "end": { "character": 9, "line": 0 }, - "start": { "character": 8, "line": 0 } - } - } - } - { - "detail": "", - "kind": 9, - "label": "List", - "sortText": "0003", - "textEdit": { - "newText": "List", - "range": { - "end": { "character": 9, "line": 0 }, - "start": { "character": 8, "line": 0 } - } - } - } - { - "detail": "", - "kind": 9, - "label": "ListLabels", - "sortText": "0004", - "textEdit": { - "newText": "ListLabels", - "range": { - "end": { "character": 9, "line": 0 }, - "start": { "character": 8, "line": 0 } - } - } - } - |}] + Completions: + { + "detail": "", + "kind": 9, + "label": "LargeFile", + "sortText": "0000", + "textEdit": { + "newText": "LargeFile", + "range": { + "end": { "character": 9, "line": 0 }, + "start": { "character": 8, "line": 0 } + } + } + } + { + "detail": "", + "kind": 9, + "label": "Lazy", + "sortText": "0001", + "textEdit": { + "newText": "Lazy", + "range": { + "end": { "character": 9, "line": 0 }, + "start": { "character": 8, "line": 0 } + } + } + } + { + "detail": "", + "kind": 9, + "label": "Lexing", + "sortText": "0002", + "textEdit": { + "newText": "Lexing", + "range": { + "end": { "character": 9, "line": 0 }, + "start": { "character": 8, "line": 0 } + } + } + } + { + "detail": "", + "kind": 9, + "label": "List", + "sortText": "0003", + "textEdit": { + "newText": "List", + "range": { + "end": { "character": 9, "line": 0 }, + "start": { "character": 8, "line": 0 } + } + } + } + { + "detail": "", + "kind": 9, + "label": "ListLabels", + "sortText": "0004", + "textEdit": { + "newText": "ListLabels", + "range": { + "end": { "character": 9, "line": 0 }, + "start": { "character": 8, "line": 0 } + } + } + } + |}] ;; let%expect_test "completion doesn't autocomplete record fields" = @@ -1097,12 +1129,14 @@ let%expect_test "completion doesn't autocomplete record fields" = |ocaml} in let position = Position.create ~line:5 ~character:8 in - print_completions - ~pre_print: - (List.filter ~f:(fun (compl : CompletionItem.t) -> - compl.label = "x" || compl.label = "y")) - source - position; + let%map () = + print_completions + ~pre_print: + (List.filter ~f:(fun (compl : CompletionItem.t) -> + compl.label = "x" || compl.label = "y")) + source + position + in (* We expect 0 completions*) [%expect {| No completions |}] ;; @@ -1114,7 +1148,7 @@ let foo param1 = let bar = param1 |ocaml} in let position = Position.create ~line:2 ~character:19 in - print_completions ~limit:3 source position; + let%map () = print_completions ~limit:3 source position in [%expect {| Completions: @@ -1155,7 +1189,8 @@ let foo param1 = } } } - ............. |}] + ............. + |}] ;; let%expect_test "completion for `in` keyword - prefix i" = @@ -1166,7 +1201,7 @@ let foo param1 = |ocaml} in let position = Position.create ~line:2 ~character:20 in - print_completions ~limit:3 source position; + let%map () = print_completions ~limit:3 source position in [%expect {| Completions: @@ -1195,19 +1230,20 @@ let foo param1 = } } { - "detail": "in_channel -> int", + "detail": "'a @ local once contended -> unit", "kind": 12, - "label": "in_channel_length", + "label": "ignore_contended", "sortText": "0001", "textEdit": { - "newText": "in_channel_length", + "newText": "ignore_contended", "range": { "end": { "character": 20, "line": 2 }, "start": { "character": 19, "line": 2 } } } } - ............. |}] + ............. + |}] ;; let%expect_test "completion for `in` keyword - prefix in" = @@ -1218,7 +1254,7 @@ let foo param1 = |ocaml} in let position = Position.create ~line:2 ~character:21 in - print_completions ~limit:3 source position; + let%map () = print_completions ~limit:3 source position in [%expect {| Completions: @@ -1259,61 +1295,6 @@ let foo param1 = } } } - ............. |}] -;; - -(* Test case was taken from issue #1358 *) -let%expect_test "completion for object methods" = - let source = {ocaml|let f (x : < a_method : 'a >) = x#|ocaml} in - let position = Position.create ~line:0 ~character:34 in - print_completions ~limit:3 source position; - [%expect - {| - Completions: - { - "kind": 14, - "label": "in", - "textEdit": { - "newText": "in", - "range": { - "end": { "character": 34, "line": 0 }, - "start": { "character": 34, "line": 0 } - } - } - } - { - "detail": "'a", - "kind": 2, - "label": "a_method", - "sortText": "0000", - "textEdit": { - "newText": "a_method", - "range": { - "end": { "character": 34, "line": 0 }, - "start": { "character": 34, "line": 0 } - } - } - } |}] -;; - -let%expect_test "completion for object methods" = - let source = {ocaml|let f (x : < a_method : 'a; ab_m : 'b >) = x#ab|ocaml} in - let position = Position.create ~line:0 ~character:49 in - print_completions ~limit:3 source position; - [%expect - {| - Completions: - { - "detail": "'b", - "kind": 2, - "label": "ab_m", - "sortText": "0000", - "textEdit": { - "newText": "ab_m", - "range": { - "end": { "character": 49, "line": 0 }, - "start": { "character": 47, "line": 0 } - } - } - } |}] + ............. + |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/completions.ml b/ocaml-lsp-server/test/e2e-new/completions.ml index 7076bad69..6ea8cfe00 100644 --- a/ocaml-lsp-server/test/e2e-new/completions.ml +++ b/ocaml-lsp-server/test/e2e-new/completions.ml @@ -1,8 +1,9 @@ open Test.Import +open Async let print_completion - (completions : - [ `CompletionList of CompletionList.t | `List of CompletionItem.t list ] option) + (completions : + [ `CompletionList of CompletionList.t | `List of CompletionItem.t list ] option) = let print_items (items : CompletionItem.t list) = List.map items ~f:(fun item -> @@ -50,11 +51,11 @@ let foo_value = foo ?a type. The LSP could filter these to exclude those that don't match the [?] prefix, but since the LSP already relies on the clients to do filtering, it feels weird to add filtering to the LSP. *) - Helpers.test source req; + let%map () = Helpers.test source req in [%expect {| { - "detail": "'a", + "detail": "'a option", "kind": 5, "label": "~aaa", "sortText": "0000", @@ -67,7 +68,7 @@ let foo_value = foo ?a } } { - "detail": "'b", + "detail": "'b option", "kind": 5, "label": "~aab", "sortText": "0001", @@ -94,7 +95,7 @@ let foo_value = foo ?a } **************************************** { - "detail": "'a", + "detail": "'a option", "kind": 5, "label": "?aaa", "sortText": "0000", @@ -107,7 +108,7 @@ let foo_value = foo ?a } } { - "detail": "'b", + "detail": "'b option", "kind": 5, "label": "?aab", "sortText": "0001", diff --git a/ocaml-lsp-server/test/e2e-new/construct.ml b/ocaml-lsp-server/test/e2e-new/construct.ml deleted file mode 100644 index 666b00658..000000000 --- a/ocaml-lsp-server/test/e2e-new/construct.ml +++ /dev/null @@ -1,137 +0,0 @@ -open Test.Import -module Req = Ocaml_lsp_server.Custom_request.Construct - -module Util = struct - let call_construct ?depth ?with_values client position = - let uri = DocumentUri.of_path "test.ml" in - let text_document = TextDocumentIdentifier.create ~uri in - let params = - Req.Request_params.create ?depth ?with_values ~text_document ~position () - |> Req.Request_params.yojson_of_t - |> Jsonrpc.Structured.t_of_yojson - |> Option.some - in - let req = Lsp.Client_request.UnknownRequest { meth = Req.meth; params } in - Client.request client req - ;; - - let test ?depth ?with_values ~line ~character source = - let position = Position.create ~line ~character in - let request client = - let open Fiber.O in - let+ response = call_construct ?depth ?with_values client position in - Test.print_result response - in - Helpers.test source request - ;; -end - -let%expect_test "Example sample from merlin 1" = - let source = - {|type r = {the_t: t; id: int} -and t = A | B of r option - -let x : t = _ -|} - in - let line = 3 - and character = 13 in - Util.test ~line ~character source; - [%expect - {| - { - "position": { - "end": { "character": 13, "line": 3 }, - "start": { "character": 12, "line": 3 } - }, - "result": [ "A", "(B _)" ] - } |}] -;; - -let%expect_test "Example sample from merlin 2" = - let source = - {|type r = {the_t: t; id: int} -and t = A | B of r option - -let x : t = B _ -|} - in - let line = 3 - and character = 14 in - Util.test ~line ~character source; - [%expect - {| - { - "position": { - "end": { "character": 15, "line": 3 }, - "start": { "character": 14, "line": 3 } - }, - "result": [ "None", "(Some _)" ] - } |}] -;; - -let%expect_test "Example sample from merlin 3" = - let source = - {|type r = {the_t: t; id: int} -and t = A | B of r option - -let x : t = B (Some _) -|} - in - let line = 3 - and character = 20 in - Util.test ~line ~character source; - [%expect - {| - { - "position": { - "end": { "character": 21, "line": 3 }, - "start": { "character": 20, "line": 3 } - }, - "result": [ "{ the_t = _; id = _ }" ] - } |}] -;; - -let%expect_test "Example sample from merlin 4" = - let source = - {|type r = {the_t: t; id: int} -and t = A | B of r option - -let x : t = B (Some { the_t = _; id = _ }) -|} - in - let line = 3 - and character = 30 in - Util.test ~line ~character source; - [%expect - {| - { - "position": { - "end": { "character": 31, "line": 3 }, - "start": { "character": 30, "line": 3 } - }, - "result": [ "A", "(B _)" ] - } |}] -;; - -let%expect_test "Example sample from merlin 5" = - let source = - {|type r = {the_t: t; id: int} -and t = A | B of r option - -let x : t = B (Some { the_t = A; id = _ }) -|} - in - let line = 3 - and character = 38 in - Util.test ~line ~character source; - [%expect - {| - { - "position": { - "end": { "character": 39, "line": 3 }, - "start": { "character": 38, "line": 3 } - }, - "result": [ "0" ] - } |}] -;; diff --git a/ocaml-lsp-server/test/e2e-new/diagnostics_filter.ml b/ocaml-lsp-server/test/e2e-new/diagnostics_filter.ml index a30297867..5b20d6a6b 100644 --- a/ocaml-lsp-server/test/e2e-new/diagnostics_filter.ml +++ b/ocaml-lsp-server/test/e2e-new/diagnostics_filter.ml @@ -1,10 +1,11 @@ +open Async open Test.Import let print_diagnostics - ?(prep = fun _ -> Fiber.return ()) - ?(print_range = false) - ?(path = "foo.ml") - source + ?(prep = fun _ -> Fiber.return ()) + ?(print_range : bool = false) + ?(path : string = "foo.ml") + (source : string) = Lsp_helpers.open_document_with_diagnostics_callback ~prep @@ -28,43 +29,32 @@ let print_diagnostics let change_config client params = Client.notification client (ChangeConfiguration params) -let%expect_test "shorten diagnostics - true" = +let%expect_test "receiving diagnostics" = let source = {ocaml| - let x: unit = fun () -> - - - - - () - - let () = match true with - - | false -> () +let x = Foo.oh_no +let y = garbage +;; |ocaml} in - print_diagnostics - ~prep:(fun client -> - change_config - client - (DidChangeConfigurationParams.create - ~settings: - (`Assoc [ "shortenMerlinDiagnostics", `Assoc [ "enable", `Bool true ] ]))) - ~print_range:true - source; + let%map () = print_diagnostics ~path:"../this-directory-does-not-exist/foo.ml" source in [%expect - {| - This expression should not be a function, the expected type is - unit - ((1, 18), (2, 0)) - , Warning 8: this pattern-matching is not exhaustive. - Here is an example of a case that is not matched: - true - ((8, 12), (9, 0)) - |}] + {| No config found for file ocaml-lsp-server/test/e2e-new/this-directory-does-not-exist/foo.ml. Try calling 'dune build'. |}] ;; -let%expect_test "shorten diagnostics - false" = +let%expect_test "doesn't add other diagnostics if syntax errors" = + let source = + {ocaml| + let x = "" in + + let () = 1 + |ocaml} + in + let%map () = print_diagnostics source in + [%expect {| Syntax error, expecting `in' |}] +;; + +let%expect_test "shorten diagnostics" = let source = {ocaml| let x: unit = fun () -> @@ -72,30 +62,51 @@ let%expect_test "shorten diagnostics - false" = - () + () - let () = match true with + let () = match true with - | false -> () -|ocaml} + | false -> () + |ocaml} + in + let req enable = + print_diagnostics + ~prep:(fun client -> + change_config + client + (DidChangeConfigurationParams.create + ~settings: + (`Assoc [ "shortenMerlinDiagnostics", `Assoc [ "enable", `Bool enable ] ]))) + ~print_range:true + source in - print_diagnostics - ~prep:(fun client -> - change_config - client - (DidChangeConfigurationParams.create - ~settings: - (`Assoc [ "shortenMerlinDiagnostics", `Assoc [ "enable", `Bool false ] ]))) - ~print_range:true - source; + let%bind.Deferred () = req true in + let%bind.Deferred () = req false in [%expect {| - This expression should not be a function, the expected type is + Warning 8: this pattern-matching is not exhaustive. + Here is an example of a case that is not matched: + true + ((8, 13), (9, 0)) + , This expression should not be a function, the expected type is unit - ((1, 18), (6, 5)) - , Warning 8: this pattern-matching is not exhaustive. + ((1, 18), (2, 0)) + + Warning 8: this pattern-matching is not exhaustive. Here is an example of a case that is not matched: true - ((8, 12), (10, 16)) - |}] + ((8, 13), (10, 17)) + , This expression should not be a function, the expected type is + unit + ((1, 18), (6, 8)) + |}]; + return () ;; + +(* TODO: I would like to test + [Diagnostics.refresh_merlin_diagnostics_if_doc_has_cached_errors], but there's no way + to replicate the behavior of "having merlin report diagnostics in a file and then change + what diagnostics Merlin should display for that file" without either modifying another + file and having a Dune update cause a refresh and then update the diagnostics in that + file, or having access to the LSP as more than just a process. This means testing + that is blocked until Dune testing support is released. *) diff --git a/ocaml-lsp-server/test/e2e-new/doc_to_md.ml b/ocaml-lsp-server/test/e2e-new/doc_to_md.ml index 6c4f44fb0..c6729d9d4 100644 --- a/ocaml-lsp-server/test/e2e-new/doc_to_md.ml +++ b/ocaml-lsp-server/test/e2e-new/doc_to_md.ml @@ -16,49 +16,3 @@ let%expect_test "subscript" = translate doc |> print_doc; [%expect {| a\_{b} |}] ;; - -let%expect_test "table" = - let doc = - {| {table {tr {td some content} {td some other content}} {tr {td in another} {td row}}} |} - in - translate doc |> print_doc; - [%expect - {| - | some content | some other content | - | in another | row | |}] -;; - -let%expect_test "table2" = - let doc = - {| -{t | z | f | - |:-----|---:| - | fse | e | } - |} - in - translate doc |> print_doc; - [%expect - {| - | z | f | - |:-|-:| - | fse | e | |}] -;; - -let%expect_test "problematic_translation" = - let doc = {| {table {tr {td {ul {li first item} {li second item}}}} } |} in - translate doc |> print_doc; - [%expect - {| - | - first item - second item | |}] -;; - -let%expect_test "code_with_output" = - let doc = {| {@ocaml[foo][output {b foo}]} |} in - translate doc |> print_doc; - [%expect - {| - ```ocaml - foo - ``` - output **foo** |}] -;; diff --git a/ocaml-lsp-server/test/e2e-new/document_flow.ml b/ocaml-lsp-server/test/e2e-new/document_flow.ml index 28080b810..a0a2c8d75 100644 --- a/ocaml-lsp-server/test/e2e-new/document_flow.ml +++ b/ocaml-lsp-server/test/e2e-new/document_flow.ml @@ -1,3 +1,4 @@ +open Async open Test.Import let%expect_test "it should allow double opening the same document" = @@ -5,9 +6,9 @@ let%expect_test "it should allow double opening the same document" = let drain_diagnostics () = Fiber.Mvar.read diagnostics in let handler = let on_request - (type resp state) - (client : state Client.t) - (req : resp Lsp.Server_request.t) + (type resp state) + (client : state Client.t) + (req : resp Lsp.Server_request.t) : (resp Lsp_fiber.Rpc.Reply.t * state) Fiber.t = match req with @@ -18,40 +19,46 @@ let%expect_test "it should allow double opening the same document" = in Client.Handler.make ~on_notification:(fun _ -> function - | PublishDiagnostics _ -> Fiber.Mvar.write diagnostics () - | _ -> Fiber.return ()) + | PublishDiagnostics _ -> Fiber.Mvar.write diagnostics () + | _ -> Fiber.return ()) ~on_request:{ Client.Handler.on_request } () in - (Test.run ~handler - @@ fun client -> - let run_client () = - let capabilities = - let window = - let showDocument = ShowDocumentClientCapabilities.create ~support:true in - WindowClientCapabilities.create ~showDocument () - in - ClientCapabilities.create ~window () - in - Client.start client (InitializeParams.create ~capabilities ()) - in - let run = - let* (_ : InitializeResult.t) = Client.initialized client in - let uri = DocumentUri.of_path "foo.ml" in - let open_ text = - let textDocument = - TextDocumentItem.create ~uri ~languageId:"ocaml" ~version:0 ~text - in - Client.notification - client - (TextDocumentDidOpen (DidOpenTextDocumentParams.create ~textDocument)) - in - let* () = open_ "text 1" in - let* () = drain_diagnostics () in - let+ () = open_ "text 2" in - () - in - Fiber.fork_and_join_unit run_client (fun () -> - run >>> drain_diagnostics () >>> Client.stop client)); + let%map.Deferred () = + Test.run ~handler + @@ fun client -> + let run_client () = + let capabilities = + let window = + let showDocument = ShowDocumentClientCapabilities.create ~support:true in + WindowClientCapabilities.create ~showDocument () + in + ClientCapabilities.create ~window () + in + Client.start client (InitializeParams.create ~capabilities ()) + in + let run = + let* (_ : InitializeResult.t) = Client.initialized client in + let* () = + let settings = `Assoc [ "merlinDiagnostics", `Assoc [ "enable", `Bool true ] ] in + Client.notification client (ChangeConfiguration { settings }) + in + let uri = DocumentUri.of_path "foo.ml" in + let open_ text = + let textDocument = + TextDocumentItem.create ~uri ~languageId:"ocaml" ~version:0 ~text + in + Client.notification + client + (TextDocumentDidOpen (DidOpenTextDocumentParams.create ~textDocument)) + in + let* () = open_ "text 1" in + let* () = drain_diagnostics () in + let+ () = open_ "text 2" in + () + in + Fiber.fork_and_join_unit run_client (fun () -> + run >>> drain_diagnostics () >>> Client.stop client) + in [%expect {| |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/document_symbol.ml b/ocaml-lsp-server/test/e2e-new/document_symbol.ml deleted file mode 100644 index 86206f6a3..000000000 --- a/ocaml-lsp-server/test/e2e-new/document_symbol.ml +++ /dev/null @@ -1,537 +0,0 @@ -open Test.Import - -module Util = struct - let call_document_symbol client = - let uri = DocumentUri.of_path "test.ml" in - let textDocument = TextDocumentIdentifier.create ~uri in - let param = Lsp.Types.DocumentSymbolParams.create ~textDocument () in - let req = Lsp.Client_request.DocumentSymbol param in - Client.request client req - ;; -end - -let print_as_json result = - result |> Yojson.Safe.pretty_to_string ~std:false |> print_endline -;; - -let print_result x = - let result = - match x with - | Some (`DocumentSymbol xs) -> List.map ~f:DocumentSymbol.yojson_of_t xs - | Some (`SymbolInformation xs) -> List.map ~f:SymbolInformation.yojson_of_t xs - | None -> [] - in - print_as_json (`List result) -;; - -let%expect_test "documentOutline in an empty file" = - let source = {||} in - let request client = - let open Fiber.O in - let+ response = Util.call_document_symbol client in - print_result response - in - Helpers.test source request; - [%expect {| [] |}] -;; - -let%expect_test "documentOutline with a module" = - let source = - {| - module T = struct - type t = int - end - |} - in - let request client = - let open Fiber.O in - let+ response = Util.call_document_symbol client in - print_result response - in - Helpers.test source request; - [%expect - {| - [ - { - "kind": 2, - "location": { - "range": { - "end": { "character": 7, "line": 3 }, - "start": { "character": 4, "line": 1 } - }, - "uri": "file:///test.ml" - }, - "name": "T" - }, - { - "containerName": "T", - "kind": 26, - "location": { - "range": { - "end": { "character": 18, "line": 2 }, - "start": { "character": 6, "line": 2 } - }, - "uri": "file:///test.ml" - }, - "name": "t" - } - ] - |}] -;; - -let%expect_test "documentOutline with a module, a class and a class type" = - let source = - {| - module T = struct - type t = int - class type b = object end - end - class c = object end - |} - in - let request client = - let open Fiber.O in - let+ response = Util.call_document_symbol client in - print_result response - in - Helpers.test source request; - [%expect - {| - [ - { - "kind": 2, - "location": { - "range": { - "end": { "character": 8, "line": 4 }, - "start": { "character": 4, "line": 1 } - }, - "uri": "file:///test.ml" - }, - "name": "T" - }, - { - "containerName": "T", - "kind": 26, - "location": { - "range": { - "end": { "character": 17, "line": 2 }, - "start": { "character": 5, "line": 2 } - }, - "uri": "file:///test.ml" - }, - "name": "t" - }, - { - "containerName": "T", - "kind": 11, - "location": { - "range": { - "end": { "character": 30, "line": 3 }, - "start": { "character": 5, "line": 3 } - }, - "uri": "file:///test.ml" - }, - "name": "b" - }, - { - "kind": 5, - "location": { - "range": { - "end": { "character": 25, "line": 5 }, - "start": { "character": 5, "line": 5 } - }, - "uri": "file:///test.ml" - }, - "name": "c" - } - ] - |}] -;; - -let%expect_test "documentOutline with recursive definition" = - let source = - {| - class a = object end and b = object end and c = object end - class type ta = object end and tb = object end - |} - in - let request client = - let open Fiber.O in - let+ response = Util.call_document_symbol client in - print_result response - in - Helpers.test source request; - [%expect - {| - [ - { - "kind": 5, - "location": { - "range": { - "end": { "character": 25, "line": 1 }, - "start": { "character": 5, "line": 1 } - }, - "uri": "file:///test.ml" - }, - "name": "a" - }, - { - "kind": 5, - "location": { - "range": { - "end": { "character": 44, "line": 1 }, - "start": { "character": 26, "line": 1 } - }, - "uri": "file:///test.ml" - }, - "name": "b" - }, - { - "kind": 5, - "location": { - "range": { - "end": { "character": 63, "line": 1 }, - "start": { "character": 45, "line": 1 } - }, - "uri": "file:///test.ml" - }, - "name": "c" - }, - { - "kind": 11, - "location": { - "range": { - "end": { "character": 31, "line": 2 }, - "start": { "character": 5, "line": 2 } - }, - "uri": "file:///test.ml" - }, - "name": "ta" - }, - { - "kind": 11, - "location": { - "range": { - "end": { "character": 51, "line": 2 }, - "start": { "character": 32, "line": 2 } - }, - "uri": "file:///test.ml" - }, - "name": "tb" - } - ] - |}] -;; - -let%expect_test "documentOutline with recursive definition and methods" = - let source = - {| - class a = object end - and b = object - val foo = 10 - method bar () = print_endline "bar" - end and c = object end - class type ta = object - method baz : int -> int -> string - end and tb = object end - |} - in - let request client = - let open Fiber.O in - let+ response = Util.call_document_symbol client in - print_result response - in - Helpers.test source request; - [%expect - {| - [ - { - "kind": 5, - "location": { - "range": { - "end": { "character": 25, "line": 1 }, - "start": { "character": 5, "line": 1 } - }, - "uri": "file:///test.ml" - }, - "name": "a" - }, - { - "kind": 5, - "location": { - "range": { - "end": { "character": 8, "line": 5 }, - "start": { "character": 5, "line": 2 } - }, - "uri": "file:///test.ml" - }, - "name": "b" - }, - { - "containerName": "b", - "kind": 7, - "location": { - "range": { - "end": { "character": 17, "line": 3 }, - "start": { "character": 5, "line": 3 } - }, - "uri": "file:///test.ml" - }, - "name": "foo" - }, - { - "containerName": "b", - "kind": 6, - "location": { - "range": { - "end": { "character": 40, "line": 4 }, - "start": { "character": 5, "line": 4 } - }, - "uri": "file:///test.ml" - }, - "name": "bar" - }, - { - "kind": 5, - "location": { - "range": { - "end": { "character": 27, "line": 5 }, - "start": { "character": 9, "line": 5 } - }, - "uri": "file:///test.ml" - }, - "name": "c" - }, - { - "kind": 11, - "location": { - "range": { - "end": { "character": 8, "line": 8 }, - "start": { "character": 5, "line": 6 } - }, - "uri": "file:///test.ml" - }, - "name": "ta" - }, - { - "containerName": "ta", - "kind": 6, - "location": { - "range": { - "end": { "character": 41, "line": 7 }, - "start": { "character": 8, "line": 7 } - }, - "uri": "file:///test.ml" - }, - "name": "baz" - }, - { - "kind": 11, - "location": { - "range": { - "end": { "character": 28, "line": 8 }, - "start": { "character": 9, "line": 8 } - }, - "uri": "file:///test.ml" - }, - "name": "tb" - } - ] - |}] -;; - -let%expect_test "documentOutline with nested recursive definition and methods" = - let source = - {| - class a = object - val b = object - method inside_a_b () = - val x_inside_a_b = 10 in - print_int x - end - end - and b = object - val foo = 10 - method bar () = print_endline "bar" - end and c = object end - class type ta = object - method baz : int -> int -> string - end and tb = object end - let final_let = - let c = object method foo = 10 end in c - |} - in - let request client = - let open Fiber.O in - let+ response = Util.call_document_symbol client in - print_result response - in - Helpers.test source request; - [%expect - {| - [ - { - "kind": 5, - "location": { - "range": { - "end": { "character": 8, "line": 6 }, - "start": { "character": 5, "line": 1 } - }, - "uri": "file:///test.ml" - }, - "name": "a" - }, - { - "containerName": "a", - "kind": 7, - "location": { - "range": { - "end": { "character": 16, "line": 5 }, - "start": { "character": 5, "line": 2 } - }, - "uri": "file:///test.ml" - }, - "name": "b" - }, - { - "containerName": "b", - "kind": 6, - "location": { - "range": { - "end": { "character": 27, "line": 3 }, - "start": { "character": 5, "line": 3 } - }, - "uri": "file:///test.ml" - }, - "name": "inside_a_b" - }, - { - "containerName": "b", - "kind": 7, - "location": { - "range": { - "end": { "character": 26, "line": 4 }, - "start": { "character": 5, "line": 4 } - }, - "uri": "file:///test.ml" - }, - "name": "x_inside_a_b" - }, - { - "kind": 5, - "location": { - "range": { - "end": { "character": 8, "line": 11 }, - "start": { "character": 5, "line": 8 } - }, - "uri": "file:///test.ml" - }, - "name": "b" - }, - { - "containerName": "b", - "kind": 7, - "location": { - "range": { - "end": { "character": 17, "line": 9 }, - "start": { "character": 5, "line": 9 } - }, - "uri": "file:///test.ml" - }, - "name": "foo" - }, - { - "containerName": "b", - "kind": 6, - "location": { - "range": { - "end": { "character": 40, "line": 10 }, - "start": { "character": 5, "line": 10 } - }, - "uri": "file:///test.ml" - }, - "name": "bar" - }, - { - "kind": 5, - "location": { - "range": { - "end": { "character": 27, "line": 11 }, - "start": { "character": 9, "line": 11 } - }, - "uri": "file:///test.ml" - }, - "name": "c" - }, - { - "kind": 11, - "location": { - "range": { - "end": { "character": 8, "line": 14 }, - "start": { "character": 5, "line": 12 } - }, - "uri": "file:///test.ml" - }, - "name": "ta" - }, - { - "containerName": "ta", - "kind": 6, - "location": { - "range": { - "end": { "character": 41, "line": 13 }, - "start": { "character": 8, "line": 13 } - }, - "uri": "file:///test.ml" - }, - "name": "baz" - }, - { - "kind": 11, - "location": { - "range": { - "end": { "character": 28, "line": 14 }, - "start": { "character": 9, "line": 14 } - }, - "uri": "file:///test.ml" - }, - "name": "tb" - }, - { - "kind": 13, - "location": { - "range": { - "end": { "character": 46, "line": 16 }, - "start": { "character": 5, "line": 15 } - }, - "uri": "file:///test.ml" - }, - "name": "final_let" - }, - { - "containerName": "final_let", - "kind": 13, - "location": { - "range": { - "end": { "character": 41, "line": 16 }, - "start": { "character": 7, "line": 16 } - }, - "uri": "file:///test.ml" - }, - "name": "c" - }, - { - "containerName": "c", - "kind": 6, - "location": { - "range": { - "end": { "character": 37, "line": 16 }, - "start": { "character": 22, "line": 16 } - }, - "uri": "file:///test.ml" - }, - "name": "foo" - } - ] - |}] -;; diff --git a/ocaml-lsp-server/test/e2e-new/documentation.ml b/ocaml-lsp-server/test/e2e-new/documentation.ml index 663a01bb8..286d2c6f9 100644 --- a/ocaml-lsp-server/test/e2e-new/documentation.ml +++ b/ocaml-lsp-server/test/e2e-new/documentation.ml @@ -1,3 +1,4 @@ +open Async open Test.Import module Req = Ocaml_lsp_server.Custom_request.Get_documentation @@ -37,7 +38,7 @@ let%expect_test "Documentation of simple type with no contentFormat and no ident let source = "type tree (** This is a comment *)" in let line = 0 in let character = 7 in - Util.test ~line ~character source; + let%map () = Util.test ~line ~character source in [%expect {| { "doc": { "kind": "plaintext", "value": "This is a comment" } } |}] ;; @@ -46,10 +47,14 @@ let%expect_test "Documentation of simple type with contentFormat set to markdown let line = 0 in let character = 7 in let contentFormat = "markdown" in - Util.test ~line ~character ~contentFormat source; + let%map () = Util.test ~line ~character ~contentFormat source in [%expect {| { "doc": { "kind": "markdown", "value": "This is another comment" } } |}] ;; +(* NOTE: the merlin documentation query appears to behave differently in some cases when + used internally. This may be because we have doc comments in different places than the + merlin documentation query expects. Since this does not represent any regression from + current behavior, I'm accepting the different test results to unblock this upgrade. *) let%expect_test "Documentation of simple type with an identifier and contentFormat" = let source = "{|type tree (** This is another comment *)\n List.iter ~f:(fun x -> x*x) [2;4]|}" @@ -58,15 +63,8 @@ let%expect_test "Documentation of simple type with an identifier and contentForm let character = 7 in let identifier = "List" in let contentFormat = "markdown" in - Util.test ~line ~character ~identifier ~contentFormat source; - [%expect - {| - { - "doc": { - "kind": "markdown", - "value": "List operations.\n\nSome functions are flagged as not tail-recursive. A tail-recursive function uses constant stack space, while a non-tail-recursive function uses stack space proportional to the length of its list argument, which can be a problem with very long lists. When the function takes several list arguments, an approximate formula giving stack usage (in some unspecified constant unit) is shown in parentheses.\n\nThe above considerations can usually be ignored if your lists are not longer than about 10000 elements.\n\nThe labeled version of this module can be used as described in the `StdLabels` module." - } - } |}] + let%map () = Util.test ~line ~character ~identifier ~contentFormat source in + [%expect {| null |}] ;; let%expect_test "Documentation of simple type with an identifier and no contentFormat" = @@ -76,15 +74,8 @@ let%expect_test "Documentation of simple type with an identifier and no contentF let line = 0 in let character = 7 in let identifier = "List" in - Util.test ~line ~character ~identifier source; - [%expect - {| - { - "doc": { - "kind": "plaintext", - "value": "List operations.\n\n Some functions are flagged as not tail-recursive. A tail-recursive\n function uses constant stack space, while a non-tail-recursive function\n uses stack space proportional to the length of its list argument, which\n can be a problem with very long lists. When the function takes several\n list arguments, an approximate formula giving stack usage (in some\n unspecified constant unit) is shown in parentheses.\n\n The above considerations can usually be ignored if your lists are not\n longer than about 10000 elements.\n\n The labeled version of this module can be used as described in the\n {!StdLabels} module." - } - } |}] + let%map () = Util.test ~line ~character ~identifier source in + [%expect {| null |}] ;; let%expect_test "Documentation when List module is shadowed" = @@ -103,15 +94,16 @@ let%expect_test "Documentation when List module is shadowed" = let line = 2 in let character = 6 in let identifier = "List.iter" in - Util.test ~line ~character ~identifier source; + let%map () = Util.test ~line ~character ~identifier source in [%expect {| - { - "doc": { - "kind": "plaintext", - "value": "[iter f [a1; ...; an]] applies function [f] in turn to\n [[a1; ...; an]]. It is equivalent to\n [f a1; f a2; ...; f an]." + { + "doc": { + "kind": "plaintext", + "value": "[iter f [a1; ...; an]] applies function [f] in turn to\n [[a1; ...; an]]. It is equivalent to\n [f a1; f a2; ...; f an]." + } } - } |}] + |}] ;; let%expect_test "Documentation when List module is shadowed" = @@ -130,10 +122,8 @@ let%expect_test "Documentation when List module is shadowed" = let line = 7 in let character = 12 in let identifier = "Base.List.iter" in - Util.test ~line ~character ~identifier source; - [%expect - {| - { "doc": { "kind": "plaintext", "value": "Base.List.iter" } } |}] + let%map () = Util.test ~line ~character ~identifier source in + [%expect {| { "doc": { "kind": "plaintext", "value": "Base.List.iter" } } |}] ;; (* TODO: Open Issue in Merlin to investigate while this doesnt return documentation of the custom List module*) @@ -152,13 +142,6 @@ let%expect_test "Documentation when List module is shadowed" = in let line = 2 in let character = 9 in - Util.test ~line ~character source; - [%expect - {| - { - "doc": { - "kind": "plaintext", - "value": "List operations.\n\n Some functions are flagged as not tail-recursive. A tail-recursive\n function uses constant stack space, while a non-tail-recursive function\n uses stack space proportional to the length of its list argument, which\n can be a problem with very long lists. When the function takes several\n list arguments, an approximate formula giving stack usage (in some\n unspecified constant unit) is shown in parentheses.\n\n The above considerations can usually be ignored if your lists are not\n longer than about 10000 elements.\n\n The labeled version of this module can be used as described in the\n {!StdLabels} module." - } - } |}] + let%map () = Util.test ~line ~character source in + [%expect {| null |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/dune b/ocaml-lsp-server/test/e2e-new/dune index 2dfa3f4fc..d42edc771 100644 --- a/ocaml-lsp-server/test/e2e-new/dune +++ b/ocaml-lsp-server/test/e2e-new/dune @@ -10,18 +10,19 @@ (enabled_if (= %{os_type} Unix)) (deps - %{bin:ocamlformat-rpc} +; %{bin:ocamlformat-rpc} for_ppx.ml - for_pp.ml (package ocaml-lsp-server))) (libraries - unix - stdune + async + async_kernel + base + core + expectree fiber + fiber_async yojson - ppx_yojson_conv_lib - lev_fiber - lev + lev_fiber_async ocaml_lsp_server spawn jsonrpc @@ -29,45 +30,15 @@ lsp_fiber ;; This is because of the (implicit_transitive_deps false) ;; in dune-project - base - ppx_expect ppx_expect.config ppx_expect.config_types - ppx_inline_test.config) - (preprocess - (per_module - ((action - (run sed "s/world/universe/g" %{input-file})) - for_pp) - ((pps ppx_expect) - action_extract - action_inline - action_mark_remove - code_actions - completion - completions - construct - doc_to_md - document_flow - exit_notification - for_ppx - hover_extended - inlay_hints - jump_to_typed_hole - merlin_call_compatible - diagnostics_filter - metrics - semantic_hl_data - semantic_hl_helpers - semantic_hl_tests - start_stop - syntax_doc_tests - test - type_enclosing - documentation - document_symbol - merlin_jump - type_search - with_pp - with_ppx - workspace_change_config)))) + ppx_expect.runtime_types + ppx_inline_test.config + ppx_yojson_conv_lib + stdune + unix) + (preprocess (pps ppx_jane)) + (flags ( + :standard + -open + Lev_fiber_async))) diff --git a/ocaml-lsp-server/test/e2e-new/exit_notification.ml b/ocaml-lsp-server/test/e2e-new/exit_notification.ml index f2a9ac3d9..b407d381d 100644 --- a/ocaml-lsp-server/test/e2e-new/exit_notification.ml +++ b/ocaml-lsp-server/test/e2e-new/exit_notification.ml @@ -1,12 +1,13 @@ open Test.Import +open Async let client_capabilities = ClientCapabilities.create () module T : sig - val run : (unit Client.t -> 'a Fiber.t) -> 'a + val run : (unit Client.t -> 'a Fiber.t) -> 'a Deferred.t end = struct let run f = - let status, a = Test.run_with_status f in + let%map status, a = Test.run_with_status f in let () = match status with | WEXITED n -> Format.eprintf "ocamllsp finished with code = %d@.%!" n @@ -25,18 +26,16 @@ let test run = Fiber.fork_and_join_unit run_client (run client)) ;; -let%expect_test - "ocamllsp process exits with code 0 after Shutdown and Exit notifications are sent" +let%expect_test "ocamllsp process exits with code 0 after Shutdown and Exit \ + notifications are sent" = let run client () = let* (_ : InitializeResult.t) = Client.initialized client in let* () = Client.request client Shutdown in Client.notification client Exit in - test run; - [%expect - {| - ocamllsp finished with code = 0 |}] + let%map () = test run in + [%expect {| ocamllsp finished with code = 0 |}] ;; let%expect_test "ocamllsp does not exit if only Shutdown notification is sent" = @@ -44,21 +43,17 @@ let%expect_test "ocamllsp does not exit if only Shutdown notification is sent" = let* (_ : InitializeResult.t) = Client.initialized client in Client.request client Shutdown in - test run; - [%expect - {| - ocamllsp killed with signal = -7 |}] + let%map () = test run in + [%expect {| ocamllsp killed with signal = -7 |}] ;; -let%expect_test - "ocamllsp process exits with code 0 after Exit notification is sent (should be 1)" +let%expect_test "ocamllsp process exits with code 0 after Exit notification is sent \ + (should be 1)" = let run client () = let* (_ : InitializeResult.t) = Client.initialized client in Client.notification client Exit in - test run; - [%expect - {| - ocamllsp finished with code = 0 |}] + let%map () = test run in + [%expect {| ocamllsp finished with code = 0 |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/for_pp.ml b/ocaml-lsp-server/test/e2e-new/for_pp.ml deleted file mode 100644 index dbc0f819e..000000000 --- a/ocaml-lsp-server/test/e2e-new/for_pp.ml +++ /dev/null @@ -1 +0,0 @@ -type world diff --git a/ocaml-lsp-server/test/e2e-new/for_ppx.ml b/ocaml-lsp-server/test/e2e-new/for_ppx.ml index f17c6b0d7..65ad85ce9 100644 --- a/ocaml-lsp-server/test/e2e-new/for_ppx.ml +++ b/ocaml-lsp-server/test/e2e-new/for_ppx.ml @@ -1,4 +1,4 @@ let%expect_test "this is a dummy source for with_ppx" = (* If you edit this file, [with_ppx] will change *) - [%expect {||}] + [%expect {| |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/helpers.mli b/ocaml-lsp-server/test/e2e-new/helpers.mli index 18836f82f..e128a3891 100644 --- a/ocaml-lsp-server/test/e2e-new/helpers.mli +++ b/ocaml-lsp-server/test/e2e-new/helpers.mli @@ -1,4 +1,9 @@ open Test.Import val uri : Uri.t -val test : ?extra_env:string list -> string -> (unit Client.t -> unit Fiber.t) -> unit + +val test + : ?extra_env:string list + -> string + -> (unit Client.t -> unit Fiber.t) + -> unit Async.Deferred.t diff --git a/ocaml-lsp-server/test/e2e-new/hover_extended.ml b/ocaml-lsp-server/test/e2e-new/hover_extended.ml index a94219f24..09da41617 100644 --- a/ocaml-lsp-server/test/e2e-new/hover_extended.ml +++ b/ocaml-lsp-server/test/e2e-new/hover_extended.ml @@ -1,3 +1,4 @@ +open Async open Test.Import let print_hover hover = @@ -56,7 +57,11 @@ let foo_value : foo = Some 1 let () = print_hover resp in Fiber.return () in - Helpers.test source req; + (* This test shows the default hover behavior, and we enable extendedHover by default. + Testing the disabling of extendedHover requires threading through extra logic and + isn't worth the effort (setting OCAMLLSP_HOVER_IS_EXTENDED=false just uses the + default value, which is [true]). *) + let%map.Deferred () = Helpers.test source req in [%expect {| { @@ -67,12 +72,13 @@ let foo_value : foo = Some 1 } } { - "contents": { "kind": "plaintext", "value": "foo" }, + "contents": { "kind": "plaintext", "value": "int option" }, "range": { "end": { "character": 13, "line": 3 }, "start": { "character": 4, "line": 3 } } - } |}] + } + |}] ;; let%expect_test "hover returns type inferred under cursor in a formatted way" = @@ -87,19 +93,20 @@ let f a b c d e f g h i = 1 + a + b + c + d + e + f + g + h + i let () = print_hover resp in Fiber.return () in - Helpers.test source req; + let%map.Deferred () = Helpers.test source req in [%expect {| { "contents": { "kind": "plaintext", - "value": "int ->\nint ->\nint ->\nint ->\nint ->\nint ->\nint ->\nint ->\nint ->\nint" + "value": "int -> int -> int -> int -> int -> int -> int -> int -> int -> int\n***\nAllocation: heap" }, "range": { "end": { "character": 5, "line": 1 }, "start": { "character": 4, "line": 1 } } - } |}] + } + |}] ;; let%expect_test "hover extended" = @@ -118,7 +125,9 @@ let foo_value : foo = Some 1 let () = print_hover resp in Fiber.return () in - Helpers.test ~extra_env:[ "OCAMLLSP_HOVER_IS_EXTENDED=true" ] source req; + let%map.Deferred () = + Helpers.test ~extra_env:[ "OCAMLLSP_HOVER_IS_EXTENDED=true" ] source req + in [%expect {| { @@ -134,7 +143,8 @@ let foo_value : foo = Some 1 "end": { "character": 13, "line": 3 }, "start": { "character": 4, "line": 3 } } - } |}] + } + |}] ;; let%expect_test "default verbosity" = @@ -151,16 +161,20 @@ let foo_value : foo = Some 1 let () = print_hover_extended resp in Fiber.return () in - Helpers.test source req; + let%map.Deferred () = Helpers.test source req in [%expect {| { + "verbosity": 0, + "canIncreaseVerbosity": true, + "canDecreaseVerbosity": false, "contents": { "kind": "plaintext", "value": "foo" }, "range": { "end": { "character": 13, "line": 3 }, "start": { "character": 4, "line": 3 } } - } |}] + } + |}] ;; let%expect_test "explicit verbosity 0" = @@ -177,16 +191,20 @@ let foo_value : foo = Some 1 let () = print_hover_extended resp in Fiber.return () in - Helpers.test source req; + let%map.Deferred () = Helpers.test source req in [%expect {| { + "verbosity": 0, + "canIncreaseVerbosity": true, + "canDecreaseVerbosity": false, "contents": { "kind": "plaintext", "value": "foo" }, "range": { "end": { "character": 13, "line": 3 }, "start": { "character": 4, "line": 3 } } - } |}] + } + |}] ;; let%expect_test "explicit verbosity 1" = @@ -203,16 +221,20 @@ let foo_value : foo = Some 1 let () = print_hover_extended resp in Fiber.return () in - Helpers.test source req; + let%map.Deferred () = Helpers.test source req in [%expect {| { + "verbosity": 1, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": true, "contents": { "kind": "plaintext", "value": "int option" }, "range": { "end": { "character": 13, "line": 3 }, "start": { "character": 4, "line": 3 } } - } |}] + } + |}] ;; let%expect_test "explicit verbosity 2" = @@ -229,16 +251,20 @@ let foo_value : foo = Some 1 let () = print_hover_extended resp in Fiber.return () in - Helpers.test source req; + let%map.Deferred () = Helpers.test source req in [%expect {| { + "verbosity": 2, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": true, "contents": { "kind": "plaintext", "value": "int option" }, "range": { "end": { "character": 13, "line": 3 }, "start": { "character": 4, "line": 3 } } - } |}] + } + |}] ;; let%expect_test "implicity verbosity increases" = @@ -259,10 +285,13 @@ let foo_value : foo = Some 1 let () = print_hover_extended resp in Fiber.return () in - Helpers.test source req; + let%map.Deferred () = Helpers.test source req in [%expect {| { + "verbosity": 0, + "canIncreaseVerbosity": true, + "canDecreaseVerbosity": false, "contents": { "kind": "plaintext", "value": "foo" }, "range": { "end": { "character": 13, "line": 3 }, @@ -270,6 +299,9 @@ let foo_value : foo = Some 1 } } { + "verbosity": 1, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": true, "contents": { "kind": "plaintext", "value": "int option" }, "range": { "end": { "character": 13, "line": 3 }, @@ -277,12 +309,16 @@ let foo_value : foo = Some 1 } } { + "verbosity": 2, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": true, "contents": { "kind": "plaintext", "value": "int option" }, "range": { "end": { "character": 13, "line": 3 }, "start": { "character": 4, "line": 3 } } - } |}] + } + |}] ;; let%expect_test "hover extended returns type inferred under cursor in a formatted way" = @@ -297,17 +333,231 @@ let f a b c d e f g h i = 1 + a + b + c + d + e + f + g + h + i let () = print_hover_extended resp in Fiber.return () in - Helpers.test source req; + let%map.Deferred () = Helpers.test source req in [%expect {| { + "verbosity": 0, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": false, "contents": { "kind": "plaintext", - "value": "int ->\nint ->\nint ->\nint ->\nint ->\nint ->\nint ->\nint ->\nint ->\nint" + "value": "int -> int -> int -> int -> int -> int -> int -> int -> int -> int\n***\nAllocation: heap" }, "range": { "end": { "character": 5, "line": 1 }, "start": { "character": 4, "line": 1 } } - } |}] + } + |}] +;; + +let%expect_test "heap allocation" = + let source = + {ocaml| +let f g x y = + let z = x + y in + Some (g z) +;; +|ocaml} + in + let position = Position.create ~line:3 ~character:3 in + let req client = + let* resp = hover_extended client position None in + let () = print_hover_extended resp in + Fiber.return () + in + let%map.Deferred () = Helpers.test source req in + [%expect + {| + { + "verbosity": 0, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": false, + "contents": { + "kind": "plaintext", + "value": "'a -> 'a option\n***\nSome\n***\nAllocation: heap" + }, + "range": { + "end": { "character": 6, "line": 3 }, + "start": { "character": 2, "line": 3 } + } + } + |}] +;; + +let%expect_test "stack allocation" = + let source = + {ocaml| +let f g x y = + let z = x + y in + exclave_ Some (g z) +;; +|ocaml} + in + let position = Position.create ~line:3 ~character:12 in + let req client = + let* resp = hover_extended client position None in + let () = print_hover_extended resp in + Fiber.return () + in + let%map.Deferred () = Helpers.test source req in + [%expect + {| + { + "verbosity": 0, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": false, + "contents": { + "kind": "plaintext", + "value": "'a -> 'a option\n***\nSome\n***\nAllocation: stack" + }, + "range": { + "end": { "character": 15, "line": 3 }, + "start": { "character": 11, "line": 3 } + } + } + |}] +;; + +(* NOTE: This only seems to work on the character to the right of the + + + This looks like a bug in the stack-or-heap-enclosing query where it returns the + range 2:11 - 2:12 when called on the +, instead of 2:12 - 2:13 like it should. + + Merlin devs will look into fixing this. +*) +let%expect_test "no relevant allocation to show" = + let source = + {ocaml| +let f g x y = + let z = x + y in + Some (g z) +;; +|ocaml} + in + let position = Position.create ~line:2 ~character:13 in + let req client = + let* resp = hover_extended client position None in + let () = print_hover_extended resp in + Fiber.return () + in + let%map.Deferred () = Helpers.test source req in + [%expect + {| + { + "verbosity": 0, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": false, + "contents": { + "kind": "plaintext", + "value": "int -> int -> int\n***\nInteger addition.\n Left-associative operator, see {!Ocaml_operators} for more information.\n***\nAllocation: no relevant allocation to show" + }, + "range": { + "end": { "character": 13, "line": 2 }, + "start": { "character": 12, "line": 2 } + } + } + |}] +;; + +let%expect_test "not an allocation (constructor without arguments)" = + let source = + {ocaml| +let f g x y = + let z = x + y in + None +;; +|ocaml} + in + let position = Position.create ~line:3 ~character:2 in + let req client = + let* resp = hover_extended client position None in + let () = print_hover_extended resp in + Fiber.return () + in + let%map.Deferred () = Helpers.test source req in + [%expect + {| + { + "verbosity": 0, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": false, + "contents": { + "kind": "plaintext", + "value": "'a option\n***\nNone\n***\nAllocation: not an allocation (constructor without arguments)" + }, + "range": { + "end": { "character": 6, "line": 3 }, + "start": { "character": 2, "line": 3 } + } + } + |}] +;; + +let%expect_test "could be stack or heap" = + let source = + {ocaml| +let f g x y = + let z = Some (g z) in + y +;; +|ocaml} + in + let position = Position.create ~line:2 ~character:10 in + let req client = + let* resp = hover_extended client position None in + let () = print_hover_extended resp in + Fiber.return () + in + let%map.Deferred () = Helpers.test source req in + [%expect + {| + { + "verbosity": 0, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": false, + "contents": { + "kind": "plaintext", + "value": "'a -> 'a option\n***\nSome\n***\nAllocation: could be stack or heap" + }, + "range": { + "end": { "character": 14, "line": 2 }, + "start": { "character": 10, "line": 2 } + } + } + |}] +;; + +let%expect_test "function on the stack" = + let source = + {ocaml| +let f g = + exclave_ fun x -> g x +;; +|ocaml} + in + let position = Position.create ~line:2 ~character:11 in + let req client = + let* resp = hover_extended client position None in + let () = print_hover_extended resp in + Fiber.return () + in + let%map.Deferred () = Helpers.test source req in + [%expect + {| + { + "verbosity": 0, + "canIncreaseVerbosity": false, + "canDecreaseVerbosity": false, + "contents": { + "kind": "plaintext", + "value": "'a -> 'b\n***\nAllocation: stack" + }, + "range": { + "end": { "character": 23, "line": 2 }, + "start": { "character": 11, "line": 2 } + } + } + |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/inlay_hints.ml b/ocaml-lsp-server/test/e2e-new/inlay_hints.ml index 4b543738a..e0bd99e54 100644 --- a/ocaml-lsp-server/test/e2e-new/inlay_hints.ml +++ b/ocaml-lsp-server/test/e2e-new/inlay_hints.ml @@ -1,13 +1,15 @@ +open Async open Test.Import let apply_inlay_hints - ?(path = "foo.ml") - ?range - ?(hint_pattern_variables = false) - ?(hint_let_bindings = false) - ?hint_function_params - ~source - () + ?(path = "foo.ml") + ?range + ?(hint_function_params = false) + ?(hint_pattern_variables = false) + ?(hint_let_bindings = false) + ?(hint_let_syntax_ppx = false) + ~source + () = let range = match range with @@ -25,19 +27,19 @@ let apply_inlay_hints let textDocument = TextDocumentIdentifier.create ~uri in InlayHintParams.create ~textDocument ~range () in - let regular_config = - [ "hintPatternVariables", `Bool hint_pattern_variables - ; "hintLetBindings", `Bool hint_let_bindings - ] - @ - match hint_function_params with - | None -> [] - | Some hint_function_params -> [ "hintFunctionParams", `Bool hint_function_params ] - in - let inlay_hints = + let%map inlay_hints = Test.run_request ~prep:(fun client -> Test.openDocument ~client ~uri ~source) - ~settings:(`Assoc [ "inlayHints", `Assoc regular_config ]) + ~settings: + (`Assoc + [ ( "inlayHints" + , `Assoc + [ "hintFunctionParams", `Bool hint_function_params + ; "hintPatternVariables", `Bool hint_pattern_variables + ; "hintLetBindings", `Bool hint_let_bindings + ; "hintLetSyntaxPpx", `Bool hint_let_syntax_ppx + ] ) + ]) (InlayHint request) in match inlay_hints with @@ -68,50 +70,346 @@ let apply_inlay_hints ;; let%expect_test "optional argument" = - apply_inlay_hints ~source:"let f ?x () = x" (); + let%map () = + apply_inlay_hints ~hint_function_params:true ~source:"let f ?x () = x" () + in [%expect {| let f ?x$: 'a option$ () = x |}] ;; let%expect_test "optional argument with value" = - apply_inlay_hints ~source:"let f ?(x = 1) () = x" (); + let%map () = + apply_inlay_hints ~hint_function_params:true ~source:"let f ?(x = 1) () = x" () + in [%expect {| let f ?(x$: int$ = 1) () = x |}] ;; let%expect_test "labeled argument" = - apply_inlay_hints ~source:"let f ~x = x + 1" (); + let%map () = + apply_inlay_hints ~hint_function_params:true ~source:"let f ~x = x + 1" () + in [%expect {| let f ~x$: int$ = x + 1 |}] ;; let%expect_test "case argument" = - apply_inlay_hints ~source:"let f (Some x) = x + 1" (); + let%map () = + apply_inlay_hints ~hint_function_params:true ~source:"let f (Some x) = x + 1" () + in [%expect {| let f (Some x$: int$) = x + 1 |}] ;; let%expect_test "pattern variables" = let source = "let f x = match x with Some x -> x | None -> 0" in - apply_inlay_hints ~source (); + let%bind () = apply_inlay_hints ~hint_function_params:true ~source () in [%expect {| let f x$: int option$ = match x with Some x -> x | None -> 0 |}]; - apply_inlay_hints ~hint_pattern_variables:true ~source (); + let%map () = + apply_inlay_hints ~hint_function_params:true ~hint_pattern_variables:true ~source () + in [%expect {| let f x$: int option$ = match x with Some x$: int$ -> x | None -> 0 |}] ;; let%expect_test "let bindings" = let source = "let f () = let y = 0 in y" in - apply_inlay_hints ~source (); + let%bind () = apply_inlay_hints ~hint_function_params:true ~source () in [%expect {| let f () = let y = 0 in y |}]; - apply_inlay_hints ~hint_let_bindings:true ~source (); + let%map () = + apply_inlay_hints ~hint_function_params:true ~hint_let_bindings:true ~source () + in [%expect {| let f () = let y$: int$ = 0 in y |}] ;; -let%expect_test "function params" = - let source = "let f a b c d = (a + b, c ^ string_of_bool d)" in - apply_inlay_hints ~source (); +let%expect_test "everything off" = + let%map () = + apply_inlay_hints + ~source: + {| +let foo x y = + let z = x, y in + match z with + | 0, b -> b + | _ -> 0 +;;|} + () + in + [%expect + {| + let foo x y = + let z = x, y in + match z with + | 0, b -> b + | _ -> 0 + ;; + |}] +;; + +let%expect_test "function params only" = + let%map () = + apply_inlay_hints + ~hint_function_params:true + ~source: + {| +let foo x y = + let z = x, y in + match z with + | 0, b -> b + | _ -> 0 +;;|} + () + in + [%expect + {| + let foo x$: int$ y$: int$ = + let z = x, y in + match z with + | 0, b -> b + | _ -> 0 + ;; + |}] +;; + +let%expect_test "let bindings only" = + let%map () = + apply_inlay_hints + ~hint_let_bindings:true + ~source: + {| +let foo x y = + let z = x, y in + match z with + | 0, b -> b + | _ -> 0 +;;|} + () + in + [%expect + {| + let foo x y = + let z$: int * int$ = x, y in + match z with + | 0, b -> b + | _ -> 0 + ;; + |}] +;; + +let%expect_test "pattern variables only" = + let%map () = + apply_inlay_hints + ~hint_pattern_variables:true + ~source: + {| +let foo x y = + let z = x, y in + match z with + | 0, b -> b + | _ -> 0 +;;|} + () + in + [%expect + {| + let foo x y = + let z = x, y in + match z with + | 0, b$: int$ -> b + | _ -> 0 + ;; + |}] +;; + +let%expect_test "everything on" = + let%map () = + apply_inlay_hints + ~hint_let_bindings:true + ~hint_pattern_variables:true + ~hint_function_params:true + ~source: + {| +let foo x y = + let z = x, y in + match z with + | 0, b -> b + | _ -> 0 +;;|} + () + in + [%expect + {| + let foo x$: int$ y$: int$ = + let z$: int * int$ = x, y in + match z with + | 0, b$: int$ -> b + | _ -> 0 + ;; + |}] +;; + +let%expect_test "argument to function that uses [function]" = + let%bind () = + apply_inlay_hints + ~source: + {| +let bar a = function + | 0 -> 10 + | _ -> -a +;;|} + () + in + [%expect + {| + let bar a = function + | 0 -> 10 + | _ -> -a + ;; + |}]; + let%map () = + apply_inlay_hints + ~hint_function_params:true + ~source: + {| + let bar a = function + | 0 -> 10 + | _ -> -a + ;;|} + () + in + [%expect + {| + let bar a$: int$ = function + | 0 -> 10 + | _ -> -a + ;; + |}] +;; + +let%expect_test "pattern variables in function that uses [function]" = + let%bind () = + apply_inlay_hints + ~source: + {| +let baz = function + | 0, b -> b + | _ -> 0 +;;|} + () + in + [%expect + {| + let baz = function + | 0, b -> b + | _ -> 0 + ;; + |}]; + let%map () = + apply_inlay_hints + ~hint_pattern_variables:true + ~source: + {| +let baz = function + | 0, b -> b + | _ -> 0 +;;|} + () + in [%expect - {| let f a$: int$ b$: int$ c$: string$ d$: bool$ = (a + b, c ^ string_of_bool d) |}] + {| + let baz = function + | 0, b$: int$ -> b + | _ -> 0 + ;; + |}] ;; -let%expect_test "function params (deactivated)" = - let source = "let f a b c d = (a + b, c ^ string_of_bool d)" in - apply_inlay_hints ~hint_function_params:false ~source (); - [%expect {| let f a b c d = (a + b, c ^ string_of_bool d) |}] +let%expect_test "let-syntax ppx annotations" = + (* Note: We can't test cases where we interleave [let open _] with the PPX because we + don't interpret them when running the test and so at the type stage the opens don't + exist. *) + let source = + {| + module First = struct module Let_syntax = struct end end + module Second = struct module Let_syntax = struct end end + module Reference = First + + open First + + let _ = + let%bind () = return () in + let%map () = return () + ;; + + let _ = + let open Second in + let%bind () = return () in + let%map () = return () in + return () + ;; + + open Reference + + let _ = + let%bind () = return () in + let%map () = return () in + return () + ;; + + module Top_level = struct + module Nested = struct + module Let_syntax = struct end + end + end + + open Top_level + + let _ = + let open Nested in + let%bind () = return () in + let%map () = return () in + return () + ;; + |} + in + let%bind () = apply_inlay_hints ~hint_let_syntax_ppx:true ~source () in + [%expect + {| + module First = struct module Let_syntax = struct end end + module Second = struct module Let_syntax = struct end end + module Reference = First + + open First + + let _ = + let%bind$.Reference$ () = return () in + let%map$.Reference$ () = return () + ;; + + let _ = + let open Second in + let%bind$.Second$ () = return () in + let%map$.Second$ () = return () in + return () + ;; + + open Reference + + let _ = + let%bind$.Reference$ () = return () in + let%map$.Reference$ () = return () in + return () + ;; + + module Top_level = struct + module Nested = struct + module Let_syntax = struct end + end + end + + open Top_level + + let _ = + let open Nested in + let%bind$.Nested$ () = return () in + let%map$.Nested$ () = return () in + return () + ;; + |}]; + return () ;; diff --git a/ocaml-lsp-server/test/e2e-new/jump_to_hole.ml b/ocaml-lsp-server/test/e2e-new/jump_to_hole.ml new file mode 100644 index 000000000..c5949d2a6 --- /dev/null +++ b/ocaml-lsp-server/test/e2e-new/jump_to_hole.ml @@ -0,0 +1,138 @@ +open Async +open Test.Import + +let print_jump_to_hole (source : string) (position : Position.t) (direction : string) = + let makeRequest (textDocument : TextDocumentIdentifier.t) = + let params = + Some + (`Assoc + [ "uri", Uri.yojson_of_t textDocument.uri + ; "position", Position.yojson_of_t position + ; "direction", `String direction + ]) + in + Lsp.Client_request.UnknownRequest { meth = "ocamllsp/jumpToHole"; params } + in + Lsp_helpers.iter_lsp_response ~makeRequest ~source (fun x -> + print_endline (Yojson.Safe.to_string x)) +;; + +let%expect_test "can jump to next hole" = + let source = + {ocaml| +let rec zip_shortest (xs : 'a list) (ys : 'b list) : ('a * 'b) list = + match (xs, ys) with + | ([], []) | ([], _::_) | (_::_, []) -> _ + | (x::xs, y::ys) -> ((_, _) :: (zip_shortest _ _)) +;; +|ocaml} + in + let position = Position.create ~line:4 ~character:40 in + let%map () = print_jump_to_hole source position "next" in + [%expect {| {"end":{"character":48,"line":4},"start":{"character":47,"line":4}} |}] +;; + +let%expect_test "can jump to prev hole" = + let source = + {ocaml| +let rec zip_shortest (xs : 'a list) (ys : 'b list) : ('a * 'b) list = + match (xs, ys) with + | ([], []) | ([], _::_) | (_::_, []) -> _ + | (x::xs, y::ys) -> ((_, _) :: (zip_shortest _ _)) +;; +|ocaml} + in + let position = Position.create ~line:4 ~character:40 in + let%map () = print_jump_to_hole source position "prev" in + [%expect {| {"end":{"character":28,"line":4},"start":{"character":27,"line":4}} |}] +;; + +let%expect_test "jump to next hole can wrap" = + let source = + {ocaml| +let rec zip_shortest (xs : 'a list) (ys : 'b list) : ('a * 'b) list = + match (xs, ys) with + | ([], []) | ([], _::_) | (_::_, []) -> _ + | (x::xs, y::ys) -> ((_, _) :: (zip_shortest _ _)) +;; +|ocaml} + in + let position = Position.create ~line:5 ~character:1 in + let%map () = print_jump_to_hole source position "next" in + [%expect {| {"end":{"character":43,"line":3},"start":{"character":42,"line":3}} |}] +;; + +let%expect_test "jump to prev hole can wrap" = + let source = + {ocaml| +let rec zip_shortest (xs : 'a list) (ys : 'b list) : ('a * 'b) list = + match (xs, ys) with + | ([], []) | ([], _::_) | (_::_, []) -> _ + | (x::xs, y::ys) -> ((_, _) :: (zip_shortest _ _)) +;; +|ocaml} + in + let position = Position.create ~line:2 ~character:20 in + let%map () = print_jump_to_hole source position "prev" in + [%expect {| {"end":{"character":50,"line":4},"start":{"character":49,"line":4}} |}] +;; + +let%expect_test "can jump to next hole when on char before current hole" = + let source = + {ocaml| +let rec zip_shortest (xs : 'a list) (ys : 'b list) : ('a * 'b) list = + match (xs, ys) with + | ([], []) | ([], _::_) | (_::_, []) -> _ + | (x::xs, y::ys) -> ((_, _) :: (zip_shortest _ _)) +;; +|ocaml} + in + let position = Position.create ~line:4 ~character:27 in + let%map () = print_jump_to_hole source position "next" in + [%expect {| {"end":{"character":48,"line":4},"start":{"character":47,"line":4}} |}] +;; + +let%expect_test "can jump to next hole when on char after current hole" = + let source = + {ocaml| +let rec zip_shortest (xs : 'a list) (ys : 'b list) : ('a * 'b) list = + match (xs, ys) with + | ([], []) | ([], _::_) | (_::_, []) -> _ + | (x::xs, y::ys) -> ((_, _) :: (zip_shortest _ _)) +;; +|ocaml} + in + let position = Position.create ~line:4 ~character:28 in + let%map () = print_jump_to_hole source position "next" in + [%expect {| {"end":{"character":48,"line":4},"start":{"character":47,"line":4}} |}] +;; + +let%expect_test "can jump to prev hole when on char before current hole" = + let source = + {ocaml| +let rec zip_shortest (xs : 'a list) (ys : 'b list) : ('a * 'b) list = + match (xs, ys) with + | ([], []) | ([], _::_) | (_::_, []) -> _ + | (x::xs, y::ys) -> ((_, _) :: (zip_shortest _ _)) +;; +|ocaml} + in + let position = Position.create ~line:4 ~character:27 in + let%map () = print_jump_to_hole source position "prev" in + [%expect {| {"end":{"character":25,"line":4},"start":{"character":24,"line":4}} |}] +;; + +let%expect_test "can jump to prev hole when on char after current hole" = + let source = + {ocaml| +let rec zip_shortest (xs : 'a list) (ys : 'b list) : ('a * 'b) list = + match (xs, ys) with + | ([], []) | ([], _::_) | (_::_, []) -> _ + | (x::xs, y::ys) -> ((_, _) :: (zip_shortest _ _)) +;; +|ocaml} + in + let position = Position.create ~line:4 ~character:28 in + let%map () = print_jump_to_hole source position "prev" in + [%expect {| {"end":{"character":25,"line":4},"start":{"character":24,"line":4}} |}] +;; diff --git a/ocaml-lsp-server/test/e2e-new/jump_to_typed_hole.ml b/ocaml-lsp-server/test/e2e-new/jump_to_typed_hole.ml deleted file mode 100644 index 7d031c2f6..000000000 --- a/ocaml-lsp-server/test/e2e-new/jump_to_typed_hole.ml +++ /dev/null @@ -1,278 +0,0 @@ -open Test.Import -module Req = Ocaml_lsp_server.Custom_request.Jump_to_typed_hole - -module Util = struct - let call ?direction ?range ~position client = - let uri = DocumentUri.of_path "test.ml" in - let text_document = TextDocumentIdentifier.create ~uri in - let meth = Req.meth in - let params = - Req.Request_params.create ?direction ?range ~text_document ~position () - |> Req.Request_params.yojson_of_t - |> Jsonrpc.Structured.t_of_yojson - |> Option.some - in - let req = Lsp.Client_request.UnknownRequest { meth; params } in - Client.request client req - ;; - - let test ?direction ?range ~line ~character source = - let position = Position.create ~line ~character in - let request client = - client |> call ?direction ?range ~position |> Fiber.map ~f:Test.print_result - in - Helpers.test source request - ;; -end - -let range (la, ca) (lb, cb) = - let start = Position.create ~line:la ~character:ca - and end_ = Position.create ~line:lb ~character:cb in - Range.create ~start ~end_ -;; - -let zip_shortest_source = - {ocaml| -let rec zip_shortest xs ys = - match (xs, ys) with - | ([], []) | ([], _::_) | (_::_, []) -> _ - | (x::xs, y::ys) -> ((_, _) :: (zip_shortest _ _)) -;; -|ocaml} -;; - -let large_amount_of_holes_source = - {ocaml| - let f () = - (_, _, _, (_, _, _, _, _,), _, _, _, _), - _, _, _, _, (_, _, _), _, _, _, _, _, _ -|ocaml} -;; - -let%expect_test "when there is no hole" = - let source = - {ocaml| -let f = List.map (fun x -> x + 1) [1; 2; 3] -|ocaml} - and direction = `Next - and line = 1 - and character = 1 in - Util.test ~direction ~line ~character source; - [%expect {| null |}] -;; - -let%expect_test "jump to next hole 1" = - let source = zip_shortest_source - and direction = `Next - and line = 4 - and character = 40 in - Util.test ~direction ~line ~character source; - [%expect - {| - { - "end": { "character": 48, "line": 4 }, - "start": { "character": 47, "line": 4 } - } - |}] -;; - -let%expect_test "jump to prev hole 1" = - let source = zip_shortest_source - and direction = `Prev - and line = 4 - and character = 40 in - Util.test ~direction ~line ~character source; - [%expect - {| - { - "end": { "character": 28, "line": 4 }, - "start": { "character": 27, "line": 4 } - } - |}] -;; - -let%expect_test "jump to next hole can wrap" = - let source = zip_shortest_source - and direction = `Next - and line = 5 - and character = 1 in - Util.test ~direction ~line ~character source; - [%expect - {| - { - "end": { "character": 43, "line": 3 }, - "start": { "character": 42, "line": 3 } - } - |}] -;; - -let%expect_test "jump to prev hole can wrap" = - let source = zip_shortest_source - and direction = `Prev - and line = 2 - and character = 20 in - Util.test ~direction ~line ~character source; - [%expect - {| - { - "end": { "character": 50, "line": 4 }, - "start": { "character": 49, "line": 4 } - } - |}] -;; - -let%expect_test "can jump to next hole when on char before current hole" = - let source = zip_shortest_source - and direction = `Next - and line = 4 - and character = 27 in - Util.test ~direction ~line ~character source; - [%expect - {| - { - "end": { "character": 48, "line": 4 }, - "start": { "character": 47, "line": 4 } - } - |}] -;; - -let%expect_test "can jump to next hole when on char after current hole" = - let source = zip_shortest_source - and direction = `Next - and line = 4 - and character = 28 in - Util.test ~direction ~line ~character source; - [%expect - {| - { - "end": { "character": 48, "line": 4 }, - "start": { "character": 47, "line": 4 } - } - |}] -;; - -let%expect_test "can jump to prev hole when on char before current hole" = - let source = zip_shortest_source - and direction = `Prev - and line = 4 - and character = 27 in - Util.test ~direction ~line ~character source; - [%expect - {| - { - "end": { "character": 25, "line": 4 }, - "start": { "character": 24, "line": 4 } - } - |}] -;; - -let%expect_test "can jump to prev hole when on char after current hole" = - let source = zip_shortest_source - and direction = `Prev - and line = 4 - and character = 28 in - Util.test ~direction ~line ~character source; - [%expect - {| - { - "end": { "character": 25, "line": 4 }, - "start": { "character": 24, "line": 4 } - } - |}] -;; - -let%expect_test "next hole in a given range" = - let source = zip_shortest_source - and direction = `Next - and range = range (4, 22) (4, 51) - and line = 4 - and character = 28 in - Util.test ~direction ~range ~line ~character source; - [%expect - {| - { - "end": { "character": 48, "line": 4 }, - "start": { "character": 47, "line": 4 } - } - |}] -;; - -let%expect_test "prev hole in a given range" = - let source = zip_shortest_source - and direction = `Prev - and range = range (4, 22) (4, 51) - and line = 4 - and character = 29 in - Util.test ~direction ~range ~line ~character source; - [%expect - {| - { - "end": { "character": 28, "line": 4 }, - "start": { "character": 27, "line": 4 } - } - |}] -;; - -let%expect_test "next hole in a given range with cursor outside the range" = - let source = zip_shortest_source - and direction = `Next - and range = range (4, 22) (4, 51) - and line = 3 - and character = 1 in - Util.test ~direction ~range ~line ~character source; - [%expect - {| - { - "end": { "character": 25, "line": 4 }, - "start": { "character": 24, "line": 4 } - } - |}] -;; - -let%expect_test "prev hole in a given range with cursor outside the range" = - let source = zip_shortest_source - and direction = `Prev - and range = range (4, 22) (4, 51) - and line = 3 - and character = 1 in - Util.test ~direction ~range ~line ~character source; - [%expect - {| - { - "end": { "character": 50, "line": 4 }, - "start": { "character": 49, "line": 4 } - } - |}] -;; - -let%expect_test "next on the middle" = - let source = large_amount_of_holes_source - and direction = `Next - and range = range (3, 16) (3, 24) - and line = 3 - and character = 20 in - Util.test ~direction ~range ~line ~character source; - [%expect - {| - { - "end": { "character": 24, "line": 3 }, - "start": { "character": 23, "line": 3 } - } - |}] -;; - -let%expect_test "next at the end" = - let source = large_amount_of_holes_source - and direction = `Next - and range = range (3, 16) (3, 24) - and line = 3 - and character = 23 in - Util.test ~direction ~range ~line ~character source; - [%expect - {| - { - "end": { "character": 18, "line": 3 }, - "start": { "character": 17, "line": 3 } - } - |}] -;; diff --git a/ocaml-lsp-server/test/e2e-new/lsp_helpers.ml b/ocaml-lsp-server/test/e2e-new/lsp_helpers.ml index cdb010867..e003ee5e6 100644 --- a/ocaml-lsp-server/test/e2e-new/lsp_helpers.ml +++ b/ocaml-lsp-server/test/e2e-new/lsp_helpers.ml @@ -1,7 +1,5 @@ open Test.Import -let change_config ~client params = Client.notification client (ChangeConfiguration params) - let open_document ~client ~uri ~source = let textDocument = TextDocumentItem.create ~uri ~languageId:"ocaml" ~version:0 ~text:source @@ -11,15 +9,18 @@ let open_document ~client ~uri ~source = (TextDocumentDidOpen (DidOpenTextDocumentParams.create ~textDocument)) ;; -let create_handler_with_diagnostics_callbacks ~got_diagnostics ~diagnostics_callback = - Client.Handler.make ~on_notification:(fun _ -> function - | PublishDiagnostics diagnostics -> - let () = diagnostics_callback diagnostics in - let* diag = Fiber.Ivar.peek got_diagnostics in - (match diag with - | Some _ -> Fiber.return () - | None -> Fiber.Ivar.fill got_diagnostics ()) - | _ -> Fiber.return ()) +let create_handler_with_diagnostics_callback ~got_diagnostics ~diagnostics_callback = + (* Calls [diagnostics_callback] and fills [got_diagnostics] when receiving diagnostics. *) + Client.Handler.make + ~on_notification:(fun _ -> function + | PublishDiagnostics diagnostics -> + diagnostics_callback diagnostics; + let* diag = Fiber.Ivar.peek got_diagnostics in + (match diag with + | Some _ -> Fiber.return () + | None -> Fiber.Ivar.fill got_diagnostics ()) + | _ -> Fiber.return ()) + () ;; let create_client client = @@ -37,7 +38,7 @@ let create_client client = ;; let open_document_with_client ~prep ~path ~source client = - let* _ = Client.initialized client in + let* (_ : InitializeResult.t) = Client.initialized client in let* () = let settings = `Assoc [ "merlinDiagnostics", `Assoc [ "enable", `Bool true ] ] in Client.notification client (ChangeConfiguration { settings }) @@ -48,42 +49,25 @@ let open_document_with_client ~prep ~path ~source client = ;; let iter_lsp_response - ?(prep = fun _ -> Fiber.return ()) - ?(path = "foo.ml") - ~makeRequest - ~source - k + ?(prep = fun _ -> Fiber.return ()) + ?(path = "foo.ml") + ~makeRequest + ~source + k = let got_diagnostics = Fiber.Ivar.create () in let handler = - Client.Handler.make - ~on_notification:(fun _ -> function - | PublishDiagnostics _ -> - let* diag = Fiber.Ivar.peek got_diagnostics in - (match diag with - | Some _ -> Fiber.return () - | None -> Fiber.Ivar.fill got_diagnostics ()) - | _ -> Fiber.return ()) - () + create_handler_with_diagnostics_callback + ~got_diagnostics + ~diagnostics_callback:(fun _ -> ()) in Test.run ~handler @@ fun client -> - let run_client () = - let capabilities = - let window = - let showDocument = ShowDocumentClientCapabilities.create ~support:true in - WindowClientCapabilities.create ~showDocument () - in - ClientCapabilities.create ~window () - in - Client.start client (InitializeParams.create ~capabilities ()) - in + let run_client = create_client client in let run = - let* (_ : InitializeResult.t) = Client.initialized client in - let uri = DocumentUri.of_path path in - let* () = prep client in - let* () = open_document ~client ~uri ~source in + let* () = open_document_with_client ~prep ~path ~source client in let+ resp = + let uri = DocumentUri.of_path path in let request = let textDocument = TextDocumentIdentifier.create ~uri in makeRequest textDocument @@ -97,15 +81,15 @@ let iter_lsp_response ;; let open_document_with_diagnostics_callback - ?(prep = fun _ -> Fiber.return ()) - ?(path = "foo.ml") - ~source - ~diagnostics_callback - () + ?(prep = fun _ -> Fiber.return ()) + ?(path = "foo.ml") + ~source + ~diagnostics_callback + () = let got_diagnostics = Fiber.Ivar.create () in let handler = - create_handler_with_diagnostics_callbacks ~got_diagnostics ~diagnostics_callback () + create_handler_with_diagnostics_callback ~got_diagnostics ~diagnostics_callback in Test.run ~handler @@ fun client -> diff --git a/ocaml-lsp-server/test/e2e-new/lsp_helpers.mli b/ocaml-lsp-server/test/e2e-new/lsp_helpers.mli index 51ffe7287..a51d753b2 100644 --- a/ocaml-lsp-server/test/e2e-new/lsp_helpers.mli +++ b/ocaml-lsp-server/test/e2e-new/lsp_helpers.mli @@ -1,33 +1,30 @@ open Test.Import -(** Send the given configuration to the language server *) -val change_config : client:'a Client.t -> DidChangeConfigurationParams.t -> unit Fiber.t - -(** Opens a document with the language server. This must be done before trying - to access it *) +(** Opens a document with the language server. This must be done before trying to access + it *) val open_document : client:'a Client.t -> uri:DocumentUri.t -> source:string -> unit Fiber.t -(** Performs the request you return from the makeRequest function and then gives - it the the handler function you provide *) +(** Performs the request you return from the makeRequest function and then gives it the + the handler function you provide *) val iter_lsp_response : ?prep:(unit Client.t -> unit Fiber.t) -> ?path:string -> makeRequest:(TextDocumentIdentifier.t -> 'a Client.out_request) -> source:string -> ('a -> unit) - -> unit + -> unit Async.Deferred.t -(** Opens the file in the specified path with source code as specified in src. - This then waits for merlin to send diagnostic info and calls the diagnostics_callback - function with the diagnostics it receives from merlin for the source*) +(* Opens the file in the specified path with source code as specified in src. + This then waits for merlin to send diagnostic info and callls the diagnostics_callback + function with the diagnostics it receives from merlin for the source. *) val open_document_with_diagnostics_callback : ?prep:(unit Client.t -> unit Fiber.t) -> ?path:string -> source:string -> diagnostics_callback:(PublishDiagnosticsParams.t -> unit) -> unit - -> unit + -> unit Async.Deferred.t diff --git a/ocaml-lsp-server/test/e2e-new/merlin_call_compatible.ml b/ocaml-lsp-server/test/e2e-new/merlin_call_compatible.ml index 1059abd1d..17a9b4b30 100644 --- a/ocaml-lsp-server/test/e2e-new/merlin_call_compatible.ml +++ b/ocaml-lsp-server/test/e2e-new/merlin_call_compatible.ml @@ -1,3 +1,4 @@ +open Async open Test.Import module Req = Ocaml_lsp_server.Custom_request.Merlin_call_compatible @@ -27,13 +28,14 @@ let f ({a; b} : t) = assert false|} let+ response = call_merlin_compatible client "case-analysis" args false in Test.print_result response in - Helpers.test source request; + let%map () = Helpers.test source request in [%expect {| { "resultAsSexp": false, "result": "{\"class\":\"return\",\"value\":[{\"start\":{\"line\":2,\"col\":8},\"end\":{\"line\":2,\"col\":9}},\"a = (_, _)\"]}" - } |}] + } + |}] ;; let%expect_test "case-analysis on empty example" = @@ -45,13 +47,14 @@ let%expect_test "case-analysis on empty example" = let () = Test.print_result response in Fiber.return () in - Helpers.test source request; + let%map () = Helpers.test source request in [%expect {| { "resultAsSexp": false, - "result": "{\"class\":\"exception\",\"value\":\"Merlin_analysis.Destruct.Nothing_to_do\"}" - } |}] + "result": "{\"class\":\"exception\",\"value\":\"Merlin_analysis__Destruct.Nothing_to_do\"}" + } + |}] ;; let%expect_test "case-analysis on simple example with result as sexp" = @@ -66,13 +69,14 @@ let f ({a; b} : t) = assert false|} let () = Test.print_result response in Fiber.return () in - Helpers.test source request; + let%map () = Helpers.test source request in [%expect {| { "resultAsSexp": true, "result": "((assoc) (class . \"return\") (value ((assoc) (start (assoc) (line . 2) (col . 8)) (end (assoc) (line . 2) (col . 9))) \"a = (_, _)\"))" - } |}] + } + |}] ;; let%expect_test "errors: warning is shown" = @@ -84,13 +88,14 @@ let%expect_test "errors: warning is shown" = let () = Test.print_result response in Fiber.return () in - Helpers.test source request; + let%map () = Helpers.test source request in [%expect {| { "resultAsSexp": false, "result": "{\"class\":\"return\",\"value\":[{\"start\":{\"line\":1,\"col\":9},\"end\":{\"line\":1,\"col\":39},\"type\":\"warning\",\"sub\":[],\"valid\":true,\"message\":\"Warning 8: this pattern-matching is not exhaustive.\\nHere is an example of a case that is not matched:\\nSome _\"}]}" - } |}] + } + |}] ;; let%expect_test "errors: warning is disabled" = @@ -102,8 +107,7 @@ let%expect_test "errors: warning is disabled" = let () = Test.print_result response in Fiber.return () in - Helpers.test source request; + let%map () = Helpers.test source request in [%expect - {| - { "resultAsSexp": false, "result": "{\"class\":\"return\",\"value\":[]}" } |}] + {| { "resultAsSexp": false, "result": "{\"class\":\"return\",\"value\":[]}" } |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/merlin_jump.ml b/ocaml-lsp-server/test/e2e-new/merlin_jump.ml deleted file mode 100644 index 809dae049..000000000 --- a/ocaml-lsp-server/test/e2e-new/merlin_jump.ml +++ /dev/null @@ -1,139 +0,0 @@ -open Test.Import -module Req = Ocaml_lsp_server.Custom_request.Merlin_jump - -module Util = struct - let call_jump position ?target client = - let uri = DocumentUri.of_path "test.ml" in - let params = - Req.Request_params.create ~uri ~position ~target - |> Req.Request_params.yojson_of_t - |> Jsonrpc.Structured.t_of_yojson - |> Option.some - in - let req = Lsp.Client_request.UnknownRequest { meth = "ocamllsp/jump"; params } in - Client.request client req - ;; - - let test ~line ~character ~source ?target () = - let position = Position.create ~character ~line in - let request client = - let open Fiber.O in - let+ response = call_jump position client ?target in - Test.print_result response - in - Helpers.test source request - ;; -end - -let%expect_test "Get all jumps including the next match case" = - let source = - {| -let find_vowel x = -match x with -| 'A' -> true -| 'E' -> true -| 'I' -> true -| 'O' -> true -| 'U' -> true -| _ -> false -|} - in - let line = 3 in - let character = 2 in - Util.test ~line ~character ~source (); - [%expect - {| - { - "jumps": [ - { "target": "fun", "position": { "character": 0, "line": 1 } }, - { "target": "match", "position": { "character": 0, "line": 2 } }, - { "target": "let", "position": { "character": 0, "line": 1 } }, - { - "target": "match-next-case", - "position": { "character": 2, "line": 4 } - } - ] - } |}] -;; - -let%expect_test "Get location of the next match case" = - let source = - {| -let find_vowel x = -match x with -| 'A' -> true -| 'E' -> true -| 'I' -> true -| 'O' -> true -| 'U' -> true -| _ -> false -|} - in - let line = 3 in - let character = 2 in - Util.test ~line ~character ~source ~target:"match-next-case" (); - [%expect - {| - { - "jumps": [ - { - "target": "match-next-case", - "position": { "character": 2, "line": 4 } - } - ] - } - |}] -;; - -let%expect_test "Get location of a the module" = - let source = - {|type a = Foo | Bar - -module A = struct - let f () = 10 - let g = Bar - let h x = x - - module B = struct - type b = Baz - - let x = (Baz, 10) - let y = (Bar, Foo) - end - - type t = { a : string; b : float } - - let z = { a = "Hello"; b = 1.0 } -end|} - in - let line = 10 in - let character = 3 in - Util.test ~line ~character ~source (); - [%expect - {| - { - "jumps": [ - { "target": "module", "position": { "character": 2, "line": 7 } } - ] - } |}] -;; - -let%expect_test "Same line should output no locations" = - let source = {|let x = 5 |} in - let line = 1 in - let character = 5 in - Util.test ~line ~character ~source (); - [%expect {| { "jumps": [] } |}] -;; - -let%expect_test "Ask for a non-existing target" = - let source = - {| -let find_vowel x = () -|} - in - let line = 1 in - let character = 2 in - Util.test ~line ~character ~source ~target:"notatarget" (); - [%expect {| { "jumps": [] } |}] -;; diff --git a/ocaml-lsp-server/test/e2e-new/metrics.ml b/ocaml-lsp-server/test/e2e-new/metrics.ml deleted file mode 100644 index ae74c5ff8..000000000 --- a/ocaml-lsp-server/test/e2e-new/metrics.ml +++ /dev/null @@ -1,52 +0,0 @@ -open Test.Import - -let%expect_test "metrics" = - let handler = - let on_request (type r) _ (r : r Lsp.Server_request.t) - : (r Lsp_fiber.Rpc.Reply.t * unit) Fiber.t - = - match r with - | ShowDocumentRequest p -> - print_endline "client: received show document params"; - let json = - ShowDocumentParams.yojson_of_t { p with uri = Uri.of_path "" } - in - Yojson.Safe.to_channel stdout json; - print_endline ""; - print_endline "metrics contents:"; - print_endline (Stdune.Io.String_path.read_file (Uri.to_path p.uri)); - let res = ShowDocumentResult.create ~success:true in - Fiber.return (Lsp_fiber.Rpc.Reply.now res, ()) - | _ -> assert false - in - let on_request = { Client.Handler.on_request } in - let on_notification (_ : _ Client.t) (_ : Client.in_notification) = - (* ignore notifications *) - Fiber.return () - in - Client.Handler.make ~on_request ~on_notification () - in - (Test.run ~handler - @@ fun client -> - let run_client () = - let capabilities = ClientCapabilities.create () in - Client.start client (InitializeParams.create ~capabilities ()) - in - let run = - let* (_ : InitializeResult.t) = Client.initialized client in - let view_metrics = ExecuteCommandParams.create ~command:"ocamllsp/view-metrics" () in - let+ res = Client.request client (ExecuteCommand view_metrics) in - print_endline "server: receiving response"; - Yojson.Safe.to_channel stdout res; - print_endline "" - in - Fiber.fork_and_join_unit run_client (fun () -> run >>> Client.stop client)); - [%expect - {| - client: received show document params - {"takeFocus":true,"uri":"file:///%3Credacted%3E"} - metrics contents: - {"traceEvents":[]} - server: receiving response - null |}] -;; diff --git a/ocaml-lsp-server/test/e2e-new/semantic_hl_helpers.ml b/ocaml-lsp-server/test/e2e-new/semantic_hl_helpers.ml index c5acb0f92..afa97a8e2 100644 --- a/ocaml-lsp-server/test/e2e-new/semantic_hl_helpers.ml +++ b/ocaml-lsp-server/test/e2e-new/semantic_hl_helpers.ml @@ -34,10 +34,10 @@ let modifiers ~(legend : string array) (encoded_mods : int) = ;; let annotate_src_with_tokens - ~(legend : SemanticTokensLegend.t) - ~(encoded_tokens : int array) - ~(annot_mods : bool) - (src : string) + ~(legend : SemanticTokensLegend.t) + ~(encoded_tokens : int array) + ~(annot_mods : bool) + (src : string) : string = let token_types = legend.SemanticTokensLegend.tokenTypes |> Array.of_list in @@ -111,5 +111,6 @@ let jar = dar|} [%expect {| let foo = bar - let jar = dar |}] + let jar = dar + |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/semantic_hl_tests.ml b/ocaml-lsp-server/test/e2e-new/semantic_hl_tests.ml index 49c7b60b9..345a47997 100644 --- a/ocaml-lsp-server/test/e2e-new/semantic_hl_tests.ml +++ b/ocaml-lsp-server/test/e2e-new/semantic_hl_tests.ml @@ -1,3 +1,4 @@ +open Async open Test.Import let semantic_tokens_full_debug = "ocamllsp/textDocument/semanticTokens/full" @@ -80,21 +81,21 @@ let test src:string -> (SemanticTokensParams.t -> resp Client.out_request) -> (resp req_ctx -> unit Fiber.t) - -> unit + -> unit Deferred.t = fun ~src req consume_resp -> let wait_for_diagnostics = Fiber.Ivar.create () in let handler = Client.Handler.make ~on_notification:(fun client -> function - | Lsp.Server_notification.PublishDiagnostics _ -> - (* we don't want to close the connection from client-side before we + | Lsp.Server_notification.PublishDiagnostics _ -> + (* we don't want to close the connection from client-side before we process diagnostics arrived on the channel. TODO: would a better solution be to simply flush on closing the connection because now semantic tokens tests is coupled to diagnostics *) - let+ () = Fiber.Ivar.fill wait_for_diagnostics () in - Client.state client - | _ -> Fiber.return ()) + let+ () = Fiber.Ivar.fill wait_for_diagnostics () in + Client.state client + | _ -> Fiber.return ()) () in Test.run ~handler (fun client -> @@ -103,6 +104,10 @@ let test in let run () = let* (initializeResult : InitializeResult.t) = Client.initialized client in + let* () = + let settings = `Assoc [ "merlinDiagnostics", `Assoc [ "enable", `Bool true ] ] in + Client.notification client (ChangeConfiguration { settings }) + in let uri = DocumentUri.of_path "test.ml" in let textDocument = TextDocumentItem.create ~uri ~languageId:"ocaml" ~version:0 ~text:src @@ -154,8 +159,9 @@ let test_semantic_tokens_full src = test ~src (fun p -> SemanticTokensFull p) print_resp ;; +(* This test hangs in external builds; skipping for now. let%expect_test "tokens for ocaml_lsp_server.ml" = - test_semantic_tokens_full Semantic_hl_data.src0; + let%map.Deferred () = test_semantic_tokens_full Semantic_hl_data.src0 in [%expect {| module Moo : sig @@ -208,24 +214,27 @@ let%expect_test "tokens for ocaml_lsp_server.ml" = { foo : Moo.t ; bar : int } - end) |}] + end) + |}] ;; +*) let test_semantic_tokens_full_debug src = test ~src (fun p -> - UnknownRequest - { meth = semantic_tokens_full_debug - ; params = - Some (SemanticTokensParams.yojson_of_t p |> Jsonrpc.Structured.t_of_yojson) - }) + UnknownRequest + { meth = semantic_tokens_full_debug + ; params = + Some (SemanticTokensParams.yojson_of_t p |> Jsonrpc.Structured.t_of_yojson) + }) (fun { resp; _ } -> - resp |> Yojson.Safe.pretty_to_string ~std:false |> print_endline |> Fiber.return) + resp |> Yojson.Safe.pretty_to_string ~std:false |> print_endline |> Fiber.return) ;; +(* This test hangs in external builds; skipping for now. let%expect_test "tokens for ocaml_lsp_server.ml" = - test_semantic_tokens_full_debug Semantic_hl_data.src0; + let%map.Deferred () = test_semantic_tokens_full_debug Semantic_hl_data.src0 in [%expect {| [ @@ -667,28 +676,34 @@ let%expect_test "tokens for ocaml_lsp_server.ml" = "type": "type", "modifiers": [] } - ] |}] + ] + |}] ;; +*) let%expect_test "highlighting longidents with space between identifiers" = - test_semantic_tokens_full - @@ String.trim - {| + let%map.Deferred () = + test_semantic_tokens_full + @@ String.trim + {| let foo = Bar.jar let joo = Bar. jar - |}; + |} + in [%expect {| let foo = Bar.jar - let joo = Bar. jar |}] + let joo = Bar. jar + |}] ;; let%expect_test "highlighting longidents with space between identifiers and infix fns" = - test_semantic_tokens_full - @@ String.trim - {| + let%map.Deferred () = + test_semantic_tokens_full + @@ String.trim + {| Bar.(+) ;; Bar.( + ) ;; @@ -696,7 +711,8 @@ Bar.( + ) ;; Bar. (+) ;; Bar. ( + ) ;; - |}; + |} + in [%expect {| Bar.(+) ;; @@ -705,50 +721,96 @@ Bar. ( + ) ;; Bar. (+) ;; - Bar. ( + ) ;; |}] + Bar. ( + ) ;; + |}] ;; let%expect_test "longidents in records" = - test_semantic_tokens_full - @@ String.trim - {| + let%map.Deferred () = + test_semantic_tokens_full + @@ String.trim + {| module M = struct type r = { foo : int ; bar : string } end let x = { M . foo = 0 ; bar = "bar"} - |}; + |} + in [%expect {| module M = struct type r = { foo : int ; bar : string } end - let x = { M . foo = 0 ; bar = "bar"} |}] + let x = { M . foo = 0 ; bar = "bar"} + |}] +;; + +let%expect_test "ppx_string highlighting" = + (* Demonstates highlighting of interpolated ints, floats, identifiers, function + applications, polymorphic variants, and field acceses. Also shows that interpolated + highlighting is not applied in the presence of escaped quotes, since ppxlib doesn't + provide precise locations in that case. *) + let%map.Deferred () = + test_semantic_tokens_full + @@ String.trim + {| +open Core + +let x = 10 +let a = "17" +let s1 = [%string "x = %{x#Int}"] +let s2 = [%string "%{s1} is a string"] +let s2 = [%string "\"%{s1}\" is a string"] +let s3 = [%string "y = %{max (x + 2) (Int.of_string a)#Int}"] +let s4 = [%string "%{((x, 17.2), Some 42, None)#Foo}"] +let s5 = [%string "%{`A (x + x)#Bar} %{q.field1 ^ q.field2}"] + |} + in + [%expect + {| + open Core + + let x = 10 + let a = "17" + let s1 = [%string "x = %{x#Int}"] + let s2 = [%string "%{s1} is a string"] + let s2 = [%string "\"%{s1}\" is a string"] + let s3 = [%string "y = %{max (x + 2) (Int.of_string a)#Int}"] + let s4 = [%string "%{((x, 17.2), Some 42, None)#Foo}"] + let s5 = [%string "%{`A (x + x)#Bar} %{q.field1 ^ q.field2}"] + |}] ;; let%expect_test "operators" = - test_semantic_tokens_full - @@ String.trim - {| + let%map () = + test_semantic_tokens_full + @@ String.trim + {| let x = 1.0 *. 2.0 let y = 1 * 2 let z = 0 >>= 1 - |}; + |} + in [%expect {| let x = 1.0 *. 2.0 let y = 1 * 2 - let z = 0 >>= 1 |}] + let z = 0 >>= 1 + |}] ;; let%expect_test "comment in unit" = - test_semantic_tokens_full - @@ String.trim - {| + let%map () = + test_semantic_tokens_full + @@ String.trim + {| let y = (* comment *) 0 let x = ((* comment *)) let ((*comment*)) = () - |}; + |} + in [%expect {| let y = (* comment *) 0 let x = ((* comment *)) - let ((*comment*)) = () |}] + let ((*comment*)) = () + |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/start_stop.ml b/ocaml-lsp-server/test/e2e-new/start_stop.ml deleted file mode 100644 index f369cf4a1..000000000 --- a/ocaml-lsp-server/test/e2e-new/start_stop.ml +++ /dev/null @@ -1,146 +0,0 @@ -open Test.Import - -let%expect_test "start/stop" = - let notifs = Queue.create () in - let handler_collecting_notifs = - Client.Handler.make - ~on_notification:(fun _ notif -> Queue.push notifs notif |> Fiber.return) - () - in - (Test.run ~handler:handler_collecting_notifs - @@ fun client -> - let run_client () = - let capabilities = - let window = - let showDocument = ShowDocumentClientCapabilities.create ~support:true in - WindowClientCapabilities.create ~showDocument () - in - let textDocument = - let codeAction = - let codeActionLiteralSupport = - let codeActionKind = - CodeActionClientCapabilities.create_codeActionKind ~valueSet:[] - in - CodeActionClientCapabilities.create_codeActionLiteralSupport ~codeActionKind - in - CodeActionClientCapabilities.create ~codeActionLiteralSupport () - in - TextDocumentClientCapabilities.create ~codeAction () - in - ClientCapabilities.create ~window ~textDocument () - in - Client.start client (InitializeParams.create ~capabilities ()) - in - let print_init = - let+ resp = Client.initialized client in - print_endline "client: server initialized with:"; - InitializeResult.yojson_of_t resp - |> Yojson.Safe.pretty_to_string ~std:false - |> print_endline - in - let run = - let* () = print_init in - print_endline "client: shutting down server"; - Client.request client Shutdown - in - Fiber.fork_and_join_unit run_client (fun () -> run >>> Client.stop client)); - print_endline "\nnotifications received:"; - Queue.iter notifs ~f:(fun notif -> - Lsp.Server_notification.to_jsonrpc notif - |> Jsonrpc.Notification.yojson_of_t - |> Yojson.Safe.pretty_to_string - |> print_endline); - [%expect - {| - client: server initialized with: - { - "capabilities": { - "codeActionProvider": { - "codeActionKinds": [ - "quickfix", "refactor.inline", "construct", - "destruct (enumerate cases)", "inferred_intf", - "put module name in identifiers", - "remove module name from identifiers", "remove type annotation", - "type-annotate" - ] - }, - "codeLensProvider": { "resolveProvider": false }, - "completionProvider": { - "resolveProvider": true, - "triggerCharacters": [ ".", "#" ] - }, - "declarationProvider": true, - "definitionProvider": true, - "documentFormattingProvider": true, - "documentHighlightProvider": true, - "documentSymbolProvider": true, - "executeCommandProvider": { - "commands": [ - "ocamllsp/view-metrics", "ocamllsp/open-related-source", - "ocamllsp/merlin-jump-to-target", "ocamllsp/show-document-text", - "ocamllsp/show-merlin-config", "dune/promote" - ] - }, - "experimental": { - "ocamllsp": { - "interfaceSpecificLangId": true, - "handleSwitchImplIntf": true, - "handleInferIntf": true, - "handleTypedHoles": true, - "handleJumpToTypedHole": true, - "handleWrappingAstNode": true, - "diagnostic_promotions": true, - "handleHoverExtended": true, - "handleMerlinCallCompatible": true, - "handleTypeEnclosing": true, - "handleGetDocumentation": true, - "handleConstruct": true, - "handleTypeSearch": true, - "handleJump": true - } - }, - "foldingRangeProvider": true, - "hoverProvider": true, - "inlayHintProvider": true, - "referencesProvider": true, - "renameProvider": { "prepareProvider": true }, - "selectionRangeProvider": true, - "semanticTokensProvider": { - "full": { "delta": true }, - "legend": { - "tokenModifiers": [ - "declaration", "definition", "readonly", "static", "deprecated", - "abstract", "async", "modification", "documentation", - "defaultLibrary" - ], - "tokenTypes": [ - "namespace", "type", "class", "enum", "interface", "struct", - "typeParameter", "parameter", "variable", "property", "enumMember", - "event", "function", "method", "macro", "keyword", "modifier", - "comment", "string", "number", "regexp", "operator", "decorator" - ] - } - }, - "signatureHelpProvider": { - "triggerCharacters": [ " ", "~", "?", ":", "(" ] - }, - "textDocumentSync": { - "change": 2, - "openClose": true, - "save": { "includeText": false }, - "willSave": false, - "willSaveWaitUntil": false - }, - "typeDefinitionProvider": true, - "workspace": { - "workspaceFolders": { "changeNotifications": true, "supported": true } - }, - "workspaceSymbolProvider": true - }, - "serverInfo": { "name": "ocamllsp", "version": "dev" } - } - client: shutting down server - - notifications received: - |}] -;; diff --git a/ocaml-lsp-server/test/e2e-new/syntax_doc_tests.ml b/ocaml-lsp-server/test/e2e-new/syntax_doc_tests.ml index 35bdcddc1..d82288a61 100644 --- a/ocaml-lsp-server/test/e2e-new/syntax_doc_tests.ml +++ b/ocaml-lsp-server/test/e2e-new/syntax_doc_tests.ml @@ -1,6 +1,7 @@ open! Test.Import -open Lsp_helpers +open Async +let change_config client params = Client.notification client (ChangeConfiguration params) let uri = DocumentUri.of_path "test.ml" let create_postion line character = Position.create ~line ~character @@ -69,13 +70,13 @@ type color = Red|Blue in let position = create_postion 1 9 in let req client = - let* () = change_config ~client activate_syntax_doc in + let* () = change_config client activate_syntax_doc in let* resp = hover_req client position in let () = print_hover resp in Fiber.return () in let (_ : string) = [%expect.output] in - run_test source req; + let%map () = run_test source req in [%expect {| { @@ -87,7 +88,8 @@ type color = Red|Blue "end": { "character": 21, "line": 1 }, "start": { "character": 0, "line": 1 } } - } |}] + } + |}] ;; let%expect_test "syntax doc should not display" = @@ -98,12 +100,12 @@ type color = Red|Blue in let position = create_postion 1 9 in let req client = - let* () = change_config ~client deactivate_syntax_doc in + let* () = change_config client deactivate_syntax_doc in let* resp = hover_req client position in let () = print_hover resp in Fiber.return () in - run_test source req; + let%map () = run_test source req in [%expect {| { @@ -112,7 +114,8 @@ type color = Red|Blue "end": { "character": 21, "line": 1 }, "start": { "character": 0, "line": 1 } } - } |}] + } + |}] ;; let%expect_test "syntax doc should print" = @@ -123,12 +126,12 @@ type t = .. in let position = create_postion 1 5 in let req client = - let* () = change_config ~client activate_syntax_doc in + let* () = change_config client activate_syntax_doc in let* resp = hover_req client position in let () = print_hover resp in Fiber.return () in - run_test source req; + let%map () = run_test source req in [%expect {| { @@ -140,7 +143,8 @@ type t = .. "end": { "character": 11, "line": 1 }, "start": { "character": 0, "line": 1 } } - } |}] + } + |}] ;; let%expect_test "should receive no hover response" = @@ -151,11 +155,11 @@ let%expect_test "should receive no hover response" = in let position = create_postion 1 5 in let req client = - let* () = change_config ~client activate_syntax_doc in + let* () = change_config client activate_syntax_doc in let* resp = hover_req client position in let () = print_hover resp in Fiber.return () in - run_test source req; + let%map () = run_test source req in [%expect {| no hover response |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/test.ml b/ocaml-lsp-server/test/e2e-new/test.ml index 849657bd0..9b28a48a3 100644 --- a/ocaml-lsp-server/test/e2e-new/test.ml +++ b/ocaml-lsp-server/test/e2e-new/test.ml @@ -74,23 +74,31 @@ module T : sig : ?extra_env:string list -> ?handler:unit Client.Handler.t -> (unit Client.t -> 'a Fiber.t) - -> Unix.process_status * 'a + -> (Unix.process_status * 'a) Async.Deferred.t val run : ?extra_env:string list -> ?handler:unit Client.Handler.t -> (unit Client.t -> 'a Fiber.t) - -> 'a + -> 'a Async.Deferred.t end = struct let _PATH = Bin.parse_path (Option.value ~default:"" @@ Env.get Env.initial "PATH") let bin = Bin.which "ocamllsp" ~path:_PATH |> Option.value_exn |> Path.to_string + let add_testing_framework env = + (* [am_running_test] checks for the presence of the TESTING_FRAMEWORK environment + variable. When building with external dune, we have to add it manually. *) + if Array.exists env ~f:(fun v -> String.starts_with v ~prefix:"TESTING_FRAMEWORK") + then env + else Array.append env [| "TESTING_FRAMEWORK=unknown" |] + ;; + let run_with_status ?(extra_env = []) ?handler f = let stdin_i, stdin_o = Unix.pipe ~cloexec:true () in let stdout_i, stdout_o = Unix.pipe ~cloexec:true () in let pid = let env = - let current = Unix.environment () in + let current = Unix.environment () |> add_testing_framework in Array.to_list current @ extra_env |> Spawn.Env.of_list in Spawn.spawn ~env ~prog:bin ~argv:[ bin ] ~stdin:stdin_i ~stdout:stdout_o () @@ -104,7 +112,7 @@ end = struct in let init = let blockity = - if Sys.win32 + if Stdlib.Sys.win32 then `Blocking else ( Unix.set_nonblock stdout_i; @@ -129,32 +137,36 @@ end = struct let cancelled = ref false in Fiber.fork_and_join_unit (fun () -> - Lev_fiber.Timer.Wheel.await timeout - >>| function - | `Cancelled -> () - | `Ok -> - Unix.kill pid Sys.sigkill; - cancelled := true) + Lev_fiber.Timer.Wheel.await timeout + >>| function + | `Cancelled -> () + | `Ok -> + Unix.kill pid Stdlib.Sys.sigkill; + cancelled := true) (fun () -> - let* (server_exit_status : Unix.process_status) = Lev_fiber.waitpid ~pid in - let+ () = - if !cancelled then Fiber.return () else Lev_fiber.Timer.Wheel.cancel timeout - in - server_exit_status) + let* (server_exit_status : Unix.process_status) = Lev_fiber.waitpid ~pid in + let+ () = + if !cancelled then Fiber.return () else Lev_fiber.Timer.Wheel.cancel timeout + in + server_exit_status) in - Lev_fiber.run (fun () -> - let* wheel = Lev_fiber.Timer.Wheel.create ~delay:3.0 in - let+ res = init - and+ status = - Fiber.fork_and_join_unit - (fun () -> Lev_fiber.Timer.Wheel.run wheel) - (fun () -> waitpid wheel) - in - status, res) - |> Lev_fiber.Error.ok_exn + let fiber = + Fiber.of_thunk (fun () -> + let* wheel = Lev_fiber.Timer.Wheel.create ~delay:3.0 in + let+ res = init + and+ status = + Fiber.fork_and_join_unit + (fun () -> Lev_fiber.Timer.Wheel.run wheel) + (fun () -> waitpid wheel) + in + status, res) + in + Fiber_async.deferred_of_fiber fiber () ;; - let run ?extra_env ?handler f = snd @@ run_with_status ?extra_env ?handler f + let run ?extra_env ?handler f = + Async.Deferred.map (run_with_status ?extra_env ?handler f) ~f:snd + ;; end include T diff --git a/ocaml-lsp-server/test/e2e-new/type_enclosing.ml b/ocaml-lsp-server/test/e2e-new/type_enclosing.ml index 246dc58e6..525a29f1c 100644 --- a/ocaml-lsp-server/test/e2e-new/type_enclosing.ml +++ b/ocaml-lsp-server/test/e2e-new/type_enclosing.ml @@ -1,3 +1,4 @@ +open Async open Test.Import module Req = Ocaml_lsp_server.Custom_request.Type_enclosing @@ -42,7 +43,7 @@ let%expect_test "Application of function without range end" = and character = 0 and verbosity = 0 and index = 0 in - Util.test ~verbosity ~index ~line ~character source; + let%map () = Util.test ~verbosity ~index ~line ~character source in [%expect {| { @@ -62,12 +63,12 @@ let%expect_test "Application of function without range end" = } ], "type": "int -> string" - } |}] + } + |}] ;; -let%expect_test - "Application of function with range end (including the current enclosing) it should \ - not change the result" +let%expect_test "Application of function with range end (including the current \ + enclosing) it should not change the result" = let source = "string_of_int 42" in let line = 0 @@ -75,7 +76,7 @@ let%expect_test and range_end = 13, 0 and verbosity = 0 and index = 0 in - Util.test ~range_end ~verbosity ~index ~line ~character source; + let%map () = Util.test ~range_end ~verbosity ~index ~line ~character source in [%expect {| { @@ -95,7 +96,8 @@ let%expect_test } ], "type": "int -> string" - } |}] + } + |}] ;; let%expect_test "Application of function with range end (excluding the current enclosing)" @@ -106,7 +108,7 @@ let%expect_test "Application of function with range end (excluding the current e and range_end = 14, 0 and verbosity = 0 and index = 0 in - Util.test ~range_end ~verbosity ~index ~line ~character source; + let%map () = Util.test ~range_end ~verbosity ~index ~line ~character source in [%expect {| { @@ -118,11 +120,11 @@ let%expect_test "Application of function with range end (excluding the current e } ], "type": "string" - } |}] + } + |}] ;; -let%expect_test - {| +let%expect_test {| The cursor is positioned on [x]. We expect to have the type [string] and no other enclosings @@ -135,7 +137,7 @@ let%expect_test and character = 4 and verbosity = 0 and index = 0 in - Util.test ~verbosity ~index ~line ~character source; + let%map () = Util.test ~verbosity ~index ~line ~character source in [%expect {| { @@ -147,11 +149,11 @@ let%expect_test } ], "type": "string" - } |}] + } + |}] ;; -let%expect_test - {| +let%expect_test {| The cursor is positioned on [string_of_int] and we do not give a range. |} = @@ -160,7 +162,7 @@ let%expect_test and character = 8 and verbosity = 0 and index = 0 in - Util.test ~verbosity ~index ~line ~character source; + let%map () = Util.test ~verbosity ~index ~line ~character source in [%expect {| { @@ -180,11 +182,11 @@ let%expect_test } ], "type": "int -> string" - } |}] + } + |}] ;; -let%expect_test - {| +let%expect_test {| The cursor is positioned on [2002]. We expect to have the type [int] and to have two enclosings: @@ -198,7 +200,7 @@ let%expect_test and character = 23 and verbosity = 0 and index = 0 in - Util.test ~verbosity ~index ~line ~character source; + let%map () = Util.test ~verbosity ~index ~line ~character source in [%expect {| { @@ -214,11 +216,11 @@ let%expect_test } ], "type": "int" - } |}] + } + |}] ;; -let%expect_test - {| +let%expect_test {| The cursor is still positioned on [2002] but we ask for the index [1] (the second enclosing). @@ -234,7 +236,7 @@ let%expect_test and character = 23 and verbosity = 0 and index = 1 in - Util.test ~verbosity ~line ~character ~index source; + let%map () = Util.test ~verbosity ~line ~character ~index source in [%expect {| { @@ -250,11 +252,11 @@ let%expect_test } ], "type": "string" - } |}] + } + |}] ;; -let%expect_test - {| +let%expect_test {| First, let's locate on [A.z], we expect the type [t], but we will increase the verbosity in order to get the full expansion of [type t]. And we will have 3 enclosings: @@ -287,7 +289,7 @@ end|} and character = 6 and verbosity = 1 and index = 0 in - Util.test ~verbosity ~index ~line ~character source; + let%map () = Util.test ~verbosity ~index ~line ~character source in [%expect {| { @@ -307,11 +309,11 @@ end|} } ], "type": "type t = { a : string; b : float; }" - } |}] + } + |}] ;; -let%expect_test - {| +let%expect_test {| Now, let's use our enclosing to jump to the index [2], in order to get the type of [module A], our enclosings will no change. 0 : [16:06 - 16:07], the [z] expr. @@ -343,7 +345,7 @@ end|} and character = 6 and verbosity = 0 and index = 2 in - Util.test ~verbosity ~line ~character ~index source; + let%map () = Util.test ~verbosity ~line ~character ~index source in [%expect {| { @@ -363,11 +365,11 @@ end|} } ], "type": "sig\n val f : unit -> int\n val g : a\n val h : 'a -> 'a\n module B : sig type b = Baz val x : b * int val y : a * a end\n type t = { a : string; b : float; }\n val z : t\nend" - } |}] + } + |}] ;; -let%expect_test - {| +let%expect_test {| Now, let's jump on the [10] inside of [A.B.x]. We expect to have the type [int]. And we get a huge list of enclosings! 0. [10:18 - 10:20] the [10] expr. @@ -401,7 +403,7 @@ end|} and character = 18 and verbosity = 0 and index = 0 in - Util.test ~verbosity ~index ~line ~character source; + let%map () = Util.test ~verbosity ~index ~line ~character source in [%expect {| { @@ -433,11 +435,11 @@ end|} } ], "type": "int" - } |}] + } + |}] ;; -let%expect_test - {| +let%expect_test {| Now, let's jump on the [10] inside of [A.B.x] and ask for index [1]. We expect to have the type [b * int]. And we keep our list of enclosings! 0. [10:18 - 10:20] the [10] expr. @@ -471,7 +473,7 @@ end|} and character = 18 and verbosity = 0 and index = 1 in - Util.test ~verbosity ~index ~line ~character source; + let%map () = Util.test ~verbosity ~index ~line ~character source in [%expect {| { @@ -503,5 +505,6 @@ end|} } ], "type": "b * int" - } |}] + } + |}] ;; diff --git a/ocaml-lsp-server/test/e2e-new/type_search.ml b/ocaml-lsp-server/test/e2e-new/type_search.ml deleted file mode 100644 index 58758ccd7..000000000 --- a/ocaml-lsp-server/test/e2e-new/type_search.ml +++ /dev/null @@ -1,238 +0,0 @@ -open Test.Import -module Req = Ocaml_lsp_server.Custom_request.Type_search - -module Util = struct - let call_search position query with_doc doc_format client = - let uri = DocumentUri.of_path "test.ml" in - let text_document = TextDocumentIdentifier.create ~uri in - let params = - Req.Request_params.create text_document position 3 query with_doc doc_format - |> Req.Request_params.yojson_of_t - |> Jsonrpc.Structured.t_of_yojson - |> Option.some - in - let req = - Lsp.Client_request.UnknownRequest { meth = "ocamllsp/typeSearch"; params } - in - Client.request client req - ;; - - let test ~line ~character ~query source ~with_doc ?(doc_format = None) () = - let position = Position.create ~character ~line in - let request client = - let open Fiber.O in - let+ response = call_search position query with_doc doc_format client in - Test.print_result response - in - Helpers.test source request - ;; -end - -let%expect_test - "Polarity Search for a simple query that takes an int and returns a string with \ - documentation" - = - let source = "" in - let line = 1 in - let character = 0 in - let doc_format = Some MarkupKind.Markdown in - Util.test ~line ~character ~query:"-int +string" source ~with_doc:true ~doc_format (); - [%expect - {| - [ - { - "name": "Int.to_string", - "typ": "int -> string", - "loc": { - "end": { "character": 29, "line": 152 }, - "start": { "character": 0, "line": 152 } - }, - "doc": { - "kind": "markdown", - "value": "`to_string x` is the written representation of `x` in decimal." - }, - "cost": 4, - "constructible": "Int.to_string _" - }, - { - "name": "string_of_int", - "typ": "int -> string", - "loc": { - "end": { "character": 33, "line": 740 }, - "start": { "character": 0, "line": 740 } - }, - "doc": { - "kind": "markdown", - "value": "Return the string representation of an integer, in decimal." - }, - "cost": 4, - "constructible": "string_of_int _" - }, - { - "name": "string_of_int", - "typ": "int -> string", - "loc": { - "end": { "character": 33, "line": 740 }, - "start": { "character": 0, "line": 740 } - }, - "doc": { - "kind": "markdown", - "value": "Return the string representation of an integer, in decimal." - }, - "cost": 4, - "constructible": "string_of_int _" - } - ] - |}] -;; - -let%expect_test - "Polarity Search for a simple query that takes an int and returns a string with no \ - documentation" - = - let source = "" in - let line = 1 in - let character = 0 in - Util.test ~line ~character ~query:"-int +string" source ~with_doc:false (); - [%expect - {| - [ - { - "name": "Int.to_string", - "typ": "int -> string", - "loc": { - "end": { "character": 29, "line": 152 }, - "start": { "character": 0, "line": 152 } - }, - "doc": null, - "cost": 4, - "constructible": "Int.to_string _" - }, - { - "name": "string_of_int", - "typ": "int -> string", - "loc": { - "end": { "character": 33, "line": 740 }, - "start": { "character": 0, "line": 740 } - }, - "doc": null, - "cost": 4, - "constructible": "string_of_int _" - }, - { - "name": "string_of_int", - "typ": "int -> string", - "loc": { - "end": { "character": 33, "line": 740 }, - "start": { "character": 0, "line": 740 } - }, - "doc": null, - "cost": 4, - "constructible": "string_of_int _" - } - ] |}] -;; - -let%expect_test - "Type Search for a simple query that takes an int and returns a string with no \ - documentation" - = - let source = "" in - let line = 1 in - let character = 0 in - Util.test ~line ~character ~query:"int -> string" source ~with_doc:false (); - [%expect - {| - [ - { - "name": "Int.to_string", - "typ": "int -> string", - "loc": { - "end": { "character": 29, "line": 152 }, - "start": { "character": 0, "line": 152 } - }, - "doc": null, - "cost": 0, - "constructible": "Int.to_string _" - }, - { - "name": "string_of_int", - "typ": "int -> string", - "loc": { - "end": { "character": 33, "line": 740 }, - "start": { "character": 0, "line": 740 } - }, - "doc": null, - "cost": 0, - "constructible": "string_of_int _" - }, - { - "name": "string_of_int", - "typ": "int -> string", - "loc": { - "end": { "character": 33, "line": 740 }, - "start": { "character": 0, "line": 740 } - }, - "doc": null, - "cost": 0, - "constructible": "string_of_int _" - } - ] |}] -;; - -let%expect_test - "Type Search for a simple query that takes an int and returns a string with \ - documentation" - = - let source = "" in - let line = 1 in - let character = 0 in - Util.test ~line ~character ~query:"int -> string" source ~with_doc:true (); - [%expect - {| - [ - { - "name": "Int.to_string", - "typ": "int -> string", - "loc": { - "end": { "character": 29, "line": 152 }, - "start": { "character": 0, "line": 152 } - }, - "doc": { - "kind": "plaintext", - "value": "[to_string x] is the written representation of [x] in decimal." - }, - "cost": 0, - "constructible": "Int.to_string _" - }, - { - "name": "string_of_int", - "typ": "int -> string", - "loc": { - "end": { "character": 33, "line": 740 }, - "start": { "character": 0, "line": 740 } - }, - "doc": { - "kind": "plaintext", - "value": "Return the string representation of an integer, in decimal." - }, - "cost": 0, - "constructible": "string_of_int _" - }, - { - "name": "string_of_int", - "typ": "int -> string", - "loc": { - "end": { "character": 33, "line": 740 }, - "start": { "character": 0, "line": 740 } - }, - "doc": { - "kind": "plaintext", - "value": "Return the string representation of an integer, in decimal." - }, - "cost": 0, - "constructible": "string_of_int _" - } - ] - |}] -;; diff --git a/ocaml-lsp-server/test/e2e-new/with_pp.ml b/ocaml-lsp-server/test/e2e-new/with_pp.ml deleted file mode 100644 index 88b97e24c..000000000 --- a/ocaml-lsp-server/test/e2e-new/with_pp.ml +++ /dev/null @@ -1,72 +0,0 @@ -open! Test.Import - -let path = Filename.concat (Sys.getcwd ()) "for_pp.ml" -let uri = DocumentUri.of_path path - -let print_hover hover = - match hover with - | None -> print_endline "no hover response" - | Some hover -> - hover |> Hover.yojson_of_t |> Yojson.Safe.pretty_to_string ~std:false |> print_endline -;; - -let hover_req client position = - Client.request - client - (TextDocumentHover - { HoverParams.position - ; textDocument = TextDocumentIdentifier.create ~uri - ; workDoneToken = None - }) -;; - -let%expect_test "with-pp" = - let position = Position.create ~line:0 ~character:9 in - let handler = - Client.Handler.make - ~on_notification:(fun client _notification -> - Client.state client; - Fiber.return ()) - () - in - let output = - Test.run ~handler - @@ fun client -> - let run_client () = - let capabilities = ClientCapabilities.create () in - Client.start client (InitializeParams.create ~capabilities ()) - in - let run () = - let* (_ : InitializeResult.t) = Client.initialized client in - let textDocument = - let text = Io.String_path.read_file path in - TextDocumentItem.create ~uri ~languageId:"ocaml" ~version:0 ~text - in - let* () = - Client.notification - client - (TextDocumentDidOpen (DidOpenTextDocumentParams.create ~textDocument)) - in - let* () = - let+ resp = hover_req client position in - print_hover resp - in - let output = [%expect.output] in - let* () = Client.request client Shutdown in - let+ () = Client.stop client in - output - in - Fiber.fork_and_join_unit run_client run - in - let (_ : string) = [%expect.output] in - print_endline output; - [%expect - {| - { - "contents": { "kind": "plaintext", "value": "type universe" }, - "range": { - "end": { "character": 13, "line": 0 }, - "start": { "character": 0, "line": 0 } - } - }|}] -;; diff --git a/ocaml-lsp-server/test/e2e-new/with_ppx.ml b/ocaml-lsp-server/test/e2e-new/with_ppx.ml index 30181353b..6fe3005cd 100644 --- a/ocaml-lsp-server/test/e2e-new/with_ppx.ml +++ b/ocaml-lsp-server/test/e2e-new/with_ppx.ml @@ -1,3 +1,4 @@ +open Async open! Test.Import let path = Filename.concat (Sys.getcwd ()) "for_ppx.ml" @@ -39,7 +40,7 @@ let%expect_test "with-ppx" = in Client.Handler.make ~on_notification () in - let output = + let%map output = Test.run ~handler @@ fun client -> let run_client () = @@ -76,11 +77,11 @@ let%expect_test "with-ppx" = Received 0 diagnostics { "contents": { - "value": "(* ppx expect expansion *)\nPpx_expect_runtime.Current_file.unset ()", + "value": "(* ppx expect expansion *)\nPpx_module_timer_runtime.record_until Ppx_module_timer_runtime.__MODULE__", "language": "ocaml" }, "range": { - "end": { "character": 16, "line": 2 }, + "end": { "character": 17, "line": 2 }, "start": { "character": 4, "line": 2 } } } diff --git a/ocaml-lsp-server/test/e2e-new/workspace_change_config.ml b/ocaml-lsp-server/test/e2e-new/workspace_change_config.ml index 8e19f5d84..86ff79172 100644 --- a/ocaml-lsp-server/test/e2e-new/workspace_change_config.ml +++ b/ocaml-lsp-server/test/e2e-new/workspace_change_config.ml @@ -1,3 +1,4 @@ +open Async open Test.Import let change_config client params = Client.notification client (ChangeConfiguration params) @@ -27,7 +28,7 @@ let string = "Hello" print_endline ("CodeLens found: " ^ string_of_int (List.length resp_codelens_disabled)); Fiber.return () in - Helpers.test source req; + let%map.Deferred () = Helpers.test source req in [%expect {| CodeLens found: 0 |}] ;; @@ -56,7 +57,7 @@ let foo_value : foo = Some 1 let () = Hover_extended.print_hover resp in Fiber.return () in - Helpers.test source req; + let%map.Deferred () = Helpers.test source req in [%expect {| { @@ -72,5 +73,6 @@ let foo_value : foo = Some 1 "end": { "character": 13, "line": 3 }, "start": { "character": 4, "line": 3 } } - } |}] + } + |}] ;; diff --git a/ocaml-lsp-server/test/e2e/__tests__/Lifecycle.test.ts b/ocaml-lsp-server/test/e2e/__tests__/Lifecycle.test.ts deleted file mode 100644 index ca17269fc..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/Lifecycle.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import * as Protocol from "vscode-languageserver-protocol"; -import * as LanguageServer from "./../src/LanguageServer"; - -test("basic", async () => { - const languageServer = LanguageServer.start(); - await LanguageServer.exit(languageServer); -}); - -test("initialize with empty capabilities", async () => { - const languageServer = LanguageServer.start(); - - const capabilities: Protocol.ClientCapabilities = {}; - - const initializeParameters: Protocol.InitializeParams = { - processId: process.pid, - rootUri: LanguageServer.toURI(__dirname), - capabilities: capabilities, - workspaceFolders: [], - }; - - const result = await languageServer.sendRequest( - Protocol.InitializeRequest.type, - initializeParameters, - ); - - expect(result.capabilities).toBeTruthy(); - await LanguageServer.exit(languageServer); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/Request.Debug.test.ts b/ocaml-lsp-server/test/e2e/__tests__/Request.Debug.test.ts deleted file mode 100644 index 258d624d1..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/Request.Debug.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import * as LanguageServer from "./../src/LanguageServer"; - -test("debug/echo", async () => { - const languageServer = await LanguageServer.startAndInitialize(); - - const params = { - message: "testing", - }; - - const result: any = await languageServer.sendRequest("debug/echo", params); - - expect(result.message).toBe("testing"); - await LanguageServer.exit(languageServer); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/TextDocument.test.ts b/ocaml-lsp-server/test/e2e/__tests__/TextDocument.test.ts deleted file mode 100644 index 5780f580c..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/TextDocument.test.ts +++ /dev/null @@ -1,365 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "./../src/LanguageServer"; - -describe("TextDocument: incremental sync", () => { - let languageServer: LanguageServer.LanguageServer; - - async function getDoc(languageServer: LanguageServer.LanguageServer) { - const result: string = await languageServer.sendRequest( - "debug/textDocument/get", - { - textDocument: Types.TextDocumentIdentifier.create( - "file:///test-document.txt", - ), - position: Types.Position.create(0, 0), - }, - ); - return result; - } - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("Manages unicode character ranges correctly", async () => { - languageServer = await LanguageServer.startAndInitialize(); - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test-document.txt", - "ocaml", - 0, - outdent` - let x = 4 - let y = "a𐐀b" - `, - ), - }, - ); - languageServer.sendNotification( - Protocol.DidChangeTextDocumentNotification.type, - { - textDocument: Types.VersionedTextDocumentIdentifier.create( - "file:///test-document.txt", - 1, - ), - contentChanges: [ - { - range: { - start: { line: 1, character: 10 }, - end: { line: 1, character: 12 }, - }, - text: "", - }, - ], - }, - ); - - expect(await getDoc(languageServer)).toEqual('let x = 4\nlet y = "ab"'); - }); - - it("updates in the middle of the line", async () => { - languageServer = await LanguageServer.startAndInitialize(); - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test-document.txt", - "ocaml", - 0, - "let x = 1;\n\nlet y = 2;", - ), - }, - ); - - expect(await getDoc(languageServer)).toEqual("let x = 1;\n\nlet y = 2;"); - - languageServer.sendNotification( - Protocol.DidChangeTextDocumentNotification.type, - { - textDocument: Types.VersionedTextDocumentIdentifier.create( - "file:///test-document.txt", - 1, - ), - contentChanges: [ - { - range: { - start: { line: 2, character: 5 }, - end: { line: 2, character: 5 }, - }, - rangeLength: 0, - text: "1", - }, - ], - }, - ); - - expect(await getDoc(languageServer)).toEqual("let x = 1;\n\nlet y1 = 2;"); - - languageServer.sendNotification( - Protocol.DidChangeTextDocumentNotification.type, - { - textDocument: Types.VersionedTextDocumentIdentifier.create( - "file:///test-document.txt", - 1, - ), - contentChanges: [ - { - range: { - start: { line: 2, character: 5 }, - end: { line: 2, character: 6 }, - }, - rangeLength: 1, - text: "", - }, - ], - }, - ); - - expect(await getDoc(languageServer)).toEqual("let x = 1;\n\nlet y = 2;"); - }); - - it("updates in at the start of the line", async () => { - languageServer = await LanguageServer.startAndInitialize(); - - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test-document.txt", - "ocaml", - 0, - "let x = 1;\n\nlet y = 2;", - ), - }, - ); - - expect(await getDoc(languageServer)).toEqual("let x = 1;\n\nlet y = 2;"); - - languageServer.sendNotification( - Protocol.DidChangeTextDocumentNotification.type, - { - textDocument: Types.VersionedTextDocumentIdentifier.create( - "file:///test-document.txt", - 1, - ), - contentChanges: [ - { - range: { - start: { line: 1, character: 0 }, - end: { line: 1, character: 0 }, - }, - rangeLength: 0, - text: "s", - }, - ], - }, - ); - - expect(await getDoc(languageServer)).toEqual("let x = 1;\ns\nlet y = 2;"); - }); - - it("update when inserting a line", async () => { - languageServer = await LanguageServer.startAndInitialize(); - - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test-document.txt", - "ocaml", - 0, - "let x = 1;\n\nlet y = 2;", - ), - }, - ); - - expect(await getDoc(languageServer)).toEqual("let x = 1;\n\nlet y = 2;"); - - languageServer.sendNotification( - Protocol.DidChangeTextDocumentNotification.type, - { - textDocument: Types.VersionedTextDocumentIdentifier.create( - "file:///test-document.txt", - 1, - ), - contentChanges: [ - { - range: { - start: { line: 0, character: 10 }, - end: { line: 0, character: 10 }, - }, - rangeLength: 0, - text: "\nlet x = 1;", - }, - ], - }, - ); - - expect(await getDoc(languageServer)).toEqual( - "let x = 1;\nlet x = 1;\n\nlet y = 2;", - ); - }); - - it("update when inserting a line at the end of the doc", async () => { - languageServer = await LanguageServer.startAndInitialize(); - - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test-document.txt", - "ocaml", - 0, - "let x = 1;\n\nlet y = 2;", - ), - }, - ); - - expect(await getDoc(languageServer)).toEqual("let x = 1;\n\nlet y = 2;"); - - languageServer.sendNotification( - Protocol.DidChangeTextDocumentNotification.type, - { - textDocument: Types.VersionedTextDocumentIdentifier.create( - "file:///test-document.txt", - 1, - ), - contentChanges: [ - { - range: { - start: { line: 2, character: 10 }, - end: { line: 2, character: 10 }, - }, - rangeLength: 0, - text: "\nlet y = 2;", - }, - ], - }, - ); - - expect(await getDoc(languageServer)).toEqual( - "let x = 1;\n\nlet y = 2;\nlet y = 2;", - ); - }); - - it("update when deleting a line", async () => { - languageServer = await LanguageServer.startAndInitialize(); - - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test-document.txt", - "ocaml", - 0, - "let x = 1;\n\nlet y = 2;", - ), - }, - ); - - expect(await getDoc(languageServer)).toEqual("let x = 1;\n\nlet y = 2;"); - - languageServer.sendNotification( - Protocol.DidChangeTextDocumentNotification.type, - { - textDocument: Types.VersionedTextDocumentIdentifier.create( - "file:///test-document.txt", - 1, - ), - contentChanges: [ - { - range: { - start: { line: 0, character: 0 }, - end: { line: 1, character: 0 }, - }, - rangeLength: 11, - text: "", - }, - ], - }, - ); - - expect(await getDoc(languageServer)).toEqual("\nlet y = 2;"); - }); -}); - -describe("TextDocument", () => { - let languageServer: LanguageServer.LanguageServer; - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - describe("didOpen", () => { - it("stores text document", async () => { - languageServer = await LanguageServer.startAndInitialize(); - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test-document.txt", - "ocaml", - 0, - "Hello, World!", - ), - }, - ); - - const result: string = await languageServer.sendRequest( - "debug/textDocument/get", - { - textDocument: Types.TextDocumentIdentifier.create( - "file:///test-document.txt", - ), - position: Types.Position.create(0, 0), - }, - ); - - expect(result).toEqual("Hello, World!"); - }); - }); - - describe("didChange", () => { - it("updates text document", async () => { - languageServer = await LanguageServer.startAndInitialize(); - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test-document.txt", - "ocaml", - 0, - "Hello, World!", - ), - }, - ); - - languageServer.sendNotification( - Protocol.DidChangeTextDocumentNotification.type, - { - textDocument: Types.VersionedTextDocumentIdentifier.create( - "file:///test-document.txt", - 1, - ), - contentChanges: [{ text: "Hello again!" }], - }, - ); - - const result: string = await languageServer.sendRequest( - "debug/textDocument/get", - { - textDocument: Types.TextDocumentIdentifier.create( - "file:///test-document.txt", - ), - position: Types.Position.create(0, 0), - }, - ); - - expect(result).toEqual("Hello again!"); - }); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/completionItem-resolve.test.ts b/ocaml-lsp-server/test/e2e/__tests__/completionItem-resolve.test.ts deleted file mode 100644 index e7b9f7e5a..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/completionItem-resolve.test.ts +++ /dev/null @@ -1,111 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "./../src/LanguageServer"; - -describe("textDocument/completion", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function queryCompletionItemResolve( - label: string, - position: Types.Position, - ) { - return languageServer.sendRequest("completionItem/resolve", { - label: label, - data: { - textDocument: { - uri: "file:///test.ml", - }, - position: position, - }, - }); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("can get documentation for the end of document", async () => { - openDocument(outdent` - List.ma - `); - - const response = await queryCompletionItemResolve( - "map2", - Types.Position.create(0, 5), - ); - - expect(response).toMatchInlineSnapshot(` -{ - "documentation": "[map2 f [a1; ...; an] [b1; ...; bn]] is - [[f a1 b1; ...; f an bn]]. - @raise Invalid_argument if the two lists are determined - to have different lengths.", - "label": "map2", -} -`); - }); - - it("can get documentation at arbitrary position", async () => { - openDocument(outdent` - List.fld((=) 0) [1; 2; 3] - `); - - const response = await queryCompletionItemResolve( - "find_all", - Types.Position.create(0, 5), - ); - - expect(response).toMatchInlineSnapshot(` -{ - "documentation": "[find_all] is another name for {!filter}.", - "label": "find_all", -} -`); - }); - - it("can get documentation at arbitrary position (before dot)", async () => { - openDocument(outdent` - module Outer = struct - (** documentation for [Inner] *) - module Inner = struct - let v = () - end - end - - let _ = ();; - - Outer.Inner.v - `); - - const response = await queryCompletionItemResolve( - "Inner", - Types.Position.create(9, 10), - ); - - expect(response).toMatchInlineSnapshot(` -{ - "documentation": "documentation for [Inner]", - "label": "Inner", -} -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/declaration_files/dune b/ocaml-lsp-server/test/e2e/__tests__/declaration_files/dune deleted file mode 100644 index df1b9e154..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/declaration_files/dune +++ /dev/null @@ -1,2 +0,0 @@ -(library - (name declaration_files)) diff --git a/ocaml-lsp-server/test/e2e/__tests__/declaration_files/dune-project b/ocaml-lsp-server/test/e2e/__tests__/declaration_files/dune-project deleted file mode 100644 index 5bbef0b49..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/declaration_files/dune-project +++ /dev/null @@ -1 +0,0 @@ -(lang dune 2.5) diff --git a/ocaml-lsp-server/test/e2e/__tests__/declaration_files/lib.ml b/ocaml-lsp-server/test/e2e/__tests__/declaration_files/lib.ml deleted file mode 100644 index 0547b3d0e..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/declaration_files/lib.ml +++ /dev/null @@ -1 +0,0 @@ -let x = 1 diff --git a/ocaml-lsp-server/test/e2e/__tests__/declaration_files/lib.mli b/ocaml-lsp-server/test/e2e/__tests__/declaration_files/lib.mli deleted file mode 100644 index 48451390c..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/declaration_files/lib.mli +++ /dev/null @@ -1 +0,0 @@ -val x : int diff --git a/ocaml-lsp-server/test/e2e/__tests__/declaration_files/main.ml b/ocaml-lsp-server/test/e2e/__tests__/declaration_files/main.ml deleted file mode 100644 index 7dd9b83f1..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/declaration_files/main.ml +++ /dev/null @@ -1 +0,0 @@ -let y = Lib.x diff --git a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-hoverExtended.ts b/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-hoverExtended.ts deleted file mode 100644 index cc1dbbf52..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-hoverExtended.ts +++ /dev/null @@ -1,736 +0,0 @@ -import outdent from "outdent"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "./../src/LanguageServer"; - -describe("ocamllsp/hoverExtended", () => { - let languageServer: LanguageServer.LanguageServer; - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("returns type inferred under cursor", async () => { - languageServer = await LanguageServer.startAndInitialize(); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - "let x = 1\n", - ), - }); - - const result = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(0, 4), - verbosity: 0, - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "plaintext", - "value": "int", - }, - "range": { - "end": { - "character": 5, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, -} -`); - }); - - it("returns type inferred under cursor (markdown formatting)", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - "let x = 1\n", - ), - }); - - const result = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(0, 4), - verbosity: 0, - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -int -\`\`\`", - }, - "range": { - "end": { - "character": 5, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, -} -`); - }); - - it("returns type inferred under cursor with documentation", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` - (** This function has a nice documentation *) - let id x = x - - let () = id () - `, - ), - }); - - const result = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(3, 9), - verbosity: 0, - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -'a -> 'a -\`\`\` -*** -This function has a nice documentation", - }, - "range": { - "end": { - "character": 11, - "line": 3, - }, - "start": { - "character": 9, - "line": 3, - }, - }, -} -`); - }); - - it("returns type inferred under cursor with documentation with tags (markdown formatting)", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` - (** This function has a nice documentation. - - It performs division of two integer numbers. - - @param x dividend - @param divisor - - @return {i quotient}, i.e. result of division - @raise Division_by_zero raised when divided by zero - - @see article - @see 'arithmetic.ml' for more context - - @since 4.0.0 - @before 4.4.0 - - @deprecated use [(/)] - - @version 1.0.0 - @author John Doe *) - let div x y = - x / y - - let f = div 4 2 - `, - ), - }); - - const result = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(23, 10), - verbosity: 0, - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -int -> int -> int -\`\`\` -*** -This function has a nice documentation. - -It performs division of two integer numbers. - -***@param*** \`x\` -dividend - -***@param*** divisor - -***@return*** -*quotient*, i.e. result of division - -***@raise*** \`Division_by_zero\` -raised when divided by zero - -***@see*** [link](https://en.wikipedia.org/wiki/Arithmetic#Division_\\(%C3%B7,_or_/\\)) -article - -***@see*** \`arithmetic.ml\` -for more context - -***@since*** \`4.0.0\` - -***@before*** \`4.4.0\` - -***@deprecated*** -use \`(/)\` - -***@version*** \`1.0.0\` - -***@author*** John Doe", - }, - "range": { - "end": { - "character": 11, - "line": 23, - }, - "start": { - "character": 8, - "line": 23, - }, - }, -} -`); - }); - - it("returns good type when cursor is between values", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` - let f i f = float_of_int i +. f - let i = 10 - let f = 10. - let sum = f i f - `, - ), - }); - - const result = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(3, 13), - verbosity: 0, - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -int -\`\`\`", - }, - "range": { - "end": { - "character": 13, - "line": 3, - }, - "start": { - "character": 12, - "line": 3, - }, - }, -} -`); - }); - - it("regression test for #343", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` - type t = s - and s = string - type 'a fib = ('a -> unit) -> unit - `, - ), - }); - - const hover1 = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(1, 4), - verbosity: 0, - }); - - expect(hover1).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -type s = t -\`\`\`", - }, - "range": { - "end": { - "character": 14, - "line": 1, - }, - "start": { - "character": 0, - "line": 1, - }, - }, -} -`); - - const hover2 = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(2, 9), - verbosity: 0, - }); - - expect(hover2).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -type 'a fib = ('a -> unit) -> unit -\`\`\`", - }, - "range": { - "end": { - "character": 34, - "line": 2, - }, - "start": { - "character": 0, - "line": 2, - }, - }, -} -`); - }); - - it("regression test for #403", async () => { - languageServer = await LanguageServer.startAndInitialize(); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` -type foo = int - -let x : foo = 1 -`, - ), - }); - - const result = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(2, 4), - verbosity: 0, - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "plaintext", - "value": "foo", - }, - "range": { - "end": { - "character": 5, - "line": 2, - }, - "start": { - "character": 4, - "line": 2, - }, - }, -} -`); - }); - - it("FIXME: reproduce [#344](https://github.com/ocaml/ocaml-lsp/issues/344)", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - // the empty space below is necessary to reproduce the bug - outdent` - - - - - - - - - - - - - - - - - - - - - - - - - let k = () - let m = List.map - `, - ), - }); - - // here we see that all is ok - const hoverOverK = await languageServer.sendRequest( - "ocamllsp/hoverExtended", - { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(24, 4), - verbosity: 0, - }, - ); - - expect(hoverOverK).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -unit -\`\`\`", - }, - "range": { - "end": { - "character": 5, - "line": 24, - }, - "start": { - "character": 4, - "line": 24, - }, - }, -} -`); - - // we trigger the bug - const autocompleteForListm = await languageServer.sendRequest( - "ocamllsp/hoverExtended", - { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(25, 15), - verbosity: 0, - }, - ); - - const buggedHoverOverK = await languageServer.sendRequest( - "ocamllsp/hoverExtended", - { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(24, 4), - verbosity: 0, - }, - ); - - // now the same hover as before comes with unrelated documentation - expect(buggedHoverOverK).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -unit -\`\`\`", - }, - "range": { - "end": { - "character": 5, - "line": 24, - }, - "start": { - "character": 4, - "line": 24, - }, - }, -} -`); - }); - - it("supports explicity verbosity", async () => { - languageServer = await LanguageServer.startAndInitialize(); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` -type foo = int option - -let x : foo = Some 1 - `, - ), - }); - - const result0 = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(2, 4), - verbosity: 0, - }); - - expect(result0).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "plaintext", - "value": "foo", - }, - "range": { - "end": { - "character": 5, - "line": 2, - }, - "start": { - "character": 4, - "line": 2, - }, - }, -} -`); - - const result1 = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(2, 4), - verbosity: 1, - }); - - expect(result1).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "plaintext", - "value": "int option", - }, - "range": { - "end": { - "character": 5, - "line": 2, - }, - "start": { - "character": 4, - "line": 2, - }, - }, -} -`); - - const result2 = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(2, 4), - verbosity: 2, - }); - - expect(result2).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "plaintext", - "value": "int option", - }, - "range": { - "end": { - "character": 5, - "line": 2, - }, - "start": { - "character": 4, - "line": 2, - }, - }, -} -`); - }); - - it("supports implicit verbosity", async () => { - languageServer = await LanguageServer.startAndInitialize(); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` -type foo = int option - -let x : foo = Some 1 - `, - ), - }); - - const result0 = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(2, 4), - }); - - expect(result0).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "plaintext", - "value": "foo", - }, - "range": { - "end": { - "character": 5, - "line": 2, - }, - "start": { - "character": 4, - "line": 2, - }, - }, -} -`); - - const result1 = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(2, 4), - }); - - expect(result1).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "plaintext", - "value": "int option", - }, - "range": { - "end": { - "character": 5, - "line": 2, - }, - "start": { - "character": 4, - "line": 2, - }, - }, -} -`); - - const result2 = await languageServer.sendRequest("ocamllsp/hoverExtended", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(2, 4), - }); - - expect(result2).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "plaintext", - "value": "int option", - }, - "range": { - "end": { - "character": 5, - "line": 2, - }, - "start": { - "character": 4, - "line": 2, - }, - }, -} -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-inferIntf.ts b/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-inferIntf.ts deleted file mode 100644 index 99e8e3209..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-inferIntf.ts +++ /dev/null @@ -1,52 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("ocamllsp/inferIntf", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string, name: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - LanguageServer.toURI(name), - "ocaml", - 0, - source, - ), - }, - ); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - async function inferIntf(name: string) { - return await languageServer.sendRequest( - "ocamllsp/inferIntf", - `file:///${name}`, - ); - } - - it("can infer module interfaces", async () => { - openDocument( - outdent` -type t = Foo of int | Bar of bool - -let f (x : t) = x -`, - "test.ml", - ); - const actions = await inferIntf("test.ml"); - expect(actions).toEqual( - "type t = Foo of int | Bar of bool\nval f : t -> t\n", - ); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-switchImplIntf.ts b/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-switchImplIntf.ts deleted file mode 100644 index 7602eaedb..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-switchImplIntf.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { assert } from "node:console"; -import { promises as fs } from "node:fs"; -import * as path from "node:path"; -import * as Protocol from "vscode-languageserver-protocol"; -import { - type DocumentUri, - TextDocumentItem, -} from "vscode-languageserver-types"; -import { URI } from "vscode-uri"; -import * as LanguageServer from "./../src/LanguageServer"; - -describe("ocamllsp/switchImplIntf", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(documentUri: DocumentUri) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: TextDocumentItem.create(documentUri, "ocaml", 0, ""), - }, - ); - } - - /* sends request "ocamllsp/switchImplIntf" */ - async function ocamllspSwitchImplIntf( - documentUri: DocumentUri, - ): Promise> { - return languageServer.sendRequest("ocamllsp/switchImplIntf", documentUri); - } - - const testWorkspacePath = path.join(__dirname, "..", "test_files/"); - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - await fs.mkdir(testWorkspacePath); - }); - - afterEach(async () => { - await fs.rm(testWorkspacePath, { recursive: true }); - await LanguageServer.exit(languageServer); - }); - - const createPathForFile = (filename: string) => - path.join(testWorkspacePath, filename); - - const createFileAtPath = (path: string) => - fs.writeFile(path, "", { flag: "a+" }); - - const pathToDocumentUri = (path: string): DocumentUri => - URI.file(path).toString(); - - const [mli, ml, mll, mly, rei, re] = ["mli", "ml", "mll", "mly", "rei", "re"]; - - const testRequest = async ( - requestParam: DocumentUri, - expectedResponse: DocumentUri[], - ) => { - const response = await ocamllspSwitchImplIntf(requestParam); - expect(response).toEqual(expectedResponse); - }; - - /** - * For testing 'ocamllsp/switchImplIntf' - * - * @param extsForCreation file name extension for files to be created in - * (test) workspace folder. The first file created (even if only one file - * is created) is treated as the file a user wants to switch from. - * @param extExpected file name extensions that are expected to be returned as - * a reponse to 'ocamllsp/switchImplIntf' - */ - const testingPipeline = async ( - extsForCreation: string[], - extExpected: string[], - ) => { - assert( - extsForCreation.length > 0, - "extensions for creation should not be empty", - ); - assert( - extExpected.length > 0, - "expected response extensions should not be empty", - ); - - const filePathsForCreation = extsForCreation.map((ext) => { - const filename = "test.".concat(ext); - return createPathForFile(filename); - }); - - await Promise.all(filePathsForCreation.map(createFileAtPath)); - - const filePathToSwitchFrom = filePathsForCreation[0]; - const fileURIToSwitchFrom = pathToDocumentUri(filePathToSwitchFrom); - await openDocument(fileURIToSwitchFrom); - - const expectedFileURIs = extExpected.map((ext) => { - const filename = "test.".concat(ext); - const filePath = createPathForFile(filename); - return pathToDocumentUri(filePath); - }); - - await testRequest(fileURIToSwitchFrom, expectedFileURIs); - }; - - /* `create`, `expect`, and `test_case` are for declarativeness */ - const varargFn = (...args: T[]): T[] => args; - const createFiles = varargFn; - const expectSwitchTo = varargFn; - const testCase = (filesToCreate: string[], filesToExpect: string[]) => [ - filesToCreate, - filesToExpect, - ]; - - test.each([ - testCase(createFiles(mli), expectSwitchTo(ml)), - testCase(createFiles(mli, ml), expectSwitchTo(ml)), - testCase(createFiles(ml), expectSwitchTo(mli)), - testCase(createFiles(ml, mli), expectSwitchTo(mli)), - testCase(createFiles(mli, mll), expectSwitchTo(mll)), - testCase(createFiles(mli, ml, mll), expectSwitchTo(ml, mll)), - ])("test switches (%s => %s)", testingPipeline); - - it("can switch from file URI with non-file scheme", async () => { - const mlFpath = createPathForFile("test.ml"); - await createFileAtPath(mlFpath); - const mlUri = pathToDocumentUri(mlFpath); - - const newMliFpath = createPathForFile("test.mli"); - await createFileAtPath(newMliFpath); - const mliUriUntitledScheme: DocumentUri = URI.file(newMliFpath) - .with({ - scheme: "untitled", - }) - .toString(); - - testRequest(mliUriUntitledScheme, [mlUri]); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-typedHoles.ts b/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-typedHoles.ts deleted file mode 100644 index 7d0207bc3..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-typedHoles.ts +++ /dev/null @@ -1,117 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("ocamllsp/typedHoles", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function sendTypedHolesReq() { - return languageServer.sendRequest("ocamllsp/typedHoles", { - uri: "file:///test.ml", - }); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("empty when no holes in file", async () => { - openDocument( - outdent` -let u = 1 -`, - ); - - const r = await sendTypedHolesReq(); - expect(r).toMatchInlineSnapshot("[]"); - }); - - it("one hole", async () => { - openDocument( - outdent` -let k = match () with () -> _ -`, - ); - - const r = await sendTypedHolesReq(); - expect(r).toMatchInlineSnapshot(` -[ - { - "end": { - "character": 29, - "line": 0, - }, - "start": { - "character": 28, - "line": 0, - }, - }, -] -`); - }); - - it("several holes", async () => { - openDocument( - outdent` -let u = - let i = match Some 1 with None -> _ | Some -> _ in - let b = match () with () -> _ in - () - `, - ); - const r = await sendTypedHolesReq(); - expect(r).toMatchInlineSnapshot(` -[ - { - "end": { - "character": 31, - "line": 2, - }, - "start": { - "character": 30, - "line": 2, - }, - }, - { - "end": { - "character": 37, - "line": 1, - }, - "start": { - "character": 36, - "line": 1, - }, - }, - { - "end": { - "character": 49, - "line": 1, - }, - "start": { - "character": 48, - "line": 1, - }, - }, -] -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-wrappingAstNode.test.ts b/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-wrappingAstNode.test.ts deleted file mode 100644 index 6db580536..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-wrappingAstNode.test.ts +++ /dev/null @@ -1,187 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import { Position } from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("ocamllsp/wrappingAstNode", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function sendWrappingAstNodeRequest({ - line, - character, - }: { - line: number; - character: number; - }) { - return languageServer.sendRequest("ocamllsp/wrappingAstNode", { - uri: "file:///test.ml", - position: Position.create(line, character), - }); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("empty document", async () => { - openDocument( - outdent` -`, - ); - - const r = await sendWrappingAstNodeRequest({ line: 0, character: 0 }); - expect(r).toMatchInlineSnapshot("null"); - }); - - const code_snippet_0 = outdent` -let k = 1 - -module M = struct - let a = - let b = 1 in - b + 1 - - let c = 2 -end - `; - - it("when on a toplevel let binding", async () => { - openDocument(code_snippet_0); - - const r = await sendWrappingAstNodeRequest({ line: 0, character: 5 }); - - /* given range corresponds to: - let k = 1 - */ - expect(r).toMatchInlineSnapshot(` -{ - "end": { - "character": 9, - "line": 0, - }, - "start": { - "character": 0, - "line": 0, - }, -} -`); - }); - - it("in between toplevel bindings (let and module def)", async () => { - openDocument(code_snippet_0); - - const r = await sendWrappingAstNodeRequest({ line: 1, character: 0 }); - - /* given range corresponds to: - whole `code_snippet_0` - */ - expect(r).toMatchInlineSnapshot(` -{ - "end": { - "character": 3, - "line": 8, - }, - "start": { - "character": 0, - "line": 0, - }, -} -`); - }); - - it("on keyword struct", async () => { - openDocument(code_snippet_0); - - const r = await sendWrappingAstNodeRequest({ line: 2, character: 14 }); - - /* given range corresponds to: the whole module definition M - module M = struct - let a = - let b = 1 in - b + 1 - - let c = 2 - end - */ - expect(r).toMatchInlineSnapshot(` -{ - "end": { - "character": 3, - "line": 8, - }, - "start": { - "character": 0, - "line": 2, - }, -} -`); - }); - - it("on `b`'s let-binding (nested let-binding in a module def)", async () => { - openDocument(code_snippet_0); - const r = await sendWrappingAstNodeRequest({ line: 4, character: 10 }); - - /* given range corresponds to: - let a = - let b = 1 in - b + 1 - */ - expect(r).toMatchInlineSnapshot(` -{ - "end": { - "character": 9, - "line": 5, - }, - "start": { - "character": 2, - "line": 3, - }, -} -`); - }); - - it("between `a`'s and `c`'s let-bindings in a module def", async () => { - openDocument(code_snippet_0); - - const r = await sendWrappingAstNodeRequest({ line: 6, character: 0 }); - - /* given range corresponds to: values in M, but not module binding itself - let a = - let b = 1 in - b + 1 - - let c = 2 - */ - expect(r).toMatchInlineSnapshot(` -{ - "end": { - "character": 11, - "line": 7, - }, - "start": { - "character": 2, - "line": 3, - }, -} -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-codeAction.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-codeAction.test.ts deleted file mode 100644 index 4e59df007..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-codeAction.test.ts +++ /dev/null @@ -1,896 +0,0 @@ -import * as path from "node:path"; -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import { Position } from "vscode-languageserver-types"; -import { URI } from "vscode-uri"; -import * as LanguageServer from "../src/LanguageServer"; - -function findAddRecAnnotation(actions: Types.CodeAction[]) { - return actions.find( - (action) => - action.kind === "quickfix" && - action.title === "Add missing `rec` keyword", - ); -} - -function findMarkUnused(actions: Types.CodeAction[]) { - return actions.find( - (action) => action.kind === "quickfix" && action.title === "Mark as unused", - ); -} - -function findRemoveUnused(actions: Types.CodeAction[]) { - return actions.find( - (action) => action.kind === "quickfix" && action.title === "Remove unused", - ); -} - -function findInferredAction(actions: Types.CodeAction[]) { - return actions.find((action) => action.kind === "inferred_intf"); -} - -function mkUnboundDiagnostic(start: Types.Position, end: Types.Position) { - return { - message: "Unbound value", - range: { end, start }, - severity: Types.DiagnosticSeverity.Error, - source: "ocamllsp", - }; -} - -function mkUnusedDiagnostic(start: Types.Position, end: Types.Position) { - return { - message: "Error (warning 26): unused variable", - range: { end, start }, - severity: Types.DiagnosticSeverity.Warning, - source: "ocamllsp", - }; -} - -describe("textDocument/codeAction", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string, uri: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create(uri, "ocaml", 0, source), - }, - ); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - experimental: { jumpToNextHole: true }, - window: { - showDocument: { support: true }, - }, - }, - }); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - async function codeAction( - uri: string, - start: Position, - end: Position, - context?: Types.CodeActionContext, - ): Promise | null> { - if (typeof context === "undefined") { - context = { diagnostics: [] }; - } - return languageServer.sendRequest("textDocument/codeAction", { - textDocument: Types.TextDocumentIdentifier.create(uri), - context: context, - range: { start, end }, - }); - } - - it("opens the implementation if not in store", async () => { - const testWorkspacePath = path.join(__dirname, "declaration_files/"); - const intfFilepath = path.join(testWorkspacePath, "lib.mli"); - const intfUri = URI.file(intfFilepath).toString(); - openDocument("", intfUri); - const start = Types.Position.create(0, 0); - const end = Types.Position.create(0, 0); - const actions = (await codeAction(intfUri, start, end)) ?? []; - expect( - findInferredAction(actions)?.edit?.documentChanges?.map((a) => - Types.TextDocumentEdit.is(a) ? a.edits : null, - ), - ).toMatchInlineSnapshot(` -[ - [ - { - "newText": "val x : int -", - "range": { - "end": { - "character": 0, - "line": 0, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - }, - ], -] -`); - }); - - it("offers `Construct an expression` code action", async () => { - const uri = "file:///test.ml"; - openDocument( - outdent` -let x = _ -`, - uri, - ); - - const actions = - (await codeAction(uri, Position.create(0, 8), Position.create(0, 9))) ?? - []; - - expect(actions).toMatchInlineSnapshot(` -[ - { - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "(_ : 'a)", - "range": { - "end": { - "character": 9, - "line": 0, - }, - "start": { - "character": 8, - "line": 0, - }, - }, - }, - ], - "textDocument": { - "uri": "file:///test.ml", - "version": 0, - }, - }, - ], - }, - "isPreferred": false, - "kind": "type-annotate", - "title": "Type-annotate", - }, - { - "command": { - "command": "editor.action.triggerSuggest", - "title": "Trigger Suggest", - }, - "kind": "construct", - "title": "Construct an expression", - }, - { - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "let var_name = _ in -", - "range": { - "end": { - "character": 8, - "line": 0, - }, - "start": { - "character": 8, - "line": 0, - }, - }, - }, - { - "newText": "var_name", - "range": { - "end": { - "character": 9, - "line": 0, - }, - "start": { - "character": 8, - "line": 0, - }, - }, - }, - ], - "textDocument": { - "uri": "file:///test.ml", - "version": 0, - }, - }, - ], - }, - "isPreferred": false, - "kind": "refactor.extract", - "title": "Extract local", - }, - { - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "let fun_name () = _ - -", - "range": { - "end": { - "character": 0, - "line": 0, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - }, - { - "newText": "fun_name ()", - "range": { - "end": { - "character": 9, - "line": 0, - }, - "start": { - "character": 8, - "line": 0, - }, - }, - }, - ], - "textDocument": { - "uri": "file:///test.ml", - "version": 0, - }, - }, - ], - }, - "isPreferred": false, - "kind": "refactor.extract", - "title": "Extract function", - }, - { - "command": { - "arguments": [ - "file:///test.mli", - ], - "command": "ocamllsp/open-related-source", - "title": "Create test.mli", - }, - "edit": { - "documentChanges": [ - { - "kind": "create", - "uri": "file:///test.mli", - }, - ], - }, - "kind": "switch", - "title": "Create test.mli", - }, -] -`); - - const construct_actions = actions.find( - (codeAction: Types.CodeAction) => - codeAction.kind && codeAction.kind === "construct", - ); - - expect(construct_actions).toMatchInlineSnapshot(` -{ - "command": { - "command": "editor.action.triggerSuggest", - "title": "Trigger Suggest", - }, - "kind": "construct", - "title": "Construct an expression", -} -`); - }); - - type refactorOpenTestSpec = { - documentUri?: string; - documentText: string; - queryStartPos: Types.Position; - queryEndPos: Types.Position; - codeActionTitle: string; - }; - - // this removes some repetition in code for testing `refactor-open` code actions - // it specifically doesn't include `expect(...).toMatchInlineSnapshot` to be able to - // capture correct output (the snapshot) from jest automatically - // (similar to ppx_expect promotion with correct output) - async function testRefactorOpen({ - documentUri, - documentText, - queryStartPos, - queryEndPos, - codeActionTitle, - }: refactorOpenTestSpec) { - documentUri = documentUri ? documentUri : "file:///test.ml"; - - openDocument(documentText, documentUri); - - const codeActions = - (await codeAction(documentUri, queryStartPos, queryEndPos)) ?? []; - - const specificCodeActions = codeActions.filter( - (codeAction: Types.CodeAction) => codeAction.title === codeActionTitle, - ); - - return specificCodeActions; - } - - it("refactor-open unqualify in-file module", async () => { - const specificCodeActions = await testRefactorOpen({ - documentText: outdent` - module M = struct - let a = 1 - let f x = x + 1 - end - - open M - - let y = M.f M.a - `, - queryStartPos: Types.Position.create(6, 5), - queryEndPos: Types.Position.create(6, 5), - codeActionTitle: "Remove module name from identifiers", - }); - - expect(specificCodeActions).toMatchInlineSnapshot(` -[ - { - "edit": { - "changes": { - "file:///test.ml": [ - { - "newText": "f", - "range": { - "end": { - "character": 11, - "line": 7, - }, - "start": { - "character": 8, - "line": 7, - }, - }, - }, - { - "newText": "a", - "range": { - "end": { - "character": 15, - "line": 7, - }, - "start": { - "character": 12, - "line": 7, - }, - }, - }, - ], - }, - }, - "isPreferred": false, - "kind": "remove module name from identifiers", - "title": "Remove module name from identifiers", - }, -] -`); - }); - - it("refactor-open qualify in-file module", async () => { - const specificCodeActions = await testRefactorOpen({ - documentText: outdent` - module M = struct - let a = 1 - let f x = x + 1 - end - - open M - - let y = f a - `, - queryStartPos: Types.Position.create(6, 5), - queryEndPos: Types.Position.create(6, 5), - codeActionTitle: "Put module name in identifiers", - }); - - expect(specificCodeActions).toMatchInlineSnapshot(` -[ - { - "edit": { - "changes": { - "file:///test.ml": [ - { - "newText": "M.f", - "range": { - "end": { - "character": 9, - "line": 7, - }, - "start": { - "character": 8, - "line": 7, - }, - }, - }, - { - "newText": "M.a", - "range": { - "end": { - "character": 11, - "line": 7, - }, - "start": { - "character": 10, - "line": 7, - }, - }, - }, - ], - }, - }, - "isPreferred": false, - "kind": "put module name in identifiers", - "title": "Put module name in identifiers", - }, -] -`); - }); - - it("add missing rec in toplevel let", async () => { - const uri = "file:///missing-rec-1.ml"; - openDocument( - outdent` -let needs_rec x = 1 + (needs_rec x) -`, - uri, - ); - const start = Types.Position.create(0, 31); - const end = Types.Position.create(0, 32); - const context = { - diagnostics: [ - mkUnboundDiagnostic( - Types.Position.create(0, 23), - Types.Position.create(0, 32), - ), - ], - }; - - const actions = (await codeAction(uri, start, end, context)) ?? []; - expect(findAddRecAnnotation(actions)).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "message": "Unbound value", - "range": { - "end": { - "character": 32, - "line": 0, - }, - "start": { - "character": 23, - "line": 0, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - ], - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "rec ", - "range": { - "end": { - "character": 4, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, - }, - ], - "textDocument": { - "uri": "file:///missing-rec-1.ml", - "version": 0, - }, - }, - ], - }, - "isPreferred": false, - "kind": "quickfix", - "title": "Add missing \`rec\` keyword", -} -`); - }); - - it("add missing rec in expression let", async () => { - const uri = "file:///missing-rec-2.ml"; - openDocument( - outdent` -let outer = - let inner x = - 1 + (inner -`, - uri, - ); - const start = Types.Position.create(2, 14); - const end = Types.Position.create(2, 15); - const context = { - diagnostics: [ - mkUnboundDiagnostic( - Types.Position.create(2, 9), - Types.Position.create(2, 14), - ), - ], - }; - - const actions = (await codeAction(uri, start, end, context)) ?? []; - expect(findAddRecAnnotation(actions)).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "message": "Unbound value", - "range": { - "end": { - "character": 14, - "line": 2, - }, - "start": { - "character": 9, - "line": 2, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - ], - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "rec ", - "range": { - "end": { - "character": 6, - "line": 1, - }, - "start": { - "character": 6, - "line": 1, - }, - }, - }, - ], - "textDocument": { - "uri": "file:///missing-rec-2.ml", - "version": 0, - }, - }, - ], - }, - "isPreferred": false, - "kind": "quickfix", - "title": "Add missing \`rec\` keyword", -} -`); - }); - - it("add missing rec in expression let-and", async () => { - const uri = "file:///missing-rec-3.ml"; - openDocument( - outdent` -let outer = - let inner1 = 0 - and inner x = - 1 + (inner -`, - uri, - ); - const start = Types.Position.create(3, 14); - const end = Types.Position.create(3, 15); - const context = { - diagnostics: [ - mkUnboundDiagnostic( - Types.Position.create(3, 9), - Types.Position.create(3, 14), - ), - ], - }; - - const actions = (await codeAction(uri, start, end, context)) ?? []; - expect(findAddRecAnnotation(actions)).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "message": "Unbound value", - "range": { - "end": { - "character": 14, - "line": 3, - }, - "start": { - "character": 9, - "line": 3, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - ], - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "rec ", - "range": { - "end": { - "character": 6, - "line": 1, - }, - "start": { - "character": 6, - "line": 1, - }, - }, - }, - ], - "textDocument": { - "uri": "file:///missing-rec-3.ml", - "version": 0, - }, - }, - ], - }, - "isPreferred": false, - "kind": "quickfix", - "title": "Add missing \`rec\` keyword", -} -`); - }); - - it("don't add rec when rec exists", async () => { - const uri = "file:///has-rec-2.ml"; - openDocument( - outdent` -let outer = - let rec inner x = - 1 + (inner -`, - uri, - ); - const start = Types.Position.create(2, 14); - const end = Types.Position.create(2, 15); - - const actions = (await codeAction(uri, start, end)) ?? []; - expect(findAddRecAnnotation(actions)).toBeUndefined(); - }); - - it("don't add rec to pattern bindings", async () => { - const uri = "file:///no-rec-1.ml"; - openDocument( - outdent` -let (f, x) = 1 + (f x) -`, - uri, - ); - const start = Types.Position.create(0, 18); - const end = Types.Position.create(0, 19); - const context = { - diagnostics: [ - mkUnboundDiagnostic( - Types.Position.create(0, 18), - Types.Position.create(0, 19), - ), - ], - }; - - const actions = (await codeAction(uri, start, end, context)) ?? []; - expect(findAddRecAnnotation(actions)).toBeUndefined(); - }); - - it("mark variable as unused", async () => { - const uri = "file:///mark-unused-variable.ml"; - openDocument( - outdent` -let f x = - let y = [ - 1; - 2; - ] in - 0 -`, - uri, - ); - const start = Types.Position.create(1, 6); - const end = Types.Position.create(1, 7); - const context = { - diagnostics: [ - mkUnusedDiagnostic( - Types.Position.create(1, 6), - Types.Position.create(1, 7), - ), - ], - }; - - const actions = (await codeAction(uri, start, end, context)) ?? []; - expect(findMarkUnused(actions)).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "message": "Error (warning 26): unused variable", - "range": { - "end": { - "character": 7, - "line": 1, - }, - "start": { - "character": 6, - "line": 1, - }, - }, - "severity": 2, - "source": "ocamllsp", - }, - ], - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "_", - "range": { - "end": { - "character": 6, - "line": 1, - }, - "start": { - "character": 6, - "line": 1, - }, - }, - }, - ], - "textDocument": { - "uri": "file:///mark-unused-variable.ml", - "version": 0, - }, - }, - ], - }, - "isPreferred": true, - "kind": "quickfix", - "title": "Mark as unused", -} -`); - }); - - it("remove unused variable", async () => { - const uri = "file:///remove-unused-variable.ml"; - openDocument( - outdent` -let f x = - let y = [ - 1; - 2; - ] in - 0 -`, - uri, - ); - const start = Types.Position.create(1, 6); - const end = Types.Position.create(1, 7); - const context = { - diagnostics: [ - mkUnusedDiagnostic( - Types.Position.create(1, 6), - Types.Position.create(1, 7), - ), - ], - }; - - const actions = (await codeAction(uri, start, end, context)) ?? []; - expect(findRemoveUnused(actions)).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "message": "Error (warning 26): unused variable", - "range": { - "end": { - "character": 7, - "line": 1, - }, - "start": { - "character": 6, - "line": 1, - }, - }, - "severity": 2, - "source": "ocamllsp", - }, - ], - "edit": { - "documentChanges": [ - { - "edits": [ - { - "newText": "", - "range": { - "end": { - "character": 2, - "line": 5, - }, - "start": { - "character": 2, - "line": 1, - }, - }, - }, - ], - "textDocument": { - "uri": "file:///remove-unused-variable.ml", - "version": 0, - }, - }, - ], - }, - "isPreferred": false, - "kind": "quickfix", - "title": "Remove unused", -} -`); - }); - - it("don't remove unused value in let-and binding", async () => { - const uri = "file:///remove-unused-variable-2.ml"; - openDocument( - outdent` -let f x = - let y = 0 and z = 0 in - 0 -`, - uri, - ); - const start = Types.Position.create(1, 6); - const end = Types.Position.create(1, 7); - const context = { - diagnostics: [ - mkUnusedDiagnostic( - Types.Position.create(1, 6), - Types.Position.create(1, 7), - ), - ], - }; - - const actions = (await codeAction(uri, start, end, context)) ?? []; - expect(findRemoveUnused(actions)).toBeUndefined(); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-codeLens.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-codeLens.test.ts deleted file mode 100644 index 9c7a32973..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-codeLens.test.ts +++ /dev/null @@ -1,107 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("textDocument/references", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function query() { - return await languageServer.sendRequest("textDocument/codeLens", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - }); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - languageServer.sendNotification("workspace/didChangeConfiguration", { - settings: { - codelens: { enable: true }, - }, - }); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("returns codeLens for a module", async () => { - openDocument(outdent` - let num = 42 - let string = "Hello" - - module M = struct - let m a b = a + b - end - `); - - const result = await query(); - - expect(result).toMatchInlineSnapshot(` -[ - { - "command": { - "command": "", - "title": "int -> int -> int", - }, - "range": { - "end": { - "character": 19, - "line": 4, - }, - "start": { - "character": 2, - "line": 4, - }, - }, - }, - { - "command": { - "command": "", - "title": "string", - }, - "range": { - "end": { - "character": 20, - "line": 1, - }, - "start": { - "character": 0, - "line": 1, - }, - }, - }, - { - "command": { - "command": "", - "title": "int", - }, - "range": { - "end": { - "character": 12, - "line": 0, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - }, -] -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-declaration.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-declaration.test.ts deleted file mode 100644 index c5f6dbfbc..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-declaration.test.ts +++ /dev/null @@ -1,84 +0,0 @@ -import * as child_process from "node:child_process"; -import { promises as fs } from "node:fs"; -import * as path from "node:path"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import { isNotNullable } from "../src/utils"; -import * as LanguageServer from "./../src/LanguageServer"; -import { testUri } from "./../src/LanguageServer"; - -describe("textDocument/declaration", () => { - let languageServer: LanguageServer.LanguageServer; - - const testWorkspacePath = path.join(__dirname, "declaration_files/"); - - const createPathForFile = (filename: string) => - path.join(testWorkspacePath, filename); - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - async function openDocument(filepath: string) { - const source = await fs.readFile(filepath); - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - testUri(filepath), - "ocaml", - 0, - source.toString(), - ), - }, - ); - } - - async function queryDeclaration(filepath: string, position: Types.Position) { - let result = await languageServer.sendRequest( - Protocol.DeclarationRequest.type, - { - textDocument: Types.TextDocumentIdentifier.create(testUri(filepath)), - position, - }, - ); - - if (result === null) return []; - - result = Array.isArray(result) ? result : [result]; - - return result - .map((location) => (Types.Location.is(location) ? location : null)) - .filter(isNotNullable); - } - - it("returns location of a declaration", async () => { - child_process.execSync("dune build", { cwd: testWorkspacePath }); - - await openDocument(createPathForFile("main.ml")); - - const result = await queryDeclaration( - createPathForFile("main.ml"), - Types.Position.create(0, 13), - ); - - expect(result.length).toBe(1); - expect(result[0].range).toMatchInlineSnapshot(` -{ - "end": { - "character": 4, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, -} -`); - expect(result[0].uri).toEqualUri(testUri(createPathForFile("lib.mli"))); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-definition.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-definition.test.ts deleted file mode 100644 index 6e097da99..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-definition.test.ts +++ /dev/null @@ -1,68 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import { isNotNullable } from "../src/utils"; -import * as LanguageServer from "./../src/LanguageServer"; -import { testUri } from "./../src/LanguageServer"; - -describe("textDocument/definition", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - testUri("test.ml"), - "ocaml", - 0, - source, - ), - }, - ); - } - - async function queryDefinition(position: Types.Position) { - let result = await languageServer.sendRequest( - Protocol.DefinitionRequest.type, - { - textDocument: Types.TextDocumentIdentifier.create(testUri("test.ml")), - position, - }, - ); - - if (result === null) return []; - - result = Array.isArray(result) ? result : [result]; - - return result - .map((location) => (Types.Location.is(location) ? location : null)) - .filter(isNotNullable); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("returns location of a definition", async () => { - openDocument(outdent` - let x = 43 - - let () = - print_int x - `); - - const result = await queryDefinition(Types.Position.create(3, 12)); - - expect(result.length).toBe(1); - expect(result[0].range).toMatchObject({ - end: { character: 4, line: 0 }, - start: { character: 4, line: 0 }, - }); - expect(result[0].uri).toEqualUri(testUri("test.ml")); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-diagnostics.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-diagnostics.ts deleted file mode 100644 index 248ffc898..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-diagnostics.ts +++ /dev/null @@ -1,493 +0,0 @@ -import outdent from "outdent"; -import type * as rpc from "vscode-jsonrpc/node"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("textDocument/diagnostics", () => { - let languageServer: rpc.MessageConnection; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("has related diagnostics", async () => { - const receivedDiganostics = new Promise((resolve, _reject) => - languageServer.onNotification((method, params) => { - expect(method).toMatchInlineSnapshot( - `"textDocument/publishDiagnostics"`, - ); - expect(params).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "message": "This comment contains an unterminated string literal", - "range": { - "end": { - "character": 2, - "line": 0, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - "relatedInformation": [ - { - "location": { - "range": { - "end": { - "character": 4, - "line": 0, - }, - "start": { - "character": 3, - "line": 0, - }, - }, - "uri": "file:///test.ml", - }, - "message": "String literal begins here", - }, - ], - "severity": 1, - "source": "ocamllsp", - }, - ], - "uri": "file:///test.ml", -} -`); - resolve(null); - }), - ); - openDocument(outdent` -(* " *) - `); - await receivedDiganostics; - }); - - it("unused values have diagnostic tags", async () => { - const receivedDiganostics = new Promise((resolve, _reject) => - languageServer.onNotification((method, params) => { - expect(method).toMatchInlineSnapshot( - `"textDocument/publishDiagnostics"`, - ); - expect(params).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "message": "Warning 26: unused variable x.", - "range": { - "end": { - "character": 7, - "line": 1, - }, - "start": { - "character": 6, - "line": 1, - }, - }, - "severity": 2, - "source": "ocamllsp", - }, - ], - "uri": "file:///test.ml", -} -`); - resolve(null); - }), - ); - openDocument(outdent` - let () = - let x = 123 in - () - `); - await receivedDiganostics; - }); - - it("deprecated values have diganostic tags", async () => { - const receivedDiganostics = new Promise((resolve, _reject) => - languageServer.onNotification((method, params) => { - expect(method).toMatchInlineSnapshot( - `"textDocument/publishDiagnostics"`, - ); - expect(params).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "message": "Alert deprecated: X.x -do not use", - "range": { - "end": { - "character": 19, - "line": 6, - }, - "start": { - "character": 16, - "line": 6, - }, - }, - "severity": 2, - "source": "ocamllsp", - }, - ], - "uri": "file:///test.ml", -} -`); - resolve(null); - }), - ); - openDocument(outdent` - module X : sig - val x : unit - [@@ocaml.deprecated "do not use"] - end = struct - let x = () - end - let () = ignore X.x - `); - await receivedDiganostics; - }); - - it("related diagnostics for mismatched signatures", async () => { - const receivedDiganostics = new Promise((resolve, _reject) => - languageServer.onNotification((method, params) => { - expect(method).toMatchInlineSnapshot( - `"textDocument/publishDiagnostics"`, - ); - expect(params).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "message": "Signature mismatch: -Modules do not match: - sig val x : int end -is not included in - sig val x : unit end -Values do not match: val x : int is not included in val x : unit -The type int is not compatible with the type unit", - "range": { - "end": { - "character": 3, - "line": 4, - }, - "start": { - "character": 6, - "line": 2, - }, - }, - "relatedInformation": [ - { - "location": { - "range": { - "end": { - "character": 14, - "line": 2, - }, - "start": { - "character": 2, - "line": 2, - }, - }, - "uri": "file:///test.ml", - }, - "message": "Expected declaration", - }, - { - "location": { - "range": { - "end": { - "character": 7, - "line": 4, - }, - "start": { - "character": 6, - "line": 4, - }, - }, - "uri": "file:///test.ml", - }, - "message": "Actual declaration", - }, - ], - "severity": 1, - "source": "ocamllsp", - }, - ], - "uri": "file:///test.ml", -} -`); - resolve(null); - }), - ); - openDocument(outdent` - module X : sig - val x : unit - end = struct - let x = 123 - end - `); - await receivedDiganostics; - }); - - it("no diagnostics for valid files", async () => { - const receivedDiganostics = new Promise((resolve, _reject) => - languageServer.onNotification((method, params) => { - expect(method).toMatchInlineSnapshot( - `"textDocument/publishDiagnostics"`, - ); - expect(params).toMatchInlineSnapshot(` -{ - "diagnostics": [], - "uri": "file:///test.ml", -} -`); - resolve(null); - }), - ); - - openDocument(outdent` - let num = 42 - `); - - await receivedDiganostics; - }); - - it("should have diagnostics for a hole only", async () => { - const receivedDiganostics = new Promise((resolve, _reject) => - languageServer.onNotification((method, params) => { - expect(method).toMatchInlineSnapshot( - `"textDocument/publishDiagnostics"`, - ); - expect(params).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "code": "hole", - "message": "This typed hole should be replaced with an expression of type int", - "range": { - "end": { - "character": 15, - "line": 0, - }, - "start": { - "character": 14, - "line": 0, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - ], - "uri": "file:///test.ml", -} -`); - resolve(null); - }), - ); - - openDocument(outdent` - let a : int = _ - `); - - await receivedDiganostics; - }); - - it("should have diagnostics for holes only", async () => { - const receivedDiganostics = new Promise((resolve, _reject) => - languageServer.onNotification((method, params) => { - expect(method).toMatchInlineSnapshot( - `"textDocument/publishDiagnostics"`, - ); - expect(params).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "code": "hole", - "message": "This typed hole should be replaced with an expression of type int", - "range": { - "end": { - "character": 16, - "line": 0, - }, - "start": { - "character": 15, - "line": 0, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - { - "message": "Warning 26: unused variable b.", - "range": { - "end": { - "character": 5, - "line": 1, - }, - "start": { - "character": 4, - "line": 1, - }, - }, - "severity": 2, - "source": "ocamllsp", - }, - { - "code": "hole", - "message": "This typed hole should be replaced with an expression of type string", - "range": { - "end": { - "character": 44, - "line": 1, - }, - "start": { - "character": 43, - "line": 1, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - { - "code": "hole", - "message": "This typed hole should be replaced with an expression of type string", - "range": { - "end": { - "character": 58, - "line": 1, - }, - "start": { - "character": 57, - "line": 1, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - ], - "uri": "file:///test.ml", -} -`); - resolve(null); - }), - ); - - openDocument(outdent` - let _a : int = _ in - let b : string = match Some 1 with None -> _ | Some _ -> _ in - () - `); - - await receivedDiganostics; - }); - - it("different diagnostics, including holes, sorted by range", async () => { - const receivedDiganostics = new Promise((resolve, _reject) => - languageServer.onNotification((method, params) => { - expect(method).toMatchInlineSnapshot( - `"textDocument/publishDiagnostics"`, - ); - expect(params).toMatchInlineSnapshot(` -{ - "diagnostics": [ - { - "message": "The constructor () has type unit but an expression was expected of type int", - "range": { - "end": { - "character": 42, - "line": 1, - }, - "start": { - "character": 40, - "line": 1, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - { - "code": "hole", - "message": "This typed hole should be replaced with an expression of type 'a", - "range": { - "end": { - "character": 12, - "line": 3, - }, - "start": { - "character": 11, - "line": 3, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - { - "code": "hole", - "message": "This typed hole should be replaced with an expression of type 'a", - "range": { - "end": { - "character": 12, - "line": 4, - }, - "start": { - "character": 11, - "line": 4, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - { - "message": "This constant has type string but an expression was expected of type int", - "range": { - "end": { - "character": 9, - "line": 5, - }, - "start": { - "character": 6, - "line": 5, - }, - }, - "severity": 1, - "source": "ocamllsp", - }, - ], - "uri": "file:///test.ml", -} -`); - resolve(null); - }), - ); - - openDocument(outdent` - let _u = - let _i = List.map (fun i -> i) [1; 2; ()] in - let b = 234 in - let _k = _ in - let _c = _ in - b + "a" - `); - - await receivedDiganostics; - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-documentHighlight.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-documentHighlight.test.ts deleted file mode 100644 index f865e1939..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-documentHighlight.test.ts +++ /dev/null @@ -1,91 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("textDocument/references", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function query(position: Types.Position) { - return await languageServer.sendRequest("textDocument/documentHighlight", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position, - }); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("highlight references in a file", async () => { - openDocument(outdent` - let num = 42 - let sum = num + 13 - let sum2 = sum + num - `); - - const result = await query(Types.Position.create(0, 4)); - - expect(result).toMatchInlineSnapshot(` -[ - { - "kind": 1, - "range": { - "end": { - "character": 7, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, - }, - { - "kind": 1, - "range": { - "end": { - "character": 13, - "line": 1, - }, - "start": { - "character": 10, - "line": 1, - }, - }, - }, - { - "kind": 1, - "range": { - "end": { - "character": 20, - "line": 2, - }, - "start": { - "character": 17, - "line": 2, - }, - }, - }, -] -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-documentSymbol.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-documentSymbol.ts deleted file mode 100644 index e5a32ec40..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-documentSymbol.ts +++ /dev/null @@ -1,294 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("textDocument/documentSymbol", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function query() { - return await languageServer.sendRequest("textDocument/documentSymbol", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - }); - } - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("returns a list of symbol infos", async () => { - languageServer = await LanguageServer.startAndInitialize(); - openDocument(outdent` - let num = 42 - let string = "Hello" - - module M = struct - let m a b = a + b - let n = 32 - end - `); - - const result = await query(); - - expect(result).toMatchInlineSnapshot(` -[ - { - "kind": 13, - "location": { - "range": { - "end": { - "character": 12, - "line": 0, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - "uri": "file:///test.ml", - }, - "name": "num", - }, - { - "kind": 13, - "location": { - "range": { - "end": { - "character": 20, - "line": 1, - }, - "start": { - "character": 0, - "line": 1, - }, - }, - "uri": "file:///test.ml", - }, - "name": "string", - }, - { - "kind": 2, - "location": { - "range": { - "end": { - "character": 3, - "line": 6, - }, - "start": { - "character": 0, - "line": 3, - }, - }, - "uri": "file:///test.ml", - }, - "name": "M", - }, - { - "containerName": "M", - "kind": 12, - "location": { - "range": { - "end": { - "character": 19, - "line": 4, - }, - "start": { - "character": 2, - "line": 4, - }, - }, - "uri": "file:///test.ml", - }, - "name": "m", - }, - { - "containerName": "M", - "kind": 13, - "location": { - "range": { - "end": { - "character": 12, - "line": 5, - }, - "start": { - "character": 2, - "line": 5, - }, - }, - "uri": "file:///test.ml", - }, - "name": "n", - }, -] -`); - }); - - it("returns a hierarchy of symbols", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - documentSymbol: { - hierarchicalDocumentSymbolSupport: true, - }, - moniker: {}, - }, - }, - }); - openDocument(outdent` - let num = 42 - let string = "Hello" - - module M = struct - let m a b = a + b - let n = 32 - end - `); - - const result = await query(); - - expect(result).toMatchInlineSnapshot(` -[ - { - "children": [], - "kind": 13, - "name": "num", - "range": { - "end": { - "character": 12, - "line": 0, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - "selectionRange": { - "end": { - "character": 7, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, - }, - { - "children": [], - "kind": 13, - "name": "string", - "range": { - "end": { - "character": 20, - "line": 1, - }, - "start": { - "character": 0, - "line": 1, - }, - }, - "selectionRange": { - "end": { - "character": 10, - "line": 1, - }, - "start": { - "character": 4, - "line": 1, - }, - }, - }, - { - "children": [ - { - "children": [], - "kind": 12, - "name": "m", - "range": { - "end": { - "character": 19, - "line": 4, - }, - "start": { - "character": 2, - "line": 4, - }, - }, - "selectionRange": { - "end": { - "character": 7, - "line": 4, - }, - "start": { - "character": 6, - "line": 4, - }, - }, - }, - { - "children": [], - "kind": 13, - "name": "n", - "range": { - "end": { - "character": 12, - "line": 5, - }, - "start": { - "character": 2, - "line": 5, - }, - }, - "selectionRange": { - "end": { - "character": 7, - "line": 5, - }, - "start": { - "character": 6, - "line": 5, - }, - }, - }, - ], - "kind": 2, - "name": "M", - "range": { - "end": { - "character": 3, - "line": 6, - }, - "start": { - "character": 0, - "line": 3, - }, - }, - "selectionRange": { - "end": { - "character": 8, - "line": 3, - }, - "start": { - "character": 7, - "line": 3, - }, - }, - }, -] -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-foldingRange.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-foldingRange.test.ts deleted file mode 100644 index ed142f939..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-foldingRange.test.ts +++ /dev/null @@ -1,1522 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("textDocument/foldingRange", () => { - let languageServer: LanguageServer.LanguageServer; - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function foldingRange() { - return languageServer.sendRequest("textDocument/foldingRange", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - }); - } - - it("returns folding ranges for `let`", async () => { - openDocument(outdent` - let a = - let b = 1 - in - let c = - "foo" - in - () - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 4, - "endLine": 6, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 9, - "endLine": 4, - "kind": "region", - "startCharacter": 2, - "startLine": 3, - }, -] -`); - }); - - it("returns folding ranges for open expressions", async () => { - openDocument(outdent` - open struct - let u = - () - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 3, - "endLine": 3, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 3, - "endLine": 3, - "kind": "region", - "startCharacter": 5, - "startLine": 0, - }, - { - "endCharacter": 6, - "endLine": 2, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, -] -`); - }); - - it("returns folding ranges for Pexp_apply expressions", async () => { - openDocument(outdent` - Stdlib.print_endline "one - two - three"`); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 6, - "endLine": 2, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, -] -`); - }); - - it("returns folding ranges for Pexp_letop", async () => { - openDocument(outdent` - let () = - let+ outline = - Stdlib.print_endline "one"; - Stdlib.print_endline "two"; - in - let symbol_info_of_outline_item = - Stdlib.print_endline "one"; - Stdlib.print_endline "two";`); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 29, - "endLine": 7, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 29, - "endLine": 7, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, - { - "endCharacter": 29, - "endLine": 7, - "kind": "region", - "startCharacter": 0, - "startLine": 5, - }, -] -`); - }); - - it("returns folding ranges for Pexp_newtype", async () => { - openDocument(outdent` - let magic_of_kind : type a . a ast_kind -> string = - let () = - Stdlib.print_endline "one"; - Stdlib.print_endline "two" - in ()`); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 7, - "endLine": 4, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 30, - "endLine": 3, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, -] -`); - }); - - it("returns folding ranges for type_extension", async () => { - openDocument(outdent` - type t += - | A - | B - - module type Type = sig - type t += - | A - | B - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 5, - "endLine": 2, - "kind": "region", - "startCharacter": 5, - "startLine": 0, - }, - { - "endCharacter": 3, - "endLine": 8, - "kind": "region", - "startCharacter": 0, - "startLine": 4, - }, - { - "endCharacter": 3, - "endLine": 8, - "kind": "region", - "startCharacter": 19, - "startLine": 4, - }, - { - "endCharacter": 7, - "endLine": 7, - "kind": "region", - "startCharacter": 7, - "startLine": 5, - }, -] -`); - }); - - it("returns folding ranges for match expressions", async () => { - openDocument(outdent` - match - Some - "large expr" - with - | None -> - () - | Some _ -> - print_endline "foo"; - print_endline "bar" - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 21, - "endLine": 8, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 4, - "endLine": 5, - "kind": "region", - "startCharacter": 6, - "startLine": 4, - }, - { - "endCharacter": 21, - "endLine": 8, - "kind": "region", - "startCharacter": 8, - "startLine": 6, - }, -] -`); - }); - - it("returns folding ranges for records", async () => { - openDocument(outdent` - type r = { - a: string; - b: int - } - - let f - { a; - b } = - { a = a; - b = b + 1 } - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 1, - "endLine": 3, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 15, - "endLine": 9, - "kind": "region", - "startCharacter": 0, - "startLine": 5, - }, - { - "endCharacter": 11, - "endLine": 7, - "kind": "region", - "startCharacter": 6, - "startLine": 6, - }, - { - "endCharacter": 15, - "endLine": 9, - "kind": "region", - "startCharacter": 2, - "startLine": 8, - }, -] -`); - }); - - it("returns folding ranges for classes", async () => { - openDocument(outdent` - class foobar = - let a = - let () = Stdlib.print_endline "" in - let () = Stdlib.print_endline "" in - let () = Stdlib.print_endline "" in - () - in - object - method add x y = - let z = - let a = 5 in - let b = 6 in - let () = - let () = Stdlib.print_endline "" in - let () = Stdlib.print_endline "" in - let () = Stdlib.print_endline "" in - () - in - a + b - in - x + y + z - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 5, - "endLine": 21, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 5, - "endLine": 21, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, - { - "endCharacter": 6, - "endLine": 5, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, - { - "endCharacter": 5, - "endLine": 21, - "kind": "region", - "startCharacter": 2, - "startLine": 7, - }, - { - "endCharacter": 15, - "endLine": 20, - "kind": "region", - "startCharacter": 4, - "startLine": 8, - }, - { - "endCharacter": 13, - "endLine": 18, - "kind": "region", - "startCharacter": 6, - "startLine": 9, - }, - { - "endCharacter": 12, - "endLine": 16, - "kind": "region", - "startCharacter": 8, - "startLine": 12, - }, -] -`); - }); - it("returns folding ranges Pexp_while", async () => { - openDocument(outdent` - while true do - Stdlib.print_endline "one"; - Stdlib.print_endline "two"; - done - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 4, - "endLine": 3, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, -] -`); - }); - - it("returns folding ranges Pexp_for", async () => { - openDocument(outdent` - for j = 0 to Array.length index - 1 do - Stdlib.print_endline "one"; - Stdlib.print_endline "two"; - done; - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 4, - "endLine": 3, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, -] -`); - }); - - it("returns folding ranges Pexp_object", async () => { - openDocument(outdent` - object - method print = - Stdlib.print_enline "one"; - Stdlib.print_enline "two"; - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 3, - "endLine": 4, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 30, - "endLine": 3, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, -] -`); - }); - - it("returns folding ranges Pexp_pack", async () => { - openDocument(outdent` - (module Set.Make (struct - type t = s - let compare = cmp - let print = - Stdlib.print_endline "one"; - Stdlib.print_endline "two" - end)) - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 5, - "endLine": 6, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 3, - "endLine": 6, - "kind": "region", - "startCharacter": 18, - "startLine": 0, - }, - { - "endCharacter": 30, - "endLine": 5, - "kind": "region", - "startCharacter": 2, - "startLine": 3, - }, -] -`); - }); - - it("returns folding ranges Pexp_letmodule", async () => { - openDocument(outdent` - let module W = Set.Make (struct - type t = s - - let compare = cmp - - let print = - Stdlib.print_endline "one"; - Stdlib.print_endline "two" - end) - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 4, - "endLine": 8, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 3, - "endLine": 8, - "kind": "region", - "startCharacter": 25, - "startLine": 0, - }, - { - "endCharacter": 30, - "endLine": 7, - "kind": "region", - "startCharacter": 2, - "startLine": 5, - }, -] -`); - }); - - it("returns folding ranges for value_description", async () => { - openDocument(outdent` - module Type : sig - val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> - ?params:(core_type * (variance * injectivity)) list -> - ?cstrs:(core_type * core_type * loc) list -> - ?kind:type_kind -> ?priv:private_flag -> ?manifest:core_type -> str -> - type_declaration - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 3, - "endLine": 6, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 3, - "endLine": 6, - "kind": "region", - "startCharacter": 14, - "startLine": 0, - }, - { - "endCharacter": 20, - "endLine": 5, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, -] -`); - }); - - it("returns folding ranges for Pstr_extension", async () => { - openDocument(outdent` - [%%expect{| - module type Module = - sig - module N : sig type t end - type t - end - |}] - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 5, - "endLine": 6, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, -] -`); - }); - - it("traverses Pexp_lazy nodes", async () => { - openDocument(outdent` - let res = - lazy - (let () = - Stdlib.print_endline "one"; - Stdlib.print_endline "two" - in - ()) - in - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 8, - "endLine": 6, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 33, - "endLine": 4, - "kind": "region", - "startCharacter": 5, - "startLine": 2, - }, -] -`); - }); - - it("traverses Pexp_letexception nodes", async () => { - openDocument(outdent` - let decode_map str = - let exception Shortcut of error_message in - let () = - Stdlib.print_endline "one"; - Stdlib.print_endline "two" - in - () - in - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 4, - "endLine": 6, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 30, - "endLine": 4, - "kind": "region", - "startCharacter": 2, - "startLine": 2, - }, -] -`); - }); - - it("traverses Pexp_sequence nodes", async () => { - openDocument(outdent` - let a = - Stdlib.print_endline ""; - let b = - 5 + 3 in - b - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 3, - "endLine": 4, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 9, - "endLine": 3, - "kind": "region", - "startCharacter": 2, - "startLine": 2, - }, -] -`); - }); - it("supports if/else", async () => { - openDocument(outdent` - let fn a = - if a == true then - let () = - Stdlib.print_endline ""; - Stdlib.print_endline "" - in - let () = - Stdlib.print_endline ""; - Stdlib.print_endline "" - in - () - else - let () = - Stdlib.print_endline ""; - Stdlib.print_endline "" - in - let () = - Stdlib.print_endline ""; - Stdlib.print_endline "" - in - () - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 6, - "endLine": 20, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 6, - "endLine": 10, - "kind": "region", - "startCharacter": 5, - "startLine": 1, - }, - { - "endCharacter": 29, - "endLine": 4, - "kind": "region", - "startCharacter": 4, - "startLine": 2, - }, - { - "endCharacter": 29, - "endLine": 8, - "kind": "region", - "startCharacter": 4, - "startLine": 6, - }, - { - "endCharacter": 29, - "endLine": 14, - "kind": "region", - "startCharacter": 4, - "startLine": 12, - }, - { - "endCharacter": 29, - "endLine": 18, - "kind": "region", - "startCharacter": 4, - "startLine": 16, - }, -] -`); - }); - - it("supports return type annotation", async () => { - openDocument(outdent` - let fn a b : int = - let result = - Stdlib.print_endline ""; - a + b - in - result - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 8, - "endLine": 5, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 9, - "endLine": 3, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, -] -`); - }); - - it("returns folding ranges for try/with", async () => { - openDocument(outdent` - let result = - try - let () = - Stdlib.print_endline ""; - Stdlib.print_endline "" - in - Some 6 - with - | Not_found -> - let () = - Stdlib.print_endline ""; - Stdlib.print_endline "" - in - None - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 8, - "endLine": 13, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 8, - "endLine": 13, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, - { - "endCharacter": 29, - "endLine": 4, - "kind": "region", - "startCharacter": 4, - "startLine": 2, - }, - { - "endCharacter": 8, - "endLine": 13, - "kind": "region", - "startCharacter": 13, - "startLine": 8, - }, - { - "endCharacter": 29, - "endLine": 11, - "kind": "region", - "startCharacter": 4, - "startLine": 9, - }, -] -`); - }); - - it("traverses Pexp_construct", async () => { - openDocument(outdent` - let a = - Some - (let () = - Stdlib.print_endline ""; - Stdlib.print_endline ""; - Stdlib.print_endline "" - in - 5) - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 7, - "endLine": 7, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 30, - "endLine": 5, - "kind": "region", - "startCharacter": 5, - "startLine": 2, - }, -] -`); - }); - - it("returns folding ranges for modules", async () => { - openDocument(outdent` - module type X = sig - type t = - | A - | B - | C - end - - module X = struct - module type T = sig - module T1 : sig - type t = - | A - | B - | C - end - type t - val uri : t -> Uri.t - val dispose : t -> unit - end - - module Y = struct - let bar a = - match a with - | None -> - Stdlib.print_endline ""; - Stdlib.print_endline ""; - Stdlib.print_endline "" - | Some b -> - Stdlib.print_endline b; - Stdlib.print_endline b; - Stdlib.print_endline b - end - - let foo () = - let x = - let y = 5 in - let z = 3 in - let open Stdlib in - let () = - let () = print_endline "" in - let () = print_endline "" in - let () = print_endline "" in - () - in - let open Promise.Syntax in - let%lwt result = - let a = 5 in - Promise.resolve a - in - let+ result_letop = - let a = 5 in - Promise.resolve a - in - z + y - in - x + 3 - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 3, - "endLine": 5, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 3, - "endLine": 5, - "kind": "region", - "startCharacter": 16, - "startLine": 0, - }, - { - "endCharacter": 7, - "endLine": 4, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, - { - "endCharacter": 3, - "endLine": 56, - "kind": "region", - "startCharacter": 0, - "startLine": 7, - }, - { - "endCharacter": 3, - "endLine": 56, - "kind": "region", - "startCharacter": 11, - "startLine": 7, - }, - { - "endCharacter": 5, - "endLine": 18, - "kind": "region", - "startCharacter": 2, - "startLine": 8, - }, - { - "endCharacter": 5, - "endLine": 18, - "kind": "region", - "startCharacter": 18, - "startLine": 8, - }, - { - "endCharacter": 7, - "endLine": 14, - "kind": "region", - "startCharacter": 4, - "startLine": 9, - }, - { - "endCharacter": 7, - "endLine": 14, - "kind": "region", - "startCharacter": 16, - "startLine": 9, - }, - { - "endCharacter": 11, - "endLine": 13, - "kind": "region", - "startCharacter": 6, - "startLine": 10, - }, - { - "endCharacter": 5, - "endLine": 31, - "kind": "region", - "startCharacter": 2, - "startLine": 20, - }, - { - "endCharacter": 5, - "endLine": 31, - "kind": "region", - "startCharacter": 13, - "startLine": 20, - }, - { - "endCharacter": 30, - "endLine": 30, - "kind": "region", - "startCharacter": 4, - "startLine": 21, - }, - { - "endCharacter": 30, - "endLine": 30, - "kind": "region", - "startCharacter": 6, - "startLine": 22, - }, - { - "endCharacter": 31, - "endLine": 26, - "kind": "region", - "startCharacter": 12, - "startLine": 23, - }, - { - "endCharacter": 30, - "endLine": 30, - "kind": "region", - "startCharacter": 14, - "startLine": 27, - }, - { - "endCharacter": 9, - "endLine": 55, - "kind": "region", - "startCharacter": 2, - "startLine": 33, - }, - { - "endCharacter": 11, - "endLine": 53, - "kind": "region", - "startCharacter": 4, - "startLine": 34, - }, - { - "endCharacter": 10, - "endLine": 42, - "kind": "region", - "startCharacter": 6, - "startLine": 38, - }, - { - "endCharacter": 25, - "endLine": 47, - "kind": "region", - "startCharacter": 6, - "startLine": 45, - }, - { - "endCharacter": 11, - "endLine": 53, - "kind": "region", - "startCharacter": 6, - "startLine": 49, - }, -] -`); - }); - - it("traverses Pstr_extension structure item", async () => { - openDocument(outdent` - let%expect_test "test from jsonrpc_test.ml" = - let a = - let b = 5 in - 6 + 5 - in - Stdlib.print_endline (string_of_int 5) - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 40, - "endLine": 5, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 40, - "endLine": 5, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 9, - "endLine": 3, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, -] -`); - }); - - it("returns folding ranges for class_type", async () => { - openDocument(outdent` - class type foo_t = - object - inherit castable - method foo: string - end;; -`); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 3, - "endLine": 4, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 3, - "endLine": 4, - "kind": "region", - "startCharacter": 0, - "startLine": 1, - }, -] -`); - }); - - it("returns folding ranges for class_type_field", async () => { - openDocument(outdent` - module type Type = sig - class reload_generic : - object - method select_operation : - Cmm.operation - -> Cmm.expression list - -> Debuginfo.t - -> Mach.operation * Cmm.expression list - end - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 3, - "endLine": 9, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 3, - "endLine": 9, - "kind": "region", - "startCharacter": 19, - "startLine": 0, - }, - { - "endCharacter": 7, - "endLine": 8, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, - { - "endCharacter": 7, - "endLine": 8, - "kind": "region", - "startCharacter": 4, - "startLine": 2, - }, - { - "endCharacter": 47, - "endLine": 7, - "kind": "region", - "startCharacter": 6, - "startLine": 3, - }, -] -`); - }); - - it("returns folding ranges for class_description", async () => { - openDocument(outdent` - module type T = sig - class cse_generic : - object - end - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 3, - "endLine": 4, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 3, - "endLine": 4, - "kind": "region", - "startCharacter": 16, - "startLine": 0, - }, - { - "endCharacter": 7, - "endLine": 3, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, - { - "endCharacter": 7, - "endLine": 3, - "kind": "region", - "startCharacter": 4, - "startLine": 2, - }, -] -`); - }); - - it("returns folding ranges for class_expr", async () => { - openDocument(outdent` - class x = - object - val x = 3 - val virtual x : t - val! mutable x = 3 - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 5, - "endLine": 5, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 5, - "endLine": 5, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, -] -`); - }); - - it("returns folding ranges for class_type", async () => { - openDocument(outdent` - class type t = - object - val x : t - val mutable x : t - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 5, - "endLine": 4, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 5, - "endLine": 4, - "kind": "region", - "startCharacter": 2, - "startLine": 1, - }, -] -`); - }); - - it("returns folding ranges for Pmod_functor and Pmod_structure", async () => { - openDocument(outdent` - module M = - functor (M : S) -> - (val x) - (struct - type t = int - let x = - Stdlib.print_endline "one"; - Stdlib.print_endline "two"; - end) - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 8, - "endLine": 8, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 8, - "endLine": 8, - "kind": "region", - "startCharacter": 10, - "startLine": 1, - }, - { - "endCharacter": 7, - "endLine": 8, - "kind": "region", - "startCharacter": 5, - "startLine": 3, - }, - { - "endCharacter": 35, - "endLine": 7, - "kind": "region", - "startCharacter": 6, - "startLine": 5, - }, -] -`); - }); - - it("returns folding ranges for Pmty_functor and Pmty_signature", async () => { - openDocument(outdent` - module type S = - functor (M : S) (_ : module type of M) -> - sig - type t = - | A - | B - end - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 7, - "endLine": 6, - "kind": "region", - "startCharacter": 0, - "startLine": 0, - }, - { - "endCharacter": 7, - "endLine": 6, - "kind": "region", - "startCharacter": 10, - "startLine": 1, - }, - { - "endCharacter": 7, - "endLine": 6, - "kind": "region", - "startCharacter": 18, - "startLine": 1, - }, - { - "endCharacter": 7, - "endLine": 6, - "kind": "region", - "startCharacter": 4, - "startLine": 2, - }, - { - "endCharacter": 11, - "endLine": 5, - "kind": "region", - "startCharacter": 6, - "startLine": 3, - }, -] -`); - }); - - it("returns folding ranges for Pexp_ifthenelse", async () => { - openDocument(outdent` - if tool_name = "ocamldep" then - if is_self_reference ~input_name ~loc lid then - {type_decl with ptype_manifest = None} - else {type_decl with ptype_manifest = Some manifest} - else - let x = - let () = Stdlib.print_endline "one" in - let () = Stdlib.print_endline "two" in - () - in - let y = - let () = Stdlib.print_endline "one" in - let () = Stdlib.print_endline "two" in - () - in - () - `); - - const result = await foldingRange(); - expect(result).toMatchInlineSnapshot(` -[ - { - "endCharacter": 54, - "endLine": 3, - "kind": "region", - "startCharacter": 3, - "startLine": 0, - }, - { - "endCharacter": 42, - "endLine": 2, - "kind": "region", - "startCharacter": 5, - "startLine": 1, - }, - { - "endCharacter": 6, - "endLine": 8, - "kind": "region", - "startCharacter": 2, - "startLine": 5, - }, - { - "endCharacter": 6, - "endLine": 13, - "kind": "region", - "startCharacter": 2, - "startLine": 10, - }, -] -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-formatting.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-formatting.test.ts deleted file mode 100644 index 5a11ccd98..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-formatting.test.ts +++ /dev/null @@ -1,183 +0,0 @@ -import * as fs from "node:fs"; -import * as os from "node:os"; -import * as path from "node:path"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -const ocamlFormat = ` -break-cases=all -break-separators=before -break-sequences=true -cases-exp-indent=2 -doc-comments=before -dock-collection-brackets=false -field-space=loose -if-then-else=k-r -indicate-nested-or-patterns=unsafe-no -let-and=sparse -sequence-style=terminator -space-around-arrays -space-around-lists -space-around-records -type-decl=sparse -wrap-comments=true -`; - -function setupOcamlFormat(ocamlFormat: string) { - const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), "ocamllsp-test-")); - fs.writeFileSync(path.join(tmpdir, ".ocamlformat"), ocamlFormat); - return tmpdir; -} - -function openDocument( - languageServer: LanguageServer.LanguageServer, - source: string, - name: string, -) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create(name, "ocaml", 0, source), - }, - ); -} - -async function query( - languageServer: LanguageServer.LanguageServer, - name: string, -) { - return await languageServer.sendRequest( - Protocol.DocumentFormattingRequest.type, - { - textDocument: Types.TextDocumentIdentifier.create(name), - options: Types.FormattingOptions.create(2, true), - }, - ); -} - -const maybeDescribe = os.type() === "Windows_NT" ? describe.skip : describe; - -maybeDescribe("textDocument/formatting", () => { - maybeDescribe("reformatter binary present", () => { - let languageServer: LanguageServer.LanguageServer; - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("can format an ocaml impl file", async () => { - languageServer = await LanguageServer.startAndInitialize(); - - const name = path.join(setupOcamlFormat(ocamlFormat), "test.ml"); - - openDocument( - languageServer, - "let rec gcd a b =\n" + - " match (a, b) with\n" + - " | 0, n\n" + - " | n, 0 ->\n" + - " n\n" + - " | _, _ -> gcd a (b mod a)\n", - name, - ); - - const result = await query(languageServer, name); - expect(result).toMatchInlineSnapshot(` -[ - { - "newText": " | 0, n -", - "range": { - "end": { - "character": 0, - "line": 3, - }, - "start": { - "character": 0, - "line": 2, - }, - }, - }, -] -`); - }); - - it("leaves unchanged files alone", async () => { - languageServer = await LanguageServer.startAndInitialize(); - - const name = path.join(setupOcamlFormat(ocamlFormat), "test.ml"); - - openDocument( - languageServer, - "let rec gcd a b =\n" + - " match (a, b) with\n" + - " | 0, n\n" + - " | n, 0 ->\n" + - " n\n" + - " | _, _ -> gcd a (b mod a)\n", - name, - ); - - const result = await query(languageServer, name); - expect(result).toMatchObject([]); - }); - - it("can format an ocaml intf file", async () => { - languageServer = await LanguageServer.startAndInitialize(); - - const name = path.join(setupOcamlFormat(ocamlFormat), "test.mli"); - - openDocument( - languageServer, - "module Test : sig\n type t =\n | Foo\n | Bar\n | Baz\nend\n", - name, - ); - - const result = await query(languageServer, name); - - expect(result).toMatchInlineSnapshot(` -[ - { - "newText": "module Test : sig -", - "range": { - "end": { - "character": 0, - "line": 1, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - }, -] -`); - }); - - it("does not format ignored files", async () => { - languageServer = await LanguageServer.startAndInitialize(); - - const tmpdir = setupOcamlFormat(ocamlFormat); - - const ocamlFormatIgnore = path.join(tmpdir, ".ocamlformat-ignore"); - fs.writeFileSync(ocamlFormatIgnore, "test.ml\n"); - - const name = path.join(tmpdir, "test.ml"); - - openDocument( - languageServer, - "let rec gcd a b = match (a, b) with\n" + - " | 0, n\n" + - " | n, 0 ->\n" + - " n\n" + - " | _, _ -> gcd a (b mod a)\n", - name, - ); - - const result = await query(languageServer, name); - expect(result).toMatchObject([]); - }); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-hover.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-hover.test.ts deleted file mode 100644 index 39eeb0f56..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-hover.test.ts +++ /dev/null @@ -1,599 +0,0 @@ -import outdent from "outdent"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "./../src/LanguageServer"; - -describe("textDocument/hover", () => { - let languageServer: LanguageServer.LanguageServer; - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("returns type inferred under cursor", async () => { - languageServer = await LanguageServer.startAndInitialize(); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - "let x = 1\n", - ), - }); - - const result = await languageServer.sendRequest("textDocument/hover", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(0, 4), - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "plaintext", - "value": "int", - }, - "range": { - "end": { - "character": 5, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, -} -`); - }); - - it("returns type inferred under cursor (markdown formatting)", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - "let x = 1\n", - ), - }); - - const result = await languageServer.sendRequest("textDocument/hover", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(0, 4), - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -int -\`\`\`", - }, - "range": { - "end": { - "character": 5, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, -} -`); - }); - - // checks for regression https://github.com/ocaml/merlin/issues/1540 - // FIXME: when we can again fetch documentation, update this test - it("returns type inferred under cursor with documentation in let-definition", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` - (** This function has a nice documentation *) - let id x = x - - `, - ), - }); - - const result = await languageServer.sendRequest("textDocument/hover", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(1, 4), - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -'a -> 'a -\`\`\` -*** -This function has a nice documentation", - }, - "range": { - "end": { - "character": 6, - "line": 1, - }, - "start": { - "character": 4, - "line": 1, - }, - }, -} -`); - }); - - it("returns type inferred under cursor with documentation", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` - (** This function has a nice documentation *) - let id x = x - - let () = id () - `, - ), - }); - - const result = await languageServer.sendRequest("textDocument/hover", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(3, 9), - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -'a -> 'a -\`\`\` -*** -This function has a nice documentation", - }, - "range": { - "end": { - "character": 11, - "line": 3, - }, - "start": { - "character": 9, - "line": 3, - }, - }, -} -`); - }); - - it("returns type inferred under cursor with documentation with tags (markdown formatting)", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` - (** This function has a nice documentation. - - It performs division of two integer numbers. - - @param x dividend - @param divisor - - @return {i quotient}, i.e. result of division - @raise Division_by_zero raised when divided by zero - - @see article - @see 'arithmetic.ml' for more context - - @since 4.0.0 - @before 4.4.0 - - @deprecated use [(/)] - - @version 1.0.0 - @author John Doe *) - let div x y = - x / y - - let f = div 4 2 - `, - ), - }); - - const result = await languageServer.sendRequest("textDocument/hover", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(23, 9), - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -int -> int -> int -\`\`\` -*** -This function has a nice documentation. - -It performs division of two integer numbers. - -***@param*** \`x\` -dividend - -***@param*** divisor - -***@return*** -*quotient*, i.e. result of division - -***@raise*** \`Division_by_zero\` -raised when divided by zero - -***@see*** [link](https://en.wikipedia.org/wiki/Arithmetic#Division_\\(%C3%B7,_or_/\\)) -article - -***@see*** \`arithmetic.ml\` -for more context - -***@since*** \`4.0.0\` - -***@before*** \`4.4.0\` - -***@deprecated*** -use \`(/)\` - -***@version*** \`1.0.0\` - -***@author*** John Doe", - }, - "range": { - "end": { - "character": 11, - "line": 23, - }, - "start": { - "character": 8, - "line": 23, - }, - }, -} -`); - }); - - it("returns good type when cursor is between values", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` - let f i f = float_of_int i +. f - let i = 10 - let f = 10. - let sum = f i f - `, - ), - }); - - const result = await languageServer.sendRequest("textDocument/hover", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(3, 13), - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -int -\`\`\`", - }, - "range": { - "end": { - "character": 13, - "line": 3, - }, - "start": { - "character": 12, - "line": 3, - }, - }, -} -`); - }); - - it("regression test for #343", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` - type t = s - and s = string - type 'a fib = ('a -> unit) -> unit - `, - ), - }); - - const hover1 = await languageServer.sendRequest("textDocument/hover", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(1, 4), - }); - - expect(hover1).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -type s = t -\`\`\`", - }, - "range": { - "end": { - "character": 14, - "line": 1, - }, - "start": { - "character": 0, - "line": 1, - }, - }, -} -`); - - const hover2 = await languageServer.sendRequest("textDocument/hover", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(2, 9), - }); - - expect(hover2).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -type 'a fib = ('a -> unit) -> unit -\`\`\`", - }, - "range": { - "end": { - "character": 34, - "line": 2, - }, - "start": { - "character": 0, - "line": 2, - }, - }, -} -`); - }); - - it("regression test for #403", async () => { - languageServer = await LanguageServer.startAndInitialize(); - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - outdent` -type foo = int - -let x : foo = 1 -`, - ), - }); - - const result = await languageServer.sendRequest("textDocument/hover", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(2, 4), - }); - - expect(result).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "plaintext", - "value": "foo", - }, - "range": { - "end": { - "character": 5, - "line": 2, - }, - "start": { - "character": 4, - "line": 2, - }, - }, -} -`); - }); - - it("FIXME: reproduce [#344](https://github.com/ocaml/ocaml-lsp/issues/344)", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - hover: { - dynamicRegistration: true, - contentFormat: ["markdown", "plaintext"], - }, - moniker: {}, - }, - }, - }); - - await languageServer.sendNotification("textDocument/didOpen", { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - // the empty space below is necessary to reproduce the bug - outdent` - - - - - - - - - - - - - - - - - - - - - - - - - let k = () - let m = List.map - `, - ), - }); - - // here we see that all is ok - const hoverOverK = await languageServer.sendRequest("textDocument/hover", { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(24, 4), - }); - - expect(hoverOverK).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -unit -\`\`\`", - }, - "range": { - "end": { - "character": 5, - "line": 24, - }, - "start": { - "character": 4, - "line": 24, - }, - }, -} -`); - - // we trigger the bug - const autocompleteForListm = await languageServer.sendRequest( - "textDocument/hover", - { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(25, 15), - }, - ); - - const buggedHoverOverK = await languageServer.sendRequest( - "textDocument/hover", - { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position: Types.Position.create(24, 4), - }, - ); - - // now the same hover as before comes with unrelated documentation - expect(buggedHoverOverK).toMatchInlineSnapshot(` -{ - "contents": { - "kind": "markdown", - "value": "\`\`\`ocaml -unit -\`\`\`", - }, - "range": { - "end": { - "character": 5, - "line": 24, - }, - "start": { - "character": 4, - "line": 24, - }, - }, -} -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-references.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-references.test.ts deleted file mode 100644 index 3a9dba1f2..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-references.test.ts +++ /dev/null @@ -1,92 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("textDocument/references", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function query(position: Types.Position) { - return await languageServer.sendRequest(Protocol.ReferencesRequest.type, { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position, - context: { includeDeclaration: false }, - }); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("finds references in a file", async () => { - openDocument(outdent` - let num = 42 - let sum = num + 13 - let sum2 = sum + num - `); - - const result = await query(Types.Position.create(0, 4)); - - expect(result).toMatchInlineSnapshot(` -[ - { - "range": { - "end": { - "character": 7, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, - "uri": "file:///test.ml", - }, - { - "range": { - "end": { - "character": 13, - "line": 1, - }, - "start": { - "character": 10, - "line": 1, - }, - }, - "uri": "file:///test.ml", - }, - { - "range": { - "end": { - "character": 20, - "line": 2, - }, - "start": { - "character": 17, - "line": 2, - }, - }, - "uri": "file:///test.ml", - }, -] -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-rename.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-rename.test.ts deleted file mode 100644 index 5f718ae6a..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-rename.test.ts +++ /dev/null @@ -1,305 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("textDocument/rename", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function query(position: Types.Position, newNameOpt?: string) { - const newName = newNameOpt ? newNameOpt : "new_num"; - return await languageServer.sendRequest(Protocol.RenameRequest.type, { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position, - newName, - }); - } - - async function query_prepare(position: Types.Position) { - return await languageServer.sendRequest( - Protocol.PrepareRenameRequest.type, - { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position, - }, - ); - } - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("can reject invalid rename request", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - workspace: { workspaceEdit: { documentChanges: false } }, - }, - }); - - openDocument(outdent` - let num = 42 - let num = num + 13 - let num2 = num - `); - - const result = await query_prepare(Types.Position.create(0, 1)); - expect(result).toBeNull(); - }); - - it("allows valid rename request", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - workspace: { workspaceEdit: { documentChanges: false } }, - }, - }); - - openDocument(outdent` - let num = 42 - let num = num + 13 - let num2 = num - `); - - const result = await query_prepare(Types.Position.create(0, 4)); - expect(result).toMatchInlineSnapshot(` -{ - "end": { - "character": 7, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, -} -`); - }); - - it("rename value in a file without documentChanges capability", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - workspace: { workspaceEdit: { documentChanges: false } }, - }, - }); - - openDocument(outdent` - let num = 42 - let num = num + 13 - let num2 = num - `); - - const result = await query(Types.Position.create(0, 4)); - - expect(result).toMatchInlineSnapshot(` -{ - "changes": { - "file:///test.ml": [ - { - "newText": "new_num", - "range": { - "end": { - "character": 13, - "line": 1, - }, - "start": { - "character": 10, - "line": 1, - }, - }, - }, - { - "newText": "new_num", - "range": { - "end": { - "character": 7, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, - }, - ], - }, -} -`); - }); - - it("rename value in a file with documentChanges capability", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - workspace: { workspaceEdit: { documentChanges: true } }, - }, - }); - - openDocument(outdent` - let num = 42 - let num = num + 13 - let num2 = num - `); - - const result = await query(Types.Position.create(0, 4)); - - expect(result).toMatchInlineSnapshot(` -{ - "documentChanges": [ - { - "edits": [ - { - "newText": "new_num", - "range": { - "end": { - "character": 13, - "line": 1, - }, - "start": { - "character": 10, - "line": 1, - }, - }, - }, - { - "newText": "new_num", - "range": { - "end": { - "character": 7, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, - }, - ], - "textDocument": { - "uri": "file:///test.ml", - "version": 0, - }, - }, - ], -} -`); - }); - - it("rename a var used as a named argument", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - workspace: { workspaceEdit: { documentChanges: false } }, - }, - }); - - openDocument(outdent` -let foo x = x - -let bar ~foo = foo () - -let () = bar ~foo - `); - - const result = await query(Types.Position.create(0, 4), "ident"); - - expect(result).toMatchInlineSnapshot(` -{ - "changes": { - "file:///test.ml": [ - { - "newText": ":ident", - "range": { - "end": { - "character": 17, - "line": 4, - }, - "start": { - "character": 17, - "line": 4, - }, - }, - }, - { - "newText": "ident", - "range": { - "end": { - "character": 7, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, - }, - ], - }, -} -`); - }); - - it("rename a var used as a named argument", async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - workspace: { workspaceEdit: { documentChanges: false } }, - }, - }); - - openDocument(outdent` -let foo = Some () - -let bar ?foo () = foo - -;; -ignore (bar ?foo ()) - `); - - const result = await query(Types.Position.create(0, 4), "sunit"); - - expect(result).toMatchInlineSnapshot(` -{ - "changes": { - "file:///test.ml": [ - { - "newText": ":sunit", - "range": { - "end": { - "character": 16, - "line": 5, - }, - "start": { - "character": 16, - "line": 5, - }, - }, - }, - { - "newText": "sunit", - "range": { - "end": { - "character": 7, - "line": 0, - }, - "start": { - "character": 4, - "line": 0, - }, - }, - }, - ], - }, -} -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-selectionRange.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-selectionRange.test.ts deleted file mode 100644 index ab6317f6b..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-selectionRange.test.ts +++ /dev/null @@ -1,521 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "../src/LanguageServer"; - -describe("textDocument/selectionRange", () => { - let languageServer: LanguageServer.LanguageServer; - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function selectionRange(positions: Types.Position[]) { - return await languageServer.sendRequest( - Protocol.SelectionRangeRequest.type, - { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - positions: positions, - }, - ); - } - - it("returns a selection range for modules", async () => { - openDocument(outdent` - let foo a b = - let min_ab = min a b in - let max_ab = max a b in - min_ab * max_ab - `); - - const result = await selectionRange([Types.Position.create(1, 17)]); - expect(result).toMatchInlineSnapshot(` -[ - { - "parent": { - "parent": { - "parent": { - "parent": { - "parent": { - "range": { - "end": { - "character": 17, - "line": 3, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - }, - "range": { - "end": { - "character": 17, - "line": 3, - }, - "start": { - "character": 8, - "line": 0, - }, - }, - }, - "range": { - "end": { - "character": 17, - "line": 3, - }, - "start": { - "character": 2, - "line": 1, - }, - }, - }, - "range": { - "end": { - "character": 22, - "line": 1, - }, - "start": { - "character": 2, - "line": 1, - }, - }, - }, - "range": { - "end": { - "character": 22, - "line": 1, - }, - "start": { - "character": 15, - "line": 1, - }, - }, - }, - "range": { - "end": { - "character": 18, - "line": 1, - }, - "start": { - "character": 15, - "line": 1, - }, - }, - }, -] -`); - }); - - it("returns a selection range for more complex documents", async () => { - openDocument(outdent` - type _ typ = - | TInt : int typ - | TBool : bool typ - module M = struct - type t - let f (_ : _ typ) = () - end - `); - - const result = await selectionRange([Types.Position.create(5, 23)]); - expect(result).toMatchInlineSnapshot(` -[ - { - "parent": { - "parent": { - "parent": { - "parent": { - "parent": { - "parent": { - "range": { - "end": { - "character": 3, - "line": 6, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - }, - "range": { - "end": { - "character": 3, - "line": 6, - }, - "start": { - "character": 0, - "line": 3, - }, - }, - }, - "range": { - "end": { - "character": 3, - "line": 6, - }, - "start": { - "character": 11, - "line": 3, - }, - }, - }, - "range": { - "end": { - "character": 24, - "line": 5, - }, - "start": { - "character": 2, - "line": 4, - }, - }, - }, - "range": { - "end": { - "character": 24, - "line": 5, - }, - "start": { - "character": 2, - "line": 5, - }, - }, - }, - "range": { - "end": { - "character": 24, - "line": 5, - }, - "start": { - "character": 8, - "line": 5, - }, - }, - }, - "range": { - "end": { - "character": 24, - "line": 5, - }, - "start": { - "character": 22, - "line": 5, - }, - }, - }, -] -`); - }); - - it("returns a selection range for functors", async () => { - openDocument(outdent` -module M = Map.Make (struct - type t = { o: < rank : int > } - let compare a b = a.o#rank - b.o#rank -end)`); - - const result = await selectionRange([Types.Position.create(2, 26)]); - expect(result).toMatchInlineSnapshot(` -[ - { - "parent": { - "parent": { - "parent": { - "parent": { - "parent": { - "parent": { - "parent": { - "parent": { - "range": { - "end": { - "character": 4, - "line": 3, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - }, - "range": { - "end": { - "character": 4, - "line": 3, - }, - "start": { - "character": 11, - "line": 0, - }, - }, - }, - "range": { - "end": { - "character": 3, - "line": 3, - }, - "start": { - "character": 21, - "line": 0, - }, - }, - }, - "range": { - "end": { - "character": 39, - "line": 2, - }, - "start": { - "character": 2, - "line": 1, - }, - }, - }, - "range": { - "end": { - "character": 39, - "line": 2, - }, - "start": { - "character": 2, - "line": 2, - }, - }, - }, - "range": { - "end": { - "character": 39, - "line": 2, - }, - "start": { - "character": 14, - "line": 2, - }, - }, - }, - "range": { - "end": { - "character": 39, - "line": 2, - }, - "start": { - "character": 20, - "line": 2, - }, - }, - }, - "range": { - "end": { - "character": 28, - "line": 2, - }, - "start": { - "character": 20, - "line": 2, - }, - }, - }, - "range": { - "end": { - "character": 28, - "line": 2, - }, - "start": { - "character": 23, - "line": 2, - }, - }, - }, -] -`); - }); - - it("returns a reasonable selection range for ill-typed modules", async () => { - openDocument(outdent` -module M = struct - let f x : int = string_of_int x -end`); - - const result = await selectionRange([Types.Position.create(1, 34)]); - expect(result).toMatchInlineSnapshot(` -[ - { - "parent": { - "parent": { - "parent": { - "parent": { - "parent": { - "range": { - "end": { - "character": 3, - "line": 2, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - }, - "range": { - "end": { - "character": 3, - "line": 2, - }, - "start": { - "character": 11, - "line": 0, - }, - }, - }, - "range": { - "end": { - "character": 35, - "line": 1, - }, - "start": { - "character": 4, - "line": 1, - }, - }, - }, - "range": { - "end": { - "character": 35, - "line": 1, - }, - "start": { - "character": 10, - "line": 1, - }, - }, - }, - "range": { - "end": { - "character": 35, - "line": 1, - }, - "start": { - "character": 20, - "line": 1, - }, - }, - }, - "range": { - "end": { - "character": 35, - "line": 1, - }, - "start": { - "character": 34, - "line": 1, - }, - }, - }, -] -`); - }); - - it("returns a reasonable selection range in the presence of syntax errors", async () => { - openDocument(outdent` -module M = struct - let f x : int = string_of_int x -ed`); - - const result = await selectionRange([Types.Position.create(1, 34)]); - expect(result).toMatchInlineSnapshot(` -[ - { - "parent": { - "parent": { - "parent": { - "parent": { - "parent": { - "range": { - "end": { - "character": 2, - "line": 2, - }, - "start": { - "character": 0, - "line": 0, - }, - }, - }, - "range": { - "end": { - "character": 2, - "line": 2, - }, - "start": { - "character": 11, - "line": 0, - }, - }, - }, - "range": { - "end": { - "character": 2, - "line": 2, - }, - "start": { - "character": 4, - "line": 1, - }, - }, - }, - "range": { - "end": { - "character": 2, - "line": 2, - }, - "start": { - "character": 10, - "line": 1, - }, - }, - }, - "range": { - "end": { - "character": 2, - "line": 2, - }, - "start": { - "character": 20, - "line": 1, - }, - }, - }, - "range": { - "end": { - "character": 35, - "line": 1, - }, - "start": { - "character": 34, - "line": 1, - }, - }, - }, -] -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-signatureHelp.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-signatureHelp.ts deleted file mode 100644 index 35a60b9e4..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-signatureHelp.ts +++ /dev/null @@ -1,506 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import * as LanguageServer from "./../src/LanguageServer"; - -const describe_opt = LanguageServer.ocamlVersionGEq("4.08.0") - ? describe - : xdescribe; - -describe_opt("textDocument/completion", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - "file:///test.ml", - "ocaml", - 0, - source, - ), - }, - ); - } - - async function querySignatureHelp(position: Types.Position) { - return await languageServer.sendRequest( - Protocol.SignatureHelpRequest.type, - { - textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"), - position, - }, - ); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize({ - capabilities: { - textDocument: { - moniker: {}, - signatureHelp: { - dynamicRegistration: true, - signatureInformation: { - documentationFormat: ["markdown", "plaintext"], - parameterInformation: { - labelOffsetSupport: true, - }, - }, - }, - }, - }, - }); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("can provide signature help after a function-type value", async () => { - openDocument(outdent` - let map = ListLabels.map - - let _ = map - `); - - const items = await querySignatureHelp(Types.Position.create(2, 11)); - expect(items).toMatchInlineSnapshot(` -{ - "activeParameter": 1, - "activeSignature": 0, - "signatures": [ - { - "label": "map : f:('a -> 'b) -> 'a list -> 'b list", - "parameters": [ - { - "label": [ - 6, - 18, - ], - }, - { - "label": [ - 22, - 29, - ], - }, - ], - }, - ], -} -`); - }); - - it("can provide signature help for an operator", async () => { - openDocument(outdent` - let (+) = (+) - - let _ = 1 + 2 - `); - - const items = await querySignatureHelp(Types.Position.create(2, 13)); - expect(items).toMatchInlineSnapshot(` -{ - "activeParameter": 1, - "activeSignature": 0, - "signatures": [ - { - "label": "(+) : int -> int -> int", - "parameters": [ - { - "label": [ - 6, - 9, - ], - }, - { - "label": [ - 13, - 16, - ], - }, - ], - }, - ], -} -`); - }); - - it("can provide signature help for an anonymous function", async () => { - openDocument(outdent` - let _ = (fun x -> x + 1) - `); - - const items = await querySignatureHelp(Types.Position.create(0, 26)); - expect(items).toMatchInlineSnapshot(` -{ - "activeParameter": 0, - "activeSignature": 0, - "signatures": [ - { - "label": "_ : int -> int", - "parameters": [ - { - "label": [ - 4, - 7, - ], - }, - ], - }, - ], -} -`); - }); - - it("can make the non-labelled parameter active", async () => { - openDocument(outdent` - let map = ListLabels.map - - let _ = map [] - `); - - const items = await querySignatureHelp(Types.Position.create(2, 14)); - expect(items).toMatchInlineSnapshot(` -{ - "activeParameter": 1, - "activeSignature": 0, - "signatures": [ - { - "label": "map : f:('a -> 'b) -> 'a list -> 'b list", - "parameters": [ - { - "label": [ - 6, - 18, - ], - }, - { - "label": [ - 22, - 29, - ], - }, - ], - }, - ], -} -`); - }); - - it("can make the labelled parameter active", async () => { - openDocument(outdent` - let map = ListLabels.map - - let _ = map ~f:Int.abs - `); - - const items = await querySignatureHelp(Types.Position.create(2, 22)); - expect(items).toMatchInlineSnapshot(` -{ - "activeParameter": 0, - "activeSignature": 0, - "signatures": [ - { - "label": "map : f:(int -> int) -> int list -> int list", - "parameters": [ - { - "label": [ - 6, - 20, - ], - }, - { - "label": [ - 24, - 32, - ], - }, - ], - }, - ], -} -`); - }); - - it("can make a labelled parameter active by prefix", async () => { - openDocument(outdent` - let mem = ListLabels.mem - - let _ = mem ~se - `); - - const items = await querySignatureHelp(Types.Position.create(2, 15)); - expect(items).toMatchInlineSnapshot(` -{ - "activeParameter": 1, - "activeSignature": 0, - "signatures": [ - { - "label": "mem : 'a -> set:'a list -> bool", - "parameters": [ - { - "label": [ - 6, - 8, - ], - }, - { - "label": [ - 12, - 23, - ], - }, - ], - }, - ], -} -`); - }); - - it("can make an optional parameter active by prefix", async () => { - openDocument(outdent` - let create = Hashtbl.create - - let _ = create ?ra - `); - - const items = await querySignatureHelp(Types.Position.create(2, 18)); - expect(items).toMatchInlineSnapshot(` -{ - "activeParameter": 0, - "activeSignature": 0, - "signatures": [ - { - "label": "create : ?random:bool -> int -> ('a, 'b) Hashtbl.t", - "parameters": [ - { - "label": [ - 9, - 21, - ], - }, - { - "label": [ - 25, - 28, - ], - }, - ], - }, - ], -} -`); - }); - - it("can return documentation for the function being applied", async () => { - openDocument( - outdent` - (** This is an example of a docstring that demonstrates various ocamldoc syntax features. - - {3 Sections and Labels} - - We can create sections using {3 Section title} and labels using {3:label_name Section title with label} - - {3 Links and Cross-references} - - External links: {{:https://ocaml.org/} OCaml's official website} - - Cross-references: {!List.length} {{!List.length} Replacement text} - - {3 Inline Formatting} - - {b Bold}, {i Italic}, {e Emphasize}, {^ Superscript}, {_ Subscript}, and [inline code] - - {3 Text Alignment} - - {C Centered text} - {L Left-aligned text} - {R Right-aligned text} - - {3 Lists} - - {ol - {- Ordered list item 1} - {- Ordered list item 2} - } - - {ul - {- Unordered list item 1} - {- Unordered list item 2} - } - - - Unordered list item 1 - - Unordered list item 2 - - {3 Code Blocks} - - {[ - let square x = x * x - let result = square 3 - ]} - - {@python[ - def f(): - return 0 - ]} - - {3 Verbatim} - - {v - This text will be displayed verbatim. - No formatting will be applied. - v} - - {3 Module List} - - {!modules: Array List String} - - @param x dividend - @param divisor - - @return {i quotient}, i.e. result of division - @raise Division_by_zero raised when divided by zero - - @see article - @see 'arithmetic.ml' for more context - - @since 4.0.0 - @before 4.4.0 - - @deprecated use [(/)] - - @version 1.0.0 - @author John Doe *) - let div x y = - x / y - - let _ = div 1 - `, - ); - - const items = await querySignatureHelp(Types.Position.create(80, 13)); - expect(items).toMatchInlineSnapshot(` -{ - "activeParameter": 0, - "activeSignature": 0, - "signatures": [ - { - "documentation": { - "kind": "markdown", - "value": "This is an example of a docstring that demonstrates various ocamldoc syntax features. - -#### Sections and Labels - -We can create sections using - -#### Section title - -and labels using - -#### Section title with label - -#### Links and Cross-references - -External links: [OCaml's official website](https://ocaml.org/) - -Cross-references: \`List.length\` Replacement text - -#### Inline Formatting - -**Bold**, *Italic*, *Emphasize*, ^{Superscript}, \\_{Subscript}, and \`inline code\` - -#### Text Alignment - -Centered text - -Left-aligned text - -Right-aligned text - -#### Lists - -1. Ordered list item 1 -2. Ordered list item 2 - -- Unordered list item 1 -- Unordered list item 2 - -- Unordered list item 1 -- Unordered list item 2 - -#### Code Blocks - -\`\`\`ocaml -let square x = x * x -let result = square 3 -\`\`\` - -\`\`\`python -def f(): - return 0 -\`\`\` - -#### Verbatim - -\`\`\`verb - This text will be displayed verbatim. - No formatting will be applied. -\`\`\` - -#### Module List - -* Array -* List -* String - -***@param*** \`x\` -dividend - -***@param*** divisor - -***@return*** -*quotient*, i.e. result of division - -***@raise*** \`Division_by_zero\` -raised when divided by zero - -***@see*** [link](https://en.wikipedia.org/wiki/Arithmetic#Division_\\(%C3%B7,_or_/\\)) -article - -***@see*** \`arithmetic.ml\` -for more context - -***@since*** \`4.0.0\` - -***@before*** \`4.4.0\` - -***@deprecated*** -use \`(/)\` - -***@version*** \`1.0.0\` - -***@author*** John Doe", - }, - "label": "div : int -> int -> int", - "parameters": [ - { - "label": [ - 6, - 9, - ], - }, - { - "label": [ - 13, - 16, - ], - }, - ], - }, - ], -} -`); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/textDocument-typeDefinition.test.ts b/ocaml-lsp-server/test/e2e/__tests__/textDocument-typeDefinition.test.ts deleted file mode 100644 index 1f411d489..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/textDocument-typeDefinition.test.ts +++ /dev/null @@ -1,129 +0,0 @@ -import outdent from "outdent"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import { isNotNullable } from "../src/utils"; -import * as LanguageServer from "./../src/LanguageServer"; -import { testUri } from "./../src/LanguageServer"; - -describe("textDocument/definition", () => { - let languageServer: LanguageServer.LanguageServer; - - function openDocument(source: string) { - languageServer.sendNotification( - Protocol.DidOpenTextDocumentNotification.type, - { - textDocument: Types.TextDocumentItem.create( - testUri("file.ml"), - "ocaml", - 0, - source, - ), - }, - ); - } - - async function queryDefinition(position: Types.Position) { - let result = await languageServer.sendRequest( - Protocol.TypeDefinitionRequest.type, - { - textDocument: Types.TextDocumentIdentifier.create(testUri("file.ml")), - position, - }, - ); - - if (result === null) return []; - - result = Array.isArray(result) ? result : [result]; - - return result - .map((location) => (Types.Location.is(location) ? location : null)) - .filter(isNotNullable); - } - - beforeEach(async () => { - languageServer = await LanguageServer.startAndInitialize(); - }); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - it("returns location of a type definition", async () => { - openDocument(outdent` - (* type we are jumping on *) - type t = T of int - - let x = T 43 - `); - - const result = await queryDefinition(Types.Position.create(3, 4)); - - expect(result.length).toBe(1); - expect(result[0].range).toMatchInlineSnapshot(` -{ - "end": { - "character": 5, - "line": 1, - }, - "start": { - "character": 5, - "line": 1, - }, -} -`); - expect(result[0].uri).toEqualUri(testUri("file.ml")); - }); - - it("ignores names in values namespace", async () => { - openDocument(outdent` - (* type we are jumping on *) - type t = T of int - - let t = T 42 - let x = T 43 - `); - - const result = await queryDefinition(Types.Position.create(4, 4)); - - expect(result.length).toBe(1); - expect(result[0].range).toMatchInlineSnapshot(` -{ - "end": { - "character": 5, - "line": 1, - }, - "start": { - "character": 5, - "line": 1, - }, -} -`); - expect(result[0].uri).toEqualUri(testUri("file.ml")); - }); - - it("ignores names in values namespace (cursor on same named value)", async () => { - openDocument(outdent` - (* type we are jumping on *) - type t = T of int - - let t = T 42 - `); - - const result = await queryDefinition(Types.Position.create(3, 4)); - - expect(result.length).toBe(1); - expect(result[0].range).toMatchInlineSnapshot(` -{ - "end": { - "character": 5, - "line": 1, - }, - "start": { - "character": 5, - "line": 1, - }, -} -`); - expect(result[0].uri).toEqualUri(testUri("file.ml")); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace-symbol.test.ts b/ocaml-lsp-server/test/e2e/__tests__/workspace-symbol.test.ts deleted file mode 100644 index 5f32d1a61..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace-symbol.test.ts +++ /dev/null @@ -1,242 +0,0 @@ -import * as child_process from "node:child_process"; -import * as path from "node:path"; -import * as Protocol from "vscode-languageserver-protocol"; -import * as Types from "vscode-languageserver-types"; -import { URI } from "vscode-uri"; -import * as LanguageServer from "./../src/LanguageServer"; - -const createWorkspaces = (names: string[]) => { - const createSingleWorkspace = (name: string) => { - const workspacePath = path.join(__dirname, name); - const uri = LanguageServer.toURI(workspacePath); - const folder: Protocol.WorkspaceFolder = { name, uri }; - return { - name, - path: workspacePath, - uri, - folder, - }; - }; - - const workspaces = names.map(createSingleWorkspace); - - const toTestResult = ( - symbol: Types.SymbolInformation | Types.WorkspaceSymbol, - ) => { - const location = Types.Location.is(symbol.location) - ? `${symbol.location.range.start.line}:${symbol.location.range.start.character} ${symbol.location.range.end.line}:${symbol.location.range.end.character}` - : ""; - - return `${symbol.name} ${symbol.kind} ${workspaces.reduce( - (acc, { path: workspacePath, name: workspaceName }) => { - const uri = symbol.location.uri; - const fsPath = URI.parse(uri).fsPath; - if (!fsPath.includes(workspaceName)) return acc; - return URI.file( - path.relative(path.resolve(workspacePath, ".."), fsPath), - ).path; - }, - "", - )} ${location}`; - }; - - return { - workspaces, - toTestResult, - }; -}; - -const buildProject = (cwd: string): void => { - child_process.execSync("dune build --root . @check", { cwd: cwd }); -}; - -describe("workspace/symbol", () => { - let languageServer: LanguageServer.LanguageServer; - - const { - workspaces: [workspaceA, workspaceB], - toTestResult, - } = createWorkspaces(["workspace_symbol_A", "workspace_symbol_B"]); - - afterEach(async () => { - await LanguageServer.exit(languageServer); - }); - - async function queryWorkspaceSymbol(params: Protocol.WorkspaceSymbolParams) { - return ( - (await languageServer.sendRequest( - Protocol.WorkspaceSymbolRequest.type, - params, - )) ?? [] - ); - } - - it("returns all symbols from workspace", async () => { - languageServer = await LanguageServer.startAndInitialize({ - workspaceFolders: [workspaceA.folder], - }); - - buildProject(workspaceA.path); - - const symbols = await queryWorkspaceSymbol({ - query: "", - }); - - expect(symbols.map(toTestResult)).toMatchInlineSnapshot(` -[ - "stack_of_ints 5 /workspace_symbol_A/bin/a.ml 51:0 65:5", - "size 6 /workspace_symbol_A/bin/a.ml 64:11 64:15", - "peek 6 /workspace_symbol_A/bin/a.ml 62:11 62:15", - "pop 6 /workspace_symbol_A/bin/a.ml 57:11 57:14", - "push 6 /workspace_symbol_A/bin/a.ml 55:11 55:15", - "the_list 12 /workspace_symbol_A/bin/a.ml 53:16 53:24", - "Foo 9 /workspace_symbol_A/bin/a.ml 49:0 49:23", - "Increment 2 /workspace_symbol_A/bin/a.ml 45:0 47:3", - "increment_x 12 /workspace_symbol_A/bin/a.ml 46:2 46:27", - "X_int 2 /workspace_symbol_A/bin/a.ml 41:0 43:3", - "x 12 /workspace_symbol_A/bin/a.ml 42:2 42:13", - "A_Mod 2 /workspace_symbol_A/bin/a.ml 29:0 39:3", - "compare 12 /workspace_symbol_A/bin/a.ml 38:2 38:30", - "private_mod_fn 12 /workspace_symbol_A/bin/a.ml 36:2 36:33", - "t 15 /workspace_symbol_A/bin/a.ml 34:2 34:14", - "My_string 2 /workspace_symbol_A/bin/a.ml 27:0 27:25", - "StringMap 2 /workspace_symbol_A/bin/a.ml 26:0 26:36", - "a_i 12 /workspace_symbol_A/bin/a.ml 22:0 24:7", - "a_arr 12 /workspace_symbol_A/bin/a.ml 18:0 18:14", - "a_u 12 /workspace_symbol_A/bin/a.ml 16:0 16:15", - "user 15 /workspace_symbol_A/bin/a.ml 12:0 14:12", - "NotAdmin 9 /workspace_symbol_A/bin/a.ml 14:2 14:12", - "Admin 9 /workspace_symbol_A/bin/a.ml 13:2 13:9", - "a_d 12 /workspace_symbol_A/bin/a.ml 7:0 10:14", - "A_B 2 /workspace_symbol_A/bin/a.ml 2:0 5:3", - "a_b 12 /workspace_symbol_A/bin/a.ml 4:2 4:19", - "a_b_t 15 /workspace_symbol_A/bin/a.ml 3:2 3:21", - "a_x 12 /workspace_symbol_A/bin/a.ml 0:0 0:11", - "main_y 12 /workspace_symbol_A/bin/main.ml 0:0 0:22", - "vendored_x 12 /workspace_symbol_A/lib/lib.ml 14:0 14:31", - "lib_private_fn 12 /workspace_symbol_A/lib/lib.ml 10:0 10:38", - "hd 12 /workspace_symbol_A/lib/lib.ml 8:0 8:16", - "lib_x 12 /workspace_symbol_A/lib/lib.ml 6:0 6:14", - "user 15 /workspace_symbol_A/lib/lib.ml 3:0 5:1", - "name 7 /workspace_symbol_A/lib/lib.ml 4:2 4:14", - "t 15 /workspace_symbol_A/lib/LibTypes.mli 0:0 0:15", - "x 12 /workspace_symbol_A/vendor/vendored_lib.ml 0:0 0:9", -] -`); - }); - - it("returns filtered symbols from workspace", async () => { - languageServer = await LanguageServer.startAndInitialize({ - workspaceFolders: [workspaceA.folder], - }); - - buildProject(workspaceA.path); - - const symbols = await queryWorkspaceSymbol({ - query: "a_", - }); - - expect(symbols.map(toTestResult)).toMatchInlineSnapshot(` -[ - "a_i 12 /workspace_symbol_A/bin/a.ml 22:0 24:7", - "a_arr 12 /workspace_symbol_A/bin/a.ml 18:0 18:14", - "a_u 12 /workspace_symbol_A/bin/a.ml 16:0 16:15", - "a_d 12 /workspace_symbol_A/bin/a.ml 7:0 10:14", - "a_b 12 /workspace_symbol_A/bin/a.ml 4:2 4:19", - "a_b_t 15 /workspace_symbol_A/bin/a.ml 3:2 3:21", - "a_x 12 /workspace_symbol_A/bin/a.ml 0:0 0:11", -] -`); - }); - - it("handles mutiple wokspaces", async () => { - languageServer = await LanguageServer.startAndInitialize({ - workspaceFolders: [workspaceA.folder, workspaceB.folder], - }); - - buildProject(workspaceA.path); - buildProject(workspaceB.path); - - const symbols = await queryWorkspaceSymbol({ - query: "", - }); - /* FIXME: symbol lib_type from lib.ml is missing */ - expect(symbols.map(toTestResult)).toMatchInlineSnapshot(` -[ - "stack_of_ints 5 /workspace_symbol_A/bin/a.ml 51:0 65:5", - "size 6 /workspace_symbol_A/bin/a.ml 64:11 64:15", - "peek 6 /workspace_symbol_A/bin/a.ml 62:11 62:15", - "pop 6 /workspace_symbol_A/bin/a.ml 57:11 57:14", - "push 6 /workspace_symbol_A/bin/a.ml 55:11 55:15", - "the_list 12 /workspace_symbol_A/bin/a.ml 53:16 53:24", - "Foo 9 /workspace_symbol_A/bin/a.ml 49:0 49:23", - "Increment 2 /workspace_symbol_A/bin/a.ml 45:0 47:3", - "increment_x 12 /workspace_symbol_A/bin/a.ml 46:2 46:27", - "X_int 2 /workspace_symbol_A/bin/a.ml 41:0 43:3", - "x 12 /workspace_symbol_A/bin/a.ml 42:2 42:13", - "A_Mod 2 /workspace_symbol_A/bin/a.ml 29:0 39:3", - "compare 12 /workspace_symbol_A/bin/a.ml 38:2 38:30", - "private_mod_fn 12 /workspace_symbol_A/bin/a.ml 36:2 36:33", - "t 15 /workspace_symbol_A/bin/a.ml 34:2 34:14", - "My_string 2 /workspace_symbol_A/bin/a.ml 27:0 27:25", - "StringMap 2 /workspace_symbol_A/bin/a.ml 26:0 26:36", - "a_i 12 /workspace_symbol_A/bin/a.ml 22:0 24:7", - "a_arr 12 /workspace_symbol_A/bin/a.ml 18:0 18:14", - "a_u 12 /workspace_symbol_A/bin/a.ml 16:0 16:15", - "user 15 /workspace_symbol_A/bin/a.ml 12:0 14:12", - "NotAdmin 9 /workspace_symbol_A/bin/a.ml 14:2 14:12", - "Admin 9 /workspace_symbol_A/bin/a.ml 13:2 13:9", - "a_d 12 /workspace_symbol_A/bin/a.ml 7:0 10:14", - "A_B 2 /workspace_symbol_A/bin/a.ml 2:0 5:3", - "a_b 12 /workspace_symbol_A/bin/a.ml 4:2 4:19", - "a_b_t 15 /workspace_symbol_A/bin/a.ml 3:2 3:21", - "a_x 12 /workspace_symbol_A/bin/a.ml 0:0 0:11", - "main_y 12 /workspace_symbol_A/bin/main.ml 0:0 0:22", - "vendored_x 12 /workspace_symbol_A/lib/lib.ml 14:0 14:31", - "lib_private_fn 12 /workspace_symbol_A/lib/lib.ml 10:0 10:38", - "hd 12 /workspace_symbol_A/lib/lib.ml 8:0 8:16", - "lib_x 12 /workspace_symbol_A/lib/lib.ml 6:0 6:14", - "user 15 /workspace_symbol_A/lib/lib.ml 3:0 5:1", - "name 7 /workspace_symbol_A/lib/lib.ml 4:2 4:14", - "t 15 /workspace_symbol_A/lib/LibTypes.mli 0:0 0:15", - "x 12 /workspace_symbol_A/vendor/vendored_lib.ml 0:0 0:9", - "workspace_B 12 /workspace_symbol_B/main.ml 0:0 0:31", -] -`); - }); - - it("shows a notification message if no build directory found", async () => { - languageServer = await LanguageServer.startAndInitialize({ - workspaceFolders: [workspaceA.folder, workspaceB.folder], - }); - - child_process.execSync("dune clean", { cwd: workspaceA.path }); - child_process.execSync("dune clean", { cwd: workspaceB.path }); - - type StarNotificationHandlerParams = - Parameters; - const receivedNotification: Promise<{ - method: StarNotificationHandlerParams[0]; - params: StarNotificationHandlerParams[1]; - }> = new Promise((resolve, _reject) => - languageServer.onNotification((method, params) => - resolve({ method, params }), - ), - ); - - await queryWorkspaceSymbol({ - query: "", - }); - - const notification = await receivedNotification; - expect(notification.method).toBe( - Protocol.ShowMessageNotification.type.method, - ); - // @ts-ignore - expect(notification.params.type).toEqual(Protocol.MessageType.Warning); - // @ts-ignore - expect(notification.params.message).toBe( - `No build directory found in workspace(s): ${workspaceA.name}, ${workspaceB.name}`, - ); - }); -}); diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/a.ml b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/a.ml deleted file mode 100644 index f167d833f..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/a.ml +++ /dev/null @@ -1,66 +0,0 @@ -let a_x = 5 - -module A_B = struct - type a_b_t = string - let a_b = "hello" -end - -let a_d = - match "" with - | "" -> true - | _ -> false - -type user = - | Admin - | NotAdmin - -let a_u = Admin - -let a_arr = [] - -let a_m, a_n = (1, 2) - -let a_i = - let a_i_h = 6 in - a_i_h - -module StringMap = Map.Make (String) -module My_string = String - -module A_Mod : sig - type t = int - - val compare : t -> t -> int -end = struct - type t = int - - let private_mod_fn = Stdlib.abs - - let compare = Stdlib.compare -end - -module type X_int = sig - val x : int -end - -module Increment (M : X_int) = struct - let increment_x = M.x + 1 -end - -exception Foo of string - -class stack_of_ints = - object - val mutable the_list : int list = [] - - method push x = the_list <- x :: the_list - - method pop = - let result = List.hd the_list in - the_list <- List.tl the_list; - result - - method peek = List.hd the_list - - method size = List.length the_list - end diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/dune b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/dune deleted file mode 100644 index 5b946dec4..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/dune +++ /dev/null @@ -1,6 +0,0 @@ -(executable - (name main) - (package main) - (flags :standard -w -32) - (public_name main) - (libraries lib)) diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/main.ml b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/main.ml deleted file mode 100644 index 3b93df360..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/main.ml +++ /dev/null @@ -1,15 +0,0 @@ -let main_y = Lib.lib_x -;; - -let () = - let main_z = "test" in - -print_endline (main_z);; - -print_endline (string_of_int main_y) - -;; -print_endline (string_of_int A.a_x) - -;; -print_endline (string_of_int (Lib.length [])) diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/dune-project b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/dune-project deleted file mode 100644 index 5bbef0b49..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/dune-project +++ /dev/null @@ -1 +0,0 @@ -(lang dune 2.5) diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib.opam b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib.opam deleted file mode 100644 index e69de29bb..000000000 diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/LibTypes.mli b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/LibTypes.mli deleted file mode 100644 index c6a8e288e..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/LibTypes.mli +++ /dev/null @@ -1 +0,0 @@ -type t = string diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/dune b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/dune deleted file mode 100644 index 0b5c5e2bc..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/dune +++ /dev/null @@ -1,8 +0,0 @@ -(library - (public_name lib) - (modules_without_implementation libTypes) - (flags :standard -w -32-38-27-34) - (name lib)) - - -(copy_files# ../vendor/*.ml{,i}) diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/lib.ml b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/lib.ml deleted file mode 100644 index 6b4e10392..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/lib.ml +++ /dev/null @@ -1,15 +0,0 @@ -include List - - -type user = { - name: string -} -let lib_x = 1 - -let hd = List.hd - -let lib_private_fn s = print_endline s - -let lib_type: LibTypes.t = "lib_types" - -let vendored_x = Vendored_lib.x diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/lib.mli b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/lib.mli deleted file mode 100644 index 108d2d2ea..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/lib.mli +++ /dev/null @@ -1,3 +0,0 @@ -include module type of List - -val lib_x : int diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/main.opam b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/main.opam deleted file mode 100644 index e69de29bb..000000000 diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/vendor/vendored_lib.ml b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/vendor/vendored_lib.ml deleted file mode 100644 index 08f32c2ee..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/vendor/vendored_lib.ml +++ /dev/null @@ -1 +0,0 @@ -let x = 5 diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/dune b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/dune deleted file mode 100644 index 4a5b9b19a..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/dune +++ /dev/null @@ -1,3 +0,0 @@ -(library - (flags :standard -w -32-38-27) - (name lib)) diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/dune-project b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/dune-project deleted file mode 100644 index 5bbef0b49..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/dune-project +++ /dev/null @@ -1 +0,0 @@ -(lang dune 2.5) diff --git a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/main.ml b/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/main.ml deleted file mode 100644 index 779cb78ae..000000000 --- a/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/main.ml +++ /dev/null @@ -1 +0,0 @@ -let workspace_B = "workspace_B" diff --git a/ocaml-lsp-server/test/e2e/jest.config.js b/ocaml-lsp-server/test/e2e/jest.config.js deleted file mode 100644 index 548ecd402..000000000 --- a/ocaml-lsp-server/test/e2e/jest.config.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @type {import('@jest/types').Config.ProjectConfig} - */ -module.exports = { - roots: [""], - setupFilesAfterEnv: ["./jest.setup.ts"], - testEnvironment: "node", - transform: { - "^.+\\.tsx?$": "@swc/jest", - }, -}; diff --git a/ocaml-lsp-server/test/e2e/jest.setup.ts b/ocaml-lsp-server/test/e2e/jest.setup.ts deleted file mode 100644 index 365bbb72a..000000000 --- a/ocaml-lsp-server/test/e2e/jest.setup.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { toEqualUri } from "./src/LanguageServer"; - -expect.extend({ - toEqualUri, -}); - -declare global { - namespace jest { - interface Matchers { - toEqualUri(uri: string): R; - } - } -} diff --git a/ocaml-lsp-server/test/e2e/package.json b/ocaml-lsp-server/test/e2e/package.json deleted file mode 100644 index d1bbe8f31..000000000 --- a/ocaml-lsp-server/test/e2e/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "@ocaml/ocaml-lsp-server-e2e", - "version": "0.0.0", - "private": true, - "scripts": { - "promote": "jest --updateSnapshot", - "test": "jest" - }, - "dependencies": { - "outdent": "0.8.0", - "vscode-uri": "3.0.8" - }, - "devDependencies": { - "@swc/core": "1.10.1", - "@swc/jest": "0.2.37", - "@types/jest": "29.5.14", - "@types/node": "22.10.2", - "jest": "29.7.0", - "typescript": "5.7.2", - "vscode-jsonrpc": "8.0.1", - "vscode-languageserver-protocol": "3.17.1", - "vscode-languageserver-types": "3.17.5" - } -} diff --git a/ocaml-lsp-server/test/e2e/src/LanguageServer.ts b/ocaml-lsp-server/test/e2e/src/LanguageServer.ts deleted file mode 100644 index 86870dea9..000000000 --- a/ocaml-lsp-server/test/e2e/src/LanguageServer.ts +++ /dev/null @@ -1,126 +0,0 @@ -import * as cp from "node:child_process"; -import * as os from "node:os"; -import * as path from "node:path"; -import * as rpc from "vscode-jsonrpc/node"; -import * as Protocol from "vscode-languageserver-protocol"; -import { URI } from "vscode-uri"; - -const ocamlVersion = cp.execSync("ocamlc --version").toString(); -export function ocamlVersionGEq(versString: string) { - return ocamlVersion >= versString; -} - -const serverBin = os.platform() === "win32" ? "ocamllsp.exe" : "ocamllsp"; - -const serverPath = path.join( - __dirname, - "..", - "..", - "..", - "..", - "_build", - "install", - "default", - "bin", - serverBin, -); - -export type LanguageServer = rpc.MessageConnection; - -export const toURI = (s: string) => { - return URI.parse(s).toString(); -}; - -export const start = (opts?: cp.SpawnOptions) => { - const env = { ...process.env }; - env.OCAMLLSP_TEST = "true"; - env.LEV_DEBUG = "1"; - opts = opts || { env: env }; - const childProcess = cp.spawn(serverPath, [], opts); - - const connection = rpc.createMessageConnection( - new rpc.StreamMessageReader(childProcess.stdout!), - new rpc.StreamMessageWriter(childProcess.stdin!), - ); - - childProcess.stderr!.on("data", (d) => { - if (process.env.OCAMLLSP_TEST_DEBUG) { - console.log("Received data: " + d); - } - }); - - connection.listen(); - - return connection as LanguageServer; -}; - -export const startAndInitialize = async ( - initializeParameters: Partial = {}, -) => { - const languageServer = start(); - - initializeParameters = { - processId: process.pid, - rootUri: toURI(path.join(__dirname, "..")), - workspaceFolders: [], - capabilities: { - textDocument: { - publishDiagnostics: { - relatedInformation: true, - }, - }, - }, - ...initializeParameters, - }; - - await languageServer.sendRequest( - Protocol.InitializeRequest.type, - initializeParameters, - ); - return languageServer; -}; - -export const exit = async (languageServer: rpc.MessageConnection) => { - const ret = new Promise((resolve, _reject) => { - languageServer.onClose(() => { - languageServer.dispose(); - resolve(null); - }); - }); - - const notification = new rpc.NotificationType("exit"); - languageServer.sendNotification(notification); - - return ret; -}; - -export const testUri = (file: string) => { - return URI.file(file).toString(); -}; - -export const toEqualUri: jest.CustomMatcher = function ( - received: string, - expected: string, -) { - const options = { - comment: "Uri equality", - isNot: this.isNot, - promise: this.promise, - }; - - const pass = - URI.parse(received).toString() === URI.parse(expected).toString(); - - const message = pass - ? () => - this.utils.matcherHint("toEqualUri", undefined, undefined, options) + - "\n\n" + - `Expected: not ${this.utils.printExpected(expected)}\n` + - `Received: ${this.utils.printReceived(received)}` - : () => - this.utils.matcherHint("toBe", undefined, undefined, options) + - "\n\n" + - `Expected: ${this.utils.printExpected(expected)}\n` + - `Received: ${this.utils.printReceived(received)}`; - return { pass, message }; -}; diff --git a/ocaml-lsp-server/test/e2e/src/Ocamlformat.js b/ocaml-lsp-server/test/e2e/src/Ocamlformat.js deleted file mode 100644 index 971a35404..000000000 --- a/ocaml-lsp-server/test/e2e/src/Ocamlformat.js +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env node - -const chunks = []; -process.stdin.resume(); -process.stdin.on("data", (chunk) => { - chunks.push(chunk); -}); -process.stdin.on("end", () => { - const body = Buffer.concat(chunks); - if (body === "special string") { - process.stderr.write("special string passed\n"); - process.exit(1); - } else { - process.stdout.write(body); - } -}); diff --git a/ocaml-lsp-server/test/e2e/src/Refmt.js b/ocaml-lsp-server/test/e2e/src/Refmt.js deleted file mode 100644 index 971a35404..000000000 --- a/ocaml-lsp-server/test/e2e/src/Refmt.js +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env node - -const chunks = []; -process.stdin.resume(); -process.stdin.on("data", (chunk) => { - chunks.push(chunk); -}); -process.stdin.on("end", () => { - const body = Buffer.concat(chunks); - if (body === "special string") { - process.stderr.write("special string passed\n"); - process.exit(1); - } else { - process.stdout.write(body); - } -}); diff --git a/ocaml-lsp-server/test/e2e/src/utils.ts b/ocaml-lsp-server/test/e2e/src/utils.ts deleted file mode 100644 index 3a7412a7a..000000000 --- a/ocaml-lsp-server/test/e2e/src/utils.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const isNotNullable = ( - x: T | null | undefined, -): x is NonNullable => x !== null && x !== undefined; diff --git a/ocaml-lsp-server/test/e2e/tsconfig.json b/ocaml-lsp-server/test/e2e/tsconfig.json deleted file mode 100644 index 1d3a27e3b..000000000 --- a/ocaml-lsp-server/test/e2e/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "esModuleInterop": true, - "lib": ["es2015"] - } -} diff --git a/ocaml-lsp-server/test/ocaml_lsp_tests.ml b/ocaml-lsp-server/test/ocaml_lsp_tests.ml index 7d090c36f..7ef270542 100644 --- a/ocaml-lsp-server/test/ocaml_lsp_tests.ml +++ b/ocaml-lsp-server/test/ocaml_lsp_tests.ml @@ -16,5 +16,12 @@ let%expect_test "eat_message tests" = test "foobar" "foo bar" false; [%expect {| [PASS] |}]; test "foo bar" "foo Bar" false; + [%expect {| [PASS] |}]; + (* Make sure errnos get filtered out *) + test "Error (warning 123123): foo" "foo" true; + [%expect {| [PASS] |}]; + test "foo" "Error (warning 123123): foo" true; + [%expect {| [PASS] |}]; + test "foo: bar" "bar" false; [%expect {| [PASS] |}] ;; diff --git a/ocaml-lsp-server/vendor/cmarkit/LICENSE.md b/ocaml-lsp-server/vendor/cmarkit/LICENSE.md deleted file mode 100644 index eecc26a39..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/LICENSE.md +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2020 The cmarkit programmers - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit.ml b/ocaml-lsp-server/vendor/cmarkit/cmarkit.ml deleted file mode 100644 index 553700f10..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit.ml +++ /dev/null @@ -1,3194 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -module String_map = Map.Make (String) -module Ascii = Cmarkit_base.Ascii -module Text = Cmarkit_base.Text -module Match = Cmarkit_base -module Textloc = Cmarkit_base.Textloc -module Meta = Cmarkit_base.Meta -module Layout = struct - type blanks = string - type nonrec string = string - type nonrec char = char - type count = int - type indent = int - let string ?(meta = Meta.none) s = s, meta - let empty = string "" -end - -type byte_pos = Textloc.byte_pos -type line_span = Match.line_span = - (* Substring on a single line, hereafter abbreviated to span *) - { line_pos : Textloc.line_pos; first : byte_pos; last : byte_pos } - -type 'a node = 'a * Meta.t - -module Block_line = struct - let _list_of_string flush s = (* cuts [s] on newlines *) - let rec loop s acc max start k = - if k > max then List.rev (flush s start max acc) else - if not (s.[k] = '\n' || s.[k] = '\r') - then loop s acc max start (k + 1) else - let acc = flush s start (k - 1) acc in - let next = k + 1 in - let start = - if s.[k] = '\r' && next <= max && s.[next] = '\n' then next + 1 else - next - in - loop s acc max start start - in - loop s [] (String.length s - 1) 0 0 - - let flush ?(meta = Meta.none) s start last acc = - let sub = String.sub s start (last - start + 1) in - (sub, meta) :: acc - - let flush_tight ?(meta = Meta.none) s start last acc = - (* If [s] has newlines, blanks after newlines are layout *) - if start > last then ("", ("", meta)) :: acc else - match acc with - | [] (* On the first line the blanks are legit *) -> - ("", (String.sub s start (last - start + 1), meta)) :: acc - | acc -> - let nb = Match.first_non_blank s ~last ~start in - (String.sub s start (nb - 1 - start + 1), - (String.sub s nb (last - nb + 1), meta)) :: acc - - (* Block lines *) - - type t = string node - - let to_string = fst - let list_of_string ?meta s = _list_of_string (flush ?meta) s - let list_textloc = function - | [] -> Textloc.none | [(_, m)] -> Meta.textloc m - | (_, first) :: _ as l -> - let _, last = List.hd (List.rev l) in - Textloc.reloc ~first:(Meta.textloc first) ~last:(Meta.textloc last) - - (* Tight lines *) - - type tight = Layout.blanks * t - - let tight_to_string l = fst (snd l) - let tight_list_of_string ?meta s = _list_of_string (flush_tight ?meta) s - let tight_list_textloc = function - | [] -> Textloc.none | [_, (_, m)] -> Meta.textloc m - | (_, (_, first)) :: _ as l -> - let (_, (_, last)) = List.hd (List.rev l) in - Textloc.reloc ~first:(Meta.textloc first) ~last:(Meta.textloc last) - - (* Blank lines *) - - type blank = Layout.blanks node -end - -module Label = struct - type key = string - type t = { meta : Meta.t; key : key; text : Block_line.tight list } - let make ?(meta = Meta.none) ~key text = { key; text; meta } - let with_meta meta l = { l with meta } - let meta t = t.meta - let key t = t.key - let text t = t.text - let textloc t = Block_line.tight_list_textloc t.text - let text_to_string t = - String.concat " " (List.map Block_line.tight_to_string t.text) - - let compare l0 l1 = String.compare l0.key l1.key - - (* Definitions *) - - module Map = Map.Make (String) - type def = .. - type defs = def Map.t - - (* Resolvers *) - - type context = - [ `Def of t option * t - | `Ref of [ `Link | `Image ] * t * (t option) ] - - type resolver = context -> t option - let default_resolver = function - | `Def (None, k) -> Some k - | `Def (Some _, k) -> None - | `Ref (_, _, k) -> k -end - -module Link_definition = struct - type layout = - { indent : Layout.indent; - angled_dest : bool; - before_dest : Block_line.blank list; - after_dest : Block_line.blank list; - title_open_delim : Layout.char; - after_title : Block_line.blank list; } - - let layout_for_dest dest = - let needs_angles c = Ascii.is_control c || c = ' ' in - let angled_dest = String.exists needs_angles dest in - { indent = 0; angled_dest; before_dest = []; - after_dest = []; title_open_delim = '\"'; after_title = [] } - - let default_layout = - { indent = 0; angled_dest = false; before_dest = []; - after_dest = []; title_open_delim = '\"'; after_title = [] } - - type t = - { layout : layout; - label : Label.t option; - defined_label : Label.t option; - dest : string node option; - title : Block_line.tight list option; } - - let make ?layout ?defined_label ?label ?dest ?title () = - let layout = match dest with - | None -> default_layout | Some (d, _) -> layout_for_dest d - in - let defined_label = match defined_label with None -> label | Some d -> d in - { layout; label; defined_label; dest; title } - - let layout ld = ld.layout - let label ld = ld.label - let defined_label ld = ld.defined_label - let dest ld = ld.dest - let title ld = ld.title - - type Label.def += Def of t node -end - -module Inline = struct - type t = .. - - module Autolink = struct - type t = { is_email : bool; link : string node; } - let is_email a = a.is_email - let link a = a.link - let make link = - let is_email = - let l = String.concat "" ["<"; fst link; ">"] in - match Match.autolink_email l ~last:(String.length l - 1) ~start:0 with - | None -> false | Some _ -> true - in - { is_email; link } - end - - module Break = struct - type type' = [ `Hard | `Soft ] - type t = - { layout_before : Layout.blanks node; - type' : type'; - layout_after : Layout.blanks node; } - - let make - ?(layout_before = Layout.empty) ?(layout_after = Layout.empty) type' - = - { layout_before; type'; layout_after } - - let type' b = b.type' - let layout_before b = b.layout_before - let layout_after b = b.layout_after - end - - module Code_span = struct - type t = - { backtick_count : Layout.count; - code_layout : Block_line.tight list; } - - let make ~backtick_count code_layout = { backtick_count; code_layout } - - let min_backtick_count ~min counts = - let rec loop min = function - | c :: cs -> if min <> c then min else loop (c + 1) cs | [] -> min - in - loop min (List.sort Int.compare counts) - - let of_string ?(meta = Meta.none) = function - | "" -> { backtick_count = 1 ; code_layout = ["", ("", meta)] } - | s -> - (* This finds out the needed backtick count, whether spaces are needed, - and treats blanks after newline as layout *) - let max = String.length s - 1 in - let need_sp = s.[0] = '`' || s.[max] = '`' in - let s = if need_sp then String.concat "" [" "; s; " "] else s in - let backtick_counts, code_layout = - let rec loop bt_counts acc max btc start k = match k > max with - | true -> - (* assert (btc = 0) because of [need_sp] *) - bt_counts, - if acc = [] then ["", (s, meta)] else - List.rev (Block_line.flush_tight ~meta s start max acc) - | false -> - if s.[k] = '`' - then loop bt_counts acc max (btc + 1) start (k + 1) else - let bt_counts = if btc > 0 then btc :: bt_counts else bt_counts in - if not (s.[k] = '\n' || s.[k] = '\r') - then loop bt_counts acc max 0 start (k + 1) else - let acc = Block_line.flush_tight ~meta s start (k - 1) acc in - let start = - if k + 1 <= max && s.[k] = '\r' && s.[k + 1] = '\n' - then k + 2 else k + 1 - in - loop bt_counts acc max 0 start start - in - loop [] [] max 0 0 0 - in - let backtick_count = min_backtick_count ~min:1 backtick_counts in - { backtick_count; code_layout } - - let backtick_count cs = cs.backtick_count - let code_layout cs = cs.code_layout - let code cs = - (* Extract code, see https://spec.commonmark.org/0.30/#code-spans *) - let sp c = Char.equal c ' ' in - let s = List.map Block_line.tight_to_string cs.code_layout in - let s = String.concat " " s in - if s = "" then "" else - if s.[0] = ' ' && s.[String.length s - 1] = ' ' && - not (String.for_all sp s) - then String.sub s 1 (String.length s - 2) else s - end - - module Emphasis = struct - type inline = t - type t = { delim : Layout.char; inline : inline } - let make ?(delim = '*') inline = { delim; inline } - let inline e = e.inline - let delim e = e.delim - end - - module Link = struct - type inline = t - - type reference_layout = [ `Collapsed | `Full | `Shortcut ] - type reference = - [ `Inline of Link_definition.t node - | `Ref of reference_layout * Label.t * Label.t ] - - type t = { text : inline; reference : reference; } - - let make text reference = { text; reference } - let text l = l.text - let reference l = l.reference - let referenced_label l = match l.reference with - | `Inline _ -> None | `Ref (_, _, k) -> Some k - - let reference_definition defs l = match l.reference with - | `Inline ld -> Some (Link_definition.Def ld) - | `Ref (_, _, def) -> Label.Map.find_opt (Label.key def) defs - - let is_unsafe l = - let allowed_data_url l = - let allowed = ["image/gif"; "image/png"; "image/jpeg"; "image/webp"] in - (* Extract mediatype from data:[][;base64], *) - match String.index_from_opt l 4 ',' with - | None -> false - | Some j -> - let k = match String.index_from_opt l 4 ';' with - | None -> j | Some k -> k - in - let t = String.sub l 5 (min j k - 5) in - List.mem t allowed - in - Ascii.caseless_starts_with ~prefix:"javascript:" l || - Ascii.caseless_starts_with ~prefix:"vbscript:" l || - Ascii.caseless_starts_with ~prefix:"file:" l || - (Ascii.caseless_starts_with ~prefix:"data:" l && not (allowed_data_url l)) - end - - module Raw_html = struct - type t = Block_line.tight list - end - - module Text = struct - type t = string - end - - type t += - | Autolink of Autolink.t node - | Break of Break.t node - | Code_span of Code_span.t node - | Emphasis of Emphasis.t node - | Image of Link.t node - | Inlines of t list node - | Link of Link.t node - | Raw_html of Raw_html.t node - | Strong_emphasis of Emphasis.t node - | Text of Text.t node - - let empty = Inlines ([], Meta.none) - - let err_unknown = "Unknown Cmarkit.Inline.t type extension" - - (* Extensions *) - - module Strikethrough = struct - type nonrec t = t - let make = Fun.id - let inline = Fun.id - end - - module Math_span = struct - type t = { display : bool; tex_layout : Block_line.tight list; } - let make ~display tex_layout = { display; tex_layout } - let display ms = ms.display - let tex_layout ms = ms.tex_layout - let tex ms = - let s = List.map Block_line.tight_to_string ms.tex_layout in - String.concat " "s - end - - type t += - | Ext_strikethrough of Strikethrough.t node - | Ext_math_span of Math_span.t node - - (* Functions on inlines *) - - let is_empty = function - | Text ("", _) | Inlines ([], _) -> true | _ -> false - - let ext_none _ = invalid_arg err_unknown - let meta ?(ext = ext_none) = function - | Autolink (_, m) | Break (_, m) | Code_span (_, m) | Emphasis (_, m) - | Image (_, m) | Inlines (_, m) | Link (_, m) | Raw_html (_, m) - | Strong_emphasis (_, m) | Text (_, m) -> m - | Ext_strikethrough (_, m) -> m | Ext_math_span (_, m) -> m - | i -> ext i - - let rec normalize ?(ext = ext_none) = function - | Autolink _ | Break _ | Code_span _ | Raw_html _ | Text _ - | Inlines ([], _) | Ext_math_span _ as i -> i - | Image (l, m) -> Image ({ l with text = normalize ~ext l.text }, m) - | Link (l, m) -> Link ({ l with text = normalize ~ext l.text }, m) - | Inlines ([i], _) -> i - | Emphasis (e, m) -> - Emphasis ({ e with inline = normalize ~ext e.inline}, m) - | Strong_emphasis (e, m) -> - Strong_emphasis ({ e with inline = normalize ~ext e.inline}, m) - | Inlines (i :: is, m) -> - let rec loop acc = function - | Inlines (is', m) :: is -> loop acc (List.rev_append (List.rev is') is) - | Text (t', m') as i' :: is -> - begin match acc with - | Text (t, m) :: acc -> - let tl = Textloc.span (Meta.textloc m) (Meta.textloc m') in - let i = Text (t ^ t', Meta.with_textloc ~keep_id:true m tl) in - loop (i :: acc) is - | _ -> loop (normalize ~ext i' :: acc) is - end - | i :: is -> loop (normalize ~ext i :: acc) is - | [] -> List.rev acc - in - let is = loop [normalize ~ext i] is in - (match is with [i] -> i | _ -> Inlines (is, m)) - | Ext_strikethrough (i, m) -> Ext_strikethrough (normalize ~ext i, m) - | i -> ext i - - let ext_none ~break_on_soft = ext_none - let to_plain_text ?(ext = ext_none) ~break_on_soft i = - let push s acc = (s :: List.hd acc) :: List.tl acc in - let newline acc = [] :: (List.rev (List.hd acc)) :: List.tl acc in - let rec loop ~break_on_soft acc = function - | Autolink (a, _) :: is -> - let acc = push (String.concat "" ["<"; fst a.link; ">"]) acc in - loop ~break_on_soft acc is - | Break ({ type' = `Hard }, _) :: is -> - loop ~break_on_soft (newline acc) is - | Break ({ type' = `Soft }, _) :: is -> - let acc = if break_on_soft then newline acc else (push " " acc) in - loop ~break_on_soft acc is - | Code_span (cs, _) :: is -> - loop ~break_on_soft (push (Code_span.code cs) acc) is - | Emphasis ({ inline }, _) :: is | Strong_emphasis ({ inline }, _) :: is -> - loop ~break_on_soft acc (inline :: is) - | Inlines (is', _) :: is -> - loop ~break_on_soft acc (List.rev_append (List.rev is') is) - | Link (l, _) :: is | Image (l, _) :: is -> - loop ~break_on_soft acc (l.text :: is) - | Raw_html _ :: is -> - loop ~break_on_soft acc is - | Text (t, _) :: is -> - loop ~break_on_soft (push t acc) is - | Ext_strikethrough (i, _) :: is -> - loop ~break_on_soft acc (i :: is) - | Ext_math_span (m, _) :: is -> - loop ~break_on_soft (push (Math_span.tex m) acc) is - | i :: is -> - loop ~break_on_soft acc (ext ~break_on_soft i :: is) - | [] -> - List.rev ((List.rev (List.hd acc)) :: List.tl acc) - in - loop ~break_on_soft ([] :: []) [i] - - let id ?buf ?ext i = - let text = to_plain_text ?ext ~break_on_soft:false i in - let s = String.concat "\n" (List.map (String.concat "") text) in - let b = match buf with - | Some b -> Buffer.reset b; b | None -> Buffer.create 256 - in - let[@inline] collapse_blanks b ~prev_byte = - (* Collapses non initial white *) - if Ascii.is_blank prev_byte && Buffer.length b <> 0 - then Buffer.add_char b '-' - in - let rec loop b s max ~prev_byte k = - if k > max then Buffer.contents b else - match s.[k] with - | ' ' | '\t' as prev_byte -> loop b s max ~prev_byte (k + 1) - | '_' | '-' as c -> - collapse_blanks b ~prev_byte; - Buffer.add_char b c; - loop b s max ~prev_byte:c (k + 1) - | c -> - let () = collapse_blanks b ~prev_byte in - let d = String.get_utf_8_uchar s k in - let u = Uchar.utf_decode_uchar d in - let u = match Uchar.to_int u with 0x0000 -> Uchar.rep | _ -> u in - let k' = k + Uchar.utf_decode_length d in - if Cmarkit_data.is_unicode_punctuation u - then loop b s max ~prev_byte:'\x00' k' else - let () = match Cmarkit_data.unicode_case_fold u with - | None -> Buffer.add_utf_8_uchar b u - | Some fold -> Buffer.add_string b fold - in - let prev_byte = s.[k] in - loop b s max ~prev_byte k' - in - loop b s (String.length s - 1) ~prev_byte:'\x00' 0 -end - -(* Blocks *) - -module Block = struct - type t = .. - - module Blank_line = struct - type t = Layout.blanks - end - - module Block_quote = struct - type nonrec t = { indent : Layout.indent; block : t; } - let make ?(indent = 0) block = { indent; block } - let indent bq = bq.indent - let block bq = bq.block - end - - module Code_block = struct - type fenced_layout = - { indent : Layout.indent; - opening_fence : Layout.string node; - closing_fence : Layout.string node option; } - - let default_fenced_layout = - { indent = 0; - opening_fence = Layout.empty; - closing_fence = Some Layout.empty } - - type layout = [ `Indented | `Fenced of fenced_layout ] - type t = - { layout : layout; - info_string : string node option; - code : string node list; } - - let make ?(layout = `Fenced default_fenced_layout) ?info_string code = - let layout = match info_string, layout with - | Some _, `Indented -> `Fenced default_fenced_layout - | _, layout -> layout - in - { layout; info_string; code } - - let layout cb = cb.layout - let info_string cb = cb.info_string - let code cb = cb.code - - let make_fence cb = - let rec loop char counts = function - | [] -> counts - | (c, _) :: cs -> - let max = String.length c - 1 in - let k = ref 0 in - while (!k <= max && c.[!k] = char) do incr k done; - loop char (if !k <> 0 then !k :: counts else counts) cs - in - let char = match cb.info_string with - | Some (i, _) when String.exists (Char.equal '`') i -> '~' - | None | Some _ -> '`' - in - let counts = loop char [] cb.code in - char, - Inline.Code_span.min_backtick_count (* not char specific *) ~min:3 counts - - let language_of_info_string s = - let rec next_white s max i = - if i > max || Ascii.is_white s.[i] then i else - next_white s max (i + 1) - in - if s = "" then None else - let max = String.length s - 1 in - let white = next_white s max 0 in - let rem_first = Match.first_non_blank s ~last:max ~start:white in - let lang = String.sub s 0 white in - if lang = "" then None else - Some (lang, String.sub s rem_first (max - rem_first + 1)) - - let is_math_block = function - | None -> false | Some (i, _) -> match language_of_info_string i with - | Some ("math", _) -> true - | Some _ | None -> false - end - - module Heading = struct - type atx_layout = - { indent : Layout.indent; - after_opening : Layout.blanks; - closing : Layout.string; } - - let default_atx_layout = { indent = 0; after_opening = ""; closing = "" } - - type setext_layout = - { leading_indent : Layout.indent; - trailing_blanks : Layout.blanks; - underline_indent : Layout.indent; - underline_count : Layout.count node; - underline_blanks : Layout.blanks; } - - type layout = [ `Atx of atx_layout | `Setext of setext_layout ] - type id = [ `Auto of string | `Id of string ] - type t = { layout : layout; level : int; inline : Inline.t; id : id option } - - let make ?id ?(layout = `Atx default_atx_layout) ~level inline = - let max = match layout with `Atx _ -> 6 | `Setext _ -> 2 in - let level = Int.max 1 (Int.min level max) in - {layout; level; inline; id} - - let layout h = h.layout - let level h = h.level - let inline h = h.inline - let id h = h.id - end - - module Html_block = struct - type t = string node list - end - - module List_item = struct - type block = t - type t = - { before_marker : Layout.indent; - marker : Layout.string node; - after_marker : Layout.indent; - block : block; - ext_task_marker : Uchar.t node option } - - let make - ?(before_marker = 0) ?(marker = Layout.empty) ?(after_marker = 1) - ?ext_task_marker block - = - { before_marker; marker; after_marker; block; ext_task_marker } - - let block i = i.block - let before_marker i = i.before_marker - let marker i = i.marker - let after_marker i = i.after_marker - let ext_task_marker i = i.ext_task_marker - let task_status_of_task_marker u = match Uchar.to_int u with - | 0x0020 -> `Unchecked - | 0x0078 (* x *) | 0x0058 (* X *) | 0x2713 (* ✓ *) | 0x2714 (* ✔ *) - | 0x10102 (* 𐄂 *) | 0x1F5F8 (* 🗸*) -> `Checked - | 0x007E (* ~ *) -> `Cancelled - | _ -> `Other u - end - - module List' = struct - type type' = [ `Unordered of Layout.char | `Ordered of int * Layout.char ] - type t = - { type' : type'; - tight : bool; - items : List_item.t node list; } - - let make ?(tight = true) type' items = { type'; tight; items } - - let type' l = l.type' - let tight l = l.tight - let items l = l.items - end - - module Paragraph = struct - type t = - { leading_indent : Layout.indent; - inline : Inline.t; - trailing_blanks : Layout.blanks; } - - let make ?(leading_indent = 0) ?(trailing_blanks = "") inline = - { leading_indent; inline; trailing_blanks } - - let inline p = p.inline - let leading_indent p = p.leading_indent - let trailing_blanks p = p.trailing_blanks - end - - module Thematic_break = struct - type t = { indent : Layout.indent; layout : Layout.string } - let make ?(indent = 0) ?(layout = "---") () = { indent; layout } - let indent t = t.indent - let layout t = t.layout - end - - type t += - | Blank_line of Layout.blanks node - | Block_quote of Block_quote.t node - | Blocks of t list node - | Code_block of Code_block.t node - | Heading of Heading.t node - | Html_block of Html_block.t node - | Link_reference_definition of Link_definition.t node - | List of List'.t node - | Paragraph of Paragraph.t node - | Thematic_break of Thematic_break.t node - - let empty = Blocks ([], Meta.none) - - (* Extensions *) - - module Table = struct - type align = [ `Left | `Center | `Right ] - type sep = align option * Layout.count - type cell_layout = Layout.blanks * Layout.blanks - type row = - [ `Header of (Inline.t * cell_layout) list - | `Sep of sep node list - | `Data of (Inline.t * cell_layout) list ] - - type t = - { indent : Layout.indent; - col_count : int; - rows : (row node * Layout.blanks) list } - - let col_count rows = - let rec loop c = function - | (((`Header cols | `Data cols), _), _) :: rs -> - loop (Int.max (List.length cols) c) rs - | (((`Sep cols), _), _) :: rs -> - loop (Int.max (List.length cols) c) rs - | [] -> c - in - loop 0 rows - - let make ?(indent = 0) rows = { indent; col_count = col_count rows; rows } - let indent t = t.indent - let col_count t = t.col_count - let rows t = t.rows - - let parse_sep_row cs = - let rec loop acc = function - | [] -> Some (List.rev acc) - | (Inline.Text (s, meta), ("", "")) :: cs -> - if s = "" then None else - let max = String.length s - 1 in - let first_colon = s.[0] = ':' and last_colon = s.[max] = ':' in - let first = if first_colon then 1 else 0 in - let last = if last_colon then max - 1 else max in - begin - match - for i = first to last do if s.[i] <> '-' then raise Exit; done - with - | exception Exit -> None - | () -> - let count = last - first + 1 in - let sep = match first_colon, last_colon with - | false, false -> None - | true, true -> Some `Center - | true, false -> Some `Left - | false, true -> Some `Right - in - loop (((sep, count), meta) :: acc) cs - end - | _ -> None - in - loop [] cs - end - - module Footnote = struct - type nonrec t = - { indent : Layout.indent; - label : Label.t; - defined_label : Label.t option; - block : t } - - let make ?(indent = 0) ?defined_label:d label block = - let defined_label = match d with None -> Some label | Some d -> d in - { indent; label; defined_label; block } - - let indent fn = fn.indent - let label fn = fn.label - let defined_label fn = fn.defined_label - let block fn = fn.block - - type Label.def += Def of t node - let stub label defined_label = - Def ({ indent = 0; label; defined_label; block = empty}, Meta.none) - end - - type t += - | Ext_math_block of Code_block.t node - | Ext_table of Table.t node - | Ext_footnote_definition of Footnote.t node - - (* Functions on blocks *) - - let err_unknown = "Unknown Cmarkit.Block.t type extension" - - let ext_none _ = invalid_arg err_unknown - let meta ?(ext = ext_none) = function - | Blank_line (_, m) | Block_quote (_, m) | Blocks (_, m) | Code_block (_, m) - | Heading (_, m) | Html_block (_, m) | Link_reference_definition (_, m) - | List (_, m) | Paragraph (_, m) | Thematic_break (_, m) - | Ext_math_block (_, m) | Ext_table (_, m) - | Ext_footnote_definition (_, m) -> m - | b -> ext b - - let rec normalize ?(ext = ext_none) = function - | Blank_line _ | Code_block _ | Heading _ | Html_block _ - | Link_reference_definition _ | Paragraph _ | Thematic_break _ - | Blocks ([], _) | Ext_math_block _ | Ext_table _ as b -> b - | Block_quote (b, m) -> - let b = { b with block = normalize ~ext b.block } in - Block_quote (b, m) - | List (l, m) -> - let item (i, meta) = - let block = List_item.block i in - { i with List_item.block = normalize ~ext block }, meta - in - List ({ l with items = List.map item l.items }, m) - | Blocks (b :: bs, m) -> - let rec loop acc = function - | Blocks (bs', m) :: bs -> loop acc (List.rev_append (List.rev bs') bs) - | b :: bs -> loop (normalize ~ext b :: acc) bs - | [] -> List.rev acc - in - let bs = loop [normalize ~ext b] bs in - (match bs with [b] -> b | _ -> Blocks (bs, m)) - | Ext_footnote_definition (fn, m) -> - let fn = { fn with block = normalize ~ext fn.block } in - Ext_footnote_definition (fn, m) - | b -> ext b - - let rec defs - ?(ext = fun b defs -> invalid_arg err_unknown) ?(init = Label.Map.empty) - = function - | Blank_line _ | Code_block _ | Heading _ | Html_block _ - | Paragraph _ | Thematic_break _ - | Ext_math_block _ | Ext_table _ -> init - | Block_quote (b, _) -> defs ~ext ~init (Block_quote.block b) - | Blocks (bs, _) -> List.fold_left (fun init b -> defs ~ext ~init b) init bs - | List (l, _) -> - let add init (i, _) = defs ~ext ~init (List_item.block i) in - List.fold_left add init l.items - | Link_reference_definition ld -> - begin match Link_definition.defined_label (fst ld) with - | None -> init - | Some def -> - Label.Map.add (Label.key def) (Link_definition.Def ld) init - end - | Ext_footnote_definition fn -> - let init = match Footnote.defined_label (fst fn) with - | None -> init - | Some def -> Label.Map.add (Label.key def) (Footnote.Def fn) init - in - defs ~ext ~init (Footnote.block (fst fn)) - | b -> ext init b -end - -(* Parsing *) - -(* Closer indexes. - - They map closing delimiters to the position where they - start. Shortcuts forward searches in inline parsing. See - Inline_struct. *) - -module Pos_set = Set.Make (Int) (* Sets of positions. *) -module Closer = struct - type t = - | Backticks of int (* run length *) - | Right_brack - | Right_paren (* Only for ruling out pathological cases. *) - | Emphasis_marks of char - | Strikethrough_marks - | Math_span_marks of int (* run length *) - - let compare = Stdlib.compare -end - -module Closer_index = struct - include Map.Make (Closer) - type nonrec t = Pos_set.t t - - let add cl pos cidx = - let add = function - | None -> Some (Pos_set.singleton pos) - | Some occs -> Some (Pos_set.add pos occs) - in - update cl add cidx - - let closer_pos cl ~after cidx = match find_opt cl cidx with - | None -> None - | Some occs -> Pos_set.find_first_opt (fun pos -> pos > after) occs - - let closer_exists cl ~after cidx = match closer_pos cl ~after cidx with - | None -> false | Some _ -> true -end - -(* Columns. That notion is needed to handle tab stops. - See https://spec.commonmark.org/current/#tabs *) - -type col = int -let[@inline] next_tab_stop col = (col + 4) land (lnot 3) - -(* Parser abstraction *) - -type parser = - { file : Textloc.fpath (* input file name *); - i : string (* input string *); - buf : Buffer.t (* scratch buffer. *); - exts : bool; (* parse extensions if [true]. *) - nolocs : bool; (* do not compute locations if [true]. *) - nolayout : bool; (* do not compute layout fields if [true]. *) - heading_auto_ids : bool; (* compute heading ids. *) - nested_links : bool; - mutable defs : Label.defs; - resolver : Label.resolver; - mutable cidx : Closer_index.t; (* For inline parsing. *) - (* Current line (only used during block parsing) *) - mutable current_line_pos : Textloc.line_pos; - mutable current_line_last_char : - (* first char of line - 1 on empty lines *) Textloc.byte_pos; - mutable current_char : Textloc.byte_pos; - mutable current_char_col : col; - mutable next_non_blank : - (* current_line_last_char + 1 if none. *) Textloc.byte_pos; - mutable next_non_blank_col : col; - mutable tab_consumed_cols : - (* number of cols consumed from the tab if i.[current_char] is '\t' *) - col; } - -let parser - ?(defs = Label.Map.empty) ?(resolver = Label.default_resolver) - ?(nested_links = false) ?(heading_auto_ids = false) ?(layout = false) - ?(locs = false) ?(file = Textloc.file_none) ~strict i - = - let nolocs = not locs and nolayout = not layout and exts = not strict in - { file; i; buf = Buffer.create 512; exts; nolocs; nolayout; - heading_auto_ids; nested_links; defs; resolver; cidx = Closer_index.empty; - current_line_pos = 1, 0; current_line_last_char = -1; current_char = 0; - current_char_col = 0; next_non_blank = 0; next_non_blank_col = 0; - tab_consumed_cols = 0; } - -let find_label_defining_key p key = match Label.Map.find_opt key p.defs with -| Some (Link_definition.Def ld) -> Link_definition.defined_label (fst ld) -| Some (Block.Footnote.Def fn) -> Block.Footnote.defined_label (fst fn) -| None -> None -| _ -> assert false - -let set_label_def p l def = p.defs <- Label.Map.add (Label.key l) def p.defs -let def_label p l = - p.resolver (`Def (find_label_defining_key p (Label.key l), l)) - -let find_def_for_ref ~image p ref = - let kind = if image then `Image else `Link in - let def = find_label_defining_key p (Label.key ref) in - p.resolver (`Ref (kind, ref, def)) - -let debug_span p s = String.sub p.i s.first (s.last - s.first + 1) -let debug_line p = - let first = snd p.current_line_pos and last = p.current_line_last_char in - String.sub p.i first (last - first + 1) - -let current_line_span p ~first ~last = - { line_pos = p.current_line_pos; first; last } - -(* Making metas and text locations. This is centralized here to be able - to disable their creation which has a non-negligible impact on - performance. *) - -let meta p textloc = if p.nolocs then Meta.none else Meta.make ~textloc () - -let textloc_of_span p span = - if p.nolocs then Textloc.none else - let first_byte = span.first and last_byte = span.last in - let first_line = span.line_pos and last_line = span.line_pos in - Textloc.v ~file:p.file ~first_byte ~last_byte ~first_line ~last_line - -let textloc_of_lines p ~first ~last ~first_line ~last_line = - if p.nolocs then Textloc.none else - let first_byte = first and first_line = first_line.line_pos in - let last_byte = last and last_line = last_line.line_pos in - Textloc.v ~file:p.file ~first_byte ~last_byte ~first_line ~last_line - -let meta_of_spans p ~first:first_line ~last:last_line = - if p.nolocs then Meta.none else - let first = first_line.first and last = last_line.last in - meta p (textloc_of_lines p ~first ~last ~first_line ~last_line) - -let meta_of_metas p ~first ~last = - if p.nolocs then Meta.none else - meta p (Textloc.span (Meta.textloc first) (Meta.textloc last)) - -let clean_raw_span ?pad p span = - Text.utf_8_clean_raw ?pad p.buf p.i ~first:span.first ~last:span.last, - meta p (textloc_of_span p span) - -let clean_unref_span p span = - Text.utf_8_clean_unref p.buf p.i ~first:span.first ~last:span.last, - meta p (textloc_of_span p span) - -let clean_unesc_unref_span p span = - Text.utf_8_clean_unesc_unref p.buf p.i ~first:span.first ~last:span.last, - meta p (textloc_of_span p span) - -let layout_clean_raw_span ?pad p span = - if p.nolayout then Layout.empty else clean_raw_span ?pad p span - -let layout_clean_raw_span' ?pad p span = - (* Like [layout_raw_span] but no meta *) - if p.nolayout then "" else - Text.utf_8_clean_raw ?pad p.buf p.i ~first:span.first ~last:span.last - -let _tight_block_lines xxx_span p ~rev_spans = - let rec loop p acc = function - | [] -> acc - | [_, fst_line] -> ("", xxx_span p fst_line) :: acc - | (line_start, span) :: spans -> - let acc = - let layout = - if p.nolayout || span.first <= line_start then "" else - Text.utf_8_clean_raw p.buf p.i ~first:line_start - ~last:(span.first - 1) - in - (layout, xxx_span p span) :: acc - in - loop p acc spans - in - loop p [] rev_spans - -let tight_block_lines p ~rev_spans = - _tight_block_lines clean_unesc_unref_span p ~rev_spans - -let raw_tight_block_lines p ~rev_spans = - _tight_block_lines clean_raw_span p ~rev_spans - -let first_non_blank_in_span p s = Match.first_non_blank_in_span p.i s -let first_non_blank_over_nl ~next_line p lines line ~start = - match Match.first_non_blank_over_nl ~next_line p.i lines ~line ~start with - | `None -> None - | `This_line non_blank -> - let layout = - if non_blank = start then [] else - [clean_raw_span p { line with first = start ; last = non_blank - 1}] - in - Some (lines, line, layout, non_blank) - | `Next_line (lines, newline, non_blank) -> - let first_layout = clean_raw_span p { line with first = start } in - let next_layout = clean_raw_span p { newline with last = non_blank -1 } in - let layout = [first_layout; next_layout] in - Some (lines, newline, layout, non_blank) - -(* Inline structure parsing *) - -module Inline_struct = struct - - (* Tokens for parsing inlines. - - The list of tokens of a paragraph are the points to consider to - parse it into inlines. Tokens gradually become [Inline] tokens - containing parsed inlines. Between two tokens there is implicit - textual data. This data gradually becomes part of [Inline] tokens - or, at the end of of the parsing process, becomes [Text] inlines. - - The token list also represents newlines explicitly, either via - the [Newline] token or via the [Inline] token since inlines may - start on a line and up on another one. *) - - type emphasis_marks = - { start : byte_pos; - char : char; - count : int; - may_open : bool; - may_close : bool } - - type strikethrough_marks = - { start : byte_pos; - may_open : bool; - may_close : bool } - - type math_span_marks = - { start : byte_pos; - count : int; - may_open : bool; - may_close : bool; } - - type token = - | Autolink_or_html_start of { start : byte_pos } - | Backticks of - { start : byte_pos; - count : int; - escaped : bool } - | Emphasis_marks of emphasis_marks - | Inline of - { start : byte_pos; - inline : Inline.t; - endline : line_span; - next : byte_pos } - | Link_start of - { start : byte_pos; - image : bool } - | Newline of - { start : (* points on spaces or \ on the broken line *) byte_pos; - break_type : Inline.Break.type'; - newline : line_span; } - | Right_brack of { start : byte_pos } - | Right_paren of { start : byte_pos } (* Only used for closer index *) - | Strikethrough_marks of strikethrough_marks - | Math_span_marks of math_span_marks - - let token_start = function - | Autolink_or_html_start { start } | Backticks { start } - | Emphasis_marks { start } | Inline { start } -> start | Link_start { start } - | Newline { start } | Right_brack { start } -> start - | Right_paren { start } -> start - | Strikethrough_marks { start } -> start - | Math_span_marks { start } -> start - - let has_backticks ~count ~after cidx = - Closer_index.closer_exists (Closer.Backticks count) ~after cidx - - let has_right_brack ~after cidx = - Closer_index.closer_exists Closer.Right_brack ~after cidx - - let has_right_paren ~after cidx = - Closer_index.closer_exists Closer.Right_paren ~after cidx - - let emphasis_closer_pos ~char ~after cidx = - Closer_index.closer_pos (Closer.Emphasis_marks char) ~after cidx - - let has_emphasis_closer ~char ~after cidx = - Closer_index.closer_exists (Closer.Emphasis_marks char) ~after cidx - - let has_strikethrough_closer ~after cidx = - Closer_index.closer_exists Closer.Strikethrough_marks ~after cidx - - let has_math_span_closer ~count ~after cidx = - Closer_index.closer_exists (Closer.Math_span_marks count) ~after cidx - - let rev_token_list_and_make_closer_index toks = - let rec loop cidx acc = function - | Backticks { start; count; _ } as t :: toks -> - let cidx = Closer_index.add (Closer.Backticks count) start cidx in - loop cidx (t :: acc) toks - | Right_brack { start } as t :: toks -> - let cidx = Closer_index.add Closer.Right_brack start cidx in - loop cidx (t :: acc) toks - | Right_paren { start } :: toks -> - let cidx = Closer_index.add Closer.Right_paren start cidx in - loop cidx (* we don't use the token for parsing *) acc toks - | Emphasis_marks { start; char; may_close = true } as t :: toks -> - let cidx = Closer_index.add (Closer.Emphasis_marks char) start cidx in - loop cidx (t :: acc) toks - | Strikethrough_marks { start; may_close = true } as t :: toks -> - let cidx = Closer_index.add Closer.Strikethrough_marks start cidx in - loop cidx (t :: acc) toks - | Math_span_marks { start; count; may_close = true } as t :: toks -> - let cidx = Closer_index.add (Closer.Math_span_marks count) start cidx in - loop cidx (t :: acc) toks - | t :: toks -> loop cidx (t :: acc) toks - | [] -> cidx, acc - in - loop Closer_index.empty [] toks - - let rec rev_tokens_and_shorten_last_line ~to_last:last acc = function - (* Used to make the text delimitation precise for nested inlines *) - | Newline ({ newline; _ } as nl) :: toks -> - let t = Newline { nl with newline = { newline with last }} in - List.rev_append toks (t :: acc) - | Inline ({ endline; _ } as i) :: toks -> - let t = Inline { i with endline = { endline with last }} in - List.rev_append toks (t :: acc) - | t :: toks -> rev_tokens_and_shorten_last_line ~to_last:last (t :: acc) toks - | [] -> acc - - let rec drop_stop_after_right_brack = function - | Right_brack _ :: toks -> toks - | _ :: toks -> drop_stop_after_right_brack toks - | [] -> [] - - let rec drop_until ~start = function - | t :: toks when token_start t < start -> drop_until ~start toks - | toks -> toks - - let rec next_line = function - (* N.B. when we use this function considering Inline tokens is not needed. *) - | [] -> None - | Newline { newline; _ } :: toks -> Some (toks, newline) - | _ :: toks -> next_line toks - - (* Tokenization *) - - let newline_token s prev_line newline = - (* https://spec.commonmark.org/current/#softbreak *) - (* https://spec.commonmark.org/current/#hard-line-breaks *) - let start (* includes spaces or '\\' on prev line *), break_type = - let first = prev_line.first and last = prev_line.last in - let non_space = Match.rev_drop_spaces s ~first ~start:last in - if non_space = last && s.[non_space] = '\\' then (non_space, `Hard) else - let start = non_space + 1 in - (start, if last - start + 1 >= 2 then `Hard else `Soft) - in - Newline { start; break_type; newline } - - let add_backtick_token acc s line ~prev_bslash ~start = - let last = Match.run_of ~char:'`' s ~last:line.last ~start:(start + 1) in - let count = last - start + 1 and escaped = prev_bslash in - Backticks {start; count; escaped} :: acc, last + 1 - - let try_add_image_link_start_token acc s line ~start = - let next = start + 1 in - if next > line.last || s.[next] <> '[' then acc, next else - Link_start { start; image = true } :: acc, next + 1 - - let try_add_emphasis_token acc s line ~start = - let first = line.first and last = line.last and char = s.[start] in - let run_last = Match.run_of ~char ~last s ~start:(start + 1) in - let count = run_last - start + 1 in - let prev_uchar = Match.prev_uchar s ~first ~before:start in - let next_uchar = Match.next_uchar s ~last ~after:run_last in - let prev_white = Cmarkit_data.is_unicode_whitespace prev_uchar in - let next_white = Cmarkit_data.is_unicode_whitespace next_uchar in - let prev_punct = Cmarkit_data.is_unicode_punctuation prev_uchar in - let next_punct = Cmarkit_data.is_unicode_punctuation next_uchar in - let is_left_flanking = - not next_white && (not next_punct || (prev_white || prev_punct)) - in - let is_right_flanking = - not prev_white && (not prev_punct || (next_white || next_punct)) - in - let next = run_last + 1 in - if not is_left_flanking && not is_right_flanking then acc, next else - let may_open = - (char = '*' && is_left_flanking) || - (char = '_' && is_left_flanking && (not is_right_flanking || prev_punct)) - in - let may_close = - (char = '*' && is_right_flanking) || - (char = '_' && is_right_flanking && (not is_left_flanking || next_punct)) - in - if not may_open && not may_close then acc, next else - Emphasis_marks { start; char; count; may_open; may_close } :: acc, next - - let try_add_strikethrough_marks_token acc s line ~start = - let first = line.first and last = line.last and char = s.[start] in - let run_last = Match.run_of ~char ~last s ~start:(start + 1) in - let count = run_last - start + 1 in - let next = run_last + 1 in - if count <> 2 then acc, next else - let prev_uchar = Match.prev_uchar s ~first ~before:start in - let next_uchar = Match.next_uchar s ~last ~after:run_last in - let may_close = not (Cmarkit_data.is_unicode_whitespace prev_uchar) in - let may_open = not (Cmarkit_data.is_unicode_whitespace next_uchar) in - if not may_open && not may_close then acc, next else - Strikethrough_marks { start; may_open; may_close } :: acc, next - - let try_add_math_span_marks_token acc s line ~start = - let first = line.first and last = line.last and char = s.[start] in - let run_last = Match.run_of ~char ~last s ~start:(start + 1) in - let count = run_last - start + 1 in - let next = run_last + 1 in - if count > 2 then acc, next else - let may_open, may_close = - if count <> 1 then true, true else - let prev_uchar = Match.prev_uchar s ~first ~before:start in - let next_uchar = Match.next_uchar s ~last ~after:run_last in - let may_close = not (Cmarkit_data.is_unicode_whitespace prev_uchar) in - let may_open = not (Cmarkit_data.is_unicode_whitespace next_uchar) in - may_open, may_close - in - if not may_open && not may_close then acc, next else - Math_span_marks { start; count; may_open; may_close } :: acc, next - - let tokenize ~exts s lines = - (* For inlines this is where we conditionalize for extensions. All code - paths after that no longer check for p.exts: there just won't be - extension data to process if [exts] was not [true] here. *) - let rec loop ~exts s lines line ~prev_bslash acc k = - if k > line.last then match lines with - | [] -> rev_token_list_and_make_closer_index acc - | newline :: lines -> - let t = newline_token s line newline in - loop ~exts s lines newline ~prev_bslash:false (t :: acc) newline.first - else - if s.[k] = '\\' - then loop ~exts s lines line ~prev_bslash:(not prev_bslash) acc (k+1) else - let acc, next = match s.[k] with - | '`' -> add_backtick_token acc s line ~prev_bslash ~start:k - | c when prev_bslash -> acc, k + 1 - | '*' | '_' -> try_add_emphasis_token acc s line ~start:k - | ']' -> Right_brack { start = k } :: acc, k + 1 - | '[' -> Link_start { start = k; image = false } :: acc, k + 1 - | '!' -> try_add_image_link_start_token acc s line ~start:k - | '<' -> Autolink_or_html_start { start = k } :: acc, k + 1 - | ')' -> Right_paren { start = k } :: acc, k + 1 - | '~' when exts -> try_add_strikethrough_marks_token acc s line ~start:k - | '$' when exts -> try_add_math_span_marks_token acc s line ~start:k - | _ -> acc, k + 1 - in - loop ~exts s lines line ~prev_bslash:false acc next - in - let line = List.hd lines and lines = List.tl lines in - let cidx, toks = loop ~exts s lines line ~prev_bslash:false [] line.first in - cidx, toks, line - - (* Making inlines and inline tokens *) - - let break_inline p line ~start ~break_type:type' ~newline = - let layout_before = { line with first = start } in - let layout_after = - let non_blank = first_non_blank_in_span p newline in - { newline with last = non_blank - 1 } - in - let m = meta_of_spans p ~first:layout_before ~last:layout_after in - let layout_before = layout_clean_raw_span p layout_before in - let layout_after = layout_clean_raw_span p layout_after in - Inline.Break ({ layout_before; type'; layout_after }, m) - - let try_add_text_inline p line ~first ~last acc = - if first > last then acc else - let first = match first = line.first with - | true -> first_non_blank_in_span p line (* strip leading blanks *) - | false -> first - in - Inline.Text (clean_unesc_unref_span p { line with first; last }) :: acc - - let inlines_inline p ~first ~last ~first_line ~last_line = function - | [i] -> i - | is -> - let textloc = textloc_of_lines p ~first ~last ~first_line ~last_line in - Inline.Inlines (is, meta p textloc) - - let code_span_token p ~count ~first ~last ~first_line ~last_line rev_spans = - let textloc = textloc_of_lines p ~first ~last ~first_line ~last_line in - let code_layout = raw_tight_block_lines p ~rev_spans in - let meta = meta p textloc in - let cs = Inline.Code_span ({ backtick_count = count; code_layout }, meta) in - Inline { start = first; inline = cs; endline = last_line; next = last + 1 } - - let autolink_token p line ~first ~last ~is_email = - let meta = meta p (textloc_of_span p { line with first; last }) in - let link = { line with first = first + 1; last = last - 1 } in - let link = clean_unref_span p link in - let inline = Inline.Autolink ({ is_email; link }, meta) in - Inline { start = first; inline; endline = line; next = last + 1 } - - let raw_html_token p ~first ~last ~first_line ~last_line rev_spans = - let raw = raw_tight_block_lines p ~rev_spans in - let textloc = - let first = Meta.textloc (snd (snd (List.hd raw))) in - let last = snd (List.hd rev_spans) in - let last_byte = last.last and last_line = last.line_pos in - Textloc.set_last first ~last_byte ~last_line - in - let inline = Inline.Raw_html (raw, meta p textloc) in - Inline { start = first; inline; endline = last_line; next = last + 1 } - - let link_token p ~first ~last ~first_line ~last_line ~image link = - let textloc = textloc_of_lines p ~first ~last ~first_line ~last_line in - let link = link, meta p textloc in - let inline = if image then Inline.Image link else Inline.Link link in - Inline { start = first; inline; endline = last_line; next = last + 1 } - - let emphasis_token p ~first ~last ~first_line ~last_line ~strong emph = - let textloc = textloc_of_lines p ~first ~last ~first_line ~last_line in - let delim = p.i.[first] in - let e = { Inline.Emphasis.delim; inline = emph}, meta p textloc in - let i = if strong then Inline.Strong_emphasis e else Inline.Emphasis e in - Inline { start = first; inline = i ; endline = last_line; next = last + 1 } - - let ext_strikethrough_token p ~first ~last ~first_line ~last_line s = - let textloc = textloc_of_lines p ~first ~last ~first_line ~last_line in - let inline = Inline.Ext_strikethrough (s, meta p textloc) in - Inline { start = first; inline; endline = last_line; next = last + 1 } - - let ext_math_span_token p ~count ~first ~last ~first_line ~last_line rspans = - let textloc = textloc_of_lines p ~first ~last ~first_line ~last_line in - let tex_layout = raw_tight_block_lines p ~rev_spans:rspans in - let meta = meta p textloc in - let ms = Inline.Math_span.make ~display:(count = 2) tex_layout in - let inline = Inline.Ext_math_span (ms, meta) in - Inline { start = first; inline; endline = last_line; next = last + 1 } - - (* Parsers *) - - let try_code p toks start_line ~start:cstart ~count ~escaped = - (* https://spec.commonmark.org/current/#code-span *) - if escaped || not (has_backticks ~count ~after:cstart p.cidx) then None else - let rec match_backticks toks line ~count spans k = match toks with - | [] -> None - | Backticks { start; count = c; _ } :: toks -> - if c <> count then match_backticks toks line ~count spans k else - let span = line.first, { line with first = k; last = start - 1} in - let spans = span :: spans in - let first = cstart and last = start + count - 1 in - let first_line = start_line and last_line = line in - let t = - code_span_token p ~count ~first ~last ~first_line ~last_line spans - in - Some (toks, line, t) - | Newline { newline } :: toks -> - let spans = (line.first, { line with first = k }) :: spans in - let k = first_non_blank_in_span p newline in - match_backticks toks newline ~count spans k - | _ :: toks -> match_backticks toks line ~count spans k - in - let first = cstart + count in - match_backticks toks { start_line with first } ~count [] first - - let try_math_span p toks start_line ~start:cstart ~count = - if not (has_math_span_closer ~count ~after:cstart p.cidx) then None else - let rec match_math_marks toks line ~count spans k = match toks with - | [] -> None - | Math_span_marks { start; count = c; may_close; _ } :: toks -> - if c <> count || not may_close - then match_math_marks toks line ~count spans k else - let span = line.first, { line with first = k; last = start - 1 } in - let spans = span :: spans in - let first = cstart and last = start + count - 1 in - let first_line = start_line and last_line = line in - let t = - ext_math_span_token p ~count ~first ~last ~first_line ~last_line - spans - in - Some (toks, line, t) - | Newline { newline } :: toks -> - let spans = (line.first, { line with first = k }) :: spans in - let k = first_non_blank_in_span p newline in - match_math_marks toks newline ~count spans k - | _ :: toks -> match_math_marks toks line ~count spans k - in - let first = cstart + count in - match_math_marks toks { start_line with first } ~count [] first - - let try_autolink_or_html p toks line ~start = - match Match.autolink_uri p.i ~last:line.last ~start with - | Some last -> - let t = autolink_token p line ~first:start ~last ~is_email:false in - let toks = drop_until ~start:(last + 1) toks in - Some (toks, line, t) - | None -> - match Match.autolink_email p.i ~last:line.last ~start with - | Some last -> - let t = autolink_token p line ~first:start ~last ~is_email:true in - let toks = drop_until ~start:(last + 1) toks in - Some (toks, line, t) - | None -> - match Match.raw_html ~next_line p.i toks ~line ~start with - | None -> None - | Some (toks, last_line, spans, last) -> - let first = start and first_line = line in - let t = raw_html_token p ~first ~last ~first_line ~last_line spans in - let toks = drop_until ~start:(last + 1) toks in - Some (toks, last_line, t) - - let label_of_rev_spans p ~key rev_spans = - let meta = - if p.nolocs || rev_spans = [] then Meta.none else - let first = snd (List.hd (List.rev rev_spans)) in - let last = snd (List.hd rev_spans) in - meta_of_spans p ~first ~last - in - let text = tight_block_lines p ~rev_spans in - { Label.meta; key; text } - - let try_full_reflink_remainder p toks line ~image ~start (* is label's [ *) = - (* https://spec.commonmark.org/current/#full-reference-link *) - match Match.link_label p.buf ~next_line p.i toks ~line ~start with - | None -> None - | Some (toks, line, rev_spans, last, key) -> - let ref = label_of_rev_spans p ~key rev_spans in - let toks = drop_stop_after_right_brack toks in - match find_def_for_ref p ~image ref with - | None -> Some None - | Some def -> Some (Some (toks, line, `Ref (`Full, ref, def), last)) - - let try_shortcut_reflink p toks line ~image ~start (* is starting [ or ! *) = - (* https://spec.commonmark.org/current/#shortcut-reference-link *) - let start = if image then start + 1 (* [ *) else start in - match Match.link_label p.buf ~next_line p.i toks ~line ~start with - | None -> None - | Some (toks, line, rev_spans, last, key) -> - let ref = label_of_rev_spans p ~key rev_spans in - let toks = drop_stop_after_right_brack toks in - match find_def_for_ref p ~image ref with - | None -> None - | Some def -> Some (toks, line, `Ref (`Shortcut, ref, def), last) - - let try_collapsed_reflink p toks line ~image ~start (* is starting [ or ! *) = - (* https://spec.commonmark.org/current/#collapsed-reference-link *) - let start = if image then start + 1 (* [ *) else start in - match Match.link_label p.buf ~next_line p.i toks ~line ~start with - | None -> None - | Some (toks, line, rev_spans, last, key) -> - let ref = label_of_rev_spans p ~key rev_spans in - let last = last + 2 in (* adjust for ][] *) - let toks = drop_stop_after_right_brack toks in - let toks = drop_stop_after_right_brack toks in - match find_def_for_ref p ~image ref with - | None -> None - | Some def -> Some (toks, line, `Ref (`Collapsed, ref, def), last) - - let try_inline_link_remainder p toks start_line ~image ~start:st (* is ( *) = - (* https://spec.commonmark.org/current/#inline-link *) - if not (has_right_paren ~after:st p.cidx) then None else - let first_non_blank_over_nl = first_non_blank_over_nl ~next_line in - match first_non_blank_over_nl p toks start_line ~start:(st + 1) with - | None -> None - | Some (toks, line, before_dest, start) -> - let toks, line, angled_dest, dest, start = - match Match.link_destination p.i ~last:line.last ~start with - | None -> toks, line, false, None, start - | Some (angled, first, last) -> - let dest = clean_unesc_unref_span p { line with first; last } in - let next = if angled then last + 2 else last + 1 in - toks, line, angled, Some dest, next - in - let toks, line, after_dest, title_open_delim, title, start = - match first_non_blank_over_nl p toks line ~start with - | None -> - toks, line, [], '\"', None, start - | Some (_, _, _, start') when start' = start -> - toks, line, [], '\"', None, start - | Some (toks, line, after_destination, start) -> - match Match.link_title ~next_line p.i toks ~line ~start with - | None -> toks, line, after_destination, '\"', None, start - | Some (toks, line, rev_spans, last) -> - let title = tight_block_lines p ~rev_spans in - toks, line, after_destination, p.i.[start], - Some title, last + 1 - in - let toks, line, after_title, last = - match first_non_blank_over_nl p toks line ~start with - | None -> toks, line, [], start - | Some (toks, line, after_title, start as v) -> v - in - if last > line.last || p.i.[last] <> ')' then None else - let layout = - { Link_definition.indent = 0; angled_dest; before_dest; - after_dest; title_open_delim; after_title; } - in - let label = None and defined_label = None in - let ld = { Link_definition.layout; label; defined_label; dest; title }in - let textloc = - let first = st and last = start in - textloc_of_lines p ~first ~last ~first_line:start_line ~last_line:line - in - let ld = (ld, meta p textloc) in - let toks = drop_until ~start:(last + 1) toks in - Some (toks, line, `Inline ld, last) - - let find_link_text_tokens p toks start_line ~start = - (* XXX The repetition with first_pass is annoying here. - we should figure out something for that not to happen. *) - (* https://spec.commonmark.org/current/#link-text *) - let rec loop toks line nest acc = match toks with - | Right_brack { start = last } :: toks when nest = 0 -> - let acc = rev_tokens_and_shorten_last_line ~to_last:(last - 1) [] acc in - Some (toks, line, acc, last) - | Backticks { start; count; escaped } :: toks -> - begin match try_code p toks line ~start ~count ~escaped with - | None -> loop toks line nest acc - | Some (toks, line, t) -> loop toks line nest (t :: acc) - end - | Math_span_marks { start; count; may_open; } :: toks -> - if not may_open then loop toks line nest acc else - begin match try_math_span p toks line ~start ~count with - | None -> loop toks line nest acc - | Some (toks, line, t) -> loop toks line nest (t :: acc) - end - | Autolink_or_html_start { start } :: toks -> - begin match try_autolink_or_html p toks line ~start with - | None -> loop toks line nest acc - | Some (toks, line, t) -> loop toks line nest (t :: acc) - end - | Right_brack _ as t :: toks -> loop toks line (nest - 1) (t :: acc) - | Link_start _ as t :: toks -> loop toks line (nest + 1) (t :: acc) - | Newline { newline; _ } as t :: toks -> loop toks newline nest (t :: acc) - | Inline { endline; _ } as t :: toks -> loop toks endline nest (t :: acc) - | t :: toks -> loop toks line nest (t :: acc) - | [] -> None - in - loop toks start_line 0 [] - - let try_link_def - p ~start ~start_toks ~start_line ~toks ~line ~text_last ~image text - = - let next = text_last + 1 in - let link = - if next > line.last - then try_shortcut_reflink p start_toks start_line ~image ~start else - match p.i.[next] with - | '(' -> - (match try_inline_link_remainder p toks line ~image ~start:next with - | None -> try_shortcut_reflink p start_toks start_line ~image ~start - | Some _ as v -> v) - | '[' -> - let next' = next + 1 in - if next' <= line.last && p.i.[next'] = ']' - then try_collapsed_reflink p start_toks start_line ~image ~start else - let r = try_full_reflink_remainder p toks line ~image ~start:next in - begin match r with - | None -> try_shortcut_reflink p start_toks start_line ~image ~start - | Some None -> None (* Example 570 *) - | Some (Some _ as v) -> v - end - | c -> - try_shortcut_reflink p start_toks start_line ~image ~start - in - match link with - | None -> None - | Some (toks, endline, reference, last) -> - let first = start in - let text = - let first_line = start_line and last_line = line in - inlines_inline p text ~first ~last:text_last ~first_line ~last_line - in - let link = { Inline.Link.text; reference } in - let first_line = start_line and last_line = endline in - let t = link_token p ~image ~first ~last ~first_line ~last_line link in - let had_link = not image && not p.nested_links in - Some (toks, endline, t, had_link) - - (* The following sequence of mutually recursive functions define - inline parsing. We have three passes over a paragraph's token - list see the [parse_tokens] function below. *) - - let rec try_link p start_toks start_line ~image ~start = - if not (has_right_brack ~after:start p.cidx) then None else - match find_link_text_tokens p start_toks start_line ~start with - | None -> None - | Some (toks, line, text_toks, text_last (* with ] delim *)) -> - let text, had_link = - let text_start = - let first = start + (if image then 2 else 1) in - let last = - if start_line == line then text_last - 1 else start_line.last - in - { start_line with first; last } - in - parse_tokens p text_toks text_start - in - if had_link && not image - then None (* Could try to keep render *) else - try_link_def - p ~start ~start_toks ~start_line ~toks ~line ~text_last ~image text - - and first_pass p toks line = - (* Parse inline atoms and links. Links are parsed here otherwise - link reference data gets parsed as atoms. *) - let rec loop p toks line ~had_link acc = match toks with - | [] -> List.rev acc, had_link - | Backticks { start; count; escaped } :: toks -> - begin match try_code p toks line ~start ~count ~escaped with - | None -> loop p toks line ~had_link acc - | Some (toks, line, t) -> loop p toks line ~had_link (t :: acc) - end - | Math_span_marks { start; count; may_open; } :: toks -> - if not may_open then loop p toks line ~had_link acc else - begin match try_math_span p toks line ~start ~count with - | None -> loop p toks line ~had_link acc - | Some (toks, line, t) -> loop p toks line ~had_link (t :: acc) - end - | Autolink_or_html_start { start } :: toks -> - begin match try_autolink_or_html p toks line ~start with - | None -> loop p toks line ~had_link acc - | Some (toks, line, t) -> loop p toks line ~had_link (t :: acc) - end - | Link_start { start; image } :: toks -> - begin match try_link p toks line ~image ~start with - | None -> loop p toks line ~had_link acc - | Some (toks, line, t, had_link) -> - loop p toks line ~had_link (t :: acc) - end - | Right_brack start :: toks -> loop p toks line ~had_link acc - | Newline { newline = l } as t :: toks -> loop p toks l ~had_link (t :: acc) - | t :: toks -> loop p toks line ~had_link (t :: acc) - in - loop p toks line ~had_link:false [] - - (* Second pass *) - - and find_emphasis_text p toks line ~opener = - let marks_match ~marks ~opener = - (opener.char = marks.char) && - (not (marks.may_open || opener.may_close) || - marks.count mod 3 = 0 || (opener.count + marks.count) mod 3 != 0) - in - let marks_has_precedence p ~marks ~opener = - if marks.char = opener.char (* Rule 16 *) then true else (* Rule 15 *) - emphasis_closer_pos ~char:marks.char ~after:marks.start p.cidx < - emphasis_closer_pos ~char:opener.char ~after:marks.start p.cidx - in - let rec loop p toks line acc ~opener = match toks with - | [] -> Either.Left (List.rev acc) (* No match but keep nested work done *) - | Emphasis_marks marks as t :: toks -> - let after = marks.start in - if marks.may_close && marks_match ~marks ~opener then - let used = if marks.count >= 2 && opener.count >= 2 then 2 else 1 in - let to_last = marks.start - 1 in - let acc = rev_tokens_and_shorten_last_line ~to_last [] acc in - Either.Right (toks, line, used, acc, marks) - else if marks.may_open && marks_has_precedence p ~marks ~opener then - match try_emphasis p toks line ~opener:marks with - | Either.Left toks -> loop p toks line acc ~opener - | Either.Right (toks, line) -> loop p toks line acc ~opener - else if has_emphasis_closer ~char:opener.char ~after p.cidx then - loop p toks line (t :: acc) ~opener - else (Either.Left (List.rev_append (t :: acc) toks)) - | Newline { newline = l } as t :: toks -> loop p toks l (t :: acc) ~opener - | Inline { endline = l } as t :: toks -> loop p toks l (t :: acc) ~opener - | t :: toks -> loop p toks line (t :: acc) ~opener - in - loop p toks line [] ~opener - - and try_emphasis p start_toks start_line ~opener = - let start = opener.start in - if not (has_emphasis_closer ~char:opener.char ~after:start p.cidx) - then Either.Left start_toks else - match find_emphasis_text p start_toks start_line ~opener with - | Either.Left _ as r -> r - | Either.Right (toks, line, used, emph_toks, closer) -> - let text_first = start + opener.count in - let text_last = closer.start - 1 (* XXX prev line ? *) in - let first = text_first - used in - let last = closer.start + used - 1 in - let first_line = start_line and last_line = line in - let emph = - let text_start = - let last = - if start_line == line then text_last else start_line.last - in - { start_line with first = text_first; last } - in - (* No need to redo first pass *) - let emph_toks = second_pass p emph_toks text_start in - let text = last_pass p emph_toks text_start in - inlines_inline p text ~first ~last:text_last ~first_line ~last_line - in - let toks = - let count = closer.count - used in - if count = 0 then toks else - Emphasis_marks { closer with start = last + 1; count } :: toks - in - let toks = - let strong = used = 2 in - emphasis_token p ~first ~last ~first_line ~last_line ~strong emph :: - toks - in - let toks = - let count = opener.count - used in - if count = 0 then toks else - Emphasis_marks { opener with count } :: toks - in - Either.Right (toks, line) - - and find_strikethrough_text p toks start_line = - let rec loop p toks line acc = match toks with - | [] -> Either.Left (List.rev acc) (* No match but keep nested work done *) - | Strikethrough_marks marks :: toks -> - if marks.may_close then - let to_last = marks.start - 1 in - let acc = rev_tokens_and_shorten_last_line ~to_last [] acc in - Either.Right (toks, line, acc, marks) - else if marks.may_open then - match try_strikethrough p toks line ~opener:marks with - | Either.Left toks -> loop p toks line acc - | Either.Right (toks, line) -> loop p toks line acc - else assert false - | Newline { newline = l } as t :: toks -> loop p toks l (t :: acc) - | Inline { endline = l } as t :: toks -> loop p toks l (t :: acc) - | t :: toks -> loop p toks line (t :: acc) - in - loop p toks start_line [] - - and try_strikethrough p start_toks start_line ~opener = - let start = opener.start in - if not (has_strikethrough_closer ~after:start p.cidx) - then Either.Left start_toks else - match find_strikethrough_text p start_toks start_line with - | Either.Left _ as r -> r - | Either.Right (toks, line, stroken_toks, closer) -> - let first_line = start_line and last_line = line in - let text = - let first = start + 2 in - let last = closer.start - 1 in - let text_start = - let last = - if start_line == line then last else start_line.last - in - { start_line with first; last } - in - (* No need to redo first pass *) - let emph_toks = second_pass p stroken_toks text_start in - let text = last_pass p emph_toks text_start in - inlines_inline p text ~first ~last ~first_line ~last_line - in - let toks = - let first = opener.start and last = closer.start + 1 in - ext_strikethrough_token p ~first ~last ~first_line ~last_line text - :: toks - in - Either.Right (toks, line) - - and second_pass p toks line = - let rec loop p toks line acc = match toks with - | [] -> List.rev acc - | Emphasis_marks ({ may_open } as opener) :: toks -> - if not may_open then loop p toks line acc else - begin match try_emphasis p toks line ~opener with - | Either.Left toks -> loop p toks line acc - | Either.Right (toks, line) -> loop p toks line acc - end - | Strikethrough_marks ({ may_open } as opener) :: toks -> - if not may_open then loop p toks line acc else - begin match try_strikethrough p toks line ~opener with - | Either.Left toks -> loop p toks line acc - | Either.Right (toks, line) -> loop p toks line acc - end - | Newline { newline } as t :: toks -> loop p toks newline (t :: acc) - | Inline { endline } as t :: toks -> loop p toks endline (t :: acc) - | t :: toks -> loop p toks line (t :: acc) - in - loop p toks line [] - - (* Last pass *) - - and last_pass p toks line = - (* Only [Inline] and [Newline] tokens remain. We fold over them to - convert them to [inline] values and [Break]s. [Text] inlines - are created for data between them. *) - let rec loop toks line acc k = match toks with - | [] -> - List.rev (try_add_text_inline p line ~first:k ~last:line.last acc) - | Newline { start; break_type; newline } :: toks -> - let acc = try_add_text_inline p line ~first:k ~last:(start - 1) acc in - let break = break_inline p line ~start ~break_type ~newline in - loop toks newline (break :: acc) newline.first - | Inline { start; inline; endline; next } :: toks -> - let acc = try_add_text_inline p line ~first:k ~last:(start - 1) acc in - let acc = match inline with - | Inline.Inlines (is, _meta_stub) -> List.rev_append (List.rev is) acc - | i -> i :: acc - in - loop toks endline acc next - | (Backticks _ | Autolink_or_html_start _ | Link_start _ | Right_brack _ - | Emphasis_marks _ | Right_paren _ | Strikethrough_marks _ - | Math_span_marks _) :: _ -> - assert false - in - loop toks line [] line.first - - and parse_tokens p toks first_line = - let toks, had_link = first_pass p toks first_line in - let toks = second_pass p toks first_line in - last_pass p toks first_line, had_link - - let strip_paragraph p lines = - (* Remove initial and final blanks. Initial blank removal on - other paragraph lines is done during the inline parsing - and integrated into the AST for layout preservation. *) - let last, trailing_blanks = - let line = List.hd lines in - let first = line.first and start = line.last in - let non_blank = Match.last_non_blank p.i ~first ~start in - { line with last = non_blank}, - layout_clean_raw_span' p { line with first = non_blank + 1; } - in - let lines = List.rev (last :: List.tl lines) in - let first, leading_indent = - let line = List.hd lines in - let non_blank = first_non_blank_in_span p line in - { line with first = non_blank }, - non_blank - line.first - in - let lines = first :: List.tl lines in - let meta = meta_of_spans p ~first ~last in - (leading_indent, trailing_blanks), meta, lines - - let parse p lines = - let layout, meta, lines = strip_paragraph p lines in - let cidx, toks, first_line = tokenize ~exts:p.exts p.i lines in - p.cidx <- cidx; - let is, _had_link = parse_tokens p toks first_line in - let inline = match is with [i] -> i | is -> Inline.Inlines (is, meta) in - layout, inline - - (* Parsing table rows *) - - let get_blanks p line ~before k = - let nb = Match.first_non_blank p.i ~last:(before - 1) ~start:k in - layout_clean_raw_span' p { line with first = k; last = nb - 1 }, nb - - let make_col p = function - | [] -> assert false - | [i] -> i - | is -> - let last = Inline.meta (List.hd is) in - let is = List.rev is in - let first = Inline.meta (List.hd is) in - let meta = meta_of_metas p ~first ~last in - Inline.Inlines (is, meta) - - let find_pipe p line ~before k = - let text p ~first ~last = - Inline.Text (clean_unesc_unref_span p { line with first; last }) - in - let n = Match.first_non_escaped_char '|' p.i ~last:(before - 1) ~start:k in - if n = before then `Not_found (text p ~first:k ~last:(n - 1)) else - let nb = Match.last_non_blank p.i ~first:k ~start:(n - 1) in - let after = - layout_clean_raw_span' p { line with first = nb + 1; last = n - 1 } - in - let text = if nb < k then None else Some (text p ~first:k ~last:nb) in - `Found (text, after, n + 1) - - let start_col p line ~before k = - let bbefore, k = get_blanks p line ~before k in - if k >= before then `Start (bbefore, []) else - match find_pipe p line ~before k with - | `Not_found text -> `Start (bbefore, [text]) - | `Found (text, bafter, k) -> - let text = match text with - | Some text -> text - | None -> - let l = textloc_of_span p { line with first = k; last = k - 1 }in - (Inline.Inlines ([], meta p l)) - in - `Col ((text, (bbefore, bafter)), k) - - let rec finish_col p line blanks_before is toks k = match toks with - | [] -> - begin match find_pipe p line ~before:(line.last + 1) k with - | `Found (text, after, k) -> - let is = match text with Some t -> t :: is | None -> is in - (make_col p is, (blanks_before, after)), [], k - | `Not_found _ -> assert false - end - | Inline { start; inline; next } :: toks when k >= start -> - finish_col p line blanks_before (inline :: is) toks next - | Inline { start; inline; next } :: toks as toks' -> - begin match find_pipe p line ~before:start k with - | `Not_found text -> - let is = inline :: text :: is in - finish_col p line blanks_before is toks next - | `Found (text, after, k) -> - let is = match text with Some t -> t :: is | None -> is in - (make_col p is, (blanks_before, after)), toks', k - end - | (Backticks _ | Autolink_or_html_start _ | Link_start _ | Right_brack _ - | Emphasis_marks _ | Right_paren _ | Strikethrough_marks _ - | Math_span_marks _ | Newline _ ) :: _ -> - assert false - - let rec parse_cols p line acc toks k = match toks with - | [] -> - if k > line.last then (List.rev acc) else - begin match start_col p line ~before:(line.last + 1) k with - | `Col (col, k) -> parse_cols p line (col :: acc) [] k - | `Start _ -> assert false - end - | Inline { start; inline; next } :: toks as toks' -> - begin match start_col p line ~before:start k with - | `Col (col, k) -> parse_cols p line (col :: acc) toks' k - | `Start (before, is) -> - let is = inline :: is in - let col, toks, k = finish_col p line before is toks next in - parse_cols p line (col :: acc) toks k - end - | (Backticks _ | Autolink_or_html_start _ | Link_start _ | Right_brack _ - | Emphasis_marks _ | Right_paren _ | Strikethrough_marks _ - | Math_span_marks _ | Newline _ ) :: _ -> - assert false - - let parse_table_row p line = - let cidx, toks, first_line = tokenize ~exts:p.exts p.i [line] in - p.cidx <- cidx; - let toks, _had_link = first_pass p toks first_line in - let toks = second_pass p toks first_line in - (* We now have modified last pass, inner inlines will have gone through - the regular [last_pass] which is fine since we are only interested - in creating the toplevel text nodes further splited on (unescaped) - [\]. *) - parse_cols p line [] toks line.first -end - -(* Block structure parsing. *) - -module Block_struct = struct - - (* Moving on the line in the indentation space (columns) and over container - markers. *) - - let[@inline] current_col p = p.current_char_col + p.tab_consumed_cols - let[@inline] current_indent p = p.next_non_blank_col - current_col p - let[@inline] end_of_line p = p.current_char > p.current_line_last_char - let[@inline] only_blanks p = p.next_non_blank > p.current_line_last_char - let[@inline] has_next_non_blank p = - p.next_non_blank <= p.current_line_last_char - - let update_next_non_blank p = - let rec loop p s last k col = - if k > last then (p.next_non_blank <- k; p.next_non_blank_col <- col) else - match s.[k] with - | ' ' -> loop p s last (k + 1) (col + 1) - | '\t' -> loop p s last (k + 1) (next_tab_stop col) - | _ -> p.next_non_blank <- k; p.next_non_blank_col <- col; - in - loop p p.i p.current_line_last_char p.current_char p.current_char_col - - let accept_cols ~count p = - let rec loop p count k col = - if count = 0 then (p.current_char <- k; p.current_char_col <- col) else - if p.i.[k] <> '\t' then loop p (count - 1) (k + 1) (col + 1) else - let col' = next_tab_stop col in - let tab_cols = col' - (col + p.tab_consumed_cols) in - if tab_cols > count - then (p.tab_consumed_cols <- count; loop p 0 k col) - else (p.tab_consumed_cols <- 0; loop p (count - tab_cols) (k + 1) col') - in - loop p count p.current_char p.current_char_col; - update_next_non_blank p - - let match_and_accept_block_quote p = - (* https://spec.commonmark.org/current/#block-quote-marker *) - if end_of_line p || p.i.[p.current_char] <> '>' then false else - let next_is_blank = - let next = p.current_char + 1 in - next <= p.current_line_last_char && Ascii.is_blank p.i.[next] - in - let count = if next_is_blank then (* we eat a space *) 2 else 1 in - accept_cols ~count p; true - - let accept_list_marker_and_indent p ~marker_size ~last = - (* Returns min indent after marker for list item *) - accept_cols ~count:marker_size p; - let indent = current_indent p in - let min_indent = - if only_blanks p || indent > 4 (* indented code *) - then 1 - else min indent 4 - in - accept_cols ~count:min_indent p; - min_indent - - let accept_code_indent p ~count = - (* Returns padding for partially consumed tab and content first char *) - accept_cols p ~count; - if p.tab_consumed_cols = 0 then 0, p.current_char else - let col' = next_tab_stop p.current_char_col in - let pad = col' - (p.current_char_col + p.tab_consumed_cols) in - pad, p.current_char (* is '\t' *) + 1 - - (* These data types are only used during parsing, to find out the - block structure. All the lists (blocks, lines) are in reverse - order. We don't extract data from the input here. We just store - line spans. See: - https://spec.commonmark.org/current/#phase-1-block-structure *) - - type space_pad = int (* number of space characters to pad content with. *) - type indented_code_line = - { pad : space_pad; - code : line_span; - is_blank : bool } - - type fence = - { indent : Layout.indent; - opening_fence : line_span; - fence : Char.t * int (* fence length *); - info_string : line_span option (* we drop the trailing blanks *); - closing_fence : line_span option; } - - type fenced_code_block = - { fence : fence; - code : (space_pad * line_span) list } - - type code_block = - [ `Indented of indented_code_line list | `Fenced of fenced_code_block ] - - type atx = - { indent : Layout.indent; - level : Match.heading_level; - after_open : byte_pos; - heading : line_span; - layout_after : line_span } - - type setext = - { level : Match.heading_level; - heading_lines : line_span list; - underline : (* Indent, underline char count, blanks *) - Layout.indent * line_span * line_span; } - - type heading = [ `Atx of atx | `Setext of setext ] - - type html_block = - { end_cond : Match.html_block_end_cond option; - html : line_span list } - - type paragraph = { maybe_ref : bool; lines : line_span list } - - type t = - | Block_quote of Layout.indent * t list - | Blank_line of space_pad * line_span - | Code_block of code_block - | Heading of heading - | Html_block of html_block - | List of list' - | Linkref_def of Link_definition.t node - | Paragraph of paragraph - | Thematic_break of Layout.indent * line_span (* including trailing blanks *) - | Ext_table of Layout.indent * (line_span * line_span (* trail blanks *)) list - | Ext_footnote of Layout.indent * (Label.t * Label.t option) * t list - - and list_item = - { before_marker : Layout.indent; - marker : line_span; - after_marker : Layout.indent; - ext_task_marker : (Uchar.t * line_span) option; - blocks : t list } - - and list' = - { last_blank : bool; (* last added line was blank and not first line - of item *) - loose : bool; (* inter-item looseness, intra-item is computed later *) - item_min_indent : int; (* last item minimal indent *) - list_type : Block.List'.type'; - items : list_item list; } - - let block_is_blank_line = function Blank_line _ -> true | _ -> false - - (* Making blocks from the current line status *) - - let blank_line p = - let first = p.current_char and last = p.current_line_last_char in - Blank_line (0, current_line_span p ~first ~last) - - let thematic_break p ~indent ~last:_ = - let last = p.current_line_last_char (* let's keep everything *) in - let break = current_line_span p ~first:p.current_char ~last in - Thematic_break (indent, break) - - let atx_heading p ~indent ~level ~after_open ~first_content ~last_content = - let heading = current_line_span p ~first:first_content ~last:last_content in - let layout_after = - let first = last_content + 1 and last = p.current_line_last_char in - current_line_span p ~first ~last - in - Heading (`Atx { indent; level; after_open; heading; layout_after }) - - let setext_heading p ~indent ~level ~last_underline heading_lines = - let u = current_line_span p ~first:p.current_char ~last:last_underline in - let blanks = - let first = last_underline + 1 and last = p.current_line_last_char in - current_line_span p ~first ~last - in - let underline = indent, u, blanks in - Heading (`Setext {level; heading_lines; underline}) - - let indented_code_block p = (* Has a side-effect on [p] *) - let pad, first = accept_code_indent p ~count:4 in - let code = current_line_span p ~first ~last:p.current_line_last_char in - Code_block (`Indented [{pad; code; is_blank = false}]) - - let fenced_code_block p ~indent ~fence_first ~fence_last ~info = - let info_string, layout_last = match info with - | None -> None, p.current_line_last_char - | Some (first, last) -> Some (current_line_span p ~first ~last), first - 1 - in - let opening_fence = - current_line_span p ~first:fence_first ~last:layout_last - in - let fence = p.i.[fence_first], (fence_last - fence_first + 1) in - let closing_fence = None in - let fence = { indent; opening_fence; fence; info_string; closing_fence } in - Code_block (`Fenced {fence; code = []}) - - let html_block p ~end_cond ~indent_start = - let first = indent_start and last = p.current_line_last_char in - let end_cond = (* Check if the same line matches the end condition. *) - if Match.html_block_end p.i ~end_cond ~last ~start:p.current_char - then None (* We are already closed *) else Some end_cond - in - Html_block { end_cond; html = [current_line_span p ~first ~last] } - - let paragraph p ~start = - let last = p.current_line_last_char in - let maybe_ref = Match.could_be_link_reference_definition p.i ~last ~start in - Paragraph { maybe_ref; lines = [current_line_span p ~first:start ~last]} - - let add_paragraph_line p ~indent_start par bs = - let first = indent_start and last = p.current_line_last_char in - let lines = current_line_span p ~first ~last :: par.lines in - Paragraph { par with lines } :: bs - - let table_row p ~first ~last = - current_line_span p ~first ~last, - current_line_span p ~first:(last + 1) ~last:p.current_line_last_char - - let table p ~indent ~last = - let row = table_row p ~first:p.current_char ~last in - Ext_table (indent, [row]) - - (* Link reference definition parsing - - This is invoked when we close a paragraph and works on the paragraph - lines. *) - - let parse_link_reference_definition p lines = - (* Has no side effect on [p], parsing occurs on [lines] spans. *) - (* https://spec.commonmark.org/current/#link-reference-definitions *) - let none () = raise_notrace Exit in - let next_line = function line :: lines -> Some (lines, line) | [] -> None in - try - let lines, line = match next_line lines with - | None -> none () | Some v -> v - in - let start = first_non_blank_in_span p line in - let indent = start - line.first in - let meta_first = { line with first = start } in - let lines, line, label, start = - match Match.link_label p.buf ~next_line p.i lines ~line ~start with - | None -> none () - | Some (lines, line, rev_spans, last, key) -> - let colon = last + 1 in - if colon > line.last || p.i.[colon] <> ':' then none () else - let label = Inline_struct.label_of_rev_spans p ~key rev_spans in - lines, line, label, colon + 1 - in - let lines, line, before_dest, start = - match first_non_blank_over_nl ~next_line p lines line ~start with - | None -> none () | Some v -> v - in - let angled_dest, dest, start, meta_last = - match Match.link_destination p.i ~last:line.last ~start with - | None -> none () - | Some (angled, first, last) -> - let dest = clean_unesc_unref_span p { line with first; last } in - let next = if angled then last + 2 else last + 1 in - angled, Some dest, next, { line with last = last } - in - let lines, after_dest, title_open_delim, title, after_title, meta_last = - match first_non_blank_over_nl ~next_line p lines line ~start with - | None -> lines, [], '\"', None, [], meta_last - | Some (_, _, _, st) when st = start (* need some space *) -> none () - | Some (lines', line', after_dest, start') -> - let no_newline = line'.line_pos = line.line_pos in - let title = - Match.link_title ~next_line p.i lines' ~line:line' ~start:start' - in - match title with - | None -> - if no_newline then none () (* garbage after dest *) else - lines, [], '\"', None, [], meta_last - | Some (lines', line', rev_spans, last) -> - let after_title = - let last = line'.last and start = last + 1 in - let nb = Match.first_non_blank p.i ~last ~start in - if nb <= line'.last - then None - else - Some [layout_clean_raw_span p { line' with first = start; }] - in - match after_title with - | None when no_newline -> none () - | None -> (lines, [], '\"', None, [], meta_last) - | Some after_title -> - let t = tight_block_lines p ~rev_spans in - lines', after_dest, p.i.[start'], Some t, - after_title, - { line' with last } - in - let meta = meta_of_spans p ~first:meta_first ~last:meta_last in - let layout = - { Link_definition.indent; angled_dest; before_dest; - after_dest; title_open_delim; after_title } - in - let defined_label = def_label p label in - let label = Some label in - let ld = - { Link_definition.layout; label; defined_label; dest; title }, meta - in - begin match defined_label with - | None -> () | Some def -> set_label_def p def (Link_definition.Def ld) - end; - Some (ld, lines) - with - | Exit -> None - - let maybe_add_link_reference_definitions p lines prevs = - let rec loop p prevs = function - | [] -> prevs - | ls -> - match parse_link_reference_definition p ls with - | None -> - (* Link defs can't interrupt a paragraph so we are good now. *) - Paragraph { maybe_ref = false; lines = List.rev ls } :: prevs - | Some (ld, ls) -> loop p (Linkref_def ld :: prevs) ls - in - loop p prevs (List.rev lines) - - (* Closing blocks and finishing the document. *) - - let close_indented_code_block p lines bs = - (* Removes trailing blank lines and add them as blank lines *) - let rec loop blanks lines bs = match lines with - | { pad; code; is_blank = true} :: lines -> - loop (Blank_line (pad, code) :: blanks) lines bs - | [] -> (* likely assert (false) *) List.rev_append blanks bs - | ls -> List.rev_append blanks ((Code_block (`Indented ls)) :: bs) - in - loop [] lines bs - - let close_paragraph p par bs = - if not par.maybe_ref then Paragraph par :: bs else - maybe_add_link_reference_definitions p par.lines bs - - let rec close_last_block p = function - | Code_block (`Indented ls) :: bs -> close_indented_code_block p ls bs - | Paragraph par :: bs -> close_paragraph p par bs - | List l :: bs -> close_list p l bs - | Ext_footnote (i, l, blocks) :: bs -> close_footnote p i l blocks bs - | bs -> bs - - and close_list p l bs = - let i = List.hd l.items in - let blocks = close_last_block p i.blocks in - (* The final blank line extraction of the list item entails less blank - line churn for CommonMark rendering but we don't do it on empty list - items. *) - match blocks with - | Blank_line _ as bl :: (_ :: _ as blocks) -> - let items = { i with blocks } :: List.tl l.items in - bl :: List { l with items } :: bs - | blocks -> - let items = { i with blocks } :: List.tl l.items in - List { l with items } :: bs - - and close_footnote p indent label blocks bs = - let blocks = close_last_block p blocks in - (* Like for lists above we do blank line extraction (except if blocks - is only a blank line) *) - let blanks, blocks = - let rec loop acc = function - | Blank_line _ as bl :: (_ :: _ as blocks) -> loop (bl :: acc) blocks - | blocks -> acc, blocks - in - loop [] blocks - in - List.rev_append blanks (Ext_footnote (indent, label, blocks) :: bs) - - let close_last_list_item p l = - let item = List.hd l.items in - let item = { item with blocks = close_last_block p item.blocks } in - { l with items = item :: List.tl l.items } - - let end_doc_close_fenced_code_block p fenced bs = match fenced.code with - | (_, l) :: code when l.first > l.last (* empty line *) -> - Blank_line (0, l) :: Code_block (`Fenced { fenced with code }) :: bs - | _ -> Code_block (`Fenced fenced) :: bs - - let end_doc_close_html p h bs = match h.html with - | l :: html when l.first > l.last (* empty line *) -> - Blank_line (0, l) :: Html_block { end_cond = None; html } :: bs - | _ -> - Html_block { h with end_cond = None } :: bs - - let rec end_doc p = function - | Block_quote (indent, bq) :: bs -> Block_quote (indent, end_doc p bq) :: bs - | List list :: bs -> close_list p list bs - | Paragraph par :: bs -> close_paragraph p par bs - | Code_block (`Indented ls) :: bs -> close_indented_code_block p ls bs - | Code_block (`Fenced f) :: bs -> end_doc_close_fenced_code_block p f bs - | Html_block html :: bs -> end_doc_close_html p html bs - | Ext_footnote (i, l, blocks) :: bs -> close_footnote p i l blocks bs - | (Thematic_break _ | Heading _ | Blank_line _ | Linkref_def _ - | Ext_table _ ) :: _ | [] as bs -> bs - - (* Adding lines to blocks *) - - let match_line_type ~no_setext ~indent p = - (* Effects on [p]'s column advance *) - if only_blanks p then Match.Blank_line else - if indent >= 4 then Indented_code_block_line else begin - accept_cols ~count:indent p; - if end_of_line p then Match.Blank_line else - let start = p.current_char and last = p.current_line_last_char in - match p.i.[start] with - (* Early dispatch shaves a few ms but may not be worth doing vs - testing all the cases in sequences. *) - | '>' -> - if match_and_accept_block_quote p then Match.Block_quote_line else - Paragraph_line - | '=' when not no_setext -> - let r = Match.setext_heading_underline p.i ~last ~start in - if r <> Nomatch then r else - Paragraph_line - | '-' -> - let r = - if no_setext then Match.Nomatch else - Match.setext_heading_underline p.i ~last ~start - in - if r <> Nomatch then r else - let r = Match.thematic_break p.i ~last ~start in - if r <> Nomatch then r else - let r = Match.list_marker p.i ~last ~start in - if r <> Nomatch then r else - Paragraph_line - | '#' -> - let r = Match.atx_heading p.i ~last ~start in - if r <> Nomatch then r else - Paragraph_line - | '+' | '*' | '0' .. '9' -> - let r = Match.thematic_break p.i ~last ~start in - if r <> Nomatch then r else - let r = Match.list_marker p.i ~last ~start in - if r <> Nomatch then r else - Paragraph_line - | '_' -> - let r = Match.thematic_break p.i ~last ~start in - if r <> Nomatch then r else - Paragraph_line - | '~' | '`' -> - let r = Match.fenced_code_block_start p.i ~last ~start in - if r <> Nomatch then r else - Paragraph_line - | '<' -> - let r = Match.html_block_start p.i ~last ~start in - if r <> Nomatch then r else - Paragraph_line - | '|' when p.exts -> - let r = Match.ext_table_row p.i ~last ~start in - if r <> Nomatch then r else - Paragraph_line - | '[' when p.exts -> - let line_pos = p.current_line_pos in - let r = Match.ext_footnote_label p.buf p.i ~line_pos ~last ~start in - if r <> Nomatch then r else - Paragraph_line - | _ -> - Paragraph_line - end - - let list_marker_can_interrupt_paragraph p = function - | `Ordered (1, _), marker_last | `Unordered _, marker_last -> - let last = p.current_line_last_char and start = marker_last + 1 in - let non_blank = Match.first_non_blank p.i ~last ~start in - non_blank <= p.current_line_last_char (* line is not blank *) - | _ -> false - - let same_list_type t0 t1 = match t0, t1 with - | `Ordered (_, c0), `Ordered (_, c1) - | `Unordered c0, `Unordered c1 when Char.equal c0 c1 -> true - | _ -> false - - let rec add_open_blocks_with_line_class p ~indent_start ~indent bs = function - | Match.Blank_line -> blank_line p :: bs - | Indented_code_block_line -> indented_code_block p :: bs - | Block_quote_line -> Block_quote (indent, add_open_blocks p []) :: bs - | Thematic_break_line last -> thematic_break p ~indent ~last :: bs - | List_marker_line m -> list p ~indent m bs - | Atx_heading_line (level, after_open, first_content, last_content) -> - atx_heading p ~indent ~level ~after_open ~first_content ~last_content :: - bs - | Fenced_code_block_line (fence_first, fence_last, info) -> - fenced_code_block p ~indent ~fence_first ~fence_last ~info :: bs - | Html_block_line end_cond -> html_block p ~end_cond ~indent_start :: bs - | Paragraph_line -> paragraph p ~start:indent_start :: bs - | Ext_table_row last -> table p ~indent ~last :: bs - | Ext_footnote_label (rev_spans, last, key) -> - footnote p ~indent ~last rev_spans key :: bs - | Setext_underline_line _ | Nomatch -> - (* This function should be called with a line type that comes out - of match_line_type ~no_setext:true *) - assert false - - and add_open_blocks p bs = - let indent_start = p.current_char and indent = current_indent p in - let ltype = match_line_type ~no_setext:true ~indent p in - add_open_blocks_with_line_class p ~indent_start ~indent bs ltype - - and footnote p ~indent ~last rev_spans key = - let label = Inline_struct.label_of_rev_spans p ~key rev_spans in - let defined_label = match def_label p label with - | None -> None - | Some def as l -> set_label_def p def (Block.Footnote.stub label l); l - in - accept_cols p ~count:(last - p.current_char + 1); - Ext_footnote (indent, (label, defined_label), add_open_blocks p []) - - and list_item ~indent p (list_type, last) = - let before_marker = indent and marker_size = last - p.current_char + 1 in - let marker = current_line_span p ~first:p.current_char ~last in - let after_marker = accept_list_marker_and_indent p ~marker_size ~last in - let ext_task_marker, ext_task_marker_size = match p.exts with - | false -> None, 0 - | true -> - let start = p.current_char and last = p.current_line_last_char in - match Match.ext_task_marker p.i ~last ~start with - | None -> None, 0 - | Some (u, last) -> - accept_cols p ~count:(last - start + 1); - let last = match last = p.current_line_last_char with - | true -> (* empty line *) last - | false -> (* remove space for locs *) last - 1 - in - Some (u, current_line_span p ~first:start ~last), 4 - in - let min = indent + marker_size + after_marker + ext_task_marker_size in - min, { before_marker; marker; after_marker; ext_task_marker; - blocks = add_open_blocks p [] } - - and list ~indent p (list_type, _ as m) bs = - let item_min_indent, item = list_item ~indent p m in - List { last_blank = false; loose = false; - item_min_indent; list_type; items = [item] } :: bs - - let try_add_to_list ~indent p (lt, _ as m) l bs = - let item_min_indent, item = list_item ~indent p m in - if same_list_type lt l.list_type then - let l = close_last_list_item p l and last_blank = false in - let list_type = l.list_type in - List { last_blank; loose = l.last_blank; item_min_indent; list_type; - items = item :: l.items } :: bs - else - let bs = close_list p l bs and last_blank = false in - List { last_blank; loose = false; item_min_indent; list_type = lt; - items = [item] } :: bs - - let try_add_to_paragraph p par bs = - let indent_start = p.current_char and indent = current_indent p in - match match_line_type ~no_setext:false ~indent p with - (* These can't interrupt paragraphs *) - | Html_block_line `End_blank_7 - | Indented_code_block_line - | Ext_table_row _ | Ext_footnote_label _ - | Paragraph_line -> - add_paragraph_line p ~indent_start par bs - | List_marker_line m when not (list_marker_can_interrupt_paragraph p m) -> - add_paragraph_line p ~indent_start par bs - | Blank_line -> - blank_line p :: close_paragraph p par bs - | Block_quote_line -> - Block_quote (indent, add_open_blocks p []) :: (close_paragraph p par bs) - | Setext_underline_line (level, last_underline) -> - let bs = close_paragraph p par bs in - begin match bs with - | Paragraph { lines; _ } :: bs -> - setext_heading p ~indent ~level ~last_underline lines :: bs - | bs -> paragraph p ~start:indent_start :: bs - end - | Thematic_break_line last -> - thematic_break p ~indent ~last :: (close_paragraph p par bs) - | List_marker_line m -> - list p ~indent m (close_paragraph p par bs) - | Atx_heading_line (level, after_open, first_content, last_content) -> - let bs = close_paragraph p par bs in - atx_heading p ~indent ~level ~after_open ~first_content ~last_content :: - bs - | Fenced_code_block_line (fence_first, fence_last, info) -> - let bs = close_paragraph p par bs in - fenced_code_block p ~indent ~fence_first ~fence_last ~info :: bs - | Html_block_line end_cond -> - html_block p ~end_cond ~indent_start :: (close_paragraph p par bs) - | Nomatch -> assert false - - let try_add_to_indented_code_block p ls bs = - if current_indent p < 4 then - if has_next_non_blank p - then add_open_blocks p (close_indented_code_block p ls bs) else - (* Blank but white is not data, make an empty span *) - let first = p.current_line_last_char + 1 in - let last = p.current_line_last_char in - let code = current_line_span p ~first ~last in - let l = { pad = 0; code; is_blank = true } in - Code_block (`Indented (l :: ls)) :: bs - else - let pad, first = accept_code_indent p ~count:4 in - let last = p.current_line_last_char in - let is_blank = only_blanks p in - let l = { pad; code = current_line_span p ~first ~last; is_blank } in - Code_block (`Indented (l :: ls)) :: bs - - let try_add_to_fenced_code_block p f bs = match f with - | { fence = { closing_fence = Some _; _}; _ } -> (* block is closed *) - add_open_blocks p ((Code_block (`Fenced f)) :: bs) - | { fence = { indent; fence; _} ; code = ls} as b -> - let start = p.current_char and last = p.current_line_last_char in - match Match.fenced_code_block_continue ~fence p.i ~last ~start with - | `Code -> - let strip = Int.min indent (current_indent p) in - let pad, first = accept_code_indent p ~count:strip in - let code = (pad, current_line_span p ~first ~last) :: ls in - Code_block (`Fenced { b with code }) :: bs - | `Close (first, _fence_last) -> - let close = current_line_span p ~first ~last (* with layout *)in - let fence = { b.fence with closing_fence = Some close } in - Code_block (`Fenced { b with fence }) :: bs - - let try_add_to_html_block p b bs = match b.end_cond with - | None -> add_open_blocks p (Html_block { b with end_cond = None} :: bs) - | Some end_cond -> - let start = p.current_char and last = p.current_line_last_char in - let l = current_line_span p ~first:start ~last in - if not (Match.html_block_end p.i ~end_cond ~last ~start) - then Html_block { b with html = l :: b.html } :: bs else - match end_cond with - | `End_blank | `End_blank_7 -> - blank_line p :: Html_block { b with end_cond = None } :: bs - | _ -> - Html_block { end_cond = None; html = l :: b.html } :: bs - - let rec try_lazy_continuation p ~indent_start = function - | Paragraph par :: bs -> Some (add_paragraph_line p ~indent_start par bs) - | Block_quote (indent, bq) :: bs -> - begin match try_lazy_continuation p ~indent_start bq with - | None -> None - | Some bq -> Some (Block_quote (indent, bq) :: bs) - end - | List l :: bs -> - let i = List.hd l.items in - begin match try_lazy_continuation p ~indent_start i.blocks with - | None -> None - | Some blocks -> - let items = { i with blocks } :: (List.tl l.items) in - Some (List { l with items; last_blank = false } :: bs) - end - | _ -> None - - let try_add_to_table p ind rows bs = - let indent_start = p.current_char and indent = current_indent p in - match match_line_type ~indent ~no_setext:true p with - | Ext_table_row last -> - let row = table_row p ~first:p.current_char ~last in - Ext_table (ind, row :: rows) :: bs - | ltype -> - let bs = Ext_table (ind, rows) :: bs in - add_open_blocks_with_line_class p ~indent ~indent_start bs ltype - - let rec try_add_to_block_quote p indent_layout bq bs = - let indent_start = p.current_char and indent = current_indent p in - match match_line_type ~indent ~no_setext:true p with - | Block_quote_line -> Block_quote (indent_layout, add_line p bq) :: bs - | (Indented_code_block_line (* Looks like a *) | Paragraph_line) as ltype -> - begin match try_lazy_continuation p ~indent_start bq with - | Some bq -> Block_quote (indent_layout, bq) :: bs - | None -> - let bs = Block_quote (indent_layout, close_last_block p bq) :: bs in - add_open_blocks_with_line_class p ~indent ~indent_start bs ltype - end - | ltype -> - let bs = Block_quote (indent_layout, close_last_block p bq) :: bs in - add_open_blocks_with_line_class p ~indent ~indent_start bs ltype - - and try_add_to_footnote p fn_indent label blocks bs = - let indent_start = p.current_char and indent = current_indent p in - if indent < fn_indent + 1 (* position of ^ *) then begin - match match_line_type ~indent ~no_setext:true p with - | (Indented_code_block_line (* Looks like a *) | Paragraph_line) as lt -> - begin match try_lazy_continuation p ~indent_start blocks with - | Some blocks -> Ext_footnote (fn_indent, label, blocks) :: bs - | None -> - let blocks = close_last_block p blocks in - let bs = (close_footnote p fn_indent label blocks) bs in - add_open_blocks_with_line_class p ~indent ~indent_start bs lt - end - | Blank_line -> - Ext_footnote (fn_indent, label, add_line p blocks) :: bs - | ltype -> - let blocks = close_last_block p blocks in - let bs = close_footnote p fn_indent label blocks bs in - add_open_blocks_with_line_class p ~indent ~indent_start bs ltype - end else begin - accept_cols p ~count:(fn_indent + 1); - Ext_footnote (fn_indent, label, add_line p blocks) :: bs - end - - and try_add_to_list_item p list bs = - let indent_start = p.current_char and indent = current_indent p in - if indent >= list.item_min_indent then begin - let last_blank = only_blanks p in - let item = List.hd list.items and items = List.tl list.items in - if list.last_blank && not last_blank && - List.for_all block_is_blank_line item.blocks - then - (* Item can only start with a single blank line, if we are - here it's not a new item so the list ends *) - add_open_blocks p (List list :: bs) - else begin - accept_cols ~count:list.item_min_indent p; - let item = { item with blocks = add_line p item.blocks } in - List { list with items = item :: items; last_blank } :: bs - end - end else match match_line_type ~indent ~no_setext:true p with - | Blank_line -> - let item = List.hd list.items and items = List.tl list.items in - let item = { item with blocks = add_line p item.blocks } in - List { list with items = item :: items; last_blank = true } :: bs - | Indented_code_block_line | Paragraph_line as ltype -> - let item = List.hd list.items and items = List.tl list.items in - begin match try_lazy_continuation p ~indent_start item.blocks with - | Some blocks -> - let items = { item with blocks } :: items in - List { list with items; last_blank = false } :: bs - | None -> - let bs = close_list p list bs in - add_open_blocks_with_line_class p ~indent ~indent_start bs ltype - end - | List_marker_line m -> - try_add_to_list p ~indent m list bs - | ltype -> - let bs = close_list p list bs in - add_open_blocks_with_line_class p ~indent ~indent_start bs ltype - - and add_line p = function - | Paragraph par :: bs -> try_add_to_paragraph p par bs - | ((Thematic_break _ | Heading _ | Blank_line _ | Linkref_def _) :: _) - | [] as bs -> add_open_blocks p bs - | List list :: bs -> try_add_to_list_item p list bs - | Code_block (`Indented ls) :: bs -> try_add_to_indented_code_block p ls bs - | Code_block (`Fenced f) :: bs -> try_add_to_fenced_code_block p f bs - | Block_quote (ind, bq) :: bs -> try_add_to_block_quote p ind bq bs - | Html_block html :: bs -> try_add_to_html_block p html bs - | Ext_table (ind, rows) :: bs -> try_add_to_table p ind rows bs - | Ext_footnote (i, l, blocks) :: bs -> try_add_to_footnote p i l blocks bs - - (* Parsing *) - - let get_first_line p = - let max = String.length p.i - 1 in - let k = ref 0 in - let last_char = - while !k <= max && p.i.[!k] <> '\n' && p.i.[!k] <> '\r' do incr k done; - !k - 1 (* if the line is empty we have -1 *) - in - p.current_line_last_char <- last_char; - update_next_non_blank p; - (* Return first used newline (or "\n" if there is none) *) - if !k > max || p.i.[!k] = '\n' then "\n" else - let next = !k + 1 in - if next <= max && p.i.[next] = '\n' then "\r\n" else "\r" - - let get_next_line p = - let max = String.length p.i - 1 in - if p.current_line_last_char = max then false else - let first_char = - let nl = p.current_line_last_char + 1 in - if p.i.[nl] = '\n' then nl + 1 else (* assert (p.i.[nl] = '\r') *) - let next = nl + 1 in - if next <= max && p.i.[next] = '\n' then next + 1 else next - in - let last_char = - let k = ref first_char in - while !k <= max && p.i.[!k] <> '\n' && p.i.[!k] <> '\r' do incr k done; - !k - 1 (* if the line is empty we have last_char = first_char - 1 *) - in - p.current_line_pos <- (fst p.current_line_pos + 1), first_char; - p.current_line_last_char <- last_char; - p.current_char <- first_char; - p.current_char_col <- 0; - p.tab_consumed_cols <- 0; - update_next_non_blank p; - true - - let parse p = - let meta p = - let first_byte = 0 and last_byte = p.current_line_last_char in - let first_line = 1, first_byte and last_line = p.current_line_pos in - let file = p.file in - meta p (Textloc.v ~file ~first_byte ~last_byte ~first_line ~last_line) - in - let rec loop p bs = - let bs = add_line p bs in - if get_next_line p then loop p bs else (end_doc p bs), meta p - in - let nl = get_first_line p in - nl, loop p [] -end - -(* Building the final AST, invokes inline parsing. *) - -let block_struct_to_blank_line p pad span = - Block.Blank_line (clean_raw_span p ~pad span) - -let block_struct_to_code_block p = function -| `Indented (ls : Block_struct.indented_code_line list) (* non-empty *) -> - let line p { Block_struct.pad; code; _} = clean_raw_span ~pad p code in - let layout = `Indented and info_string = None in - let last = (List.hd ls).code in - let code = List.rev_map (line p) ls in - let meta = - let last_line = last.line_pos and last_byte = last.last in - let start = Meta.textloc (snd (List.hd code)) in - meta p (Textloc.set_last start ~last_byte ~last_line) - in - Block.Code_block ({layout; info_string; code}, meta) -| `Fenced { Block_struct.fence; code = ls } -> - let layout = - let opening_fence = layout_clean_raw_span p fence.opening_fence in - let closing_fence = - Option.map (layout_clean_raw_span p) fence.closing_fence - in - { Block.Code_block.indent = fence.indent; opening_fence; closing_fence } - in - let info_string = Option.map (clean_unesc_unref_span p) fence.info_string in - let code = List.rev_map (fun (pad, l) -> clean_raw_span p ~pad l) ls in - let meta = - let first = fence.opening_fence in - let last = match fence.closing_fence with - | Some last -> last - | None -> match ls with [] -> first | (_, last_line) :: _ -> last_line - in - meta_of_spans p ~first ~last - in - let cb = {Block.Code_block.layout = `Fenced layout; info_string; code} in - if p.exts && Block.Code_block.is_math_block info_string - then Block.Ext_math_block (cb, meta) - else Block.Code_block (cb, meta) - -let block_struct_to_heading p = function -| `Atx { Block_struct.indent; level; after_open; heading; layout_after } -> - let after_opening = - let first = after_open and last = heading.first - 1 in - layout_clean_raw_span' p { heading with first; last } - in - let closing = layout_clean_raw_span' p layout_after in - let layout = `Atx { Block.Heading.indent; after_opening; closing } in - let meta = - meta p (textloc_of_span p { heading with first = after_open - level }) - in - let _layout, inline = Inline_struct.parse p [heading] in - let id = match p.heading_auto_ids with - | false -> None - | true -> Some (`Auto (Inline.id ~buf:p.buf inline)) - in - Block.Heading ({layout; level; inline; id}, meta) -| `Setext { Block_struct.level; heading_lines; underline } -> - let (leading_indent, trailing_blanks), inline = - Inline_struct.parse p heading_lines - in - let underline_indent, u, blanks = underline in - let underline_blanks = layout_clean_raw_span' p blanks in - let underline_count = u.last - u.first + 1, meta p (textloc_of_span p u) in - let layout = - { Block.Heading.leading_indent; trailing_blanks; underline_indent; - underline_count; underline_blanks } - in - let meta = - let last_line = u.line_pos and last_byte = u.last in - let start = Meta.textloc (Inline.meta inline) in - meta p (Textloc.set_last start ~last_byte ~last_line) - in - let id = match p.heading_auto_ids with - | false -> None - | true -> Some (`Auto (Inline.id ~buf:p.buf inline)) - in - Block.Heading ({ layout = `Setext layout; level; inline; id }, meta) - -let block_struct_to_html_block p (b : Block_struct.html_block) = - let last = List.hd b.html in - let last_byte = last.last and last_line = last.line_pos in - let lines = List.rev_map (clean_raw_span p) b.html in - let start_loc = Meta.textloc (snd (List.hd lines)) in - let meta = meta p (Textloc.set_last start_loc ~last_byte ~last_line) in - Block.Html_block (lines, meta) - -let block_struct_to_paragraph p par = - let layout, inline = Inline_struct.parse p par.Block_struct.lines in - let leading_indent, trailing_blanks = layout in - let meta = Inline.meta inline in - Block.Paragraph ({ leading_indent; inline; trailing_blanks }, meta) - -let block_struct_to_thematic_break p indent span = - let layout, meta = (* not layout because of loc *) clean_raw_span p span in - Block.Thematic_break ({ indent; layout }, meta) - -let block_struct_to_table p indent rows = - let rec loop p col_count last_was_sep acc = function - | (row, blanks) :: rs -> - let meta = meta p (textloc_of_span p row) in - let row' = { row with first = row.first + 1; last = row.last } in - let cols = Inline_struct.parse_table_row p row' in - let col_count = Int.max col_count (List.length cols) in - let r, last_was_sep = match Block.Table.parse_sep_row cols with - | Some seps -> ((`Sep seps), meta), true - | None -> - ((if last_was_sep then `Header cols else `Data cols), meta), false - in - let acc = (r, layout_clean_raw_span' p blanks) :: acc in - if rs = [] then row, col_count, acc else - loop p col_count last_was_sep acc rs - | [] -> assert false - in - let last = fst (List.hd rows) in - let first, col_count, rows = loop p 0 false [] rows in - let meta = meta_of_spans p ~first ~last in - Block.Ext_table ({ indent; col_count; rows }, meta) - -let rec block_struct_to_block_quote p indent bs = - let add_block p acc b = block_struct_to_block p b :: acc in - let last = block_struct_to_block p (List.hd bs) in - let block = List.fold_left (add_block p) [last] (List.tl bs) in - let block = match block with - | [b] -> b - | quote -> - let first = Block.meta (List.hd quote) and last = Block.meta last in - Block.Blocks (quote, meta_of_metas p ~first ~last) - in - Block.Block_quote ({indent; block}, Block.meta block) - -and block_struct_to_footnote_definition p indent (label, defined_label) bs = - let add_block p acc b = block_struct_to_block p b :: acc in - let last = block_struct_to_block p (List.hd bs) in - let block = List.fold_left (add_block p) [last] (List.tl bs) in - let last = Block.meta last in - let block = match block with - | [b] -> b - | bs -> - let first = Block.meta (List.hd bs) in - Block.Blocks (bs, meta_of_metas p ~first ~last) - in - let loc = - let labelloc = Label.textloc label in - let lastloc = Meta.textloc last in - let loc = Textloc.span labelloc lastloc in - let first_byte = Textloc.first_byte loc - 1 in - Textloc.set_first loc ~first_byte ~first_line:(Textloc.first_line loc) - in - let fn = { Block.Footnote.indent; label; defined_label; block }, meta p loc in - begin match defined_label with - | None -> () | Some def -> set_label_def p def (Block.Footnote.Def fn) - end; - Block.Ext_footnote_definition fn - -and block_struct_to_list_item p (i : Block_struct.list_item) = - let rec loop bstate tight acc = function - | Block_struct.Blank_line _ as bl :: bs -> - let bstate = if bstate = `Trail_blank then `Trail_blank else `Blank in - loop bstate tight (block_struct_to_block p bl :: acc) bs - | Block_struct.List - { items = { blocks = Block_struct.Blank_line _ :: _ } :: _ } as l :: bs - -> - loop bstate false (block_struct_to_block p l :: acc) bs - | b :: bs -> - let tight = tight && not (bstate = `Blank) in - loop `Non_blank tight (block_struct_to_block p b :: acc) bs - | [] -> tight, acc - in - let last_meta, (tight, blocks) = match i.blocks with - | [Block_struct.Blank_line _ as blank] -> - let bl = block_struct_to_block p blank in - Block.meta bl, (true, [bl]) - | Block_struct.Blank_line _ as blank :: bs -> - let bl = block_struct_to_block p blank in - (Block.meta bl), loop `Trail_blank true [bl] bs - | b :: bs -> - let b = block_struct_to_block p b in - (Block.meta b), loop `Non_blank true [b] bs - | [] -> assert false - in - let block = match blocks with - | [i] -> i - | is -> - let first = Block.meta (List.hd is) in - Block.Blocks (is, meta_of_metas p ~first ~last:last_meta) - in - let before_marker = i.before_marker and after_marker = i.after_marker in - let marker = (* not layout to get loc *) clean_raw_span p i.marker in - let ext_task_marker = match i.ext_task_marker with - | None -> None - | Some (u, span) -> Some (u, meta p (textloc_of_span p span)) - in - let meta = meta_of_metas p ~first:(snd marker) ~last:last_meta in - let i = - { Block.List_item.before_marker; marker; after_marker; block; - ext_task_marker } - in - (i, meta), tight - -and block_struct_to_list p list = - let rec loop p tight acc = function - | [] -> tight, acc - | item :: items -> - let item, item_tight = block_struct_to_list_item p item in - loop p (tight && item_tight) (item :: acc) items - in - let items = list.Block_struct.items in - let last, tight = block_struct_to_list_item p (List.hd items) in - let tight, items = loop p (not list.loose && tight) [last] (List.tl items) in - let meta = meta_of_metas p ~first:(snd (List.hd items)) ~last:(snd last) in - Block.List ({ type' = list.Block_struct.list_type; tight; items }, meta) - -and block_struct_to_block p = function -| Block_struct.Block_quote (ind, bs) -> block_struct_to_block_quote p ind bs -| Block_struct.List list -> block_struct_to_list p list -| Block_struct.Paragraph par -> block_struct_to_paragraph p par -| Block_struct.Thematic_break (i, br) -> block_struct_to_thematic_break p i br -| Block_struct.Code_block cb -> block_struct_to_code_block p cb -| Block_struct.Heading h -> block_struct_to_heading p h -| Block_struct.Html_block html -> block_struct_to_html_block p html -| Block_struct.Blank_line (pad, span) -> block_struct_to_blank_line p pad span -| Block_struct.Linkref_def r -> Block.Link_reference_definition r -| Block_struct.Ext_table (i, rows) -> block_struct_to_table p i rows -| Block_struct.Ext_footnote (i, labels, bs) -> - block_struct_to_footnote_definition p i labels bs - -let block_struct_to_doc p (doc, meta) = - match List.rev_map (block_struct_to_block p) doc with - | [b] -> b | bs -> Block.Blocks (bs, meta) - -(* Documents *) - -module Doc = struct - type t = { nl : Layout.string; block : Block.t; defs : Label.defs } - let make ?(nl = "\n") ?(defs = Label.Map.empty) block = { nl; block; defs } - let empty = make (Block.Blocks ([], Meta.none)) - let nl d = d.nl - let block d = d.block - let defs d = d.defs - let of_string - ?defs ?resolver ?nested_links ?heading_auto_ids ?layout ?locs ?file - ?(strict = true) s - = - let p = - parser ?defs ?resolver ?nested_links ?heading_auto_ids ?layout ?locs - ?file ~strict s - in - let nl, doc = Block_struct.parse p in - let block = block_struct_to_doc p doc in - make ~nl block ~defs:p.defs - - let unicode_version = Cmarkit_data.unicode_version - let commonmark_version = "0.30" -end - -(* Maps and folds *) - -module Mapper = struct - type 'a filter_map = 'a option - type 'a result = [ `Default | `Map of 'a filter_map ] - let default = `Default - let delete = `Map None - let ret v = `Map (Some v) - - type t = - { inline_ext_default : Inline.t map; - block_ext_default : Block.t map; - inline : Inline.t mapper; - block : Block.t mapper } - and 'a map = t -> 'a -> 'a filter_map - and 'a mapper = t -> 'a -> 'a result - - let none _ _ = `Default - let ext_inline_none _ _ = invalid_arg Inline.err_unknown - let ext_block_none _ _ = invalid_arg Block.err_unknown - let make - ?(inline_ext_default = ext_inline_none) - ?(block_ext_default = ext_block_none) - ?(inline = none) ?(block = none) () - = - { inline_ext_default; block_ext_default; inline; block } - - let inline_mapper m = m.inline - let block_mapper m = m.block - let inline_ext_default m = m.inline_ext_default - let block_ext_default m = m.block_ext_default - - let ( let* ) = Option.bind - - let rec map_inline m i = match m.inline m i with - | `Map i -> i - | `Default -> - let open Inline in - match i with - | Autolink _ | Break _ | Code_span _ | Raw_html _ - | Text _ | Ext_math_span _ as i -> Some i - | Image (l, meta) -> - let text = Option.value ~default:Inline.empty (map_inline m l.text) in - Some (Image ({ l with text }, meta)) - | Link (l, meta) -> - let* text = map_inline m l.text in - Some (Link ({ l with text }, meta)) - | Emphasis (e, meta) -> - let* inline = map_inline m e.inline in - Some (Emphasis ({ e with inline }, meta)) - | Strong_emphasis (e, meta) -> - let* inline = map_inline m e.inline in - Some (Strong_emphasis ({ e with inline}, meta)) - | Inlines (is, meta) -> - (match List.filter_map (map_inline m) is with - | [] -> None | is -> Some (Inlines (is, meta))) - | Ext_strikethrough (s, meta) -> - let* inline = map_inline m s in - Some (Ext_strikethrough (inline, meta)) - | ext -> m.inline_ext_default m ext - - let rec map_block m b = match m.block m b with - | `Map b -> b - | `Default -> - let open Block in - match b with - | Blank_line _ | Code_block _ | Html_block _ - | Link_reference_definition _ | Thematic_break _ - | Ext_math_block _ as b -> Some b - | Heading (h, meta) -> - let inline = match map_inline m (Block.Heading.inline h) with - | None -> (* Can be empty *) Inline.Inlines ([], Meta.none) - | Some i -> i - in - Some (Heading ({ h with inline}, meta)) - | Block_quote (b, meta) -> - let block = match map_block m b.block with - | None -> (* Can be empty *) Blocks ([], Meta.none) | Some b -> b - in - Some (Block_quote ({ b with block}, meta)) - | Blocks (bs, meta) -> - (match List.filter_map (map_block m) bs with - | [] -> None | bs -> Some (Blocks (bs, meta))) - | List (l, meta) -> - let map_list_item m (i, meta) = - let* block = map_block m (List_item.block i) in - Some ({ i with block }, meta) - in - (match List.filter_map (map_list_item m) l.items with - | [] -> None | items -> Some (List ({ l with items }, meta))) - | Paragraph (p, meta) -> - let* inline = map_inline m (Paragraph.inline p) in - Some (Paragraph ({ p with inline }, meta)) - | Ext_table (t, meta) -> - let map_col m (i, layout) = match map_inline m i with - | None -> None | Some i -> Some (i, layout) - in - let map_row (((r, meta), blanks) as row) = match r with - | `Header is -> - (`Header (List.filter_map (map_col m) is), meta), blanks - | `Sep _ -> row - | `Data is -> - (`Data (List.filter_map (map_col m) is), meta), blanks - in - let rows = List.map map_row t.rows in - Some (Ext_table ({ t with Table.rows }, meta)) - | Ext_footnote_definition (fn, meta) -> - let block = match map_block m fn.block with - | None -> (* Can be empty *) Blocks ([], Meta.none) | Some b -> b - in - Some (Ext_footnote_definition ({ fn with block}, meta)) - | ext -> m.block_ext_default m ext - - let map_doc m d = - let map_block m b = Option.value ~default:Block.empty (map_block m b) in - (* XXX something better for defs should be devised here. *) - let map_def m = function - | Block.Footnote.Def (fn, meta) -> - let block = map_block m (Block.Footnote.block fn) in - Block.Footnote.Def ({ fn with block }, meta) - | def -> def - in - let block = map_block m (Doc.block d) in - let defs = Label.Map.map (map_def m) (Doc.defs d) in - { d with Doc.block; defs } -end - -module Folder = struct - type 'a result = [ `Default | `Fold of 'a ] - let default = `Default - let ret v = `Fold v - - type ('a, 'b) fold = 'b t -> 'b -> 'a -> 'b - and ('a, 'b) folder = 'b t -> 'b -> 'a -> 'b result - and 'a t = - { inline_ext_default : (Inline.t, 'a) fold; - block_ext_default : (Block.t, 'a) fold; - inline : (Inline.t, 'a) folder; - block : (Block.t, 'a) folder; } - - let none _ _ _ = `Default - let ext_inline_none _ _ _ = invalid_arg Inline.err_unknown - let ext_block_none _ _ _ = invalid_arg Block.err_unknown - let make - ?(inline_ext_default = ext_inline_none) - ?(block_ext_default = ext_block_none) - ?(inline = none) ?(block = none) () - = - { inline_ext_default; block_ext_default; inline; block } - - let inline_folder f = f.inline - let block_folder f = f.block - let inline_ext_default f = f.inline_ext_default - let block_ext_default f = f.block_ext_default - - let rec fold_inline f acc i = match f.inline f acc i with - | `Fold acc -> acc - | `Default -> - let open Inline in - match i with - | Autolink _ | Break _ | Code_span _ | Raw_html _ | Text _ - | Ext_math_span _ -> acc - | Image (l, _) | Link (l, _) -> fold_inline f acc l.text - | Emphasis ({ inline }, _) -> fold_inline f acc inline - | Strong_emphasis ({ inline }, _) -> fold_inline f acc inline - | Inlines (is, _) -> List.fold_left (fold_inline f) acc is - | Ext_strikethrough (inline, _) -> fold_inline f acc inline - | ext -> f.inline_ext_default f acc ext - - let rec fold_block f acc b = match f.block f acc b with - | `Fold acc -> acc - | `Default -> - let open Block in - match b with - | Blank_line _ | Code_block _ | Html_block _ - | Link_reference_definition _ | Thematic_break _ | Ext_math_block _ -> acc - | Heading (h, _) -> fold_inline f acc (Block.Heading.inline h) - | Block_quote (bq, _) -> fold_block f acc bq.block - | Blocks (bs, _) -> List.fold_left (fold_block f) acc bs - | List (l, _) -> - let fold_list_item m acc (i, _) = - fold_block m acc (Block.List_item.block i) - in - List.fold_left (fold_list_item f) acc l.items - | Paragraph (p, _) -> fold_inline f acc (Block.Paragraph.inline p) - | Ext_table (t, _) -> - let fold_row acc ((r, _), _) = match r with - | (`Header is | `Data is) -> - List.fold_left (fun acc (i, _) -> fold_inline f acc i) acc is - | `Sep _ -> acc - in - List.fold_left fold_row acc t.Table.rows - | Ext_footnote_definition (fn, _) -> fold_block f acc fn.block - | ext -> f.block_ext_default f acc ext - - let fold_doc f acc d = fold_block f acc (Doc.block d) -end - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit.mli b/ocaml-lsp-server/vendor/cmarkit/cmarkit.mli deleted file mode 100644 index b0279b01b..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit.mli +++ /dev/null @@ -1,1891 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(** CommonMark parser and abstract syntax tree. - - See {{!page-index.quick}examples}. - - {b References.} - {ul - {- John MacFarlane. - {e {{:https://spec.commonmark.org/0.30/} - CommonMark Spec}}. Version 0.30, 2021}} *) - -(** {1:ast Abstract syntax tree} *) - -(** Text locations. - - A text location identifies a text span in a given UTF-8 encoded file - by an inclusive range of absolute {{!Textloc.type-byte_pos}byte} positions - and the {{!Textloc.type-line_pos}line positions} on which those occur. *) -module Textloc : sig - - (** {1:fpath File paths} *) - - type fpath = string - (** The type for file paths. *) - - val file_none : fpath - (** [file_none] is ["-"]. A file path to use when there is none. *) - - (** {1:pos Positions} *) - - (** {2:byte_pos Byte positions} *) - - type byte_pos = int - (** The type for zero-based, absolute, byte positions in text. If - the text has [n] bytes, [0] is the first position and [n-1] is - the last position. *) - - val byte_pos_none : byte_pos - (** [byte_pos_none] is [-1]. A position to use when there is none. *) - - (** {2:lines Lines} *) - - type line_num = int - (** The type for one-based, line numbers in the text. Lines - increment after a {e newline} which is either a line feed ['\n'] - (U+000A), a carriage return ['\r'] (U+000D) or a carriage return - and a line feed ["\r\n"] (). *) - - val line_num_none : line_num - (** [line_num_none] is [-1]. A line number to use when there is none. *) - - (** {2:line_pos Line positions} *) - - type line_pos = line_num * byte_pos - (** The type for line positions. This identifies a line by its line - number and the absolute byte position following its newline - (or the start of text for the first line). That byte position: - {ul - {- Indexes the first byte of text of the line if the line is non-empty.} - {- Indexes the first byte of the next newline if the line is empty.} - {- Is out of bounds and equal to the text's length for a last empty - line (this includes when the text is empty).}} *) - - val line_pos_first : line_pos - (** [line_pos_first] is [1, 0]. Note that this is the only line position - of the empty text. *) - - val line_pos_none : line_pos - (** [line_pos_none] is [(line_none, pos_none)]. *) - - (** {1:tloc Text locations} *) - - type t - (** The type for text locations. A text location identifies a text - span in an UTF-8 encoded file by an inclusive range of absolute - {{!type-byte_pos}byte positions} and the {{!type-line_pos}line positions} - on which they occur. - - If the first byte equals the last byte the range contains - exactly that byte. If the first byte is greater than the last - byte this represents an insertion point before the first byte. In - this case information about the last position should be ignored: - it can contain anything. *) - - val none : t - (** [none] is a position to use when there is none. *) - - val v : - file:fpath -> first_byte:byte_pos -> last_byte:byte_pos -> - first_line:line_pos -> last_line:line_pos -> t - (** [v ~file ~first_byte ~last_byte ~first_line ~last_line] is a text - location with the given arguments, see corresponding accessors for - the semantics. If you don't have a file use {!file_none}. *) - - val file : t -> fpath - (** [file l] is [l]'s file. *) - - val first_byte : t -> byte_pos - (** [first_byte l] is [l]'s first byte. Irrelevant if {!is_none} is - [true]. *) - - val last_byte : t -> byte_pos - (** [last_byte l] is [l]'s last byte. Irrelevant if {!is_none} or {!is_empty} - is [true]. *) - - val first_line : t -> line_pos - (** [first_line l] is the line position on which [first_byte l] lies. - Irrelevant if {!is_none} is [true].*) - - val last_line : t -> line_pos - (** [last_line l] is the line position on which [last_byte l] lies. - Irrelevant if {!is_none} or {!is_empty} is [true].*) - - (** {2:preds Predicates and comparisons} *) - - val is_none : t -> bool - (** [is_none t] is [true] iff [first_byte < 0]. *) - - val is_empty : t -> bool - (** [is_empty t] is [true] iff [first_byte t > last_byte t]. *) - - val equal : t -> t -> bool - (** [equal t0 t1] is [true] iff [t0] and [t1] are equal. This checks - that {!file}, {!first_byte} and {!last_byte} are equal. Line information - is ignored. *) - - val compare : t -> t -> int - (** [compare t0 t1] orders [t0] and [t1]. The order is compatible - with {!equal}. Comparison starts with {!file}, follows with {!first_byte} - and ends, if needed, with {!last_byte}. Line information is ignored. *) - - (** {2:shrink_and_stretch Shrink and stretch} *) - - val set_first : t -> first_byte:byte_pos -> first_line:line_pos -> t - (** [set_first l ~first_byte ~first_line] sets the the first position of - [l] to given values. *) - - val set_last : t -> last_byte:byte_pos -> last_line:line_pos -> t - (** [set_last l ~last_byte ~last_line] sets the last position of [l] - to given values. *) - - val to_first : t -> t - (** [to_first l] has both first and last positions set to [l]'s first - position. The range spans {!first_byte}. See also {!before}. *) - - val to_last : t -> t - (** [to_last l] has both first and last positions set to [l]'s last - position. The range spans {!last_byte}. See also {!after}. *) - - val before : t -> t - (** [before t] is the {{!is_empty}empty} text location starting at - {!first_byte}. *) - - val after : t -> t - (** [after t] is the empty {{!is_empty}empty} location starting at - [last_byte t + 1]; note that at the end of input this may be an - invalid byte {e index}. The {!first_line} and {!last_line} of the - result is [last_line t]. *) - - val span : t -> t -> t - (** [span l0 l1] is the span from the smallest byte position of [l0] and - [l1] to the largest byte position of [l0] and [l1]. The file path is - taken from the greatest byte position. *) - - val reloc : first:t -> last:t -> t - (** [reloc ~first ~last] uses the first position of [first], the - last position of [last] and the file of [last]. *) - - (** {2:fmt Formatting} *) - - val pp_ocaml : Format.formatter -> t -> unit - (** [pp_ocaml] formats text locations like the OCaml compiler. *) - - val pp_gnu : Format.formatter -> t -> unit - (** [pp_gnu] formats text locations according to the - {{:https://www.gnu.org/prep/standards/standards.html#Errors}GNU - convention}. *) - - val pp : Format.formatter -> t -> unit - (** [pp] is {!pp_gnu}. *) - - val pp_dump : Format.formatter -> t -> unit - (** [pp_dump] formats raw data for debugging. *) -end - -(** Node metadata. - - Holds text locations and custom, client-defined metadata. *) -module Meta : sig - - type id = int - (** The type for non-negative metadata identifiers. *) - - type t - (** The type for abstract syntax tree node metadata. *) - - val none : t - (** [none] is metadata for when there is none, its {!textloc} is - {!Textloc.none}. *) - - val make : ?textloc:Textloc.t -> unit -> t - (** [make textloc] is metadata with text location [textloc] (defaults - to {!Textloc.none}) and a fresh identifier (see {!val-id}). *) - - val id : t -> id - (** [id m] is an identifier for the metadata. Depending on how you - process the abstract syntax tree this may become non-unique but - the metadata values in an abstract syntax tree returned by - {!Doc.of_string} with [locs:true] have distinct identifiers. *) - - val textloc : t -> Textloc.t - (** [textloc m] is the source location of the syntactic construct [m] - is attached to. *) - - val with_textloc : keep_id:bool -> t -> Textloc.t -> t - (** [with_textloc ~keep_id m textloc] is metadata [m] with text location - [textloc] and a fresh id, unless [keep_id] is [true]. *) - - (** {1:preds Predicates and comparisons} *) - - val equal : t -> t -> bool - (** [equal m0 m1] is [true] if [m0] and [m1] have the same {!val-id}. - Note that they may have different {{!custom}metadata.} *) - - val compare : t -> t -> int - (** [compare m0 m1] is a total order on metadata {!val-id}s compatible with - {!equal}. *) - - val is_none : t -> bool - (** [is_none m] is [equal none m]. *) - - (** {1:custom Custom metadata} - - {b Warning.} Operating on custom metadata never changes - {!val-id}. It is possible for two meta values to have the same - id and different metadata. *) - - type 'a key - (** The type for custom metadata keys. *) - - val key : unit -> 'a key - (** [key ()] is a new metadata key. *) - - val mem : 'a key -> t -> bool - (** [mem k m] is [true] iff [k] is bound in [m]. *) - - val add : 'a key -> 'a -> t -> t - (** [add k v m] is [m] with key [k] bound to [v]. *) - - val tag : unit key -> t -> t - (** [tag k m] is [add k () m]. *) - - val remove : 'a key -> t -> t - (** [remove k m] is [m] with key [k] unbound in [v]. *) - - val find : 'a key -> t -> 'a option - (** [find k m] the value of [k] in [m], if any. *) -end - -type 'a node = 'a * Meta.t -(** The type for abstract syntax tree nodes. The data of type ['a] and its - metadata. *) - -(** Types for layout information. - - Values of these types do not represent document data. They are - used to recover document source layout informations when the - abstract syntax tree cannot represent them. - See {{!Cmarkit_commonmark.layout}source layout preservation} - for more information. - - For programmatically generated nodes, values of these types can be - left empty or filled with a desired layout. Except for the - {{!Cmarkit_commonmark}CommonMark renderer} these values are usually - ignored. *) -module Layout : sig - - type blanks = string - (** The type for blanks layout. This is only made of spaces and tabs. *) - - type nonrec string = string - (** The type for string layout. For example the art of thematic breaks - or code fences. *) - - type nonrec char = char - (** The type for character layout. For example the character used for - an emphasis or an unordered list marker. *) - - type count = int - (** The type for some kind of layout count. Usually a character - count. *) - - type indent = int - (** The type for block indentation. Mostly between 0-3. *) - - val string : ?meta:Meta.t -> string -> string node - (** [string s] is a layout string with meta data [meta] - (defaults to {!Meta.none}). *) - - val empty : string node - (** [empty] is [string ""]. *) -end - -(** Block lines. - - In CommonMark blocks, a "line" does not necessarily correspond to - a line in the source plain text. For example the lines of a - paragraph in a block quote are the lines stripped from the block - quote markers. We call the line resulting from stripping the - block structure preceeding a given block a {e block line}. *) -module Block_line : sig - - (** {1:lines Lines} *) - - type t = string node - (** The type for block lines. *) - - val to_string : t -> string - (** [to_string l] is (fst l). *) - - val list_textloc : t list -> Textloc.t - (** [list_textloc ls] is a text location spanning the lines [ls] - This is {!Textloc.none} on [[]]. *) - - val list_of_string : ?meta:Meta.t -> string -> t list - (** [list_of_string s] cuts [s] on newlines. [meta] is used for - all nodes, default to [Meta.none]. *) - - (** {1:tight_lines Tight lines} *) - - type tight = Layout.blanks * t - (** The type for tight block lines. A block line with its - initial blanks trimmed but kept for layout. *) - - val tight_to_string : tight -> string - (** [tight_to_string l] is [(fst (snd l))]. *) - - val tight_list_textloc : tight list -> Textloc.t - (** [tigh_list_textloc ls] is a text location spanning the lines [ls] - This is {!Textloc.none} on [[]]. *) - - val tight_list_of_string : ?meta:Meta.t -> string -> tight list - (** [list_of_string s] cuts [s] on newlines and computes the blanks - (except on the first line where they are part of the - data). [meta] is used for all nodes, default to [Meta.none]. *) - - (** {1:blank_lines Blank lines} *) - - type blank = Layout.blanks node - (** The type for blank block lines. *) -end - -(** Labels. - - Labels are used by - {{:https://spec.commonmark.org/0.30/#reference-link}reference links} to - refer to the {{!Label.definitions}definitions} of - {{:https://spec.commonmark.org/0.30/#link-reference-definitions} - link reference definitions}, - {{!Cmarkit.ext_footnote_def}footnote definitions} and your own - {{!Label.resolvers}interpretations}. *) -module Label : sig - - (** {1:label Labels} *) - - type key = string - (** The type for label keys. These are - {{:https://spec.commonmark.org/0.30/#link-label}link labels} - normalized for {{:https://spec.commonmark.org/0.30/#matches}matching}. *) - - type t - (** The type for {{:https://spec.commonmark.org/0.30/#link-label}link - labels}. *) - - val make : ?meta:Meta.t -> key:string -> Block_line.tight list -> t - (** [make key text] is a label with key [id] and unormalized text [text]. *) - - val with_meta : Meta.t -> t -> t - (** [with_meta m l] is [l] with meta [m]. *) - - val meta : t -> Meta.t - (** [meta k] is metadata for [k]. *) - - val key : t -> key - (** [key_id l] is the label's key. If [l] comes out of a parse this - [l]'s normalized {!text}. *) - - val text : t -> Block_line.tight list - (** [text l] is the text of [l]. *) - - val text_to_string : t -> string - (** [text_to_string l] is the lines of {!text} separated - by spaces. In contrast to {!val-key} this has not gone - throught {{:https://spec.commonmark.org/0.30/#matches}normalization}. - *) - - val compare : t -> t -> int - (** [compare l0 l1] is [String.compare (key l0) (key l1)]. *) - - (** {1:definitions Definitions} - - A label definition is the content referenced by its {!val-key}. - - Labels are defined in documents via footnotes and link reference - definitions. Additional label definitions can be added before - parsing starts by using the [defs] argument of - {!Doc.of_string}. They can also be manipulated and - created on the fly during parsing by using a - {{!resolvers}resolver}. *) - - type def = .. - (** The type for label definitions. - See for example {!Link_definition.extension-Def} or - {!Block.Footnote.extension-Def}. *) - - (** Label key maps. *) - module Map : Map.S with type key := key - - type defs = def Map.t - (** The type for label definitions. Maps label keys to their definition. *) - - (** {1:resolvers Resolvers} - - To have more control over the label definitions used in a - document, the [defs] argument of {!Doc.of_string} can be - specified to pre-populate the label definitions used during parsing; - for example with those of a previously parsed document. - - In addition the [resolver] argument can be specified to: - {ol - {- Alter or suppress label definitions made by link reference definitions - and footnote definitions. It can also be used to warn, by - side effect, on multiple label definitions.} - {- Alter, or suppress label references on reference links and images – - which happen after all label definitions have been made. You can - define the actual label that will be used for resolving - the reference to its definition.}} - - In particular 2. can be used to create synthetic label definitions - on undefined label references. This provides the ability to treat - the very liberal - {{:https://spec.commonmark.org/0.30/#link-label}link label} - syntax as a domain specific language of yours (e.g. for data binding). - - Note that parsing is not finished when resolvers are invoked - this is the reason why you don't get access to the definition's - data during resolution. - - See {{!resolver_example}an example}. *) - - type context = - [ `Def of t option * t (** Label definitions *) - | `Ref of [ `Link | `Image ] * t * t option (** Label references *) ] - (** The type for resolver contexts. See {!type-resolver}. *) - - type resolver = context -> t option - (** The type for resolvers. [context] is: - {ul - {- [`Def (prev, current)] when we just hit a - {{:https://spec.commonmark.org/0.30/#link-reference-definitions} - link reference definition} or - {{!Cmarkit.ext_footnote_def}footnote definition} that defines - the label [current]. If there is already a definition for - [current]'s {!val-key} it is provided in [prev] (whose {!meta} has - the location of the definition if you parse with locations). - If [None] is returned the [current] definition is ignored, - and definition [prev] (if any) is kept for the document. If - [Some l] is returned [l]'s key will be bound to the parsed - definition for [current] in {!Doc.defs} at the end of parsing. - The result of the resolver is stored in the abstract syntax tree and - available via {!Link_definition.defined_label} and - {!Block.Footnote.defined_label}.} - {- [`Ref (kind, ref, def)] when we just hit a link or image - referencing label [ref]. [def] is the label defining [ref]'s {!val-key} - in the document (if any). The result of the resolver is the label - stored for resolving the reference to its definition in the resulting - {!Inline.module-Link} node; - [None] means that [label] is undefined and the inline becomes - {!Inline.extension-Text} like in CommonMark.}} - - See {{!resolver_example}an example} and the {!default_resolver}. *) - - val default_resolver : resolver - (** [default_resolver] is the default resolver. - - This resolves according to the CommonMark specification. - The first label definition always takes over subsequent - ones and resolution is left untouched (i.e. a label has to be - defined in the document to be used): -{[ -let default_resolver = function -| `Def (None, l) -> Some l -| `Def (Some _, _) -> None (* Previous takes over *) -| `Ref (_, _, def) -> def -]} *) - - (** {1:resolver_example Resolver example} - - In this example we assume references to undefined labels denote - links to pages or media in our wiki and want to process them - them later via a {{!Mapper}tree transformation} or in a - {{!Cmarkit_renderer.example}renderer extension}. - - We devise a resolver to create synthetic labels on any undefined - label so that the CommonMark parser does not turn them into text. -{[ -let wikilink = Cmarkit.Meta.key () (* A meta key to recognize them *) - -let make_wikilink label = (* Just a placeholder label definition *) - let meta = Cmarkit.Meta.tag wikilink (Cmarkit.Label.meta label) in - Cmarkit.Label.with_meta meta label - -let with_wikilinks = function -| `Def _ as ctx -> Cmarkit.Label.default_resolver ctx -| `Ref (_, _, (Some _ as def)) -> def (* As per doc definition *) -| `Ref (_, ref, None) -> Some (make_wikilink ref) -]} - *) -end - -(** Link definitions. *) -module Link_definition : sig - - (** {1:layout Layout} *) - - type layout = - { indent : Layout.indent; (** Amount of indentation, [0] on inline links. *) - angled_dest : bool; (** [true] if destination is between [<…>]. *) - before_dest : Block_line.blank list; (** Blanks to destination. *) - after_dest : Block_line.blank list; (** Blanks after destination. *) - title_open_delim : Layout.char; - (** Title open delimiter (['\"'], ['('], …) *) - after_title : Block_line.blank list; - (** Blanks after title (inline links). *) } - (** The type for link reference layout. *) - - val layout_for_dest : string -> layout - (** [layout_for_dest d] computes a layout value for destination [d]. This - just determines if [angled_dest] needs to be [true]. *) - - (** {1:link_defs Link definitions} *) - - type t - (** The type for representing - {{:https://spec.commonmark.org/0.30/#link-reference-definitions} - link references definitions} and - {{:https://spec.commonmark.org/0.30/#inline-link}inline links}. *) - - val make : - ?layout:layout -> ?defined_label:Label.t option -> ?label:Label.t -> - ?dest:string node -> ?title:Block_line.tight list -> unit -> t - (** [make ()] is a link reference with given parameters. If [dest] is - given and [layout] is not, the latter is computed with - {!layout_for_dest}. [label] is a label if the link is defined - via a link reference definition. [defined_label] defaults to - [label]. *) - - val layout : t -> layout - (** [layout ld] is the layout of [ld]. *) - - val label : t -> Label.t option - (** [label ld] is [None] if this is a link definition for an inline - link. It is [Some l], if [ld] is a link reference - definition. [l] is the label as found in the text. The result - of the resolver is in {!defined_label}. *) - - val defined_label : t -> Label.t option - (** [defined_label ld] is the label determined by the {!Label.type-resolver} - for the link definition reference. The label as found - in the source text is in {!label}. If this is [None] either - it's a link definition for an inline link or the resolver deleted - the label definition. *) - - val dest : t -> string node option - (** [dest ld] is the link destination of [ld]. [None] means - there was no destination. CommonMark renders that as an empty - [href] in HTML. *) - - val title : t -> Block_line.tight list option - (** [title ld] is the title of the reference, if any. *) - - (** {1:labeldef As label definitions} *) - - type Label.def += Def of t node (** *) - (** A label definition for links. *) -end - -(** Inlines. - - {b Note.} Document data in inline nodes is always stored - {{:https://spec.commonmark.org/0.30/#backslash-escapes}unescaped} and - with {{:https://spec.commonmark.org/0.30/#entity-and-numeric-character-references}entity and character references} resolved. *) -module Inline : sig - - (** {1:inlines Inlines} *) - - type t = .. - (** The type for inlines. *) - - (** Autolinks. *) - module Autolink : sig - type t - (** The type for - {{:https://spec.commonmark.org/0.30/#autolink}autolinks}. *) - - val make : string node -> t - (** [autolink link] is an autolink for [link] - which must be a CommonMark - {{:https://spec.commonmark.org/0.30/#absolute-uri}absolute URI} - or a CommonMark - {{:https://spec.commonmark.org/0.30/#email-address}email - address}. *) - - val is_email : t -> bool - (** [is_email a] is [true] iff {!link}[ a] is - a CommonMark - {{:https://spec.commonmark.org/0.30/#email-address}email - address}. *) - - val link : t -> string node - (** [link a] is the CommonMark - {{:https://spec.commonmark.org/0.30/#absolute-uri}absolute URI} or - {{:https://spec.commonmark.org/0.30/#email-address}email address}. *) - end - - (** Hard and soft breaks *) - module Break : sig - - type type' = - [ `Hard (** {{:https://spec.commonmark.org/0.30/#hard-line-breaks} - Hard line break.} *) - | `Soft (** {{:https://spec.commonmark.org/0.30/#soft-line-breaks} - Soft line break.} *) ] - (** The type for types of line breaks. *) - - type t - (** The type for - {{:https://spec.commonmark.org/0.30/#hard-line-breaks}hard} - and - {{:https://spec.commonmark.org/0.30/#soft-line-breaks}soft} - line breaks. *) - - val make : - ?layout_before:Layout.string node -> ?layout_after:Layout.blanks node -> - type' -> t - (** [make type'] is a new break of type [type']. Layout values default - to {!Layout.empty}. *) - - val type' : t -> type' - (** [type' b] is the type of [b]. *) - - val layout_before : t -> Layout.string node - (** [layout_before b] is the layout before the newline, spaces - or possibly ['\'] for hard breaks. *) - - val layout_after : t -> Layout.blanks node - (** [layout_after] are blanks on the new {e block line}. *) - end - - (** Code spans. *) - module Code_span : sig - - type t - (** The type for - {{:https://spec.commonmark.org/0.30/#code-spans}code spans}. *) - - val make : backtick_count:Layout.count -> Block_line.tight list -> t - (** [make ~backtick_count code_layout] is a code span with given - parameters. - - {b Warning.} Nothing is made to ensure correctness of the - data, use {!of_string} to compute the right amount of - backticks. *) - - val of_string : ?meta:Meta.t -> string -> t - (** [of_string s] is a code span for [s]. [s] can start with or - include backticks; the appropriate minimal backtick count and - possible needed leading and trailing space are computed - accordingly. If [s] contains newlines, blanks after newlines - are treated as layout like during parsing. [meta] is used for - the lines of the resulting code layout (see {!code_layout}). *) - - val backtick_count : t -> Layout.count - (** [backtick_count cs] is the number of delimiting backticks. *) - - val code : t -> string - (** [code cs] computes from {!code_layout} the code in the span [cs]. *) - - val code_layout : t -> Block_line.tight list - (** [code_layout cs] is the code data in a form that allows layout - preservation. - - The actual code data is the tight block lines concatenated and - separated by space and if the result starts and ends with a - space and is not only made of spaces, these should be - dropped. The {!code} function does all that for you. *) - end - - (** Emphasis and strong emphasis. *) - module Emphasis : sig - - type inline := t - - type t - (** The type for - {{:https://spec.commonmark.org/0.30/#emphasis-and-strong-emphasis} - emphasis and strong emphasis}. *) - - val make : ?delim:Layout.char -> inline -> t - (** [make i] is an emphasis on [i]. [delim] is the delimiter - used it should be either ['*'] or ['_']. *) - - val inline : t -> inline - (** [inline e] is the emphasised inline. *) - - val delim : t -> Layout.char - (** [delim e] is the delimiter used for emphasis, should be - either ['*'] or ['_']. *) - end - - (** Links. *) - module Link : sig - - type inline := t - - type reference_layout = - [ `Collapsed - (** {{:https://spec.commonmark.org/0.30/#collapsed-reference-link} - Collapsed reference link} *) - | `Full - (** {{:https://spec.commonmark.org/0.30/#full-reference-link} - Full reference link} *) - | `Shortcut - (** {{:https://spec.commonmark.org/0.30/#shortcut-reference-link} - Shortcut reference link} *) ] - (** The type for reference link layouts. *) - - type reference = - [ `Inline of Link_definition.t node - (** {{:https://spec.commonmark.org/0.30/#inline-link}Inline link} *) - | `Ref of reference_layout * Label.t * Label.t - (** {{:https://spec.commonmark.org/0.30/#reference-link}Reference - links}. First label is the label of the reference, second - label is the label of the referenced definition. *) ] - (** The type for references. *) - - type t - (** The type for {{:https://spec.commonmark.org/0.30/#links}links} - and {{:https://spec.commonmark.org/0.30/#images}images}. *) - - val make : inline -> reference -> t - (** [make i ref] is a link for text [i] and link reference [ref]. - - If you plan to render to CommonMark and this is not an inline - reference you should include a - {!Block.extension-Link_reference_definition} (or - {!Block.extension-Ext_footnote_definition}) for [ref] - somewhere in the document, otherwise the reference will not - parse back. *) - - val text : t -> inline - (** [text l] is the text of the link. *) - - val reference : t -> reference - (** [reference l] is the reference of the link. *) - - val referenced_label : t -> Label.t option - (** [referenced_label l] is the label referenced by the label of [l]. - This is the second label of [`Ref _] or [None] on inline - references.*) - - val reference_definition : Label.defs -> t -> Label.def option - (** [reference_definition defs l] is the definition of [l]'s - reference. If [l] is an [`Inline] reference this returns its - link definition wrapped in a {!Link_definition.Def}. If [l] is - [`Ref] this looks up the {!referenced_label} in [defs]. *) - - val is_unsafe : string -> bool - (** [is_unsafe url] is [true] if [url] is deemed unsafe. This is - the case if [url] starts with a caseless match of - [javascript:], [vbscript:], [file:] or [data:] except if - [data:image/{gif,png,jpeg,webp}]. These rules were taken from - {{:https://github.com/commonmark/cmark}[cmark]}, the C - reference implementation of CommonMark and are likely - incomplete. If you are trying to prevent XSS you should - post-process rendering outputs with a dedicated HTML sanitizer. *) - end - - (** Raw HTML. *) - module Raw_html : sig - - type t = Block_line.tight list - (** The type for {{:https://spec.commonmark.org/0.30/#raw-html}inline raw - HTML} (can span multiple lines). - - {b Warning.} If you create HTML blocks using - {!Block_line.tight_list_of_string} you should make sure the - resulting lines satisfy the contraints of CommonMark raw HTML - (one way is to parse them instead). *) - end - - (** Text. *) - module Text : sig - type t = string - (** The type for - {{:https://spec.commonmark.org/0.30/#textual-content}textual content}. - - Normally these strings should not contain newlines. This can - however happen if the source had newlines as - {{:https://spec.commonmark.org/0.30/#entity-and-numeric-character-references}character references}. *) - end - - type t += - | Autolink of Autolink.t node - | Break of Break.t node - | Code_span of Code_span.t node - | Emphasis of Emphasis.t node - | Image of Link.t node - | Inlines of t list node (** Splicing *) - | Link of Link.t node - | Raw_html of Raw_html.t node - | Strong_emphasis of Emphasis.t node - | Text of Text.t node (** *) - (** The - CommonMark {{:https://spec.commonmark.org/0.30/#inlines}inlines}. *) - - val empty : t - (** [empty] is [Inlines ([], Meta.none)]. *) - - (** {1:exts Extensions} - - See the description of {{!Cmarkit.extensions}extensions}. *) - - (** Strikethrough. *) - module Strikethrough : sig - type inline := t - - type t - (** The type for {{!Cmarkit.ext_strikethrough}strikethrough}. *) - - val make : inline -> t - (** [make i] is [i] with a strikethrough. *) - - val inline : t -> inline - (** [inline s] is the inline with a strikethrough. *) - end - - (** Math span. *) - module Math_span : sig - type t - (** The type for {{!Cmarkit.ext_math_inline}math spans}. *) - - val make : display:bool -> Block_line.tight list -> t - (** [make tex_layout] is an inline or display math span with given - T{_E}X code. *) - - val display : t -> bool - (** [display ms] is [true] if the span should be on its own line. *) - - val tex : t -> string - (** [tex ms] is the inline math T{_E}X code of [ms] *) - - val tex_layout : t -> Block_line.tight list - (** [tex_layout ms] is inline math T{_E}X code in a form that - allows layout preservation. - - The acual code data is the tight block lines concatenated and - separated by space. The {!tex} function does that for you. *) - end - - type t += - | Ext_strikethrough of Strikethrough.t node - | Ext_math_span of Math_span.t node (** *) - (** The supported inline extensions. These inlines are only parsed when - {!Doc.of_string} is called with [strict:false]. *) - - (** {1:funs Functions} *) - - val is_empty : t -> bool - (** [is_empty i] is [true] if [i] is [Inline ([], _)] or [Text ("", _)]. *) - - val meta : ?ext:(t -> Meta.t) -> t -> Meta.t - (** [meta ~ext i] is the metadata of [i]. - - [ext] is called on cases not defined in this module. The default - raises [Invalid_argument]. *) - - val normalize : ?ext:(t -> t) -> t -> t - (** [normalize i] has the same content as [i] but is such that for any - occurence of [Inlines (is, _)] in [i] the list of inlines [is]: - {ol - {- [is] is not a singleton list.} - {- Has no two consecutive [Text _] cases. If that occurs the texts are - concatenated, the meta of the first one is kept and its text - location extended to include the second one.} - {- Has no [Inlines _] case. The meta is dropped and the nested - inlines are spliced in [is] where the case occurs.}} - - [ext] is called on cases not defined in this module. The default - raises [Invalid_argument]. *) - - val to_plain_text : - ?ext:(break_on_soft:bool -> t -> t) -> break_on_soft:bool -> - t -> string list list - (** [to_plain_text ~ext ~break_on_soft i] has the plain text of [i] - as a sequence of lines represented by a list of strings to be - concatenated. If [break_on_soft] is [true] soft line breaks - are turned into hard line breaks. To turn the result [r] - in a single string apply: - - {[ String.concat "\n" (List.map (String.concat "") r) ]} - - [ext] is called on cases not defined in this module, it should - compile extensions to one of these cases. The default raises - [Invalid_argument]. *) - - val id : ?buf:Buffer.t -> ?ext:(break_on_soft:bool -> t -> t) -> t -> string - (** [id ?buf i] derives an identifier for inline [i] using [buf] as - scratch space (one is created if unspecified). - - This converts [i] to plain text using {!Inline.to_plain_text}, - then applies the same - {{:https://spec.commonmark.org/0.30/#matches}normalization} - performed on labels, maps spaces to character [-] (U+002D), - drops {{:https://spec.commonmark.org/0.30/#unicode-punctuation-character} - Unicode punctuation characters} except [-] (U+002D) and [_] ([U+005F]). - - [ext] is given to {!Inline.to_plain_text}. *) -end - -(** Blocks. *) -module Block : sig - - (** {1:blocks Blocks} *) - - type t = .. - (** The type for blocks. *) - - (** Blank lines. *) - module Blank_line : sig - type t = Layout.blanks - (** The type for - {{:https://spec.commonmark.org/0.30/#blank-lines}blank lines}. - These can be ignored during rendering, they are kept for layout. *) - end - - (** Block quotes. *) - module Block_quote : sig - - type block := t - - type t - (** The type for {{:https://spec.commonmark.org/0.30/#block-quotes} - block quotes}. *) - - val make : ?indent:Layout.indent -> block -> t - (** [make b] quotes block [b]. *) - - val indent : t -> Layout.indent - (** [indent bq] is the indentation to the block quote - marker found on the first line. *) - - val block : t -> block - (** [block bq] is the quoted block. *) - end - - (** Code blocks. *) - module Code_block : sig - - type fenced_layout = - { indent : Layout.indent; (** Indent to opening fence *) - opening_fence : Layout.string node; - (** Opening fence (before info string). *) - closing_fence : Layout.string node option; - (** Closing fence (if any). *) } - (** The type for fenced code block layouts. *) - - type layout = [ `Indented | `Fenced of fenced_layout ] - (** The type for code block layouts. *) - - type t - (** The type for - {{:https://spec.commonmark.org/0.30/#indented-code-block} - indented} and - {{:https://spec.commonmark.org/0.30/#fenced-code-blocks}fenced} - code blocks. *) - - val make : - ?layout:layout -> ?info_string:string node -> Block_line.t list -> t - (** [make ?layout ?info_string code] is a code block with given - parameters. [layout] defaults to a fenced layout. If [layout] - is [`Indented] and an [info_string] is provided, the layout is - switched to [`Fenced]. *) - - val layout : t -> layout - (** [layout cb] is the layout of [cb]. *) - - val info_string : t -> string node option - (** [info_string cb] is the - {{:https://spec.commonmark.org/0.30/#info-string}info string} - of [cb], if any. *) - - val code : t -> Block_line.t list - (** [code cb] are the code lines of [cb]. *) - - val make_fence : t -> Layout.char * Layout.count - (** [make_fence cb] is a fence character and count suitable for [cb]. *) - - val language_of_info_string : string -> (string * string) option - (** [language_of_info_string s] extracts a (non-empty) language, - the first word of [s] and a trimmed remainder. Assumes [s] is - {!String.trim}ed which is what {!info_string} gives you. *) - end - - (** Headings. *) - module Heading : sig - - type atx_layout = - { indent : Layout.indent; (** Indent to ['#']. *) - after_opening : Layout.blanks; (** Blanks after ['#']. *) - closing : Layout.string; (** Closing sequence of ['#'] and blanks. *) } - (** The type for ATX heading layout. *) - - type setext_layout = - { leading_indent : Layout.indent; (** Of heading first line. *) - trailing_blanks : Layout.blanks; (** Of heading last line. *) - underline_indent : Layout.indent; (** Indentation of underline. *) - underline_count : Layout.count node; (** Underline char count. *) - underline_blanks : Layout.blanks; (** Underline trailing blanks. *) } - (** The type for setext heading layout. *) - - type layout = [ `Atx of atx_layout | `Setext of setext_layout ] - (** The type for heading layouts. *) - - type id = - [ `Auto of string (** Automatically derived. *) - | `Id of string (** Explicitely specified in another way. *) ] - (** The type for heading identifiers. This notion does not - exist in CommonMark. *) - - type t - (** The type for {{:https://spec.commonmark.org/0.30/#atx-headings} - ATX} and {{:https://spec.commonmark.org/0.30/#setext-headings}Setext} - headings. *) - - val make : ?id:id -> ?layout:layout -> level:int -> Inline.t -> t - (** [make ~level text] is a heading with given - parameters. [layout] defaults to [`Atx] so you should make - sure [text] has no breaks. [level] is clamped to 1-6 or 1-2 - depending on [layout]. [id] is an identifier for the heading. *) - - val layout : t -> layout - (** [layout h] is the layout of [h]. *) - - val level : t -> int - (** [level h] is the level of [h], from [1] to [6]. *) - - val inline : t -> Inline.t - (** [inline h] is the contents of the heading. *) - - val id : t -> id option - (** [id h] is the heading identifier (if any). Can be automatically - derived at parse time from the heading {!inline} if - {{!Doc.of_string}[heading_auto_ids:true]}. - Can also be derived later via {!Inline.id}. *) - end - - (** HTML blocks. *) - module Html_block : sig - type t = Block_line.t list - (** The type for {{:https://spec.commonmark.org/0.30/#html-blocks}HTML - blocks}. - - {b Warning.} If you create HTML blocks using - {!Block_line.list_of_string} you should make sure the resulting - lines satisfy the contraints of CommonMark HTML blocks. - (one way is to parse them instead). *) - end - - (** List items. *) - module List_item : sig - - type block := t - - type t - (** The type for {{:https://spec.commonmark.org/0.30/#list-items}list - items}. *) - - val make : - ?before_marker:Layout.indent -> ?marker:Layout.string node -> - ?after_marker:Layout.indent -> ?ext_task_marker:Uchar.t node -> - block -> t - (** [make b] is a list item for block [b] with given parameters, see - corresponding accessors for semantics. *) - - val block : t -> block - (** [block i] is the contents of [i]. *) - - val before_marker : t -> Layout.indent - (** [before_marker i] is the indentation before the list marker. *) - - val marker : t -> Layout.string node - (** [marker i] is the item marker layout of [i]. *) - - val after_marker : t -> Layout.indent - (** [after_marker i] is the indentation after the marker. *) - - (** {1:ext_task_item Task items} *) - - val ext_task_marker : t -> Uchar.t node option - (** [ext_task_marker i] is a task marker, only occurs in non-strict - parsing mode, see see extension - {{!Cmarkit.ext_list_task_items}list task items}.*) - - val task_status_of_task_marker : - Uchar.t -> [ `Unchecked | `Checked | `Cancelled | `Other of Uchar.t ] - (** [task_status_of_task_marker u] is a status for marker [u], see extension - {{!ext_list_task_items}list task item}. *) - end - - (** Lists. *) - module List' : sig - - type type' = - [ `Unordered of Layout.char (** with given marker. *) - | `Ordered of int * Layout.char - (** starting at given integer, markers ending with given character - ([')'] or ['.']). *) ] - (** The type for list types. *) - - type t - (** The type for {{:https://spec.commonmark.org/0.30/#lists}lists}. *) - - val make : ?tight:bool -> type' -> List_item.t node list -> t - (** [make ?tight t items] is a list with given parameters. - tight default to [true], but should be computed from [items] - in practice. *) - - val type' : t -> type' - (** [type' l] is the list type of [l]. *) - - val tight : t -> bool - (** [tight l] is [true] iff the list is - {{:https://spec.commonmark.org/0.30/#tight}tight}. *) - - val items : t -> List_item.t node list - (** [items l] are the items of [l]. *) - end - - (** Paragraphs. *) - module Paragraph : sig - - type t - (** The type for - {{:https://spec.commonmark.org/0.30/#paragraphs}paragraphs}. *) - - val make : - ?leading_indent:Layout.indent -> ?trailing_blanks:Layout.blanks -> - Inline.t -> t - (** [make inline] is a paragraph with given parameters. *) - - val inline : t -> Inline.t - (** [inline p] is the paragraph content. *) - - val leading_indent : t -> Layout.indent - (** [leading_indent p] is the indent on the first line (0-3). *) - - val trailing_blanks : t -> Layout.blanks - (** [trailing_blanks] are trailing blanks on the last line. *) - end - - (** Thematic breaks. *) - module Thematic_break : sig - - type t - (** The type for {{:https://spec.commonmark.org/0.30/#thematic-break} - thematic breaks}. *) - - val make : ?indent:Layout.indent -> ?layout:Layout.string -> unit -> t - (** [make ()] is a thematic break with given parameters. [layout] - defaults to ["---"]. *) - - val indent : t -> Layout.indent - (** [indent t] is the thematic break indent (0-3). *) - - val layout : t -> Layout.string - (** [layout t] is the thematic break art, including trailing blanks. *) - end - - type t += - | Blank_line of Blank_line.t node - | Block_quote of Block_quote.t node - | Blocks of t list node (** Splicing *) - | Code_block of Code_block.t node - | Heading of Heading.t node - | Html_block of Html_block.t node - | Link_reference_definition of Link_definition.t node - (** {{:https://spec.commonmark.org/0.30/#link-reference-definitions} - Link reference definitions}, kept for layout *) - | List of List'.t node - | Paragraph of Paragraph.t node - | Thematic_break of Thematic_break.t node - (** {{:https://spec.commonmark.org/0.30/#paragraphs}Thematic break} *) - (** The CommonMark {{:https://spec.commonmark.org/0.30/#leaf-blocks}leaf} - and {{:https://spec.commonmark.org/0.30/#container-blocks}container} - blocks. *) - - val empty : t - (** [empty] is [Blocks ([], Meta.none)]. *) - - (** {1:exts Extensions} - - See the description of {{!Cmarkit.extensions}extensions}. *) - - (** Tables. *) - module Table : sig - - type align = [ `Left | `Center | `Right ] - (** The type for column alignments. *) - - type sep = align option * Layout.count - (** The type for separators. The column aligment and the number of - [-] for layout preservation. *) - - type cell_layout = Layout.blanks * Layout.blanks - (** The type for cell layout, initial and trailing blanks. *) - - type row = - [ `Header of (Inline.t * cell_layout) list - | `Sep of sep node list - | `Data of (Inline.t * cell_layout) list ] - (** The type for rows. The lists only have entries for columns as - found in rows in the document. You need to pad them on the - right with more columns to reach the table's {!col_count}. *) - - type t - (** The type for {{!Cmarkit.ext_tables}tables}. *) - - val make : ?indent:Layout.indent -> (row node * Layout.blanks) list -> t - (** [make rows] is a table row [rows]. *) - - val indent : t -> Layout.indent - (** [indent t] is the indentation to the first pipe found on the - first row. *) - - val col_count : t -> int - (** [col_count t] is the number of columns in the table. *) - - val rows : t -> (row node * Layout.blanks) list - (** [rows t] are the table's rows. *) - end - - (** Footnotes. *) - module Footnote : sig - - (** {1:footnotes Footnotes} *) - - type block := t - - type t - (** The type for {{!Cmarkit.ext_footnotes}footnotes}. *) - - val make : - ?indent:Layout.indent -> ?defined_label:Label.t option -> Label.t -> - block -> t - (** [make label b] is a footnote for label [label] with content [b]. - [defined_label] defaults to [label]. *) - - val indent : t -> Layout.indent - (** [indent fn] is the indentation to the label found on the first line. *) - - val label : t -> Label.t - (** [label fn] is the footnote definition label as found in the - source text. It includes the [^]. See also {!defined_label}. *) - - val defined_label : t -> Label.t option - (** [defined_label fn] is the label determined by the {!Label.type-resolver} - for the footnote. The label as found in the source text is in {!label}. - If this is [None] the resolver deleted the label definition. *) - - val block : t -> block - (** [block fn] is the footnote content. *) - - (** {1:labeldef As label definitions} *) - - type Label.def += Def of t node (** *) - (** A label definition for footnotes. *) - end - - type t += - | Ext_math_block of Code_block.t node - (** {{!Cmarkit.ext_math_display}display math}*) - | Ext_table of Table.t node (** *) - | Ext_footnote_definition of Footnote.t node (** *) - (** The supported block extensions. These blocks are only parsed when - {!Doc.of_string} is called with [strict:false]. *) - - (** {1:funs Functions on blocks} *) - - val meta : ?ext:(t -> Meta.t) -> t -> Meta.t - (** [meta ~ext b] is the metadata of [b]. - - [ext] is called on cases not defined in this module. The default - raies [Invalid_argument]. *) - - val normalize : ?ext:(t -> t) -> t -> t - (** [normalize b] has the same content as [b] but is such that for any - occurence of [Blocks (bs, _)] in [b] the list of blocks [bs]: - - {ol - {- [bs] is not a singleton list.} - {- Has no [Blocks _] case. The meta is dropped and the nested - blocks are spliced in [bs] where the case occurs.}} - - [ext] is called on cases not defined in this module. The default raises - [Invalid_argument]. *) - - val defs : - ?ext:(Label.defs -> t -> Label.defs) -> ?init:Label.defs -> t -> - Label.defs - (** [defs b] collects [b]'s {!Link_reference_definition} and - {!Ext_footnote_definition} and for those that have a label - definition (see {!Link_definition.defined_label} and - {!Footnote.defined_label}) - adds them to [init] (defaults to {!Label.Map.empty}). - - [ext] is called on cases not defined in this module. The default - raises [Invalid_argument]. *) -end - -(** Documents (and parser). *) -module Doc : sig - - (** {1:docs Documents} *) - - type t - (** The type for CommonMark documents. *) - - val nl : t -> Layout.string - (** [nl d] is the first newline found in the text during parsing - or ["\n"] if there was none. *) - - val block : t -> Block.t - (** [block d] is the document's contents as a block. *) - - val defs : t -> Label.defs - (** [defs d] are the label definitions resulting from parsing [d]. - The result depends on the label definitions found in the - source and the [defs] and [resolver] values specified on - {!Doc.of_string}. *) - - val make : ?nl:Layout.string -> ?defs:Label.defs -> Block.t -> t - (** [make ~nl ~defs b] is a document for block [b] with newline - [nl] (defaults to ["\n"]), label definition [defs] - (defaults to {!Label.Map.empty}). *) - - val empty : t - (** [empty] is an empty document. *) - - (** {1:parsing Parsing} *) - - val of_string : - ?defs:Label.defs -> ?resolver:Label.resolver -> ?nested_links:bool -> - ?heading_auto_ids:bool -> ?layout:bool -> ?locs:bool -> - ?file:Textloc.fpath -> ?strict:bool -> string -> t - (** [of_string md] is a document from the UTF-8 encoded CommonMark - document [md]. - - {ul - {- If [strict] is [true] (default) the CommonMark specification is - followed. If [false] these {{!extensions}extensions} are enabled.} - {- [file] is the file path from which [s] is assumed to have been read - (defaults to {!Textloc.file_none}), used in the {!Textloc.t} - values iff [locs] is [true].} - {- If [locs] is [true] locations are stored in nodes of the abstract - syntax tree in individually {{!Meta.val-id}identified} {!Meta.t} - values. If [false] (default) node meta values are all {!Meta.none} - whose text location is {!Textloc.none}.} - {- If [layout] is [false] (default) layout values cannot be relied - upon and do not in general represent source layout, some fields - may be normalized. The {!Block.extension-Blank_line}, - {!Block.extension-Link_reference_definition}, - {!Block.extension-Ext_footnote_definition}, - layout block values are present in the result regardless of this - parameter.} - {- If [heading_auto_ids] is [true] (defaults to [false]) then [`Auto] - {{!Block.Heading.type-id}heading identifiers} are generated - during parsing from the header text - with {!Inline.id} (at that point no [ext] argument is needed) - and made accessible in {!Block.Heading.val-id}. Note that the identifiers - may not be unique, we leave it to the backends to handle this - problem.} - {- If [nested_links] is [true] (defaults to [false]) there is no - restriction on having links in link text, which is forbidden by - CommonMark and HTML. This can be useful for - embedding DSLs in link labels or destinations. Note that image - links already allow link nesting as per CommonMark - specification.} - {- If [resolver] is provided this is used resolve label definitions - and references. See {{!Label.resolvers}here} for details. Defaults to - {!Label.default_resolver}.} - {- If [defs] adds these label definitions to the document - (defaults to {!Label.Map.empty}). Think of them - as being prepended to [md]. If [resolver] is - {!Label.default_resolver}, these take over the same labels - defined in [md] (first definition takes over in CommonMark).}} - - UTF-8 decoding errors and U+0000 are turned into {!Uchar.rep} - characters. Inlines of the result should be {!Inline.normalize}d. - Blocks of the result should be {!Block.normalize}d. - - {b Note.} For simple renders parsing with [layout:false] and - [locs:false] is generally faster; having these to [true] - allocates quite a bit. *) - - (** {1:versions Versions} *) - - val unicode_version : string - (** [unicode_version] is the Unicode version known to {!of_string}. *) - - val commonmark_version : string - (** [commonmark_version] is the CommonMark version known to {!of_string}. *) -end - -(** {1:maps_and_folds Maps and folds} *) - -(** Abstract syntax tree mappers. - - Mappers help with pushing abstract syntax tree transformations in every - node with a minimal amount of code by defaulting the cases you - don't handle. The default map maps leaves to themselves and - otherwise propagates the map to all childrens. - - This map has the form of {!List.filter_map}, however it is akin - to {!List.concat_map} as it allows: - - {ul - {- Node deletion by mapping to [None]} - {- Node transformation by mapping to [Some _]} - {- Node expansion by mapping to [Some (Inlines _)] or [Some (Blocks _)]}} - - See an {{!Mapper.example}example}. *) -module Mapper : sig - - (** {1:results Map results} *) - - type 'a filter_map = 'a option - (** The type for maps. [None] is for node deletion. [Some n] is a map - to [n]. *) - - type 'a result = - [ `Default (** Do the default map. *) | `Map of 'a filter_map ] - (** The type for mapper results. *) - - val default : 'a result - (** [default] is [`Default]. *) - - val delete : 'a result - (** [delete] is [`Map None]. *) - - val ret : 'a -> 'a result - (** [ret v] is [`Map (Some v)]. *) - - (** {1:mappers Mappers} *) - - type t - (** The type for abstract syntax tree mappers. *) - - type 'a map = t -> 'a -> 'a filter_map - (** The type for maps on values of type ['a]. *) - - type 'a mapper = t -> 'a -> 'a result - (** The type for mappers on values of type ['a]. - - This is what you specify. Return [`Default] if you are not - interested in handling the given case. Use {!map_inline} or - {!map_block} with the given mapper if you need to call the - mapper recursively. *) - - val make : - ?inline_ext_default:Inline.t map -> ?block_ext_default:Block.t map -> - ?inline:Inline.t mapper -> ?block:Block.t mapper -> unit -> t - (** [make ?inline ?block ()] is a mapper using [inline] and [block] - to map the abstract syntax tree. Both default to [fun _ _ -> `Default]. - - The mapper knows how to default the built-in abstract syntax - tree and the built-in {{!extensions}extensions}. It maps - them in document and depth-first order. - - If you extend the abstract syntax tree you need to indicate how to default - these new cases by providing [inline_ext_default] or - [block_ext_default] functions. By default these functions raise - [Invalid_argument]. *) - - (** {1:mapping Mapping} *) - - val map_inline : Inline.t map - (** [map_inline m i] maps [i] with [m]. *) - - val map_block : Block.t map - (** [map_block m b] maps [b] with [m]. *) - - val map_doc : t -> Doc.t -> Doc.t - (** [map_doc m d] maps [Doc.block d] with [m]. If the document - block maps to [None] is replaced by {!Block.empty}. - - {b Warning unstable.} The following may change in the future. - This function also maps the blocks present {!Block.Footnote.Def} - label definitions but will not map inline or block data in - {!Label.def} cases unknown to [Cmarkit]. If the block maps to - [None] for the footnote it is replaced by {!Block.empty}. - - Also note that if these label definitions were defined in [d]'s - abstract syntax tree, they will also already be - mapped in {!Block.Link_reference_definition} and - {!Block.Ext_footnote_definition} cases. It is possible to collect - these mapped definitions via {!Block.defs} on the resulting - document's block. *) - - (** {1:accessors Accessors} *) - - val inline_mapper : t -> Inline.t mapper - (** [inline m] is the inline mapper of [m]. *) - - val block_mapper : t -> Block.t mapper - (** [block m] is the block mapper of [m]. *) - - val inline_ext_default : t -> Inline.t map - (** [inline_ext_default m] is the inline extensions defaulter of [m] *) - - val block_ext_default : t -> Block.t map - (** [block_ext_default m] is the block extensions defaulter of [m]. *) - - (** {1:example Example} - - This example sets all code blocks of document [doc] without info string - to [lang]. - {[ -let set_unknown_code_block_lang ~lang doc = - let open Cmarkit in - let default = lang, Meta.none in - let block m = function - | Block.Code_block (cb, meta) - when Option.is_none (Block.Code_block.info_string cb) -> - let layout = Block.Code_block.layout cb in - let code = Block.Code_block.code cb in - let cb = Block.Code_block.make ~layout ~info_string:default code in - Mapper.ret (Block.Code_block (cb, meta)) - | _ -> - Mapper.default (* let the mapper thread the map *) - in - let mapper = Mapper.make ~block () in - Mapper.map_doc mapper doc -]} - *) -end - -(** Abstract syntax tree folders. - - Folders help with pushing abstract syntax tree folds in every node - with a minimal amount of code by defaulting the cases you don't handle. - The default fold returns the accumulator unchanged on leaves and otherwise - propagates the fold to all children. - - See an {{!Folder.example}example}. *) -module Folder : sig - - (** {1:results Fold results} *) - - type 'a result = [ `Default (** Do the default fold *) | `Fold of 'a ] - (** The type for folder results. The [`Default] case indicates the folder - to perform the default fold. *) - - val default : 'a result - (** [default] is [`Default]. *) - - val ret : 'a -> 'a result - (** [ret v] is [`Fold v]. *) - - (** {1:folders Folders} *) - - type 'a t - (** The type for abstract syntax tree folders with result values of type - ['a]. *) - - type ('a, 'b) fold = 'b t -> 'b -> 'a -> 'b - (** The type for folds on values of type ['a]. *) - - type ('a, 'b) folder = 'b t -> 'b -> 'a -> 'b result - (** The type for folders on value of type ['a]. - - This is what you specify. Return [`Default] if you are not - interested in handling the given case. Use {!fold_inline} or - {!fold_block} with the given folder if you need to call the - folder recursively. *) - - val make : - ?inline_ext_default:(Inline.t, 'a) fold -> - ?block_ext_default:(Block.t, 'a) fold -> - ?inline:(Inline.t, 'a) folder -> ?block:(Block.t, 'a) folder -> unit -> 'a t - (** [make ?inline ?block ()] is a folder using [inline] and [block] - to fold the abstract syntax tree. Both default to - [fun _ _ _ -> `Default]. - - The folder knows how to default the built-in abstract syntax tree - and the built-in {{!extensions}extensions}. It folds - them in document and depth-first order. - - If you extend the abstract syntax tree you need to indicate how - to default these new cases by providing [inline_ext_default] or - [block_ext_default] functions. By default these functions raise - [Invalid_argument]. *) - - (** {1:folding Folding} *) - - val fold_inline : 'a t -> 'a -> Inline.t -> 'a - (** [fold_inline f acc i] folds [i] with [f] starting with [acc]. *) - - val fold_block : 'a t -> 'a -> Block.t -> 'a - (** [fold_block f acc b] folds [b] with [f] starting with [acc]. *) - - val fold_doc : 'a t -> 'a -> Doc.t -> 'a - (** [fold_doc f acc d] folds [Doc.block d] with [f] starting with [acc]. - - {b Warning.} Blocks present in [d]'s {!Doc.defs} is not folded - over. Note however that if these definitions were defined by - [d]'s abstract syntax tree, they will already have been folded - over on {!Block.Link_reference_definition} and - {!Block.Ext_footnote_definition} cases. *) - - (** {1:acesssors Accessors} *) - - val inline_folder : 'a t -> (Inline.t, 'a) folder - (** [inline_folder f] is the inline folder of [f]. *) - - val block_folder : 'a t -> (Block.t, 'a) folder - (** [block_folder f] is the block folder of [f]. *) - - val inline_ext_default : 'a t -> (Inline.t, 'a) fold - (** [inline_ext_default f] is the inline extension defaulter of [f]. *) - - val block_ext_default : 'a t -> (Block.t, 'a) fold - (** [block_ext_default f] is the block extension defaulter of [f]. *) - - (** {1:example Example} - - This example collects the languages present in the code blocks - of a document. -{[ -let code_block_langs doc = - let open Cmarkit in - let module String_set = Set.Make (String) in - let block m acc = function - | Block.Code_block (cb, _) -> - let acc = match Block.Code_block.info_string cb with - | None -> acc - | Some (info, _) -> - match Block.Code_block.language_of_info_string info with - | None -> acc - | Some (lang, _) -> String_set.add lang acc - in - Folder.ret acc - | _ -> - Folder.default (* let the folder thread the fold *) - in - let folder = Folder.make ~block () in - let langs = Folder.fold_doc folder String_set.empty doc in - String_set.elements langs -]} *) -end - -(** {1:extensions Extensions} - - For some documents, bare CommonMark just misses it. The extensions - are here to make it hit the mark. To enable them use - {!Doc.of_string} with [strict:false]. - - Please note the following: - {ol - {- There is no plan to provide an extension mechanism at the - parsing level. A lot can already be achieved by using - {{!Label.resolvers}reference resolvers}, - abusing code fences, post-processing the abstract syntax tree, or - {{!Cmarkit_renderer.example}extending} the renderers.} - {- In order to minimize dialects and extension interaction - oddities, there is no plan to allow to selectively - enable extensions.} - {- If one day the CommonMark specification standardizes a set - of extensions. [Cmarkit] will support those.} - {- In the short term, there is no plan to support more extensions than - those that are listed here.}} - - {2:ext_strikethrough Strikethrough} - - According to {{:https://pandoc.org/MANUAL.html#strikeout}[pandoc]}. - - {v Strikethrough your ~~perfect~~ imperfect thoughts. v} - - Inline text delimited between two [~~] gets into an - {!Inline.extension-Ext_strikethrough} node. - - The text delimited by [~~] cannot start or end with - {{:https://spec.commonmark.org/0.30/#unicode-whitespace-character} - Unicode whitespace}. When a closer can close multiple openers, the - neareast opener is closed. Strikethrough inlines can be nested. - - {2:ext_math Math} - - According to a mix of - {{:https://pandoc.org/MANUAL.html#extension-tex_math_dollars} - [pandoc]}, {{:https://docs.gitlab.com/ee/user/markdown.html#math}GLFM}, - {{:https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions}GFM}. - - {3:ext_math_inline Inline math} - - {v This is an inline $\sqrt(x - 1)$ math expression. v} - - Inline text delimited between [$] gets into an - {!Inline.extension-Ext_math_span} node. - - The text delimited by [$] cannot start and end with - {{:https://spec.commonmark.org/0.30/#unicode-whitespace-character} - Unicode whitespace}. Inline math cannot be nested, after an opener - the nearest (non-escaped) closing delimiter matches. Otherwise it - is parsed in essence like a - {{:https://spec.commonmark.org/0.30/#code-spans}code span}. - - {3:ext_math_display Display math} - - {v -It's better to get that $$ \left( \sum_{k=1}^n a_k b_k \right)^2 $$ -on its own line. A math block may also be more convenient: - -```math -\left( \sum_{k=1}^n a_k b_k \right)^2 < \Phi -``` -v} - - Inline text delimited by [$$] gets into a - {!Inline.extension-Ext_math_span} with the - {!Inline.Math_span.display} property set to [true]. Alternatively - code blocks whose - {{!Block.Code_block.language_of_info_string}language} is [math] - get into in {!Block.Ext_math_block} blocks. - - In contrast to [$], the text delimited by [$$] can start and end - with whitespace, however it can't contain a blank line. Display - math cannot be nested, after an opener the nearest (non-escaped) - closing delimiter matches. Otherwise it's parsed in essence like - a {{:https://spec.commonmark.org/0.30/#code-spans}code span}. - - {2:ext_list_task_items List task items} - - According to a mix of - {{:https://github.com/mity/md4c/blob/master/test/tasklists.txt}md4c}, - {{:https://docs.gitlab.com/ee/user/markdown.html#task-lists}GLFM}, - {{:https://github.github.com/gfm/#task-list-item}GFM} and personal - ad-hoc brewery. - -{v -* [ ] That's unchecked. -* [x] That's checked. -* [~] That's cancelled. -v} - - If a list item starts with up to three space, followed by followed - by [\[], a single Unicode character, [\]] and a space (the space - can be omitted if the line is empty, but subsequent indentation - considers there was one). The Unicode character gets stored in - {!Block.List_item.ext_task_marker} and counts as one column - regardless of the character's render width. The task marker - including the final space is considered part of the list marker as - far as subsequent indentation is concerned. - - The Unicode character indicates the status of the task. That's up - to the client but the function - {!Block.List_item.task_status_of_task_marker} which is used by the - built-in renderers makes the following choices: - - {ul - {- Unchecked: [' '] (U+0020).} - {- Checked: ['x'] (U+0078), ['X'] (U+0058), ['✓'] (U+2713, CHECK MARK), - ['✔'] (U+2714, HEAVY CHECK MARK), ['𐄂'] (U+10102, AEGEAN CHECK MARK), - ['🗸'] (U+1F5F8, LIGHT CHECK MARK).} - {- Cancelled: ['~'] (U+007E).} - {- Other: any other character, interpretation left to clients or - renderers (built-in ones equate it with done).}} - - {2:ext_tables Tables} - - According to {{:https://htmlpreview.github.io/?https://github.com/jgm/djot/blob/master/doc/syntax.html#pipe-table}djot}. - -{v -| # | Name | Description | Link | -|:-:|----------:|:----------------------|------------------------:| -| 1 | OCaml | The OCaml website | | -| 2 | Haskell | The Haskell website | | -| 3 | MDN | Web dev docs | | -| 4 | Wikipedia | The Free Encyclopedia | | -v} - - A table is a sequence of rows, each row starts and ends with a - (non-escaped) pipe [|] character. The first row can't be indented - by more than three spaces of indentation, subsequent rows can be - arbitrarily indented. Blanks after the final pipe are allowed. - - Each row of the table contains cells separated by (non-escaped) - pipe [|] characters. Pipes embedded in inlines constructs do not - count as separators (the parsing strategy is to parse the row as - an inline, split the result on the [|] present in {e toplevel} - text nodes and strip initial and trailing blanks in cells). The - number of [|] separators plus 1 determines the number of columns - of a row. The number of columns of a table is the greatest number - of columns of its rows. - - A separator line is a row in which every cell content is made only - of one or more [-] optionally prefixed and suffixed by [:]. These - rows are not data, they indicate alignment of data in their cell - for subsequent rows (multiple separator lines in a single table - are allowed) and that the previous line (if any) was a row of - column headers. [:-] is left aligned [-:] is right aligned, [:-:] - is centered. If there's no alignement specified it's left - aligned. - - Tables are stored in {!Block.extension-Ext_table} nodes. - - {2:ext_footnotes Footnotes} - - According to {{:https://htmlpreview.github.io/?https://github.com/jgm/djot/blob/master/doc/syntax.html#footnotes}djot} for the footnote contents. - -{v -This is a footnote in history[^1] with mutiple references[^1]. -Footnotes are not [very special][^1] references. - - [^1]: Footnotes can have -lazy continuation lines and multiple paragraphs. - - If you start one column after the left bracket, blocks still get - into the footnote. - - But this is no longer the footnote. -v} - - Footnotes go through the label resolution mecanism and share the - same namespace as link references (including the [^]). They end up - being defined in the {!Doc.defs} as {!Block.Footnote.Def} - definitions. Footnote references are simply made by using - {!Inline.extension-Link} with the corresponding labels. - - {3:ext_footnote_def Definition} - - A footnote definition starts with a (single line) - {{:https://spec.commonmark.org/0.30/#link-label}link label} - followed by [:]. The label must start with a [^]. Footnote labels - go through the label {{!Label.resolvers}resolution} mechanism. - - All subsequent lines indented one column further than the start of - the label (i.e. starting on the [^]) get into the footnote. Lazy - continuation lines are supported. - - The result is stored in the document's {!Doc.defs} in - {!Block.Footnote.Def} cases and it's position in the documentation - witnessed by a {!Block.extension-Ext_footnote_definition} node which - is kept for layout. - - {3:ext_footnote_ref References} - - Footnote references are simply reference links with the footnote - label. Linking text on footnotes is allowed. Shortcut and - collapsed references to footnotes are rendered specially by - {!Cmarkit_html}. *) - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_base.ml b/ocaml-lsp-server/vendor/cmarkit/cmarkit_base.ml deleted file mode 100644 index 81b79557d..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_base.ml +++ /dev/null @@ -1,1360 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(* N.B. The doc strings of the .mli can help understanding these internal - functions. *) - -let sub_includes ~affix s ~first ~last = - let get = String.get in - let len_a = String.length affix in - let len_s = last - first + 1 in - if len_a > len_s then false else - let max_idx_a = len_a - 1 in - let max_idx_s = first + (len_s - len_a) in - let rec loop i k = - if i > max_idx_s then false else - if k > max_idx_a then true else - if k > 0 - then if get affix k = get s (i + k) then loop i (k + 1) else loop (i + 1) 0 - else if get affix 0 = get s i then loop i 1 else loop (i + 1) 0 - in - loop first 0 - -let unsafe_get = String.unsafe_get - -module String_set = Set.Make (String) - -(* Heterogeneous dictionaries *) - -module Dict = struct - (* Type identifiers, can be deleted once we require 5.1 *) - module Type = struct - type (_, _) eq = Equal : ('a, 'a) eq - module Id = struct - type _ id = .. - module type ID = sig type t type _ id += Id : t id end - type 'a t = (module ID with type t = 'a) - - let make (type a) () : a t = - (module struct type t = a type _ id += Id : t id end) - - let provably_equal - (type a b) ((module A) : a t) ((module B) : b t) : (a, b) eq option - = - match A.Id with B.Id -> Some Equal | _ -> None - - let uid (type a) ((module A) : a t) = - Obj.Extension_constructor.id (Obj.Extension_constructor.of_val A.Id) - end - end - - module M = Map.Make (Int) - type 'a key = 'a Type.Id.t - type binding = B : 'a key * 'a -> binding - type t = binding M.t - - let key = Type.Id.make - let empty = M.empty - let mem k m = M.mem (Type.Id.uid k) m - let add k v m = M.add (Type.Id.uid k) (B (k, v)) m - let tag k m = add k () m - let remove k m = M.remove (Type.Id.uid k) m - let find : type a. a key -> t -> a option = - fun k m -> match M.find_opt (Type.Id.uid k) m with - | None -> None - | Some B (k', v) -> - match Type.Id.provably_equal k k' with - | None -> assert false | Some Type.Equal -> Some v -end - -(* Text locations *) - -module Textloc = struct - - (* File paths *) - - type fpath = string - let file_none = "-" - let pp_path = Format.pp_print_string - - (* Byte positions *) - - type byte_pos = int (* zero-based *) - let byte_pos_none = -1 - - (* Lines *) - - type line_num = int (* one-based *) - let line_num_none = -1 - - (* Line positions - - We keep the byte position of the first element on the line. This - first element may not exist and be equal to the text length if - the input ends with a newline. Editors expect tools to compute - visual columns (not a very good idea). By keeping these byte - positions we can approximate columns by subtracting the line byte - position data byte location. This will only be correct on - US-ASCII data. *) - - type line_pos = line_num * byte_pos - let line_pos_first = 1, 0 - let line_pos_none = line_num_none, byte_pos_none - - (* Text locations *) - - type t = - { file : fpath; - first_byte : byte_pos; last_byte : byte_pos; - first_line : line_pos; last_line : line_pos } - - let v ~file ~first_byte ~last_byte ~first_line ~last_line = - { file; first_byte; last_byte; first_line; last_line } - - let file l = l.file - let first_byte l = l.first_byte - let last_byte l = l.last_byte - let first_line l = l.first_line - let last_line l = l.last_line - let none = - let first_byte = byte_pos_none and last_byte = byte_pos_none in - let first_line = line_pos_none and last_line = line_pos_none in - v ~file:file_none ~first_byte ~last_byte ~first_line ~last_line - - (* Predicates and comparisons *) - - let is_none l = l.first_byte < 0 - let is_empty l = l.first_byte > l.last_byte - let equal l0 l1 = - String.equal l0.file l1.file && - Int.equal l0.first_byte l1.first_byte && - Int.equal l0.last_byte l1.last_byte - - let compare l0 l1 = - let c = String.compare l0.file l1.file in - if c <> 0 then c else - let c = Int.compare l0.first_byte l1.first_byte in - if c <> 0 then c else - Int.compare l0.last_byte l1.last_byte - - (* Shrink and stretch *) - - let set_first l ~first_byte ~first_line = { l with first_byte; first_line } - let set_last l ~last_byte ~last_line = { l with last_byte; last_line } - - [@@@warning "-6"] - let to_first l = v l.file l.first_byte l.first_byte l.first_line l.first_line - let to_last l = v l.file l.last_byte l.last_byte l.last_line l.last_line - let before l = v l.file l.first_byte byte_pos_none l.first_line line_pos_none - let after l = - v l.file (l.first_byte + 1) byte_pos_none l.last_line line_pos_none - [@@@warning "+6"] - - let span l0 l1 = - let first_byte, first_line = - if l0.first_byte < l1.first_byte - then l0.first_byte, l0.first_line - else l1.first_byte, l1.first_line - in - let last_byte, last_line, file = - if l0.last_byte < l1.last_byte - then l1.last_byte, l1.last_line, l1.file - else l0.last_byte, l0.last_line, l0.file - in - v ~file ~first_byte ~first_line ~last_byte ~last_line - - [@@@warning "-6"] - let reloc ~first ~last = - v last.file first.first_byte last.last_byte first.first_line last.last_line - [@@@warning "+6"] - - (* Formatters *) - - let pf = Format.fprintf - let pp_ocaml ppf l = match is_none l with - | true -> pf ppf "File \"%a\"" pp_path l.file - | false -> - let pp_lines ppf l = match fst l.first_line = fst l.last_line with - | true -> pf ppf "line %d" (fst l.first_line) - | false -> pf ppf "lines %d-%d" (fst l.first_line) (fst l.last_line) - in - (* "characters" represent positions (insertion points) not columns *) - let pos_s = l.first_byte - snd l.first_line in - let pos_e = l.last_byte - snd l.last_line + 1 in - if pos_s = 0 && pos_e = 0 - then pf ppf "File \"%a\", %a" pp_path l.file pp_lines l - else pf ppf "File \"%a\", %a, characters %d-%d" - pp_path l.file pp_lines l pos_s pos_e - - let pp_gnu ppf l = match is_none l with - | true -> pf ppf "%a:" pp_path l.file - | false -> - let pp_lines ppf l = - let col_s = l.first_byte - snd l.first_line + 1 in - let col_e = l.last_byte - snd l.last_line + 1 in - match fst l.first_line = fst l.last_line with - | true -> pf ppf "%d.%d-%d" (fst l.first_line) col_s col_e - | false -> - pf ppf "%d.%d-%d.%d" - (fst l.first_line) col_s (fst l.last_line) col_e - in - pf ppf "%a:%a" pp_path l.file pp_lines l - - let pp = pp_gnu - - let pp_dump ppf l = - pf ppf "file:%s bytes:%d-%d lines:%d-%d lines-bytes:%d-%d]" - l.file l.first_byte l.last_byte (fst l.first_line) (fst l.last_line) - (snd l.first_line) (snd l.last_line) -end - -type line_span = - { line_pos : Textloc.line_pos; - first : Textloc.byte_pos; - last : Textloc.byte_pos } - -type line_start = Textloc.byte_pos -type rev_spans = (line_start * line_span) list -type 'a next_line = 'a -> ('a * line_span) option - -(* Node meta data *) - -module Meta = struct - type id = int - type t = { textloc : Textloc.t; id : id; dict : Dict.t } - - let new_id = let id = Atomic.make 0 in fun () -> Atomic.fetch_and_add id 1 - let make ?(textloc = Textloc.none) () = - { textloc; id = new_id (); dict = Dict.empty } - - let none = make () - let id m = m.id - let textloc m = m.textloc - let with_textloc ~keep_id m textloc = match keep_id with - | true -> { m with textloc } - | false -> { m with textloc; id = new_id () } - - let equal m0 m1 = Int.equal m0.id m1.id - let compare m0 m1 = Int.compare m0.id m1.id - let is_none m = equal none m - - type 'a key = 'a Dict.key - let key = Dict.key - let mem k m = Dict.mem k m.dict - let add k v m = { m with dict = Dict.add k v m.dict } - let tag k m = add k () m - let remove k m = { m with dict = Dict.remove k m.dict } - let find k m = Dict.find k m.dict -end - -(* US-ASCII processing *) - -module Ascii = struct - let is_control = function '\x00' .. '\x1F' | '\x7F' -> true | _ -> false - let is_letter = function 'a' .. 'z' | 'A' .. 'Z' -> true | _ -> false - let is_upper = function 'A' .. 'Z' -> true | _ -> false - let is_lower = function 'a' .. 'z' -> true | _ -> false - let is_digit = function '0' .. '9' -> true | _ -> false - let is_hex_digit = function - | '0' .. '9' | 'A' .. 'F' | 'a' .. 'f' -> true | _ -> false - - let hex_digit_to_int = function - | '0' .. '9' as c -> Char.code c - 0x30 - | 'A' .. 'F' as c -> Char.code c - 0x37 - | 'a' .. 'f' as c -> Char.code c - 0x57 - | _ -> assert false - - let is_alphanum = function - | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' -> true | _ -> false - - let is_white = function - | '\x20' | '\x09' | '\x0A' | '\x0B' | '\x0C' | '\x0D' -> true | _ -> false - - let is_punct = function - (* https://spec.commonmark.org/current/#ascii-punctuation-character *) - | '!' | '\"' | '#' | '$' | '%' | '&' | '\'' | '(' | ')' | '*' | '+' - | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' - | '[' | '\\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~' -> true - | _ -> false - - let is_blank = function ' ' | '\t' -> true | _ -> false - - let caseless_starts_with ~prefix s = - let get = String.get in - let len_a = String.length prefix in - let len_s = String.length s in - if len_a > len_s then false else - let max_idx_a = len_a - 1 in - let rec loop s i max = - if i > max then true else - let c = match get s i with - | 'A' .. 'Z' as c -> Char.(unsafe_chr (code c + 32)) | c -> c - in - if get prefix i <> c then false else loop s (i + 1) max - in - loop s 0 max_idx_a - - let match' ~sub s ~start = - (* assert (start + String.length sub - 1 < String.length s) *) - try - for i = 0 to String.length sub - 1 - do if s.[start + i] <> sub.[i] then raise_notrace Exit done; true - with - | Exit -> false - - let caseless_match ~sub s ~start = - (* assert (start + String.length sub - 1 < String.length s) *) - try - for i = 0 to String.length sub - 1 do - let c = match s.[start + i] with - | 'A' .. 'Z' as c -> Char.(unsafe_chr (code c + 32)) | c -> c - in - if c <> sub.[i] then raise_notrace Exit - done; - true - with - | Exit -> false - - let lowercase_sub s first len = - let b = Bytes.create len in - for i = 0 to len - 1 do - let c = match s.[first + i] with - | 'A' .. 'Z' as c -> Char.(unsafe_chr (code c + 32)) | c -> c - in - Bytes.set b i c - done; - Bytes.unsafe_to_string b -end - -module Text = struct - let _utf_8_clean_unesc_unref ~do_unesc buf s ~first ~last = - (* This unescapes CommonMark escapes if [do_unesc] is true, - resolves entity and character references and replaces U+0000 or - UTF-8 decoding errors by U+FFFD *) - let get = String.get in - let flush buf s last start k = - if start <= last then Buffer.add_substring buf s start (k - start) - in - let rec try_entity_hex ~do_unesc buf s last start num_start k u = - (* https://spec.commonmark.org/current/\ - #hexadecimal-numeric-character-references *) - if k > last || k > num_start + 6 - then resolve ~do_unesc buf s last start k else - match get s k with - | ';' -> - let next = k + 1 in - if k = num_start then resolve ~do_unesc buf s last start next else - let u = - if Uchar.is_valid u && u <> 0 then Uchar.unsafe_of_int u else - Uchar.rep - in - flush buf s last start (num_start - 3 (* don't include &#(x|X) *)); - Buffer.add_utf_8_uchar buf u; - resolve ~do_unesc buf s last next next - | c when Ascii.is_hex_digit c -> - let u = u * 16 + (Ascii.hex_digit_to_int c) in - try_entity_hex ~do_unesc buf s last start num_start (k + 1) u - | _ -> - resolve ~do_unesc buf s last start k - and try_entity_dec ~do_unesc buf s last start num_start k u = - if k > last || k > num_start + 7 - then resolve ~do_unesc buf s last start k else - match get s k with - | ';' -> - let next = k + 1 in - if k = num_start then resolve ~do_unesc buf s last start next else - let u = - if Uchar.is_valid u && u <> 0 then Uchar.unsafe_of_int u else - Uchar.rep - in - flush buf s last start (num_start - 2 (* don't include &# *)); - Buffer.add_utf_8_uchar buf u; - resolve ~do_unesc buf s last next next - | c when Ascii.is_digit c -> - let u = u * 10 + (Char.code c - 0x30) in - try_entity_dec ~do_unesc buf s last start num_start (k + 1) u - | _ -> - resolve ~do_unesc buf s last start k - and try_entity_named ~do_unesc buf s last start name_start k = - (* https://spec.commonmark.org/current/\ - #entity-and-numeric-character-references *) - if k > last then resolve ~do_unesc buf s last start k else - match get s k with - | ';' -> - let name = String.sub s name_start (k - name_start) in - begin match Cmarkit_data.html_entity name with - | None -> resolve ~do_unesc buf s last start (k + 1) - | Some rep -> - let next = k + 1 in - flush buf s last start (name_start - 1 (* don't include & *)) ; - Buffer.add_string buf rep; - resolve ~do_unesc buf s last next next - end - | c when Ascii.is_alphanum c -> - try_entity_named ~do_unesc buf s last start name_start (k + 1) - | _ -> - resolve ~do_unesc buf s last start k - and resolve ~do_unesc buf s last start k = - if k > last then (flush buf s last start k; Buffer.contents buf) else - let next = k + 1 in - match get s k with - | '\x00' -> - flush buf s last start k; Buffer.add_utf_8_uchar buf Uchar.rep; - resolve ~do_unesc buf s last next next - | '\\' when do_unesc -> - if next > last then resolve ~do_unesc buf s last start next else - let nc = get s next in - if not (Ascii.is_punct nc) - then resolve ~do_unesc buf s last start next else - let next' = next + 1 in - (flush buf s last start k; Buffer.add_char buf nc; - resolve ~do_unesc buf s last next' next') - | '&' -> - if k + 2 > last then resolve ~do_unesc buf s last start next else - begin match get s next with - | c when Ascii.is_letter c -> - try_entity_named ~do_unesc buf s last start next next - | '#' -> - let next = next + 1 in - begin match get s next with - | c when Ascii.is_digit c -> - try_entity_dec ~do_unesc buf s last start next next 0 - | 'x' | 'X' -> - let next = next + 1 in - try_entity_hex ~do_unesc buf s last start next next 0 - | _ -> resolve ~do_unesc buf s last start next - end - | _ -> resolve ~do_unesc buf s last start next - end - | '\x01' .. '\x7F' -> resolve ~do_unesc buf s last start next - | b -> - let d = String.get_utf_8_uchar s k in - let next = k + Uchar.utf_decode_length d in - match Uchar.utf_decode_is_valid d with - | true -> resolve ~do_unesc buf s last start next - | false -> - flush buf s last start k; - Buffer.add_utf_8_uchar buf Uchar.rep; - resolve ~do_unesc buf s last next next - in - let rec check ~do_unesc buf s last start k = - if k > last then String.sub s first (last - start + 1) else - match unsafe_get s k with - | '\\' when do_unesc -> - Buffer.reset buf; resolve ~do_unesc buf s last start k - | '&' | '\x00' -> - Buffer.reset buf; resolve ~do_unesc buf s last start k - | '\x01' .. '\x7F' -> - check ~do_unesc buf s last start (k + 1) - | _ -> - let d = String.get_utf_8_uchar s k in - if Uchar.utf_decode_is_valid d - then check ~do_unesc buf s last start (k + Uchar.utf_decode_length d) - else (Buffer.reset buf; resolve ~do_unesc buf s last start k) - in - if first > last then "" else - let max = String.length s - 1 in - let last = if last > max then max else last in - let first = if first < 0 then 0 else first in - check ~do_unesc buf s last first first - - let utf_8_clean_unesc_unref buf s ~first ~last = - _utf_8_clean_unesc_unref ~do_unesc:true buf s ~first ~last - - let utf_8_clean_unref buf s ~first ~last = - _utf_8_clean_unesc_unref ~do_unesc:false buf s ~first ~last - - let utf_8_clean_raw ?(pad = 0) buf s ~first ~last = - let get = String.get in - let padit buf pad = for i = 1 to pad do Buffer.add_char buf ' ' done in - let clean buf s last first dirty = - let flush buf s last start k = - if start <= last then Buffer.add_substring buf s start (k - start); - in - let rec loop buf s last start k = - if k > last then (flush buf s last start k; Buffer.contents buf) else - match get s k with - | '\x01' .. '\x7F' (* US-ASCII *) -> loop buf s last start (k + 1) - | '\x00' -> - let next = k + 1 in - flush buf s last start k; Buffer.add_utf_8_uchar buf Uchar.rep; - loop buf s last next next - | _ -> - let d = String.get_utf_8_uchar s k in - let next = k + Uchar.utf_decode_length d in - match Uchar.utf_decode_is_valid d with - | true -> loop buf s last start next - | false -> - flush buf s last start k; Buffer.add_utf_8_uchar buf Uchar.rep; - loop buf s last next next - in - flush buf s last first dirty; loop buf s last dirty dirty - in - let rec check buf s last first k = - if k > last then String.sub s first (last - first + 1) else - match get s k with - | '\x01' .. '\x7F' (* US-ASCII *) -> check buf s last first (k + 1) - | '\x00' -> (Buffer.reset buf; clean buf s last first k) - | _ -> - let d = String.get_utf_8_uchar s k in - if Uchar.utf_decode_is_valid d - then check buf s last first (k + Uchar.utf_decode_length d) - else (Buffer.reset buf; clean buf s last first k) - in - if first > last then - if pad = 0 then "" else - (Buffer.reset buf; padit buf pad; Buffer.contents buf) - else - let max = String.length s - 1 in - let last = if last > max then max else last in - let first = if first < 0 then 0 else first in - if pad = 0 then check buf s last first first else - (Buffer.reset buf; padit buf pad; clean buf s last first first) -end - -(* Unicode matching *) - -let prev_uchar s ~first ~before = - let rec find_utf_8_starter s ~first ~start = - if start < first then first else match s.[start] with - | '\x00' .. '\x7F' | '\xC2' .. '\xDF' - | '\xE0' .. '\xEF' | '\xF0' .. '\xF4' -> start - | _ -> find_utf_8_starter s ~first ~start:(start - 1) - in - if before <= first then Uchar.of_int 0x0020 (* something white *) else - let k = find_utf_8_starter s ~first ~start:(before - 1) in - Uchar.utf_decode_uchar (String.get_utf_8_uchar s k) - -let next_uchar s ~last ~after = - if after >= last then Uchar.of_int 0x0020 (* something white *) else - Uchar.utf_decode_uchar (String.get_utf_8_uchar s (after + 1)) - -(* Result types *) - -type indent = int -type byte_pos = Textloc.byte_pos -type first = Textloc.byte_pos -type last = Textloc.byte_pos -type next = Textloc.byte_pos -type heading_level = int - -(* Runs, blanks and indents *) - -let rec run_of ~char s ~last ~start = - if start > last || s.[start] <> char then start - 1 else - run_of ~char s ~last ~start:(start + 1) - -let rec first_non_blank s ~last ~start = - if start > last then last + 1 else match s.[start] with - | ' ' | '\t' -> first_non_blank s ~last ~start:(start + 1) - | _ -> start - -let first_non_blank_in_span s sp = - first_non_blank s ~last:sp.last ~start:sp.first - -let rec last_non_blank s ~first ~start = - if start < first then first - 1 else match s.[start] with - | ' ' | '\t' -> last_non_blank s ~first ~start:(start - 1) - | _ -> start - -let rec rev_drop_spaces s ~first ~start = - if start < first then first - 1 else - if s.[start] = ' ' then rev_drop_spaces s ~first ~start:(start - 1) else start - -let push_span ~line first' last' = function -| (line_start, { line_pos; first; last }) :: acc - when (fst line_pos) = (fst line.line_pos) -> (* Merge if on same line *) - (line_start, { line with first; last = last' }) :: acc -| acc -> - (line.first, { line with first = first'; last = last' }) :: acc - -let accept_to ~char ~next_line s lines ~line spans ~after = - (* Includes final [char] in spans *) - let rec loop ~char ~next_line s lines line start acc k = - if k > line.last then match next_line lines with - | None -> None - | Some (lines, newline) -> - let acc = push_span ~line start line.last acc in - let start = first_non_blank_in_span s newline in - loop ~char ~next_line s lines newline start acc start - else - if s.[k] = char - then Some (lines, line, push_span ~line start k acc, k) - else loop ~char ~next_line s lines line start acc (k + 1) - in - loop ~char ~next_line s lines line after spans (after + 1) - -let accept_upto ~char ~next_line s lines ~line acc ~after = - (* Does not not include final [char] in spans and continues on - backslashed [char]. *) - let rec loop ~char ~next_line s lines line ~prev_bslash start acc k = - if k > line.last then match next_line lines with - | None -> None - | Some (lines, newline) -> - if newline.first > newline.last (* empty *) then None else - let acc = push_span ~line start line.last acc in - let start = first_non_blank_in_span s newline in - let prev_bslash = false in - loop ~char ~next_line s lines newline ~prev_bslash start acc start - else - if s.[k] = char && not prev_bslash - then Some (lines, line, push_span ~line start (k - 1) acc, k) else - let prev_bslash = s.[k] = '\\' && not prev_bslash (* \\ is not *) in - loop ~char ~next_line s lines line ~prev_bslash start acc (k + 1) - in - let start = after + 1 in - loop ~char ~next_line s lines line ~prev_bslash:false start acc start - -let first_non_blank_over_nl ~next_line s lines ~line ~start = - let nb = first_non_blank s ~last:line.last ~start in - if nb <= line.last then `This_line nb else - match next_line lines with - | None -> `None - | Some (lines, newline) -> - let nb = first_non_blank_in_span s newline in - if nb > newline.last then `None else `Next_line (lines, newline, nb) - -let first_non_blank_over_nl' ~next_line s lines ~line spans ~start = - (* Same as [first_non_blank_over_nl] but pushes skipped data on [spans]. *) - match first_non_blank_over_nl ~next_line s lines ~line ~start with - | `None -> None - | `This_line nb -> - let line = { line with first = start } (* no layout *) in - let spans = push_span ~line start (nb - 1) spans in - Some (lines, line, spans, nb - 1) - | `Next_line (lines, newline, nb) -> - let line = { line with first = start } (* no layout *) in - let spans = push_span ~line start line.last spans in - Some (lines, newline, spans, nb - 1) - -let first_non_escaped_char c s ~last ~start = - let rec loop c s ~last ~start k = - if k > last then k else - if s.[k] = c && (k = start || s.[k - 1] <> '\\') then k else - loop c s ~last ~start (k + 1) - in - loop c s ~last ~start start - -(* Autolinks *) - -let autolink_email s ~last ~start = - (* https://spec.commonmark.org/current/#email-address - Via the ABNF "<" email ">" with email defined by: - https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address *) - let is_atext_plus_dot = function - | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' - | '!' | '#' | '$' | '%' | '&' | '\'' | '*' | '+' | '-' | '/' | '=' | '?' - | '^' | '_' | '`' | '{' | '|' | '}' | '~' | '.' -> true - | _ -> false - in - let is_let_dig = Ascii.is_alphanum in - let is_let_dig_hyp c = Ascii.is_alphanum c || c = '-' in - let rec label_seq s last k = - let rec loop s last c k = - if k > last then None else - if is_let_dig_hyp s.[k] && c <= 63 then loop s last (c + 1) (k + 1) else - if c > 63 || not (is_let_dig s.[k - 1]) then None else - match s.[k] with - | '>' -> Some k - | '.' -> label_seq s last (k + 1) - | c -> None - in - if k > last || not (is_let_dig s.[k]) then None else - loop s last 1 (k + 1) - in - let rec atext_seq s last k = - if k > last then None else - if is_atext_plus_dot s.[k] then atext_seq s last (k + 1) else - if s.[k] = '@' && is_atext_plus_dot s.[k - 1] - then label_seq s last (k + 1) - else None - in - if start > last || s.[start] <> '<' then None else - atext_seq s last (start + 1) - -let autolink_uri s ~last ~start = - (* https://spec.commonmark.org/current/#uri-autolink *) - let is_scheme_letter = function - | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '+' | '.' | '-' -> true | _ -> false - in - let is_uri_char = function - |'\x00' .. '\x1F' | '\x7F' | ' ' | '<' | '>' -> false | _ -> true - in - let rec rest s last k = - if k > last then None else - if is_uri_char s.[k] then rest s last (k + 1) else - if s.[k] = '>' then Some k else None - in - let rec scheme s last c k = - if k > last then None else - if is_scheme_letter s.[k] && c <= 32 then scheme s last (c + 1) (k + 1) else - if s.[k] = ':' && 2 <= c && c <= 32 then rest s last (k + 1) else None - in - let next = start + 1 in - if next > last || s.[start] <> '<' || not (Ascii.is_letter s.[next]) - then None else scheme s last 1 (next + 1) - -(* Raw HTML *) - -let tag_name s ~last ~start : last option = - (* https://spec.commonmark.org/current/#tag-name *) - let rec loop s last k = - if k > last || not (Ascii.is_alphanum s.[k] || s.[k] = '-') - then Some (k - 1) else loop s last (k + 1) - in - if start > last || not (Ascii.is_letter s.[start]) then None else - loop s last (start + 1) - -let attribute_name s ~last ~start : next option = - (* https://spec.commonmark.org/current/#attribute-name *) - let is_start = function - | c when Ascii.is_letter c -> true | '_' | ':' -> true | _ -> false - in - let is_cont = function - | c when Ascii.is_alphanum c -> true | '_' | '.' | ':' | '-' -> true - | _ -> false - in - let rec loop s last k = - if k > last || not (is_cont s.[k]) - then Some (k - 1) else loop s last (k + 1) - in - if start > last || not (is_start s.[start]) then None else - loop s last (start + 1) - -let attribute_value ~next_line s lines ~line spans ~start = - (* https://spec.commonmark.org/current/#attribute-value *) - if start > line.last then None else match s.[start] with - | '\'' | '\"' as char -> - (* https://spec.commonmark.org/current/#double-quoted-attribute-value - https://spec.commonmark.org/current/#unquoted-attribute-value *) - accept_to ~char ~next_line s lines ~line spans ~after:start - | c -> - (* https://spec.commonmark.org/current/#unquoted-attribute-value *) - let cont = function - | ' ' | '\t' | '\"' | '\'' | '=' | '<' | '>' | '`' -> false | _ -> true - in - let rec loop s last k = - if k > last || not (cont s.[k]) then - let last = k - 1 in - Some (lines, line, push_span ~line start last spans, last) - else loop s last (k + 1) - in - loop s line.last (start + 1) - -let attribute ~next_line s lines ~line spans ~start = - (* https://spec.commonmark.org/current/#attribute *) - (* https://spec.commonmark.org/current/#attribute-value-specification *) - match attribute_name s ~last:line.last ~start with - | None -> None - | Some end_name -> - let spans = push_span ~line start end_name spans in - let start = end_name + 1 in - match first_non_blank_over_nl' ~next_line s lines ~line spans ~start with - | None -> None - | Some (lines', line', spans', last_blank) -> - let nb = last_blank + 1 in - if s.[nb] <> '=' - then Some (lines, line, spans, end_name) (* no value *) else - let spans' = push_span ~line nb nb spans' in - let start = nb + 1 in - match - first_non_blank_over_nl' - ~next_line s lines' ~line:line' spans' ~start - with - | None -> None - | Some (lines, line, spans, last_blank) -> - let start = last_blank + 1 in - attribute_value ~next_line s lines ~line spans ~start - -let open_tag ~next_line s lines ~line ~start:tag_start = (* tag_start has < *) - (* https://spec.commonmark.org/current/#open-tag *) - match tag_name s ~last:line.last ~start:(tag_start + 1) with - | None -> None - | Some tag_end_name -> - let rec loop ~next_line s lines ~line spans ~start = - match - first_non_blank_over_nl' ~next_line s lines ~line spans ~start - with - | None -> None - | Some (lines, line, spans, last_blank) -> - let next = last_blank + 1 in - match s.[next] with - | '>' -> - Some (lines, line, push_span ~line next next spans, next) - | '/' -> - let last = next + 1 in - if last > line.last || s.[last] <> '>' then None else - Some (lines, line, push_span ~line next last spans, last) - | c -> - if next = start then None else - match attribute ~next_line s lines ~line spans ~start:next with - | None -> None - | Some (lines, line, spans, last) -> - loop ~next_line s lines ~line spans ~start:(last + 1) - in - let start = tag_end_name + 1 in - let span = { line with first = tag_start; last = tag_end_name} in - let spans = [tag_start, span] in - loop ~next_line s lines ~line spans ~start - -let closing_tag ~next_line s ls ~line ~start:tag_start = (* start is on None - | Some tag_name_end -> - let span = { line with first = tag_start; last = tag_name_end} in - let spans = [tag_start, span] in - let start = tag_name_end + 1 in - match first_non_blank_over_nl' ~next_line s ls ~line spans ~start with - | None -> None - | Some (lines, line, spans, last_blank) -> - let last = last_blank + 1 in - if s.[last] <> '>' then None else - Some (lines, line, push_span ~line last last spans, last) - -let declaration ~next_line s lines ~line ~start = (* start is on ' ~next_line s lines ~line [] ~after:start - -let processing_instruction ~next_line s lines ~line ~start = (* start is on line.last then match next_line lines with - | None -> None - | Some (lines, newline) -> - let acc = push_span ~line start line.last acc in - let start = first_non_blank_in_span s newline in - loop ~next_line s lines newline start acc start - else - if s.[k] <> '?' then loop ~next_line s lines line start acc (k + 1) else - let last = k + 1 in - if last <= line.last && s.[last] = '>' (* ?> *) - then Some (lines, line, push_span ~line start last acc, last) - else loop ~next_line s lines line start acc last - in - loop ~next_line s lines line start [] (start + 2) - -let html_comment ~next_line s lines ~line ~start = (* start is on line.last then match next_line lines with - | None -> None - | Some (lines, newline) -> - let acc = push_span ~line start line.last acc in - let start = first_non_blank_in_span s newline in - loop ~next_line s lines newline start acc start - else - if s.[k] = '-' && s.[k - 1] <> '-' then - let last = k + 2 in - if last <= line.last && s.[k + 1] = '-' then - if s.[last] = '>' (* --> and we do not end with - *) - then Some (lines, line, push_span ~line start last acc, last) - else None (* -- in the input *) - else loop ~next_line s lines line start acc (k + 1) - else loop ~next_line s lines line start acc (k + 1) - in - (* Check we have at least or *) - if (start + 3 > line.last) || not (s.[start + 3] = '-') || - (start + 4 <= line.last && s.[start + 4] = '>') || - (start + 5 <= line.last && s.[start + 4] = '-' && s.[start + 5] = '>') - then None else loop ~next_line s lines line start [] (start + 4) - -let cdata_section ~next_line s lines ~line ~start = (* start is on line.last then match next_line lines with - | None -> None - | Some (lines, newline) -> - let acc = push_span ~line start line.last acc in - let start = first_non_blank_in_span s newline in - loop ~next_line s lines newline start acc start - else - if s.[k] <> ']' then loop ~next_line s lines line start acc (k + 1) else - let last = k + 2 in - if last <= line.last && s.[k + 1] = ']' && s.[last] = '>' (* ]> *) - then Some (lines, line, push_span ~line start last acc, last) - else loop ~next_line s lines line start acc (k + 1) - in - if start + 8 > line.last || (* not CDATA[ *) - not (s.[start + 3] = 'C' && s.[start + 4] = 'D' && s.[start + 5] = 'A' && - s.[start + 6] = 'T' && s.[start + 7] = 'A' && s.[start + 8] = '[') - then None else loop ~next_line s lines line start [] (start + 9) - -let raw_html ~next_line s lines ~line ~start = - (* https://spec.commonmark.org/current/#html-tag *) - let next = start + 1 and last = line.last in - if next > last || s.[start] <> '<' then None else match s.[next] with - | '/' -> closing_tag ~next_line s lines ~line ~start - | '?' -> processing_instruction ~next_line s lines ~line ~start - | '!' -> - let next = next + 1 in - if next > last then None else - begin match s.[next] with - | '-' -> html_comment ~next_line s lines ~line ~start - | '[' -> cdata_section ~next_line s lines ~line ~start - | c when Ascii.is_letter c -> declaration ~next_line s lines ~line ~start - | _ -> None - end - | c -> open_tag ~next_line s lines ~line ~start - -(* Links *) - -let link_destination s ~last ~start = - let delimited s ~last ~start = (* start has '<' *) - (* https://spec.commonmark.org/current/#link-destination 1st *) - let rec loop s start last prev_byte k = - if k > last then None else match s.[k] with - | '\n' | '\r' -> None - | '\\' when prev_byte = '\\' -> loop s start last '\x00' (k + 1) - | '<' when prev_byte <> '\\' -> None - | '>' when prev_byte <> '\\' -> Some (true, (start + 1), k - 1) - | c -> loop s start last c (k + 1) - in - loop s start last '\x00' (start + 1) - in - let not_delimited s ~last ~start = - (* https://spec.commonmark.org/current/#link-destination 2nd *) - let rec loop s start last prev_byte bal k = - if k > last then (if bal = 0 then Some (false, start, k - 1) else None) - else match s.[k] with - | '\\' when prev_byte = '\\' -> loop s start last '\x00' bal (k + 1) - | '(' as c when prev_byte <> '\\' -> loop s start last c (bal + 1) (k + 1) - | ')' as c when prev_byte <> '\\' -> - let bal = bal - 1 in - if bal < 0 - then Some (false, start, k - 1) (* hit inline link closing ')' *) - else loop s start last c bal (k + 1) - | ' ' -> if k <> start && bal = 0 then Some (false, start, k-1) else None - | c when Ascii.is_control c -> - if k <> start && bal = 0 then Some (false, start, k - 1) else None - | c -> loop s start last c bal (k + 1) - in - loop s start last '\x00' 0 start - in - if start > last then None else - if s.[start] = '<' - then delimited s ~last ~start - else not_delimited s ~last ~start - -let link_title ~next_line s lines ~line ~start = - (* https://spec.commonmark.org/current/#link-title *) - let rec paren ~next_line s lines ~line ~prev_bslash start acc k = - if k > line.last then match next_line lines with - | None -> None - | Some (lines, newline) -> - if newline.first > newline.last (* empty *) then None else - let acc = push_span ~line start line.last acc in - let start = first_non_blank_in_span s newline in - let prev_bslash = false in - paren ~next_line s lines ~line:newline ~prev_bslash start acc start - else - if s.[k] = '(' && not prev_bslash then None else - if s.[k] = ')' && not prev_bslash - then Some (lines, line, push_span ~line start (k - 1) acc, k) else - let prev_bslash = s.[k] = '\\' && not prev_bslash in - paren ~next_line s lines ~line ~prev_bslash start acc (k + 1) - in - if start > line.last then None else match s.[start] with - | '\"' | '\'' as char -> - accept_upto ~char ~next_line s lines ~line [] ~after:start - | '(' -> - let start = start + 1 and prev_bslash = false in - paren ~next_line s lines ~line ~prev_bslash start [] start - | _ -> None - -let link_label b ~next_line s lines ~line ~start = - (* https://spec.commonmark.org/current/#link-label *) - let rec loop b ~next_line s lines ~line ~prev_byte start acc count k = - if k > line.last then match next_line lines with - | None -> None - | Some (lines, newline) -> - if newline.first > newline.last (* empty *) then None else - let acc = push_span ~line start line.last acc in - let start = first_non_blank_in_span s newline in - let () = if Buffer.length b <> 0 then Buffer.add_char b ' ' in - let prev_byte = '\x00' in - loop b ~next_line s lines ~line:newline ~prev_byte start acc count start - else - if count > 999 then None else match s.[k] with - | '\\' when prev_byte = '\\' -> - Buffer.add_char b '\\'; - let prev_byte = '\x00' in - loop b ~next_line s lines ~line ~prev_byte start acc (count + 1) (k + 1) - | ']' when prev_byte <> '\\' -> - let key = Buffer.contents b in - if String.for_all Ascii.is_blank key then None else - let acc = push_span ~line start (k - 1) acc in - Some (lines, line, acc, k, key) - | '[' when prev_byte <> '\\' -> None - | ' ' | '\t' as prev_byte -> - loop b ~next_line s lines ~line ~prev_byte start acc (count + 1) (k + 1) - | c -> - let () = - (* Collapses non initial white *) - if Ascii.is_blank prev_byte && Buffer.length b <> 0 - then Buffer.add_char b ' ' - in - let d = String.get_utf_8_uchar s k in - let u = Uchar.utf_decode_uchar d in - let u = match Uchar.to_int u with 0x0000 -> Uchar.rep | _ -> u in - let k' = k + Uchar.utf_decode_length d in - let () = match Cmarkit_data.unicode_case_fold u with - | None -> Buffer.add_utf_8_uchar b u - | Some fold -> Buffer.add_string b fold - in - let prev_byte = s.[k] in - loop b ~next_line s lines ~line ~prev_byte start acc (count + 1) k' - in - if start > line.last || s.[start] <> '[' then None else - let start = start + 1 in - (Buffer.reset b; - loop b ~next_line s lines ~line ~prev_byte:'\x00' start [] 0 start) - -(* Leaf blocks - - The matching functions assume the indentation has been stripped. *) - -type html_block_end_cond = - [ `End_str of string | `End_cond_1 | `End_blank | `End_blank_7 ] - -type line_type = -| Atx_heading_line of heading_level * byte_pos * first * last -| Blank_line -| Block_quote_line -| Fenced_code_block_line of first * last * (first * last) option -| Html_block_line of html_block_end_cond -| Indented_code_block_line -| List_marker_line of ([ `Ordered of int * char | `Unordered of char ] * last) -| Paragraph_line -| Setext_underline_line of heading_level * last -| Thematic_break_line of last -| Ext_table_row of last -| Ext_footnote_label of rev_spans * last * string -| Nomatch - -let thematic_break s ~last ~start = - (* https://spec.commonmark.org/current/#thematic-breaks *) - let rec loop s last count prev k = - if k > last - then (if count < 3 then Nomatch else Thematic_break_line prev) else - if s.[k] = s.[prev] then loop s last (count + 1) k (k + 1) else - if s.[k] = ' ' || s.[k] = '\t' then loop s last count prev (k + 1) else - Nomatch - in - if start > last then Nomatch else match s.[start] with - | '-' | '_' | '*' -> loop s last 1 start (start + 1) - | _ -> Nomatch - -let atx_heading s ~last ~start = - (* https://spec.commonmark.org/current/#atx-headings *) - let rec skip_hashes s last k = - if k > last then k else - if s.[k] = '#' then skip_hashes s last (k + 1) else k - in - let find_end s last k = (* blank on k, last + 1 if blank* [#+] blank* *) - let after_blank = first_non_blank s ~last ~start:(k + 1) in - if after_blank > last then after_blank else - if s.[after_blank] <> '#' then after_blank else - let after_hash = skip_hashes s last (after_blank + 1) in - let after_blank = first_non_blank s ~last ~start:after_hash in - if after_blank > last || after_blank = after_hash then after_blank else - after_blank - 1 (* this could be the beginning of the end, trigger again *) - in - let rec content s last k = - if k > last then k - 1 else - if not (s.[k] = ' ' || s.[k] = '\t') then content s last (k + 1) else - let end' = find_end s last k in - if end' > last then (k - 1) else content s last end' - in - let rec level s last acc k = - if k > last then Atx_heading_line (acc, k, k, last) else - if s.[k] = '#' then - if acc < 6 then level s last (acc + 1) (k + 1) else Nomatch - else - let first = first_non_blank s ~last ~start:k in - if first > last - then Atx_heading_line (acc, k, last + 1, last) (* empty cases *) else - if first = k then Nomatch (* need a blank *) else - let last = - if s.[first] <> '#' then content s last (first + 1) else - let end' = find_end s last (first - 1 (* start on blank *)) in - if end' > last then first - 1 else content s last end' - in - Atx_heading_line (acc, k, first, last) - in - if start > last || s.[start] <> '#' then Nomatch else - level s last 1 (start + 1) - -let setext_heading_underline s ~last ~start = - (* https://spec.commonmark.org/current/#setext-heading *) - let level c = if c = '=' then 1 else 2 in - let rec underline s last start k = - if k > last then Setext_underline_line (level s.[start], k - 1) else - if s.[k] = s.[start] then underline s last start (k + 1) else - if not (s.[k] = ' ' || s.[k] = '\t') then Nomatch else - let end_blank = first_non_blank s ~last ~start:(k + 1) in - if end_blank > last - then Setext_underline_line (level s.[start], k - 1) - else Nomatch - in - if start > last then Nomatch else - if not (s.[start] = '-' || s.[start] = '=') then Nomatch else - underline s last start (start + 1) - -let fenced_code_block_start s ~last ~start = - (* https://spec.commonmark.org/current/#code-fence *) - let rec info s last nobt info_first k = - if k > last then Some (info_first, last) else - if nobt && s.[k] = '`' then raise_notrace Exit else - if not (s.[k] = ' ' || s.[k] = '\t') - then info s last nobt info_first (k + 1) else - let after_blank = first_non_blank s ~last ~start:k in - if after_blank > last then Some (info_first, k - 1) else - info s last nobt info_first after_blank - in - let rec fence s last fence_first k = - if k <= last && s.[k] = s.[fence_first] - then fence s last fence_first (k + 1) else - let fence_last = k - 1 in - let fcount = fence_last - fence_first + 1 in - if fcount < 3 then Nomatch else - let info = - let after_blank = first_non_blank s ~last ~start:k in - if after_blank > last then None else - info s last (s.[fence_first] = '`') after_blank after_blank - in - Fenced_code_block_line (fence_first, fence_last, info) - in - let rec loop s first last k = - if k > last then Nomatch else - if k - first + 1 < 4 && s.[k] = ' ' then loop s first last (k + 1) else - if not (s.[k] = '~' || s.[k] = '`') then Nomatch else - try fence s last k (k + 1) with - | Exit (* backtick fence and info *) -> Nomatch - in - if start > last then Nomatch else loop s start last start - -let fenced_code_block_continue ~fence:(fc, fcount) s ~last ~start = - (* https://spec.commonmark.org/current/#code-fence *) - let rec fence s last fence_first k = - if k <= last && s.[k] = fc then fence s last fence_first (k + 1) else - let fence_last = k - 1 in - if fence_last - fence_first + 1 < fcount then raise Exit (* not closing *) - else - let after_blank = first_non_blank s ~last ~start:k in - if after_blank > last then `Close (fence_first, fence_last) else - raise Exit - in - let rec loop s first last k = - if k > last then `Code (* short blank line *) else - if k - first + 1 < 4 && s.[k] = ' ' then loop s first last (k + 1) else - if s.[k] <> fc then `Code else - try fence s last k (k + 1) with Exit -> `Code - in - if start > last then `Code else loop s start last start - -let html_start_cond_1_set = - String_set.of_list ["pre"; "script"; "style"; "textarea"] - -let html_start_cond_6_set = - String_set.of_list - [ "address"; "article"; "aside"; "base"; "basefont"; "blockquote"; "body"; - "caption"; "center"; "col"; "colgroup"; "dd"; "details"; "dialog"; "dir"; - "div"; "dl"; "dt"; "fieldset"; "figcaption"; "figure"; "footer"; "form"; - "frame"; "frameset"; "h1"; "h2"; "h3"; "h4"; "h5"; "h6"; "head"; "header"; - "hr"; "html"; "iframe"; "legend"; "li"; "link"; "main"; "menu"; - "menuitem"; "nav"; "noframes"; "ol"; "optgroup"; "option"; "p"; "param"; - "section"; "source"; "summary"; "table"; "tbody"; "td"; "tfoot"; "th"; - "thead"; "title"; "tr"; "track"; "ul" ] - -let html_block_start_5 s ~last ~start = (* 3 first chars checked *) - let next = start + 3 and sub = "CDATA[" in - if start + 8 > last || not (Ascii.match' ~sub s ~start:next) then Nomatch else - Html_block_line (`End_str "]]>") (* 5 *) - -let html_block_start_2 s ~last ~start = (* 3 first chars checked *) - let next = start + 3 in - if next > last || s.[next] <> '-' then Nomatch else - Html_block_line (`End_str "-->") (* 2 *) - -let html_block_start_7_open_tag s ~last ~start = - (* Has to be on the same line we fake one and use the inline parser *) - let line = { line_pos = Textloc.line_pos_none; first = start; last } in - let next_line () = None in - match open_tag ~next_line s () ~line ~start with - | None -> Nomatch - | Some (_, _, _, tag_end) -> - let next = first_non_blank s ~last ~start:(tag_end + 1) in - if next > last then Html_block_line `End_blank_7 else Nomatch - -let html_block_start_7_close_tag s ~last ~start = - (* Has to be on the same line we fake one and use the inline parser *) - let line = { line_pos = Textloc.line_pos_none; first = start; last } in - let next_line () = None in - match closing_tag ~next_line s () ~line ~start with - | None -> Nomatch - | Some (_, _, _, tag_end) -> - let next = first_non_blank s ~last ~start:(tag_end + 1) in - if next > last then Html_block_line `End_blank_7 else Nomatch - -let html_block_start s ~last ~start = - (* https://spec.commonmark.org/current/#html-blocks *) - let next = start + 1 in - if next > last || s.[start] <> '<' then Nomatch else - match s.[next] with - | '?' -> Html_block_line (`End_str "?>") (* 3 *) - | '!' -> - let next = next + 1 in - if next > last then Nomatch else - begin match s.[next] with - | '[' -> html_block_start_5 s ~last ~start - | '-' -> html_block_start_2 s ~last ~start - | c when Ascii.is_letter c -> Html_block_line (`End_str ">") (* 4 *) - | _ -> Nomatch - end - | c when Ascii.is_letter c || c = '/' -> - let tag_first = if c = '/' then next + 1 else next in - let tag_last = - let rec find_tag_end s last i = - if i > last || not (Ascii.is_letter s.[i]) then i - 1 else - find_tag_end s last (i + 1) - in - find_tag_end s last tag_first - in - let tag = Ascii.lowercase_sub s tag_first (tag_last - tag_first + 1) in - let is_open_end = - let n = tag_last + 1 in - n > last || s.[n] = ' ' || s.[n] = '\t' || s.[n] = '>' - in - let is_open_close_end = - is_open_end || - (tag_last + 2 <= last && s.[tag_last + 1] = '/' && - s.[tag_last + 2] = '>') - in - if c <> '/' then begin - if String_set.mem tag html_start_cond_1_set && is_open_end - then Html_block_line `End_cond_1 (* 1 *) else - if String_set.mem tag html_start_cond_6_set && is_open_close_end - then Html_block_line `End_blank (* 6 *) else - html_block_start_7_open_tag s ~last ~start - end else begin - if String_set.mem tag html_start_cond_6_set && is_open_close_end - then Html_block_line `End_blank (* 6 *) else - html_block_start_7_close_tag s ~last ~start - end - | _ -> Nomatch - -let html_block_end_cond_1 s ~last ~start = - (* https://spec.commonmark.org/current/#html-blocks end condition 1. *) - let rec loop s last k = - if k + 3 > last then false else - if s.[k] <> '<' || s.[k + 1] <> '/' then loop s last (k + 1) else - let next = k + 2 in - let is_end_tag = match s.[next] with - | 'p' -> Ascii.caseless_match ~sub:"pre>" s ~start:next - | 's' -> - if s.[k + 3] = 't' - then Ascii.caseless_match ~sub:"style>" s ~start:next - else Ascii.caseless_match ~sub:"script>" s ~start:next - | 't' -> Ascii.caseless_match ~sub:"textarea>" s ~start:next - | _ -> false - in - if is_end_tag then true else loop s last (k + 1) - in - loop s last start - -let html_block_end ~end_cond s ~last ~start = match end_cond with -| `End_str str -> sub_includes ~affix:str s ~first:start ~last -| `End_cond_1 -> html_block_end_cond_1 s ~last ~start -| `End_blank | `End_blank_7 -> first_non_blank s ~last ~start = last + 1 - -let ext_table_row s ~last ~start = - if start > last || s.[start] <> '|' then Nomatch else - let first = start + 1 in - let last_nb = last_non_blank s ~first ~start:last in - let before = last_nb - 1 in - if last_nb < first || s.[last_nb] <> '|' || - (before >= first && s.[before] = '\\') - then Nomatch else Ext_table_row last_nb - -let ext_footnote_label buf s ~line_pos ~last ~start = - if start + 1 > last || s.[start] <> '[' || s.[start + 1] <> '^' - then Nomatch else - let rbrack = first_non_escaped_char ']' s ~last ~start:(start + 2) in - let colon = rbrack + 1 in - if colon > last || s.[colon] <> ':' || colon - start + 1 < 5 then Nomatch else - (* Get the normalized label *) - let line = { line_pos; first = start; last } in - let next_line () = None in - match link_label buf ~next_line s () ~line ~start with - | None -> (* should not happen *) Nomatch - | Some (_, _, rev_spans, _, key) -> - Ext_footnote_label (rev_spans, colon, key) - -let could_be_link_reference_definition s ~last ~start = - (* https://spec.commonmark.org/current/#link-reference-definition *) - let rec loop s first last k = - if k > last then false else - if k - first + 1 < 4 && s.[k] = ' ' then loop s first last (k + 1) else - s.[k] = '[' - in - if start > last then false else loop s start last start - -(* Container blocks *) - -let list_marker s ~last ~start = - (* https://spec.commonmark.org/current/#list-marker *) - if start > last then Nomatch else match s.[start] with - | '-' | '+' | '*' as c -> - let next = start + 1 in - if next > last || Ascii.is_blank s.[next] - then List_marker_line (`Unordered c, start) - else Nomatch - | '0' .. '9' as c -> - let[@inline] digit c = Char.code c - 0x30 in - let rec loop s last count acc k = - if k > last || count > 9 then Nomatch else - match s.[k] with - | '0' .. '9' as c -> - loop s last (count + 1) (acc * 10 + digit c) (k + 1) - | '.' | ')' as c -> - let next = k + 1 in - if next > last || Ascii.is_blank s.[next] - then List_marker_line (`Ordered (acc, c), k) else Nomatch - | _ -> Nomatch - in - loop s last 1 (digit c) (start + 1) - | _ -> Nomatch - -let ext_task_marker s ~last ~start = - if start + 1 > last then None else - if s.[start] <> '[' then None else - let next = start + 1 in - let u = String.get_utf_8_uchar s next in - if not (Uchar.utf_decode_is_valid u) then None else - let next = next + Uchar.utf_decode_length u in - if next > last then None else - if s.[next] <> ']' then None else - let next = next + 1 in - if next > last - then Some (Uchar.utf_decode_uchar u, last) - else if s.[next] <> ' ' then None else - Some (Uchar.utf_decode_uchar u, next) - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_base.mli b/ocaml-lsp-server/vendor/cmarkit/cmarkit_base.mli deleted file mode 100644 index 0400ecbd0..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_base.mli +++ /dev/null @@ -1,401 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(** Low-level internal tools. *) - -(** Heterogeneous dictionaries. - - Used by {!Cmarkit.Meta}. *) -module Dict : sig - type 'a key - val key : unit -> 'a key - type t - val empty : t - val mem : 'a key -> t -> bool - val add : 'a key -> 'a -> t -> t - val tag : unit key -> t -> t - val remove : 'a key -> t -> t - val find : 'a key -> t -> 'a option -end - -(** Text locations. - - See {!Cmarkit.Textloc} for documentation. *) -module Textloc : sig - type fpath = string - val file_none : fpath - - type byte_pos = int - val byte_pos_none : byte_pos - - type line_num = int - val line_num_none : line_num - - type line_pos = line_num * byte_pos - val line_pos_first : line_pos - val line_pos_none : line_pos - - type t - val none : t - val v : - file:fpath -> first_byte:byte_pos -> last_byte:byte_pos -> - first_line:line_pos -> last_line:line_pos -> t - - val file : t -> fpath - val first_byte : t -> byte_pos - val last_byte : t -> byte_pos - val first_line : t -> line_pos - val last_line : t -> line_pos - val is_none : t -> bool - val is_empty : t -> bool - val equal : t -> t -> bool - val compare : t -> t -> int - val set_first : t -> first_byte:byte_pos -> first_line:line_pos -> t - val set_last : t -> last_byte:byte_pos -> last_line:line_pos -> t - val to_first : t -> t - val to_last : t -> t - val before : t -> t - val after : t -> t - val span : t -> t -> t - val reloc : first:t -> last:t -> t - val pp_ocaml : Format.formatter -> t -> unit - val pp_gnu : Format.formatter -> t -> unit - val pp : Format.formatter -> t -> unit - val pp_dump : Format.formatter -> t -> unit -end - -(** Node metadata. - - See {!Cmarkit.Meta} for documentation. *) -module Meta : sig - type id = int - type t - - val none : t - val make : ?textloc:Textloc.t -> unit -> t - val id : t -> id - - val textloc : t -> Textloc.t - val with_textloc : keep_id:bool -> t -> Textloc.t -> t - - val equal : t -> t -> bool - val compare : t -> t -> int - val is_none : t -> bool - - type 'a key - val key : unit -> 'a key - val mem : 'a key -> t -> bool - val add : 'a key -> 'a -> t -> t - val tag : unit key -> t -> t - val remove : 'a key -> t -> t - val find : 'a key -> t -> 'a option -end - -type line_span = - { line_pos : Textloc.line_pos; - first : Textloc.byte_pos; - last : Textloc.byte_pos } -(** The type for line spans. A line position, the first and last - bytes of the span. If the former is greater than the latter, - the span is empty. *) - -type line_start = Textloc.byte_pos -(** The type for denoting a line start inside - a CommonMark container (i.e. may not match the text line's first - character). *) - -type rev_spans = (line_start * line_span) list -(** A reversed list of line spans, tupled with the byte position on - where the line starts (inside a CommonMark container). The - [line_start] is the start of line in the container, the - [line_span] has the actual data. The characters in the - \[[line_start];[line_span.first - 1]\] are blanks. *) - -type 'a next_line = 'a -> ('a * line_span) option -(** The type for getting a new line of input. This is used by certain - multi-line matchers (e.g. raw HTML). *) - -(** {1:ascii US-ASCII matching} *) - -(** US-ASCII matching. *) -module Ascii : sig - val is_control : char -> bool - val is_letter : char -> bool - val is_upper : char -> bool - val is_lower : char -> bool - val is_digit : char -> bool - val is_hex_digit : char -> bool - val hex_digit_to_int : char -> int - val is_alphanum : char -> bool - val is_white : char -> bool - val is_punct : char -> bool - val is_blank : char -> bool - val caseless_starts_with : prefix:string -> string -> bool -end - -(** {1:uchar Unicode matching} *) - -val prev_uchar : string -> first:int -> before:int -> Uchar.t -(** [prev_uchar s ~first ~before] is the first Unicode character before - byte position [before] in the range \[[first];[before-1]\]. If - [before <= first], U+0020 is returned (a Unicode whitespace character). *) - -val next_uchar : string -> last:int -> after:int -> Uchar.t -(** [next_uchar s ~last ~after] is the next Unicode character after - byte position [after] in the range \[[after+1];[last]\]. If [after - >= last], U+0020 is returned (a Unicode whitespace character). *) - -(** {1:content Textual content} *) - -(** Textual content. - - Ensures UTF-8 validity, unescapes, resolves numeric and named character - references. *) -module Text : sig - val utf_8_clean_unesc_unref : - Buffer.t -> string -> first:int -> last:int -> string - (** [utf_8_clean_unesc_unref b s ~first ~last] unescapes CommonMark - escapes, resolves HTML entity and character references in the - given span and replaces U+0000 and UTF-8 decoding errors by - {!Uchar.rep}. [b] is used as scratch space. If [last > first] - or [first] and [last] are not valid indices of [s] is [""]. *) - - val utf_8_clean_unref : - Buffer.t -> string -> first:int -> last:int -> string - (** [utf_8_clean_unref b s ~first ~last] is like - {!utf_8_clean_unesc_unref} but does not unsescape. *) - - val utf_8_clean_raw : - ?pad:int -> Buffer.t -> string -> first:int -> last:int -> string - (** [utf_8_clean_raw b s ~first ~last] replaces U+0000 and UTF-8 - decoding errors by {!Uchar.rep}. [b] is used as scratch space. - [pad] (defaults to [0]) specifies a number of U+0020 spaces to prepend. - If [last > first] or [first] and [last] are not valid indices of - [s] is either [""] or the padded string. *) -end - -(** {1:result Result types} *) - -type indent = int -(** The type for indentation magnitude. *) - -type byte_pos = Textloc.byte_pos -(** The type for positions. *) - -type first = Textloc.byte_pos -(** The type for the first first byte position of a parsed construct. *) - -type last = Textloc.byte_pos -(** The type for the last byte position of a parsed construct. *) - -type next = Textloc.byte_pos -(** The type for a byte position after a parsed construct. The byte position - may be invalid (end of input range) or on the newline. *) - -type heading_level = int -(** The type for heading levels. *) - -(** {1:blanks Newlines, runs, blanks and indents} *) - -val run_of : char:char -> string -> last:byte_pos -> start:byte_pos -> last -(** [run_of ~char s ~last ~start] is the last byte position of a - consecutive run of [char] in the range \[[start];[last]\] or - [start - 1] if [start] is not [char]. *) - -val first_non_blank : string -> last:byte_pos -> start:byte_pos -> byte_pos -(** [first_non_blank s ~last ~start] is the first byte position in the - range \[[start];[last]\] that is not blank and [last + 1] if there - is none. *) - -val first_non_blank_in_span : string -> line_span -> byte_pos -(** [first_non_blank_in_span s span] is - [first_non_blank s ~last:span.last ~start:span.first]. *) - -val last_non_blank : string -> first:byte_pos -> start:byte_pos -> byte_pos -(** [last_non_blank s ~first ~start] is the last position in the - range \[[first];[start]\] that is non blank and [first - 1] if - there is none. *) - -val rev_drop_spaces : string -> first:byte_pos -> start:byte_pos -> byte_pos -(** [rev_drop_spaces s ~first ~start] is the last position in the - range \[[first];[start]\] that is not U+0020 and [first - 1] if - there is none. *) - -val first_non_blank_over_nl : - next_line: 'a next_line -> string -> 'a -> line:line_span -> start:int -> - [ `None - | `This_line of byte_pos - | `Next_line of 'a * line_span * byte_pos ] -(** [first_non_blank_over_nl ~next_line s ~line ~start] is the first - byte position starting with [start] that is not blank in [line] or - on the next line as determined by [next_line]. Returns [`None] if - there is no such position. *) - -val first_non_escaped_char : - char -> string -> last:byte_pos -> start:byte_pos -> byte_pos -(** [first_non_escaped_char c s ~last ~start] is the first byte position - in the range \[[start];[last]\] that has [c] unescaped and [last + 1] - if there is none. *) - -(** {1:autolinks Autolinks} *) - -val autolink_email : string -> last:byte_pos -> start:byte_pos -> last option -(** [autolink_email s ~last ~start] matches an email autolink starting at - [start] in the range \[[start];[last]\] (assumed on the same line). *) - -val autolink_uri : string -> last:byte_pos -> start:byte_pos -> last option -(** [autolink_uri s ~last ~start] matches an URI autolink starting at - [start] in the range \[[start];[last]\] (assumed on the same line). *) - -(** {1:raw_html Raw HTML} *) - -val raw_html : - next_line:'a next_line -> string -> 'a -> line:line_span -> start:byte_pos -> - ('a * line_span * rev_spans * last) option -(** [raw_html ~next_line s lines ~line ~start] matches raw HTML on - line [line] starting at [start]. [next_line] is used to get new - lines on [lines]. Returns [Some (lines, last_line, spans, - last_byte)] with [lines] the lines after consuming the raw HTML, - [last_line] the line where it stops [spans] the byte ranges of [s] - that make up the raw HTML in reverse order and [last_byte] the - last byte included in it (guaranteed to be on [last_line]). *) - -(** {1:link Links} *) - -val link_destination : - string -> last:byte_pos -> start:byte_pos -> (bool * first * last) option -(** [link_destination s ~last ~start] matches a link destination - starting at [start] in the range \[[start];[last]\] (assumed on - the same line). This is [Some (delimited, first, last)] with the - data in \[[first];[last]\] the destination data. [delimited] is - [true] if [first-1] is '<' and [last + 1] is '>'. *) - -val link_title : - next_line:'a next_line -> string -> 'a -> line:line_span -> start:byte_pos -> - ('a * line_span * rev_spans * last) option -(** [link_title ~next_line s lines ~line ~last] is a link title on line [line] - starting at [start]. Returns [Some (lines, last_line, spans, last)] with - [lines] the lines after consuming the title, [last_line] the line where - it stops, [spans] the byte ranges of [s] that make up the title in reverse - order, [last] is on the closing delimiter and guaranteed to be on - [last_line]. *) - -val link_label : - Buffer.t -> next_line:'a next_line -> string -> 'a -> line:line_span -> - start:byte_pos -> ('a * line_span * rev_spans * last * string) option -(** [link_label buf ~next_line s lines ~line ~start] matches a link label - on line [line] starting at [start]. The byte ranges have the label's - content, the string is the normalized label. [buf] is used as scratch - space. *) - -(** {1:leaf_block Leaf blocks} - - Unless otherwise noted [start] is always after leading blanks. *) - -type html_block_end_cond = - [ `End_str of string | `End_cond_1 | `End_blank | `End_blank_7 ] -(** The type for HTML block end conditions. *) - -type line_type = -| Atx_heading_line of heading_level * byte_pos (* after # *) * first * last -| Blank_line -| Block_quote_line -| Fenced_code_block_line of first * last * (first * last) option -| Html_block_line of html_block_end_cond -| Indented_code_block_line -| List_marker_line of ([ `Ordered of int * char | `Unordered of char ] * last) -| Paragraph_line -| Setext_underline_line of heading_level * last -| Thematic_break_line of last -| Ext_table_row of last -| Ext_footnote_label of rev_spans * last * string -| Nomatch (* built-in [None] to avoid option allocs *) - -val thematic_break : string -> last:byte_pos -> start:byte_pos -> line_type -(** [thematic_break s ~last ~start] matches a thematic break in the range - in the range \[[start];[last]\]. The returned position is the last - non-blank. *) - -val atx_heading : - string -> last:byte_pos -> start:byte_pos -> line_type -(** [atx_heading s ~first ~last] is an ATX heading in the range - \[[start];[last]\]. *) - -val setext_heading_underline : - string -> last:byte_pos -> start:byte_pos -> line_type -(** [setext_heading_underline s ~last ~start] is a setext heading - underline in the range \[[start];[last]\]. The returned position - is the last underline char. *) - -val fenced_code_block_start : - string -> last:byte_pos -> start:byte_pos -> line_type -(** [fenced_code_block_start s ~last ~start] is the start of a fenced - code block line in the range \[[start];[last]\]. The first span is - the fence and the second one is the info string (if any). *) - -val fenced_code_block_continue : - fence:char * int -> string -> last:byte_pos -> start:byte_pos -> - [ `Close of first * last | `Code ] -(** [fenced_code_block_continue ~fence s ~last ~start] indicates - whether the fence code continues or closes in the the range - \[[start];[last]\] given the opening [open] which indicates the - indent, fence char and number of fence chars. *) - -val html_block_start : - string -> last:byte_pos -> start:byte_pos -> line_type -(** [html_block_start s ~last ~start] matches the start of an HTML - block starting at [start] in the range \[[start];[last]\] and on - success returns the condition to end it. *) - -val html_block_end : - end_cond:html_block_end_cond -> string -> last:byte_pos -> start:byte_pos -> - bool -(** [html_block ~end_code s ~last ~start] is [true] if the HTML block - end with [end_code] in the the range \[[start];[last]\] *) - -val ext_table_row : string -> last:byte_pos -> start:byte_pos -> line_type -(** [ext_table s ~last ~start] matches a table row in the range - \[[start];[last]\]. The returned position is the rightmost [|]. *) - -val ext_footnote_label : - Buffer.t -> string -> line_pos:Textloc.line_pos -> last:byte_pos -> - start:byte_pos -> line_type -(** [ext_footnote_label s ~last ~start] matches a footnote label the range - \[[start];[last]\]. The returned position is the rightmost [:]. - This remains on the same line. *) - -val could_be_link_reference_definition : - string -> last:byte_pos -> start:byte_pos -> bool -(** [could_be_link_reference_definition s ~last ~start] is [true] if - in the range \[[start];[last]\] could hold a link reference definition. *) - -(** {1:container Container blocks} *) - -val list_marker : - string -> last:byte_pos -> start:byte_pos -> line_type -(** [list_marker s ~last ~start] is a list marker in the range - \[[start];[last]\]. This checks there's at least one space - following unless the item is empty. *) - -val ext_task_marker : - string -> last:byte_pos -> start:byte_pos -> (Uchar.t * last) option -(** [ext_task_marker s ~last ~start] is a list task item marker in the - range \[[start];[last]\]. *) - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_commonmark.ml b/ocaml-lsp-server/vendor/cmarkit/cmarkit_commonmark.ml deleted file mode 100644 index 94469e04b..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_commonmark.ml +++ /dev/null @@ -1,446 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2023 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -open Cmarkit -module C = Cmarkit_renderer.Context - -(* Renderer state *) - -type indent = -[ `I of int | `L of int * string * int * Uchar.t option | `Q of int -| `Fn of int * Label.t ] - -type state = - { nl : string; (* newline to output. *) - mutable sot : bool; (* start of text *) - mutable indents : indent list; (* indentation stack. *) } - -let state : state C.State.t = C.State.make () -let get_state c = C.State.get c state -let init_context c d = - C.State.set c state (Some { nl = Cmarkit.Doc.nl d; sot = true; indents = [] }) - -(* Escaping *) - -module Char_set = Set.Make (Char) - -let esc_angles = Char_set.of_list ['<'; '>'] -let esc_parens = Char_set.of_list ['(';')' ] -let esc_quote = Char_set.singleton '\'' -let esc_dquote = Char_set.singleton '\"' -let esc_link_label = Char_set.of_list ['['; ']'; '\\'] - -let buffer_add_dec_esc b c = - Buffer.add_string b "&#"; - Buffer.add_string b (Int.to_string (Char.code c)); - Buffer.add_char b ';' - -let buffer_add_bslash_esc b c = - Buffer.add_char b '\\'; Buffer.add_char b c - -let buffer_add_escaped_string ?(esc_ctrl = true) b cs s = - let flush b max start i = - if start <= max then Buffer.add_substring b s start (i - start) - in - let rec loop b s max start i = - if i > max then flush b max start i else - let next = i + 1 in - let c = String.get s i in - if Char_set.mem c cs then - (flush b max start i; buffer_add_bslash_esc b c; loop b s max next next) - else if esc_ctrl && Cmarkit_base.Ascii.is_control c then - (flush b max start i; buffer_add_dec_esc b c; loop b s max next next) - else loop b s max start next - in - loop b s (String.length s - 1) 0 0 - -let escaped_string ?esc_ctrl c cs s = - buffer_add_escaped_string ?esc_ctrl (C.buffer c) cs s - -let buffer_add_escaped_text b s = - let esc_first b s = match s.[0] with - | '-' | '+' | '_' | '=' as c -> - Buffer.add_char b '\\'; Buffer.add_char b c; true - | _ -> false - in - let esc_amp s max next = - next <= max && (Cmarkit_base.Ascii.is_letter s.[next] || s.[next] = '#') - in - let esc_tilde s max prev next = - not (Char.equal prev '~') && next <= max && s.[next] = '~' - in - let esc_item_marker s i prev = - if prev <> '1' then false else - let k = ref (i - 2) in - while !k >= 0 && s.[!k] = '0' do decr k done; - !k < 0 - in - let flush b max start i = - if start <= max then Buffer.add_substring b s start (i - start) - in - let rec loop b s max start prev i = - if i > max then flush b max start i else - let next = i + 1 in - let c = String.get s i in - if Cmarkit_base.Ascii.is_control c then - (flush b max start i; buffer_add_dec_esc b c; loop b s max next c next) - else match c with - | '#' | '`' when not (Char.equal prev c) -> - flush b max start i; buffer_add_bslash_esc b c; loop b s max next c next - | '~' when esc_tilde s max prev next -> - flush b max start i; buffer_add_bslash_esc b c; loop b s max next c next - | '&' when esc_amp s max next -> - flush b max start i; buffer_add_bslash_esc b c; loop b s max next c next - | '!' when i = max -> - flush b max start i; buffer_add_bslash_esc b c; loop b s max next c next - | '.' | ')' when esc_item_marker s i prev -> - flush b max start i; buffer_add_bslash_esc b c; loop b s max next c next - | '\\' | '<' | '>' | '[' | ']' | '*' | '_' | '$' | '|' -> - flush b max start i; buffer_add_bslash_esc b c; loop b s max next c next - | _ -> - loop b s max start c next - in - let max = String.length s - 1 in - if max < 0 then () else - if esc_first b s then loop b s max 1 s.[0] 1 else loop b s max 0 '\x00' 0 - -let escaped_text c s = buffer_add_escaped_text (C.buffer c) s - -(* Newlines, indentation and multi-line layouts of raw data. *) - -let string_node_option c = function None -> () | Some (s, _) -> C.string c s -let nchars c n char = for i = 1 to n do C.byte c char done - -let newline c = - (* Block generally introduce newlines, except the first one. *) - let st = get_state c in if st.sot then st.sot <- false else C.string c st.nl - -let push_indent c n = let st = get_state c in st.indents <- n :: st.indents -let pop_indent c = - let st = get_state c in - match st.indents with [] -> () | ns -> st.indents <- (List.tl ns) - -let rec indent c = - let rec loop c acc = function - | [] -> acc - | `I n as i :: is -> - nchars c n ' '; loop c (i :: acc) is - | `Q n as i :: is -> - nchars c n ' '; C.byte c '>'; C.byte c ' '; loop c (i :: acc) is - | `L (before, m, after, task) :: is -> - nchars c before ' '; C.string c m; nchars c after ' '; - let after = match task with - | None -> after - | Some u -> C.byte c '['; C.utf_8_uchar c u; C.string c "] "; after + 4 - in - (* On the next call we'll just indent for the list item *) - loop c (`I (before + String.length m + after) :: acc) is - | `Fn (before, label) :: is -> - nchars c before ' '; - C.byte c '['; link_label_lines c (Label.text label); - C.string c "]:"; - (* On the next call we'll just indent to ^ for the footnote *) - loop c (`I (before + 1) :: acc) is - in - let st = get_state c in - st.indents <- loop c [] (List.rev st.indents) - -and link_label_lines c lines = - escaped_tight_block_lines c esc_link_label lines - -and escaped_tight_block_lines c cs = function -| [] -> () | l :: ls -> - let tight c (blanks, (l, _)) = C.string c blanks; escaped_string c cs l in - let line c l = newline c; indent c; tight c l in - tight c l; List.iter (line c) ls - -let block_lines c = function -| [] -> () | (l, _) :: ls -> - let line c (l, _) = newline c; indent c; C.string c l in - C.string c l; List.iter (line c) ls - -let tight_block_lines c = function -| [] -> () | l :: ls -> - let tight c (blanks, (l, _)) = C.string c blanks; C.string c l in - let line c l = newline c; indent c; tight c l in - tight c l; List.iter (line c) ls - -(* Inline rendering *) - -let autolink c a = - C.byte c '<'; C.string c (fst (Inline.Autolink.link a)); C.byte c '>' - -let break c b = - let layout_before = fst (Inline.Break.layout_before b) in - let layout_after = fst (Inline.Break.layout_after b) in - let before, after = match Inline.Break.type' b with - | `Soft -> layout_before, layout_after - | `Hard -> (if layout_before = "" then " " else layout_before), layout_after - in - C.string c before; newline c; indent c; C.string c after - -let code_span c cs = - nchars c (Inline.Code_span.backtick_count cs) '`'; - tight_block_lines c (Inline.Code_span.code_layout cs); - nchars c (Inline.Code_span.backtick_count cs) '`' - -let emphasis c e = - let delim = Inline.Emphasis.delim e and i = Inline.Emphasis.inline e in - let delim = if not (delim = '*' || delim = '_') then '*' else delim in - C.byte c delim; C.inline c i; C.byte c delim - -let strong_emphasis c e = - let delim = Inline.Emphasis.delim e and i = Inline.Emphasis.inline e in - let delim = if not (delim = '*' || delim = '_') then '*' else delim in - C.byte c delim; C.byte c delim; C.inline c i; C.byte c delim; C.byte c delim - -let link_title c open_delim title = match title with -| None -> () -| Some lines -> - let open', close, escapes = match open_delim with - | '\"' as delim -> delim, delim, esc_dquote - | '\'' as delim -> delim, delim, esc_quote - | '(' -> '(', ')', esc_parens - | _ -> '\"', '\"', esc_dquote - in - C.byte c open'; escaped_tight_block_lines c escapes lines; C.byte c close - -let link_definition c ld = - let layout = Link_definition.layout ld in - block_lines c layout.before_dest; - begin match Link_definition.dest ld with - | None -> () - | Some (dest, _) -> - if layout.angled_dest - then (C.byte c '<'; escaped_string c esc_angles dest; C.byte c '>') - else (escaped_string c esc_parens dest) - end; - if layout.after_dest = [] && - Option.is_some (Link_definition.dest ld) && - Option.is_some (Link_definition.title ld) - then C.byte c ' ' (* at least a space is needed *); - block_lines c layout.after_dest; - link_title c layout.title_open_delim (Link_definition.title ld); - block_lines c layout.after_title - -let link c l = match Inline.Link.reference l with -| `Inline (ld, _) -> - C.byte c '['; C.inline c (Inline.Link.text l); C.byte c ']'; - C.byte c '('; link_definition c ld; C.byte c ')' -| `Ref (`Shortcut, label, _) -> - C.byte c '['; link_label_lines c (Label.text label); C.byte c ']'; -| `Ref (`Collapsed, label, _) -> - C.byte c '['; link_label_lines c (Label.text label); C.byte c ']'; - C.string c "[]" -| `Ref (`Full, label, _) -> - C.byte c '['; C.inline c (Inline.Link.text l); C.byte c ']'; - C.byte c '['; link_label_lines c (Label.text label); C.byte c ']' - -let inlines c is = List.iter (C.inline c) is -let image c l = C.byte c '!'; link c l -let raw_html c h = tight_block_lines c h -let text c t = escaped_text c t - -let strikethrough c s = - let i = Inline.Strikethrough.inline s in - C.string c "~~"; C.inline c i; C.string c "~~" - -let math_span c ms = - let sep = if Inline.Math_span.display ms then "$$" else "$" in - C.string c sep; - tight_block_lines c (Inline.Math_span.tex_layout ms); - C.string c sep - -let inline c = function -| Inline.Autolink (a, _) -> autolink c a; true -| Inline.Break (b, _) -> break c b; true -| Inline.Code_span (cs, _) -> code_span c cs; true -| Inline.Emphasis (e, _) -> emphasis c e; true -| Inline.Image (i, _) -> image c i; true -| Inline.Inlines (is, _) -> inlines c is; true -| Inline.Link (l, _) -> link c l; true -| Inline.Raw_html (html, _) -> raw_html c html; true -| Inline.Strong_emphasis (e, _) -> strong_emphasis c e; true -| Inline.Text (t, _) -> text c t; true -| Inline.Ext_strikethrough (s, _) -> strikethrough c s; true -| Inline.Ext_math_span (m, _) -> math_span c m; true -| _ -> C.string c ""; true - -(* Block rendering *) - -let blank_line c l = newline c; indent c; C.string c l - -let block_quote c bq = - push_indent c (`Q (Block.Block_quote.indent bq)); - C.block c (Block.Block_quote.block bq); pop_indent c - -let code_block c cb = match Block.Code_block.layout cb with -| `Indented -> - newline c; push_indent c (`I 4); indent c; - block_lines c (Block.Code_block.code cb); - pop_indent c -| `Fenced f -> - let opening, closing = match fst f.opening_fence with - | "" -> - let char, len = Block.Code_block.make_fence cb in - let f = String.make len char in - f, Some f - | opening -> opening, Option.map fst f.closing_fence - in - let info_string = Block.Code_block.info_string cb in - let code = Block.Code_block.code cb in - newline c; push_indent c (`I f.indent); indent c; - C.string c opening; string_node_option c info_string; - if code <> [] then (newline c; indent c; block_lines c code); - (match closing with - | None -> () | Some close -> newline c; indent c; C.string c close); - pop_indent c - -let heading c h = - newline c; indent c; - match (Block.Heading.layout h) with - | `Atx { indent; after_opening; closing } -> - let inline = Block.Heading.inline h in - nchars c indent ' '; - nchars c (Block.Heading.level h) '#'; - (if after_opening = "" && not (Cmarkit.Inline.is_empty inline) - then C.byte c ' ' else C.string c after_opening); - C.inline c inline; - C.string c closing - | `Setext l -> - let u = match Block.Heading.level h with 1 -> '=' | 2 -> '-' | _ -> '-' in - nchars c l.leading_indent ' '; - C.inline c (Block.Heading.inline h); - C.string c l.trailing_blanks; - newline c; indent c; - nchars c l.underline_indent ' '; - nchars c (fst l.underline_count) u; - C.string c l.underline_blanks - -let html_block c h = newline c; indent c; block_lines c h - -let link_reference_definition c ld = - newline c; indent c; nchars c (Link_definition.layout ld).indent ' '; - C.byte c '['; - begin match Link_definition.label ld with - | None -> () - | Some label -> escaped_tight_block_lines c esc_link_label (Label.text label) - end; - C.string c "]:"; - link_definition c ld - -let unordered_item c marker (i, _) = - let before = Block.List_item.before_marker i in - let after = Block.List_item.after_marker i in - let task = Option.map fst (Block.List_item.ext_task_marker i) in - push_indent c (`L (before, marker, after, task)); - C.block c (Block.List_item.block i); - pop_indent c - -let ordered_item c sep num (i, _) = - let before = Block.List_item.before_marker i in - let marker = fst (Block.List_item.marker i) in - let marker = if marker = "" then Int.to_string num ^ sep else marker in - let after = Block.List_item.after_marker i in - let task = Option.map fst (Block.List_item.ext_task_marker i) in - push_indent c (`L (before, marker, after, task)); - C.block c (Block.List_item.block i); - pop_indent c; - num + 1 - -let list c l = match Block.List'.type' l with -| `Unordered marker -> - let marker = match marker with '*' | '-' | '+' -> marker | _ -> '*' in - let marker = String.make 1 marker in - List.iter (unordered_item c marker) (Block.List'.items l) -| `Ordered (start, sep) -> - let sep = if sep <> '.' && sep <> ')' then '.' else sep in - let sep = String.make 1 sep in - ignore (List.fold_left (ordered_item c sep) start (Block.List'.items l)) - -let paragraph c p = - newline c; indent c; - nchars c (Block.Paragraph.leading_indent p) ' '; - C.inline c (Block.Paragraph.inline p); - C.string c (Block.Paragraph.trailing_blanks p) - -let thematic_break c t = - let ind = Block.Thematic_break.indent t in - let break = Block.Thematic_break.layout t in - let break = if break = "" then "---" else break in - newline c; indent c; nchars c ind ' '; C.string c break - -let table c t = - let col c (i, (before, after)) = - C.byte c '|'; C.string c before; C.inline c i; C.string c after - in - let sep c ((align, len), _) = - C.byte c '|'; - match align with - | None -> nchars c len '-' - | Some `Left -> C.byte c ':'; nchars c len '-' - | Some `Center -> C.byte c ':'; nchars c len '-'; C.byte c ':' - | Some `Right -> nchars c len '-'; C.byte c ':' - in - let row c = function - | (`Header cols, _), blanks | (`Data cols, _), blanks -> - newline c; indent c; - (if cols = [] then C.byte c '|' else List.iter (col c) cols); - C.byte c '|'; C.string c blanks - | (`Sep seps, _), blanks -> - newline c; indent c; - (if seps = [] then C.byte c '|' else List.iter (sep c) seps); - C.byte c '|'; C.string c blanks - in - push_indent c (`I (Block.Table.indent t)); - List.iter (row c) (Block.Table.rows t); - pop_indent c - -let footnote c fn = - push_indent c (`Fn (Block.Footnote.indent fn, Block.Footnote.label fn)); - C.block c (Block.Footnote.block fn); - pop_indent c - -let block c = function -| Block.Blank_line (l, _) -> blank_line c l; true -| Block.Block_quote (b, _) -> block_quote c b; true -| Block.Blocks (bs, _) -> List.iter (C.block c) bs; true -| Block.Code_block (cb, _) -> code_block c cb; true -| Block.Heading (h, _) -> heading c h; true -| Block.Html_block (h, _) -> html_block c h; true -| Block.Link_reference_definition (ld, _) -> - link_reference_definition c ld; true -| Block.List (l, _) -> list c l; true -| Block.Paragraph (p, _) -> paragraph c p; true -| Block.Thematic_break (t, _) -> thematic_break c t; true -| Block.Ext_math_block (cb, _) -> code_block c cb; true -| Block.Ext_table (t, _) -> table c t; true -| Block.Ext_footnote_definition (t, _) -> footnote c t; true -| _ -> newline c; indent c; C.string c ""; true - -(* Document rendering *) - -let doc c d = C.block c (Doc.block d); true - -(* Renderer *) - -let renderer () = Cmarkit_renderer.make ~init_context ~inline ~block ~doc () -let of_doc d = Cmarkit_renderer.doc_to_string (renderer ()) d - -(*--------------------------------------------------------------------------- - Copyright (c) 2023 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_commonmark.mli b/ocaml-lsp-server/vendor/cmarkit/cmarkit_commonmark.mli deleted file mode 100644 index 4dd78d93a..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_commonmark.mli +++ /dev/null @@ -1,266 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2023 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(** Rendering CommonMark to CommonMark. - - Generates CommonMark. If your document was parsed with - [layout:true], it preserves most of the source layout on output. - This won't be perfect, make sure you understand the - {{!layout}details} before reporting issues. - - See {{!page-index.quick}an example}. - - {b Warning.} Rendering outputs are unstable. They may be tweaked - even between minor versions of the library. *) - -(** {1:rendering Rendering} *) - -val of_doc : Cmarkit.Doc.t -> string -(** [of_doc d] is a CommonMark document for [d]. See {!val-renderer} for - more details. *) - -(** {1:renderer Renderer} *) - -val renderer : unit -> Cmarkit_renderer.t -(** [renderer ()] is the default CommonMark renderer. This renders - the strict CommonMark abstract syntax tree and the supported - Cmarkit {{!Cmarkit.extensions}extensions}. - - The inline, block and document renderers always return - [true]. Unknown block and inline values are rendered by an HTML - comment (as permitted by the CommonMark specification). - - See {{!Cmarkit_renderer.example}this example} to extend or - selectively override the renderer. *) - -(** {1:render Render functions} - - Only useful if you extend the renderer. *) - -(** {2:indents Newlines and indentation} *) - -val newline : Cmarkit_renderer.context -> unit -(** [newline c] starts a new line, except on the first call on [c] which is - a nop. *) - -type indent = -[ `I of int (** Identation by given amount. *) -| `L of int * string * int * Uchar.t option - (** Indent before, list marker, indent after, list item task extension *) -| `Q of int (** Identation followed by a block quote marker and a space *) -| `Fn of int * Cmarkit.Label.t (** Indent before, label (footnote extension)*)] -(** The type for specifying block indentation. *) - -val push_indent : Cmarkit_renderer.context -> indent -> unit -(** [push_indent c i] pushes [i] on the current indentation of [c]. This - does not render anything. *) - -val pop_indent : Cmarkit_renderer.context -> unit -(** [pop_indent c] pops the last indentation pushed on [c]. This - does not render anything. *) - -val indent : Cmarkit_renderer.context -> unit -(** [indent i c] outputs current indentation on [c]. Note that [`L] - and [`Fn] get replaced by an [`I] indent on subsequent lines, that - is the list or foonote marker is output only once. *) - -(** {2:bslash Backslash escaping} *) - -module Char_set : Set.S with type elt = char -(** Sets of US-ASCII characters. *) - -val escaped_string : - ?esc_ctrl:bool -> Cmarkit_renderer.context -> Char_set.t -> string -> unit -(** [escaped_string ?esc_ctrl c cs s] renders [s] on [c] with - characters in [cs] backslash escaped. If [esc_ctrl] is [true] - (default) {{:https://spec.commonmark.org/0.30/#ascii-control-character} - ASCII control characters} are escaped to decimal escapes. *) - -val buffer_add_escaped_string : - ?esc_ctrl:bool -> Buffer.t -> Char_set.t -> string -> unit -(** [buffer_add_escaped_string b cs s] is {!escaped_string} but - appends to a buffer value. *) - -val escaped_text : Cmarkit_renderer.context -> string -> unit -(** [escaped_text c s] renders [s] on [c] trying to be smart about escaping - Commonmark structural symbols for {!Cmarkit.Inline.extension-Text} inlines. - We assume text can be anywhere in a sequence of inlines and in particular - that it can start a line. This function also takes into account - the existence of the {{!Cmarkit.extensions}extensions}. - - As such we escape: - - {ul - {- These block markers: [-] [+] [_] [=] only if present at [s.[0]].} - {- Only the first of runs of them: [#] [`]} - {- Only the first of a run longer than 1: [~] - ({{!Cmarkit.ext_strikethrough}strikethrough extension}).} - {- [&] if followed by an US-ASCII letter or [#].} - {- [!] if it is the last character of [s].} - {- [.] or [)] only if preceeded by a single [1] and zero or more [0] to - the start of text.} - {- Everywhere, [*] [_] [\ ] [<] [>] [\[] [\]], - {{:https://spec.commonmark.org/0.30/#ascii-control-character} - ASCII control characters}, [$] ({{!Cmarkit.ext_math_inline}inline math - extension}), [|] ({{!Cmarkit.ext_tables}table extension}) }} *) - -val buffer_add_escaped_text : Buffer.t -> string -> unit -(** [buffer_add_escaped_text b s] is {!escaped_text} but appends to - a buffer value. *) - -(** {1:layout Source layout preservation} - - The abstract syntax tree has a few block cases and data fields to - represent the source document layout. This allows to update - CommonMark documents without normalizing them too much when they - are {{!Cmarkit.Doc.of_string}parsed} with [layout:true]. - - To keep things reasonably simple a few things are {b not} attempted like: - - {ol - {- Preserving entities and character references.} - {- Preserving the exact line by line indentation layout of container - blocks.} - {- Preserving lazy continuation lines.} - {- Keeping track of used newlines except for the first one.} - {- Preserving layout source location information when it can be - reconstructed from the document data source location.}} - - In general we try to keep the following desirable properties - for the abstract syntax tree definition: - - {ol - {- Layout information should not interfere with document data or - be affected by it. Otherwise data updates also needs to update - the layout data, which is error prone and unconvenient.} - {- Abstract syntax trees resulting from the source document, from - renders of the source document parsed with or without - [layout:tree] should all render to the same HTML.}} - - In practice CommonMark being not context free point 1. is not - always achieved. In particular in {!Cmarkit.Inline.extension-Code_span} the - number of delimiting backticks depends on the code content - ({!Cmarkit.Inline.Code_span.of_string}, computes that for you). - - The renderer performs almost no checks on the layout data. You - should be careful if you fill these yourself since you could - generate CommonMark that will be misinterpreted. Layout - data of pristine nodes coming out of {!Cmarkit.Doc.of_string}, created - with the {!Cmarkit.Inline} and {!Cmarkit.Block} constructors - should not need your attention (respect their input constraints - though). *) - -(** {2:rendering_class Classifying renderings} - - We say that a CommonMark render: - {ul - {- is {e correct}, if the result renders the same HTML - as the source document. This can be checked with the - [cmarkit] tool included in the distribution: - {[ - cmarkit commonmark --html-diff mydoc.md - ]} - If a difference shows up, the rendering is said to be {e incorrect}.} - {- {e round trips}, if the result is byte-for-byte equal to the - source document. This can be checked with the [cmarkit] tool - included in the distribution: - {[ - cmarkit commonmark --diff mydoc.md - ]} - If a difference shows up, the rendering does not round trip but - it may still be correct.}} *) - -(** {2:known_diffs Known correct differences} - - In general lack of round trip is due to: - - {ul - {- Loss of layout on input (see above).} - {- Eager escaping of CommonMark delimiters (the escape strategy - is {{!escaped_text}here}).} - {- Churn around blank lines which can be part of blocks without - adhering to their structural convention.}} - - Please do not report issues for differences that are due to the - following: - - {ol - {- Source US-ASCII control characters in textual data render as decimal - character references in the output.} - {- Source entity and character references are lost during parsing and - thus replaced by their definition in the output.} - {- Source tab stop advances may be replaced by spaces in the output.} - {- Source escaped characters may end up unescaped in the output.} - {- Source unescaped characters may end up escaped in the output.} - {- Source lazy continuation lines are made part of blocks in the output.} - {- Source indented blank lines following indented code blocks - lose four spaces of indentation (as per specification these are not - part of the block).} - {- Source unindented blank lines in indented code blocks are indented - in the output.} - {- Source fenced code block indentation is retained from the opening - fence and used for the following lines in the output.} - {- Source block quote indentation is retained from the first line - and used for the following lines in the output. The optional space - following the quotation mark ['>'] is made mandatory. } - {- Source list item indentation is regularized, in particular blank lines - will indent.} - {- Source list item that start with an empty line get a space after - their marker.} - {- The newline used in the output is the one found in the rendered - {!Cmarkit.Doc.t} value.}} - - {e Simple} and {e implemented} round trip improvements to the - renderer are welcome. - - {2:known_incorrect Known incorrect renderings} - - Please do not report issues incorrect renderings that are due to the - following (and unlikely to be fixed): - - {ol - {- Use of entities and character references around structural - CommonMark symbols can make things go wrong. These get resolved - after inline parsing because they can't be used to stand for - structural CommonMark symbols, however once they have been resolved they - can interact with parsing. Here is an example: - {[ - *emph * - ]} - It parses as emphasis. But if we render it to CommonMark - non-breaking space renders as is and we get: - {[ - *emph * - ]} - which no longer parses as emphasis. - - Note in this particular case it is possible to do something - about it by being smarter about the context when escaping. However - there's a trade-off between renderer complexity and the (conjectured) - paucity of these cases.} - } - - Otherwise, if you spot an incorrect rendering please report a minimal - reproduction case. - - {e Simple} and {e implemented} round trip improvements to the - renderer are welcome. - *) - -(*--------------------------------------------------------------------------- - Copyright (c) 2023 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_data.ml b/ocaml-lsp-server/vendor/cmarkit/cmarkit_data.ml deleted file mode 100644 index e3bc3716d..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_data.ml +++ /dev/null @@ -1,59 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(* Unicode character data - - XXX. For now we kept that simple and use the Stdlib's Set and - Maps. Bring in Uucp's tmapbool and tmap if that turns out to be too - costly in space or time. *) - -module Uset = struct - include Set.Make (Uchar) - let of_array = - let add acc u = add (Uchar.unsafe_of_int u) acc in - Array.fold_left add empty -end - -module Umap = struct - include Map.Make (Uchar) - let of_array = - let add acc (u, f) = add (Uchar.unsafe_of_int u) f acc in - Array.fold_left add empty -end - -let whitespace_uset = Uset.of_array Cmarkit_data_uchar.whitespace -let punctuation_uset = Uset.of_array Cmarkit_data_uchar.punctuation -let case_fold_umap = Umap.of_array Cmarkit_data_uchar.case_fold - -let unicode_version = Cmarkit_data_uchar.unicode_version -let is_unicode_whitespace u = Uset.mem u whitespace_uset -let is_unicode_punctuation u = Uset.mem u punctuation_uset -let unicode_case_fold u = Umap.find_opt u case_fold_umap - -(* HTML entity data. *) - -module String_map = Map.Make (String) - -let html_entity_smap = - let add acc (entity, rep) = String_map.add entity rep acc in - Array.fold_left add String_map.empty Cmarkit_data_html.entities - -let html_entity e = String_map.find_opt e html_entity_smap - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_data.mli b/ocaml-lsp-server/vendor/cmarkit/cmarkit_data.mli deleted file mode 100644 index 7cd98bcb9..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_data.mli +++ /dev/null @@ -1,50 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(** Data needed for CommonMark parsing. *) - -(** {1:unicode Unicode data} *) - -val unicode_version : string -(** [unicode_version] is the supported Unicode version. *) - -val is_unicode_whitespace : Uchar.t -> bool -(** [is_unicode_whitespace u] is [true] iff - [u] is a CommonMark - {{:https://spec.commonmark.org/current/#unicode-whitespace-character} - Unicode whitespace character}. *) - -val is_unicode_punctuation : Uchar.t -> bool -(** [is_unicode_punctuation u] is [true] iff - [u] is a CommonMark - {{:https://spec.commonmark.org/current/#unicode-punctuation-character} - Unicode punctuation character}. *) - -val unicode_case_fold : Uchar.t -> string option -(** [unicode_case_fold u] is the UTF-8 encoding of [u]'s Unicode - {{:http://www.unicode.org/reports/tr44/#Case_Folding}case fold} or - [None] if [u] case folds to itself. *) - -(** {1:html HTML data} *) - -val html_entity : string -> string option -(** [html_entity e] is the UTF-8 data for of the HTML entity {e name} - (without [&] and [;]) [e]. *) - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_data_html.ml b/ocaml-lsp-server/vendor/cmarkit/cmarkit_data_html.ml deleted file mode 100644 index c53b62244..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_data_html.ml +++ /dev/null @@ -1,2165 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(* Munged from https://html.spec.whatwg.org/entities.json - Note that some entities map to sequences of characters. *) - -let entities = [| -(* Generated with: -cat entities.json | \ -# Extract entities and code points -jq -r \ -'map_values(.codepoints)|to_entries|.[]|[.key,(.value|join(" "))]|join (", ")' | \ -# Drop entities from the list that are not closed by a ';' -grep ';' | \ -# Keep only the name of entities -sed 's/[&;]//g' | -# Replace decimal code points by OCaml Unicode escapes -perl -pe 's/ \d{1,}/sprintf " \\u{%04X}", $&/ge' | -# Convert the lines to OCaml syntax -sed 's/ //g;s/^/"/g;s/$/";/g;s/;,/", "/g' -*) -"AElig", "\u{00C6}"; -"AMP", "\u{0026}"; -"Aacute", "\u{00C1}"; -"Abreve", "\u{0102}"; -"Acirc", "\u{00C2}"; -"Acy", "\u{0410}"; -"Afr", "\u{1D504}"; -"Agrave", "\u{00C0}"; -"Alpha", "\u{0391}"; -"Amacr", "\u{0100}"; -"And", "\u{2A53}"; -"Aogon", "\u{0104}"; -"Aopf", "\u{1D538}"; -"ApplyFunction", "\u{2061}"; -"Aring", "\u{00C5}"; -"Ascr", "\u{1D49C}"; -"Assign", "\u{2254}"; -"Atilde", "\u{00C3}"; -"Auml", "\u{00C4}"; -"Backslash", "\u{2216}"; -"Barv", "\u{2AE7}"; -"Barwed", "\u{2306}"; -"Bcy", "\u{0411}"; -"Because", "\u{2235}"; -"Bernoullis", "\u{212C}"; -"Beta", "\u{0392}"; -"Bfr", "\u{1D505}"; -"Bopf", "\u{1D539}"; -"Breve", "\u{02D8}"; -"Bscr", "\u{212C}"; -"Bumpeq", "\u{224E}"; -"CHcy", "\u{0427}"; -"COPY", "\u{00A9}"; -"Cacute", "\u{0106}"; -"Cap", "\u{22D2}"; -"CapitalDifferentialD", "\u{2145}"; -"Cayleys", "\u{212D}"; -"Ccaron", "\u{010C}"; -"Ccedil", "\u{00C7}"; -"Ccirc", "\u{0108}"; -"Cconint", "\u{2230}"; -"Cdot", "\u{010A}"; -"Cedilla", "\u{00B8}"; -"CenterDot", "\u{00B7}"; -"Cfr", "\u{212D}"; -"Chi", "\u{03A7}"; -"CircleDot", "\u{2299}"; -"CircleMinus", "\u{2296}"; -"CirclePlus", "\u{2295}"; -"CircleTimes", "\u{2297}"; -"ClockwiseContourIntegral", "\u{2232}"; -"CloseCurlyDoubleQuote", "\u{201D}"; -"CloseCurlyQuote", "\u{2019}"; -"Colon", "\u{2237}"; -"Colone", "\u{2A74}"; -"Congruent", "\u{2261}"; -"Conint", "\u{222F}"; -"ContourIntegral", "\u{222E}"; -"Copf", "\u{2102}"; -"Coproduct", "\u{2210}"; -"CounterClockwiseContourIntegral", "\u{2233}"; -"Cross", "\u{2A2F}"; -"Cscr", "\u{1D49E}"; -"Cup", "\u{22D3}"; -"CupCap", "\u{224D}"; -"DD", "\u{2145}"; -"DDotrahd", "\u{2911}"; -"DJcy", "\u{0402}"; -"DScy", "\u{0405}"; -"DZcy", "\u{040F}"; -"Dagger", "\u{2021}"; -"Darr", "\u{21A1}"; -"Dashv", "\u{2AE4}"; -"Dcaron", "\u{010E}"; -"Dcy", "\u{0414}"; -"Del", "\u{2207}"; -"Delta", "\u{0394}"; -"Dfr", "\u{1D507}"; -"DiacriticalAcute", "\u{00B4}"; -"DiacriticalDot", "\u{02D9}"; -"DiacriticalDoubleAcute", "\u{02DD}"; -"DiacriticalGrave", "\u{0060}"; -"DiacriticalTilde", "\u{02DC}"; -"Diamond", "\u{22C4}"; -"DifferentialD", "\u{2146}"; -"Dopf", "\u{1D53B}"; -"Dot", "\u{00A8}"; -"DotDot", "\u{20DC}"; -"DotEqual", "\u{2250}"; -"DoubleContourIntegral", "\u{222F}"; -"DoubleDot", "\u{00A8}"; -"DoubleDownArrow", "\u{21D3}"; -"DoubleLeftArrow", "\u{21D0}"; -"DoubleLeftRightArrow", "\u{21D4}"; -"DoubleLeftTee", "\u{2AE4}"; -"DoubleLongLeftArrow", "\u{27F8}"; -"DoubleLongLeftRightArrow", "\u{27FA}"; -"DoubleLongRightArrow", "\u{27F9}"; -"DoubleRightArrow", "\u{21D2}"; -"DoubleRightTee", "\u{22A8}"; -"DoubleUpArrow", "\u{21D1}"; -"DoubleUpDownArrow", "\u{21D5}"; -"DoubleVerticalBar", "\u{2225}"; -"DownArrow", "\u{2193}"; -"DownArrowBar", "\u{2913}"; -"DownArrowUpArrow", "\u{21F5}"; -"DownBreve", "\u{0311}"; -"DownLeftRightVector", "\u{2950}"; -"DownLeftTeeVector", "\u{295E}"; -"DownLeftVector", "\u{21BD}"; -"DownLeftVectorBar", "\u{2956}"; -"DownRightTeeVector", "\u{295F}"; -"DownRightVector", "\u{21C1}"; -"DownRightVectorBar", "\u{2957}"; -"DownTee", "\u{22A4}"; -"DownTeeArrow", "\u{21A7}"; -"Downarrow", "\u{21D3}"; -"Dscr", "\u{1D49F}"; -"Dstrok", "\u{0110}"; -"ENG", "\u{014A}"; -"ETH", "\u{00D0}"; -"Eacute", "\u{00C9}"; -"Ecaron", "\u{011A}"; -"Ecirc", "\u{00CA}"; -"Ecy", "\u{042D}"; -"Edot", "\u{0116}"; -"Efr", "\u{1D508}"; -"Egrave", "\u{00C8}"; -"Element", "\u{2208}"; -"Emacr", "\u{0112}"; -"EmptySmallSquare", "\u{25FB}"; -"EmptyVerySmallSquare", "\u{25AB}"; -"Eogon", "\u{0118}"; -"Eopf", "\u{1D53C}"; -"Epsilon", "\u{0395}"; -"Equal", "\u{2A75}"; -"EqualTilde", "\u{2242}"; -"Equilibrium", "\u{21CC}"; -"Escr", "\u{2130}"; -"Esim", "\u{2A73}"; -"Eta", "\u{0397}"; -"Euml", "\u{00CB}"; -"Exists", "\u{2203}"; -"ExponentialE", "\u{2147}"; -"Fcy", "\u{0424}"; -"Ffr", "\u{1D509}"; -"FilledSmallSquare", "\u{25FC}"; -"FilledVerySmallSquare", "\u{25AA}"; -"Fopf", "\u{1D53D}"; -"ForAll", "\u{2200}"; -"Fouriertrf", "\u{2131}"; -"Fscr", "\u{2131}"; -"GJcy", "\u{0403}"; -"GT", "\u{003E}"; -"Gamma", "\u{0393}"; -"Gammad", "\u{03DC}"; -"Gbreve", "\u{011E}"; -"Gcedil", "\u{0122}"; -"Gcirc", "\u{011C}"; -"Gcy", "\u{0413}"; -"Gdot", "\u{0120}"; -"Gfr", "\u{1D50A}"; -"Gg", "\u{22D9}"; -"Gopf", "\u{1D53E}"; -"GreaterEqual", "\u{2265}"; -"GreaterEqualLess", "\u{22DB}"; -"GreaterFullEqual", "\u{2267}"; -"GreaterGreater", "\u{2AA2}"; -"GreaterLess", "\u{2277}"; -"GreaterSlantEqual", "\u{2A7E}"; -"GreaterTilde", "\u{2273}"; -"Gscr", "\u{1D4A2}"; -"Gt", "\u{226B}"; -"HARDcy", "\u{042A}"; -"Hacek", "\u{02C7}"; -"Hat", "\u{005E}"; -"Hcirc", "\u{0124}"; -"Hfr", "\u{210C}"; -"HilbertSpace", "\u{210B}"; -"Hopf", "\u{210D}"; -"HorizontalLine", "\u{2500}"; -"Hscr", "\u{210B}"; -"Hstrok", "\u{0126}"; -"HumpDownHump", "\u{224E}"; -"HumpEqual", "\u{224F}"; -"IEcy", "\u{0415}"; -"IJlig", "\u{0132}"; -"IOcy", "\u{0401}"; -"Iacute", "\u{00CD}"; -"Icirc", "\u{00CE}"; -"Icy", "\u{0418}"; -"Idot", "\u{0130}"; -"Ifr", "\u{2111}"; -"Igrave", "\u{00CC}"; -"Im", "\u{2111}"; -"Imacr", "\u{012A}"; -"ImaginaryI", "\u{2148}"; -"Implies", "\u{21D2}"; -"Int", "\u{222C}"; -"Integral", "\u{222B}"; -"Intersection", "\u{22C2}"; -"InvisibleComma", "\u{2063}"; -"InvisibleTimes", "\u{2062}"; -"Iogon", "\u{012E}"; -"Iopf", "\u{1D540}"; -"Iota", "\u{0399}"; -"Iscr", "\u{2110}"; -"Itilde", "\u{0128}"; -"Iukcy", "\u{0406}"; -"Iuml", "\u{00CF}"; -"Jcirc", "\u{0134}"; -"Jcy", "\u{0419}"; -"Jfr", "\u{1D50D}"; -"Jopf", "\u{1D541}"; -"Jscr", "\u{1D4A5}"; -"Jsercy", "\u{0408}"; -"Jukcy", "\u{0404}"; -"KHcy", "\u{0425}"; -"KJcy", "\u{040C}"; -"Kappa", "\u{039A}"; -"Kcedil", "\u{0136}"; -"Kcy", "\u{041A}"; -"Kfr", "\u{1D50E}"; -"Kopf", "\u{1D542}"; -"Kscr", "\u{1D4A6}"; -"LJcy", "\u{0409}"; -"LT", "\u{003C}"; -"Lacute", "\u{0139}"; -"Lambda", "\u{039B}"; -"Lang", "\u{27EA}"; -"Laplacetrf", "\u{2112}"; -"Larr", "\u{219E}"; -"Lcaron", "\u{013D}"; -"Lcedil", "\u{013B}"; -"Lcy", "\u{041B}"; -"LeftAngleBracket", "\u{27E8}"; -"LeftArrow", "\u{2190}"; -"LeftArrowBar", "\u{21E4}"; -"LeftArrowRightArrow", "\u{21C6}"; -"LeftCeiling", "\u{2308}"; -"LeftDoubleBracket", "\u{27E6}"; -"LeftDownTeeVector", "\u{2961}"; -"LeftDownVector", "\u{21C3}"; -"LeftDownVectorBar", "\u{2959}"; -"LeftFloor", "\u{230A}"; -"LeftRightArrow", "\u{2194}"; -"LeftRightVector", "\u{294E}"; -"LeftTee", "\u{22A3}"; -"LeftTeeArrow", "\u{21A4}"; -"LeftTeeVector", "\u{295A}"; -"LeftTriangle", "\u{22B2}"; -"LeftTriangleBar", "\u{29CF}"; -"LeftTriangleEqual", "\u{22B4}"; -"LeftUpDownVector", "\u{2951}"; -"LeftUpTeeVector", "\u{2960}"; -"LeftUpVector", "\u{21BF}"; -"LeftUpVectorBar", "\u{2958}"; -"LeftVector", "\u{21BC}"; -"LeftVectorBar", "\u{2952}"; -"Leftarrow", "\u{21D0}"; -"Leftrightarrow", "\u{21D4}"; -"LessEqualGreater", "\u{22DA}"; -"LessFullEqual", "\u{2266}"; -"LessGreater", "\u{2276}"; -"LessLess", "\u{2AA1}"; -"LessSlantEqual", "\u{2A7D}"; -"LessTilde", "\u{2272}"; -"Lfr", "\u{1D50F}"; -"Ll", "\u{22D8}"; -"Lleftarrow", "\u{21DA}"; -"Lmidot", "\u{013F}"; -"LongLeftArrow", "\u{27F5}"; -"LongLeftRightArrow", "\u{27F7}"; -"LongRightArrow", "\u{27F6}"; -"Longleftarrow", "\u{27F8}"; -"Longleftrightarrow", "\u{27FA}"; -"Longrightarrow", "\u{27F9}"; -"Lopf", "\u{1D543}"; -"LowerLeftArrow", "\u{2199}"; -"LowerRightArrow", "\u{2198}"; -"Lscr", "\u{2112}"; -"Lsh", "\u{21B0}"; -"Lstrok", "\u{0141}"; -"Lt", "\u{226A}"; -"Map", "\u{2905}"; -"Mcy", "\u{041C}"; -"MediumSpace", "\u{205F}"; -"Mellintrf", "\u{2133}"; -"Mfr", "\u{1D510}"; -"MinusPlus", "\u{2213}"; -"Mopf", "\u{1D544}"; -"Mscr", "\u{2133}"; -"Mu", "\u{039C}"; -"NJcy", "\u{040A}"; -"Nacute", "\u{0143}"; -"Ncaron", "\u{0147}"; -"Ncedil", "\u{0145}"; -"Ncy", "\u{041D}"; -"NegativeMediumSpace", "\u{200B}"; -"NegativeThickSpace", "\u{200B}"; -"NegativeThinSpace", "\u{200B}"; -"NegativeVeryThinSpace", "\u{200B}"; -"NestedGreaterGreater", "\u{226B}"; -"NestedLessLess", "\u{226A}"; -"NewLine", "\u{000A}"; -"Nfr", "\u{1D511}"; -"NoBreak", "\u{2060}"; -"NonBreakingSpace", "\u{00A0}"; -"Nopf", "\u{2115}"; -"Not", "\u{2AEC}"; -"NotCongruent", "\u{2262}"; -"NotCupCap", "\u{226D}"; -"NotDoubleVerticalBar", "\u{2226}"; -"NotElement", "\u{2209}"; -"NotEqual", "\u{2260}"; -"NotEqualTilde", "\u{2242}\u{0338}"; -"NotExists", "\u{2204}"; -"NotGreater", "\u{226F}"; -"NotGreaterEqual", "\u{2271}"; -"NotGreaterFullEqual", "\u{2267}\u{0338}"; -"NotGreaterGreater", "\u{226B}\u{0338}"; -"NotGreaterLess", "\u{2279}"; -"NotGreaterSlantEqual", "\u{2A7E}\u{0338}"; -"NotGreaterTilde", "\u{2275}"; -"NotHumpDownHump", "\u{224E}\u{0338}"; -"NotHumpEqual", "\u{224F}\u{0338}"; -"NotLeftTriangle", "\u{22EA}"; -"NotLeftTriangleBar", "\u{29CF}\u{0338}"; -"NotLeftTriangleEqual", "\u{22EC}"; -"NotLess", "\u{226E}"; -"NotLessEqual", "\u{2270}"; -"NotLessGreater", "\u{2278}"; -"NotLessLess", "\u{226A}\u{0338}"; -"NotLessSlantEqual", "\u{2A7D}\u{0338}"; -"NotLessTilde", "\u{2274}"; -"NotNestedGreaterGreater", "\u{2AA2}\u{0338}"; -"NotNestedLessLess", "\u{2AA1}\u{0338}"; -"NotPrecedes", "\u{2280}"; -"NotPrecedesEqual", "\u{2AAF}\u{0338}"; -"NotPrecedesSlantEqual", "\u{22E0}"; -"NotReverseElement", "\u{220C}"; -"NotRightTriangle", "\u{22EB}"; -"NotRightTriangleBar", "\u{29D0}\u{0338}"; -"NotRightTriangleEqual", "\u{22ED}"; -"NotSquareSubset", "\u{228F}\u{0338}"; -"NotSquareSubsetEqual", "\u{22E2}"; -"NotSquareSuperset", "\u{2290}\u{0338}"; -"NotSquareSupersetEqual", "\u{22E3}"; -"NotSubset", "\u{2282}\u{20D2}"; -"NotSubsetEqual", "\u{2288}"; -"NotSucceeds", "\u{2281}"; -"NotSucceedsEqual", "\u{2AB0}\u{0338}"; -"NotSucceedsSlantEqual", "\u{22E1}"; -"NotSucceedsTilde", "\u{227F}\u{0338}"; -"NotSuperset", "\u{2283}\u{20D2}"; -"NotSupersetEqual", "\u{2289}"; -"NotTilde", "\u{2241}"; -"NotTildeEqual", "\u{2244}"; -"NotTildeFullEqual", "\u{2247}"; -"NotTildeTilde", "\u{2249}"; -"NotVerticalBar", "\u{2224}"; -"Nscr", "\u{1D4A9}"; -"Ntilde", "\u{00D1}"; -"Nu", "\u{039D}"; -"OElig", "\u{0152}"; -"Oacute", "\u{00D3}"; -"Ocirc", "\u{00D4}"; -"Ocy", "\u{041E}"; -"Odblac", "\u{0150}"; -"Ofr", "\u{1D512}"; -"Ograve", "\u{00D2}"; -"Omacr", "\u{014C}"; -"Omega", "\u{03A9}"; -"Omicron", "\u{039F}"; -"Oopf", "\u{1D546}"; -"OpenCurlyDoubleQuote", "\u{201C}"; -"OpenCurlyQuote", "\u{2018}"; -"Or", "\u{2A54}"; -"Oscr", "\u{1D4AA}"; -"Oslash", "\u{00D8}"; -"Otilde", "\u{00D5}"; -"Otimes", "\u{2A37}"; -"Ouml", "\u{00D6}"; -"OverBar", "\u{203E}"; -"OverBrace", "\u{23DE}"; -"OverBracket", "\u{23B4}"; -"OverParenthesis", "\u{23DC}"; -"PartialD", "\u{2202}"; -"Pcy", "\u{041F}"; -"Pfr", "\u{1D513}"; -"Phi", "\u{03A6}"; -"Pi", "\u{03A0}"; -"PlusMinus", "\u{00B1}"; -"Poincareplane", "\u{210C}"; -"Popf", "\u{2119}"; -"Pr", "\u{2ABB}"; -"Precedes", "\u{227A}"; -"PrecedesEqual", "\u{2AAF}"; -"PrecedesSlantEqual", "\u{227C}"; -"PrecedesTilde", "\u{227E}"; -"Prime", "\u{2033}"; -"Product", "\u{220F}"; -"Proportion", "\u{2237}"; -"Proportional", "\u{221D}"; -"Pscr", "\u{1D4AB}"; -"Psi", "\u{03A8}"; -"QUOT", "\u{0022}"; -"Qfr", "\u{1D514}"; -"Qopf", "\u{211A}"; -"Qscr", "\u{1D4AC}"; -"RBarr", "\u{2910}"; -"REG", "\u{00AE}"; -"Racute", "\u{0154}"; -"Rang", "\u{27EB}"; -"Rarr", "\u{21A0}"; -"Rarrtl", "\u{2916}"; -"Rcaron", "\u{0158}"; -"Rcedil", "\u{0156}"; -"Rcy", "\u{0420}"; -"Re", "\u{211C}"; -"ReverseElement", "\u{220B}"; -"ReverseEquilibrium", "\u{21CB}"; -"ReverseUpEquilibrium", "\u{296F}"; -"Rfr", "\u{211C}"; -"Rho", "\u{03A1}"; -"RightAngleBracket", "\u{27E9}"; -"RightArrow", "\u{2192}"; -"RightArrowBar", "\u{21E5}"; -"RightArrowLeftArrow", "\u{21C4}"; -"RightCeiling", "\u{2309}"; -"RightDoubleBracket", "\u{27E7}"; -"RightDownTeeVector", "\u{295D}"; -"RightDownVector", "\u{21C2}"; -"RightDownVectorBar", "\u{2955}"; -"RightFloor", "\u{230B}"; -"RightTee", "\u{22A2}"; -"RightTeeArrow", "\u{21A6}"; -"RightTeeVector", "\u{295B}"; -"RightTriangle", "\u{22B3}"; -"RightTriangleBar", "\u{29D0}"; -"RightTriangleEqual", "\u{22B5}"; -"RightUpDownVector", "\u{294F}"; -"RightUpTeeVector", "\u{295C}"; -"RightUpVector", "\u{21BE}"; -"RightUpVectorBar", "\u{2954}"; -"RightVector", "\u{21C0}"; -"RightVectorBar", "\u{2953}"; -"Rightarrow", "\u{21D2}"; -"Ropf", "\u{211D}"; -"RoundImplies", "\u{2970}"; -"Rrightarrow", "\u{21DB}"; -"Rscr", "\u{211B}"; -"Rsh", "\u{21B1}"; -"RuleDelayed", "\u{29F4}"; -"SHCHcy", "\u{0429}"; -"SHcy", "\u{0428}"; -"SOFTcy", "\u{042C}"; -"Sacute", "\u{015A}"; -"Sc", "\u{2ABC}"; -"Scaron", "\u{0160}"; -"Scedil", "\u{015E}"; -"Scirc", "\u{015C}"; -"Scy", "\u{0421}"; -"Sfr", "\u{1D516}"; -"ShortDownArrow", "\u{2193}"; -"ShortLeftArrow", "\u{2190}"; -"ShortRightArrow", "\u{2192}"; -"ShortUpArrow", "\u{2191}"; -"Sigma", "\u{03A3}"; -"SmallCircle", "\u{2218}"; -"Sopf", "\u{1D54A}"; -"Sqrt", "\u{221A}"; -"Square", "\u{25A1}"; -"SquareIntersection", "\u{2293}"; -"SquareSubset", "\u{228F}"; -"SquareSubsetEqual", "\u{2291}"; -"SquareSuperset", "\u{2290}"; -"SquareSupersetEqual", "\u{2292}"; -"SquareUnion", "\u{2294}"; -"Sscr", "\u{1D4AE}"; -"Star", "\u{22C6}"; -"Sub", "\u{22D0}"; -"Subset", "\u{22D0}"; -"SubsetEqual", "\u{2286}"; -"Succeeds", "\u{227B}"; -"SucceedsEqual", "\u{2AB0}"; -"SucceedsSlantEqual", "\u{227D}"; -"SucceedsTilde", "\u{227F}"; -"SuchThat", "\u{220B}"; -"Sum", "\u{2211}"; -"Sup", "\u{22D1}"; -"Superset", "\u{2283}"; -"SupersetEqual", "\u{2287}"; -"Supset", "\u{22D1}"; -"THORN", "\u{00DE}"; -"TRADE", "\u{2122}"; -"TSHcy", "\u{040B}"; -"TScy", "\u{0426}"; -"Tab", "\u{0009}"; -"Tau", "\u{03A4}"; -"Tcaron", "\u{0164}"; -"Tcedil", "\u{0162}"; -"Tcy", "\u{0422}"; -"Tfr", "\u{1D517}"; -"Therefore", "\u{2234}"; -"Theta", "\u{0398}"; -"ThickSpace", "\u{205F}\u{200A}"; -"ThinSpace", "\u{2009}"; -"Tilde", "\u{223C}"; -"TildeEqual", "\u{2243}"; -"TildeFullEqual", "\u{2245}"; -"TildeTilde", "\u{2248}"; -"Topf", "\u{1D54B}"; -"TripleDot", "\u{20DB}"; -"Tscr", "\u{1D4AF}"; -"Tstrok", "\u{0166}"; -"Uacute", "\u{00DA}"; -"Uarr", "\u{219F}"; -"Uarrocir", "\u{2949}"; -"Ubrcy", "\u{040E}"; -"Ubreve", "\u{016C}"; -"Ucirc", "\u{00DB}"; -"Ucy", "\u{0423}"; -"Udblac", "\u{0170}"; -"Ufr", "\u{1D518}"; -"Ugrave", "\u{00D9}"; -"Umacr", "\u{016A}"; -"UnderBar", "\u{005F}"; -"UnderBrace", "\u{23DF}"; -"UnderBracket", "\u{23B5}"; -"UnderParenthesis", "\u{23DD}"; -"Union", "\u{22C3}"; -"UnionPlus", "\u{228E}"; -"Uogon", "\u{0172}"; -"Uopf", "\u{1D54C}"; -"UpArrow", "\u{2191}"; -"UpArrowBar", "\u{2912}"; -"UpArrowDownArrow", "\u{21C5}"; -"UpDownArrow", "\u{2195}"; -"UpEquilibrium", "\u{296E}"; -"UpTee", "\u{22A5}"; -"UpTeeArrow", "\u{21A5}"; -"Uparrow", "\u{21D1}"; -"Updownarrow", "\u{21D5}"; -"UpperLeftArrow", "\u{2196}"; -"UpperRightArrow", "\u{2197}"; -"Upsi", "\u{03D2}"; -"Upsilon", "\u{03A5}"; -"Uring", "\u{016E}"; -"Uscr", "\u{1D4B0}"; -"Utilde", "\u{0168}"; -"Uuml", "\u{00DC}"; -"VDash", "\u{22AB}"; -"Vbar", "\u{2AEB}"; -"Vcy", "\u{0412}"; -"Vdash", "\u{22A9}"; -"Vdashl", "\u{2AE6}"; -"Vee", "\u{22C1}"; -"Verbar", "\u{2016}"; -"Vert", "\u{2016}"; -"VerticalBar", "\u{2223}"; -"VerticalLine", "\u{007C}"; -"VerticalSeparator", "\u{2758}"; -"VerticalTilde", "\u{2240}"; -"VeryThinSpace", "\u{200A}"; -"Vfr", "\u{1D519}"; -"Vopf", "\u{1D54D}"; -"Vscr", "\u{1D4B1}"; -"Vvdash", "\u{22AA}"; -"Wcirc", "\u{0174}"; -"Wedge", "\u{22C0}"; -"Wfr", "\u{1D51A}"; -"Wopf", "\u{1D54E}"; -"Wscr", "\u{1D4B2}"; -"Xfr", "\u{1D51B}"; -"Xi", "\u{039E}"; -"Xopf", "\u{1D54F}"; -"Xscr", "\u{1D4B3}"; -"YAcy", "\u{042F}"; -"YIcy", "\u{0407}"; -"YUcy", "\u{042E}"; -"Yacute", "\u{00DD}"; -"Ycirc", "\u{0176}"; -"Ycy", "\u{042B}"; -"Yfr", "\u{1D51C}"; -"Yopf", "\u{1D550}"; -"Yscr", "\u{1D4B4}"; -"Yuml", "\u{0178}"; -"ZHcy", "\u{0416}"; -"Zacute", "\u{0179}"; -"Zcaron", "\u{017D}"; -"Zcy", "\u{0417}"; -"Zdot", "\u{017B}"; -"ZeroWidthSpace", "\u{200B}"; -"Zeta", "\u{0396}"; -"Zfr", "\u{2128}"; -"Zopf", "\u{2124}"; -"Zscr", "\u{1D4B5}"; -"aacute", "\u{00E1}"; -"abreve", "\u{0103}"; -"ac", "\u{223E}"; -"acE", "\u{223E}\u{0333}"; -"acd", "\u{223F}"; -"acirc", "\u{00E2}"; -"acute", "\u{00B4}"; -"acy", "\u{0430}"; -"aelig", "\u{00E6}"; -"af", "\u{2061}"; -"afr", "\u{1D51E}"; -"agrave", "\u{00E0}"; -"alefsym", "\u{2135}"; -"aleph", "\u{2135}"; -"alpha", "\u{03B1}"; -"amacr", "\u{0101}"; -"amalg", "\u{2A3F}"; -"amp", "\u{0026}"; -"and", "\u{2227}"; -"andand", "\u{2A55}"; -"andd", "\u{2A5C}"; -"andslope", "\u{2A58}"; -"andv", "\u{2A5A}"; -"ang", "\u{2220}"; -"ange", "\u{29A4}"; -"angle", "\u{2220}"; -"angmsd", "\u{2221}"; -"angmsdaa", "\u{29A8}"; -"angmsdab", "\u{29A9}"; -"angmsdac", "\u{29AA}"; -"angmsdad", "\u{29AB}"; -"angmsdae", "\u{29AC}"; -"angmsdaf", "\u{29AD}"; -"angmsdag", "\u{29AE}"; -"angmsdah", "\u{29AF}"; -"angrt", "\u{221F}"; -"angrtvb", "\u{22BE}"; -"angrtvbd", "\u{299D}"; -"angsph", "\u{2222}"; -"angst", "\u{00C5}"; -"angzarr", "\u{237C}"; -"aogon", "\u{0105}"; -"aopf", "\u{1D552}"; -"ap", "\u{2248}"; -"apE", "\u{2A70}"; -"apacir", "\u{2A6F}"; -"ape", "\u{224A}"; -"apid", "\u{224B}"; -"apos", "\u{0027}"; -"approx", "\u{2248}"; -"approxeq", "\u{224A}"; -"aring", "\u{00E5}"; -"ascr", "\u{1D4B6}"; -"ast", "\u{002A}"; -"asymp", "\u{2248}"; -"asympeq", "\u{224D}"; -"atilde", "\u{00E3}"; -"auml", "\u{00E4}"; -"awconint", "\u{2233}"; -"awint", "\u{2A11}"; -"bNot", "\u{2AED}"; -"backcong", "\u{224C}"; -"backepsilon", "\u{03F6}"; -"backprime", "\u{2035}"; -"backsim", "\u{223D}"; -"backsimeq", "\u{22CD}"; -"barvee", "\u{22BD}"; -"barwed", "\u{2305}"; -"barwedge", "\u{2305}"; -"bbrk", "\u{23B5}"; -"bbrktbrk", "\u{23B6}"; -"bcong", "\u{224C}"; -"bcy", "\u{0431}"; -"bdquo", "\u{201E}"; -"becaus", "\u{2235}"; -"because", "\u{2235}"; -"bemptyv", "\u{29B0}"; -"bepsi", "\u{03F6}"; -"bernou", "\u{212C}"; -"beta", "\u{03B2}"; -"beth", "\u{2136}"; -"between", "\u{226C}"; -"bfr", "\u{1D51F}"; -"bigcap", "\u{22C2}"; -"bigcirc", "\u{25EF}"; -"bigcup", "\u{22C3}"; -"bigodot", "\u{2A00}"; -"bigoplus", "\u{2A01}"; -"bigotimes", "\u{2A02}"; -"bigsqcup", "\u{2A06}"; -"bigstar", "\u{2605}"; -"bigtriangledown", "\u{25BD}"; -"bigtriangleup", "\u{25B3}"; -"biguplus", "\u{2A04}"; -"bigvee", "\u{22C1}"; -"bigwedge", "\u{22C0}"; -"bkarow", "\u{290D}"; -"blacklozenge", "\u{29EB}"; -"blacksquare", "\u{25AA}"; -"blacktriangle", "\u{25B4}"; -"blacktriangledown", "\u{25BE}"; -"blacktriangleleft", "\u{25C2}"; -"blacktriangleright", "\u{25B8}"; -"blank", "\u{2423}"; -"blk12", "\u{2592}"; -"blk14", "\u{2591}"; -"blk34", "\u{2593}"; -"block", "\u{2588}"; -"bne", "\u{003D}\u{20E5}"; -"bnequiv", "\u{2261}\u{20E5}"; -"bnot", "\u{2310}"; -"bopf", "\u{1D553}"; -"bot", "\u{22A5}"; -"bottom", "\u{22A5}"; -"bowtie", "\u{22C8}"; -"boxDL", "\u{2557}"; -"boxDR", "\u{2554}"; -"boxDl", "\u{2556}"; -"boxDr", "\u{2553}"; -"boxH", "\u{2550}"; -"boxHD", "\u{2566}"; -"boxHU", "\u{2569}"; -"boxHd", "\u{2564}"; -"boxHu", "\u{2567}"; -"boxUL", "\u{255D}"; -"boxUR", "\u{255A}"; -"boxUl", "\u{255C}"; -"boxUr", "\u{2559}"; -"boxV", "\u{2551}"; -"boxVH", "\u{256C}"; -"boxVL", "\u{2563}"; -"boxVR", "\u{2560}"; -"boxVh", "\u{256B}"; -"boxVl", "\u{2562}"; -"boxVr", "\u{255F}"; -"boxbox", "\u{29C9}"; -"boxdL", "\u{2555}"; -"boxdR", "\u{2552}"; -"boxdl", "\u{2510}"; -"boxdr", "\u{250C}"; -"boxh", "\u{2500}"; -"boxhD", "\u{2565}"; -"boxhU", "\u{2568}"; -"boxhd", "\u{252C}"; -"boxhu", "\u{2534}"; -"boxminus", "\u{229F}"; -"boxplus", "\u{229E}"; -"boxtimes", "\u{22A0}"; -"boxuL", "\u{255B}"; -"boxuR", "\u{2558}"; -"boxul", "\u{2518}"; -"boxur", "\u{2514}"; -"boxv", "\u{2502}"; -"boxvH", "\u{256A}"; -"boxvL", "\u{2561}"; -"boxvR", "\u{255E}"; -"boxvh", "\u{253C}"; -"boxvl", "\u{2524}"; -"boxvr", "\u{251C}"; -"bprime", "\u{2035}"; -"breve", "\u{02D8}"; -"brvbar", "\u{00A6}"; -"bscr", "\u{1D4B7}"; -"bsemi", "\u{204F}"; -"bsim", "\u{223D}"; -"bsime", "\u{22CD}"; -"bsol", "\u{005C}"; -"bsolb", "\u{29C5}"; -"bsolhsub", "\u{27C8}"; -"bull", "\u{2022}"; -"bullet", "\u{2022}"; -"bump", "\u{224E}"; -"bumpE", "\u{2AAE}"; -"bumpe", "\u{224F}"; -"bumpeq", "\u{224F}"; -"cacute", "\u{0107}"; -"cap", "\u{2229}"; -"capand", "\u{2A44}"; -"capbrcup", "\u{2A49}"; -"capcap", "\u{2A4B}"; -"capcup", "\u{2A47}"; -"capdot", "\u{2A40}"; -"caps", "\u{2229}\u{FE00}"; -"caret", "\u{2041}"; -"caron", "\u{02C7}"; -"ccaps", "\u{2A4D}"; -"ccaron", "\u{010D}"; -"ccedil", "\u{00E7}"; -"ccirc", "\u{0109}"; -"ccups", "\u{2A4C}"; -"ccupssm", "\u{2A50}"; -"cdot", "\u{010B}"; -"cedil", "\u{00B8}"; -"cemptyv", "\u{29B2}"; -"cent", "\u{00A2}"; -"centerdot", "\u{00B7}"; -"cfr", "\u{1D520}"; -"chcy", "\u{0447}"; -"check", "\u{2713}"; -"checkmark", "\u{2713}"; -"chi", "\u{03C7}"; -"cir", "\u{25CB}"; -"cirE", "\u{29C3}"; -"circ", "\u{02C6}"; -"circeq", "\u{2257}"; -"circlearrowleft", "\u{21BA}"; -"circlearrowright", "\u{21BB}"; -"circledR", "\u{00AE}"; -"circledS", "\u{24C8}"; -"circledast", "\u{229B}"; -"circledcirc", "\u{229A}"; -"circleddash", "\u{229D}"; -"cire", "\u{2257}"; -"cirfnint", "\u{2A10}"; -"cirmid", "\u{2AEF}"; -"cirscir", "\u{29C2}"; -"clubs", "\u{2663}"; -"clubsuit", "\u{2663}"; -"colon", "\u{003A}"; -"colone", "\u{2254}"; -"coloneq", "\u{2254}"; -"comma", "\u{002C}"; -"commat", "\u{0040}"; -"comp", "\u{2201}"; -"compfn", "\u{2218}"; -"complement", "\u{2201}"; -"complexes", "\u{2102}"; -"cong", "\u{2245}"; -"congdot", "\u{2A6D}"; -"conint", "\u{222E}"; -"copf", "\u{1D554}"; -"coprod", "\u{2210}"; -"copy", "\u{00A9}"; -"copysr", "\u{2117}"; -"crarr", "\u{21B5}"; -"cross", "\u{2717}"; -"cscr", "\u{1D4B8}"; -"csub", "\u{2ACF}"; -"csube", "\u{2AD1}"; -"csup", "\u{2AD0}"; -"csupe", "\u{2AD2}"; -"ctdot", "\u{22EF}"; -"cudarrl", "\u{2938}"; -"cudarrr", "\u{2935}"; -"cuepr", "\u{22DE}"; -"cuesc", "\u{22DF}"; -"cularr", "\u{21B6}"; -"cularrp", "\u{293D}"; -"cup", "\u{222A}"; -"cupbrcap", "\u{2A48}"; -"cupcap", "\u{2A46}"; -"cupcup", "\u{2A4A}"; -"cupdot", "\u{228D}"; -"cupor", "\u{2A45}"; -"cups", "\u{222A}\u{FE00}"; -"curarr", "\u{21B7}"; -"curarrm", "\u{293C}"; -"curlyeqprec", "\u{22DE}"; -"curlyeqsucc", "\u{22DF}"; -"curlyvee", "\u{22CE}"; -"curlywedge", "\u{22CF}"; -"curren", "\u{00A4}"; -"curvearrowleft", "\u{21B6}"; -"curvearrowright", "\u{21B7}"; -"cuvee", "\u{22CE}"; -"cuwed", "\u{22CF}"; -"cwconint", "\u{2232}"; -"cwint", "\u{2231}"; -"cylcty", "\u{232D}"; -"dArr", "\u{21D3}"; -"dHar", "\u{2965}"; -"dagger", "\u{2020}"; -"daleth", "\u{2138}"; -"darr", "\u{2193}"; -"dash", "\u{2010}"; -"dashv", "\u{22A3}"; -"dbkarow", "\u{290F}"; -"dblac", "\u{02DD}"; -"dcaron", "\u{010F}"; -"dcy", "\u{0434}"; -"dd", "\u{2146}"; -"ddagger", "\u{2021}"; -"ddarr", "\u{21CA}"; -"ddotseq", "\u{2A77}"; -"deg", "\u{00B0}"; -"delta", "\u{03B4}"; -"demptyv", "\u{29B1}"; -"dfisht", "\u{297F}"; -"dfr", "\u{1D521}"; -"dharl", "\u{21C3}"; -"dharr", "\u{21C2}"; -"diam", "\u{22C4}"; -"diamond", "\u{22C4}"; -"diamondsuit", "\u{2666}"; -"diams", "\u{2666}"; -"die", "\u{00A8}"; -"digamma", "\u{03DD}"; -"disin", "\u{22F2}"; -"div", "\u{00F7}"; -"divide", "\u{00F7}"; -"divideontimes", "\u{22C7}"; -"divonx", "\u{22C7}"; -"djcy", "\u{0452}"; -"dlcorn", "\u{231E}"; -"dlcrop", "\u{230D}"; -"dollar", "\u{0024}"; -"dopf", "\u{1D555}"; -"dot", "\u{02D9}"; -"doteq", "\u{2250}"; -"doteqdot", "\u{2251}"; -"dotminus", "\u{2238}"; -"dotplus", "\u{2214}"; -"dotsquare", "\u{22A1}"; -"doublebarwedge", "\u{2306}"; -"downarrow", "\u{2193}"; -"downdownarrows", "\u{21CA}"; -"downharpoonleft", "\u{21C3}"; -"downharpoonright", "\u{21C2}"; -"drbkarow", "\u{2910}"; -"drcorn", "\u{231F}"; -"drcrop", "\u{230C}"; -"dscr", "\u{1D4B9}"; -"dscy", "\u{0455}"; -"dsol", "\u{29F6}"; -"dstrok", "\u{0111}"; -"dtdot", "\u{22F1}"; -"dtri", "\u{25BF}"; -"dtrif", "\u{25BE}"; -"duarr", "\u{21F5}"; -"duhar", "\u{296F}"; -"dwangle", "\u{29A6}"; -"dzcy", "\u{045F}"; -"dzigrarr", "\u{27FF}"; -"eDDot", "\u{2A77}"; -"eDot", "\u{2251}"; -"eacute", "\u{00E9}"; -"easter", "\u{2A6E}"; -"ecaron", "\u{011B}"; -"ecir", "\u{2256}"; -"ecirc", "\u{00EA}"; -"ecolon", "\u{2255}"; -"ecy", "\u{044D}"; -"edot", "\u{0117}"; -"ee", "\u{2147}"; -"efDot", "\u{2252}"; -"efr", "\u{1D522}"; -"eg", "\u{2A9A}"; -"egrave", "\u{00E8}"; -"egs", "\u{2A96}"; -"egsdot", "\u{2A98}"; -"el", "\u{2A99}"; -"elinters", "\u{23E7}"; -"ell", "\u{2113}"; -"els", "\u{2A95}"; -"elsdot", "\u{2A97}"; -"emacr", "\u{0113}"; -"empty", "\u{2205}"; -"emptyset", "\u{2205}"; -"emptyv", "\u{2205}"; -"emsp13", "\u{2004}"; -"emsp14", "\u{2005}"; -"emsp", "\u{2003}"; -"eng", "\u{014B}"; -"ensp", "\u{2002}"; -"eogon", "\u{0119}"; -"eopf", "\u{1D556}"; -"epar", "\u{22D5}"; -"eparsl", "\u{29E3}"; -"eplus", "\u{2A71}"; -"epsi", "\u{03B5}"; -"epsilon", "\u{03B5}"; -"epsiv", "\u{03F5}"; -"eqcirc", "\u{2256}"; -"eqcolon", "\u{2255}"; -"eqsim", "\u{2242}"; -"eqslantgtr", "\u{2A96}"; -"eqslantless", "\u{2A95}"; -"equals", "\u{003D}"; -"equest", "\u{225F}"; -"equiv", "\u{2261}"; -"equivDD", "\u{2A78}"; -"eqvparsl", "\u{29E5}"; -"erDot", "\u{2253}"; -"erarr", "\u{2971}"; -"escr", "\u{212F}"; -"esdot", "\u{2250}"; -"esim", "\u{2242}"; -"eta", "\u{03B7}"; -"eth", "\u{00F0}"; -"euml", "\u{00EB}"; -"euro", "\u{20AC}"; -"excl", "\u{0021}"; -"exist", "\u{2203}"; -"expectation", "\u{2130}"; -"exponentiale", "\u{2147}"; -"fallingdotseq", "\u{2252}"; -"fcy", "\u{0444}"; -"female", "\u{2640}"; -"ffilig", "\u{FB03}"; -"fflig", "\u{FB00}"; -"ffllig", "\u{FB04}"; -"ffr", "\u{1D523}"; -"filig", "\u{FB01}"; -"fjlig", "\u{0066}\u{006A}"; -"flat", "\u{266D}"; -"fllig", "\u{FB02}"; -"fltns", "\u{25B1}"; -"fnof", "\u{0192}"; -"fopf", "\u{1D557}"; -"forall", "\u{2200}"; -"fork", "\u{22D4}"; -"forkv", "\u{2AD9}"; -"fpartint", "\u{2A0D}"; -"frac12", "\u{00BD}"; -"frac13", "\u{2153}"; -"frac14", "\u{00BC}"; -"frac15", "\u{2155}"; -"frac16", "\u{2159}"; -"frac18", "\u{215B}"; -"frac23", "\u{2154}"; -"frac25", "\u{2156}"; -"frac34", "\u{00BE}"; -"frac35", "\u{2157}"; -"frac38", "\u{215C}"; -"frac45", "\u{2158}"; -"frac56", "\u{215A}"; -"frac58", "\u{215D}"; -"frac78", "\u{215E}"; -"frasl", "\u{2044}"; -"frown", "\u{2322}"; -"fscr", "\u{1D4BB}"; -"gE", "\u{2267}"; -"gEl", "\u{2A8C}"; -"gacute", "\u{01F5}"; -"gamma", "\u{03B3}"; -"gammad", "\u{03DD}"; -"gap", "\u{2A86}"; -"gbreve", "\u{011F}"; -"gcirc", "\u{011D}"; -"gcy", "\u{0433}"; -"gdot", "\u{0121}"; -"ge", "\u{2265}"; -"gel", "\u{22DB}"; -"geq", "\u{2265}"; -"geqq", "\u{2267}"; -"geqslant", "\u{2A7E}"; -"ges", "\u{2A7E}"; -"gescc", "\u{2AA9}"; -"gesdot", "\u{2A80}"; -"gesdoto", "\u{2A82}"; -"gesdotol", "\u{2A84}"; -"gesl", "\u{22DB}\u{FE00}"; -"gesles", "\u{2A94}"; -"gfr", "\u{1D524}"; -"gg", "\u{226B}"; -"ggg", "\u{22D9}"; -"gimel", "\u{2137}"; -"gjcy", "\u{0453}"; -"gl", "\u{2277}"; -"glE", "\u{2A92}"; -"gla", "\u{2AA5}"; -"glj", "\u{2AA4}"; -"gnE", "\u{2269}"; -"gnap", "\u{2A8A}"; -"gnapprox", "\u{2A8A}"; -"gne", "\u{2A88}"; -"gneq", "\u{2A88}"; -"gneqq", "\u{2269}"; -"gnsim", "\u{22E7}"; -"gopf", "\u{1D558}"; -"grave", "\u{0060}"; -"gscr", "\u{210A}"; -"gsim", "\u{2273}"; -"gsime", "\u{2A8E}"; -"gsiml", "\u{2A90}"; -"gt", "\u{003E}"; -"gtcc", "\u{2AA7}"; -"gtcir", "\u{2A7A}"; -"gtdot", "\u{22D7}"; -"gtlPar", "\u{2995}"; -"gtquest", "\u{2A7C}"; -"gtrapprox", "\u{2A86}"; -"gtrarr", "\u{2978}"; -"gtrdot", "\u{22D7}"; -"gtreqless", "\u{22DB}"; -"gtreqqless", "\u{2A8C}"; -"gtrless", "\u{2277}"; -"gtrsim", "\u{2273}"; -"gvertneqq", "\u{2269}\u{FE00}"; -"gvnE", "\u{2269}\u{FE00}"; -"hArr", "\u{21D4}"; -"hairsp", "\u{200A}"; -"half", "\u{00BD}"; -"hamilt", "\u{210B}"; -"hardcy", "\u{044A}"; -"harr", "\u{2194}"; -"harrcir", "\u{2948}"; -"harrw", "\u{21AD}"; -"hbar", "\u{210F}"; -"hcirc", "\u{0125}"; -"hearts", "\u{2665}"; -"heartsuit", "\u{2665}"; -"hellip", "\u{2026}"; -"hercon", "\u{22B9}"; -"hfr", "\u{1D525}"; -"hksearow", "\u{2925}"; -"hkswarow", "\u{2926}"; -"hoarr", "\u{21FF}"; -"homtht", "\u{223B}"; -"hookleftarrow", "\u{21A9}"; -"hookrightarrow", "\u{21AA}"; -"hopf", "\u{1D559}"; -"horbar", "\u{2015}"; -"hscr", "\u{1D4BD}"; -"hslash", "\u{210F}"; -"hstrok", "\u{0127}"; -"hybull", "\u{2043}"; -"hyphen", "\u{2010}"; -"iacute", "\u{00ED}"; -"ic", "\u{2063}"; -"icirc", "\u{00EE}"; -"icy", "\u{0438}"; -"iecy", "\u{0435}"; -"iexcl", "\u{00A1}"; -"iff", "\u{21D4}"; -"ifr", "\u{1D526}"; -"igrave", "\u{00EC}"; -"ii", "\u{2148}"; -"iiiint", "\u{2A0C}"; -"iiint", "\u{222D}"; -"iinfin", "\u{29DC}"; -"iiota", "\u{2129}"; -"ijlig", "\u{0133}"; -"imacr", "\u{012B}"; -"image", "\u{2111}"; -"imagline", "\u{2110}"; -"imagpart", "\u{2111}"; -"imath", "\u{0131}"; -"imof", "\u{22B7}"; -"imped", "\u{01B5}"; -"in", "\u{2208}"; -"incare", "\u{2105}"; -"infin", "\u{221E}"; -"infintie", "\u{29DD}"; -"inodot", "\u{0131}"; -"int", "\u{222B}"; -"intcal", "\u{22BA}"; -"integers", "\u{2124}"; -"intercal", "\u{22BA}"; -"intlarhk", "\u{2A17}"; -"intprod", "\u{2A3C}"; -"iocy", "\u{0451}"; -"iogon", "\u{012F}"; -"iopf", "\u{1D55A}"; -"iota", "\u{03B9}"; -"iprod", "\u{2A3C}"; -"iquest", "\u{00BF}"; -"iscr", "\u{1D4BE}"; -"isin", "\u{2208}"; -"isinE", "\u{22F9}"; -"isindot", "\u{22F5}"; -"isins", "\u{22F4}"; -"isinsv", "\u{22F3}"; -"isinv", "\u{2208}"; -"it", "\u{2062}"; -"itilde", "\u{0129}"; -"iukcy", "\u{0456}"; -"iuml", "\u{00EF}"; -"jcirc", "\u{0135}"; -"jcy", "\u{0439}"; -"jfr", "\u{1D527}"; -"jmath", "\u{0237}"; -"jopf", "\u{1D55B}"; -"jscr", "\u{1D4BF}"; -"jsercy", "\u{0458}"; -"jukcy", "\u{0454}"; -"kappa", "\u{03BA}"; -"kappav", "\u{03F0}"; -"kcedil", "\u{0137}"; -"kcy", "\u{043A}"; -"kfr", "\u{1D528}"; -"kgreen", "\u{0138}"; -"khcy", "\u{0445}"; -"kjcy", "\u{045C}"; -"kopf", "\u{1D55C}"; -"kscr", "\u{1D4C0}"; -"lAarr", "\u{21DA}"; -"lArr", "\u{21D0}"; -"lAtail", "\u{291B}"; -"lBarr", "\u{290E}"; -"lE", "\u{2266}"; -"lEg", "\u{2A8B}"; -"lHar", "\u{2962}"; -"lacute", "\u{013A}"; -"laemptyv", "\u{29B4}"; -"lagran", "\u{2112}"; -"lambda", "\u{03BB}"; -"lang", "\u{27E8}"; -"langd", "\u{2991}"; -"langle", "\u{27E8}"; -"lap", "\u{2A85}"; -"laquo", "\u{00AB}"; -"larr", "\u{2190}"; -"larrb", "\u{21E4}"; -"larrbfs", "\u{291F}"; -"larrfs", "\u{291D}"; -"larrhk", "\u{21A9}"; -"larrlp", "\u{21AB}"; -"larrpl", "\u{2939}"; -"larrsim", "\u{2973}"; -"larrtl", "\u{21A2}"; -"lat", "\u{2AAB}"; -"latail", "\u{2919}"; -"late", "\u{2AAD}"; -"lates", "\u{2AAD}\u{FE00}"; -"lbarr", "\u{290C}"; -"lbbrk", "\u{2772}"; -"lbrace", "\u{007B}"; -"lbrack", "\u{005B}"; -"lbrke", "\u{298B}"; -"lbrksld", "\u{298F}"; -"lbrkslu", "\u{298D}"; -"lcaron", "\u{013E}"; -"lcedil", "\u{013C}"; -"lceil", "\u{2308}"; -"lcub", "\u{007B}"; -"lcy", "\u{043B}"; -"ldca", "\u{2936}"; -"ldquo", "\u{201C}"; -"ldquor", "\u{201E}"; -"ldrdhar", "\u{2967}"; -"ldrushar", "\u{294B}"; -"ldsh", "\u{21B2}"; -"le", "\u{2264}"; -"leftarrow", "\u{2190}"; -"leftarrowtail", "\u{21A2}"; -"leftharpoondown", "\u{21BD}"; -"leftharpoonup", "\u{21BC}"; -"leftleftarrows", "\u{21C7}"; -"leftrightarrow", "\u{2194}"; -"leftrightarrows", "\u{21C6}"; -"leftrightharpoons", "\u{21CB}"; -"leftrightsquigarrow", "\u{21AD}"; -"leftthreetimes", "\u{22CB}"; -"leg", "\u{22DA}"; -"leq", "\u{2264}"; -"leqq", "\u{2266}"; -"leqslant", "\u{2A7D}"; -"les", "\u{2A7D}"; -"lescc", "\u{2AA8}"; -"lesdot", "\u{2A7F}"; -"lesdoto", "\u{2A81}"; -"lesdotor", "\u{2A83}"; -"lesg", "\u{22DA}\u{FE00}"; -"lesges", "\u{2A93}"; -"lessapprox", "\u{2A85}"; -"lessdot", "\u{22D6}"; -"lesseqgtr", "\u{22DA}"; -"lesseqqgtr", "\u{2A8B}"; -"lessgtr", "\u{2276}"; -"lesssim", "\u{2272}"; -"lfisht", "\u{297C}"; -"lfloor", "\u{230A}"; -"lfr", "\u{1D529}"; -"lg", "\u{2276}"; -"lgE", "\u{2A91}"; -"lhard", "\u{21BD}"; -"lharu", "\u{21BC}"; -"lharul", "\u{296A}"; -"lhblk", "\u{2584}"; -"ljcy", "\u{0459}"; -"ll", "\u{226A}"; -"llarr", "\u{21C7}"; -"llcorner", "\u{231E}"; -"llhard", "\u{296B}"; -"lltri", "\u{25FA}"; -"lmidot", "\u{0140}"; -"lmoust", "\u{23B0}"; -"lmoustache", "\u{23B0}"; -"lnE", "\u{2268}"; -"lnap", "\u{2A89}"; -"lnapprox", "\u{2A89}"; -"lne", "\u{2A87}"; -"lneq", "\u{2A87}"; -"lneqq", "\u{2268}"; -"lnsim", "\u{22E6}"; -"loang", "\u{27EC}"; -"loarr", "\u{21FD}"; -"lobrk", "\u{27E6}"; -"longleftarrow", "\u{27F5}"; -"longleftrightarrow", "\u{27F7}"; -"longmapsto", "\u{27FC}"; -"longrightarrow", "\u{27F6}"; -"looparrowleft", "\u{21AB}"; -"looparrowright", "\u{21AC}"; -"lopar", "\u{2985}"; -"lopf", "\u{1D55D}"; -"loplus", "\u{2A2D}"; -"lotimes", "\u{2A34}"; -"lowast", "\u{2217}"; -"lowbar", "\u{005F}"; -"loz", "\u{25CA}"; -"lozenge", "\u{25CA}"; -"lozf", "\u{29EB}"; -"lpar", "\u{0028}"; -"lparlt", "\u{2993}"; -"lrarr", "\u{21C6}"; -"lrcorner", "\u{231F}"; -"lrhar", "\u{21CB}"; -"lrhard", "\u{296D}"; -"lrm", "\u{200E}"; -"lrtri", "\u{22BF}"; -"lsaquo", "\u{2039}"; -"lscr", "\u{1D4C1}"; -"lsh", "\u{21B0}"; -"lsim", "\u{2272}"; -"lsime", "\u{2A8D}"; -"lsimg", "\u{2A8F}"; -"lsqb", "\u{005B}"; -"lsquo", "\u{2018}"; -"lsquor", "\u{201A}"; -"lstrok", "\u{0142}"; -"lt", "\u{003C}"; -"ltcc", "\u{2AA6}"; -"ltcir", "\u{2A79}"; -"ltdot", "\u{22D6}"; -"lthree", "\u{22CB}"; -"ltimes", "\u{22C9}"; -"ltlarr", "\u{2976}"; -"ltquest", "\u{2A7B}"; -"ltrPar", "\u{2996}"; -"ltri", "\u{25C3}"; -"ltrie", "\u{22B4}"; -"ltrif", "\u{25C2}"; -"lurdshar", "\u{294A}"; -"luruhar", "\u{2966}"; -"lvertneqq", "\u{2268}\u{FE00}"; -"lvnE", "\u{2268}\u{FE00}"; -"mDDot", "\u{223A}"; -"macr", "\u{00AF}"; -"male", "\u{2642}"; -"malt", "\u{2720}"; -"maltese", "\u{2720}"; -"map", "\u{21A6}"; -"mapsto", "\u{21A6}"; -"mapstodown", "\u{21A7}"; -"mapstoleft", "\u{21A4}"; -"mapstoup", "\u{21A5}"; -"marker", "\u{25AE}"; -"mcomma", "\u{2A29}"; -"mcy", "\u{043C}"; -"mdash", "\u{2014}"; -"measuredangle", "\u{2221}"; -"mfr", "\u{1D52A}"; -"mho", "\u{2127}"; -"micro", "\u{00B5}"; -"mid", "\u{2223}"; -"midast", "\u{002A}"; -"midcir", "\u{2AF0}"; -"middot", "\u{00B7}"; -"minus", "\u{2212}"; -"minusb", "\u{229F}"; -"minusd", "\u{2238}"; -"minusdu", "\u{2A2A}"; -"mlcp", "\u{2ADB}"; -"mldr", "\u{2026}"; -"mnplus", "\u{2213}"; -"models", "\u{22A7}"; -"mopf", "\u{1D55E}"; -"mp", "\u{2213}"; -"mscr", "\u{1D4C2}"; -"mstpos", "\u{223E}"; -"mu", "\u{03BC}"; -"multimap", "\u{22B8}"; -"mumap", "\u{22B8}"; -"nGg", "\u{22D9}\u{0338}"; -"nGt", "\u{226B}\u{20D2}"; -"nGtv", "\u{226B}\u{0338}"; -"nLeftarrow", "\u{21CD}"; -"nLeftrightarrow", "\u{21CE}"; -"nLl", "\u{22D8}\u{0338}"; -"nLt", "\u{226A}\u{20D2}"; -"nLtv", "\u{226A}\u{0338}"; -"nRightarrow", "\u{21CF}"; -"nVDash", "\u{22AF}"; -"nVdash", "\u{22AE}"; -"nabla", "\u{2207}"; -"nacute", "\u{0144}"; -"nang", "\u{2220}\u{20D2}"; -"nap", "\u{2249}"; -"napE", "\u{2A70}\u{0338}"; -"napid", "\u{224B}\u{0338}"; -"napos", "\u{0149}"; -"napprox", "\u{2249}"; -"natur", "\u{266E}"; -"natural", "\u{266E}"; -"naturals", "\u{2115}"; -"nbsp", "\u{00A0}"; -"nbump", "\u{224E}\u{0338}"; -"nbumpe", "\u{224F}\u{0338}"; -"ncap", "\u{2A43}"; -"ncaron", "\u{0148}"; -"ncedil", "\u{0146}"; -"ncong", "\u{2247}"; -"ncongdot", "\u{2A6D}\u{0338}"; -"ncup", "\u{2A42}"; -"ncy", "\u{043D}"; -"ndash", "\u{2013}"; -"ne", "\u{2260}"; -"neArr", "\u{21D7}"; -"nearhk", "\u{2924}"; -"nearr", "\u{2197}"; -"nearrow", "\u{2197}"; -"nedot", "\u{2250}\u{0338}"; -"nequiv", "\u{2262}"; -"nesear", "\u{2928}"; -"nesim", "\u{2242}\u{0338}"; -"nexist", "\u{2204}"; -"nexists", "\u{2204}"; -"nfr", "\u{1D52B}"; -"ngE", "\u{2267}\u{0338}"; -"nge", "\u{2271}"; -"ngeq", "\u{2271}"; -"ngeqq", "\u{2267}\u{0338}"; -"ngeqslant", "\u{2A7E}\u{0338}"; -"nges", "\u{2A7E}\u{0338}"; -"ngsim", "\u{2275}"; -"ngt", "\u{226F}"; -"ngtr", "\u{226F}"; -"nhArr", "\u{21CE}"; -"nharr", "\u{21AE}"; -"nhpar", "\u{2AF2}"; -"ni", "\u{220B}"; -"nis", "\u{22FC}"; -"nisd", "\u{22FA}"; -"niv", "\u{220B}"; -"njcy", "\u{045A}"; -"nlArr", "\u{21CD}"; -"nlE", "\u{2266}\u{0338}"; -"nlarr", "\u{219A}"; -"nldr", "\u{2025}"; -"nle", "\u{2270}"; -"nleftarrow", "\u{219A}"; -"nleftrightarrow", "\u{21AE}"; -"nleq", "\u{2270}"; -"nleqq", "\u{2266}\u{0338}"; -"nleqslant", "\u{2A7D}\u{0338}"; -"nles", "\u{2A7D}\u{0338}"; -"nless", "\u{226E}"; -"nlsim", "\u{2274}"; -"nlt", "\u{226E}"; -"nltri", "\u{22EA}"; -"nltrie", "\u{22EC}"; -"nmid", "\u{2224}"; -"nopf", "\u{1D55F}"; -"not", "\u{00AC}"; -"notin", "\u{2209}"; -"notinE", "\u{22F9}\u{0338}"; -"notindot", "\u{22F5}\u{0338}"; -"notinva", "\u{2209}"; -"notinvb", "\u{22F7}"; -"notinvc", "\u{22F6}"; -"notni", "\u{220C}"; -"notniva", "\u{220C}"; -"notnivb", "\u{22FE}"; -"notnivc", "\u{22FD}"; -"npar", "\u{2226}"; -"nparallel", "\u{2226}"; -"nparsl", "\u{2AFD}\u{20E5}"; -"npart", "\u{2202}\u{0338}"; -"npolint", "\u{2A14}"; -"npr", "\u{2280}"; -"nprcue", "\u{22E0}"; -"npre", "\u{2AAF}\u{0338}"; -"nprec", "\u{2280}"; -"npreceq", "\u{2AAF}\u{0338}"; -"nrArr", "\u{21CF}"; -"nrarr", "\u{219B}"; -"nrarrc", "\u{2933}\u{0338}"; -"nrarrw", "\u{219D}\u{0338}"; -"nrightarrow", "\u{219B}"; -"nrtri", "\u{22EB}"; -"nrtrie", "\u{22ED}"; -"nsc", "\u{2281}"; -"nsccue", "\u{22E1}"; -"nsce", "\u{2AB0}\u{0338}"; -"nscr", "\u{1D4C3}"; -"nshortmid", "\u{2224}"; -"nshortparallel", "\u{2226}"; -"nsim", "\u{2241}"; -"nsime", "\u{2244}"; -"nsimeq", "\u{2244}"; -"nsmid", "\u{2224}"; -"nspar", "\u{2226}"; -"nsqsube", "\u{22E2}"; -"nsqsupe", "\u{22E3}"; -"nsub", "\u{2284}"; -"nsubE", "\u{2AC5}\u{0338}"; -"nsube", "\u{2288}"; -"nsubset", "\u{2282}\u{20D2}"; -"nsubseteq", "\u{2288}"; -"nsubseteqq", "\u{2AC5}\u{0338}"; -"nsucc", "\u{2281}"; -"nsucceq", "\u{2AB0}\u{0338}"; -"nsup", "\u{2285}"; -"nsupE", "\u{2AC6}\u{0338}"; -"nsupe", "\u{2289}"; -"nsupset", "\u{2283}\u{20D2}"; -"nsupseteq", "\u{2289}"; -"nsupseteqq", "\u{2AC6}\u{0338}"; -"ntgl", "\u{2279}"; -"ntilde", "\u{00F1}"; -"ntlg", "\u{2278}"; -"ntriangleleft", "\u{22EA}"; -"ntrianglelefteq", "\u{22EC}"; -"ntriangleright", "\u{22EB}"; -"ntrianglerighteq", "\u{22ED}"; -"nu", "\u{03BD}"; -"num", "\u{0023}"; -"numero", "\u{2116}"; -"numsp", "\u{2007}"; -"nvDash", "\u{22AD}"; -"nvHarr", "\u{2904}"; -"nvap", "\u{224D}\u{20D2}"; -"nvdash", "\u{22AC}"; -"nvge", "\u{2265}\u{20D2}"; -"nvgt", "\u{003E}\u{20D2}"; -"nvinfin", "\u{29DE}"; -"nvlArr", "\u{2902}"; -"nvle", "\u{2264}\u{20D2}"; -"nvlt", "\u{003C}\u{20D2}"; -"nvltrie", "\u{22B4}\u{20D2}"; -"nvrArr", "\u{2903}"; -"nvrtrie", "\u{22B5}\u{20D2}"; -"nvsim", "\u{223C}\u{20D2}"; -"nwArr", "\u{21D6}"; -"nwarhk", "\u{2923}"; -"nwarr", "\u{2196}"; -"nwarrow", "\u{2196}"; -"nwnear", "\u{2927}"; -"oS", "\u{24C8}"; -"oacute", "\u{00F3}"; -"oast", "\u{229B}"; -"ocir", "\u{229A}"; -"ocirc", "\u{00F4}"; -"ocy", "\u{043E}"; -"odash", "\u{229D}"; -"odblac", "\u{0151}"; -"odiv", "\u{2A38}"; -"odot", "\u{2299}"; -"odsold", "\u{29BC}"; -"oelig", "\u{0153}"; -"ofcir", "\u{29BF}"; -"ofr", "\u{1D52C}"; -"ogon", "\u{02DB}"; -"ograve", "\u{00F2}"; -"ogt", "\u{29C1}"; -"ohbar", "\u{29B5}"; -"ohm", "\u{03A9}"; -"oint", "\u{222E}"; -"olarr", "\u{21BA}"; -"olcir", "\u{29BE}"; -"olcross", "\u{29BB}"; -"oline", "\u{203E}"; -"olt", "\u{29C0}"; -"omacr", "\u{014D}"; -"omega", "\u{03C9}"; -"omicron", "\u{03BF}"; -"omid", "\u{29B6}"; -"ominus", "\u{2296}"; -"oopf", "\u{1D560}"; -"opar", "\u{29B7}"; -"operp", "\u{29B9}"; -"oplus", "\u{2295}"; -"or", "\u{2228}"; -"orarr", "\u{21BB}"; -"ord", "\u{2A5D}"; -"order", "\u{2134}"; -"orderof", "\u{2134}"; -"ordf", "\u{00AA}"; -"ordm", "\u{00BA}"; -"origof", "\u{22B6}"; -"oror", "\u{2A56}"; -"orslope", "\u{2A57}"; -"orv", "\u{2A5B}"; -"oscr", "\u{2134}"; -"oslash", "\u{00F8}"; -"osol", "\u{2298}"; -"otilde", "\u{00F5}"; -"otimes", "\u{2297}"; -"otimesas", "\u{2A36}"; -"ouml", "\u{00F6}"; -"ovbar", "\u{233D}"; -"par", "\u{2225}"; -"para", "\u{00B6}"; -"parallel", "\u{2225}"; -"parsim", "\u{2AF3}"; -"parsl", "\u{2AFD}"; -"part", "\u{2202}"; -"pcy", "\u{043F}"; -"percnt", "\u{0025}"; -"period", "\u{002E}"; -"permil", "\u{2030}"; -"perp", "\u{22A5}"; -"pertenk", "\u{2031}"; -"pfr", "\u{1D52D}"; -"phi", "\u{03C6}"; -"phiv", "\u{03D5}"; -"phmmat", "\u{2133}"; -"phone", "\u{260E}"; -"pi", "\u{03C0}"; -"pitchfork", "\u{22D4}"; -"piv", "\u{03D6}"; -"planck", "\u{210F}"; -"planckh", "\u{210E}"; -"plankv", "\u{210F}"; -"plus", "\u{002B}"; -"plusacir", "\u{2A23}"; -"plusb", "\u{229E}"; -"pluscir", "\u{2A22}"; -"plusdo", "\u{2214}"; -"plusdu", "\u{2A25}"; -"pluse", "\u{2A72}"; -"plusmn", "\u{00B1}"; -"plussim", "\u{2A26}"; -"plustwo", "\u{2A27}"; -"pm", "\u{00B1}"; -"pointint", "\u{2A15}"; -"popf", "\u{1D561}"; -"pound", "\u{00A3}"; -"pr", "\u{227A}"; -"prE", "\u{2AB3}"; -"prap", "\u{2AB7}"; -"prcue", "\u{227C}"; -"pre", "\u{2AAF}"; -"prec", "\u{227A}"; -"precapprox", "\u{2AB7}"; -"preccurlyeq", "\u{227C}"; -"preceq", "\u{2AAF}"; -"precnapprox", "\u{2AB9}"; -"precneqq", "\u{2AB5}"; -"precnsim", "\u{22E8}"; -"precsim", "\u{227E}"; -"prime", "\u{2032}"; -"primes", "\u{2119}"; -"prnE", "\u{2AB5}"; -"prnap", "\u{2AB9}"; -"prnsim", "\u{22E8}"; -"prod", "\u{220F}"; -"profalar", "\u{232E}"; -"profline", "\u{2312}"; -"profsurf", "\u{2313}"; -"prop", "\u{221D}"; -"propto", "\u{221D}"; -"prsim", "\u{227E}"; -"prurel", "\u{22B0}"; -"pscr", "\u{1D4C5}"; -"psi", "\u{03C8}"; -"puncsp", "\u{2008}"; -"qfr", "\u{1D52E}"; -"qint", "\u{2A0C}"; -"qopf", "\u{1D562}"; -"qprime", "\u{2057}"; -"qscr", "\u{1D4C6}"; -"quaternions", "\u{210D}"; -"quatint", "\u{2A16}"; -"quest", "\u{003F}"; -"questeq", "\u{225F}"; -"quot", "\u{0022}"; -"rAarr", "\u{21DB}"; -"rArr", "\u{21D2}"; -"rAtail", "\u{291C}"; -"rBarr", "\u{290F}"; -"rHar", "\u{2964}"; -"race", "\u{223D}\u{0331}"; -"racute", "\u{0155}"; -"radic", "\u{221A}"; -"raemptyv", "\u{29B3}"; -"rang", "\u{27E9}"; -"rangd", "\u{2992}"; -"range", "\u{29A5}"; -"rangle", "\u{27E9}"; -"raquo", "\u{00BB}"; -"rarr", "\u{2192}"; -"rarrap", "\u{2975}"; -"rarrb", "\u{21E5}"; -"rarrbfs", "\u{2920}"; -"rarrc", "\u{2933}"; -"rarrfs", "\u{291E}"; -"rarrhk", "\u{21AA}"; -"rarrlp", "\u{21AC}"; -"rarrpl", "\u{2945}"; -"rarrsim", "\u{2974}"; -"rarrtl", "\u{21A3}"; -"rarrw", "\u{219D}"; -"ratail", "\u{291A}"; -"ratio", "\u{2236}"; -"rationals", "\u{211A}"; -"rbarr", "\u{290D}"; -"rbbrk", "\u{2773}"; -"rbrace", "\u{007D}"; -"rbrack", "\u{005D}"; -"rbrke", "\u{298C}"; -"rbrksld", "\u{298E}"; -"rbrkslu", "\u{2990}"; -"rcaron", "\u{0159}"; -"rcedil", "\u{0157}"; -"rceil", "\u{2309}"; -"rcub", "\u{007D}"; -"rcy", "\u{0440}"; -"rdca", "\u{2937}"; -"rdldhar", "\u{2969}"; -"rdquo", "\u{201D}"; -"rdquor", "\u{201D}"; -"rdsh", "\u{21B3}"; -"real", "\u{211C}"; -"realine", "\u{211B}"; -"realpart", "\u{211C}"; -"reals", "\u{211D}"; -"rect", "\u{25AD}"; -"reg", "\u{00AE}"; -"rfisht", "\u{297D}"; -"rfloor", "\u{230B}"; -"rfr", "\u{1D52F}"; -"rhard", "\u{21C1}"; -"rharu", "\u{21C0}"; -"rharul", "\u{296C}"; -"rho", "\u{03C1}"; -"rhov", "\u{03F1}"; -"rightarrow", "\u{2192}"; -"rightarrowtail", "\u{21A3}"; -"rightharpoondown", "\u{21C1}"; -"rightharpoonup", "\u{21C0}"; -"rightleftarrows", "\u{21C4}"; -"rightleftharpoons", "\u{21CC}"; -"rightrightarrows", "\u{21C9}"; -"rightsquigarrow", "\u{219D}"; -"rightthreetimes", "\u{22CC}"; -"ring", "\u{02DA}"; -"risingdotseq", "\u{2253}"; -"rlarr", "\u{21C4}"; -"rlhar", "\u{21CC}"; -"rlm", "\u{200F}"; -"rmoust", "\u{23B1}"; -"rmoustache", "\u{23B1}"; -"rnmid", "\u{2AEE}"; -"roang", "\u{27ED}"; -"roarr", "\u{21FE}"; -"robrk", "\u{27E7}"; -"ropar", "\u{2986}"; -"ropf", "\u{1D563}"; -"roplus", "\u{2A2E}"; -"rotimes", "\u{2A35}"; -"rpar", "\u{0029}"; -"rpargt", "\u{2994}"; -"rppolint", "\u{2A12}"; -"rrarr", "\u{21C9}"; -"rsaquo", "\u{203A}"; -"rscr", "\u{1D4C7}"; -"rsh", "\u{21B1}"; -"rsqb", "\u{005D}"; -"rsquo", "\u{2019}"; -"rsquor", "\u{2019}"; -"rthree", "\u{22CC}"; -"rtimes", "\u{22CA}"; -"rtri", "\u{25B9}"; -"rtrie", "\u{22B5}"; -"rtrif", "\u{25B8}"; -"rtriltri", "\u{29CE}"; -"ruluhar", "\u{2968}"; -"rx", "\u{211E}"; -"sacute", "\u{015B}"; -"sbquo", "\u{201A}"; -"sc", "\u{227B}"; -"scE", "\u{2AB4}"; -"scap", "\u{2AB8}"; -"scaron", "\u{0161}"; -"sccue", "\u{227D}"; -"sce", "\u{2AB0}"; -"scedil", "\u{015F}"; -"scirc", "\u{015D}"; -"scnE", "\u{2AB6}"; -"scnap", "\u{2ABA}"; -"scnsim", "\u{22E9}"; -"scpolint", "\u{2A13}"; -"scsim", "\u{227F}"; -"scy", "\u{0441}"; -"sdot", "\u{22C5}"; -"sdotb", "\u{22A1}"; -"sdote", "\u{2A66}"; -"seArr", "\u{21D8}"; -"searhk", "\u{2925}"; -"searr", "\u{2198}"; -"searrow", "\u{2198}"; -"sect", "\u{00A7}"; -"semi", "\u{003B}"; -"seswar", "\u{2929}"; -"setminus", "\u{2216}"; -"setmn", "\u{2216}"; -"sext", "\u{2736}"; -"sfr", "\u{1D530}"; -"sfrown", "\u{2322}"; -"sharp", "\u{266F}"; -"shchcy", "\u{0449}"; -"shcy", "\u{0448}"; -"shortmid", "\u{2223}"; -"shortparallel", "\u{2225}"; -"shy", "\u{00AD}"; -"sigma", "\u{03C3}"; -"sigmaf", "\u{03C2}"; -"sigmav", "\u{03C2}"; -"sim", "\u{223C}"; -"simdot", "\u{2A6A}"; -"sime", "\u{2243}"; -"simeq", "\u{2243}"; -"simg", "\u{2A9E}"; -"simgE", "\u{2AA0}"; -"siml", "\u{2A9D}"; -"simlE", "\u{2A9F}"; -"simne", "\u{2246}"; -"simplus", "\u{2A24}"; -"simrarr", "\u{2972}"; -"slarr", "\u{2190}"; -"smallsetminus", "\u{2216}"; -"smashp", "\u{2A33}"; -"smeparsl", "\u{29E4}"; -"smid", "\u{2223}"; -"smile", "\u{2323}"; -"smt", "\u{2AAA}"; -"smte", "\u{2AAC}"; -"smtes", "\u{2AAC}\u{FE00}"; -"softcy", "\u{044C}"; -"sol", "\u{002F}"; -"solb", "\u{29C4}"; -"solbar", "\u{233F}"; -"sopf", "\u{1D564}"; -"spades", "\u{2660}"; -"spadesuit", "\u{2660}"; -"spar", "\u{2225}"; -"sqcap", "\u{2293}"; -"sqcaps", "\u{2293}\u{FE00}"; -"sqcup", "\u{2294}"; -"sqcups", "\u{2294}\u{FE00}"; -"sqsub", "\u{228F}"; -"sqsube", "\u{2291}"; -"sqsubset", "\u{228F}"; -"sqsubseteq", "\u{2291}"; -"sqsup", "\u{2290}"; -"sqsupe", "\u{2292}"; -"sqsupset", "\u{2290}"; -"sqsupseteq", "\u{2292}"; -"squ", "\u{25A1}"; -"square", "\u{25A1}"; -"squarf", "\u{25AA}"; -"squf", "\u{25AA}"; -"srarr", "\u{2192}"; -"sscr", "\u{1D4C8}"; -"ssetmn", "\u{2216}"; -"ssmile", "\u{2323}"; -"sstarf", "\u{22C6}"; -"star", "\u{2606}"; -"starf", "\u{2605}"; -"straightepsilon", "\u{03F5}"; -"straightphi", "\u{03D5}"; -"strns", "\u{00AF}"; -"sub", "\u{2282}"; -"subE", "\u{2AC5}"; -"subdot", "\u{2ABD}"; -"sube", "\u{2286}"; -"subedot", "\u{2AC3}"; -"submult", "\u{2AC1}"; -"subnE", "\u{2ACB}"; -"subne", "\u{228A}"; -"subplus", "\u{2ABF}"; -"subrarr", "\u{2979}"; -"subset", "\u{2282}"; -"subseteq", "\u{2286}"; -"subseteqq", "\u{2AC5}"; -"subsetneq", "\u{228A}"; -"subsetneqq", "\u{2ACB}"; -"subsim", "\u{2AC7}"; -"subsub", "\u{2AD5}"; -"subsup", "\u{2AD3}"; -"succ", "\u{227B}"; -"succapprox", "\u{2AB8}"; -"succcurlyeq", "\u{227D}"; -"succeq", "\u{2AB0}"; -"succnapprox", "\u{2ABA}"; -"succneqq", "\u{2AB6}"; -"succnsim", "\u{22E9}"; -"succsim", "\u{227F}"; -"sum", "\u{2211}"; -"sung", "\u{266A}"; -"sup1", "\u{00B9}"; -"sup2", "\u{00B2}"; -"sup3", "\u{00B3}"; -"sup", "\u{2283}"; -"supE", "\u{2AC6}"; -"supdot", "\u{2ABE}"; -"supdsub", "\u{2AD8}"; -"supe", "\u{2287}"; -"supedot", "\u{2AC4}"; -"suphsol", "\u{27C9}"; -"suphsub", "\u{2AD7}"; -"suplarr", "\u{297B}"; -"supmult", "\u{2AC2}"; -"supnE", "\u{2ACC}"; -"supne", "\u{228B}"; -"supplus", "\u{2AC0}"; -"supset", "\u{2283}"; -"supseteq", "\u{2287}"; -"supseteqq", "\u{2AC6}"; -"supsetneq", "\u{228B}"; -"supsetneqq", "\u{2ACC}"; -"supsim", "\u{2AC8}"; -"supsub", "\u{2AD4}"; -"supsup", "\u{2AD6}"; -"swArr", "\u{21D9}"; -"swarhk", "\u{2926}"; -"swarr", "\u{2199}"; -"swarrow", "\u{2199}"; -"swnwar", "\u{292A}"; -"szlig", "\u{00DF}"; -"target", "\u{2316}"; -"tau", "\u{03C4}"; -"tbrk", "\u{23B4}"; -"tcaron", "\u{0165}"; -"tcedil", "\u{0163}"; -"tcy", "\u{0442}"; -"tdot", "\u{20DB}"; -"telrec", "\u{2315}"; -"tfr", "\u{1D531}"; -"there4", "\u{2234}"; -"therefore", "\u{2234}"; -"theta", "\u{03B8}"; -"thetasym", "\u{03D1}"; -"thetav", "\u{03D1}"; -"thickapprox", "\u{2248}"; -"thicksim", "\u{223C}"; -"thinsp", "\u{2009}"; -"thkap", "\u{2248}"; -"thksim", "\u{223C}"; -"thorn", "\u{00FE}"; -"tilde", "\u{02DC}"; -"times", "\u{00D7}"; -"timesb", "\u{22A0}"; -"timesbar", "\u{2A31}"; -"timesd", "\u{2A30}"; -"tint", "\u{222D}"; -"toea", "\u{2928}"; -"top", "\u{22A4}"; -"topbot", "\u{2336}"; -"topcir", "\u{2AF1}"; -"topf", "\u{1D565}"; -"topfork", "\u{2ADA}"; -"tosa", "\u{2929}"; -"tprime", "\u{2034}"; -"trade", "\u{2122}"; -"triangle", "\u{25B5}"; -"triangledown", "\u{25BF}"; -"triangleleft", "\u{25C3}"; -"trianglelefteq", "\u{22B4}"; -"triangleq", "\u{225C}"; -"triangleright", "\u{25B9}"; -"trianglerighteq", "\u{22B5}"; -"tridot", "\u{25EC}"; -"trie", "\u{225C}"; -"triminus", "\u{2A3A}"; -"triplus", "\u{2A39}"; -"trisb", "\u{29CD}"; -"tritime", "\u{2A3B}"; -"trpezium", "\u{23E2}"; -"tscr", "\u{1D4C9}"; -"tscy", "\u{0446}"; -"tshcy", "\u{045B}"; -"tstrok", "\u{0167}"; -"twixt", "\u{226C}"; -"twoheadleftarrow", "\u{219E}"; -"twoheadrightarrow", "\u{21A0}"; -"uArr", "\u{21D1}"; -"uHar", "\u{2963}"; -"uacute", "\u{00FA}"; -"uarr", "\u{2191}"; -"ubrcy", "\u{045E}"; -"ubreve", "\u{016D}"; -"ucirc", "\u{00FB}"; -"ucy", "\u{0443}"; -"udarr", "\u{21C5}"; -"udblac", "\u{0171}"; -"udhar", "\u{296E}"; -"ufisht", "\u{297E}"; -"ufr", "\u{1D532}"; -"ugrave", "\u{00F9}"; -"uharl", "\u{21BF}"; -"uharr", "\u{21BE}"; -"uhblk", "\u{2580}"; -"ulcorn", "\u{231C}"; -"ulcorner", "\u{231C}"; -"ulcrop", "\u{230F}"; -"ultri", "\u{25F8}"; -"umacr", "\u{016B}"; -"uml", "\u{00A8}"; -"uogon", "\u{0173}"; -"uopf", "\u{1D566}"; -"uparrow", "\u{2191}"; -"updownarrow", "\u{2195}"; -"upharpoonleft", "\u{21BF}"; -"upharpoonright", "\u{21BE}"; -"uplus", "\u{228E}"; -"upsi", "\u{03C5}"; -"upsih", "\u{03D2}"; -"upsilon", "\u{03C5}"; -"upuparrows", "\u{21C8}"; -"urcorn", "\u{231D}"; -"urcorner", "\u{231D}"; -"urcrop", "\u{230E}"; -"uring", "\u{016F}"; -"urtri", "\u{25F9}"; -"uscr", "\u{1D4CA}"; -"utdot", "\u{22F0}"; -"utilde", "\u{0169}"; -"utri", "\u{25B5}"; -"utrif", "\u{25B4}"; -"uuarr", "\u{21C8}"; -"uuml", "\u{00FC}"; -"uwangle", "\u{29A7}"; -"vArr", "\u{21D5}"; -"vBar", "\u{2AE8}"; -"vBarv", "\u{2AE9}"; -"vDash", "\u{22A8}"; -"vangrt", "\u{299C}"; -"varepsilon", "\u{03F5}"; -"varkappa", "\u{03F0}"; -"varnothing", "\u{2205}"; -"varphi", "\u{03D5}"; -"varpi", "\u{03D6}"; -"varpropto", "\u{221D}"; -"varr", "\u{2195}"; -"varrho", "\u{03F1}"; -"varsigma", "\u{03C2}"; -"varsubsetneq", "\u{228A}\u{FE00}"; -"varsubsetneqq", "\u{2ACB}\u{FE00}"; -"varsupsetneq", "\u{228B}\u{FE00}"; -"varsupsetneqq", "\u{2ACC}\u{FE00}"; -"vartheta", "\u{03D1}"; -"vartriangleleft", "\u{22B2}"; -"vartriangleright", "\u{22B3}"; -"vcy", "\u{0432}"; -"vdash", "\u{22A2}"; -"vee", "\u{2228}"; -"veebar", "\u{22BB}"; -"veeeq", "\u{225A}"; -"vellip", "\u{22EE}"; -"verbar", "\u{007C}"; -"vert", "\u{007C}"; -"vfr", "\u{1D533}"; -"vltri", "\u{22B2}"; -"vnsub", "\u{2282}\u{20D2}"; -"vnsup", "\u{2283}\u{20D2}"; -"vopf", "\u{1D567}"; -"vprop", "\u{221D}"; -"vrtri", "\u{22B3}"; -"vscr", "\u{1D4CB}"; -"vsubnE", "\u{2ACB}\u{FE00}"; -"vsubne", "\u{228A}\u{FE00}"; -"vsupnE", "\u{2ACC}\u{FE00}"; -"vsupne", "\u{228B}\u{FE00}"; -"vzigzag", "\u{299A}"; -"wcirc", "\u{0175}"; -"wedbar", "\u{2A5F}"; -"wedge", "\u{2227}"; -"wedgeq", "\u{2259}"; -"weierp", "\u{2118}"; -"wfr", "\u{1D534}"; -"wopf", "\u{1D568}"; -"wp", "\u{2118}"; -"wr", "\u{2240}"; -"wreath", "\u{2240}"; -"wscr", "\u{1D4CC}"; -"xcap", "\u{22C2}"; -"xcirc", "\u{25EF}"; -"xcup", "\u{22C3}"; -"xdtri", "\u{25BD}"; -"xfr", "\u{1D535}"; -"xhArr", "\u{27FA}"; -"xharr", "\u{27F7}"; -"xi", "\u{03BE}"; -"xlArr", "\u{27F8}"; -"xlarr", "\u{27F5}"; -"xmap", "\u{27FC}"; -"xnis", "\u{22FB}"; -"xodot", "\u{2A00}"; -"xopf", "\u{1D569}"; -"xoplus", "\u{2A01}"; -"xotime", "\u{2A02}"; -"xrArr", "\u{27F9}"; -"xrarr", "\u{27F6}"; -"xscr", "\u{1D4CD}"; -"xsqcup", "\u{2A06}"; -"xuplus", "\u{2A04}"; -"xutri", "\u{25B3}"; -"xvee", "\u{22C1}"; -"xwedge", "\u{22C0}"; -"yacute", "\u{00FD}"; -"yacy", "\u{044F}"; -"ycirc", "\u{0177}"; -"ycy", "\u{044B}"; -"yen", "\u{00A5}"; -"yfr", "\u{1D536}"; -"yicy", "\u{0457}"; -"yopf", "\u{1D56A}"; -"yscr", "\u{1D4CE}"; -"yucy", "\u{044E}"; -"yuml", "\u{00FF}"; -"zacute", "\u{017A}"; -"zcaron", "\u{017E}"; -"zcy", "\u{0437}"; -"zdot", "\u{017C}"; -"zeetrf", "\u{2128}"; -"zeta", "\u{03B6}"; -"zfr", "\u{1D537}"; -"zhcy", "\u{0436}"; -"zigrarr", "\u{21DD}"; -"zopf", "\u{1D56B}"; -"zscr", "\u{1D4CF}"; -"zwj", "\u{200D}"; -"zwnj", "\u{200C}"; -|] - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_data_uchar.ml b/ocaml-lsp-server/vendor/cmarkit/cmarkit_data_uchar.ml deleted file mode 100644 index 849a33464..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_data_uchar.ml +++ /dev/null @@ -1,658 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(* Do not edit. Data generated by support/unicode_data.ml *) - -let unicode_version = "15.0.0" - -let whitespace = - [|0x0009; 0x000A; 0x000C; 0x000D; 0x0020; 0x00A0; 0x1680; 0x2000; 0x2001; - 0x2002; 0x2003; 0x2004; 0x2005; 0x2006; 0x2007; 0x2008; 0x2009; 0x200A; - 0x202F; 0x205F; 0x3000|] - -let punctuation = - [|0x0021; 0x0022; 0x0023; 0x0024; 0x0025; 0x0026; 0x0027; 0x0028; 0x0029; - 0x002A; 0x002B; 0x002C; 0x002D; 0x002E; 0x002F; 0x003A; 0x003B; 0x003C; - 0x003D; 0x003E; 0x003F; 0x0040; 0x005B; 0x005C; 0x005D; 0x005E; 0x005F; - 0x0060; 0x007B; 0x007C; 0x007D; 0x007E; 0x00A1; 0x00A7; 0x00AB; 0x00B6; - 0x00B7; 0x00BB; 0x00BF; 0x037E; 0x0387; 0x055A; 0x055B; 0x055C; 0x055D; - 0x055E; 0x055F; 0x0589; 0x058A; 0x05BE; 0x05C0; 0x05C3; 0x05C6; 0x05F3; - 0x05F4; 0x0609; 0x060A; 0x060C; 0x060D; 0x061B; 0x061D; 0x061E; 0x061F; - 0x066A; 0x066B; 0x066C; 0x066D; 0x06D4; 0x0700; 0x0701; 0x0702; 0x0703; - 0x0704; 0x0705; 0x0706; 0x0707; 0x0708; 0x0709; 0x070A; 0x070B; 0x070C; - 0x070D; 0x07F7; 0x07F8; 0x07F9; 0x0830; 0x0831; 0x0832; 0x0833; 0x0834; - 0x0835; 0x0836; 0x0837; 0x0838; 0x0839; 0x083A; 0x083B; 0x083C; 0x083D; - 0x083E; 0x085E; 0x0964; 0x0965; 0x0970; 0x09FD; 0x0A76; 0x0AF0; 0x0C77; - 0x0C84; 0x0DF4; 0x0E4F; 0x0E5A; 0x0E5B; 0x0F04; 0x0F05; 0x0F06; 0x0F07; - 0x0F08; 0x0F09; 0x0F0A; 0x0F0B; 0x0F0C; 0x0F0D; 0x0F0E; 0x0F0F; 0x0F10; - 0x0F11; 0x0F12; 0x0F14; 0x0F3A; 0x0F3B; 0x0F3C; 0x0F3D; 0x0F85; 0x0FD0; - 0x0FD1; 0x0FD2; 0x0FD3; 0x0FD4; 0x0FD9; 0x0FDA; 0x104A; 0x104B; 0x104C; - 0x104D; 0x104E; 0x104F; 0x10FB; 0x1360; 0x1361; 0x1362; 0x1363; 0x1364; - 0x1365; 0x1366; 0x1367; 0x1368; 0x1400; 0x166E; 0x169B; 0x169C; 0x16EB; - 0x16EC; 0x16ED; 0x1735; 0x1736; 0x17D4; 0x17D5; 0x17D6; 0x17D8; 0x17D9; - 0x17DA; 0x1800; 0x1801; 0x1802; 0x1803; 0x1804; 0x1805; 0x1806; 0x1807; - 0x1808; 0x1809; 0x180A; 0x1944; 0x1945; 0x1A1E; 0x1A1F; 0x1AA0; 0x1AA1; - 0x1AA2; 0x1AA3; 0x1AA4; 0x1AA5; 0x1AA6; 0x1AA8; 0x1AA9; 0x1AAA; 0x1AAB; - 0x1AAC; 0x1AAD; 0x1B5A; 0x1B5B; 0x1B5C; 0x1B5D; 0x1B5E; 0x1B5F; 0x1B60; - 0x1B7D; 0x1B7E; 0x1BFC; 0x1BFD; 0x1BFE; 0x1BFF; 0x1C3B; 0x1C3C; 0x1C3D; - 0x1C3E; 0x1C3F; 0x1C7E; 0x1C7F; 0x1CC0; 0x1CC1; 0x1CC2; 0x1CC3; 0x1CC4; - 0x1CC5; 0x1CC6; 0x1CC7; 0x1CD3; 0x2010; 0x2011; 0x2012; 0x2013; 0x2014; - 0x2015; 0x2016; 0x2017; 0x2018; 0x2019; 0x201A; 0x201B; 0x201C; 0x201D; - 0x201E; 0x201F; 0x2020; 0x2021; 0x2022; 0x2023; 0x2024; 0x2025; 0x2026; - 0x2027; 0x2030; 0x2031; 0x2032; 0x2033; 0x2034; 0x2035; 0x2036; 0x2037; - 0x2038; 0x2039; 0x203A; 0x203B; 0x203C; 0x203D; 0x203E; 0x203F; 0x2040; - 0x2041; 0x2042; 0x2043; 0x2045; 0x2046; 0x2047; 0x2048; 0x2049; 0x204A; - 0x204B; 0x204C; 0x204D; 0x204E; 0x204F; 0x2050; 0x2051; 0x2053; 0x2054; - 0x2055; 0x2056; 0x2057; 0x2058; 0x2059; 0x205A; 0x205B; 0x205C; 0x205D; - 0x205E; 0x207D; 0x207E; 0x208D; 0x208E; 0x2308; 0x2309; 0x230A; 0x230B; - 0x2329; 0x232A; 0x2768; 0x2769; 0x276A; 0x276B; 0x276C; 0x276D; 0x276E; - 0x276F; 0x2770; 0x2771; 0x2772; 0x2773; 0x2774; 0x2775; 0x27C5; 0x27C6; - 0x27E6; 0x27E7; 0x27E8; 0x27E9; 0x27EA; 0x27EB; 0x27EC; 0x27ED; 0x27EE; - 0x27EF; 0x2983; 0x2984; 0x2985; 0x2986; 0x2987; 0x2988; 0x2989; 0x298A; - 0x298B; 0x298C; 0x298D; 0x298E; 0x298F; 0x2990; 0x2991; 0x2992; 0x2993; - 0x2994; 0x2995; 0x2996; 0x2997; 0x2998; 0x29D8; 0x29D9; 0x29DA; 0x29DB; - 0x29FC; 0x29FD; 0x2CF9; 0x2CFA; 0x2CFB; 0x2CFC; 0x2CFE; 0x2CFF; 0x2D70; - 0x2E00; 0x2E01; 0x2E02; 0x2E03; 0x2E04; 0x2E05; 0x2E06; 0x2E07; 0x2E08; - 0x2E09; 0x2E0A; 0x2E0B; 0x2E0C; 0x2E0D; 0x2E0E; 0x2E0F; 0x2E10; 0x2E11; - 0x2E12; 0x2E13; 0x2E14; 0x2E15; 0x2E16; 0x2E17; 0x2E18; 0x2E19; 0x2E1A; - 0x2E1B; 0x2E1C; 0x2E1D; 0x2E1E; 0x2E1F; 0x2E20; 0x2E21; 0x2E22; 0x2E23; - 0x2E24; 0x2E25; 0x2E26; 0x2E27; 0x2E28; 0x2E29; 0x2E2A; 0x2E2B; 0x2E2C; - 0x2E2D; 0x2E2E; 0x2E30; 0x2E31; 0x2E32; 0x2E33; 0x2E34; 0x2E35; 0x2E36; - 0x2E37; 0x2E38; 0x2E39; 0x2E3A; 0x2E3B; 0x2E3C; 0x2E3D; 0x2E3E; 0x2E3F; - 0x2E40; 0x2E41; 0x2E42; 0x2E43; 0x2E44; 0x2E45; 0x2E46; 0x2E47; 0x2E48; - 0x2E49; 0x2E4A; 0x2E4B; 0x2E4C; 0x2E4D; 0x2E4E; 0x2E4F; 0x2E52; 0x2E53; - 0x2E54; 0x2E55; 0x2E56; 0x2E57; 0x2E58; 0x2E59; 0x2E5A; 0x2E5B; 0x2E5C; - 0x2E5D; 0x3001; 0x3002; 0x3003; 0x3008; 0x3009; 0x300A; 0x300B; 0x300C; - 0x300D; 0x300E; 0x300F; 0x3010; 0x3011; 0x3014; 0x3015; 0x3016; 0x3017; - 0x3018; 0x3019; 0x301A; 0x301B; 0x301C; 0x301D; 0x301E; 0x301F; 0x3030; - 0x303D; 0x30A0; 0x30FB; 0xA4FE; 0xA4FF; 0xA60D; 0xA60E; 0xA60F; 0xA673; - 0xA67E; 0xA6F2; 0xA6F3; 0xA6F4; 0xA6F5; 0xA6F6; 0xA6F7; 0xA874; 0xA875; - 0xA876; 0xA877; 0xA8CE; 0xA8CF; 0xA8F8; 0xA8F9; 0xA8FA; 0xA8FC; 0xA92E; - 0xA92F; 0xA95F; 0xA9C1; 0xA9C2; 0xA9C3; 0xA9C4; 0xA9C5; 0xA9C6; 0xA9C7; - 0xA9C8; 0xA9C9; 0xA9CA; 0xA9CB; 0xA9CC; 0xA9CD; 0xA9DE; 0xA9DF; 0xAA5C; - 0xAA5D; 0xAA5E; 0xAA5F; 0xAADE; 0xAADF; 0xAAF0; 0xAAF1; 0xABEB; 0xFD3E; - 0xFD3F; 0xFE10; 0xFE11; 0xFE12; 0xFE13; 0xFE14; 0xFE15; 0xFE16; 0xFE17; - 0xFE18; 0xFE19; 0xFE30; 0xFE31; 0xFE32; 0xFE33; 0xFE34; 0xFE35; 0xFE36; - 0xFE37; 0xFE38; 0xFE39; 0xFE3A; 0xFE3B; 0xFE3C; 0xFE3D; 0xFE3E; 0xFE3F; - 0xFE40; 0xFE41; 0xFE42; 0xFE43; 0xFE44; 0xFE45; 0xFE46; 0xFE47; 0xFE48; - 0xFE49; 0xFE4A; 0xFE4B; 0xFE4C; 0xFE4D; 0xFE4E; 0xFE4F; 0xFE50; 0xFE51; - 0xFE52; 0xFE54; 0xFE55; 0xFE56; 0xFE57; 0xFE58; 0xFE59; 0xFE5A; 0xFE5B; - 0xFE5C; 0xFE5D; 0xFE5E; 0xFE5F; 0xFE60; 0xFE61; 0xFE63; 0xFE68; 0xFE6A; - 0xFE6B; 0xFF01; 0xFF02; 0xFF03; 0xFF05; 0xFF06; 0xFF07; 0xFF08; 0xFF09; - 0xFF0A; 0xFF0C; 0xFF0D; 0xFF0E; 0xFF0F; 0xFF1A; 0xFF1B; 0xFF1F; 0xFF20; - 0xFF3B; 0xFF3C; 0xFF3D; 0xFF3F; 0xFF5B; 0xFF5D; 0xFF5F; 0xFF60; 0xFF61; - 0xFF62; 0xFF63; 0xFF64; 0xFF65; 0x10100; 0x10101; 0x10102; 0x1039F; - 0x103D0; 0x1056F; 0x10857; 0x1091F; 0x1093F; 0x10A50; 0x10A51; 0x10A52; - 0x10A53; 0x10A54; 0x10A55; 0x10A56; 0x10A57; 0x10A58; 0x10A7F; 0x10AF0; - 0x10AF1; 0x10AF2; 0x10AF3; 0x10AF4; 0x10AF5; 0x10AF6; 0x10B39; 0x10B3A; - 0x10B3B; 0x10B3C; 0x10B3D; 0x10B3E; 0x10B3F; 0x10B99; 0x10B9A; 0x10B9B; - 0x10B9C; 0x10EAD; 0x10F55; 0x10F56; 0x10F57; 0x10F58; 0x10F59; 0x10F86; - 0x10F87; 0x10F88; 0x10F89; 0x11047; 0x11048; 0x11049; 0x1104A; 0x1104B; - 0x1104C; 0x1104D; 0x110BB; 0x110BC; 0x110BE; 0x110BF; 0x110C0; 0x110C1; - 0x11140; 0x11141; 0x11142; 0x11143; 0x11174; 0x11175; 0x111C5; 0x111C6; - 0x111C7; 0x111C8; 0x111CD; 0x111DB; 0x111DD; 0x111DE; 0x111DF; 0x11238; - 0x11239; 0x1123A; 0x1123B; 0x1123C; 0x1123D; 0x112A9; 0x1144B; 0x1144C; - 0x1144D; 0x1144E; 0x1144F; 0x1145A; 0x1145B; 0x1145D; 0x114C6; 0x115C1; - 0x115C2; 0x115C3; 0x115C4; 0x115C5; 0x115C6; 0x115C7; 0x115C8; 0x115C9; - 0x115CA; 0x115CB; 0x115CC; 0x115CD; 0x115CE; 0x115CF; 0x115D0; 0x115D1; - 0x115D2; 0x115D3; 0x115D4; 0x115D5; 0x115D6; 0x115D7; 0x11641; 0x11642; - 0x11643; 0x11660; 0x11661; 0x11662; 0x11663; 0x11664; 0x11665; 0x11666; - 0x11667; 0x11668; 0x11669; 0x1166A; 0x1166B; 0x1166C; 0x116B9; 0x1173C; - 0x1173D; 0x1173E; 0x1183B; 0x11944; 0x11945; 0x11946; 0x119E2; 0x11A3F; - 0x11A40; 0x11A41; 0x11A42; 0x11A43; 0x11A44; 0x11A45; 0x11A46; 0x11A9A; - 0x11A9B; 0x11A9C; 0x11A9E; 0x11A9F; 0x11AA0; 0x11AA1; 0x11AA2; 0x11B00; - 0x11B01; 0x11B02; 0x11B03; 0x11B04; 0x11B05; 0x11B06; 0x11B07; 0x11B08; - 0x11B09; 0x11C41; 0x11C42; 0x11C43; 0x11C44; 0x11C45; 0x11C70; 0x11C71; - 0x11EF7; 0x11EF8; 0x11F43; 0x11F44; 0x11F45; 0x11F46; 0x11F47; 0x11F48; - 0x11F49; 0x11F4A; 0x11F4B; 0x11F4C; 0x11F4D; 0x11F4E; 0x11F4F; 0x11FFF; - 0x12470; 0x12471; 0x12472; 0x12473; 0x12474; 0x12FF1; 0x12FF2; 0x16A6E; - 0x16A6F; 0x16AF5; 0x16B37; 0x16B38; 0x16B39; 0x16B3A; 0x16B3B; 0x16B44; - 0x16E97; 0x16E98; 0x16E99; 0x16E9A; 0x16FE2; 0x1BC9F; 0x1DA87; 0x1DA88; - 0x1DA89; 0x1DA8A; 0x1DA8B; 0x1E95E; 0x1E95F|] - -let case_fold = - [|0x0041, "\u{0061}"; 0x0042, "\u{0062}"; 0x0043, "\u{0063}"; - 0x0044, "\u{0064}"; 0x0045, "\u{0065}"; 0x0046, "\u{0066}"; - 0x0047, "\u{0067}"; 0x0048, "\u{0068}"; 0x0049, "\u{0069}"; - 0x004A, "\u{006A}"; 0x004B, "\u{006B}"; 0x004C, "\u{006C}"; - 0x004D, "\u{006D}"; 0x004E, "\u{006E}"; 0x004F, "\u{006F}"; - 0x0050, "\u{0070}"; 0x0051, "\u{0071}"; 0x0052, "\u{0072}"; - 0x0053, "\u{0073}"; 0x0054, "\u{0074}"; 0x0055, "\u{0075}"; - 0x0056, "\u{0076}"; 0x0057, "\u{0077}"; 0x0058, "\u{0078}"; - 0x0059, "\u{0079}"; 0x005A, "\u{007A}"; 0x00B5, "\u{03BC}"; - 0x00C0, "\u{00E0}"; 0x00C1, "\u{00E1}"; 0x00C2, "\u{00E2}"; - 0x00C3, "\u{00E3}"; 0x00C4, "\u{00E4}"; 0x00C5, "\u{00E5}"; - 0x00C6, "\u{00E6}"; 0x00C7, "\u{00E7}"; 0x00C8, "\u{00E8}"; - 0x00C9, "\u{00E9}"; 0x00CA, "\u{00EA}"; 0x00CB, "\u{00EB}"; - 0x00CC, "\u{00EC}"; 0x00CD, "\u{00ED}"; 0x00CE, "\u{00EE}"; - 0x00CF, "\u{00EF}"; 0x00D0, "\u{00F0}"; 0x00D1, "\u{00F1}"; - 0x00D2, "\u{00F2}"; 0x00D3, "\u{00F3}"; 0x00D4, "\u{00F4}"; - 0x00D5, "\u{00F5}"; 0x00D6, "\u{00F6}"; 0x00D8, "\u{00F8}"; - 0x00D9, "\u{00F9}"; 0x00DA, "\u{00FA}"; 0x00DB, "\u{00FB}"; - 0x00DC, "\u{00FC}"; 0x00DD, "\u{00FD}"; 0x00DE, "\u{00FE}"; - 0x00DF, "\u{0073}\u{0073}"; 0x0100, "\u{0101}"; 0x0102, "\u{0103}"; - 0x0104, "\u{0105}"; 0x0106, "\u{0107}"; 0x0108, "\u{0109}"; - 0x010A, "\u{010B}"; 0x010C, "\u{010D}"; 0x010E, "\u{010F}"; - 0x0110, "\u{0111}"; 0x0112, "\u{0113}"; 0x0114, "\u{0115}"; - 0x0116, "\u{0117}"; 0x0118, "\u{0119}"; 0x011A, "\u{011B}"; - 0x011C, "\u{011D}"; 0x011E, "\u{011F}"; 0x0120, "\u{0121}"; - 0x0122, "\u{0123}"; 0x0124, "\u{0125}"; 0x0126, "\u{0127}"; - 0x0128, "\u{0129}"; 0x012A, "\u{012B}"; 0x012C, "\u{012D}"; - 0x012E, "\u{012F}"; 0x0130, "\u{0069}\u{0307}"; 0x0132, "\u{0133}"; - 0x0134, "\u{0135}"; 0x0136, "\u{0137}"; 0x0139, "\u{013A}"; - 0x013B, "\u{013C}"; 0x013D, "\u{013E}"; 0x013F, "\u{0140}"; - 0x0141, "\u{0142}"; 0x0143, "\u{0144}"; 0x0145, "\u{0146}"; - 0x0147, "\u{0148}"; 0x0149, "\u{02BC}\u{006E}"; 0x014A, "\u{014B}"; - 0x014C, "\u{014D}"; 0x014E, "\u{014F}"; 0x0150, "\u{0151}"; - 0x0152, "\u{0153}"; 0x0154, "\u{0155}"; 0x0156, "\u{0157}"; - 0x0158, "\u{0159}"; 0x015A, "\u{015B}"; 0x015C, "\u{015D}"; - 0x015E, "\u{015F}"; 0x0160, "\u{0161}"; 0x0162, "\u{0163}"; - 0x0164, "\u{0165}"; 0x0166, "\u{0167}"; 0x0168, "\u{0169}"; - 0x016A, "\u{016B}"; 0x016C, "\u{016D}"; 0x016E, "\u{016F}"; - 0x0170, "\u{0171}"; 0x0172, "\u{0173}"; 0x0174, "\u{0175}"; - 0x0176, "\u{0177}"; 0x0178, "\u{00FF}"; 0x0179, "\u{017A}"; - 0x017B, "\u{017C}"; 0x017D, "\u{017E}"; 0x017F, "\u{0073}"; - 0x0181, "\u{0253}"; 0x0182, "\u{0183}"; 0x0184, "\u{0185}"; - 0x0186, "\u{0254}"; 0x0187, "\u{0188}"; 0x0189, "\u{0256}"; - 0x018A, "\u{0257}"; 0x018B, "\u{018C}"; 0x018E, "\u{01DD}"; - 0x018F, "\u{0259}"; 0x0190, "\u{025B}"; 0x0191, "\u{0192}"; - 0x0193, "\u{0260}"; 0x0194, "\u{0263}"; 0x0196, "\u{0269}"; - 0x0197, "\u{0268}"; 0x0198, "\u{0199}"; 0x019C, "\u{026F}"; - 0x019D, "\u{0272}"; 0x019F, "\u{0275}"; 0x01A0, "\u{01A1}"; - 0x01A2, "\u{01A3}"; 0x01A4, "\u{01A5}"; 0x01A6, "\u{0280}"; - 0x01A7, "\u{01A8}"; 0x01A9, "\u{0283}"; 0x01AC, "\u{01AD}"; - 0x01AE, "\u{0288}"; 0x01AF, "\u{01B0}"; 0x01B1, "\u{028A}"; - 0x01B2, "\u{028B}"; 0x01B3, "\u{01B4}"; 0x01B5, "\u{01B6}"; - 0x01B7, "\u{0292}"; 0x01B8, "\u{01B9}"; 0x01BC, "\u{01BD}"; - 0x01C4, "\u{01C6}"; 0x01C5, "\u{01C6}"; 0x01C7, "\u{01C9}"; - 0x01C8, "\u{01C9}"; 0x01CA, "\u{01CC}"; 0x01CB, "\u{01CC}"; - 0x01CD, "\u{01CE}"; 0x01CF, "\u{01D0}"; 0x01D1, "\u{01D2}"; - 0x01D3, "\u{01D4}"; 0x01D5, "\u{01D6}"; 0x01D7, "\u{01D8}"; - 0x01D9, "\u{01DA}"; 0x01DB, "\u{01DC}"; 0x01DE, "\u{01DF}"; - 0x01E0, "\u{01E1}"; 0x01E2, "\u{01E3}"; 0x01E4, "\u{01E5}"; - 0x01E6, "\u{01E7}"; 0x01E8, "\u{01E9}"; 0x01EA, "\u{01EB}"; - 0x01EC, "\u{01ED}"; 0x01EE, "\u{01EF}"; 0x01F0, "\u{006A}\u{030C}"; - 0x01F1, "\u{01F3}"; 0x01F2, "\u{01F3}"; 0x01F4, "\u{01F5}"; - 0x01F6, "\u{0195}"; 0x01F7, "\u{01BF}"; 0x01F8, "\u{01F9}"; - 0x01FA, "\u{01FB}"; 0x01FC, "\u{01FD}"; 0x01FE, "\u{01FF}"; - 0x0200, "\u{0201}"; 0x0202, "\u{0203}"; 0x0204, "\u{0205}"; - 0x0206, "\u{0207}"; 0x0208, "\u{0209}"; 0x020A, "\u{020B}"; - 0x020C, "\u{020D}"; 0x020E, "\u{020F}"; 0x0210, "\u{0211}"; - 0x0212, "\u{0213}"; 0x0214, "\u{0215}"; 0x0216, "\u{0217}"; - 0x0218, "\u{0219}"; 0x021A, "\u{021B}"; 0x021C, "\u{021D}"; - 0x021E, "\u{021F}"; 0x0220, "\u{019E}"; 0x0222, "\u{0223}"; - 0x0224, "\u{0225}"; 0x0226, "\u{0227}"; 0x0228, "\u{0229}"; - 0x022A, "\u{022B}"; 0x022C, "\u{022D}"; 0x022E, "\u{022F}"; - 0x0230, "\u{0231}"; 0x0232, "\u{0233}"; 0x023A, "\u{2C65}"; - 0x023B, "\u{023C}"; 0x023D, "\u{019A}"; 0x023E, "\u{2C66}"; - 0x0241, "\u{0242}"; 0x0243, "\u{0180}"; 0x0244, "\u{0289}"; - 0x0245, "\u{028C}"; 0x0246, "\u{0247}"; 0x0248, "\u{0249}"; - 0x024A, "\u{024B}"; 0x024C, "\u{024D}"; 0x024E, "\u{024F}"; - 0x0345, "\u{03B9}"; 0x0370, "\u{0371}"; 0x0372, "\u{0373}"; - 0x0376, "\u{0377}"; 0x037F, "\u{03F3}"; 0x0386, "\u{03AC}"; - 0x0388, "\u{03AD}"; 0x0389, "\u{03AE}"; 0x038A, "\u{03AF}"; - 0x038C, "\u{03CC}"; 0x038E, "\u{03CD}"; 0x038F, "\u{03CE}"; - 0x0390, "\u{03B9}\u{0308}\u{0301}"; 0x0391, "\u{03B1}"; - 0x0392, "\u{03B2}"; 0x0393, "\u{03B3}"; 0x0394, "\u{03B4}"; - 0x0395, "\u{03B5}"; 0x0396, "\u{03B6}"; 0x0397, "\u{03B7}"; - 0x0398, "\u{03B8}"; 0x0399, "\u{03B9}"; 0x039A, "\u{03BA}"; - 0x039B, "\u{03BB}"; 0x039C, "\u{03BC}"; 0x039D, "\u{03BD}"; - 0x039E, "\u{03BE}"; 0x039F, "\u{03BF}"; 0x03A0, "\u{03C0}"; - 0x03A1, "\u{03C1}"; 0x03A3, "\u{03C3}"; 0x03A4, "\u{03C4}"; - 0x03A5, "\u{03C5}"; 0x03A6, "\u{03C6}"; 0x03A7, "\u{03C7}"; - 0x03A8, "\u{03C8}"; 0x03A9, "\u{03C9}"; 0x03AA, "\u{03CA}"; - 0x03AB, "\u{03CB}"; 0x03B0, "\u{03C5}\u{0308}\u{0301}"; - 0x03C2, "\u{03C3}"; 0x03CF, "\u{03D7}"; 0x03D0, "\u{03B2}"; - 0x03D1, "\u{03B8}"; 0x03D5, "\u{03C6}"; 0x03D6, "\u{03C0}"; - 0x03D8, "\u{03D9}"; 0x03DA, "\u{03DB}"; 0x03DC, "\u{03DD}"; - 0x03DE, "\u{03DF}"; 0x03E0, "\u{03E1}"; 0x03E2, "\u{03E3}"; - 0x03E4, "\u{03E5}"; 0x03E6, "\u{03E7}"; 0x03E8, "\u{03E9}"; - 0x03EA, "\u{03EB}"; 0x03EC, "\u{03ED}"; 0x03EE, "\u{03EF}"; - 0x03F0, "\u{03BA}"; 0x03F1, "\u{03C1}"; 0x03F4, "\u{03B8}"; - 0x03F5, "\u{03B5}"; 0x03F7, "\u{03F8}"; 0x03F9, "\u{03F2}"; - 0x03FA, "\u{03FB}"; 0x03FD, "\u{037B}"; 0x03FE, "\u{037C}"; - 0x03FF, "\u{037D}"; 0x0400, "\u{0450}"; 0x0401, "\u{0451}"; - 0x0402, "\u{0452}"; 0x0403, "\u{0453}"; 0x0404, "\u{0454}"; - 0x0405, "\u{0455}"; 0x0406, "\u{0456}"; 0x0407, "\u{0457}"; - 0x0408, "\u{0458}"; 0x0409, "\u{0459}"; 0x040A, "\u{045A}"; - 0x040B, "\u{045B}"; 0x040C, "\u{045C}"; 0x040D, "\u{045D}"; - 0x040E, "\u{045E}"; 0x040F, "\u{045F}"; 0x0410, "\u{0430}"; - 0x0411, "\u{0431}"; 0x0412, "\u{0432}"; 0x0413, "\u{0433}"; - 0x0414, "\u{0434}"; 0x0415, "\u{0435}"; 0x0416, "\u{0436}"; - 0x0417, "\u{0437}"; 0x0418, "\u{0438}"; 0x0419, "\u{0439}"; - 0x041A, "\u{043A}"; 0x041B, "\u{043B}"; 0x041C, "\u{043C}"; - 0x041D, "\u{043D}"; 0x041E, "\u{043E}"; 0x041F, "\u{043F}"; - 0x0420, "\u{0440}"; 0x0421, "\u{0441}"; 0x0422, "\u{0442}"; - 0x0423, "\u{0443}"; 0x0424, "\u{0444}"; 0x0425, "\u{0445}"; - 0x0426, "\u{0446}"; 0x0427, "\u{0447}"; 0x0428, "\u{0448}"; - 0x0429, "\u{0449}"; 0x042A, "\u{044A}"; 0x042B, "\u{044B}"; - 0x042C, "\u{044C}"; 0x042D, "\u{044D}"; 0x042E, "\u{044E}"; - 0x042F, "\u{044F}"; 0x0460, "\u{0461}"; 0x0462, "\u{0463}"; - 0x0464, "\u{0465}"; 0x0466, "\u{0467}"; 0x0468, "\u{0469}"; - 0x046A, "\u{046B}"; 0x046C, "\u{046D}"; 0x046E, "\u{046F}"; - 0x0470, "\u{0471}"; 0x0472, "\u{0473}"; 0x0474, "\u{0475}"; - 0x0476, "\u{0477}"; 0x0478, "\u{0479}"; 0x047A, "\u{047B}"; - 0x047C, "\u{047D}"; 0x047E, "\u{047F}"; 0x0480, "\u{0481}"; - 0x048A, "\u{048B}"; 0x048C, "\u{048D}"; 0x048E, "\u{048F}"; - 0x0490, "\u{0491}"; 0x0492, "\u{0493}"; 0x0494, "\u{0495}"; - 0x0496, "\u{0497}"; 0x0498, "\u{0499}"; 0x049A, "\u{049B}"; - 0x049C, "\u{049D}"; 0x049E, "\u{049F}"; 0x04A0, "\u{04A1}"; - 0x04A2, "\u{04A3}"; 0x04A4, "\u{04A5}"; 0x04A6, "\u{04A7}"; - 0x04A8, "\u{04A9}"; 0x04AA, "\u{04AB}"; 0x04AC, "\u{04AD}"; - 0x04AE, "\u{04AF}"; 0x04B0, "\u{04B1}"; 0x04B2, "\u{04B3}"; - 0x04B4, "\u{04B5}"; 0x04B6, "\u{04B7}"; 0x04B8, "\u{04B9}"; - 0x04BA, "\u{04BB}"; 0x04BC, "\u{04BD}"; 0x04BE, "\u{04BF}"; - 0x04C0, "\u{04CF}"; 0x04C1, "\u{04C2}"; 0x04C3, "\u{04C4}"; - 0x04C5, "\u{04C6}"; 0x04C7, "\u{04C8}"; 0x04C9, "\u{04CA}"; - 0x04CB, "\u{04CC}"; 0x04CD, "\u{04CE}"; 0x04D0, "\u{04D1}"; - 0x04D2, "\u{04D3}"; 0x04D4, "\u{04D5}"; 0x04D6, "\u{04D7}"; - 0x04D8, "\u{04D9}"; 0x04DA, "\u{04DB}"; 0x04DC, "\u{04DD}"; - 0x04DE, "\u{04DF}"; 0x04E0, "\u{04E1}"; 0x04E2, "\u{04E3}"; - 0x04E4, "\u{04E5}"; 0x04E6, "\u{04E7}"; 0x04E8, "\u{04E9}"; - 0x04EA, "\u{04EB}"; 0x04EC, "\u{04ED}"; 0x04EE, "\u{04EF}"; - 0x04F0, "\u{04F1}"; 0x04F2, "\u{04F3}"; 0x04F4, "\u{04F5}"; - 0x04F6, "\u{04F7}"; 0x04F8, "\u{04F9}"; 0x04FA, "\u{04FB}"; - 0x04FC, "\u{04FD}"; 0x04FE, "\u{04FF}"; 0x0500, "\u{0501}"; - 0x0502, "\u{0503}"; 0x0504, "\u{0505}"; 0x0506, "\u{0507}"; - 0x0508, "\u{0509}"; 0x050A, "\u{050B}"; 0x050C, "\u{050D}"; - 0x050E, "\u{050F}"; 0x0510, "\u{0511}"; 0x0512, "\u{0513}"; - 0x0514, "\u{0515}"; 0x0516, "\u{0517}"; 0x0518, "\u{0519}"; - 0x051A, "\u{051B}"; 0x051C, "\u{051D}"; 0x051E, "\u{051F}"; - 0x0520, "\u{0521}"; 0x0522, "\u{0523}"; 0x0524, "\u{0525}"; - 0x0526, "\u{0527}"; 0x0528, "\u{0529}"; 0x052A, "\u{052B}"; - 0x052C, "\u{052D}"; 0x052E, "\u{052F}"; 0x0531, "\u{0561}"; - 0x0532, "\u{0562}"; 0x0533, "\u{0563}"; 0x0534, "\u{0564}"; - 0x0535, "\u{0565}"; 0x0536, "\u{0566}"; 0x0537, "\u{0567}"; - 0x0538, "\u{0568}"; 0x0539, "\u{0569}"; 0x053A, "\u{056A}"; - 0x053B, "\u{056B}"; 0x053C, "\u{056C}"; 0x053D, "\u{056D}"; - 0x053E, "\u{056E}"; 0x053F, "\u{056F}"; 0x0540, "\u{0570}"; - 0x0541, "\u{0571}"; 0x0542, "\u{0572}"; 0x0543, "\u{0573}"; - 0x0544, "\u{0574}"; 0x0545, "\u{0575}"; 0x0546, "\u{0576}"; - 0x0547, "\u{0577}"; 0x0548, "\u{0578}"; 0x0549, "\u{0579}"; - 0x054A, "\u{057A}"; 0x054B, "\u{057B}"; 0x054C, "\u{057C}"; - 0x054D, "\u{057D}"; 0x054E, "\u{057E}"; 0x054F, "\u{057F}"; - 0x0550, "\u{0580}"; 0x0551, "\u{0581}"; 0x0552, "\u{0582}"; - 0x0553, "\u{0583}"; 0x0554, "\u{0584}"; 0x0555, "\u{0585}"; - 0x0556, "\u{0586}"; 0x0587, "\u{0565}\u{0582}"; 0x10A0, "\u{2D00}"; - 0x10A1, "\u{2D01}"; 0x10A2, "\u{2D02}"; 0x10A3, "\u{2D03}"; - 0x10A4, "\u{2D04}"; 0x10A5, "\u{2D05}"; 0x10A6, "\u{2D06}"; - 0x10A7, "\u{2D07}"; 0x10A8, "\u{2D08}"; 0x10A9, "\u{2D09}"; - 0x10AA, "\u{2D0A}"; 0x10AB, "\u{2D0B}"; 0x10AC, "\u{2D0C}"; - 0x10AD, "\u{2D0D}"; 0x10AE, "\u{2D0E}"; 0x10AF, "\u{2D0F}"; - 0x10B0, "\u{2D10}"; 0x10B1, "\u{2D11}"; 0x10B2, "\u{2D12}"; - 0x10B3, "\u{2D13}"; 0x10B4, "\u{2D14}"; 0x10B5, "\u{2D15}"; - 0x10B6, "\u{2D16}"; 0x10B7, "\u{2D17}"; 0x10B8, "\u{2D18}"; - 0x10B9, "\u{2D19}"; 0x10BA, "\u{2D1A}"; 0x10BB, "\u{2D1B}"; - 0x10BC, "\u{2D1C}"; 0x10BD, "\u{2D1D}"; 0x10BE, "\u{2D1E}"; - 0x10BF, "\u{2D1F}"; 0x10C0, "\u{2D20}"; 0x10C1, "\u{2D21}"; - 0x10C2, "\u{2D22}"; 0x10C3, "\u{2D23}"; 0x10C4, "\u{2D24}"; - 0x10C5, "\u{2D25}"; 0x10C7, "\u{2D27}"; 0x10CD, "\u{2D2D}"; - 0x13F8, "\u{13F0}"; 0x13F9, "\u{13F1}"; 0x13FA, "\u{13F2}"; - 0x13FB, "\u{13F3}"; 0x13FC, "\u{13F4}"; 0x13FD, "\u{13F5}"; - 0x1C80, "\u{0432}"; 0x1C81, "\u{0434}"; 0x1C82, "\u{043E}"; - 0x1C83, "\u{0441}"; 0x1C84, "\u{0442}"; 0x1C85, "\u{0442}"; - 0x1C86, "\u{044A}"; 0x1C87, "\u{0463}"; 0x1C88, "\u{A64B}"; - 0x1C90, "\u{10D0}"; 0x1C91, "\u{10D1}"; 0x1C92, "\u{10D2}"; - 0x1C93, "\u{10D3}"; 0x1C94, "\u{10D4}"; 0x1C95, "\u{10D5}"; - 0x1C96, "\u{10D6}"; 0x1C97, "\u{10D7}"; 0x1C98, "\u{10D8}"; - 0x1C99, "\u{10D9}"; 0x1C9A, "\u{10DA}"; 0x1C9B, "\u{10DB}"; - 0x1C9C, "\u{10DC}"; 0x1C9D, "\u{10DD}"; 0x1C9E, "\u{10DE}"; - 0x1C9F, "\u{10DF}"; 0x1CA0, "\u{10E0}"; 0x1CA1, "\u{10E1}"; - 0x1CA2, "\u{10E2}"; 0x1CA3, "\u{10E3}"; 0x1CA4, "\u{10E4}"; - 0x1CA5, "\u{10E5}"; 0x1CA6, "\u{10E6}"; 0x1CA7, "\u{10E7}"; - 0x1CA8, "\u{10E8}"; 0x1CA9, "\u{10E9}"; 0x1CAA, "\u{10EA}"; - 0x1CAB, "\u{10EB}"; 0x1CAC, "\u{10EC}"; 0x1CAD, "\u{10ED}"; - 0x1CAE, "\u{10EE}"; 0x1CAF, "\u{10EF}"; 0x1CB0, "\u{10F0}"; - 0x1CB1, "\u{10F1}"; 0x1CB2, "\u{10F2}"; 0x1CB3, "\u{10F3}"; - 0x1CB4, "\u{10F4}"; 0x1CB5, "\u{10F5}"; 0x1CB6, "\u{10F6}"; - 0x1CB7, "\u{10F7}"; 0x1CB8, "\u{10F8}"; 0x1CB9, "\u{10F9}"; - 0x1CBA, "\u{10FA}"; 0x1CBD, "\u{10FD}"; 0x1CBE, "\u{10FE}"; - 0x1CBF, "\u{10FF}"; 0x1E00, "\u{1E01}"; 0x1E02, "\u{1E03}"; - 0x1E04, "\u{1E05}"; 0x1E06, "\u{1E07}"; 0x1E08, "\u{1E09}"; - 0x1E0A, "\u{1E0B}"; 0x1E0C, "\u{1E0D}"; 0x1E0E, "\u{1E0F}"; - 0x1E10, "\u{1E11}"; 0x1E12, "\u{1E13}"; 0x1E14, "\u{1E15}"; - 0x1E16, "\u{1E17}"; 0x1E18, "\u{1E19}"; 0x1E1A, "\u{1E1B}"; - 0x1E1C, "\u{1E1D}"; 0x1E1E, "\u{1E1F}"; 0x1E20, "\u{1E21}"; - 0x1E22, "\u{1E23}"; 0x1E24, "\u{1E25}"; 0x1E26, "\u{1E27}"; - 0x1E28, "\u{1E29}"; 0x1E2A, "\u{1E2B}"; 0x1E2C, "\u{1E2D}"; - 0x1E2E, "\u{1E2F}"; 0x1E30, "\u{1E31}"; 0x1E32, "\u{1E33}"; - 0x1E34, "\u{1E35}"; 0x1E36, "\u{1E37}"; 0x1E38, "\u{1E39}"; - 0x1E3A, "\u{1E3B}"; 0x1E3C, "\u{1E3D}"; 0x1E3E, "\u{1E3F}"; - 0x1E40, "\u{1E41}"; 0x1E42, "\u{1E43}"; 0x1E44, "\u{1E45}"; - 0x1E46, "\u{1E47}"; 0x1E48, "\u{1E49}"; 0x1E4A, "\u{1E4B}"; - 0x1E4C, "\u{1E4D}"; 0x1E4E, "\u{1E4F}"; 0x1E50, "\u{1E51}"; - 0x1E52, "\u{1E53}"; 0x1E54, "\u{1E55}"; 0x1E56, "\u{1E57}"; - 0x1E58, "\u{1E59}"; 0x1E5A, "\u{1E5B}"; 0x1E5C, "\u{1E5D}"; - 0x1E5E, "\u{1E5F}"; 0x1E60, "\u{1E61}"; 0x1E62, "\u{1E63}"; - 0x1E64, "\u{1E65}"; 0x1E66, "\u{1E67}"; 0x1E68, "\u{1E69}"; - 0x1E6A, "\u{1E6B}"; 0x1E6C, "\u{1E6D}"; 0x1E6E, "\u{1E6F}"; - 0x1E70, "\u{1E71}"; 0x1E72, "\u{1E73}"; 0x1E74, "\u{1E75}"; - 0x1E76, "\u{1E77}"; 0x1E78, "\u{1E79}"; 0x1E7A, "\u{1E7B}"; - 0x1E7C, "\u{1E7D}"; 0x1E7E, "\u{1E7F}"; 0x1E80, "\u{1E81}"; - 0x1E82, "\u{1E83}"; 0x1E84, "\u{1E85}"; 0x1E86, "\u{1E87}"; - 0x1E88, "\u{1E89}"; 0x1E8A, "\u{1E8B}"; 0x1E8C, "\u{1E8D}"; - 0x1E8E, "\u{1E8F}"; 0x1E90, "\u{1E91}"; 0x1E92, "\u{1E93}"; - 0x1E94, "\u{1E95}"; 0x1E96, "\u{0068}\u{0331}"; - 0x1E97, "\u{0074}\u{0308}"; 0x1E98, "\u{0077}\u{030A}"; - 0x1E99, "\u{0079}\u{030A}"; 0x1E9A, "\u{0061}\u{02BE}"; - 0x1E9B, "\u{1E61}"; 0x1E9E, "\u{0073}\u{0073}"; 0x1EA0, "\u{1EA1}"; - 0x1EA2, "\u{1EA3}"; 0x1EA4, "\u{1EA5}"; 0x1EA6, "\u{1EA7}"; - 0x1EA8, "\u{1EA9}"; 0x1EAA, "\u{1EAB}"; 0x1EAC, "\u{1EAD}"; - 0x1EAE, "\u{1EAF}"; 0x1EB0, "\u{1EB1}"; 0x1EB2, "\u{1EB3}"; - 0x1EB4, "\u{1EB5}"; 0x1EB6, "\u{1EB7}"; 0x1EB8, "\u{1EB9}"; - 0x1EBA, "\u{1EBB}"; 0x1EBC, "\u{1EBD}"; 0x1EBE, "\u{1EBF}"; - 0x1EC0, "\u{1EC1}"; 0x1EC2, "\u{1EC3}"; 0x1EC4, "\u{1EC5}"; - 0x1EC6, "\u{1EC7}"; 0x1EC8, "\u{1EC9}"; 0x1ECA, "\u{1ECB}"; - 0x1ECC, "\u{1ECD}"; 0x1ECE, "\u{1ECF}"; 0x1ED0, "\u{1ED1}"; - 0x1ED2, "\u{1ED3}"; 0x1ED4, "\u{1ED5}"; 0x1ED6, "\u{1ED7}"; - 0x1ED8, "\u{1ED9}"; 0x1EDA, "\u{1EDB}"; 0x1EDC, "\u{1EDD}"; - 0x1EDE, "\u{1EDF}"; 0x1EE0, "\u{1EE1}"; 0x1EE2, "\u{1EE3}"; - 0x1EE4, "\u{1EE5}"; 0x1EE6, "\u{1EE7}"; 0x1EE8, "\u{1EE9}"; - 0x1EEA, "\u{1EEB}"; 0x1EEC, "\u{1EED}"; 0x1EEE, "\u{1EEF}"; - 0x1EF0, "\u{1EF1}"; 0x1EF2, "\u{1EF3}"; 0x1EF4, "\u{1EF5}"; - 0x1EF6, "\u{1EF7}"; 0x1EF8, "\u{1EF9}"; 0x1EFA, "\u{1EFB}"; - 0x1EFC, "\u{1EFD}"; 0x1EFE, "\u{1EFF}"; 0x1F08, "\u{1F00}"; - 0x1F09, "\u{1F01}"; 0x1F0A, "\u{1F02}"; 0x1F0B, "\u{1F03}"; - 0x1F0C, "\u{1F04}"; 0x1F0D, "\u{1F05}"; 0x1F0E, "\u{1F06}"; - 0x1F0F, "\u{1F07}"; 0x1F18, "\u{1F10}"; 0x1F19, "\u{1F11}"; - 0x1F1A, "\u{1F12}"; 0x1F1B, "\u{1F13}"; 0x1F1C, "\u{1F14}"; - 0x1F1D, "\u{1F15}"; 0x1F28, "\u{1F20}"; 0x1F29, "\u{1F21}"; - 0x1F2A, "\u{1F22}"; 0x1F2B, "\u{1F23}"; 0x1F2C, "\u{1F24}"; - 0x1F2D, "\u{1F25}"; 0x1F2E, "\u{1F26}"; 0x1F2F, "\u{1F27}"; - 0x1F38, "\u{1F30}"; 0x1F39, "\u{1F31}"; 0x1F3A, "\u{1F32}"; - 0x1F3B, "\u{1F33}"; 0x1F3C, "\u{1F34}"; 0x1F3D, "\u{1F35}"; - 0x1F3E, "\u{1F36}"; 0x1F3F, "\u{1F37}"; 0x1F48, "\u{1F40}"; - 0x1F49, "\u{1F41}"; 0x1F4A, "\u{1F42}"; 0x1F4B, "\u{1F43}"; - 0x1F4C, "\u{1F44}"; 0x1F4D, "\u{1F45}"; 0x1F50, "\u{03C5}\u{0313}"; - 0x1F52, "\u{03C5}\u{0313}\u{0300}"; 0x1F54, "\u{03C5}\u{0313}\u{0301}"; - 0x1F56, "\u{03C5}\u{0313}\u{0342}"; 0x1F59, "\u{1F51}"; - 0x1F5B, "\u{1F53}"; 0x1F5D, "\u{1F55}"; 0x1F5F, "\u{1F57}"; - 0x1F68, "\u{1F60}"; 0x1F69, "\u{1F61}"; 0x1F6A, "\u{1F62}"; - 0x1F6B, "\u{1F63}"; 0x1F6C, "\u{1F64}"; 0x1F6D, "\u{1F65}"; - 0x1F6E, "\u{1F66}"; 0x1F6F, "\u{1F67}"; 0x1F80, "\u{1F00}\u{03B9}"; - 0x1F81, "\u{1F01}\u{03B9}"; 0x1F82, "\u{1F02}\u{03B9}"; - 0x1F83, "\u{1F03}\u{03B9}"; 0x1F84, "\u{1F04}\u{03B9}"; - 0x1F85, "\u{1F05}\u{03B9}"; 0x1F86, "\u{1F06}\u{03B9}"; - 0x1F87, "\u{1F07}\u{03B9}"; 0x1F88, "\u{1F00}\u{03B9}"; - 0x1F89, "\u{1F01}\u{03B9}"; 0x1F8A, "\u{1F02}\u{03B9}"; - 0x1F8B, "\u{1F03}\u{03B9}"; 0x1F8C, "\u{1F04}\u{03B9}"; - 0x1F8D, "\u{1F05}\u{03B9}"; 0x1F8E, "\u{1F06}\u{03B9}"; - 0x1F8F, "\u{1F07}\u{03B9}"; 0x1F90, "\u{1F20}\u{03B9}"; - 0x1F91, "\u{1F21}\u{03B9}"; 0x1F92, "\u{1F22}\u{03B9}"; - 0x1F93, "\u{1F23}\u{03B9}"; 0x1F94, "\u{1F24}\u{03B9}"; - 0x1F95, "\u{1F25}\u{03B9}"; 0x1F96, "\u{1F26}\u{03B9}"; - 0x1F97, "\u{1F27}\u{03B9}"; 0x1F98, "\u{1F20}\u{03B9}"; - 0x1F99, "\u{1F21}\u{03B9}"; 0x1F9A, "\u{1F22}\u{03B9}"; - 0x1F9B, "\u{1F23}\u{03B9}"; 0x1F9C, "\u{1F24}\u{03B9}"; - 0x1F9D, "\u{1F25}\u{03B9}"; 0x1F9E, "\u{1F26}\u{03B9}"; - 0x1F9F, "\u{1F27}\u{03B9}"; 0x1FA0, "\u{1F60}\u{03B9}"; - 0x1FA1, "\u{1F61}\u{03B9}"; 0x1FA2, "\u{1F62}\u{03B9}"; - 0x1FA3, "\u{1F63}\u{03B9}"; 0x1FA4, "\u{1F64}\u{03B9}"; - 0x1FA5, "\u{1F65}\u{03B9}"; 0x1FA6, "\u{1F66}\u{03B9}"; - 0x1FA7, "\u{1F67}\u{03B9}"; 0x1FA8, "\u{1F60}\u{03B9}"; - 0x1FA9, "\u{1F61}\u{03B9}"; 0x1FAA, "\u{1F62}\u{03B9}"; - 0x1FAB, "\u{1F63}\u{03B9}"; 0x1FAC, "\u{1F64}\u{03B9}"; - 0x1FAD, "\u{1F65}\u{03B9}"; 0x1FAE, "\u{1F66}\u{03B9}"; - 0x1FAF, "\u{1F67}\u{03B9}"; 0x1FB2, "\u{1F70}\u{03B9}"; - 0x1FB3, "\u{03B1}\u{03B9}"; 0x1FB4, "\u{03AC}\u{03B9}"; - 0x1FB6, "\u{03B1}\u{0342}"; 0x1FB7, "\u{03B1}\u{0342}\u{03B9}"; - 0x1FB8, "\u{1FB0}"; 0x1FB9, "\u{1FB1}"; 0x1FBA, "\u{1F70}"; - 0x1FBB, "\u{1F71}"; 0x1FBC, "\u{03B1}\u{03B9}"; 0x1FBE, "\u{03B9}"; - 0x1FC2, "\u{1F74}\u{03B9}"; 0x1FC3, "\u{03B7}\u{03B9}"; - 0x1FC4, "\u{03AE}\u{03B9}"; 0x1FC6, "\u{03B7}\u{0342}"; - 0x1FC7, "\u{03B7}\u{0342}\u{03B9}"; 0x1FC8, "\u{1F72}"; - 0x1FC9, "\u{1F73}"; 0x1FCA, "\u{1F74}"; 0x1FCB, "\u{1F75}"; - 0x1FCC, "\u{03B7}\u{03B9}"; 0x1FD2, "\u{03B9}\u{0308}\u{0300}"; - 0x1FD3, "\u{03B9}\u{0308}\u{0301}"; 0x1FD6, "\u{03B9}\u{0342}"; - 0x1FD7, "\u{03B9}\u{0308}\u{0342}"; 0x1FD8, "\u{1FD0}"; - 0x1FD9, "\u{1FD1}"; 0x1FDA, "\u{1F76}"; 0x1FDB, "\u{1F77}"; - 0x1FE2, "\u{03C5}\u{0308}\u{0300}"; 0x1FE3, "\u{03C5}\u{0308}\u{0301}"; - 0x1FE4, "\u{03C1}\u{0313}"; 0x1FE6, "\u{03C5}\u{0342}"; - 0x1FE7, "\u{03C5}\u{0308}\u{0342}"; 0x1FE8, "\u{1FE0}"; - 0x1FE9, "\u{1FE1}"; 0x1FEA, "\u{1F7A}"; 0x1FEB, "\u{1F7B}"; - 0x1FEC, "\u{1FE5}"; 0x1FF2, "\u{1F7C}\u{03B9}"; - 0x1FF3, "\u{03C9}\u{03B9}"; 0x1FF4, "\u{03CE}\u{03B9}"; - 0x1FF6, "\u{03C9}\u{0342}"; 0x1FF7, "\u{03C9}\u{0342}\u{03B9}"; - 0x1FF8, "\u{1F78}"; 0x1FF9, "\u{1F79}"; 0x1FFA, "\u{1F7C}"; - 0x1FFB, "\u{1F7D}"; 0x1FFC, "\u{03C9}\u{03B9}"; 0x2126, "\u{03C9}"; - 0x212A, "\u{006B}"; 0x212B, "\u{00E5}"; 0x2132, "\u{214E}"; - 0x2160, "\u{2170}"; 0x2161, "\u{2171}"; 0x2162, "\u{2172}"; - 0x2163, "\u{2173}"; 0x2164, "\u{2174}"; 0x2165, "\u{2175}"; - 0x2166, "\u{2176}"; 0x2167, "\u{2177}"; 0x2168, "\u{2178}"; - 0x2169, "\u{2179}"; 0x216A, "\u{217A}"; 0x216B, "\u{217B}"; - 0x216C, "\u{217C}"; 0x216D, "\u{217D}"; 0x216E, "\u{217E}"; - 0x216F, "\u{217F}"; 0x2183, "\u{2184}"; 0x24B6, "\u{24D0}"; - 0x24B7, "\u{24D1}"; 0x24B8, "\u{24D2}"; 0x24B9, "\u{24D3}"; - 0x24BA, "\u{24D4}"; 0x24BB, "\u{24D5}"; 0x24BC, "\u{24D6}"; - 0x24BD, "\u{24D7}"; 0x24BE, "\u{24D8}"; 0x24BF, "\u{24D9}"; - 0x24C0, "\u{24DA}"; 0x24C1, "\u{24DB}"; 0x24C2, "\u{24DC}"; - 0x24C3, "\u{24DD}"; 0x24C4, "\u{24DE}"; 0x24C5, "\u{24DF}"; - 0x24C6, "\u{24E0}"; 0x24C7, "\u{24E1}"; 0x24C8, "\u{24E2}"; - 0x24C9, "\u{24E3}"; 0x24CA, "\u{24E4}"; 0x24CB, "\u{24E5}"; - 0x24CC, "\u{24E6}"; 0x24CD, "\u{24E7}"; 0x24CE, "\u{24E8}"; - 0x24CF, "\u{24E9}"; 0x2C00, "\u{2C30}"; 0x2C01, "\u{2C31}"; - 0x2C02, "\u{2C32}"; 0x2C03, "\u{2C33}"; 0x2C04, "\u{2C34}"; - 0x2C05, "\u{2C35}"; 0x2C06, "\u{2C36}"; 0x2C07, "\u{2C37}"; - 0x2C08, "\u{2C38}"; 0x2C09, "\u{2C39}"; 0x2C0A, "\u{2C3A}"; - 0x2C0B, "\u{2C3B}"; 0x2C0C, "\u{2C3C}"; 0x2C0D, "\u{2C3D}"; - 0x2C0E, "\u{2C3E}"; 0x2C0F, "\u{2C3F}"; 0x2C10, "\u{2C40}"; - 0x2C11, "\u{2C41}"; 0x2C12, "\u{2C42}"; 0x2C13, "\u{2C43}"; - 0x2C14, "\u{2C44}"; 0x2C15, "\u{2C45}"; 0x2C16, "\u{2C46}"; - 0x2C17, "\u{2C47}"; 0x2C18, "\u{2C48}"; 0x2C19, "\u{2C49}"; - 0x2C1A, "\u{2C4A}"; 0x2C1B, "\u{2C4B}"; 0x2C1C, "\u{2C4C}"; - 0x2C1D, "\u{2C4D}"; 0x2C1E, "\u{2C4E}"; 0x2C1F, "\u{2C4F}"; - 0x2C20, "\u{2C50}"; 0x2C21, "\u{2C51}"; 0x2C22, "\u{2C52}"; - 0x2C23, "\u{2C53}"; 0x2C24, "\u{2C54}"; 0x2C25, "\u{2C55}"; - 0x2C26, "\u{2C56}"; 0x2C27, "\u{2C57}"; 0x2C28, "\u{2C58}"; - 0x2C29, "\u{2C59}"; 0x2C2A, "\u{2C5A}"; 0x2C2B, "\u{2C5B}"; - 0x2C2C, "\u{2C5C}"; 0x2C2D, "\u{2C5D}"; 0x2C2E, "\u{2C5E}"; - 0x2C2F, "\u{2C5F}"; 0x2C60, "\u{2C61}"; 0x2C62, "\u{026B}"; - 0x2C63, "\u{1D7D}"; 0x2C64, "\u{027D}"; 0x2C67, "\u{2C68}"; - 0x2C69, "\u{2C6A}"; 0x2C6B, "\u{2C6C}"; 0x2C6D, "\u{0251}"; - 0x2C6E, "\u{0271}"; 0x2C6F, "\u{0250}"; 0x2C70, "\u{0252}"; - 0x2C72, "\u{2C73}"; 0x2C75, "\u{2C76}"; 0x2C7E, "\u{023F}"; - 0x2C7F, "\u{0240}"; 0x2C80, "\u{2C81}"; 0x2C82, "\u{2C83}"; - 0x2C84, "\u{2C85}"; 0x2C86, "\u{2C87}"; 0x2C88, "\u{2C89}"; - 0x2C8A, "\u{2C8B}"; 0x2C8C, "\u{2C8D}"; 0x2C8E, "\u{2C8F}"; - 0x2C90, "\u{2C91}"; 0x2C92, "\u{2C93}"; 0x2C94, "\u{2C95}"; - 0x2C96, "\u{2C97}"; 0x2C98, "\u{2C99}"; 0x2C9A, "\u{2C9B}"; - 0x2C9C, "\u{2C9D}"; 0x2C9E, "\u{2C9F}"; 0x2CA0, "\u{2CA1}"; - 0x2CA2, "\u{2CA3}"; 0x2CA4, "\u{2CA5}"; 0x2CA6, "\u{2CA7}"; - 0x2CA8, "\u{2CA9}"; 0x2CAA, "\u{2CAB}"; 0x2CAC, "\u{2CAD}"; - 0x2CAE, "\u{2CAF}"; 0x2CB0, "\u{2CB1}"; 0x2CB2, "\u{2CB3}"; - 0x2CB4, "\u{2CB5}"; 0x2CB6, "\u{2CB7}"; 0x2CB8, "\u{2CB9}"; - 0x2CBA, "\u{2CBB}"; 0x2CBC, "\u{2CBD}"; 0x2CBE, "\u{2CBF}"; - 0x2CC0, "\u{2CC1}"; 0x2CC2, "\u{2CC3}"; 0x2CC4, "\u{2CC5}"; - 0x2CC6, "\u{2CC7}"; 0x2CC8, "\u{2CC9}"; 0x2CCA, "\u{2CCB}"; - 0x2CCC, "\u{2CCD}"; 0x2CCE, "\u{2CCF}"; 0x2CD0, "\u{2CD1}"; - 0x2CD2, "\u{2CD3}"; 0x2CD4, "\u{2CD5}"; 0x2CD6, "\u{2CD7}"; - 0x2CD8, "\u{2CD9}"; 0x2CDA, "\u{2CDB}"; 0x2CDC, "\u{2CDD}"; - 0x2CDE, "\u{2CDF}"; 0x2CE0, "\u{2CE1}"; 0x2CE2, "\u{2CE3}"; - 0x2CEB, "\u{2CEC}"; 0x2CED, "\u{2CEE}"; 0x2CF2, "\u{2CF3}"; - 0xA640, "\u{A641}"; 0xA642, "\u{A643}"; 0xA644, "\u{A645}"; - 0xA646, "\u{A647}"; 0xA648, "\u{A649}"; 0xA64A, "\u{A64B}"; - 0xA64C, "\u{A64D}"; 0xA64E, "\u{A64F}"; 0xA650, "\u{A651}"; - 0xA652, "\u{A653}"; 0xA654, "\u{A655}"; 0xA656, "\u{A657}"; - 0xA658, "\u{A659}"; 0xA65A, "\u{A65B}"; 0xA65C, "\u{A65D}"; - 0xA65E, "\u{A65F}"; 0xA660, "\u{A661}"; 0xA662, "\u{A663}"; - 0xA664, "\u{A665}"; 0xA666, "\u{A667}"; 0xA668, "\u{A669}"; - 0xA66A, "\u{A66B}"; 0xA66C, "\u{A66D}"; 0xA680, "\u{A681}"; - 0xA682, "\u{A683}"; 0xA684, "\u{A685}"; 0xA686, "\u{A687}"; - 0xA688, "\u{A689}"; 0xA68A, "\u{A68B}"; 0xA68C, "\u{A68D}"; - 0xA68E, "\u{A68F}"; 0xA690, "\u{A691}"; 0xA692, "\u{A693}"; - 0xA694, "\u{A695}"; 0xA696, "\u{A697}"; 0xA698, "\u{A699}"; - 0xA69A, "\u{A69B}"; 0xA722, "\u{A723}"; 0xA724, "\u{A725}"; - 0xA726, "\u{A727}"; 0xA728, "\u{A729}"; 0xA72A, "\u{A72B}"; - 0xA72C, "\u{A72D}"; 0xA72E, "\u{A72F}"; 0xA732, "\u{A733}"; - 0xA734, "\u{A735}"; 0xA736, "\u{A737}"; 0xA738, "\u{A739}"; - 0xA73A, "\u{A73B}"; 0xA73C, "\u{A73D}"; 0xA73E, "\u{A73F}"; - 0xA740, "\u{A741}"; 0xA742, "\u{A743}"; 0xA744, "\u{A745}"; - 0xA746, "\u{A747}"; 0xA748, "\u{A749}"; 0xA74A, "\u{A74B}"; - 0xA74C, "\u{A74D}"; 0xA74E, "\u{A74F}"; 0xA750, "\u{A751}"; - 0xA752, "\u{A753}"; 0xA754, "\u{A755}"; 0xA756, "\u{A757}"; - 0xA758, "\u{A759}"; 0xA75A, "\u{A75B}"; 0xA75C, "\u{A75D}"; - 0xA75E, "\u{A75F}"; 0xA760, "\u{A761}"; 0xA762, "\u{A763}"; - 0xA764, "\u{A765}"; 0xA766, "\u{A767}"; 0xA768, "\u{A769}"; - 0xA76A, "\u{A76B}"; 0xA76C, "\u{A76D}"; 0xA76E, "\u{A76F}"; - 0xA779, "\u{A77A}"; 0xA77B, "\u{A77C}"; 0xA77D, "\u{1D79}"; - 0xA77E, "\u{A77F}"; 0xA780, "\u{A781}"; 0xA782, "\u{A783}"; - 0xA784, "\u{A785}"; 0xA786, "\u{A787}"; 0xA78B, "\u{A78C}"; - 0xA78D, "\u{0265}"; 0xA790, "\u{A791}"; 0xA792, "\u{A793}"; - 0xA796, "\u{A797}"; 0xA798, "\u{A799}"; 0xA79A, "\u{A79B}"; - 0xA79C, "\u{A79D}"; 0xA79E, "\u{A79F}"; 0xA7A0, "\u{A7A1}"; - 0xA7A2, "\u{A7A3}"; 0xA7A4, "\u{A7A5}"; 0xA7A6, "\u{A7A7}"; - 0xA7A8, "\u{A7A9}"; 0xA7AA, "\u{0266}"; 0xA7AB, "\u{025C}"; - 0xA7AC, "\u{0261}"; 0xA7AD, "\u{026C}"; 0xA7AE, "\u{026A}"; - 0xA7B0, "\u{029E}"; 0xA7B1, "\u{0287}"; 0xA7B2, "\u{029D}"; - 0xA7B3, "\u{AB53}"; 0xA7B4, "\u{A7B5}"; 0xA7B6, "\u{A7B7}"; - 0xA7B8, "\u{A7B9}"; 0xA7BA, "\u{A7BB}"; 0xA7BC, "\u{A7BD}"; - 0xA7BE, "\u{A7BF}"; 0xA7C0, "\u{A7C1}"; 0xA7C2, "\u{A7C3}"; - 0xA7C4, "\u{A794}"; 0xA7C5, "\u{0282}"; 0xA7C6, "\u{1D8E}"; - 0xA7C7, "\u{A7C8}"; 0xA7C9, "\u{A7CA}"; 0xA7D0, "\u{A7D1}"; - 0xA7D6, "\u{A7D7}"; 0xA7D8, "\u{A7D9}"; 0xA7F5, "\u{A7F6}"; - 0xAB70, "\u{13A0}"; 0xAB71, "\u{13A1}"; 0xAB72, "\u{13A2}"; - 0xAB73, "\u{13A3}"; 0xAB74, "\u{13A4}"; 0xAB75, "\u{13A5}"; - 0xAB76, "\u{13A6}"; 0xAB77, "\u{13A7}"; 0xAB78, "\u{13A8}"; - 0xAB79, "\u{13A9}"; 0xAB7A, "\u{13AA}"; 0xAB7B, "\u{13AB}"; - 0xAB7C, "\u{13AC}"; 0xAB7D, "\u{13AD}"; 0xAB7E, "\u{13AE}"; - 0xAB7F, "\u{13AF}"; 0xAB80, "\u{13B0}"; 0xAB81, "\u{13B1}"; - 0xAB82, "\u{13B2}"; 0xAB83, "\u{13B3}"; 0xAB84, "\u{13B4}"; - 0xAB85, "\u{13B5}"; 0xAB86, "\u{13B6}"; 0xAB87, "\u{13B7}"; - 0xAB88, "\u{13B8}"; 0xAB89, "\u{13B9}"; 0xAB8A, "\u{13BA}"; - 0xAB8B, "\u{13BB}"; 0xAB8C, "\u{13BC}"; 0xAB8D, "\u{13BD}"; - 0xAB8E, "\u{13BE}"; 0xAB8F, "\u{13BF}"; 0xAB90, "\u{13C0}"; - 0xAB91, "\u{13C1}"; 0xAB92, "\u{13C2}"; 0xAB93, "\u{13C3}"; - 0xAB94, "\u{13C4}"; 0xAB95, "\u{13C5}"; 0xAB96, "\u{13C6}"; - 0xAB97, "\u{13C7}"; 0xAB98, "\u{13C8}"; 0xAB99, "\u{13C9}"; - 0xAB9A, "\u{13CA}"; 0xAB9B, "\u{13CB}"; 0xAB9C, "\u{13CC}"; - 0xAB9D, "\u{13CD}"; 0xAB9E, "\u{13CE}"; 0xAB9F, "\u{13CF}"; - 0xABA0, "\u{13D0}"; 0xABA1, "\u{13D1}"; 0xABA2, "\u{13D2}"; - 0xABA3, "\u{13D3}"; 0xABA4, "\u{13D4}"; 0xABA5, "\u{13D5}"; - 0xABA6, "\u{13D6}"; 0xABA7, "\u{13D7}"; 0xABA8, "\u{13D8}"; - 0xABA9, "\u{13D9}"; 0xABAA, "\u{13DA}"; 0xABAB, "\u{13DB}"; - 0xABAC, "\u{13DC}"; 0xABAD, "\u{13DD}"; 0xABAE, "\u{13DE}"; - 0xABAF, "\u{13DF}"; 0xABB0, "\u{13E0}"; 0xABB1, "\u{13E1}"; - 0xABB2, "\u{13E2}"; 0xABB3, "\u{13E3}"; 0xABB4, "\u{13E4}"; - 0xABB5, "\u{13E5}"; 0xABB6, "\u{13E6}"; 0xABB7, "\u{13E7}"; - 0xABB8, "\u{13E8}"; 0xABB9, "\u{13E9}"; 0xABBA, "\u{13EA}"; - 0xABBB, "\u{13EB}"; 0xABBC, "\u{13EC}"; 0xABBD, "\u{13ED}"; - 0xABBE, "\u{13EE}"; 0xABBF, "\u{13EF}"; 0xFB00, "\u{0066}\u{0066}"; - 0xFB01, "\u{0066}\u{0069}"; 0xFB02, "\u{0066}\u{006C}"; - 0xFB03, "\u{0066}\u{0066}\u{0069}"; 0xFB04, "\u{0066}\u{0066}\u{006C}"; - 0xFB05, "\u{0073}\u{0074}"; 0xFB06, "\u{0073}\u{0074}"; - 0xFB13, "\u{0574}\u{0576}"; 0xFB14, "\u{0574}\u{0565}"; - 0xFB15, "\u{0574}\u{056B}"; 0xFB16, "\u{057E}\u{0576}"; - 0xFB17, "\u{0574}\u{056D}"; 0xFF21, "\u{FF41}"; 0xFF22, "\u{FF42}"; - 0xFF23, "\u{FF43}"; 0xFF24, "\u{FF44}"; 0xFF25, "\u{FF45}"; - 0xFF26, "\u{FF46}"; 0xFF27, "\u{FF47}"; 0xFF28, "\u{FF48}"; - 0xFF29, "\u{FF49}"; 0xFF2A, "\u{FF4A}"; 0xFF2B, "\u{FF4B}"; - 0xFF2C, "\u{FF4C}"; 0xFF2D, "\u{FF4D}"; 0xFF2E, "\u{FF4E}"; - 0xFF2F, "\u{FF4F}"; 0xFF30, "\u{FF50}"; 0xFF31, "\u{FF51}"; - 0xFF32, "\u{FF52}"; 0xFF33, "\u{FF53}"; 0xFF34, "\u{FF54}"; - 0xFF35, "\u{FF55}"; 0xFF36, "\u{FF56}"; 0xFF37, "\u{FF57}"; - 0xFF38, "\u{FF58}"; 0xFF39, "\u{FF59}"; 0xFF3A, "\u{FF5A}"; - 0x10400, "\u{10428}"; 0x10401, "\u{10429}"; 0x10402, "\u{1042A}"; - 0x10403, "\u{1042B}"; 0x10404, "\u{1042C}"; 0x10405, "\u{1042D}"; - 0x10406, "\u{1042E}"; 0x10407, "\u{1042F}"; 0x10408, "\u{10430}"; - 0x10409, "\u{10431}"; 0x1040A, "\u{10432}"; 0x1040B, "\u{10433}"; - 0x1040C, "\u{10434}"; 0x1040D, "\u{10435}"; 0x1040E, "\u{10436}"; - 0x1040F, "\u{10437}"; 0x10410, "\u{10438}"; 0x10411, "\u{10439}"; - 0x10412, "\u{1043A}"; 0x10413, "\u{1043B}"; 0x10414, "\u{1043C}"; - 0x10415, "\u{1043D}"; 0x10416, "\u{1043E}"; 0x10417, "\u{1043F}"; - 0x10418, "\u{10440}"; 0x10419, "\u{10441}"; 0x1041A, "\u{10442}"; - 0x1041B, "\u{10443}"; 0x1041C, "\u{10444}"; 0x1041D, "\u{10445}"; - 0x1041E, "\u{10446}"; 0x1041F, "\u{10447}"; 0x10420, "\u{10448}"; - 0x10421, "\u{10449}"; 0x10422, "\u{1044A}"; 0x10423, "\u{1044B}"; - 0x10424, "\u{1044C}"; 0x10425, "\u{1044D}"; 0x10426, "\u{1044E}"; - 0x10427, "\u{1044F}"; 0x104B0, "\u{104D8}"; 0x104B1, "\u{104D9}"; - 0x104B2, "\u{104DA}"; 0x104B3, "\u{104DB}"; 0x104B4, "\u{104DC}"; - 0x104B5, "\u{104DD}"; 0x104B6, "\u{104DE}"; 0x104B7, "\u{104DF}"; - 0x104B8, "\u{104E0}"; 0x104B9, "\u{104E1}"; 0x104BA, "\u{104E2}"; - 0x104BB, "\u{104E3}"; 0x104BC, "\u{104E4}"; 0x104BD, "\u{104E5}"; - 0x104BE, "\u{104E6}"; 0x104BF, "\u{104E7}"; 0x104C0, "\u{104E8}"; - 0x104C1, "\u{104E9}"; 0x104C2, "\u{104EA}"; 0x104C3, "\u{104EB}"; - 0x104C4, "\u{104EC}"; 0x104C5, "\u{104ED}"; 0x104C6, "\u{104EE}"; - 0x104C7, "\u{104EF}"; 0x104C8, "\u{104F0}"; 0x104C9, "\u{104F1}"; - 0x104CA, "\u{104F2}"; 0x104CB, "\u{104F3}"; 0x104CC, "\u{104F4}"; - 0x104CD, "\u{104F5}"; 0x104CE, "\u{104F6}"; 0x104CF, "\u{104F7}"; - 0x104D0, "\u{104F8}"; 0x104D1, "\u{104F9}"; 0x104D2, "\u{104FA}"; - 0x104D3, "\u{104FB}"; 0x10570, "\u{10597}"; 0x10571, "\u{10598}"; - 0x10572, "\u{10599}"; 0x10573, "\u{1059A}"; 0x10574, "\u{1059B}"; - 0x10575, "\u{1059C}"; 0x10576, "\u{1059D}"; 0x10577, "\u{1059E}"; - 0x10578, "\u{1059F}"; 0x10579, "\u{105A0}"; 0x1057A, "\u{105A1}"; - 0x1057C, "\u{105A3}"; 0x1057D, "\u{105A4}"; 0x1057E, "\u{105A5}"; - 0x1057F, "\u{105A6}"; 0x10580, "\u{105A7}"; 0x10581, "\u{105A8}"; - 0x10582, "\u{105A9}"; 0x10583, "\u{105AA}"; 0x10584, "\u{105AB}"; - 0x10585, "\u{105AC}"; 0x10586, "\u{105AD}"; 0x10587, "\u{105AE}"; - 0x10588, "\u{105AF}"; 0x10589, "\u{105B0}"; 0x1058A, "\u{105B1}"; - 0x1058C, "\u{105B3}"; 0x1058D, "\u{105B4}"; 0x1058E, "\u{105B5}"; - 0x1058F, "\u{105B6}"; 0x10590, "\u{105B7}"; 0x10591, "\u{105B8}"; - 0x10592, "\u{105B9}"; 0x10594, "\u{105BB}"; 0x10595, "\u{105BC}"; - 0x10C80, "\u{10CC0}"; 0x10C81, "\u{10CC1}"; 0x10C82, "\u{10CC2}"; - 0x10C83, "\u{10CC3}"; 0x10C84, "\u{10CC4}"; 0x10C85, "\u{10CC5}"; - 0x10C86, "\u{10CC6}"; 0x10C87, "\u{10CC7}"; 0x10C88, "\u{10CC8}"; - 0x10C89, "\u{10CC9}"; 0x10C8A, "\u{10CCA}"; 0x10C8B, "\u{10CCB}"; - 0x10C8C, "\u{10CCC}"; 0x10C8D, "\u{10CCD}"; 0x10C8E, "\u{10CCE}"; - 0x10C8F, "\u{10CCF}"; 0x10C90, "\u{10CD0}"; 0x10C91, "\u{10CD1}"; - 0x10C92, "\u{10CD2}"; 0x10C93, "\u{10CD3}"; 0x10C94, "\u{10CD4}"; - 0x10C95, "\u{10CD5}"; 0x10C96, "\u{10CD6}"; 0x10C97, "\u{10CD7}"; - 0x10C98, "\u{10CD8}"; 0x10C99, "\u{10CD9}"; 0x10C9A, "\u{10CDA}"; - 0x10C9B, "\u{10CDB}"; 0x10C9C, "\u{10CDC}"; 0x10C9D, "\u{10CDD}"; - 0x10C9E, "\u{10CDE}"; 0x10C9F, "\u{10CDF}"; 0x10CA0, "\u{10CE0}"; - 0x10CA1, "\u{10CE1}"; 0x10CA2, "\u{10CE2}"; 0x10CA3, "\u{10CE3}"; - 0x10CA4, "\u{10CE4}"; 0x10CA5, "\u{10CE5}"; 0x10CA6, "\u{10CE6}"; - 0x10CA7, "\u{10CE7}"; 0x10CA8, "\u{10CE8}"; 0x10CA9, "\u{10CE9}"; - 0x10CAA, "\u{10CEA}"; 0x10CAB, "\u{10CEB}"; 0x10CAC, "\u{10CEC}"; - 0x10CAD, "\u{10CED}"; 0x10CAE, "\u{10CEE}"; 0x10CAF, "\u{10CEF}"; - 0x10CB0, "\u{10CF0}"; 0x10CB1, "\u{10CF1}"; 0x10CB2, "\u{10CF2}"; - 0x118A0, "\u{118C0}"; 0x118A1, "\u{118C1}"; 0x118A2, "\u{118C2}"; - 0x118A3, "\u{118C3}"; 0x118A4, "\u{118C4}"; 0x118A5, "\u{118C5}"; - 0x118A6, "\u{118C6}"; 0x118A7, "\u{118C7}"; 0x118A8, "\u{118C8}"; - 0x118A9, "\u{118C9}"; 0x118AA, "\u{118CA}"; 0x118AB, "\u{118CB}"; - 0x118AC, "\u{118CC}"; 0x118AD, "\u{118CD}"; 0x118AE, "\u{118CE}"; - 0x118AF, "\u{118CF}"; 0x118B0, "\u{118D0}"; 0x118B1, "\u{118D1}"; - 0x118B2, "\u{118D2}"; 0x118B3, "\u{118D3}"; 0x118B4, "\u{118D4}"; - 0x118B5, "\u{118D5}"; 0x118B6, "\u{118D6}"; 0x118B7, "\u{118D7}"; - 0x118B8, "\u{118D8}"; 0x118B9, "\u{118D9}"; 0x118BA, "\u{118DA}"; - 0x118BB, "\u{118DB}"; 0x118BC, "\u{118DC}"; 0x118BD, "\u{118DD}"; - 0x118BE, "\u{118DE}"; 0x118BF, "\u{118DF}"; 0x16E40, "\u{16E60}"; - 0x16E41, "\u{16E61}"; 0x16E42, "\u{16E62}"; 0x16E43, "\u{16E63}"; - 0x16E44, "\u{16E64}"; 0x16E45, "\u{16E65}"; 0x16E46, "\u{16E66}"; - 0x16E47, "\u{16E67}"; 0x16E48, "\u{16E68}"; 0x16E49, "\u{16E69}"; - 0x16E4A, "\u{16E6A}"; 0x16E4B, "\u{16E6B}"; 0x16E4C, "\u{16E6C}"; - 0x16E4D, "\u{16E6D}"; 0x16E4E, "\u{16E6E}"; 0x16E4F, "\u{16E6F}"; - 0x16E50, "\u{16E70}"; 0x16E51, "\u{16E71}"; 0x16E52, "\u{16E72}"; - 0x16E53, "\u{16E73}"; 0x16E54, "\u{16E74}"; 0x16E55, "\u{16E75}"; - 0x16E56, "\u{16E76}"; 0x16E57, "\u{16E77}"; 0x16E58, "\u{16E78}"; - 0x16E59, "\u{16E79}"; 0x16E5A, "\u{16E7A}"; 0x16E5B, "\u{16E7B}"; - 0x16E5C, "\u{16E7C}"; 0x16E5D, "\u{16E7D}"; 0x16E5E, "\u{16E7E}"; - 0x16E5F, "\u{16E7F}"; 0x1E900, "\u{1E922}"; 0x1E901, "\u{1E923}"; - 0x1E902, "\u{1E924}"; 0x1E903, "\u{1E925}"; 0x1E904, "\u{1E926}"; - 0x1E905, "\u{1E927}"; 0x1E906, "\u{1E928}"; 0x1E907, "\u{1E929}"; - 0x1E908, "\u{1E92A}"; 0x1E909, "\u{1E92B}"; 0x1E90A, "\u{1E92C}"; - 0x1E90B, "\u{1E92D}"; 0x1E90C, "\u{1E92E}"; 0x1E90D, "\u{1E92F}"; - 0x1E90E, "\u{1E930}"; 0x1E90F, "\u{1E931}"; 0x1E910, "\u{1E932}"; - 0x1E911, "\u{1E933}"; 0x1E912, "\u{1E934}"; 0x1E913, "\u{1E935}"; - 0x1E914, "\u{1E936}"; 0x1E915, "\u{1E937}"; 0x1E916, "\u{1E938}"; - 0x1E917, "\u{1E939}"; 0x1E918, "\u{1E93A}"; 0x1E919, "\u{1E93B}"; - 0x1E91A, "\u{1E93C}"; 0x1E91B, "\u{1E93D}"; 0x1E91C, "\u{1E93E}"; - 0x1E91D, "\u{1E93F}"; 0x1E91E, "\u{1E940}"; 0x1E91F, "\u{1E941}"; - 0x1E920, "\u{1E942}"; 0x1E921, "\u{1E943}"|] - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_html.ml b/ocaml-lsp-server/vendor/cmarkit/cmarkit_html.ml deleted file mode 100644 index 40c8d8227..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_html.ml +++ /dev/null @@ -1,518 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -open Cmarkit -module C = Cmarkit_renderer.Context -module String_set = Set.Make (String) - -(* Renderer state *) - -type state = - { safe : bool; - backend_blocks : bool; - mutable ids : String_set.t; - mutable footnote_count : int; - mutable footnotes : - (* Text, id, ref count, footnote *) - (string * string * int ref * Block.Footnote.t) Label.Map.t } - -let state : state C.State.t = C.State.make () -let safe c = (C.State.get c state).safe -let backend_blocks c = (C.State.get c state).backend_blocks -let init_context ?(backend_blocks = false) ~safe c _ = - let ids = String_set.empty and footnotes = Label.Map.empty in - let st = { safe; backend_blocks; ids; footnote_count = 0; footnotes } in - C.State.set c state (Some st) - -let unique_id c id = - let st = C.State.get c state in - let rec loop ids id c = - let id' = if c = 0 then id else (String.concat "-" [id; Int.to_string c]) in - match String_set.mem id' ids with - | true -> loop ids id (c + 1) - | false -> st.ids <- String_set.add id' ids; id' - in - loop st.ids id 0 - -let footnote_id label = - let make_label l = String.map (function ' ' | '\t' -> '-' | c -> c) l in - "fn-" ^ (make_label (String.sub label 1 (String.length label - 1))) - -let footnote_ref_id fnid c = String.concat "-" ["ref"; Int.to_string c; fnid] - -let make_footnote_ref_ids c label fn = - let st = C.State.get c state in - match Label.Map.find_opt label st.footnotes with - | Some (text, id, refc, _) -> incr refc; (text, id, footnote_ref_id id !refc) - | None -> - st.footnote_count <- st.footnote_count + 1; - let text = String.concat "" ["["; Int.to_string st.footnote_count;"]"] in - let id = footnote_id label in - st.footnotes <- Label.Map.add label (text, id, ref 1, fn) st.footnotes; - text, id, footnote_ref_id id 1 - -(* Escaping *) - -let buffer_add_html_escaped_uchar b u = match Uchar.to_int u with -| 0x0000 -> Buffer.add_utf_8_uchar b Uchar.rep -| 0x0026 (* & *) -> Buffer.add_string b "&" -| 0x003C (* < *) -> Buffer.add_string b "<" -| 0x003E (* > *) -> Buffer.add_string b ">" -(* | 0x0027 (* ' *) -> Buffer.add_string b "'" *) -| 0x0022 (* '\"' *) -> Buffer.add_string b """ -| _ -> Buffer.add_utf_8_uchar b u - -let html_escaped_uchar c s = buffer_add_html_escaped_uchar (C.buffer c) s - -let buffer_add_html_escaped_string b s = - let string = Buffer.add_string in - let len = String.length s in - let max_idx = len - 1 in - let flush b start i = - if start < len then Buffer.add_substring b s start (i - start); - in - let rec loop start i = - if i > max_idx then flush b start i else - let next = i + 1 in - match String.get s i with - | '\x00' -> - flush b start i; Buffer.add_utf_8_uchar b Uchar.rep; loop next next - | '&' -> flush b start i; string b "&"; loop next next - | '<' -> flush b start i; string b "<"; loop next next - | '>' -> flush b start i; string b ">"; loop next next -(* | '\'' -> flush c start i; string c "'"; loop next next *) - | '\"' -> flush b start i; string b """; loop next next - | c -> loop start next - in - loop 0 0 - -let html_escaped_string c s = buffer_add_html_escaped_string (C.buffer c) s - -let buffer_add_pct_encoded_string b s = (* Percent encoded + HTML escaped *) - let byte = Buffer.add_char and string = Buffer.add_string in - let unsafe_hexdig_of_int i = match i < 10 with - | true -> Char.unsafe_chr (i + 0x30) - | false -> Char.unsafe_chr (i + 0x37) - in - let flush b max start i = - if start <= max then Buffer.add_substring b s start (i - start); - in - let rec loop b s max start i = - if i > max then flush b max start i else - let next = i + 1 in - match String.get s i with - | '%' (* In CommonMark destinations may have percent encoded chars *) - (* See https://tools.ietf.org/html/rfc3986 *) - (* unreserved *) - | 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '-' | '.' | '_' | '~' - (* sub-delims *) - | '!' | '$' | (*'&' | '\'' | *) '(' | ')' | '*' | '+' | ',' | ';' | '=' - (* gen-delims *) - | ':' | '/' | '?' | '#' | (* '[' | ']' cmark escapes them | *) '@' -> - loop b s max start next - | '&' -> flush b max start i; string b "&"; loop b s max next next - | '\'' -> flush b max start i; string b "'"; loop b s max next next - | c -> - flush b max start i; - let hi = (Char.code c lsr 4) land 0xF in - let lo = (Char.code c) land 0xF in - byte b '%'; - byte b (unsafe_hexdig_of_int hi); - byte b (unsafe_hexdig_of_int lo); - loop b s max next next - in - loop b s (String.length s - 1) 0 0 - -let pct_encoded_string c s = buffer_add_pct_encoded_string (C.buffer c) s - -(* Rendering functions *) - -let comment c s = - C.string c "" - -let comment_undefined_label c l = match Inline.Link.referenced_label l with -| None -> () | Some def -> comment c ("Undefined label " ^ (Label.key def)) - -let comment_unknown_def_type c l = match Inline.Link.referenced_label l with -| None -> () | Some def -> - comment c ("Unknown label definition type for " ^ (Label.key def)) - -let comment_foonote_image c l = match Inline.Link.referenced_label l with -| None -> () | Some def -> - comment c ("Footnote " ^ (Label.key def) ^ " referenced as image") - -let block_lines c = function (* newlines only between lines *) -| [] -> () | (l, _) :: ls -> - let line c (l, _) = C.byte c '\n'; C.string c l in - C.string c l; List.iter (line c) ls - -(* Inline rendering *) - -let autolink c a = - let pre = if Inline.Autolink.is_email a then "mailto:" else "" in - let url = pre ^ (fst (Inline.Autolink.link a)) in - let url = if Inline.Link.is_unsafe url then "" else url in - C.string c ""; - html_escaped_string c (fst (Inline.Autolink.link a)); - C.string c "" - -let break c b = match Inline.Break.type' b with -| `Hard -> C.string c "
\n" -| `Soft -> C.byte c '\n' - -let code_span c cs = - C.string c ""; - html_escaped_string c (Inline.Code_span.code cs); - C.string c "" - -let emphasis c e = - C.string c ""; C.inline c (Inline.Emphasis.inline e); C.string c "" - -let strong_emphasis c e = - C.string c ""; - C.inline c (Inline.Emphasis.inline e); - C.string c "" - -let link_dest_and_title c ld = - let dest = match Link_definition.dest ld with - | None -> "" - | Some (link, _) when safe c && Inline.Link.is_unsafe link -> "" - | Some (link, _) -> link - in - let title = match Link_definition.title ld with - | None -> "" - | Some title -> String.concat "\n" (List.map (fun (_, (t, _)) -> t) title) - in - dest, title - -let image ?(close = " >") c i = - match Inline.Link.reference_definition (C.get_defs c) i with - | Some (Link_definition.Def (ld, _)) -> - let plain_text c i = - let lines = Inline.to_plain_text ~break_on_soft:false i in - String.concat "\n" (List.map (String.concat "") lines) - in - let link, title = link_dest_and_title c ld in - C.string c "\""; "" - then (C.string c " title=\""; html_escaped_string c title; C.byte c '\"'); - C.string c close - | Some (Block.Footnote.Def _) -> comment_foonote_image c i - | None -> comment_undefined_label c i - | Some _ -> comment_unknown_def_type c i - -let link_footnote c l fn = - let key = Label.key (Option.get (Inline.Link.referenced_label l)) in - let text, label, ref = make_footnote_ref_ids c key fn in - let is_full_ref = match Inline.Link.reference l with - | `Ref (`Full, _, _) -> true | _ -> false - in - if is_full_ref then begin - C.string c ""; - C.inline c (Inline.Link.text l); C.string c "" - end else begin - C.string c ""; - C.string c text; C.string c "" - end - -let link c l = match Inline.Link.reference_definition (C.get_defs c) l with -| Some (Link_definition.Def (ld, _)) -> - let link, title = link_dest_and_title c ld in - C.string c " "" then (C.string c "\" title=\""; html_escaped_string c title); - C.string c "\">"; C.inline c (Inline.Link.text l); C.string c "" -| Some (Block.Footnote.Def (fn, _)) -> link_footnote c l fn -| None -> C.inline c (Inline.Link.text l); comment_undefined_label c l -| Some _ -> C.inline c (Inline.Link.text l); comment_unknown_def_type c l - -let raw_html c h = - if safe c then comment c "CommonMark raw HTML omitted" else - let line c (_, (h, _)) = C.byte c '\n'; C.string c h in - if h <> [] - then (C.string c (fst (snd (List.hd h))); List.iter (line c) (List.tl h)) - -let strikethrough c s = - C.string c ""; - C.inline c (Inline.Strikethrough.inline s); - C.string c "" - -let math_span c ms = - let tex_line c l = html_escaped_string c (Block_line.tight_to_string l) in - let tex_lines c = function (* newlines only between lines *) - | [] -> () | l :: ls -> - let line c l = C.byte c '\n'; tex_line c l in - tex_line c l; List.iter (line c) ls - in - let tex = Inline.Math_span.tex_layout ms in - if tex = [] then () else - (C.string c (if Inline.Math_span.display ms then "\\[" else "\\("); - tex_lines c tex; - C.string c (if Inline.Math_span.display ms then "\\]" else "\\)")) - -let inline c = function -| Inline.Autolink (a, _) -> autolink c a; true -| Inline.Break (b, _) -> break c b; true -| Inline.Code_span (cs, _) -> code_span c cs; true -| Inline.Emphasis (e, _) -> emphasis c e; true -| Inline.Image (i, _) -> image c i; true -| Inline.Inlines (is, _) -> List.iter (C.inline c) is; true -| Inline.Link (l, _) -> link c l; true -| Inline.Raw_html (html, _) -> raw_html c html; true -| Inline.Strong_emphasis (e, _) -> strong_emphasis c e; true -| Inline.Text (t, _) -> html_escaped_string c t; true -| Inline.Ext_strikethrough (s, _) -> strikethrough c s; true -| Inline.Ext_math_span (ms, _) -> math_span c ms; true -| _ -> comment c ""; true - -(* Block rendering *) - -let block_quote c bq = - C.string c "
\n"; - C.block c (Block.Block_quote.block bq); - C.string c "
\n" - -let code_block c cb = - let i = Option.map fst (Block.Code_block.info_string cb) in - let lang = Option.bind i Block.Code_block.language_of_info_string in - let line (l, _) = html_escaped_string c l; C.byte c '\n' in - match lang with - | Some (lang, _env) when backend_blocks c && lang.[0] = '=' -> - if lang = "=html" && not (safe c) - then block_lines c (Block.Code_block.code cb) else () - | _ -> - C.string c "
 ()
-      | Some (lang, _env) ->
-          C.string c " class=\"language-"; html_escaped_string c lang;
-          C.byte c '\"'
-      end;
-      C.byte c '>';
-      List.iter line (Block.Code_block.code cb);
-      C.string c "
\n" - -let heading c h = - let level = string_of_int (Block.Heading.level h) in - C.string c " C.byte c '>'; - | Some (`Auto id | `Id id) -> - let id = unique_id c id in - C.string c " id=\""; C.string c id; - C.string c "\">"; - end; - C.inline c (Block.Heading.inline h); - C.string c "\n" - -let paragraph c p = - C.string c "

"; C.inline c (Block.Paragraph.inline p); C.string c "

\n" - -let item_block ~tight c = function -| Block.Blank_line _ -> () -| Block.Paragraph (p, _) when tight -> C.inline c (Block.Paragraph.inline p) -| Block.Blocks (bs, _) -> - let rec loop c add_nl = function - | Block.Blank_line _ :: bs -> loop c add_nl bs - | Block.Paragraph (p,_) :: bs when tight -> - C.inline c (Block.Paragraph.inline p); loop c true bs - | b :: bs -> (if add_nl then C.byte c '\n'); C.block c b; loop c false bs - | [] -> () - in - loop c true bs -| b -> C.byte c '\n'; C.block c b - -let list_item ~tight c (i, _) = match Block.List_item.ext_task_marker i with -| None -> - C.string c "
  • "; - item_block ~tight c (Block.List_item.block i); - C.string c "
  • \n" -| Some (mark, _) -> - C.string c "
  • "; - let close = match Block.List_item.task_status_of_task_marker mark with - | `Unchecked -> - C.string c - "
    "; - "
  • \n" - | `Checked | `Other _ -> - C.string c - "
    "; - "
    \n" - | `Cancelled -> - C.string c - "
    "; - "
    \n" - in - item_block ~tight c (Block.List_item.block i); - C.string c close - -let list c l = - let tight = Block.List'.tight l in - match Block.List'.type' l with - | `Unordered _ -> - C.string c "
      \n"; - List.iter (list_item ~tight c) (Block.List'.items l); - C.string c "
    \n" - | `Ordered (start, _) -> - C.string c "\n" else - (C.string c " start=\""; C.string c (string_of_int start); - C.string c "\">\n"); - List.iter (list_item ~tight c) (Block.List'.items l); - C.string c "\n" - -let html_block c lines = - let line (l, _) = C.string c l; C.byte c '\n' in - if safe c then (comment c "CommonMark HTML block omitted"; C.byte c '\n') else - List.iter line lines - -let thematic_break c = C.string c "
    \n" - -let math_block c cb = - let line l = html_escaped_string c (Block_line.to_string l); C.byte c '\n' in - C.string c "\\[\n"; - List.iter line (Block.Code_block.code cb); - C.string c "\\]\n" - -let table c t = - let start c align tag = - C.byte c '<'; C.string c tag; - match align with - | None -> C.byte c '>'; - | Some `Left -> C.string c " class=\"left\">" - | Some `Center -> C.string c " class=\"center\">" - | Some `Right -> C.string c " class=\"right\">" - in - let close c tag = C.string c "\n" in - let rec cols c tag ~align count cs = match align, cs with - | ((a, _) :: align), (col, _) :: cs -> - start c (fst a) tag; C.inline c col; close c tag; - cols c tag ~align (count - 1) cs - | ((a, _) :: align), [] -> - start c (fst a) tag; close c tag; - cols c tag ~align (count - 1) [] - | [], (col, _) :: cs -> - start c None tag; C.inline c col; close c tag; - cols c tag ~align:[] (count - 1) cs - | [], [] -> - for i = count downto 1 do start c None tag; close c tag done; - in - let row c tag ~align count cs = - C.string c "\n"; cols c tag ~align count cs; C.string c "\n"; - in - let header c count ~align cols = row c "th" ~align count cols in - let data c count ~align cols = row c "td" ~align count cols in - let rec rows c col_count ~align = function - | ((`Header cols, _), _) :: rs -> - let align, rs = match rs with - | ((`Sep align, _), _) :: rs -> align, rs - | _ -> align, rs - in - header c col_count ~align cols; rows c col_count ~align rs - | ((`Data cols, _), _) :: rs -> - data c col_count ~align cols; rows c col_count ~align rs - | ((`Sep align, _), _) :: rs -> rows c col_count ~align rs - | [] -> () - in - C.string c "
    \n"; - rows c (Block.Table.col_count t) ~align:[] (Block.Table.rows t); - C.string c "
    " - -let block c = function -| Block.Block_quote (bq, _) -> block_quote c bq; true -| Block.Blocks (bs, _) -> List.iter (C.block c) bs; true -| Block.Code_block (cb, _) -> code_block c cb; true -| Block.Heading (h, _) -> heading c h; true -| Block.Html_block (h, _) -> html_block c h; true -| Block.List (l, _) -> list c l; true -| Block.Paragraph (p, _) -> paragraph c p; true -| Block.Thematic_break (_, _) -> thematic_break c; true -| Block.Ext_math_block (cb, _) -> math_block c cb; true -| Block.Ext_table (t, _) -> table c t; true -| Block.Blank_line _ -| Block.Link_reference_definition _ -| Block.Ext_footnote_definition _ -> true -| _ -> comment c "Unknown Cmarkit block"; C.byte c '\n'; true - -(* XHTML rendering *) - -let xhtml_block c = function -| Block.Thematic_break _ -> C.string c "
    \n"; true -| b -> block c b - -let xhtml_inline c = function -| Inline.Break (b, _) when Inline.Break.type' b = `Hard -> - C.string c "
    \n"; true -| Inline.Image (i, _) -> - image ~close:" />" c i; true -| i -> inline c i - -(* Document rendering *) - -let footnotes c fns = - (* XXX we could do something about recursive footnotes and footnotes in - footnotes here. *) - let fns = Label.Map.fold (fun _ fn acc -> fn :: acc) fns [] in - let fns = List.sort Stdlib.compare fns in - let footnote c (_, id, refc, fn) = - C.string c "
  • \n"; - C.block c (Block.Footnote.block fn); - C.string c ""; - for r = 1 to !refc do - C.string c "↩︎︎"; - if !refc > 1 then - (C.string c ""; C.string c (Int.to_string r); C.string c ""); - C.string c "" - done; - C.string c ""; - C.string c "
  • " - in - C.string c "
      \n"; - List.iter (footnote c) fns; - C.string c "
    \n" - -let doc c d = - C.block c (Doc.block d); - let st = C.State.get c state in - if Label.Map.is_empty st.footnotes then () else footnotes c st.footnotes; - true - -(* Renderer *) - -let renderer ?backend_blocks ~safe () = - let init_context = init_context ?backend_blocks ~safe in - Cmarkit_renderer.make ~init_context ~inline ~block ~doc () - -let xhtml_renderer ?backend_blocks ~safe () = - let init_context = init_context ?backend_blocks ~safe in - let inline = xhtml_inline and block = xhtml_block in - Cmarkit_renderer.make ~init_context ~inline ~block ~doc () - -let of_doc ?backend_blocks ~safe d = - Cmarkit_renderer.doc_to_string (renderer ~safe ()) d - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_html.mli b/ocaml-lsp-server/vendor/cmarkit/cmarkit_html.mli deleted file mode 100644 index b5d05c135..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_html.mli +++ /dev/null @@ -1,185 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(** Rendering CommonMark to HTML. - - Generates HTML fragments, consult the - {{!integration}integration notes} for requirements on the webpage. - - See {{!page-index.quick}a quick example} and - {{!page_frame}another one}. - - {b Warning.} Rendering outputs are unstable, they may be tweaked - even between minor versions of the library. *) - -(** {1:rendering Rendering} *) - -val of_doc : ?backend_blocks:bool -> safe:bool -> Cmarkit.Doc.t -> string -(** [of_doc ~safe d] is an HTML fragment for [d]. See {!renderer} - for more details and documentation about rendering options. *) - -(** {1:renderers Renderers} *) - -val renderer : ?backend_blocks:bool -> safe:bool -> unit -> Cmarkit_renderer.t -(** [renderer ~safe ()] is the default HTML renderer. This renders the - strict CommonMark abstract syntax tree and the supported Cmarkit - {{!Cmarkit.extensions}extensions}. - - The inline, block and document renderers always return - [true]. Unknown block and inline values are rendered by an HTML - comment. - - The following options are available: - - {ul - {- [safe], if [true] {{!Cmarkit.Block.extension-Html_block}HTML blocks} and - {{!Cmarkit.Inline.extension-Raw_html}raw HTML inlines} are discarded and - replaced by an HTML comment in the output. Besides the URLs of - autolinks, links and images that satisfy - {!Cmarkit.Inline.Link.is_unsafe} are replaced by the empty string. - - Using safe renderings is a good first step at preventing - {{:https://en.wikipedia.org/wiki/Cross-site_scripting}XSS} from - untrusted user inputs but you should rather post-process rendering - outputs with a dedicated HTML sanitizer.} - {- [backend_blocks], if [true], code blocks with language [=html] - are written verbatim in the output (iff [safe] is [true]) and - any other code block whose langage starts with [=] is - dropped. Defaults to [false].}} - - See {{!Cmarkit_renderer.example}this example} to extend or - selectively override the renderer. *) - -val xhtml_renderer : - ?backend_blocks:bool -> safe:bool -> unit -> Cmarkit_renderer.t -(** [xhtml_renderer] is like {!val-renderer} but explicitely closes - empty tags to possibly make the output valid XML. Note that it - still renders HTML blocks and inline raw HTML unless {!safe} is - [true] (which also suppresses some URLs). - - See {{!Cmarkit_renderer.example}this example} to extend or - selectively override the renderer. *) - -(** {1:render Render functions} - - Only useful if you extend the renderer. *) - -val safe : Cmarkit_renderer.context -> bool -(** [safe c] is [true] if a safe rendering is requested. - See {!renderer} for more information. *) - -val html_escaped_uchar : Cmarkit_renderer.context -> Uchar.t -> unit -(** [html_escaped_uchar c u] renders the UTF-8 encoding of [u] on [c] - with HTML markup delimiters [<] [>] [&] and ["] escaped - to HTML entities (Single quotes ['] are not escaped use ["] to delimit your - attributes). This also renders U+0000 to {!Uchar.rep}. *) - -val buffer_add_html_escaped_uchar : Buffer.t -> Uchar.t -> unit -(** [buffer_add_html_escaped_uchar] is {!html_escaped_uchar} but appends - to a buffer value. *) - -val html_escaped_string : Cmarkit_renderer.context -> string -> unit -(** [html_escaped_string c s] renders string [s] on [c] with HTML - markup delimiters [<], [>], [&], and ["] escaped to HTML - entities (Single quotes ['] are not escaped, use ["] to delimit your - attributes). *) - -val buffer_add_html_escaped_string : Buffer.t -> string -> unit -(** [buffer_add_html_escaped_string] is {!html_escaped_string} but appends - to a buffer value. *) - -val pct_encoded_string : Cmarkit_renderer.context -> string -> unit -(** [pct_encoded_string c s] renders string [s] on [c] with everything - percent encoded except [%] and the - {{:https://datatracker.ietf.org/doc/html/rfc3986#section-2.3} - [unreserved]}, - {{:https://datatracker.ietf.org/doc/html/rfc3986#section-2.2} - [sub-delims]} - and the {{:https://datatracker.ietf.org/doc/html/rfc3986#section-2.2} - [gen-delims]} - URI characters except brackets [\[] and [\]] (to match the [cmark] tool). - - In other words only characters [%] [a-z] [A-Z] [0-9] [-] [.] [_] [~] [!] - [$] [&] ['] [(] [)] [*] [+] [,] [;] [=] [:] [/] [?] [#] [@] - are not percent-encoded. - - {b Warning.} The function also replaces both [&] and ['] by their - corresponding HTML entities, so you can't use this in a context - that doesn't allow entities. Besides this assumes [s] may already - have percent encoded bits so it doesn't percent encode [%], as such you - can't use this as a general percent encode function. *) - -val buffer_add_pct_encoded_string : Buffer.t -> string -> unit -(** [buffer_add_pct_encoded_string b s] is {!pct_encoded_string} but - appends to a buffer value. *) - -(** {1:integration HTML integration notes} - - {2:code_blocks Code blocks} - - If a language [lang] can be extracted from the info string of a - code block with - {!Cmarkit.Block.Code_block.language_of_info_string}, a - [language-lang] class is added to the corresponding [code] - element. If you want to highlight the syntax, adding - {{:https://highlightjs.org/}highlight.js} to your page is an - option. - - {2:ids Heading identifiers} - - Headings identifiers and anchors are added to the output whenever - {!Cmarkit.Block.Heading.val-id} holds a value. If the identifier - already exists it is made unique by appending ["-"] and the first - number starting from 1 that makes it unique. - - {2:math Maths} - - If your document has {!Cmarkit.Inline.extension-Ext_math_span} - inlines or {!Cmarkit.Block.extension-Ext_math_block} blocks, the - default renderer outputs them in [\(], [\)] and - [\\[], [\\]] delimiters. You should add - {{:https://katex.org/}K{^A}T{_E}X} or - {{:https://www.mathjax.org/}MathJax} in your page to let these - bits be rendered by the typography they deserve. - - {2:page_frame Page frame} - - The default renderers only generate HTML fragments. You may - want to add a page frame. For example: -{[ -let html_doc_of_md ?(lang = "en") ~title ~safe md = - let doc = Cmarkit.Doc.of_string md in - let r = Cmarkit_html.renderer ~safe () in - let buffer_add_doc = Cmarkit_renderer.buffer_add_doc r in - let buffer_add_title = Cmarkit_html.buffer_add_html_escaped_string in - Printf.kbprintf Buffer.contents (Buffer.create 1024) -{| - - - - %a - - -%a -|} - lang buffer_add_title title buffer_add_doc doc -]} -*) - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_latex.ml b/ocaml-lsp-server/vendor/cmarkit/cmarkit_latex.ml deleted file mode 100644 index 2439be6f1..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_latex.ml +++ /dev/null @@ -1,423 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -open Cmarkit -module C = Cmarkit_renderer.Context -module String_set = Set.Make (String) - -(* State *) - -type state = - { backend_blocks : bool; - mutable sot : bool; (* start of text *) - mutable labels : String_set.t; - mutable footnote_labels : string Label.Map.t; } - -let state : state C.State.t = C.State.make () -let get_state c = C.State.get c state -let backend_blocks c = (get_state c).backend_blocks -let init_context ?(backend_blocks = false) c _ = - let labels = String_set.empty and footnote_labels = Label.Map.empty in - let st = { backend_blocks; sot = true; labels; footnote_labels } in - C.State.set c state (Some st) - -let unique_label c l = - let st = C.State.get c state in - let rec loop labels l c = - let l' = if c = 0 then l else (String.concat "-" [l; Int.to_string c]) in - match String_set.mem l' labels with - | true -> loop labels l (c + 1) - | false -> st.labels <- String_set.add l' labels; l' - in - loop st.labels l 0 - -let make_label l = (* latex seems to choke on these underscores in labels *) - String.map (function '_' | ' ' | '\t' -> '-' | c -> c) l - -let footnote_label c id = - let st = get_state c in - match Label.Map.find_opt id st.footnote_labels with - | Some l -> l, false - | None -> - let l = make_label (String.sub id 1 (String.length id - 1)) in - let l = "fn-" ^ l in - st.footnote_labels <- Label.Map.add id l st.footnote_labels; - l, true - -(* Escaping *) - -let buffer_add_latex_escaped_uchar b u = match Uchar.to_int u with -| 0x0000 -> Buffer.add_utf_8_uchar b Uchar.rep -| 0x0023 (* # *) -> Buffer.add_string b {|\#|} -| 0x0024 (* $ *) -> Buffer.add_string b {|\$|} -| 0x0025 (* % *) -> Buffer.add_string b {|\%|} -| 0x0026 (* & *) -> Buffer.add_string b {|\&|} -| 0x005C (* \ *) -> Buffer.add_string b {|\textbackslash{}|} -| 0x005E (* ^ *) -> Buffer.add_string b {|\textasciicircum{}|} -| 0x005F (* _ *) -> Buffer.add_string b {|\_|} -| 0x007B (* { *) -> Buffer.add_string b {|\{|} -| 0x007D (* } *) -> Buffer.add_string b {|\}|} -| 0x007E (* ~ *) -> Buffer.add_string b {|\textasciitilde{}|} -| _ -> Buffer.add_utf_8_uchar b u - -let latex_escaped_uchar c u = buffer_add_latex_escaped_uchar (C.buffer c) u - -let buffer_add_latex_escaped_string b s = - let string = Buffer.add_string in - let flush b max start i = - if start <= max then Buffer.add_substring b s start (i - start); - in - let rec loop b s max start i = - if i > max then flush b max start i else - let next = i + 1 in - match String.get s i with - | '\x00' -> - flush b max start i; Buffer.add_utf_8_uchar b Uchar.rep; - loop b s max next next - | '#' -> flush b max start i; string b {|\#|}; loop b s max next next - | '$' -> flush b max start i; string b {|\$|}; loop b s max next next - | '%' -> flush b max start i; string b {|\%|}; loop b s max next next - | '&' -> flush b max start i; string b {|\&|}; loop b s max next next - | '\\' -> - flush b max start i; string b {|\textbackslash{}|}; - loop b s max next next - | '^' -> - flush b max start i; string b {|\textasciicircum{}|}; - loop b s max next next - | '_' -> flush b max start i; string b {|\_|}; loop b s max next next - | '{' -> flush b max start i; string b {|\{|}; loop b s max next next - | '}' -> flush b max start i; string b {|\}|}; loop b s max next next - | '~' -> - flush b max start i; string b {|\textasciitilde{}|}; - loop b s max next next - | c -> loop b s max start next - in - loop b s (String.length s - 1) 0 0 - -let latex_escaped_string c s = buffer_add_latex_escaped_string (C.buffer c) s - -(* Rendering functions *) - -let newline c = - (* Block generally introduce newlines, except the first one. *) - let st = get_state c in if st.sot then st.sot <- false else C.byte c '\n' - -let comment c s = C.string c "% "; latex_escaped_string c s; newline c - -let comment_undefined_label c l = match Inline.Link.referenced_label l with -| None -> () | Some def -> comment c ("Undefined label " ^ (Label.key def)) - -let comment_unknown_def_type c l = match Inline.Link.referenced_label l with -| None -> () | Some def -> - comment c ("Unknown label definition type for " ^ (Label.key def)) - -let comment_foonote_image c l = match Inline.Link.referenced_label l with -| None -> () | Some def -> - comment c ("Footnote " ^ (Label.key def) ^ " referenced as image") - -let block_lines c = function (* newlines only between lines *) -| [] -> () | l :: ls -> - let line c l = newline c; C.string c (Block_line.to_string l) in - C.string c (Block_line.to_string l); List.iter (line c) ls - -let tight_block_lines c = function (* newlines only between lines *) -| [] -> () | l :: ls -> - let line c l = newline c; C.string c (Block_line.tight_to_string l) in - C.string c (Block_line.tight_to_string l); List.iter (line c) ls - -(* Inline rendering *) - -let autolink c a = - let pre = if Inline.Autolink.is_email a then "mailto:" else "" in - let link = pre ^ (fst (Inline.Autolink.link a)) in - C.string c "\\url{"; latex_escaped_string c link; C.byte c '}' - -let code_span c cs = - let code = Inline.Code_span.code cs in - C.string c "\\texttt{"; latex_escaped_string c code; C.byte c '}' - -let emphasis c e = - C.string c "\\emph{"; C.inline c (Inline.Emphasis.inline e); C.byte c '}' - -let link c l = match Inline.Link.reference_definition (C.get_defs c) l with -| Some (Link_definition.Def (ld, _)) -> - let d = match Link_definition.dest ld with None -> "" | Some (u, _) -> u in - let dlen = String.length d in - begin match dlen > 0 && d.[0] = '#' with - | true -> - let label = make_label (String.sub d 1 (dlen - 1)) in - C.string c "\\hyperref["; - latex_escaped_string c label; - C.string c "]{"; - C.inline c (Inline.Link.text l); C.byte c '}' - | false -> - C.string c "\\href{"; - latex_escaped_string c d; - C.string c "}{"; - C.inline c (Inline.Link.text l); C.byte c '}' - end -| Some (Block.Footnote.Def (fn, _)) -> - let key = Label.key (Option.get (Inline.Link.referenced_label l)) in - let l, new' = footnote_label c key in - begin match new' with - | false -> - C.string c "\\textsuperscript{\\ref{"; C.string c l; C.string c "}}" - | true -> - C.string c "\\footnote{\\label{"; C.string c l; C.string c "}"; - C.block c (Block.Footnote.block fn); - C.string c "}" - end -| None -> C.inline c (Inline.Link.text l); comment_undefined_label c l -| Some _ -> C.inline c (Inline.Link.text l); comment_unknown_def_type c l - -let image c i = match Inline.Link.reference_definition (C.get_defs c) i with -| Some (Link_definition.Def (ld, _)) -> - let d = match Link_definition.dest ld with - | None -> "" | Some (u, _) -> u - in - let is_external d = - String.starts_with ~prefix:"http:" d || - String.starts_with ~prefix:"https:" d - in - if is_external d then link c i else - begin - C.string c "\\protect\\includegraphics{"; - latex_escaped_string c d; - C.byte c '}' - end -| Some (Block.Footnote.Def _) -> comment_foonote_image c i -| None -> comment_undefined_label c i -| Some _ -> comment_unknown_def_type c i - -let strong_emphasis c e = - C.string c "\\textbf{"; C.inline c (Inline.Emphasis.inline e); C.byte c '}' - -let break c b = match Inline.Break.type' b with -| `Hard -> C.string c "\\\\"; newline c -| `Soft -> newline c - -let text c t = latex_escaped_string c t - -let strikethrough c s = - C.string c "\\sout{"; C.inline c (Inline.Strikethrough.inline s); C.byte c '}' - -let math_span c ms = - let tex = Inline.Math_span.tex_layout ms in - C.string c (if Inline.Math_span.display ms then "\\[" else "\\("); - tight_block_lines c tex; - C.string c (if Inline.Math_span.display ms then "\\]" else "\\)") - -let inline c = function -| Inline.Autolink (a, _) -> autolink c a; true -| Inline.Break (b, _) -> break c b; true -| Inline.Code_span (cs, _) -> code_span c cs; true -| Inline.Emphasis (e, _) -> emphasis c e; true -| Inline.Image (i, _) -> image c i; true -| Inline.Inlines (is, _) -> List.iter (C.inline c) is; true -| Inline.Link (l, _) -> link c l; true -| Inline.Raw_html (_, _) -> comment c "Raw CommonMark HTML omitted"; true -| Inline.Strong_emphasis (e, _) -> strong_emphasis c e; true -| Inline.Text (t, _) -> text c t; true -| Inline.Ext_strikethrough (s, _) -> strikethrough c s; true -| Inline.Ext_math_span (ms, _) -> math_span c ms; true -| _ -> comment c "Unknown Cmarkit inline"; true - -(* Block rendering *) - -let block_quote c bq = - newline c; - C.string c "\\begin{quote}"; - C.block c (Block.Block_quote.block bq); - C.string c "\\end{quote}"; - newline c - -let code_block c cb = - let info = Option.map fst (Block.Code_block.info_string cb) in - let lang = Option.bind info Block.Code_block.language_of_info_string in - let code = Block.Code_block.code cb in - let raw_line (l, _) = C.string c l; newline c in - let line = raw_line (* XXX: escape or not ? *) in - match lang with - | Some (lang, _env) when backend_blocks c && lang.[0] = '=' -> - if lang = "=latex" then block_lines c code else () - | _ -> - newline c; - begin match lang with - | None -> - C.string c "\\begin{verbatim}"; newline c; - List.iter line code; - C.string c "\\end{verbatim}" - | Some (lang, _env) -> - C.string c "\\begin{lstlisting}[language="; - C.string c lang; C.byte c ']'; newline c; - List.iter line code; - C.string c "\\end{lstlisting}" - end; - newline c - -let heading c h = - let cmd = match Block.Heading.level h with - | 1 -> "section{" | 2 -> "subsection{" | 3 -> "subsubsection{" - | 4 -> "paragraph{" | 5 -> "subparagraph{" | 6 -> "subparagraph{" - | _ -> "subparagraph{" - in - let i = Block.Heading.inline h in - newline c; - C.byte c '\\'; C.string c cmd; C.inline c i; C.byte c '}'; - begin match Block.Heading.id h with - | None -> () - | Some (`Auto id | `Id id) -> - let label = unique_label c (make_label id) in - C.string c "\\label{"; latex_escaped_string c label; C.byte c '}' - end; - newline c - -let list_item c (i, _meta) = - C.string c "\\item{}"; - begin match Block.List_item.ext_task_marker i with - | None -> () - | Some (u, _) -> (* Something better can likely be done *) - C.string c " \\lbrack"; - begin match Uchar.to_int u = 0x0020 with - | true -> C.string c "\\phantom{x}" - | false -> C.byte c ' '; C.utf_8_uchar c u - end; - C.string c "\\rbrack \\enspace" - end; - C.block c (Block.List_item.block i) - -let list c l = match Block.List'.type' l with -| `Unordered _ -> - newline c; - C.string c "\\begin{itemize}"; newline c; - List.iter (list_item c) (Block.List'.items l); - C.string c "\\end{itemize}"; - newline c -| `Ordered (start, _) -> - newline c; - C.string c "\\begin{enumerate}"; - if start <> 1 - then (C.string c "[start="; C.string c (Int.to_string start); C.byte c ']'); - newline c; - List.iter (list_item c) (Block.List'.items l); - C.string c "\\end{enumerate}"; - newline c - -let html_block c _ = newline c; comment c "CommonMark HTML block omitted" - -let paragraph c p = - newline c; C.inline c (Block.Paragraph.inline p); newline c - -let thematic_break c = - newline c; - C.string c "\\begin{center}\\rule{0.5\\linewidth}{.25pt}\\end{center}"; - newline c - -let math_block c cb = - let line l = C.string c (Block_line.to_string l); newline c in - C.string c "\\["; newline c; - List.iter line (Block.Code_block.code cb); - C.string c "\\]"; newline c - -let table c t = - let start c align op = - begin match align with - | None -> C.byte c '{'; - | Some `Left -> C.string c "\\multicolumn{1}{l}{" - | Some `Center -> C.string c "\\multicolumn{1}{c}{" - | Some `Right -> C.string c "\\multicolumn{1}{r}{" - end; - if op <> "" then C.string c op; - in - let close c = C.byte c '}'; newline c in - let rec cols c op ~align count cs = match align, cs with - | ((a, _) :: align), (col, _) :: cs -> - start c (fst a) op; C.inline c col; close c; - if count > 1 then (C.string c " &"; newline c); - cols c op ~align (count - 1) cs - | [], (col, _) :: cs -> - start c None op; C.inline c col; close c; - if count > 1 then (C.string c " &"; newline c); - cols c op ~align:[] (count - 1) cs - | (a :: align), [] -> - if count > 1 then (C.string c "&"; newline c); - cols c op ~align (count - 1) [] - | [], [] -> - for i = count downto 2 do C.string c "&"; newline c done; - C.string c "\\\\"; newline c - in - let header c count ~align cs = cols c "\\bfseries{}" ~align count cs in - let data c count ~align cs = cols c "" ~align count cs in - let rec rows c col_count ~align = function - | ((`Header cols, _), _) :: rs -> - let align, rs = match rs with - | ((`Sep align, _), _) :: rs -> align, rs - | _ -> align, rs - in - header c col_count ~align cols; - C.string c "\\hline"; newline c; - rows c col_count ~align rs - | ((`Data cols, _), _) :: rs -> - data c col_count ~align cols; rows c col_count ~align rs - | ((`Sep align, _), _) :: rs -> rows c col_count ~align rs - | [] -> () - in - newline c; C.string c "\\bigskip"; newline c; - C.string c "\\begin{tabular}{"; - for i = 1 to Block.Table.col_count t do C.byte c 'l' done; - C.byte c '}'; newline c; - begin match Block.Table.rows t with - | (((`Data _ | `Sep _), _), _) :: _ -> C.string c "\\hline"; newline c - | _ -> () - end; - rows c (Block.Table.col_count t) ~align:[] (Block.Table.rows t); - C.string c "\\hline"; newline c; - C.string c "\\end{tabular}"; - newline c; C.string c "\\bigskip"; newline c - -let block c = function -| Block.Block_quote (bq, _) -> block_quote c bq; true -| Block.Blocks (bs, _) -> List.iter (C.block c) bs; true -| Block.Code_block (cb, _) -> code_block c cb; true -| Block.Heading (h, _) -> heading c h; true -| Block.Html_block (html, _) -> html_block c html; true -| Block.List (l, _) -> list c l; true -| Block.Paragraph (p, _) -> paragraph c p; true -| Block.Thematic_break _ -> thematic_break c; true -| Block.Ext_math_block (cb, _)-> math_block c cb; true -| Block.Ext_table (t, _)-> table c t; true -| Block.Blank_line _ -> true -| Block.Link_reference_definition _ -| Block.Ext_footnote_definition _ -> true; -| _ -> comment c "Unknown Cmarkit block"; true - -(* Document rendering *) - -let doc c d = C.block c (Doc.block d); true - -(* Renderer *) - -let renderer ?backend_blocks () = - let init_context = init_context ?backend_blocks in - Cmarkit_renderer.make ~init_context ~inline ~block ~doc () - -let of_doc ?backend_blocks d = - Cmarkit_renderer.doc_to_string (renderer ?backend_blocks ()) d - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_latex.mli b/ocaml-lsp-server/vendor/cmarkit/cmarkit_latex.mli deleted file mode 100644 index 09ededa89..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_latex.mli +++ /dev/null @@ -1,226 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(** Rendering CommonMark to L{^A}T{_E}X. - - Generates L{^A}T{_E}X fragments, consult the {{!integration} - integration notes} for requirements on the document. - - See {{!page-index.quick}a quick example} and {{!doc_frame}another one}. - - {b Warning.} Rendering outputs are unstable, they may be tweaked even - between minor versions of the library. *) - -(** {1:rendering Rendering} *) - -val of_doc : ?backend_blocks:bool -> Cmarkit.Doc.t -> string -(** [of_doc d] is a L{^A}T{_E}X fragment for [d]. See {!val-renderer} - for more details and documentation about rendering options. *) - -(** {1:renderer Renderer} *) - -val renderer : ?backend_blocks:bool -> unit -> Cmarkit_renderer.t -(** [renderer] is a default L{^A}T{_E}X renderer. This renders - the strict CommonMark abstract syntax tree and the supported - Cmarkit {{!Cmarkit.extensions}extensions}. - - The inline, block and document renderers always return - [true]. Unknown block and inline values are rendered by a - L{^A}T{_E}X comment. - - The following options are available: - - {ul - {- [backend_blocks], if [true], code blocks with language [=latex] - are written verbatim in the output and any other code block whose - langage starts with [=] is dropped. Defaults to [false].}} - - See {{!Cmarkit_renderer.example}this example} to extend or - selectively override the renderer. *) - -(** {1:render Render functions} - - Only useful if you extend the renderer. *) - -val newline : Cmarkit_renderer.context -> unit -(** [newline c] starts a new line. Except on the first call on [c] which is - a nop. *) - -val latex_escaped_uchar : Cmarkit_renderer.context -> Uchar.t -> unit -(** [latex_escaped_uchar c u] renders the UTF-8 encoding of [u] on [c] - propertly escaped for L{^A}T{_E}X. That is the characters - [&] [%] [$] [#] [_] [{] [}] [~] [^] [\ ] - are escaped. This also renders U+0000 to {!Uchar.rep}. *) - -val buffer_add_latex_escaped_uchar : Buffer.t -> Uchar.t -> unit -(** [buffer_add_latex_escaped_uchar] is {!latex_escaped_uchar} but appends - to a buffer value. *) - -val latex_escaped_string : Cmarkit_renderer.context -> string -> unit -(** [latex_escaped_string c s] renders string [s] on [c] with - characters [&] [%] [$] [#] [_] [{] [}] [~] [^] [\ ] escaped. This - also escapes U+0000 to {!Uchar.rep}. *) - -val buffer_add_latex_escaped_string : Buffer.t -> string -> unit -(** [buffer_add_latex_escaped_string] is {!latex_escaped_string} - but acts on a buffer value. *) - -(** {1:integration L{^A}T{_E}X integration notes} - - Along with the built-in [graphicx] package, the following - L{^A}T{_E}X packages are needed to use the outputs of the default - renderer: -{v -tlmgr install enumitem listings hyperref # Required -tlmgr install ulem # Strikethrough extension -tlmgr install bera fontspec # Optional -v} - This means you should have at least the following in your - document preamble: -{v -% Required -\usepackage{graphicx} -\usepackage{enumitem} -\usepackage{listings} -\usepackage{hyperref} -\usepackage[normalem]{ulem} % Strikethrough extension - -% Optional -\usepackage[scaled=0.8]{beramono} % A font for code blocks -\usepackage{fontspec} % Supports more Unicode characters -v} - - See the sections below for more details. - - {2:char_encoding Character encoding} - - The output is UTF-8 encoded. - {{:https://tug.org/TUGboat/tb39-1/tb121ltnews28.pdf}It became} the - the default encoding for L{^A}T{_E}X in 2018. But if you are using - an older version a [\usepackage[utf8]{inputenc}] may be needed. - - Using [xelatex] rather than [pdflatex] will not get stuck on missing - glyphs. - - {2:links Autolinks and links} - - The {{:https://www.ctan.org/pkg/hyperref}[hyperref]} package is - used to render links ([\href]) and autolink ([\url]). Link - destination starting with a [#] are assumed to refer to - {{!labels}section labels} and are rendered using the [\hyperref] - macro, with the [#] chopped. - - {2:images Images} - - Images are inserted using the - {{:https://ctan.org/pkg/graphicx}graphicx}'s package. Only - images with relative URLs are supported, those that point - to external ressources on the www are turned into links. - - {2:labels Section labels} - - Section labels are added to the output whenever - {!Cmarkit.Block.Heading.val-id} holds a value. If the identifier - already exists it is made unique by appending ["-"] and the first - number starting from 1 that makes it unique. Also the character - [_] seems problematic in labels even when escaped, we map it to [-] - (if you know any better get in touch). - - {2:lists Lists} - - To support the starting point of ordereded lists without having to - fiddle with [enumi] counters, the - {{:https://www.ctan.org/pkg/enumitem}[enumitem]} package is used. - - {2:code_blocks Code blocks} - - If a language [lang] can be - {{!Cmarkit.Block.Code_block.language_of_info_string}extracted} - from a code block info string, the - {{:https://www.ctan.org/pkg/listings}[listings]} package is used - with the corresponding language in a [lstlisting] environment. - Otherwise the built-in [verbatim] environment is used. - - Note that the [listings] package has no definition for the [ocaml] - language, the default renderings are a bit subpar and - break on character literals with double quotes. This improves things: -{v -\lstset{ - columns=[c]fixed, - basicstyle=\small\ttfamily, - keywordstyle=\bfseries, - upquote=true, - commentstyle=\slshape, - breaklines=true, - showstringspaces=false} - -\lstdefinelanguage{ocaml}{language=[objective]caml, - % Fixes double quotes in char literals - literate={'"'}{\textquotesingle "\textquotesingle}3 - {'\\"'}{\textquotesingle \textbackslash"\textquotesingle}4, -} -v} - - {2:doc_frame Document frame} - - The default renderer only generates L{^A}T{_E}X fragments. You - may want to add a document frame. For example: -{[ -let latex_doc_of_md ?(title = "") md = - let doc = Cmarkit.Doc.of_string md in - let r = Cmarkit_latex.renderer () in - let buffer_add_doc = Cmarkit_renderer.buffer_add_doc r in - let buffer_add_title = Cmarkit_latex.buffer_add_latex_escaped_string in - let maketitle = if title = "" then "" else {|\maketitle|} in - Printf.kbprintf Buffer.contents (Buffer.create 1024) -{|\documentclass{article} - -\usepackage{graphicx} -\usepackage{enumitem} -\usepackage{listings} -\usepackage{hyperref} -\usepackage[normalem]{ulem} -\usepackage[scaled=0.8]{beramono} -\usepackage{fontspec} - -\lstset{ - columns=[c]fixed, - basicstyle=\small\ttfamily, - keywordstyle=\bfseries, - upquote=true, - commentstyle=\slshape, - breaklines=true, - showstringspaces=false} - -\lstdefinelanguage{ocaml}{language=[objective]caml, - literate={'"'}{\textquotesingle "\textquotesingle}3 - {'\\"'}{\textquotesingle \textbackslash"\textquotesingle}4, -} - -\title{%a} -\begin{document} -%s -%a -\end{document}|} buffer_add_title title maketitle buffer_add_doc doc -]} - -Ignore this: ". -*) - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_renderer.ml b/ocaml-lsp-server/vendor/cmarkit/cmarkit_renderer.ml deleted file mode 100644 index e52648a6f..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_renderer.ml +++ /dev/null @@ -1,104 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(* Renderers *) - -module Dict = Cmarkit_base.Dict - -type t = - { init_context : context -> Cmarkit.Doc.t -> unit; - inline : inline; - block : block; - doc : doc; } - -and context = - { renderer : t; - mutable state : Dict.t; - b : Buffer.t; - mutable doc : Cmarkit.Doc.t } - -and inline = context -> Cmarkit.Inline.t -> bool -and block = context -> Cmarkit.Block.t -> bool -and doc = context -> Cmarkit.Doc.t -> bool - -let nop _ _ = () -let none _ _ = false - -let make - ?(init_context = nop) ?(inline = none) ?(block = none) ?(doc = none) () - = - { init_context; inline; block; doc } - -let compose g f = - let init_context c d = g.init_context c d; f.init_context c d in - let block c b = f.block c b || g.block c b in - let inline c i = f.inline c i || g.inline c i in - let doc c d = f.doc c d || g.doc c d in - { init_context; inline; block; doc } - -let init_context r = r.init_context -let inline r = r.inline -let block r = r.block -let doc r = r.doc - -module Context = struct - type t = context - let make renderer b = - { renderer; b; state = Dict.empty; doc = Cmarkit.Doc.empty } - - let buffer c = c.b - let renderer c = c.renderer - let get_doc (c : context) = c.doc - let get_defs (c : context) = Cmarkit.Doc.defs c.doc - - module State = struct - type 'a t = 'a Dict.key - let make = Dict.key - let find c st = Dict.find st c.state - let get c st = Option.get (Dict.find st c.state) - let set c st = function - | None -> c.state <- Dict.remove st c.state - | Some s -> c.state <- Dict.add st s c.state - end - - let init c d = c.renderer.init_context c d - - let invalid_inline _ = invalid_arg "Unknown Cmarkit.Inline.t case" - let invalid_block _ = invalid_arg "Unknown Cmarkit.Block.t case" - let unhandled_doc _ = invalid_arg "Unhandled Cmarkit.Doc.t" - - let byte r c = Buffer.add_char r.b c - let utf_8_uchar r u = Buffer.add_utf_8_uchar r.b u - let string c s = Buffer.add_string c.b s - let inline c i = ignore (c.renderer.inline c i || invalid_inline i) - let block c b = ignore (c.renderer.block c b || invalid_block b) - let doc (c : context) d = - c.doc <- d; init c d; - ignore (c.renderer.doc c d || unhandled_doc d); - c.doc <- Cmarkit.Doc.empty -end - -let doc_to_string r d = - let b = Buffer.create 1024 in - let c = Context.make r b in - Context.doc c d; Buffer.contents b - -let buffer_add_doc r b d = Context.doc (Context.make r b) d - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/cmarkit_renderer.mli b/ocaml-lsp-server/vendor/cmarkit/cmarkit_renderer.mli deleted file mode 100644 index 1f14ec234..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/cmarkit_renderer.mli +++ /dev/null @@ -1,275 +0,0 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - ---------------------------------------------------------------------------*) - -(** Renderer abstraction. - - Stateful renderer abstraction to render documents in {!Stdlib.Buffer.t} - values. - - {b Note.} This is a low-level interface. For quick and standard - renderings see {!Cmarkit_html.of_doc}, {!Cmarkit_latex.of_doc} and - {!Cmarkit_commonmark.of_doc}. If you want to extend them, - see {{!example}this example}. *) - -(** {1:rendering Rendering} *) - -type t -(** The type for renderers. *) - -val doc_to_string : t -> Cmarkit.Doc.t -> string -(** [doc_to_string r d] renders document [d] to a string using renderer [r]. *) - -val buffer_add_doc : t -> Buffer.t -> Cmarkit.Doc.t -> unit -(** [buffer_add_doc r b d] renders document [d] on buffer [b] using - renderer [r]. *) - -(** {1:renderers Renderers} *) - -type context -(** The type for rendering contexts, holds a renderer, a - {!Stdlib.Buffer.t} value to act on and rendering state. *) - -type inline = context -> Cmarkit.Inline.t -> bool -(** The type for inline renderers. - - Return [false] if you are not interested in rendering the given - inline. Use {!Context.inline} and {!Context.block} on the given - context if you need to invoke the renderer recursively. *) - -type block = context -> Cmarkit.Block.t -> bool -(** The type for block renderers. - - Return [false] if you are not interested in rendering the given - block. Use {!Context.inline} and {!Context.block} with the given - context if you need to invoke the renderer recursively. *) - -type doc = context -> Cmarkit.Doc.t -> bool -(** The type for document renderers. - - Return [false] if you are not interested in rendering the given - document. Use {!Context.inline}, {!Context.block} and {!Context.doc} - with the given context if you need to invoke the renderer recursively. *) - -val make : - ?init_context:(context -> Cmarkit.Doc.t -> unit) -> - ?inline:inline -> ?block:block -> ?doc:doc -> unit -> t -(** [make ?init_context ?inline ?block ?doc ()] is a renderer using - [inline], [block], [doc] to render documents. They all default to - [(fun _ _ -> false)], which means that by default they defer to - next renderer (see {!compose}). - - [init_context] is used to initialize the context for the renderer - before a document render. It defaults to [fun _ _ -> ()]. *) - -val compose : t -> t -> t -(** [compose g f] renders first with [f] and if a renderer returns [false], - falls back on its counterpart in [g]. - - The {!init_context} of the result calls [g]'s initialization - context function first, followed by the one of [f]. This means - [f]'s initialization function can assume the context is already - setup for [g]. *) - -(** {2:accessors Accessors} - - Normally you should not need these but you may want to peek - into other renderers. *) - -val init_context : t -> (context -> Cmarkit.Doc.t -> unit) -(** [init_context r] is the context initalization function for [r]. *) - -val inline : t -> inline -(** [inline r] is the inline renderer of [r]. *) - -val block : t -> block -(** [block_renderer r] is the block renderer of [r]. *) - -val doc : t -> doc -(** [doc_renderer r] is the documentation renderer of [r]. *) - -(** {1:context Rendering contexts} *) - -(** Rendering contexts. *) -module Context : sig - - (** {1:contexts Contexts} *) - - type renderer := t - - type t = context - (** The type for rendering contexts. *) - - val make : renderer -> Buffer.t -> t - (** [make r b] is a context using renderer [r] to render documents - on buffer [b]. - - The renderer [r] must be able to handle any inline, block and - document values (i.e. its renderers should always return [true]) - otherwise [Invalid_argument] may raise on renders. - - This means the last renderer you {{!compose}compose with} should - always have catch all cases returning [true]; after possibly - indicating in the output that something was missed. The built-in - renderers {!Cmarkit_commonmark.val-renderer}, - {!Cmarkit_html.val-renderer} and {!Cmarkit_latex.val-renderer} - do have these catch all cases. *) - - val renderer : t -> renderer - (** [renderer c] is the renderer of [c]. *) - - val buffer : t -> Buffer.t - (** [buffer c] is the buffer of [c]. *) - - val get_doc : t -> Cmarkit.Doc.t - (** [get_doc c] is the document being rendered. *) - - val get_defs : t -> Cmarkit.Label.defs - (** [get_defs c] is [Doc.defs (get_doc c)]. *) - - (** Custom context state. *) - module State : sig - - type 'a t - (** The type for custom state of type ['a]. *) - - val make : unit -> 'a t - (** [make ()] is a new bit of context state. *) - - val find : context -> 'a t -> 'a option - (** [find c state] is the state [state] of context [c], if any. *) - - val get : context -> 'a t -> 'a - (** [get c state] is the state [state] of context [c], raises - [Invalid_argument] if there is no state [state] in [c]. *) - - val set : context -> 'a t -> 'a option -> unit - (** [set c state s] sets the state [state] of [c] to [s]. [state] is - cleared in [c] if [s] is [None]. *) - end - - val init : t -> Cmarkit.Doc.t -> unit - (** [init c] calls the initialisation function of [c]'s - {!val-renderer}. Note, this is done automatically by {!val-doc}. *) - - (** {1:render Rendering functions} - - These function append data to the {!buffer} of the context. For more - specialized rendering functions, see the corresponding rendering - backends. *) - - val byte : t -> char -> unit - (** [byte c b] renders byte [b] verbatim on [c]. *) - - val utf_8_uchar : t -> Uchar.t -> unit - (** [utf_8_uchar c u] renders the UTF-8 encoding of [u] on [c]. *) - - val string : t -> string -> unit - (** [string c s] renders string [s] verbatim on [c]. *) - - val inline : t -> Cmarkit.Inline.t -> unit - (** [inline c i] renders inline [i] on [c]. This invokes the - {{!compose}composition} of inline renderers of [c]. *) - - val block : t -> Cmarkit.Block.t -> unit - (** [block c b] renders block [b] on [c]. This invokes the - {{!compose}composition} of block renderers of [c]. *) - - val doc : t -> Cmarkit.Doc.t -> unit - (** [doc c d] initializes [c] with {!init} and renders document [d] on [c]. - This invokes the {{!compose}composition} of document renderers of [c]. *) -end - -(** {1:example Extending renderers} - - This example extends the {!Cmarkit_html.val-renderer} but it - applies {e mutatis mutandis} to the other backend document - renderers. - - Let's assume you want to: - - {ul - {- Extend the abstract syntax tree with a [Doc] block which - allows to splice documents in another one (note that - splicing is already built-in via the {!Cmarkit.Block.extension-Blocks} - block case).} - {- Change the rendering of {!Cmarkit.Inline.extension-Image} inlines to - render HTML [video] or [audio] elements depending on the link's - destination suffix.} - {- For the rest use the built-in {!Cmarkit_html.renderer} renderer - as it exists.}} - - This boils down to: - - {ol - {- Add a new case to the abstract syntax tree.} - {- Define a [custom_html] renderer which treats - {!Cmarkit.Inline.Image} and the new [Doc] case the way we - see it fit and return [false] otherwise to use the built-in renderer. } - {- {!compose} [custom_html] with {!Cmarkit_html.val-renderer}}} - -{[ -type Cmarkit.Block.t += Doc of Cmarkit.Doc.t (* 1 *) - -let media_link c l = - let has_ext s ext = String.ends_with ~suffix:ext s in - let is_video s = List.exists (has_ext s) [".mp4"; ".webm"] in - let is_audio s = List.exists (has_ext s) [".mp3"; ".flac"] in - let defs = Cmarkit_renderer.Context.get_defs c in - match Cmarkit.Inline.Link.reference_definition defs l with - | Some Cmarkit.Link_definition.Def (ld, _) -> - let start_tag = match Cmarkit.Link_definition.dest ld with - | Some (src, _) when is_video src -> Some (" Some (" None - in - begin match start_tag with - | None -> false (* let the default HTML renderer handle that *) - | Some (start_tag, src) -> - (* More could be done with the reference title and link text *) - Cmarkit_renderer.Context.string c start_tag; - Cmarkit_renderer.Context.string c {| src="|}; - Cmarkit_html.pct_encoded_string c src; - Cmarkit_renderer.Context.string c {|" />|}; - true - end - | None | Some _ -> false (* let the default HTML renderer that *) - -let custom_html = - let inline c = function - | Cmarkit.Inline.Image (l, _) -> media_link c l - | _ -> false (* let the default HTML renderer handle that *) - in - let block c = function - | Doc d -> - (* It's important to recurse via Cmarkit_renderer.Context.block *) - Cmarkit_renderer.Context.block c (Cmarkit.Doc.block d); true - | _ -> false (* let the default HTML renderer handle that *) - in - Cmarkit_renderer.make ~inline ~block () (* 2 *) - -let custom_html_of_doc ~safe doc = - let default = Cmarkit_html.renderer ~safe () in - let r = Cmarkit_renderer.compose default custom_html in (* 3 *) - Cmarkit_renderer.doc_to_string r doc -]} - -The [custom_html_of_doc] function performs your extended -renderings. *) - -(*--------------------------------------------------------------------------- - Copyright (c) 2021 The cmarkit programmers - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------------------------------------------*) diff --git a/ocaml-lsp-server/vendor/cmarkit/dune b/ocaml-lsp-server/vendor/cmarkit/dune deleted file mode 100644 index c1a666805..000000000 --- a/ocaml-lsp-server/vendor/cmarkit/dune +++ /dev/null @@ -1,3 +0,0 @@ -(library - (name cmarkit) - (wrapped false)) diff --git a/submodules/lev/.github/workflows/workflow.yml b/submodules/lev/.github/workflows/workflow.yml deleted file mode 100644 index f39486c28..000000000 --- a/submodules/lev/.github/workflows/workflow.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Main workflow - -on: - - pull_request - - push - -jobs: - build_and_test: - name: Build and test - strategy: - fail-fast: false - matrix: - os: - - macos-latest - - ubuntu-latest - - windows-latest - ocaml-compiler: - - 4.14.x - - runs-on: ${{ matrix.os }} - - steps: - - name: Set git to use LF - run: | - git config --global core.autocrlf false - git config --global core.eol lf - git config --global core.ignorecase false - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Use OCaml ${{ matrix.ocaml-compiler }} - uses: ocaml/setup-ocaml@v2 - with: - ocaml-compiler: ${{ matrix.ocaml-compiler }} - opam-local-packages: lev.opam lev-fiber.opam - - - run: opam install --deps-only --with-doc --with-test . - - run: opam exec -- dune build - - run: opam exec -- dune runtest - diff --git a/submodules/lev/.gitignore b/submodules/lev/.gitignore deleted file mode 100644 index 5397bfc3b..000000000 --- a/submodules/lev/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -_build -_opam -_coverage -*.install -.vscode/ diff --git a/submodules/lev/.gitrepo b/submodules/lev/.gitrepo deleted file mode 100644 index 3514df054..000000000 --- a/submodules/lev/.gitrepo +++ /dev/null @@ -1,12 +0,0 @@ -; DO NOT EDIT (unless you know what you are doing) -; -; This subdirectory is a git "subrepo", and this file is maintained by the -; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme -; -[subrepo] - remote = https://github.com/rgrinberg/lev - branch = master - commit = 9258b71a2880de89762bcfac0b281979a58a2aa6 - parent = 3cf37f43238af9bbec82534f08a0477594603ccd - method = rebase - cmdver = 0.4.1 diff --git a/submodules/lev/.ocamlformat b/submodules/lev/.ocamlformat deleted file mode 100644 index 9af4b1f63..000000000 --- a/submodules/lev/.ocamlformat +++ /dev/null @@ -1 +0,0 @@ -version=0.21.0 diff --git a/submodules/lev/README.cpp.md b/submodules/lev/README.cpp.md deleted file mode 100644 index 98201f3c8..000000000 --- a/submodules/lev/README.cpp.md +++ /dev/null @@ -1,35 +0,0 @@ -# Lev - OCaml bindings to libev - -[libev]: http://software.schmorp.de/pkg/libev.html -[libevdoc]: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod - -## Abstract - -[libev](libev) by Marc Lehmann is a minimal & portable event loop library. This -repository contains two packages. The first is `lev` which offers low level -bindings to this library. The bindings are designed to be minimal, low -overhead, and easily embeddable in larger projects. The API is callback based -so you need to BYOC (bring your own concurrency). - -The second package is `lev-fiber`. It provides a more familiar, higher level -API. It is based on dune's fiber library for structured concurrency. - -## Example - -This example of the low level API lev api: - -```ocaml -#include "lev/examples/readme.ml" -``` - -## Documentation - -Lev's API is a thin wrapper around libev itself. So you should first and -foremost refer to libev's extensive [documentation](libevdoc). Lev itself will -document where it differs from libev's conventions. - -## License - -`vendor/` is under Marc Lehmann's original terms (see vendor/LICENSE). - -Everything else is offered under ISC (see src/LICENSE.md). diff --git a/submodules/lev/README.md b/submodules/lev/README.md deleted file mode 100644 index 8fdbb9787..000000000 --- a/submodules/lev/README.md +++ /dev/null @@ -1,62 +0,0 @@ -# Lev - OCaml bindings to libev - -[libev]: http://software.schmorp.de/pkg/libev.html -[libevdoc]: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod - -## Abstract - -[libev](libev) by Marc Lehmann is a minimal & portable event loop library. This -repository contains two packages. The first is `lev` which offers low level -bindings to this library. The bindings are designed to be minimal, low -overhead, and easily embeddable in larger projects. The API is callback based -so you need to BYOC (bring your own concurrency). - -The second package is `lev-fiber`. It provides a more familiar, higher level -API. It is based on dune's fiber library for structured concurrency. - -## Example - -This example of the low level API lev api: - -```ocaml -open Lev - -let () = - let loop = Loop.default () in - let stdin, stdin_w = Unix.pipe ~cloexec:true () in - let stdout_r, stdout = Unix.pipe ~cloexec:true () in - let stderr_r, stderr = Unix.pipe ~cloexec:true () in - Unix.close stdin_w; - Unix.close stdout_r; - Unix.close stderr_r; - let pid = - Unix.create_process "sh" [| "sh"; "-c"; "exit 42" |] stdin stdout stderr - in - let child = - match Child.create with - | Error `Unimplemented -> assert false - | Ok create -> - create - (fun t ~pid status -> - Child.stop t loop; - match status with - | Unix.WEXITED i -> Printf.printf "%d exited with status %d\n" pid i - | _ -> assert false) - (Pid pid) Terminate - in - Child.start child loop; - Loop.run_until_done loop; - Child.destroy child -``` - -## Documentation - -Lev's API is a thin wrapper around libev itself. So you should first and -foremost refer to libev's extensive [documentation](libevdoc). Lev itself will -document where it differs from libev's conventions. - -## License - -`vendor/` is under Marc Lehmann's original terms (see vendor/LICENSE). - -Everything else is offered under ISC (see src/LICENSE.md). diff --git a/submodules/lev/dune b/submodules/lev/dune deleted file mode 100644 index 26fa19812..000000000 --- a/submodules/lev/dune +++ /dev/null @@ -1,12 +0,0 @@ -(rule - (mode promote) - (deps - (:dep README.cpp.md) - (source_tree lev/examples/)) - (target README.md) - (action - (run cppo -n %{dep} -o %{target}))) - -(env - (_ - (flags :standard -alert -unstable))) diff --git a/submodules/lev/dune-project b/submodules/lev/dune-project deleted file mode 100644 index 8245543a4..000000000 --- a/submodules/lev/dune-project +++ /dev/null @@ -1,49 +0,0 @@ -(lang dune 3.0) - -(name lev) - -(generate_opam_files true) - -(license ISC) -(maintainers "Rudi Grinberg ") -(authors - "Rudi Grinberg " - "Ulugbek Abdullaev ") -(source (github rgrinberg/lev)) - -(implicit_transitive_deps false) - -(package - (synopsis "Bindings to libev") - (description "Low level bindings to libev") - (name lev) - (depends - (ppx_expect :with-test) - base-unix)) - -(package - (synopsis "Fiber + Lev") - (description "High level API based on dune's fibers") - (name lev-fiber) - (depends - (ppx_expect :with-test) - (ocaml (>= 4.14.0)) - lev - dyn - fiber - stdune - base-threads - base-unix)) - -(package - (synopsis "Fiber + Lev + Csexp") - (description "Client/Servers that use csexp for transport") - (name lev-fiber-csexp) - (depends - (ppx_expect :with-test) - lev-fiber - stdune - dyn - csexp - (fiber (>= 3.1.1)) - base-unix)) diff --git a/submodules/lev/lev-fiber-csexp.opam b/submodules/lev/lev-fiber-csexp.opam deleted file mode 100644 index 7d770747c..000000000 --- a/submodules/lev/lev-fiber-csexp.opam +++ /dev/null @@ -1,38 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -synopsis: "Fiber + Lev + Csexp" -description: "Client/Servers that use csexp for transport" -maintainer: ["Rudi Grinberg "] -authors: [ - "Rudi Grinberg " - "Ulugbek Abdullaev " -] -license: "ISC" -homepage: "https://github.com/rgrinberg/lev" -bug-reports: "https://github.com/rgrinberg/lev/issues" -depends: [ - "dune" {>= "3.0"} - "ppx_expect" {with-test} - "lev-fiber" - "stdune" - "dyn" - "csexp" - "fiber" {>= "3.1.1"} - "base-unix" - "odoc" {with-doc} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] -dev-repo: "git+https://github.com/rgrinberg/lev.git" diff --git a/submodules/lev/lev-fiber-csexp/src/dune b/submodules/lev/lev-fiber-csexp/src/dune deleted file mode 100644 index d5393c536..000000000 --- a/submodules/lev/lev-fiber-csexp/src/dune +++ /dev/null @@ -1,4 +0,0 @@ -(library - (name lev_fiber_csexp) - (public_name lev-fiber-csexp) - (libraries fiber csexp stdune dyn lev_fiber)) diff --git a/submodules/lev/lev-fiber-csexp/src/lev_fiber_csexp.ml b/submodules/lev/lev-fiber-csexp/src/lev_fiber_csexp.ml deleted file mode 100644 index 4065caff3..000000000 --- a/submodules/lev/lev-fiber-csexp/src/lev_fiber_csexp.ml +++ /dev/null @@ -1,163 +0,0 @@ -open Stdune -open Fiber.O -module Io = Lev_fiber.Io -module Session_id = Id.Make () - -module Session = struct - module Lexer = Csexp.Parser.Lexer - module Stack = Csexp.Parser.Stack - module Id = Session_id - - type state = - | Closed - | Open of { - out_channel : Io.output Io.t; - in_channel : Io.input Io.t; - read : Fiber.Mutex.t; - write : Fiber.Mutex.t; - socket : bool; - } - - type t = { id : Id.t; mutable state : state } - - let create ~socket in_channel out_channel = - let id = Id.gen () in - let state = - Open - { - in_channel; - out_channel; - socket; - read = Fiber.Mutex.create (); - write = Fiber.Mutex.create (); - } - in - { id; state } - - let close t = - match t.state with - | Closed -> () - | Open { in_channel; out_channel; read = _; write = _; socket } -> - (match socket with - | false -> () - | true -> ( - try - let fd = Io.fd out_channel in - Unix.shutdown (Lev_fiber.Fd.fd_exn fd) Unix.SHUTDOWN_ALL - with Unix.Unix_error (_, _, _) -> ())); - Io.close in_channel; - Io.close out_channel; - t.state <- Closed - - let read t = - match t.state with - | Closed -> Fiber.return None - | Open { in_channel; _ } -> - let lexer = Lexer.create () in - let buf = Buffer.create 16 in - let rec loop reader parser = - match Io.Reader.Expert.available reader with - | `Eof -> - Lexer.feed_eoi lexer; - Fiber.return None - | `Ok 0 -> - let* () = Io.Reader.Expert.refill reader in - loop reader parser - | `Ok _ -> ( - let token = - let c = Io.Reader.read_char_exn reader in - Lexer.feed lexer c - in - match token with - | Atom n -> - Buffer.clear buf; - atom reader parser n - | (Lparen | Rparen | Await) as token -> ( - let parser = Stack.add_token token parser in - match parser with - | Sexp (sexp, Empty) -> Fiber.return (Some sexp) - | parser -> loop reader parser)) - and atom reader parser len = - if len = 0 then - let atom = Buffer.contents buf in - match Stack.add_atom atom parser with - | Sexp (sexp, Empty) -> Fiber.return (Some sexp) - | parser -> loop reader parser - else - match Io.Reader.Expert.available reader with - | `Eof -> - Lexer.feed_eoi lexer; - Fiber.return None - | `Ok 0 -> - let* () = Io.Reader.Expert.refill reader in - atom reader parser len - | `Ok _ -> - let bytes, { Io.Slice.pos; len = buf_len } = - Io.Reader.Expert.buffer reader - in - let len_read = min len buf_len in - Buffer.add_subbytes buf bytes pos len_read; - Io.Reader.Expert.consume reader ~len:len_read; - atom reader parser (len - len_read) - in - Io.with_read in_channel ~f:(fun reader -> loop reader Stack.Empty) - - let read t = - match t.state with - | Closed -> Fiber.return None - | Open { read = mutex; _ } -> - Fiber.Mutex.with_lock mutex ~f:(fun () -> read t) - - let write_closed sexps = - Code_error.raise "attempting to write to a closed channel" - [ ("sexp", Dyn.(list Sexp.to_dyn) sexps) ] - - let write t sexps = - match t.state with - | Closed -> write_closed sexps - | Open { out_channel; _ } -> - Io.with_write out_channel ~f:(fun writer -> - let rec write sexp src_pos = - if src_pos = String.length sexp then Fiber.return () - else - let* size = - let size = Io.Writer.Expert.available writer in - if size > 0 then Fiber.return size - else - let+ () = Io.Writer.flush writer in - Io.Writer.Expert.available writer - in - let dst, { Io.Slice.pos = dst_pos; len } = - Io.Writer.Expert.prepare writer ~len:size - in - let len = min len (String.length sexp - src_pos) in - Bytes.blit_string ~src:sexp ~src_pos ~dst ~dst_pos ~len; - Io.Writer.Expert.commit writer ~len; - write sexp (src_pos + len) - in - let rec loop = function - | [] -> Io.Writer.flush writer - | sexp :: sexps -> - let* () = write (Csexp.to_string sexp) 0 in - loop sexps - in - loop sexps) - - let write t sexps = - match t.state with - | Closed -> write_closed sexps - | Open { write = mutex; _ } -> - Fiber.Mutex.with_lock mutex ~f:(fun () -> write t sexps) -end - -let connect fd sockaddr = - let* () = Lev_fiber.Socket.connect fd sockaddr in - let+ i, o = Lev_fiber.Io.create_rw fd in - Session.create ~socket:true i o - -let serve server ~f = - let module Server = Lev_fiber.Socket.Server in - Server.serve server ~f:(fun session -> - let* i, o = Server.Session.io session in - let session = Session.create ~socket:true i o in - f session) diff --git a/submodules/lev/lev-fiber-csexp/src/lev_fiber_csexp.mli b/submodules/lev/lev-fiber-csexp/src/lev_fiber_csexp.mli deleted file mode 100644 index ae3c9b426..000000000 --- a/submodules/lev/lev-fiber-csexp/src/lev_fiber_csexp.mli +++ /dev/null @@ -1,35 +0,0 @@ -(** Canonical S-expression RPC. - - This module implements a RPC mechanism for exchanging canonical - S-expressions over unix or internet sockets. It allows a server to accept - connections and a client to connect to a server. - - However, it doesn't explain how to encode queries, responses or generally - any kind of messages as Canonical S-expressions. This part should be built - on top of this module. *) - -module Session : sig - type t - (** Rpc session backed by an input & output stream *) - - val create : - socket:bool -> - Lev_fiber.Io.input Lev_fiber.Io.t -> - Lev_fiber.Io.output Lev_fiber.Io.t -> - t - - val close : t -> unit - - (* [write t x] writes the s-expression when [x] is [Some sexp], and closes the - session if [x = None ] *) - val write : t -> Csexp.t list -> unit Fiber.t - - val read : t -> Csexp.t option Fiber.t - (** If [read] returns [None], the session is closed and all subsequent reads - will return [None] *) -end - -val connect : Lev_fiber.Fd.t -> Unix.sockaddr -> Session.t Fiber.t - -val serve : - Lev_fiber.Socket.Server.t -> f:(Session.t -> unit Fiber.t) -> unit Fiber.t diff --git a/submodules/lev/lev-fiber-csexp/test/dune b/submodules/lev/lev-fiber-csexp/test/dune deleted file mode 100644 index 2bbfcf47d..000000000 --- a/submodules/lev/lev-fiber-csexp/test/dune +++ /dev/null @@ -1,21 +0,0 @@ -(library - (name lev_fiber_csexp_tests) - (libraries - fiber - csexp - lev - lev_fiber - lev_fiber_csexp - stdune - unix - threads.posix - ;; This is because of the (implicit_transitive_deps false) - ;; in dune-project - ppx_expect.config - ppx_expect.config_types - ppx_expect - base - ppx_inline_test.config) - (inline_tests) - (preprocess - (pps ppx_expect))) diff --git a/submodules/lev/lev-fiber-csexp/test/lev_fiber_csexp_rpc_tests.ml b/submodules/lev/lev-fiber-csexp/test/lev_fiber_csexp_rpc_tests.ml deleted file mode 100644 index 2d9b43095..000000000 --- a/submodules/lev/lev-fiber-csexp/test/lev_fiber_csexp_rpc_tests.ml +++ /dev/null @@ -1,67 +0,0 @@ -open Stdune -open Fiber.O -module Csexp_rpc = Lev_fiber_csexp - -let%expect_test "serve/connect" = - let path = "levfibercsexp.sock" in - (try Unix.unlink path with Unix.Unix_error _ -> ()); - let server_sockaddr = - if Sys.win32 then Unix.ADDR_INET (Unix.inet_addr_loopback, 0) - else Unix.ADDR_UNIX path - in - let domain = Unix.domain_of_sockaddr server_sockaddr in - let socket () = - Lev_fiber.Fd.create - (Unix.socket ~cloexec:true domain Unix.SOCK_STREAM 0) - (`Non_blocking false) - in - let run () = - let ready_client = Fiber.Ivar.create () in - let client () = - let* sockaddr = Fiber.Ivar.read ready_client in - printfn "client: connecting"; - let* session = Csexp_rpc.connect (socket ()) sockaddr in - let* () = - Csexp_rpc.Session.write session - [ Csexp.List [ Atom "one"; List [ Atom "two"; Atom "three" ] ] ] - in - let+ response = Csexp_rpc.Session.read session in - (match response with - | None -> assert false - | Some s -> - let resp = Csexp.to_string s in - printfn "client: received %S" resp); - Csexp_rpc.Session.close session - and server () = - let fd = socket () in - let unix_fd = Lev_fiber.Fd.fd_exn fd in - Unix.setsockopt unix_fd Unix.SO_REUSEADDR true; - let* server = - Lev_fiber.Socket.Server.create fd server_sockaddr ~backlog:10 - in - printfn "server: started"; - let listening_addr = Unix.getsockname unix_fd in - let* () = Fiber.Ivar.fill ready_client listening_addr in - Csexp_rpc.serve server ~f:(fun session -> - printfn "server: new session"; - let* req = Csexp_rpc.Session.read session in - (match req with - | None -> assert false - | Some req -> printfn "server: request %S" (Csexp.to_string req)); - let* () = - Csexp_rpc.Session.write session - [ Atom "response"; List [ Atom "foo" ] ] - in - Csexp_rpc.Session.close session; - Lev_fiber.Socket.Server.close server) - in - Fiber.fork_and_join_unit client server - in - Lev_fiber.run run |> Lev_fiber.Error.ok_exn; - [%expect - {| - server: started - client: connecting - server: new session - server: request "(3:one(3:two5:three))" - client: received "8:response" |}] diff --git a/submodules/lev/lev-fiber-csexp/test/lev_fiber_csexp_rpc_tests.mli b/submodules/lev/lev-fiber-csexp/test/lev_fiber_csexp_rpc_tests.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/submodules/lev/lev-fiber.opam b/submodules/lev/lev-fiber.opam deleted file mode 100644 index 8654572a0..000000000 --- a/submodules/lev/lev-fiber.opam +++ /dev/null @@ -1,39 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -synopsis: "Fiber + Lev" -description: "High level API based on dune's fibers" -maintainer: ["Rudi Grinberg "] -authors: [ - "Rudi Grinberg " - "Ulugbek Abdullaev " -] -license: "ISC" -homepage: "https://github.com/rgrinberg/lev" -bug-reports: "https://github.com/rgrinberg/lev/issues" -depends: [ - "dune" {>= "3.0"} - "ppx_expect" {with-test} - "ocaml" {>= "4.14.0"} - "lev" - "dyn" - "fiber" - "stdune" - "base-threads" - "base-unix" - "odoc" {with-doc} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] -dev-repo: "git+https://github.com/rgrinberg/lev.git" diff --git a/submodules/lev/lev-fiber/bench/dune b/submodules/lev/lev-fiber/bench/dune deleted file mode 100644 index c77eb8a39..000000000 --- a/submodules/lev/lev-fiber/bench/dune +++ /dev/null @@ -1,3 +0,0 @@ -(executable - (name ping_pong) - (libraries lev-fiber fiber lev stdune)) diff --git a/submodules/lev/lev-fiber/bench/ping_pong.ml b/submodules/lev/lev-fiber/bench/ping_pong.ml deleted file mode 100644 index aa9024b0b..000000000 --- a/submodules/lev/lev-fiber/bench/ping_pong.ml +++ /dev/null @@ -1,63 +0,0 @@ -open! Stdune -open Fiber.O -open Lev_fiber - -let () = - let current = Gc.get () in - Gc.set { current with max_overhead = 1000000; allocation_policy = 1 } - -let response = "+PONG\r\n" - -let pong o times = - Io.with_write o ~f:(fun writer -> - for _ = 1 to times do - Io.Writer.add_string writer response - done; - Io.Writer.flush writer) - -let rec process_bytes buf pos len count = - if pos >= len then count - else - let c = Bytes.get buf pos in - let count = if c = '\n' then count + 1 else count in - process_bytes buf (pos + 1) len count - -let rec read o reader = - match Io.Reader.Expert.available reader with - | `Eof -> Fiber.return () - | `Ok 0 -> - let* () = Io.Reader.Expert.refill reader in - read o reader - | `Ok _ -> - let buf, { Io.Slice.pos; len } = Io.Reader.Expert.buffer reader in - let times = process_bytes buf pos len 0 in - Io.Reader.Expert.consume reader ~len; - let* () = pong o times in - read o reader - -let serve session = - let* i, o = Socket.Server.Session.io session in - let+ () = Io.with_read i ~f:(fun reader -> read o reader) in - Io.close i; - Io.close o - -let run sock_path = - let delete () = try Unix.unlink sock_path with Unix.Unix_error _ -> () in - delete (); - let socket = - let socket = Unix.socket ~cloexec:true Unix.PF_UNIX Unix.SOCK_STREAM 0 in - Lev_fiber.Fd.create socket (`Non_blocking false) - in - let addr = Unix.ADDR_UNIX sock_path in - let* server = Socket.Server.create ~backlog:128 socket addr in - at_exit delete; - let serve session = - Fiber.with_error_handler - (fun () -> serve session) - ~on_error:(fun exn -> - Format.eprintf "%a@.%!" Exn_with_backtrace.pp_uncaught exn; - Exn_with_backtrace.reraise exn) - in - Socket.Server.serve server ~f:serve - -let () = Lev_fiber.run (fun () -> run Sys.argv.(1)) |> Lev_fiber.Error.ok_exn diff --git a/submodules/lev/lev-fiber/bench/ping_pong.mli b/submodules/lev/lev-fiber/bench/ping_pong.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/submodules/lev/lev-fiber/src/dune b/submodules/lev/lev-fiber/src/dune deleted file mode 100644 index ce42a4fcd..000000000 --- a/submodules/lev/lev-fiber/src/dune +++ /dev/null @@ -1,10 +0,0 @@ -(env - (_ - (flags :standard -alert -unstable))) - -(library - (name lev_fiber) - (public_name lev-fiber) - (instrumentation - (backend bisect_ppx)) - (libraries unix dyn stdune threads.posix fiber lev lev_fiber_util)) diff --git a/submodules/lev/lev-fiber/src/lev_fiber.ml b/submodules/lev/lev-fiber/src/lev_fiber.ml deleted file mode 100644 index 89056d108..000000000 --- a/submodules/lev/lev-fiber/src/lev_fiber.ml +++ /dev/null @@ -1,1282 +0,0 @@ -open Stdune -open Fiber.O -open Lev_fiber_util -module Timestamp = Lev.Timestamp - -module Signal_watcher = struct - type t = { - thread : Thread.t; - old_sigmask : int list; - old_sigpipe : Sys.signal_behavior option; - old_sigchld : Sys.signal_behavior; - sigchld_watcher : Lev.Async.t; - } - - let stop_sig = Sys.sigusr2 - - let blocked_signals = - [ Sys.sigchld; stop_sig ] |> List.sort ~compare:Int.compare - - let stop t = - Unix.kill (Unix.getpid ()) stop_sig; - Thread.join t.thread; - let used_mask = - Unix.sigprocmask SIG_SETMASK t.old_sigmask - |> List.sort ~compare:Int.compare - in - Option.iter t.old_sigpipe ~f:(Sys.set_signal Sys.sigpipe); - Sys.set_signal Sys.sigchld t.old_sigchld; - if used_mask <> blocked_signals then - Code_error.raise "cannot restore old sigmask" - [ - ("stop_sig", Dyn.int stop_sig); - ("sigchld", Dyn.int stop_sig); - ("used_mask", Dyn.(list int) used_mask); - ("old_sigmask", Dyn.(list int) t.old_sigmask); - ("blocked_signals", Dyn.(list int) blocked_signals); - ] - - let run (watcher, loop) = - while true do - let signal = Thread.wait_signal blocked_signals in - if signal = Sys.sigusr2 then raise_notrace Thread.Exit - else Lev.Async.send watcher loop - done - - let create ~sigpipe ~sigchld_watcher ~loop = - let old_sigpipe = - match sigpipe with - | `Inherit -> None - | `Ignore -> Some (Sys.signal Sys.sigpipe Sys.Signal_ignore) - in - let old_sigchld = - Sys.signal Sys.sigchld (Sys.Signal_handle (fun (_ : int) -> ())) - in - let old_sigmask = Unix.sigprocmask SIG_BLOCK blocked_signals in - let thread = Thread.create run (sigchld_watcher, loop) in - { thread; old_sigmask; old_sigchld; old_sigpipe; sigchld_watcher } -end - -module Process_watcher = struct - module Process_table = struct - type process = { pid : Pid.t; ivar : Unix.process_status Fiber.Ivar.t } - type t = { loop : Lev.Loop.t; active : (Pid.t, process) Table.t } - - let create loop = { loop; active = Table.create (module Pid) 16 } - - let spawn t pid = - Lev.Loop.ref t.loop; - let ivar = Fiber.Ivar.create () in - let process = { pid; ivar } in - Table.add_exn t.active pid process; - ivar - - let is_empty t = Table.length t.active = 0 - - let reap t queue = - Table.filteri_inplace t.active ~f:(fun ~key:pid ~data:process -> - let pid, status = Unix.waitpid [ WNOHANG ] (Pid.to_int pid) in - match pid with - | 0 -> true - | _ -> - Lev.Loop.unref t.loop; - Queue.push queue (Fiber.Fill (process.ivar, status)); - false) - end - - type watcher = Signal of Lev.Async.t | Poll of Lev.Timer.t - type t = { loop : Lev.Loop.t; table : Process_table.t; watcher : watcher } - - let create loop queue = - let table = Process_table.create loop in - let watcher = - if Sys.win32 then - let reap timer = - Process_table.reap table queue; - if Process_table.is_empty table then Lev.Timer.stop timer loop - in - let watcher = Lev.Timer.create ~repeat:0.05 ~after:0.05 reap in - Poll watcher - else - let reap (_ : Lev.Async.t) = Process_table.reap table queue in - let watcher = Lev.Async.create reap in - Lev.Async.start watcher loop; - Lev.Loop.unref loop; - Signal watcher - in - { table; watcher; loop } - - let ensure_started t = - match t.watcher with - | Signal _ -> () - | Poll s -> if not (Lev.Timer.is_active s) then Lev.Timer.start s t.loop - - let waitpid t ~pid = - ensure_started t; - Process_table.spawn t.table pid - - let cleanup t = - (* XXX shall we kill the running processes here? *) - match t.watcher with - | Poll s -> - Lev.Timer.stop s t.loop; - Lev.Timer.destroy s - | Signal s -> - Lev.Async.stop s t.loop; - Lev.Async.destroy s -end - -type thread_job_status = Active | Complete | Cancelled -type thread_job = { status : thread_job_status ref; ivar : Fiber.fill } -type worker = Worker : 'a Worker.t -> worker - -type t = { - loop : Lev.Loop.t; - queue : Fiber.fill Queue.t; - (* TODO stop when there are no threads *) - async : Lev.Async.t; - thread_jobs : thread_job Queue.t; - thread_mutex : Mutex.t; - process_watcher : Process_watcher.t; - signal_watcher : Signal_watcher.t option (* [None] on windows *); - mutable thread_workers : worker list; -} - -type scheduler = t - -let t : t Fiber.Var.t = Fiber.Var.create () -let t_var = t -let scheduler = t - -module Buffer = struct - include Bip_buffer - - let default_size = 4096 - - type nonrec t = bytes t - - let create ~size : t = create (Stdlib.Bytes.create size) ~len:size -end - -module State = struct - type ('a, 'b) t' = Open of 'a | Closed of 'b - type ('a, 'b) t = ('a, 'b) t' ref - - let create a = ref (Open a) -end - -module Thread = struct - type job = - | Job : { - run : unit -> 'a; - status : thread_job_status ref; - ivar : - ('a, [ `Exn of Exn_with_backtrace.t | `Cancelled ]) result - Fiber.Ivar.t; - } - -> job - - type nonrec t = { worker : job Worker.t; scheduler : t } - - let create = - let finish_job t fill = - Mutex.lock t.thread_mutex; - Queue.push t.thread_jobs fill; - Mutex.unlock t.thread_mutex; - Lev.Async.send t.async t.loop - in - fun () -> - let+ t = Fiber.Var.get_exn t in - let do_no_raise (Job { run; status; ivar }) = - let res = - match Exn_with_backtrace.try_with run with - | Ok x -> Ok x - | Error exn -> Error (`Exn exn) - in - finish_job t { status; ivar = Fiber.Fill (ivar, res) } - in - let worker = - Worker.create ~do_no_raise ~spawn_thread:(fun f -> Thread.create f ()) - in - t.thread_workers <- Worker worker :: t.thread_workers; - { worker; scheduler = t } - - type 'a task = { - ivar : - ('a, [ `Exn of Exn_with_backtrace.t | `Cancelled ]) result Fiber.Ivar.t; - task : Worker.task; - status : thread_job_status ref; - loop : Lev.Loop.t; - } - - let task (t : t) ~f = - let ivar = Fiber.Ivar.create () in - let status = ref Active in - match Worker.add_work t.worker (Job { run = f; status; ivar }) with - | Error `Stopped -> Error `Stopped - | Ok task -> - Lev.Loop.ref t.scheduler.loop; - Ok { ivar; task; status; loop = t.scheduler.loop } - - let await task = Fiber.Ivar.read task.ivar - - let cancel task = - match !(task.status) with - | Cancelled | Complete -> Fiber.return () - | Active -> - Lev.Loop.unref task.loop; - task.status := Cancelled; - Worker.cancel_if_not_consumed task.task; - Fiber.Ivar.fill task.ivar (Error `Cancelled) - - let close t = - t.scheduler.thread_workers <- - (let id = Worker.id t.worker in - List.filter t.scheduler.thread_workers ~f:(fun (Worker w) -> - let id' = Worker.id w in - not (Worker.Id.equal id id'))); - Worker.complete_tasks_and_stop t.worker -end - -module Timer = struct - let sleepf after = - let* t = Fiber.Var.get_exn t in - let ivar = Fiber.Ivar.create () in - let timer = - Lev.Timer.create ~after (fun timer -> - Lev.Timer.stop timer t.loop; - Lev.Timer.destroy timer; - Queue.push t.queue (Fiber.Fill (ivar, ()))) - in - Lev.Timer.start timer t.loop; - Fiber.Ivar.read ivar - - module Wheel = struct - type running_state = - | Idle - | Sleeping of Lev.Timer.t * unit Fiber.Ivar.t - (* set whenever the wheel is waiting for a new task *) - | Waiting of { ivar : unit Fiber.Ivar.t; filled : bool } - - type elt = { - ivar : [ `Ok | `Cancelled ] Fiber.Ivar.t; - scheduled : Lev.Timestamp.t; - mutable filled : bool; - wheel : t; - } - - and running = { - queue : elt Removable_queue.t; - delay : float; - scheduler : scheduler; - mutable state : running_state; - } - - and state = Stopped of { delay : float } | Running of running - and t = state ref - - let delay t = - match !t with Stopped { delay } -> delay | Running { delay; _ } -> delay - - let create ~delay = - let+ scheduler = Fiber.Var.get_exn t in - ref - (Running - { queue = Removable_queue.create (); delay; scheduler; state = Idle }) - - type task = elt Removable_queue.node ref - type condition = { sleeping : bool; waiting : bool } - - let wakeup_if t { sleeping; waiting } = - match t.state with - | Sleeping (timer, ivar) when sleeping -> - let* { loop; _ } = Fiber.Var.get_exn scheduler in - Lev.Timer.stop timer loop; - Lev.Timer.destroy timer; - t.state <- Idle; - Fiber.Ivar.fill ivar () - | Waiting { ivar; filled = false } when waiting -> - t.state <- Idle; - Fiber.Ivar.fill ivar () - | _ -> Fiber.return () - - let set_delay t ~delay = - match !t with - | Stopped _ -> Code_error.raise "Wheel.set_delay" [] - | Running d -> - t := Running { d with delay }; - wakeup_if d { sleeping = true; waiting = false } - - let task (t : t) : task Fiber.t = - Fiber.of_thunk (fun () -> - match !t with - | Stopped _ -> Code_error.raise "Wheel.task" [] - | Running wheel -> - let now = Lev.Loop.now wheel.scheduler.loop in - let data = - { - wheel = t; - ivar = Fiber.Ivar.create (); - scheduled = now; - filled = false; - } - in - let res = Removable_queue.push wheel.queue data in - let+ () = wakeup_if wheel { waiting = true; sleeping = false } in - ref res) - - let reset (task : task) = - Fiber.of_thunk (fun () -> - let task' = Removable_queue.data !task in - match !(task'.wheel) with - | Stopped _ -> Code_error.raise "reset: wheel is stopped" [] - | Running wheel -> - Removable_queue.remove !task; - let now = Lev.Loop.now wheel.scheduler.loop in - let filled = task'.filled in - let task' = - let task' = { task' with scheduled = now } in - if filled then ( - task'.filled <- false; - { task' with ivar = Fiber.Ivar.create () }) - else task' - in - let new_task = Removable_queue.push wheel.queue task' in - task := new_task; - if filled then - wakeup_if wheel { sleeping = false; waiting = true } - else Fiber.return ()) - - let await (task : task) = - Fiber.of_thunk (fun () -> - let task = Removable_queue.data !task in - Fiber.Ivar.read task.ivar) - - let cancel (node : task) = - Fiber.of_thunk (fun () -> - let task = Removable_queue.data !node in - if task.filled then Fiber.return () - else ( - task.filled <- true; - Removable_queue.remove !node; - Fiber.Ivar.fill task.ivar `Cancelled)) - - let rec run t = - (* TODO do not allow double [run] *) - match !t with - | Stopped _ -> Fiber.return () - | Running r -> ( - match Removable_queue.peek r.queue with - | None -> - let ivar = Fiber.Ivar.create () in - r.state <- Waiting { ivar; filled = false }; - let* () = Fiber.Ivar.read ivar in - run t - | Some node -> - let task = Removable_queue.data node in - let after = - let now = Timestamp.to_float (Lev.Loop.now r.scheduler.loop) in - let scheduled = Timestamp.to_float task.scheduled in - scheduled -. now +. r.delay - in - let expired = after < 0. in - let* () = - if expired then ( - Removable_queue.remove node; - if not task.filled then ( - task.filled <- true; - Queue.push r.scheduler.queue (Fiber.Fill (task.ivar, `Ok))); - Fiber.return ()) - else - let scheduler = r.scheduler in - let ivar = Fiber.Ivar.create () in - let timer = - Lev.Timer.create ~after (fun timer -> - (* TODO reuse timer *) - Lev.Timer.destroy timer; - Queue.push scheduler.queue (Fiber.Fill (ivar, ()))) - in - r.state <- Sleeping (timer, ivar); - Lev.Timer.start timer scheduler.loop; - Fiber.Ivar.read ivar - in - run t) - - let run t = Fiber.of_thunk (fun () -> run t) - - let stop = - let rec cancel_all r = - match Removable_queue.pop r.queue with - | None -> Fiber.return () - | Some task -> - let* () = - if task.filled then Fiber.return () - else ( - task.filled <- true; - Fiber.Ivar.fill task.ivar `Cancelled) - in - cancel_all r - in - fun t -> - Fiber.of_thunk (fun () -> - match !t with - | Stopped _ -> Fiber.return () - | Running r -> - t := Stopped { delay = r.delay }; - let* () = cancel_all r in - wakeup_if r { sleeping = true; waiting = true }) - end -end - -let waitpid ~pid = - let pid = Pid.of_int pid in - let* t = Fiber.Var.get_exn t in - let ivar = Process_watcher.waitpid t.process_watcher ~pid in - Fiber.Ivar.read ivar - -let signal ~signal = - let* { loop; queue; _ } = Fiber.Var.get_exn t in - let ivar = Fiber.Ivar.create () in - let signal = - Lev.Signal.create ~signal (fun t -> - Queue.push queue (Fiber.Fill (ivar, ())); - Lev.Signal.stop t loop; - Lev.Signal.destroy t) - in - Lev.Signal.start signal loop; - Fiber.Ivar.read ivar - -module Fd = struct - type kind = Blocking | Non_blocking of { mutable set : bool } - type t = { fd : Unix.file_descr; kind : kind; mutable closed : bool } - - let fd_exn t = - if t.closed then raise (Unix.Unix_error (Unix.EBADF, "closed fd", "")); - t.fd - - let close t = - if not t.closed then ( - t.closed <- true; - Unix.close t.fd) - - let create' fd kind = { kind; fd; closed = false } - - let create fd kind = - let kind = - match kind with - | `Blocking -> Blocking - | `Non_blocking set -> Non_blocking { set } - in - create' fd kind - - let set_nonblock t = - assert (not t.closed); - match t.kind with - | Blocking -> () - | Non_blocking nb -> - if not nb.set then ( - Unix.set_nonblock t.fd; - nb.set <- true) - - let pipe = - if Sys.win32 then fun ?cloexec () -> - let r, w = Unix.pipe ?cloexec () in - ( { fd = r; kind = Blocking; closed = false }, - { fd = w; kind = Blocking; closed = false } ) - else fun ?cloexec () -> - let r, w = Unix.pipe ?cloexec () in - Unix.set_nonblock r; - Unix.set_nonblock w; - ( { fd = r; kind = Non_blocking { set = true }; closed = false }, - { fd = w; kind = Non_blocking { set = true }; closed = false } ) -end - -module Lev_fd = struct - module Event = Lev.Io.Event - - type open_ = { - io : Lev.Io.t; - fd : Fd.t; - scheduler : scheduler; - mutable events : Event.Set.t; - read : [ `Ready | `Closed ] Fiber.Ivar.t Queue.t; - write : [ `Ready | `Closed ] Fiber.Ivar.t Queue.t; - } - - type state = Open of open_ | Closed of Fd.t - type t = state ref - - let reset nb new_set = - nb.events <- new_set; - Lev.Io.stop nb.io nb.scheduler.loop; - Lev.Io.modify nb.io nb.events; - Lev.Io.start nb.io nb.scheduler.loop - - let await t (what : Lev.Io.Event.t) = - let* () = Fiber.return () in - match !t with - | Closed _ -> Fiber.return `Closed - | Open t -> - if t.fd.closed then Fiber.return `Closed - else ( - if not (Event.Set.mem t.events what) then - reset t (Event.Set.add t.events what); - let ivar = Fiber.Ivar.create () in - let q = match what with Write -> t.write | Read -> t.read in - Queue.push q ivar; - let+ res = Fiber.Ivar.read ivar in - match res with - | `Closed -> `Closed - | `Ready -> - assert (not t.fd.closed); - `Ready t.fd) - - let rec close_queue ivar_queue q = - match Queue.pop q with - | None -> () - | Some ivar -> - Queue.push ivar_queue (Fiber.Fill (ivar, `Closed)); - close_queue ivar_queue q - - let close (t : t) = - match !t with - | Closed fd -> fd - | Open { io; scheduler; fd; read; write; events = _ } -> - t := Closed fd; - Lev.Io.stop io scheduler.loop; - Lev.Io.destroy io; - Fd.close fd; - close_queue scheduler.queue read; - close_queue scheduler.queue write; - fd - - let make_cb t scheduler _ _ set = - match !(Fdecl.get t) with - | Closed _ -> () - | Open nb -> - let keep_read = ref true in - let keep_write = ref true in - (if Lev.Io.Event.Set.mem set Read then - match Queue.pop nb.read with - | Some ivar -> Queue.push scheduler.queue (Fiber.Fill (ivar, `Ready)) - | None -> keep_read := false); - (if Lev.Io.Event.Set.mem set Write then - match Queue.pop nb.write with - | Some ivar -> Queue.push scheduler.queue (Fiber.Fill (ivar, `Ready)) - | None -> keep_write := false); - let new_set = - Event.Set.inter nb.events - (Event.Set.create ~read:!keep_read ~write:!keep_write ()) - in - if not (Event.Set.equal new_set nb.events) then reset nb new_set - - let create (fd : Fd.t) : t Fiber.t = - if fd.closed then Code_error.raise "create: fd is closed" []; - let+ scheduler = Fiber.Var.get_exn scheduler in - let t : t Fdecl.t = Fdecl.create Dyn.opaque in - let events = Event.Set.create () in - let io = Lev.Io.create (make_cb t scheduler) fd.fd events in - let read = Queue.create () in - let write = Queue.create () in - Fdecl.set t (ref (Open { events; fd; scheduler; io; read; write })); - Lev.Io.start io scheduler.loop; - Fdecl.get t -end - -module Io = struct - let callstack = - match Sys.getenv_opt "LEV_DEBUG" with - | None -> fun () -> None - | Some _ -> fun () -> Some (Printexc.get_callstack 15) - - type input = Input - type output = Output - type 'a mode = Input : input mode | Output : output mode - - module Slice = Buffer.Slice - - type _ kind = - | Write : { mutable flush_counter : int } -> output kind - | Read : { mutable eof : bool } -> input kind - - type fd = Blocking of Thread.t * Fd.t | Non_blocking of Lev_fd.t - - let with_ fd (kind : Lev.Io.Event.t) ~f = - let* () = Fiber.return () in - match fd with - | Non_blocking lev_fd -> ( - let+ event = Lev_fd.await lev_fd kind in - match event with - | `Closed -> Error `Eof - | `Ready fd -> ( - match f fd with exception exn -> Error (`Exn exn) | s -> Ok s)) - | Blocking (th, fd) -> ( - let task = - match Thread.task th ~f:(fun () -> f fd) with - | Error `Stopped -> Code_error.raise "already stopped" [] - | Ok task -> task - in - let+ res = Thread.await task in - match res with - | Ok _ as s -> s - | Error `Cancelled -> assert false - | Error (`Exn exn) -> Error (`Exn exn.exn)) - - type activity = Idle | Busy of Printexc.raw_backtrace option - - type 'a open_ = { - mutable buffer : Buffer.t; - kind : 'a kind; - fd : fd; - mutable activity : activity; - source : Printexc.raw_backtrace option; - } - - type 'a t = ('a open_, Fd.t * Printexc.raw_backtrace option) State.t - - let fd (t : _ t) = - match !t with - | Closed (fd, _) -> fd - | Open { fd = Blocking (_, fd); _ } -> fd - | Open { fd = Non_blocking fd; _ } -> ( - match !fd with Closed fd -> fd | Open f -> f.fd) - - let rec with_resize_buffer t ~len reserve_fail k = - match Buffer.reserve t.buffer ~len with - | Some dst_pos -> k t ~len ~dst_pos - | None -> ( - match reserve_fail with - | `Compress -> - if Buffer.unused_space t.buffer >= len then - Buffer.Bytes.compress t.buffer; - with_resize_buffer t ~len `Resize k - | `Resize -> - let len = Buffer.length t.buffer + len in - Buffer.Bytes.resize t.buffer ~len; - with_resize_buffer t ~len `Fail k - | `Fail -> assert false) - - module Writer = struct - type nonrec t = output open_ - - module Expert = struct - let available t = Buffer.max_available t.buffer - - let prepare = - let k t ~len ~dst_pos:pos = - let buf = Buffer.buffer t.buffer in - (buf, { Slice.pos; len }) - in - fun t ~len -> with_resize_buffer t ~len `Compress k - - let commit t ~len = Buffer.commit t.buffer ~len - end - - let flush = - let rec loop t stop_count = - (* TODO fix overflow issues *) - if - (match t.kind with Write { flush_counter } -> flush_counter) - >= stop_count - then Fiber.return () - else - let* res = - with_ t.fd Write ~f:(fun fd -> - match Buffer.peek t.buffer with - | None -> () - | Some { Slice.pos; len } -> ( - let buffer = Buffer.buffer t.buffer in - let len = Unix.single_write fd.fd buffer pos len in - Buffer.junk t.buffer ~len; - match t.kind with - | Write t -> t.flush_counter <- t.flush_counter + len)) - in - match res with - | Ok () -> loop t stop_count - | Error (`Exn (Unix.Unix_error (Unix.EAGAIN, _, _))) -> - loop t stop_count - | Error (`Exn (Unix.Unix_error (EPIPE, _, _))) | Error `Eof -> - let args = - [ - ("remaining", Dyn.int stop_count); - ( "contents", - Dyn.string (Format.asprintf "%a@." Buffer.Bytes.pp t.buffer) - ); - ] - in - let args = - match t.source with - | None -> args - | Some source -> - ( "source", - Dyn.string @@ Printexc.raw_backtrace_to_string source ) - :: args - in - Code_error.raise "fd closed unflushed" args - | Error (`Exn exn) -> reraise exn - in - fun t -> - Fiber.of_thunk (fun () -> - let stop_count = - match t.kind with - | Write { flush_counter } -> - flush_counter + Buffer.length t.buffer - in - loop t stop_count) - - let add_substring t str ~pos ~len = - Buffer.Bytes.Writer.add_substring t.buffer str ~pos ~len - - let add_string t str = Buffer.Bytes.Writer.add_string t.buffer str - end - - let create_gen (type a) ~source fd (mode : a mode) = - let buffer = Buffer.create ~size:Buffer.default_size in - let kind : a kind = - match mode with - | Input -> Read { eof = false } - | Output -> Write { flush_counter = 0 } - in - State.create { buffer; fd; kind; activity = Idle; source } - - let create (type a) (fd : Fd.t) (mode : a mode) = - let source = callstack () in - match fd.kind with - | Non_blocking _ -> - let+ fd = Lev_fd.create fd in - create_gen ~source (Non_blocking fd) mode - | Blocking -> - let+ thread = Thread.create () in - create_gen ~source (Blocking (thread, fd)) mode - - let create_rw (fd : Fd.t) : (input t * output t) Fiber.t = - let source = callstack () in - match fd.kind with - | Non_blocking _ -> - let+ fd = - let+ fd = Lev_fd.create fd in - Non_blocking fd - in - let r = create_gen ~source fd Input in - let w = create_gen ~source fd Output in - (r, w) - | Blocking -> - let* r = - let+ thread = Thread.create () in - create_gen ~source (Blocking (thread, fd)) Input - in - let+ w = - let+ thread = Thread.create () in - create_gen ~source (Blocking (thread, fd)) Output - in - (r, w) - - let close = - let close_fd t = - match t with - | Non_blocking fd -> Lev_fd.close fd - | Blocking (th, fd) -> - Thread.close th; - Fd.close fd; - fd - in - fun (type a) (t : a t) -> - match !t with - | State.Closed _ -> () - | Open o -> - (match (o.kind : _ kind) with - | Read r -> r.eof <- true - | Write _ -> () (* TODO *)); - let fd = close_fd o.fd in - t := Closed (fd, o.source) - - module Reader = struct - type t = input open_ - - exception Unavailable - - module Expert = struct - let buffer t = - match Buffer.peek t.buffer with - | None -> raise Unavailable - | Some { Buffer.Slice.pos; len } -> - let b = Buffer.buffer t.buffer in - (b, { Slice.pos; len }) - - let consume (t : t) ~len = Buffer.junk t.buffer ~len - - let available t = - let eof = match t.kind with Read { eof } -> eof in - let available = Buffer.length t.buffer in - if available = 0 && eof then `Eof else `Ok available - - let refill = - let rec read t ~len ~dst_pos = - let buffer = Buffer.buffer t.buffer in - let* res = - with_ t.fd Read ~f:(fun fd -> Unix.read fd.fd buffer 0 len) - in - match res with - | Error (`Exn (Unix.Unix_error (Unix.EAGAIN, _, _))) -> - read t ~len ~dst_pos - | Error `Eof | Ok 0 -> - (match t.kind with Read b -> b.eof <- true); - Buffer.commit t.buffer ~len:0; - Fiber.return () - | Ok len -> - Buffer.commit t.buffer ~len; - Fiber.return () - | Error (`Exn exn) -> reraise exn - in - fun ?(size = Buffer.default_size) (t : t) -> - with_resize_buffer t ~len:size `Compress read - end - - exception Found of int - - let read_char_exn t = - let b, { Buffer.Slice.pos; len } = Expert.buffer t in - assert (len > 0); - let res = Bytes.get b pos in - Expert.consume t ~len:1; - res - - let read_line = - let contents buf = - let module Buffer = Stdlib.Buffer in - let len = Buffer.length buf in - if len = 0 then "" - else if Buffer.nth buf (len - 1) = '\r' then Buffer.sub buf 0 (len - 1) - else Buffer.contents buf - in - let find_nl b pos len = - try - for i = pos to pos + len - 1 do - if Bytes.get b i = '\n' then raise_notrace (Found i) - done; - None - with Found i -> Some i - in - let rec loop t buf = - match Expert.available t with - | `Eof -> - Fiber.return (Error (`Partial_eof (Stdlib.Buffer.contents buf))) - | `Ok 0 -> - let* () = Expert.refill t in - loop t buf - | `Ok _ -> ( - let b, { Slice.pos; len } = Expert.buffer t in - match find_nl b pos len with - | Some i -> - let len = i - pos in - Stdlib.Buffer.add_subbytes buf b pos len; - Buffer.junk t.buffer ~len:(len + 1); - Fiber.return (Ok (contents buf)) - | None -> - Stdlib.Buffer.add_subbytes buf b pos len; - Buffer.junk t.buffer ~len; - loop t buf) - in - let rec self t = - (* we can always call loop, but we do a little optimization to see if we can - read the line without an extra copy - *) - match Expert.available t with - | `Eof -> Fiber.return (Error (`Partial_eof "")) - | `Ok 0 -> - let* () = Expert.refill t in - self t - | `Ok _ -> ( - let b, { Slice.pos; len } = Expert.buffer t in - match find_nl b pos len with - | Some i -> - let len = i - pos in - let res = - let len = - if len > 0 && Bytes.get b (i - 1) = '\r' then len - 1 - else len - in - Bytes.sub b ~pos ~len - in - Buffer.junk t.buffer ~len:(len + 1); - Fiber.return (Ok (Bytes.unsafe_to_string res)) - | None -> - let buf = Stdlib.Buffer.create len in - Stdlib.Buffer.add_subbytes buf b pos len; - Buffer.junk t.buffer ~len; - loop t buf) - in - fun t -> Fiber.of_thunk (fun () -> self t) - - let read_exactly = - let rec loop_buffer t buf remains = - if remains = 0 then Fiber.return (Ok (Stdlib.Buffer.contents buf)) - else - match Expert.available t with - | `Eof -> - Fiber.return (Error (`Partial_eof (Stdlib.Buffer.contents buf))) - | `Ok 0 -> - let* () = Expert.refill t in - loop_buffer t buf remains - | `Ok _ -> - let b, { Slice.pos; len } = Expert.buffer t in - let len = min remains len in - Stdlib.Buffer.add_subbytes buf b pos len; - Buffer.junk t.buffer ~len; - loop_buffer t buf (remains - len) - in - let rec self t len = - (* we can always call loop, but we do a little optimization to see if we can - read the line without an extra copy - *) - match Expert.available t with - | `Eof -> Fiber.return (Error (`Partial_eof "")) - | `Ok 0 -> - let* () = Expert.refill t in - self t len - | `Ok _ -> - let b, { Slice.pos; len = avail } = Expert.buffer t in - if len <= avail then ( - let res = Bytes.sub b ~pos ~len in - Buffer.junk t.buffer ~len; - Fiber.return (Ok (Bytes.unsafe_to_string res))) - else - let buf = Stdlib.Buffer.create len in - Stdlib.Buffer.add_subbytes buf b pos avail; - Buffer.junk t.buffer ~len:avail; - loop_buffer t buf (len - avail) - in - fun t len -> Fiber.of_thunk (fun () -> self t len) - - let to_string = - let rec loop t buf = - match Expert.available t with - | `Eof -> Fiber.return (Stdlib.Buffer.contents buf) - | `Ok 0 -> - let* () = Expert.refill t in - loop t buf - | `Ok _ -> - let b, { Slice.pos; len } = Expert.buffer t in - Stdlib.Buffer.add_subbytes buf b pos len; - Expert.consume t ~len; - loop t buf - in - fun t -> Fiber.of_thunk (fun () -> loop t (Stdlib.Buffer.create 512)) - end - - let with_ (type a) (t : a t) ~f = - let activity_source = callstack () in - let* () = Fiber.return () in - let t = - match !(t : _ State.t) with - | Open t -> t - | Closed (_, source) -> - let args = - match source with - | None -> [] - | Some source -> - [ - ( "source", - Dyn.string (Printexc.raw_backtrace_to_string source) ); - ] - in - Code_error.raise "Lev_fiber.Io: already closed" args - in - (match t.activity with - | Idle -> t.activity <- Busy activity_source - | Busy activity_source -> - let args = - let args = - [ - ( "kind", - Dyn.string - (match t.kind with Read _ -> "read" | Write _ -> "write") ); - ] - in - let args = - match t.source with - | None -> args - | Some source -> - ("source", Dyn.string (Printexc.raw_backtrace_to_string source)) - :: args - in - match activity_source with - | None -> args - | Some activity_source -> - ( "activity_source", - Dyn.string (Printexc.raw_backtrace_to_string activity_source) ) - :: args - in - Code_error.raise "Io.t is already busy" args); - Fiber.finalize - (fun () -> f t) - ~finally:(fun () -> - t.activity <- Idle; - Fiber.return ()) - - let with_read (t : input t) ~f = with_ t ~f - let with_write (t : output t) ~f = with_ t ~f - - let pipe ?cloexec () : (input t * output t) Fiber.t = - Fiber.of_thunk @@ fun () -> - let r, w = Fd.pipe ?cloexec () in - let* input = create r Input in - let+ output = create w Output in - (input, output) - - module Lazy_fiber : sig - type 'a t - - val create : (unit -> 'a Fiber.t) -> 'a t - val force : 'a t -> 'a Fiber.t - end = struct - type 'a t = { - value : 'a Fiber.Ivar.t; - mutable f : (unit -> 'a Fiber.t) option; - } - - let create f = { f = Some f; value = Fiber.Ivar.create () } - - let force t = - let open Fiber.O in - match t.f with - | None -> Fiber.Ivar.read t.value - | Some f -> - Fiber.of_thunk (fun () -> - t.f <- None; - let* v = f () in - let+ () = Fiber.Ivar.fill t.value v in - v) - end - - let make_std_fd fd kind = - Lazy_fiber.create (fun () -> - let blockity = - if Sys.win32 then `Blocking - else ( - Unix.set_nonblock fd; - `Non_blocking true) - in - create (Fd.create fd blockity) kind) - - let stdin = Lazy_fiber.force (make_std_fd Unix.stdin Input) - let stderr = Lazy_fiber.force (make_std_fd Unix.stderr Output) - let stdout = Lazy_fiber.force (make_std_fd Unix.stdout Output) -end - -module Socket = struct - let writeable_fd scheduler fd = - let ivar = Fiber.Ivar.create () in - let io = - Lev.Io.create - (fun io _ _ -> - Queue.push scheduler.queue (Fiber.Fill (ivar, ())); - Lev.Io.stop io scheduler.loop; - Lev.Io.destroy io) - fd - (Lev.Io.Event.Set.create ~write:true ()) - in - Lev.Io.start io scheduler.loop; - Fiber.Ivar.read ivar - - let rec connect (fd : Fd.t) sock = - let* scheduler = Fiber.Var.get_exn scheduler in - Fd.set_nonblock fd; - match Unix.connect fd.fd sock with - | () -> Fiber.return () - | exception Unix.Unix_error (Unix.EISCONN, _, _) when Sys.win32 -> - Fiber.return () - | exception Unix.Unix_error (Unix.EWOULDBLOCK, _, _) when Sys.win32 -> - let* () = writeable_fd scheduler fd.fd in - connect fd sock - | exception Unix.Unix_error (Unix.EINPROGRESS, _, _) -> ( - let+ () = writeable_fd scheduler fd.fd in - match Unix.getsockopt_error fd.fd with - | None -> () - | Some err -> raise (Unix.Unix_error (err, "connect", ""))) - - module Server = struct - type t = { - fd : Fd.t; - pool : Fiber.Pool.t; - io : Lev.Io.t; - mutable close : bool; - mutable await : unit Fiber.Ivar.t; - } - - let create (fd : Fd.t) sockaddr ~backlog = - let+ scheduler = Fiber.Var.get_exn scheduler in - let pool = Fiber.Pool.create () in - Fd.set_nonblock fd; - Unix.bind fd.fd sockaddr; - Unix.listen fd.fd backlog; - let t = Fdecl.create Dyn.opaque in - let io = - Lev.Io.create - (fun _ _ _ -> - let t = Fdecl.get t in - Queue.push scheduler.queue (Fiber.Fill (t.await, ()))) - fd.fd - (Lev.Io.Event.Set.create ~read:true ()) - in - Fdecl.set t { pool; await = Fiber.Ivar.create (); close = false; fd; io }; - Fdecl.get t - - let close t = - Fiber.of_thunk (fun () -> - if t.close then Fiber.return () - else - let* scheduler = Fiber.Var.get_exn scheduler in - Fd.close t.fd; - Lev.Io.stop t.io scheduler.loop; - Lev.Io.destroy t.io; - t.close <- true; - let* () = Fiber.Pool.stop t.pool in - Fiber.Ivar.fill t.await ()) - - module Session = struct - type t = { fd : Fd.t; sockaddr : Unix.sockaddr } - - let fd t = t.fd - let sockaddr t = t.sockaddr - - let io t = - Fd.set_nonblock t.fd; - Io.create_rw t.fd - end - - let serve = - let rec loop t f = - let* () = Fiber.Ivar.read t.await in - match t.close with - | true -> Fiber.return () - | false -> - t.await <- Fiber.Ivar.create (); - let session = - let fd, sockaddr = Unix.accept ~cloexec:true t.fd.fd in - let fd = Fd.create' fd (Non_blocking { set = false }) in - { Session.fd; sockaddr } - in - let* () = Fiber.Pool.task t.pool ~f:(fun () -> f session) in - loop t f - in - fun (t : t) ~f -> - let* scheduler = Fiber.Var.get_exn scheduler in - Lev.Io.start t.io scheduler.loop; - Fiber.fork_and_join_unit - (fun () -> Fiber.Pool.run t.pool) - (fun () -> loop t f) - end -end - -let yield () = - let* scheduler = Fiber.Var.get_exn scheduler in - let ivar = Fiber.Ivar.create () in - Queue.push scheduler.queue (Fiber.Fill (ivar, ())); - Fiber.Ivar.read ivar - -module Error = struct - type t = Aborted of Exn_with_backtrace.t | Already_reported | Deadlock - - let ok_exn = function - | Ok s -> s - | Error (Aborted exn) -> Exn_with_backtrace.reraise exn - | Error Already_reported -> Code_error.raise "Already_reported" [] - | Error Deadlock -> Code_error.raise "Deadlock" [] -end - -exception Deadlock - -let run (type a) ?(sigpipe = `Inherit) - ?(flags = Lev.Loop.Flag.Set.singleton Nosigmask) (f : unit -> a Fiber.t) : - (a, Error.t) result = - if not (Lev.Loop.Flag.Set.mem flags Nosigmask) then - Code_error.raise "flags must include Nosigmask" []; - let lev_loop = Lev.Loop.create ~flags () in - let thread_jobs = Queue.create () in - let thread_mutex = Mutex.create () in - let queue = Queue.create () in - let async = - Lev.Async.create (fun _ -> - Mutex.lock thread_mutex; - while not (Queue.is_empty thread_jobs) do - let { ivar; status } = Queue.pop_exn thread_jobs in - match !status with - | Active -> - Lev.Loop.unref lev_loop; - status := Complete; - Queue.push queue ivar - | Cancelled -> () - | Complete -> assert false - done; - Mutex.unlock thread_mutex) - in - Lev.Async.start async lev_loop; - Lev.Loop.unref lev_loop; - let process_watcher = Process_watcher.create lev_loop queue in - let signal_watcher = - if Sys.win32 then None - else - let sigchld_watcher = - match process_watcher.watcher with - | Signal s -> s - | Poll _ -> assert false - in - Some (Signal_watcher.create ~sigpipe ~sigchld_watcher ~loop:lev_loop) - in - let t = - { - loop = lev_loop; - signal_watcher; - queue; - async; - thread_mutex; - thread_jobs; - process_watcher; - thread_workers = []; - } - in - let rec events q acc = - match Queue.pop q with None -> acc | Some e -> events q (e :: acc) - in - let rec iter_or_deadlock q = - match Nonempty_list.of_list (events q []) with - | Some e -> e - | None -> raise_notrace Deadlock - and iter loop q = - match Nonempty_list.of_list (events q []) with - | Some e -> e - | None -> ( - let res = Lev.Loop.run loop Once in - match res with - | `No_more_active_watchers -> iter_or_deadlock q - | `Otherwise -> iter loop q) - in - let f = - let on_error exn = - Format.eprintf "%a@." Exn_with_backtrace.pp_uncaught exn; - Fiber.return () - in - let f () = Fiber.Var.set t_var t f in - Fiber.map_reduce_errors (module Monoid.Unit) ~on_error f - in - let res : (a, Error.t) result = - match Fiber.run f ~iter:(fun () -> iter lev_loop queue) with - | Error () -> Error Already_reported - | Ok s -> Ok s - | exception Deadlock -> Error Deadlock - | exception exn -> - let exn = Exn_with_backtrace.capture exn in - Error (Aborted exn) - in - let () = - Process_watcher.cleanup process_watcher; - Lev.Async.stop async lev_loop; - Option.iter signal_watcher ~f:Signal_watcher.stop; - List.iter t.thread_workers ~f:(fun (Worker w) -> - Worker.complete_tasks_and_stop w; - Worker.join w); - Lev.Async.destroy async; - Lev.Loop.destroy lev_loop - in - res diff --git a/submodules/lev/lev-fiber/src/lev_fiber.mli b/submodules/lev/lev-fiber/src/lev_fiber.mli deleted file mode 100644 index 4b535a126..000000000 --- a/submodules/lev/lev-fiber/src/lev_fiber.mli +++ /dev/null @@ -1,188 +0,0 @@ -open Stdune - -module Timer : sig - val sleepf : float -> unit Fiber.t - (** [sleep f] wait for [f] seconds *) - - module Wheel : sig - type t - (** wheel to handle many constant timeouts efficiently *) - - val create : delay:float -> t Fiber.t - (** [create ~delay] will create a wheel that times out every task in [delay] *) - - val set_delay : t -> delay:float -> unit Fiber.t - val delay : t -> float - - type task - (** a task scheduled by the timer wheel *) - - val reset : task -> unit Fiber.t - - val task : t -> task Fiber.t - (** create a new task *) - - val await : task -> [ `Ok | `Cancelled ] Fiber.t - (** wait for delay seconds *) - - val cancel : task -> unit Fiber.t - (** cancel waiting *) - - val run : t -> unit Fiber.t - (** run the wheel forever *) - - val stop : t -> unit Fiber.t - (** [stop t] stop running the wheel and cancel everything. - it's an error to call [task t] after this. *) - end -end - -val waitpid : pid:int -> Unix.process_status Fiber.t -val signal : signal:int -> unit Fiber.t - -module Thread : sig - type t - - val create : unit -> t Fiber.t - - type 'a task - - val task : t -> f:(unit -> 'a) -> ('a task, [ `Stopped ]) result - val cancel : 'a task -> unit Fiber.t - - val await : - 'a task -> - ('a, [ `Exn of Exn_with_backtrace.t | `Cancelled ]) result Fiber.t - - val close : t -> unit -end - -module Fd : sig - type t - - val close : t -> unit - val create : Unix.file_descr -> [ `Blocking | `Non_blocking of bool ] -> t - - val fd_exn : t -> Unix.file_descr - (** [fd_exn [Unix.EBADF] if the underlying FD is closed. *) -end - -module Io : sig - type input = Input - type output = Output - type 'a mode = Input : input mode | Output : output mode - type 'a t - - val fd : _ t -> Fd.t - val create : Fd.t -> 'a mode -> 'a t Fiber.t - val create_rw : Fd.t -> (input t * output t) Fiber.t - - module Slice : sig - type t = { pos : int; len : int } - end - - module Reader : sig - type t - - exception Unavailable - - val read_char_exn : t -> char - val read_line : t -> (string, [ `Partial_eof of string ]) result Fiber.t - - val read_exactly : - t -> int -> (string, [ `Partial_eof of string ]) result Fiber.t - - val to_string : t -> string Fiber.t - (** [to_string t] read the entire stream into a string. Not recommended for serious use as - this is inefficient *) - - module Expert : sig - val available : t -> [ `Ok of int | `Eof ] - val buffer : t -> Bytes.t * Slice.t - val consume : t -> len:int -> unit - val refill : ?size:int -> t -> unit Fiber.t - end - end - - module Writer : sig - type t - - val flush : t -> unit Fiber.t - val add_substring : t -> string -> pos:int -> len:int -> unit - val add_string : t -> string -> unit - - module Expert : sig - (* max size we can allocate for a transaction without resizing *) - val available : t -> int - val prepare : t -> len:int -> Bytes.t * Slice.t - val commit : t -> len:int -> unit - end - end - - val with_read : input t -> f:(Reader.t -> 'a Fiber.t) -> 'a Fiber.t - val with_write : output t -> f:(Writer.t -> 'a Fiber.t) -> 'a Fiber.t - - val close : 'a t -> unit - (** close the underlying file descriptor, watchers, threads (if any) *) - - val pipe : ?cloexec:bool -> unit -> (input t * output t) Fiber.t - - val stdin : input t Fiber.t - (** [Unix.stdin] wrapped with [Io.t] *) - - val stderr : output t Fiber.t - (** [Unix.stderr] wrapped with [Io.t] *) - - val stdout : output t Fiber.t - (** [Unix.stdout] wrapped with [Io.t] *) -end - -module Socket : sig - module Server : sig - type t - - val create : Fd.t -> Unix.sockaddr -> backlog:int -> t Fiber.t - val close : t -> unit Fiber.t - - module Session : sig - type t - - val fd : t -> Fd.t - val sockaddr : t -> Unix.sockaddr - val io : t -> (Io.input Io.t * Io.output Io.t) Fiber.t - end - - val serve : t -> f:(Session.t -> unit Fiber.t) -> unit Fiber.t - end - - val connect : Fd.t -> Unix.sockaddr -> unit Fiber.t -end - -val yield : unit -> unit Fiber.t -(** [yield ()] wait for one iteration of the event loop *) - -module Error : sig - type t = - | Aborted of Exn_with_backtrace.t - (** An error from the scheduler itself. Usually due to a bug *) - | Already_reported - (** An exception from the fiber was bubbled up to the toplevel *) - | Deadlock - - val ok_exn : ('a, t) result -> 'a -end - -val run : - ?sigpipe:[ `Inherit | `Ignore ] -> - ?flags:Lev.Loop.Flag.Set.t -> - (unit -> 'a Fiber.t) -> - ('a, Error.t) result -(** [Scheduler.run ?flags f] runs [f]. - - If you set [flags] manually, you must include the [Nosigprocmask] flag. - - Returns [Error ()] if [f] raises at least once. By default, errors that - will be leaked to the toplevel will be logged to stderr. To customize this - behavior, wrap [f] with one of the various error handling functions in - [Fiber]. - *) diff --git a/submodules/lev/lev-fiber/src/util/bip_buffer.ml b/submodules/lev/lev-fiber/src/util/bip_buffer.ml deleted file mode 100644 index 36e2d63b1..000000000 --- a/submodules/lev/lev-fiber/src/util/bip_buffer.ml +++ /dev/null @@ -1,202 +0,0 @@ -open Stdune - -module Blit = struct - type ('src, 'dst) t = - src:'src -> src_pos:int -> dst:'dst -> dst_pos:int -> len:int -> unit - - let bytes : (Bytes.t, Bytes.t) t = Bytes.blit -end - -module Slice = struct - type t = { pos : int; len : int } -end - -type 'a t = { - mutable buf : 'a; - mutable buf_len : int; - mutable a_start : int; - mutable a_end : int; - mutable b_end : int; - mutable b_inuse : bool; - mutable reserving : bool; -} - -let buffer t = t.buf - -let _invariant t = - if t.b_inuse then assert (t.b_end - t.a_start > t.buf_len - t.a_end) - -let create buf ~len = - { - buf; - buf_len = len; - a_start = 0; - a_end = 0; - b_end = 0; - b_inuse = false; - reserving = false; - } - -let peek t = - if t.a_start < t.a_end then - Some { Slice.pos = t.a_start; len = t.a_end - t.a_start } - else None - -let is_empty t = t.a_start = t.a_end -let length t = t.a_end - t.a_start + t.b_end - -let junk t ~len:size = - assert (length t >= size); - let read_len = min size (t.a_end - t.a_start) in - t.a_start <- t.a_start + read_len; - if t.a_start = t.a_end then ( - t.a_start <- size - read_len; - t.a_end <- t.b_end; - t.b_end <- 0; - t.b_inuse <- false) - -let space_left_for_a t = t.buf_len - t.a_end -let space_left_for_b t = t.a_start - t.b_end - -(* the maximum buffer that doesn't fragment the buffer *) -let best_available t = - if t.b_inuse then space_left_for_b t else space_left_for_a t - -(* the maximum space for a single contiguous write *) -let max_available t = - if t.b_inuse then space_left_for_b t - else max (space_left_for_a t) (space_left_for_b t) - -(* the maximum we can write if we don't mind doing it two blits *) -let available_two_writes t = - if t.b_inuse then space_left_for_b t - else space_left_for_a t + space_left_for_b t - -let reserve t ~len:size = - if t.reserving then Code_error.raise "previous reserve not committed" []; - let space_left_for_a = space_left_for_a t in - let space_left_for_b = space_left_for_b t in - if t.b_inuse then - if space_left_for_b >= size then ( - t.reserving <- true; - Some t.b_end) - else None - else if space_left_for_a >= size then ( - t.reserving <- true; - Some t.a_end) - else if space_left_for_b >= size then ( - t.reserving <- true; - t.b_inuse <- true; - Some t.b_end) - else None - -let commit t ~len = - assert t.reserving; - if t.b_inuse then ( - assert (t.b_end + len <= t.a_start); - t.b_end <- t.b_end + len) - else ( - assert (t.a_end + len <= t.buf_len); - t.a_end <- t.a_end + len); - t.reserving <- false - -let unused_space t = space_left_for_a t + space_left_for_b t - -let compress t (blit : (_, _) Blit.t) = - assert (not t.reserving); - if t.a_start = 0 then () - else - let src = t.buf in - let dst = t.buf in - if t.b_end = 0 then ( - let len_a = t.a_end - t.a_start in - blit ~src ~dst ~src_pos:t.a_start ~dst_pos:0 ~len:len_a; - t.a_start <- 0; - t.a_end <- len_a; - t.b_end <- 0; - t.b_inuse <- false) - else if space_left_for_b t >= t.a_end - t.a_start then ( - let len_a = t.a_end - t.a_start in - blit ~src ~dst ~src_pos:0 ~dst_pos:len_a ~len:t.b_end; - blit ~src ~dst ~src_pos:t.a_start ~dst_pos:0 ~len:len_a; - t.a_start <- 0; - t.a_end <- len_a + t.b_end; - t.b_end <- 0; - t.b_inuse <- false) - -let resize t (blit : (_, _) Blit.t) dst ~len = - assert (not t.reserving); - let len_t = length t in - assert (len >= len_t); - let src = t.buf in - let len_a = t.a_end - t.a_start in - blit ~src ~dst ~src_pos:t.a_start ~dst_pos:0 ~len:len_a; - blit ~src ~dst ~src_pos:0 ~dst_pos:len_a ~len:t.b_end; - t.buf <- dst; - t.buf_len <- len; - t.a_start <- 0; - t.b_end <- 0; - t.a_end <- len_t; - t.b_inuse <- false; - t.a_start <- 0 - -let pp pp_slice fmt t = - let slice = { Slice.pos = t.a_start; len = t.a_end - t.a_start } in - pp_slice fmt (t.buf, slice); - if t.b_end > 0 then - let slice = { Slice.pos = 0; len = t.b_end } in - pp_slice fmt (t.buf, slice) - -module Bytes = struct - type nonrec t = Bytes.t t - - let resize t ~len = - let new_buf = Bytes.create len in - resize t Blit.bytes new_buf ~len - - let compress t = compress t Blit.bytes - - let pp_slice fmt (bytes, { Slice.pos; len }) = - Format.fprintf fmt "%s" (Bytes.sub_string bytes ~pos ~len) - - let pp fmt (t : t) = pp pp_slice fmt t - - module Writer = struct - module Make_from_bytes (S : sig - val add_subbytes : t -> Bytes.t -> pos:int -> len:int -> unit - end) = - struct - include S - - let add_substring t src ~pos ~len = - add_subbytes t (Bytes.unsafe_of_string src) ~len ~pos - - let add_bytes t src = add_subbytes t src ~len:(Bytes.length src) ~pos:0 - let add_string t src = add_substring t src ~pos:0 ~len:(String.length src) - let add_char t c = add_string t (String.make 1 c) - end - - include Make_from_bytes (struct - let add_subbytes (t : t) src ~pos:src_pos ~len = - if unused_space t < len then - (* we must resize *) - let len = max (t.buf_len + len) (t.buf_len * 2) in - resize t ~len - else if len > available_two_writes t then - (* in this case, a compression is sufficient *) - compress t; - (* now we know we can fit the write *) - let len_1 = min len (best_available t) in - let dst_pos = Option.value_exn (reserve t ~len:len_1) in - let dst = buffer t in - Blit.bytes ~src ~src_pos ~dst_pos ~dst ~len:len_1; - commit t ~len:len_1; - let len_2 = len - len_1 in - if len_2 > 0 then ( - let src_pos = src_pos + len_1 in - let dst_pos = Option.value_exn (reserve t ~len:len_2) in - Blit.bytes ~src ~src_pos ~dst_pos ~dst ~len:len_2; - commit t ~len:len_2) - end) - end -end diff --git a/submodules/lev/lev-fiber/src/util/bip_buffer.mli b/submodules/lev/lev-fiber/src/util/bip_buffer.mli deleted file mode 100644 index af10b2bb5..000000000 --- a/submodules/lev/lev-fiber/src/util/bip_buffer.mli +++ /dev/null @@ -1,81 +0,0 @@ -(** Simon Cooke's Bip_buffer *) - -module Blit : sig - type ('src, 'dst) t = - src:'src -> src_pos:int -> dst:'dst -> dst_pos:int -> len:int -> unit -end - -module Slice : sig - type t = { pos : int; len : int } -end - -type 'a t -(** a bip buffer with some underlying container of bytes indexed by a continuous range - of integers that starts from 0. *) - -val max_available : _ t -> int -(** [max_available t] returns the maximum available contiguous write size the - buffer can accept *) - -val best_available : _ t -> int -(** [best_available t] returns the best available contiguous write size the - buffer can accept. If all writes are smaller than [best_available t], it is - guaranteed that no space will be wasted. *) - -val is_empty : _ t -> bool -(** [is_empty t] true if there are no bytes available to read in [t] *) - -val length : _ t -> int -(** [length t] returns the number of bytes readable in [t] *) - -val buffer : 'a t -> 'a -(** [buffer t] returns the underlying buffer of [t] for reading/writing *) - -val create : 'a -> len:int -> 'a t -(** [create buf ~len] creates a new buffer with underlying storage [buf] of length [len] *) - -val junk : _ t -> len:int -> unit -(** [junk t ~len] discards [len] from the front of the buffer. Usually called after reading *) - -val peek : _ t -> Slice.t option -(** [peek t] returns the next contiguous readable buffer slice as [Some _]. If - [t] is empty, [None] is returned. Once a portion of this slice is read, - [junk] should be called. *) - -val reserve : _ t -> len:int -> int option -val commit : _ t -> len:int -> unit - -val unused_space : _ t -> int -(** Total amount of free space available in the buffer. Not all of it may be - usable. To reclaim it, call [compress] *) - -val compress : 'a t -> ('a, 'a) Blit.t -> unit -(** [compress t blit] will try to compress the buffer with 2 blit operations. - Use [unused_space t] to asses how useful this will be. *) - -val resize : 'a t -> ('a, 'a) Blit.t -> 'a -> len:int -> unit -(** [resize t blit buf ~len] will create a new buffer with the same data. The - old buffer is then emptied and can be reused *) - -val pp : - (Format.formatter -> 'a * Slice.t -> unit) -> Format.formatter -> 'a t -> unit - -module Bytes : sig - type nonrec t = Bytes.t t - - val resize : t -> len:int -> unit - val compress : t -> unit - val pp : Format.formatter -> t -> unit - - module Writer : sig - (** This module will automatically resize/compress the buffer when space - runs out. If you want to make sure the buffer doesn't grow, make sure - the writes are within [max_available] or [best_available]. *) - - val add_char : t -> char -> unit - val add_string : t -> string -> unit - val add_substring : t -> string -> pos:int -> len:int -> unit - val add_bytes : t -> Bytes.t -> unit - val add_subbytes : t -> Bytes.t -> pos:int -> len:int -> unit - end -end diff --git a/submodules/lev/lev-fiber/src/util/channel.ml b/submodules/lev/lev-fiber/src/util/channel.ml deleted file mode 100644 index e5ae43f28..000000000 --- a/submodules/lev/lev-fiber/src/util/channel.ml +++ /dev/null @@ -1,61 +0,0 @@ -open Stdune - -type 'a t = { - q : 'a Removable_queue.t; - m : Mutex.t; - c : Condition.t; - mutable is_closed : bool; -} - -type elt_in_channel = - | Node : - Mutex.t (* mutex of the channel, where this element was sent *) - * 'a Removable_queue.node - -> elt_in_channel - -let create () = - { - q = Removable_queue.create (); - m = Mutex.create (); - c = Condition.create (); - is_closed = false; - } - -let with_mutex m ~f = - Mutex.lock m; - Exn.protect ~f:(fun () -> f ()) ~finally:(fun () -> Mutex.unlock m) - -let is_empty t = with_mutex t.m ~f:(fun () -> Removable_queue.is_empty t.q) -let length t = with_mutex t.m ~f:(fun () -> Removable_queue.length t.q) - -let send_removable t v = - with_mutex t.m ~f:(fun () -> - if t.is_closed then Error `Closed - else - let n = Removable_queue.push t.q v in - Condition.signal t.c; - Ok (Node (t.m, n))) - -let send t v = send_removable t v |> Result.map ~f:ignore - -let get t = - with_mutex t.m ~f:(fun () -> - let rec aux () = - match Removable_queue.pop t.q with - | Some v -> Ok v - | None -> - if t.is_closed then Error `Closed - else ( - Condition.wait t.c t.m; - aux ()) - in - aux ()) - -let remove_if_not_consumed (Node (m, n)) = - with_mutex m ~f:(fun () -> Removable_queue.remove n) - -let close t = - with_mutex t.m ~f:(fun () -> - if not t.is_closed then ( - t.is_closed <- true; - Condition.signal t.c)) diff --git a/submodules/lev/lev-fiber/src/util/channel.mli b/submodules/lev/lev-fiber/src/util/channel.mli deleted file mode 100644 index 5b114e747..000000000 --- a/submodules/lev/lev-fiber/src/util/channel.mli +++ /dev/null @@ -1,30 +0,0 @@ -type 'a t -type elt_in_channel - -val create : unit -> 'a t - -val is_empty : 'a t -> bool -(** Checks whether the channel contains elements *) - -val length : 'a t -> int -(** Number of elements currently in the channel not consumed. Runs in O(n). *) - -val send_removable : 'a t -> 'a -> (elt_in_channel, [ `Closed ]) result -(** [send_removable ch v] puts a value [v] in the channel [ch] in a non-blocking - manner (we consider acquiring/waiting for the lock to be "non-blocking"). - The returned value [elt_in_channel] can then be used to remove the put - element from the channel if it hasn't been consumed by the other end of the - channel yet. *) - -val send : 'a t -> 'a -> (unit, [ `Closed ]) result -(** similar to [send_removable] but the element is non-removable from the - channel once sent *) - -val remove_if_not_consumed : elt_in_channel -> unit -(** remove element put in the channel if it hasn't been consumed yet *) - -val get : 'a t -> ('a, [ `Closed ]) result -(** [get ch] reads a value [v] from the channel [ch]. If there is no value to - read, the thread sleeps until there is some value to read. *) - -val close : 'a t -> unit diff --git a/submodules/lev/lev-fiber/src/util/dune b/submodules/lev/lev-fiber/src/util/dune deleted file mode 100644 index 3a68f1e30..000000000 --- a/submodules/lev/lev-fiber/src/util/dune +++ /dev/null @@ -1,6 +0,0 @@ -(library - (name lev_fiber_util) - (libraries stdune threads.posix) - (instrumentation - (backend bisect_ppx)) - (package lev-fiber)) diff --git a/submodules/lev/lev-fiber/src/util/removable_queue.ml b/submodules/lev/lev-fiber/src/util/removable_queue.ml deleted file mode 100644 index 2a1717501..000000000 --- a/submodules/lev/lev-fiber/src/util/removable_queue.ml +++ /dev/null @@ -1,75 +0,0 @@ -(* Implementation of a doubly linked list, based on Cormen et al. "Introduction - to Algorithms" and - https://github.com/janestreet/jenga/blob/114.04/tenacious/lib/ring.ml for - hacky OCaml-specific pieces. *) - -type 'a t = { - data : 'a option; - mutable prev : 'a t; - (* Invariant: if [node.prev == node] then [node] has been removed from - the list. Easy to hold invariant that frees us from having a separate - mutable record field to hold this information. *) - mutable next : 'a t; - (* Invariant: if [node.next == node] then it's the sentinel *) -} - -type 'a node = 'a t - -let data node = match node.data with None -> assert false | Some s -> s - -let create () : 'a t = - let rec sentinel = - { - data = - None - (* sentinel doesn't hold [data]; so this field should never be - accessed *); - prev = sentinel; - next = sentinel; - } - in - sentinel - -let is_empty (sentinel : 'a t) : bool = sentinel.next == sentinel - -let length (sentinel : 'a t) : int = - let head = ref sentinel.next in - let count = ref 0 in - while not (!head == sentinel) do - incr count; - head := !head.next - done; - !count - -(* appends a tail node *) -let push : 'a. 'a t -> 'a -> 'a node = - fun sentinel v -> - let inserted_node = - { data = Some v; prev = sentinel.prev; next = sentinel } - in - sentinel.prev.next <- inserted_node; - sentinel.prev <- inserted_node; - inserted_node - -let mark_as_detached (node : 'a node) = node.prev <- node -let is_detached (node : 'a node) = node.prev == node - -let peek : 'a. 'a t -> 'a node option = - fun sentinel -> if is_empty sentinel then None else Some sentinel.next - -(* removes head node *) -let pop : 'a. 'a t -> 'a option = - fun sentinel -> - if is_empty sentinel then None - else - let removed_node = sentinel.next in - sentinel.next <- removed_node.next; - removed_node.next.prev <- sentinel; - mark_as_detached removed_node; - removed_node.data - -let remove node : unit = - if not (is_detached node) then ( - node.prev.next <- node.next; - node.next.prev <- node.prev; - mark_as_detached node) diff --git a/submodules/lev/lev-fiber/src/util/removable_queue.mli b/submodules/lev/lev-fiber/src/util/removable_queue.mli deleted file mode 100644 index ab1e76782..000000000 --- a/submodules/lev/lev-fiber/src/util/removable_queue.mli +++ /dev/null @@ -1,15 +0,0 @@ -type 'a t -(** Like a queue, but allows O(1) removal at any position *) - -type 'a node - -val data : 'a node -> 'a -val remove : _ node -> unit -val is_empty : _ t -> bool -val create : unit -> 'a t -val push : 'a t -> 'a -> 'a node -val pop : 'a t -> 'a option -val peek : 'a t -> 'a node option - -val length : 'a t -> int -(** Numbers of elements in the queue. Runs in O(n). *) diff --git a/submodules/lev/lev-fiber/src/util/worker.ml b/submodules/lev/lev-fiber/src/util/worker.ml deleted file mode 100644 index 5123b8f56..000000000 --- a/submodules/lev/lev-fiber/src/util/worker.ml +++ /dev/null @@ -1,27 +0,0 @@ -module Id = Int - -type 'a t = { work_chan : 'a Channel.t; thread : Thread.t } -type task = Channel.elt_in_channel - -let id t = Thread.id t.thread -let join t = Thread.join t.thread - -let rec run work_chan f = - match Channel.get work_chan with - | Error `Closed -> () - | Ok v -> - f v; - run work_chan f - -let create ~spawn_thread ~do_no_raise = - let work_chan = Channel.create () in - let thread = spawn_thread (fun () -> run work_chan do_no_raise) in - { work_chan; thread } - -let add_work t v = - match Channel.send_removable t.work_chan v with - | Error `Closed -> Error `Stopped - | Ok _ as task -> task - -let cancel_if_not_consumed = Channel.remove_if_not_consumed -let complete_tasks_and_stop t = Channel.close t.work_chan diff --git a/submodules/lev/lev-fiber/src/util/worker.mli b/submodules/lev/lev-fiber/src/util/worker.mli deleted file mode 100644 index 12fe90152..000000000 --- a/submodules/lev/lev-fiber/src/util/worker.mli +++ /dev/null @@ -1,30 +0,0 @@ -type 'work t -(** Simple queue that is consumed by its own thread *) - -val create : - spawn_thread:((unit -> unit) -> Thread.t) -> do_no_raise:('a -> unit) -> 'a t -(** [create ~spawn_thread ~do_no_raise] creates a worker with a task handler - [do_no_raise]. The worker will not handle an exception raised by the task - handler, so [do_no_raise] is expected to not raise. [spawn_thread] is used - to launch the thread doing the work *) - -type task - -val cancel_if_not_consumed : task -> unit -(** Cancels the task in the queue if it hasn't already been consumed by the - thread. Does nothing if the task has been consumed already. *) - -val add_work : 'a t -> 'a -> (task, [ `Stopped ]) result - -module Id : sig - type t - - val equal : t -> t -> bool -end - -val id : _ t -> Id.t -val join : _ t -> unit - -val complete_tasks_and_stop : _ t -> unit -(** Signals the worker to complete tasks currently available in the queue and - stop. *) diff --git a/submodules/lev/lev-fiber/test/basic.ml b/submodules/lev/lev-fiber/test/basic.ml deleted file mode 100644 index 5b7630854..000000000 --- a/submodules/lev/lev-fiber/test/basic.ml +++ /dev/null @@ -1,46 +0,0 @@ -let () = Printexc.record_backtrace false - -let%expect_test "toplevel exception" = - (match - Lev_fiber.run @@ fun () -> - print_endline "raising Exit"; - let _ = raise Exit in - Fiber.return () - with - | Error Deadlock | Ok () -> assert false - | Error Already_reported -> print_endline "raised Exit" - | Error (Aborted _) -> assert false); - [%expect - {| - raising Exit - /----------------------------------------------------------------------- - | Internal error: Uncaught exception. - | Stdlib.Exit - \----------------------------------------------------------------------- - - raised Exit |}] - -let%expect_test "" = - (match - Lev_fiber.run @@ fun () -> - Fiber.fork_and_join_unit - (fun () -> - print_endline "t1: raising"; - raise Exit) - (fun () -> - print_endline "t2: running"; - Fiber.return ()) - with - | Error Deadlock | Ok () -> assert false - | Error Already_reported -> print_endline "raised Exit" - | Error (Aborted _) -> assert false); - [%expect - {| - t1: raising - /----------------------------------------------------------------------- - | Internal error: Uncaught exception. - | Stdlib.Exit - \----------------------------------------------------------------------- - - t2: running - raised Exit |}] diff --git a/submodules/lev/lev-fiber/test/dune b/submodules/lev/lev-fiber/test/dune deleted file mode 100644 index 441635ffc..000000000 --- a/submodules/lev/lev-fiber/test/dune +++ /dev/null @@ -1,19 +0,0 @@ -(library - (name lev_fiber_tests) - (libraries - fiber - lev - lev_fiber - stdune - unix - threads.posix - ;; This is because of the (implicit_transitive_deps false) - ;; in dune-project - ppx_expect.config - ppx_expect.config_types - ppx_expect - base - ppx_inline_test.config) - (inline_tests) - (preprocess - (pps ppx_expect))) diff --git a/submodules/lev/lev-fiber/test/lev_fiber_threads.ml b/submodules/lev/lev-fiber/test/lev_fiber_threads.ml deleted file mode 100644 index 8ddffeaf2..000000000 --- a/submodules/lev/lev-fiber/test/lev_fiber_threads.ml +++ /dev/null @@ -1,65 +0,0 @@ -open Stdune -open Fiber.O - -let thread_yield () = Thread.yield () - -open Lev_fiber - -let%expect_test "create thread" = - let f () = - let* thread = Thread.create () in - let task = - match Thread.task thread ~f:(fun () -> print_endline "in thread") with - | Ok s -> s - | Error _ -> assert false - in - let+ result = Thread.await task in - match result with Error _ -> assert false | Ok () -> Thread.close thread - in - run f |> Error.ok_exn; - [%expect {| in thread |}] - -let%expect_test "cancellation" = - let f () = - let* thread = Thread.create () in - let keep_running = Atomic.make false in - let task = - match - Thread.task thread ~f:(fun () -> - while Atomic.get keep_running do - thread_yield () - done) - with - | Ok s -> s - | Error _ -> assert false - in - let to_cancel = - match Thread.task thread ~f:(fun () -> assert false) with - | Ok task -> task - | Error _ -> assert false - in - let* () = Thread.cancel to_cancel in - let* res = Thread.await to_cancel in - (match res with - | Error `Cancelled -> - printfn "Successful cancellation"; - Atomic.set keep_running false - | Ok _ | Error (`Exn _) -> assert false); - let+ res = Thread.await task in - (match res with Ok () -> () | Error _ -> assert false); - Thread.close thread - in - run f |> Error.ok_exn; - [%expect {| Successful cancellation |}] - -let%expect_test "deadlock" = - let f () = - let+ _ = Fiber.never in - () - in - try - run f |> Error.ok_exn; - assert false - with Code_error.E e -> - print_endline e.message; - [%expect {| Deadlock |}] diff --git a/submodules/lev/lev-fiber/test/lev_fiber_threads.mli b/submodules/lev/lev-fiber/test/lev_fiber_threads.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/submodules/lev/lev-fiber/test/process.ml b/submodules/lev/lev-fiber/test/process.ml deleted file mode 100644 index 9d30ac9f1..000000000 --- a/submodules/lev/lev-fiber/test/process.ml +++ /dev/null @@ -1,18 +0,0 @@ -open Stdune -open Fiber.O - -let%expect_test "wait for simple process" = - let stdin, stdin_w = Unix.pipe () in - let stdout_r, stdout = Unix.pipe () in - let stderr_r, stderr = Unix.pipe () in - Unix.close stdin_w; - Unix.close stdout_r; - Unix.close stderr_r; - Lev_fiber.run (fun () -> - let pid = Unix.create_process "true" [| "true" |] stdin stdout stderr in - let+ status = Lev_fiber.waitpid ~pid in - match status with - | WEXITED n -> printfn "status: %d" n - | _ -> assert false) - |> Lev_fiber.Error.ok_exn; - [%expect {| status: 0 |}] diff --git a/submodules/lev/lev-fiber/test/reader_writer.ml b/submodules/lev/lev-fiber/test/reader_writer.ml deleted file mode 100644 index 091f7ab14..000000000 --- a/submodules/lev/lev-fiber/test/reader_writer.ml +++ /dev/null @@ -1,223 +0,0 @@ -open! Stdune -open Fiber.O -open Lev_fiber - -let%expect_test "pipe" = - let run () = - let* input, output = Io.pipe ~cloexec:true () in - let write () = - let+ () = - Io.with_write output ~f:(fun writer -> - Io.Writer.add_string writer "foobar"; - Io.Writer.flush writer) - in - Io.close output; - printfn "writer: finished" - in - let read () = - let+ contents = Io.with_read input ~f:Io.Reader.to_string in - printfn "read: %S" contents; - Io.close input - in - Fiber.fork_and_join_unit read write - in - let print_errors f () = - Fiber.with_error_handler - ~on_error:(fun exn -> - Format.eprintf "%a@." Exn_with_backtrace.pp_uncaught exn; - Exn_with_backtrace.reraise exn) - f - in - Lev_fiber.run (print_errors run) |> Lev_fiber.Error.ok_exn; - [%expect {| - writer: finished - read: "foobar" |}] - -let%expect_test "write with resize" = - let run () = - let* input, output = Io.pipe ~cloexec:true () in - let len = 6120 in - let write () = - let+ () = - Io.with_write output ~f:(fun writer -> - Io.Writer.add_string writer (String.make len '1'); - Io.Writer.flush writer) - in - Io.close output; - printfn "writer: finished" - in - let read () = - let+ contents = Io.with_read input ~f:Io.Reader.to_string in - let len' = String.length contents in - printfn "read: %d length" len'; - assert (len = len'); - Io.close input - in - Fiber.fork_and_join_unit read write - in - let print_errors f () = - Fiber.with_error_handler - ~on_error:(fun exn -> - Format.eprintf "%a@." Exn_with_backtrace.pp_uncaught exn; - Exn_with_backtrace.reraise exn) - f - in - print_errors run |> Lev_fiber.run |> Lev_fiber.Error.ok_exn; - [%expect {| - writer: finished - read: 6120 length |}] - -let%expect_test "blocking pipe" = - let fdr, fdw = Unix.pipe ~cloexec:true () in - let run () = - let* r = Io.create (Fd.create fdr `Blocking) Input in - let* w = Io.create (Fd.create fdw `Blocking) Output in - let writer () = - let+ () = - Io.with_write w ~f:(fun writer -> - Io.Writer.add_string writer "foo bar baz"; - Io.Writer.flush writer) - in - printfn "writer: finished"; - Io.close w - in - let reader () = - let+ read = Io.with_read r ~f:Io.Reader.to_string in - printfn "read: %S" read; - Io.close r - in - Fiber.fork_and_join_unit reader writer - in - Lev_fiber.run run |> Lev_fiber.Error.ok_exn; - [%expect {| - writer: finished - read: "foo bar baz" |}] - -let with_pipe_test output f = - let run () = - let* ic, oc = Io.pipe ~cloexec:true () in - let writer () = - let+ () = - Io.with_write oc ~f:(fun writer -> - let len_output = String.length output in - let rec loop pos = - if pos = len_output then Fiber.return () - else - let available = Io.Writer.Expert.available writer in - if available = 0 then - let* () = Io.Writer.flush writer in - loop pos - else - let len = min available (len_output - pos) in - Io.Writer.add_substring writer output ~pos ~len; - loop (pos + len) - in - let* () = loop 0 in - Io.Writer.flush writer) - in - Io.close oc - in - Fiber.fork_and_join_unit - (fun () -> - let+ () = f ic in - Io.close ic) - writer - in - Lev_fiber.run run - -let%expect_test "read lines" = - with_pipe_test "foo\nbar\r\n\nbaz\r\r\neof" (fun r -> - Io.with_read r - ~f: - (let rec loop reader = - let* res = Io.Reader.read_line reader in - match res with - | Ok line -> - printfn "line: %S" line; - loop reader - | Error (`Partial_eof s) -> - printfn "eof: %S" s; - Fiber.return () - in - loop)) - |> Lev_fiber.Error.ok_exn; - [%expect - {| - line: "foo" - line: "bar" - line: "" - line: "baz\r" - eof: "eof" |}] - -let%expect_test "read exactly - sufficient" = - let len = 6 in - with_pipe_test "foobarbaz" (fun r -> - Io.with_read r ~f:(fun reader -> - let+ res = Io.Reader.read_exactly reader len in - match res with - | Error (`Partial_eof s) -> printfn "eof: %S" s - | Ok s -> - assert (String.length s = len); - printfn "success: %S\n" s)) - |> Lev_fiber.Error.ok_exn; - [%expect {| success: "foobar" |}] - -let%expect_test "read exactly - insufficient" = - let str = "foobarbaz" in - let len = String.length str + 10 in - with_pipe_test str (fun r -> - Io.with_read r ~f:(fun reader -> - let+ res = Io.Reader.read_exactly reader len in - match res with - | Error (`Partial_eof s) -> printfn "eof: %S" s - | Ok s -> - assert (String.length s = len); - printfn "success: %S\n" s)) - |> Lev_fiber.Error.ok_exn; - [%expect {| eof: "foobarbaz" |}] - -let%expect_test "reading from closed pipe" = - let r, w = Unix.pipe () in - ( Lev_fiber.run @@ fun () -> - let* io = Io.create (Fd.create r `Blocking) Input in - let close () = - let+ () = Timer.sleepf 0.3 in - Unix.close w - in - let read () = - let+ contents = Io.with_read io ~f:Io.Reader.to_string in - printfn "contents: %S" contents; - Io.close io - in - Fiber.fork_and_join_unit close read ) - |> Lev_fiber.Error.ok_exn; - [%expect {| contents: "" |}] - -let%expect_test "writing to a closed pipe" = - let r, w = Unix.pipe () in - Unix.close r; - ( Lev_fiber.run ~sigpipe:`Ignore @@ fun () -> - let* io = Io.create (Fd.create w `Blocking) Output in - print_endline "writing to closed pipe"; - let+ res = - let on_error (exn : Exn_with_backtrace.t) = - match exn.exn with - | Code_error.E e -> - printfn "error: %s" @@ Dyn.to_string - @@ Code_error.to_dyn_without_loc e; - Fiber.return () - | _ -> Exn_with_backtrace.reraise exn - in - Fiber.map_reduce_errors (module Monoid.Unit) ~on_error @@ fun () -> - Io.with_write io ~f:(fun w -> - Io.Writer.add_string w "foobar"; - Io.Writer.flush w) - in - (match res with Error () -> () | Ok () -> assert false); - print_endline "finished writing" ) - |> Lev_fiber.Error.ok_exn; - [%expect{| - writing to closed pipe - error: ("fd closed unflushed", { remaining = 6; contents = "foobar\n\ - " }) - finished writing |}] diff --git a/submodules/lev/lev-fiber/test/reader_writer.mli b/submodules/lev/lev-fiber/test/reader_writer.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/submodules/lev/lev-fiber/test/sockets.ml b/submodules/lev/lev-fiber/test/sockets.ml deleted file mode 100644 index 2d287f8d4..000000000 --- a/submodules/lev/lev-fiber/test/sockets.ml +++ /dev/null @@ -1,76 +0,0 @@ -open! Stdune -open Fiber.O -open Lev_fiber - -let%expect_test "server & client" = - let path = "levfiber.sock" in - (try Unix.unlink path with Unix.Unix_error _ -> ()); - let server_sockaddr = - if Sys.win32 then Unix.ADDR_INET (Unix.inet_addr_loopback, 0) - else Unix.ADDR_UNIX path - in - let domain = Unix.domain_of_sockaddr server_sockaddr in - let socket () = - Lev_fiber.Fd.create - (Unix.socket ~cloexec:true domain Unix.SOCK_STREAM 0) - (`Non_blocking false) - in - let client_sockaddr = Fiber.Ivar.create () in - let run () = - let ready_client = Fiber.Ivar.create () in - let server () = - print_endline "server: starting"; - let fd = socket () in - let unix_fd = Lev_fiber.Fd.fd_exn fd in - Unix.setsockopt unix_fd Unix.SO_REUSEADDR true; - let* server = Socket.Server.create fd server_sockaddr ~backlog:10 in - let* () = Fiber.Ivar.fill client_sockaddr (Unix.getsockname unix_fd) in - print_endline "server: created"; - let* () = Fiber.Ivar.fill ready_client () in - print_endline "server: serving"; - Socket.Server.serve server ~f:(fun session -> - let* i, o = Socket.Server.Session.io session in - print_endline "server: client connected"; - let* contents = Io.with_read i ~f:Io.Reader.to_string in - printfn "server: received %S" contents; - let* () = - Io.with_write o ~f:(fun w -> - Io.Writer.add_string w "pong"; - Io.Writer.flush w) - in - Io.close o; - Io.close i; - Socket.Server.close server) - in - let client () = - let* () = Fiber.Ivar.read ready_client in - let fd = socket () in - print_endline "client: starting"; - let* sockaddr = Fiber.Ivar.read client_sockaddr in - let* () = Socket.connect fd sockaddr in - print_endline "client: successfully connected"; - let* i, o = Io.create_rw fd in - let* () = - Io.with_write o ~f:(fun w -> - Io.Writer.add_string w "ping"; - Io.Writer.flush w) - in - Unix.shutdown (Lev_fiber.Fd.fd_exn fd) SHUTDOWN_SEND; - let+ result = Io.with_read i ~f:Io.Reader.to_string in - printfn "client: received %S" result; - Io.close o; - Io.close i - in - Fiber.fork_and_join_unit client server - in - Lev_fiber.run run |> Lev_fiber.Error.ok_exn; - [%expect - {| - server: starting - server: created - server: serving - client: starting - client: successfully connected - server: client connected - server: received "ping" - client: received "pong" |}] diff --git a/submodules/lev/lev-fiber/test/sockets.mli b/submodules/lev/lev-fiber/test/sockets.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/submodules/lev/lev-fiber/test/timers.ml b/submodules/lev/lev-fiber/test/timers.ml deleted file mode 100644 index f8c83afd9..000000000 --- a/submodules/lev/lev-fiber/test/timers.ml +++ /dev/null @@ -1,121 +0,0 @@ -open Stdune -open Fiber.O -module Timer = Lev_fiber.Timer -module Wheel = Timer.Wheel - -let%expect_test "sleep" = - Lev_fiber.run (fun () -> - print_endline "sleep"; - let+ () = Lev_fiber.Timer.sleepf 0.1 in - print_endline "awake") - |> Lev_fiber.Error.ok_exn; - [%expect {| - sleep - awake |}] - -let%expect_test "timer wheel start/stop" = - Lev_fiber.run (fun () -> - let* wheel = Wheel.create ~delay:10. in - Fiber.fork_and_join_unit - (fun () -> - print_endline "wheel: run"; - Wheel.run wheel) - (fun () -> - print_endline "wheel: stop"; - Wheel.stop wheel)) - |> Lev_fiber.Error.ok_exn; - [%expect {| - wheel: run - wheel: stop |}] - -let%expect_test "timer wheel cancellation" = - Lev_fiber.run (fun () -> - let* wheel = Wheel.create ~delay:10. in - Fiber.fork_and_join_unit - (fun () -> - let* task = Wheel.task wheel in - let* () = Wheel.cancel task in - let* result = Wheel.await task in - match result with - | `Ok -> assert false - | `Cancelled -> - print_endline "cancellation succeeded"; - Wheel.stop wheel) - (fun () -> - print_endline "wheel: stop"; - Wheel.run wheel)) - |> Lev_fiber.Error.ok_exn; - [%expect {| - cancellation succeeded - wheel: stop |}] - -let%expect_test "wheel - stopping with running timers" = - Lev_fiber.run (fun () -> - let* wheel = Wheel.create ~delay:1.0 in - Fiber.fork_and_join_unit - (fun () -> - print_endline "wheel: run"; - Wheel.run wheel) - (fun () -> - printfn "creating a task"; - let* task = Wheel.task wheel in - printfn "stopping the wheel"; - let* () = Wheel.stop wheel in - let+ res = Wheel.await task in - match res with - | `Ok -> assert false - | `Cancelled -> printfn "timer cancelled")) - |> Lev_fiber.Error.ok_exn; - [%expect - {| - wheel: run - creating a task - stopping the wheel - timer cancelled |}] - -let%expect_test "wheel - reset" = - Lev_fiber.run (fun () -> - let delay = 0.1 in - let* wheel = Wheel.create ~delay in - let* task = Wheel.task wheel in - let test () = - Fiber.fork_and_join_unit - (fun () -> - let* () = Lev_fiber.yield () in - printfn "cancelling task"; - Wheel.cancel task) - (fun () -> - let* res = Wheel.await task in - (match res with - | `Cancelled -> printfn "cancelled" - | `Ok -> assert false); - let* () = Wheel.reset task in - let* res = Wheel.await task in - (match res with - | `Cancelled -> assert false - | `Ok -> printfn "success after reset"); - Wheel.stop wheel) - in - Fiber.fork_and_join_unit (fun () -> Wheel.run wheel) test) - |> Lev_fiber.Error.ok_exn; - [%expect {| - cancelling task - cancelled - success after reset |}] - -let%expect_test "wheel - set_delay" = - Lev_fiber.run (fun () -> - let* wheel = Wheel.create ~delay:200. in - let* task = Wheel.task wheel in - let test () = - let* () = Wheel.set_delay wheel ~delay:0. in - let* res = Wheel.await task in - match res with - | `Cancelled -> assert false - | `Ok -> - printfn "immediately finished after delay"; - Wheel.stop wheel - in - Fiber.fork_and_join_unit (fun () -> Wheel.run wheel) test) - |> Lev_fiber.Error.ok_exn; - [%expect {| immediately finished after delay |}] diff --git a/submodules/lev/lev-fiber/test/timers.mli b/submodules/lev/lev-fiber/test/timers.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/submodules/lev/lev-fiber/test/util/bip_buffer_tests.ml b/submodules/lev/lev-fiber/test/util/bip_buffer_tests.ml deleted file mode 100644 index a4156ce2e..000000000 --- a/submodules/lev/lev-fiber/test/util/bip_buffer_tests.ml +++ /dev/null @@ -1,180 +0,0 @@ -open Stdune -module Bytes = BytesLabels -open Lev_fiber_util -module B = Bip_buffer - -let%expect_test "is_empty" = - let len = 100 in - assert (B.is_empty (B.create (Bytes.create len) ~len)); - [%expect {||}] - -let%expect_test "read empty" = - let b = B.create (Bytes.create 0) ~len:1 in - assert (B.peek b = None); - [%expect {||}] - -let peek_str b ~len = - match B.peek b with - | None -> assert false - | Some s -> - assert (s.len >= len); - printfn "Requested %d. Available %d" len s.len; - let get len = - let dst = Bytes.create len in - let src = B.buffer b in - Bytes.blit ~dst ~dst_pos:0 ~src ~src_pos:s.pos ~len; - Bytes.to_string dst - in - let peek = get len in - if len = s.len then printfn "Peek: %S" peek - else printfn "Peek: %S (full: %S)" peek (get s.len); - peek - -let print b = - let pp_slice fmt (b, { B.Slice.pos; len }) = - Format.fprintf fmt "%S" (Bytes.sub_string b ~pos ~len) - in - Format.printf "%a@." (B.pp pp_slice) b - -let write_str b src = - let len = String.length src in - match B.reserve b ~len with - | None -> assert false - | Some dst_pos -> - let dst = B.buffer b in - Bytes.blit_string ~dst ~dst_pos ~src ~src_pos:0 ~len; - B.commit b ~len - -let%expect_test "bip buffers" = - let buf_size = 16 in - let b = B.create (Bytes.create buf_size) ~len:buf_size in - assert (B.is_empty b); - [%expect {| |}]; - let () = - let mystr = "Test Foo|Bar" in - let mystr_len = String.length mystr in - write_str b mystr; - assert (B.length b = mystr_len) - in - [%expect {| |}]; - (* Now we try to read 4 characters *) - let () = - let read_len = 8 in - print b; - B.junk b ~len:read_len - in - [%expect {| - "Test Foo|Bar" |}]; - print b; - [%expect {| - "|Bar" |}] - -let%expect_test "fill buffer" = - let str = "foo bar baz foo" in - let len = String.length str in - let b = B.create (Bytes.create len) ~len in - write_str b str; - let str' = peek_str b ~len in - assert (String.equal str str'); - [%expect {| - Requested 15. Available 15 - Peek: "foo bar baz foo" |}] - -let%expect_test "reserve overflow" = - let buf_size = 16 in - let b = B.create (Bytes.create buf_size) ~len:buf_size in - let len = 17 in - (match B.reserve b ~len with None -> () | Some _ -> assert false); - [%expect {||}] - -let%expect_test "unused space" = - let buf_size = 16 in - let half = buf_size / 2 in - let b = B.create (Bytes.create buf_size) ~len:buf_size in - let unused = B.unused_space b in - printfn "unused space: %d" unused; - [%expect {| - unused space: 16 |}]; - assert (unused = buf_size); - write_str b (String.make half 'a'); - assert (B.unused_space b = half); - write_str b (String.make (pred half) 'b'); - B.junk b ~len:half; - let unused = B.unused_space b in - printfn "unused space: %d" unused; - assert (unused = 9); - [%expect {| - unused space: 9 |}]; - let b = B.create (Bytes.create buf_size) ~len:buf_size in - write_str b (String.make half 'a'); - assert (B.length b = half); - B.junk b ~len:1; - assert (B.length b = pred half); - let unused = B.unused_space b in - printfn "unused space: %d" unused; - assert (unused = 9); - [%expect {| unused space: 9 |}] - -let blit ~src ~src_pos ~dst ~dst_pos ~len = - Bytes.blit ~src ~src_pos ~dst ~dst_pos ~len - -let%expect_test "resize" = - let buf_size = 16 in - let b = B.create (Bytes.make buf_size '0') ~len:buf_size in - write_str b "00000"; - print b; - [%expect {| - "00000" |}]; - B.resize b blit (Bytes.make (buf_size * 2) '1') ~len:(buf_size * 2); - print b; - [%expect {| - "00000" |}] - -let%expect_test "compression - a only" = - let buf_size = 8 in - let b = B.create (Bytes.make buf_size '0') ~len:buf_size in - write_str b "00000"; - B.junk b ~len:2; - printfn "available: %d" (B.max_available b); - [%expect {| available: 3 |}]; - B.compress b blit; - print b; - [%expect {| - "000" |}]; - printfn "available: %d" (B.max_available b); - [%expect {| - available: 5 |}] - -let%expect_test "compression - a & b" = - let buf_size = 8 in - let b = B.create (Bytes.make buf_size '0') ~len:buf_size in - write_str b (String.make 7 '1'); - B.junk b ~len:6; - print b; - [%expect {| "1" |}]; - write_str b (String.make 3 '2'); - print b; - [%expect {| "1""222" |}]; - printfn "available: %d" (B.max_available b); - [%expect {| available: 3 |}]; - B.compress b blit; - printfn "available: %d" (B.max_available b); - [%expect {| available: 4 |}]; - print b; - [%expect {| "1222" |}] - -let%expect_test "reserve and commit b" = - let buf_size = 8 in - let b = B.create (Bytes.make buf_size '0') ~len:buf_size in - write_str b (String.make 4 '1'); - write_str b (String.make 2 '1'); - assert (B.reserve b ~len:4 = None); - B.junk b ~len:4; - print b; - [%expect {| "11" |}]; - write_str b (String.make 3 '2'); - print b; - [%expect {| "11""222" |}]; - write_str b (String.make 1 '3'); - print b; - [%expect {| "11""2223" |}] diff --git a/submodules/lev/lev-fiber/test/util/bip_buffer_tests.mli b/submodules/lev/lev-fiber/test/util/bip_buffer_tests.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/submodules/lev/lev-fiber/test/util/channel_tests.ml b/submodules/lev/lev-fiber/test/util/channel_tests.ml deleted file mode 100644 index 28a0c2ea4..000000000 --- a/submodules/lev/lev-fiber/test/util/channel_tests.ml +++ /dev/null @@ -1,62 +0,0 @@ -module Channel = Lev_fiber_util.Channel - -let%expect_test "send/recv 0, 1 in concurrent threads; then close the channel" = - let ch = Channel.create () in - let th0 = - Thread.create - (fun () -> - for _ = 0 to 1 do - match Channel.get ch with - | Ok i -> Printf.printf "%d\n" i - | Error `Closed -> assert false - done; - match Channel.get ch with - | Ok _ -> assert false - | Error `Closed -> print_endline "closed") - () - in - let send_or_fail v = - match Channel.send ch v with Ok () -> () | Error `Closed -> assert false - in - let th1 = - Thread.create - (fun () -> - send_or_fail 0; - send_or_fail 1; - Channel.close ch) - () - in - Thread.join th0; - Thread.join th1; - [%expect {| - 0 - 1 - closed |}] - -let%expect_test "send 0, 1, 2, but remove 1" = - let ch = Channel.create () in - let print_int i = Printf.printf "%d\n" i in - let th0 = - Thread.create - (fun () -> - let v0 = Channel.get ch in - print_int @@ Result.get_ok v0; - Unix.sleepf 0.01; - let v1 = Channel.get ch in - print_int @@ Result.get_ok v1) - () - in - let th1 = - Thread.create - (fun () -> - ignore @@ Channel.send ch 0; - let removable = Channel.send_removable ch 1 in - Channel.remove_if_not_consumed @@ Result.get_ok removable; - Channel.send ch 2) - () - in - Thread.join th0; - Thread.join th1; - [%expect {| - 0 - 2 |}] diff --git a/submodules/lev/lev-fiber/test/util/channel_tests.mli b/submodules/lev/lev-fiber/test/util/channel_tests.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/submodules/lev/lev-fiber/test/util/dune b/submodules/lev/lev-fiber/test/util/dune deleted file mode 100644 index 2929abb75..000000000 --- a/submodules/lev/lev-fiber/test/util/dune +++ /dev/null @@ -1,17 +0,0 @@ -(library - (name lev_fiber_util_tests) - (libraries - lev_fiber_util - stdune - unix - threads.posix - ;; This is because of the (implicit_transitive_deps false) - ;; in dune-project - ppx_expect.config - ppx_expect.config_types - ppx_expect - base - ppx_inline_test.config) - (inline_tests) - (preprocess - (pps ppx_expect))) diff --git a/submodules/lev/lev-fiber/test/util/removable_queue_tests.ml b/submodules/lev/lev-fiber/test/util/removable_queue_tests.ml deleted file mode 100644 index 0893d99e0..000000000 --- a/submodules/lev/lev-fiber/test/util/removable_queue_tests.ml +++ /dev/null @@ -1,77 +0,0 @@ -open Stdune -open Lev_fiber_util -module Q = Removable_queue - -let printf = Printf.printf - -let print_all q f = - while not (Q.is_empty q) do - let elem = Option.value_exn (Q.pop q) in - printf "elem: %s\n" (f elem) - done - -let add_all q xs = List.iter xs ~f:(fun x -> ignore (Q.push q x)) - -let%expect_test "create is empty" = - let q = Q.create () in - printf "new queue is empty: %b" (Q.is_empty q); - [%expect {| new queue is empty: true |}] - -let%expect_test "pushing adds an element" = - let q = Q.create () in - let (_ : int Q.node) = Q.push q 100 in - printf "empty: %b\n" (Q.is_empty q); - [%expect {| empty: false |}] - -let%expect_test "remove works with a 1 element queue" = - let q = Q.create () in - let node = Q.push q 100 in - printf "empty: %b\n" (Q.is_empty q); - Q.remove node; - printf "empty: %b\n" (Q.is_empty q); - [%expect {| - empty: false - empty: true |}] - -let%expect_test "remove works with a 1 element queue" = - let q = Q.create () in - let (_ : int Q.node) = Q.push q 100 in - printf "empty: %b\n" (Q.is_empty q); - print_all q Int.to_string; - printf "empty: %b\n" (Q.is_empty q); - [%expect {| - empty: false - elem: 100 - empty: true |}] - -let%expect_test "deque all" = - let q = Q.create () in - add_all q [ 1; 2; 3 ]; - print_all q Int.to_string; - [%expect {| - elem: 1 - elem: 2 - elem: 3 |}] - -let%expect_test "remove in the middle" = - let q = Q.create () in - add_all q [ 100; 200 ]; - let elem = Q.push q 300 in - add_all q [ 400 ]; - Q.remove elem; - print_all q Int.to_string; - [%expect {| - elem: 100 - elem: 200 - elem: 400 |}] - -let%expect_test "push; push; remove; push -- head & tail are set correctly" = - let q = Q.create () in - ignore @@ Q.push q 0; - let n = Q.push q 1 in - Q.remove n; - ignore @@ Q.push q 2; - print_all q Int.to_string; - [%expect {| - elem: 0 - elem: 2 |}] diff --git a/submodules/lev/lev-fiber/test/util/removable_queue_tests.mli b/submodules/lev/lev-fiber/test/util/removable_queue_tests.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/submodules/lev/lev.opam b/submodules/lev/lev.opam deleted file mode 100644 index 01a5886a6..000000000 --- a/submodules/lev/lev.opam +++ /dev/null @@ -1,33 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -synopsis: "Bindings to libev" -description: "Low level bindings to libev" -maintainer: ["Rudi Grinberg "] -authors: [ - "Rudi Grinberg " - "Ulugbek Abdullaev " -] -license: "ISC" -homepage: "https://github.com/rgrinberg/lev" -bug-reports: "https://github.com/rgrinberg/lev/issues" -depends: [ - "dune" {>= "3.0"} - "ppx_expect" {with-test} - "base-unix" - "odoc" {with-doc} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] -dev-repo: "git+https://github.com/rgrinberg/lev.git" diff --git a/submodules/lev/lev/bench/dune b/submodules/lev/lev/bench/dune deleted file mode 100644 index 8b14ca50f..000000000 --- a/submodules/lev/lev/bench/dune +++ /dev/null @@ -1,3 +0,0 @@ -(executable - (name ping_pong) - (libraries lev unix)) diff --git a/submodules/lev/lev/bench/ping_pong.ml b/submodules/lev/lev/bench/ping_pong.ml deleted file mode 100644 index 565526df1..000000000 --- a/submodules/lev/lev/bench/ping_pong.ml +++ /dev/null @@ -1,78 +0,0 @@ -(* Benchmark with: - {[ - $ SOCK=/tmp/sock - $ dune exec -- bench/ping_pong.exe $SOCK - $ redis-benchmark -s $SOCK -t ping -n 100000 -P 1 - ]} -*) -open Lev - -let client_events = Io.Event.Set.create ~read:true ~write:true () -let response = Bytes.of_string "+PONG\r\n" - -type client = { - mutable writeable : bool; - mutable pending_responses : int; - buf : Bytes.t; -} - -let new_client buf = { writeable = false; pending_responses = 0; buf } - -let server socket = - let loop = Loop.default () in - let buf = Bytes.create 1024 in - let cleanup io loop fd = - Unix.close fd; - Io.stop io loop - in - let client_loop client io fd events = - if Io.Event.Set.mem events Write then client.writeable <- true; - (if Io.Event.Set.mem events Read then - match Unix.read fd client.buf 0 (Bytes.length client.buf) with - | exception Unix.Unix_error (Unix.EAGAIN, _, _) -> () - | exception _ -> Io.stop io loop - | 0 -> cleanup io loop fd - | read -> - for i = 0 to read - 1 do - if Bytes.get client.buf i = '\n' then - client.pending_responses <- client.pending_responses + 1 - done); - if client.writeable then - let () = client.writeable <- client.pending_responses = 0 in - try - (* we don't bother buffering writes for this benchmark *) - while client.pending_responses > 0 do - let len = Bytes.length response in - assert (Unix.write fd response 0 len = len); - client.pending_responses <- client.pending_responses - 1 - done - with - | Unix.Unix_error (Unix.EAGAIN, _, _) -> () - | _ -> cleanup io loop fd - in - let accept = - Io.create - (fun _io fd _ -> - let client, _ = Unix.accept ~cloexec:true fd in - Unix.set_nonblock client; - let io = - Io.create (client_loop (new_client buf)) client client_events - in - Io.start io loop) - socket - (Io.Event.Set.create ~read:true ()) - in - Io.start accept loop; - Loop.run_until_done loop - -let run sock_path = - let delete () = try Unix.unlink sock_path with Unix.Unix_error _ -> () in - delete (); - let socket = Unix.socket ~cloexec:true Unix.PF_UNIX Unix.SOCK_STREAM 0 in - Unix.set_nonblock socket; - Unix.bind socket (Unix.ADDR_UNIX sock_path); - at_exit delete; - Unix.listen socket 128; - server socket - -let () = run Sys.argv.(1) diff --git a/submodules/lev/lev/bench/ping_pong.mli b/submodules/lev/lev/bench/ping_pong.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/submodules/lev/lev/dune b/submodules/lev/lev/dune deleted file mode 100644 index 94865487d..000000000 --- a/submodules/lev/lev/dune +++ /dev/null @@ -1 +0,0 @@ -(vendored_dirs vendor) diff --git a/submodules/lev/lev/examples/dune b/submodules/lev/lev/examples/dune deleted file mode 100644 index 7b54f115a..000000000 --- a/submodules/lev/lev/examples/dune +++ /dev/null @@ -1,3 +0,0 @@ -(executables - (names readme) - (libraries lev unix)) diff --git a/submodules/lev/lev/examples/readme.ml b/submodules/lev/lev/examples/readme.ml deleted file mode 100644 index 8ead3fc98..000000000 --- a/submodules/lev/lev/examples/readme.ml +++ /dev/null @@ -1,28 +0,0 @@ -open Lev - -let () = - let loop = Loop.default () in - let stdin, stdin_w = Unix.pipe ~cloexec:true () in - let stdout_r, stdout = Unix.pipe ~cloexec:true () in - let stderr_r, stderr = Unix.pipe ~cloexec:true () in - Unix.close stdin_w; - Unix.close stdout_r; - Unix.close stderr_r; - let pid = - Unix.create_process "sh" [| "sh"; "-c"; "exit 42" |] stdin stdout stderr - in - let child = - match Child.create with - | Error `Unimplemented -> assert false - | Ok create -> - create - (fun t ~pid status -> - Child.stop t loop; - match status with - | Unix.WEXITED i -> Printf.printf "%d exited with status %d\n" pid i - | _ -> assert false) - (Pid pid) Terminate - in - Child.start child loop; - Loop.run_until_done loop; - Child.destroy child diff --git a/submodules/lev/lev/src/LICENSE.md b/submodules/lev/lev/src/LICENSE.md deleted file mode 100644 index ad43e3143..000000000 --- a/submodules/lev/lev/src/LICENSE.md +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021 Rudi Grinberg - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. diff --git a/submodules/lev/lev/src/config.h b/submodules/lev/lev/src/config.h deleted file mode 100644 index 6d75422b7..000000000 --- a/submodules/lev/lev/src/config.h +++ /dev/null @@ -1,75 +0,0 @@ -// TODO port support - -#define EV_MULTIPLICITY 1 - -#ifdef _MSC_VER -#define HAVE_SYS_SELECT_H 1 -#define HAVE_SELECT 1 -#else /* _MSC_VER */ - -#if __has_include() -#define HAVE_SYS_INOTIFY_H 1 -#endif - -#ifdef _WIN32 -#define HAVE_SYS_SELECT_H 1 -#define HAVE_SELECT 1 -#endif - -#if __has_include() -#define HAVE_SYS_SELECT_H 1 -#define HAVE_SELECT 1 -#endif - -#if __has_include() -#define HAVE_POLL_H 1 -#define HAVE_POLL 1 -#endif - -#if __has_include() -#define HAVE_SYS_EPOLL_H 1 -#define HAVE_EPOLL 1 -#define HAVE_EPOLL_CTL 1 -#endif - -#if __has_include() -#define HAVE_SYS_TIMERFD_H 1 -#endif - -#if __has_include() -#define HAVE_SYS_SIGNALFD_H 1 -#define HAVE_SIGNALFD_H 1 -#endif - -#if __has_include() -#define HAVE_SYS_SIGNALFD_H 1 -#define HAVE_SIGNALFD_H 1 -#endif - -#if __has_include() -#define HAVE_INOTIFY_INIT 1 -#endif - -#if __has_include() -#define HAVE_LINUX_FS_H 1 -#endif - -#if __has_include() -#define HAVE_AIO_ABI_H 1 -#endif - -#if __has_include() -#define HAVE_SYS_EVENT_H 1 -#endif - -#if HAVE_SYS_EVENT_H && (defined(__APPLE__) || defined(__unix__)) -#define HAVE_KQUEUE 1 -#endif - -#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) -#define HAVE_NANOSLEEP 1 -#endif - -#endif /* _MSC_VER */ - -#define HAVE_FLOOR 1 diff --git a/submodules/lev/lev/src/dune b/submodules/lev/lev/src/dune deleted file mode 100644 index e62d99974..000000000 --- a/submodules/lev/lev/src/dune +++ /dev/null @@ -1,27 +0,0 @@ -(copy_files# ../vendor/*.c) - -(copy_files# ../vendor/{ev,ev_vars,ev_wrap}.h) - -(foreign_library - (archive_name ev) - (extra_deps - ev_kqueue.c - ev_epoll.c - ev_iouring.c - ev_poll.c - ev_port.c - ev_select.c - ev_win32.c) - (language c) - (names ev)) - -(library - (public_name lev) - (synopsis "libev bindings") - (libraries unix) - (foreign_archives ev) - (instrumentation - (backend bisect_ppx)) - (foreign_stubs - (language c) - (names lev_stubs))) diff --git a/submodules/lev/lev/src/lev.ml b/submodules/lev/lev/src/lev.ml deleted file mode 100644 index eb9f2130f..000000000 --- a/submodules/lev/lev/src/lev.ml +++ /dev/null @@ -1,514 +0,0 @@ -module List = ListLabels - -external ev_version : unit -> int * int = "lev_version" - -module Set (Element : sig - type t - - val to_int : t -> int -end) = -struct - type t = int - - let equal = Int.equal - let mem t c = t land Element.to_int c <> 0 - let singleton x : t = Element.to_int x - let empty : t = 0 - let union x y = x lor y - let add x y = union x (singleton y) - let negate x = lnot x - let inter x y = x land y -end - -module Backend = struct - type t = - | Select - | Poll - | Epoll - | Kqueue - | Devpoll - | Port - | Linuxaio - | Iouring - - let all = [ Select; Poll; Epoll; Kqueue; Devpoll; Port; Linuxaio; Iouring ] - - external select : unit -> int = "lev_backend_select" - - let select = select () - - external poll : unit -> int = "lev_backend_poll" - - let poll = poll () - - external epoll : unit -> int = "lev_backend_epoll" - - let epoll = epoll () - - external kqueue : unit -> int = "lev_backend_kqueue" - - let kqueue = kqueue () - - external devpoll : unit -> int = "lev_backend_devpoll" - - let devpoll = devpoll () - - external port : unit -> int = "lev_backend_port" - - let port = port () - - external linuxaio : unit -> int = "lev_backend_linuxaio" - - let linuxaio = linuxaio () - - external iouring : unit -> int = "lev_backend_iouring" - - let iouring = iouring () - - let to_int = function - | Select -> select - | Poll -> poll - | Epoll -> epoll - | Kqueue -> kqueue - | Devpoll -> devpoll - | Port -> port - | Linuxaio -> linuxaio - | Iouring -> iouring - - module Set = struct - include Set (struct - type nonrec t = t - - let to_int = to_int - end) - - let all = List.fold_left ~f:(fun x y -> to_int y lor x) all ~init:0 - end - - external supported : unit -> Set.t = "lev_backend_supported" - external embeddable : unit -> Set.t = "lev_backend_embeddable" - external recommended : unit -> Set.t = "lev_backend_recommended" -end - -module Timestamp = struct - type t = float - - external sleep : t -> unit = "lev_sleep" - - let to_float x = x - let of_float x = x -end - -module Loop = struct - module Flag = struct - type t = - | Backend of Backend.t - | Auto - | Noenv - | Forkcheck - | Noinotify - | Signalfd - | Nosigmask - | Notimerfd - - external auto : unit -> int = "lev_loop_flags_auto" - - let auto = auto () - - external noenv : unit -> int = "lev_loop_flags_noenv" - - let noenv = noenv () - - external forkcheck : unit -> int = "lev_loop_flags_forkcheck" - - let forkcheck = forkcheck () - - external noinotify : unit -> int = "lev_loop_flags_noinotify" - - let noinotify = noinotify () - - external signalfd : unit -> int = "lev_loop_flags_signalfd" - - let signalfd = signalfd () - - external nosigmask : unit -> int = "lev_loop_flags_nosigmask" - - let nosigmask = nosigmask () - - external notimerfd : unit -> int = "lev_loop_flags_notimerfd" - - let notimerfd = notimerfd () - - let to_int = function - | Backend b -> Backend.to_int b - | Auto -> auto - | Noenv -> noenv - | Forkcheck -> forkcheck - | Noinotify -> noinotify - | Signalfd -> signalfd - | Nosigmask -> nosigmask - | Notimerfd -> notimerfd - - module Set = struct - include Set (struct - type nonrec t = t - - let to_int = to_int - end) - - let of_backend_set x = x - end - end - - type t - - let flags = Flag.Set.singleton Auto - - external default : int -> t = "lev_ev_default" - - let default ?(flags = flags) () = default flags - - external create : int -> t = "lev_ev_create" - - let create ?(flags = flags) () = create flags - - external now : t -> Timestamp.t = "lev_ev_now" - external destroy : t -> unit = "lev_loop_destroy" - external now_update : t -> unit = "lev_loop_now_update" - external run : t -> int -> bool = "lev_ev_run" - external is_default : t -> bool = "lev_loop_is_default" - - type run = Once | Nowait - - external once : unit -> int = "lev_loop_run_once" - - let once = once () - - external nowait : unit -> int = "lev_loop_run_nowait" - - let nowait = nowait () - let int_of_run = function Once -> once | Nowait -> nowait - - let run t v = - if run t (int_of_run v) then `Otherwise else `No_more_active_watchers - - let rec run_until_done t = - match run t Once with - | `Otherwise -> run_until_done t - | `No_more_active_watchers -> () - - external depth : t -> int = "lev_loop_depth" - - type break = One | All | Cancel - - external one : unit -> int = "lev_loop_break_one_code" - - let one = one () - - external all : unit -> int = "lev_loop_break_all_code" - - let all = all () - - external cancel : unit -> int = "lev_loop_break_cancel_code" - - let cancel = cancel () - let int_of_break = function One -> one | All -> all | Cancel -> cancel - - external break : t -> int -> unit = "lev_loop_break" - - let break t b = break t (int_of_break b) - - external backend : t -> Backend.Set.t = "lev_loop_backend" - - let backend t = - let b = backend t in - List.find Backend.all ~f:(fun backend -> Backend.Set.mem b backend) - - external suspend : t -> unit = "lev_loop_suspend" - external resume : t -> unit = "lev_loop_resume" - external ref : t -> unit = "lev_loop_ref" - external unref : t -> unit = "lev_loop_unref" - external feed_signal : signal:int -> unit = "lev_feed_signal" - - external feed_signal_event : t -> signal:int -> unit - = "lev_loop_feed_signal_event" -end - -module type Watcher = sig - type t - - val start : t -> Loop.t -> unit - val is_active : t -> bool - val is_pending : t -> bool - val stop : t -> Loop.t -> unit - val destroy : t -> unit -end - -module Watcher (S : sig - type t -end) = -struct - open S - - external is_active : t -> bool = "lev_watcher_is_active" - external is_pending : t -> bool = "lev_watcher_is_pending" - external destroy : t -> unit = "lev_watcher_destroy" -end - -module Io = struct - module Event = struct - type t = Read | Write - - external read : unit -> int = "lev_io_read_code" - - let read = read () - - external write : unit -> int = "lev_io_write_code" - - let write = write () - let to_int = function Read -> read | Write -> write - - module Set = struct - include Set (struct - type nonrec t = t - - let to_int = to_int - end) - - let create ?(read = false) ?(write = false) () = - union - (if read then singleton Read else empty) - (if write then singleton Write else empty) - end - end - - type t - - include Watcher (struct - type nonrec t = t - end) - - external fd : t -> Unix.file_descr = "lev_io_fd" - external modify : t -> Event.Set.t -> unit = "lev_io_modify" - - external create : - (t -> Unix.file_descr -> Event.Set.t -> unit) -> - Unix.file_descr -> - Event.Set.t -> - t = "lev_io_create" - - external start : t -> Loop.t -> unit = "lev_io_start" - external stop : t -> Loop.t -> unit = "lev_io_stop" -end - -let wrap_callback f t () = f t - -module Periodic = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external destroy : t -> unit = "lev_periodic_destroy" - - type kind = - | Regular of { offset : Timestamp.t; interval : Timestamp.t option } - | Custom of (t -> now:Timestamp.t -> Timestamp.t) - - external create_regular : (t -> unit -> unit) -> float -> float -> t - = "lev_periodic_create_regular" - - external create_custom : - (t -> unit -> unit) -> (t -> now:Timestamp.t -> Timestamp.t) -> t - = "lev_periodic_create_custom" - - let create f kind = - let f = wrap_callback f in - match kind with - | Custom rb -> create_custom f rb - | Regular { offset; interval } -> - let interval = match interval with None -> 0. | Some f -> f in - create_regular f offset interval - - external stop : t -> Loop.t -> unit = "lev_periodic_stop" - external start : t -> Loop.t -> unit = "lev_periodic_start" -end - -module Timer = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external create : (t -> unit -> unit) -> float -> float -> t - = "lev_timer_create" - - let create ?(repeat = 0.) ~after f = create (wrap_callback f) after repeat - - external remaining : t -> Loop.t -> Timestamp.t = "lev_timer_remaining" - external stop : t -> Loop.t -> unit = "lev_timer_stop" - external start : t -> Loop.t -> unit = "lev_timer_start" - external again : t -> Loop.t -> unit = "lev_timer_again" -end - -module Signal = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external stop : t -> Loop.t -> unit = "lev_signal_stop" - external start : t -> Loop.t -> unit = "lev_signal_start" - external create : (t -> unit -> unit) -> signal:int -> t = "lev_signal_create" - - let create f ~signal = create (wrap_callback f) ~signal -end - -module Child = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external stop : t -> Loop.t -> unit = "lev_child_stop" - external start : t -> Loop.t -> unit = "lev_child_start" - - type pid = Any | Pid of int - type trace = Terminate | Terminate_stop_or_continue - - external create : - (t -> pid:int -> Unix.process_status -> unit) -> int -> int -> t - = "lev_child_create" - - let create cb pid trace = - let pid = match pid with Any -> 0 | Pid pid -> pid in - let trace = - match trace with Terminate -> 0 | Terminate_stop_or_continue -> 1 - in - create cb pid trace - - let create = if Sys.win32 then Error `Unimplemented else Ok create -end - -module Cleanup = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external stop : t -> Loop.t -> unit = "lev_cleanup_stop" - external start : t -> Loop.t -> unit = "lev_cleanup_start" - external create : (t -> unit -> unit) -> t = "lev_cleanup_create" - - let create f = create (wrap_callback f) -end - -module Stat = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external stop : t -> Loop.t -> unit = "lev_stat_stop" - external start : t -> Loop.t -> unit = "lev_stat_start" - - external create : (t -> unit -> unit) -> string -> Timestamp.t -> t - = "lev_stat_create" - - external stat : t -> Unix.stats = "lev_stat_stat" - - let create_unix ?(interval = 0.) ~path f = - create (wrap_callback f) path interval - - let create = if Sys.win32 then Error `Unimplemented else Ok create_unix -end - -module Embed = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external destroy : t -> unit = "lev_embed_destroy" - external stop : t -> Loop.t -> unit = "lev_embed_stop" - external start : t -> Loop.t -> unit = "lev_embed_start" - - type sweep = Automatic | Manual of (t -> unit) - - external create_automatic : Loop.t -> t = "lev_embed_create_automatic" - - external create_manual : (t -> unit -> unit) -> Loop.t -> t - = "lev_embed_create_manual" - - let create sweep loop = - match sweep with - | Automatic -> create_automatic loop - | Manual f -> create_manual (wrap_callback f) loop - - external sweep : t -> Loop.t -> unit = "lev_embed_sweep" -end - -module Idle = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external stop : t -> Loop.t -> unit = "lev_idle_stop" - external start : t -> Loop.t -> unit = "lev_idle_start" - external create : (t -> unit -> unit) -> t = "lev_idle_create" - - let create f = create (wrap_callback f) -end - -module Check = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external stop : t -> Loop.t -> unit = "lev_check_stop" - external start : t -> Loop.t -> unit = "lev_check_start" - external create : (t -> unit -> unit) -> t = "lev_check_create" - - let create f = create (wrap_callback f) -end - -module Async = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external stop : t -> Loop.t -> unit = "lev_async_stop" - external start : t -> Loop.t -> unit = "lev_async_start" - external pending : t -> bool = "lev_async_pending" - external send : t -> Loop.t -> unit = "lev_async_send" - external create : (t -> unit -> unit) -> t = "lev_async_create" - - let create f = create (wrap_callback f) -end - -module Prepare = struct - type t - - include Watcher (struct - type nonrec t = t - end) - - external stop : t -> Loop.t -> unit = "lev_prepare_stop" - external start : t -> Loop.t -> unit = "lev_prepare_start" - external create : (t -> unit -> unit) -> t = "lev_prepare_create" - - let create f = create (wrap_callback f) -end diff --git a/submodules/lev/lev/src/lev.mli b/submodules/lev/lev/src/lev.mli deleted file mode 100644 index 2608098a2..000000000 --- a/submodules/lev/lev/src/lev.mli +++ /dev/null @@ -1,269 +0,0 @@ -(** Thin wrapper around Marc Lehmann's libev library. - -libev is small and performant, but this comes at a cost of a few rough edges -and a higher learning curve. Lev tries to make it more usable, but it does not -try to invent a new API. You should be somewhat familiar with async IO and -libev's quirks to use this library effectively. - -Some things to keep in mind: - - - It is your responsibility to make sure that fd's are non blocking - - - Watchers are mutable and the event loop will mutate them. In libev, it is - possible for the user to mutate the watchers as well, but [Lev] does not - provide this because it is unsafe and mostly unnecessary. Just crate new - watchers and throw out the old ones. - - - All actual read, write, accept, etc. calls are outside the scope of this - library. - - - You must call [$Watcher.destroy] to free the resources taken of every - watcher. A similar rule applies for [Loop.destroy], but it usually does not - matter. - - - You must not reuse the same watcher between different event loops. - - - Watchers are not threadsafe with the exception of [Async]. [Async] is the - specifically designed to wake up the event loop from different threads. - - *) - -val ev_version : unit -> int * int - -module Backend : sig - type t = - | Select - | Poll - | Epoll - | Kqueue - | Devpoll - | Port - | Linuxaio - | Iouring - - module Set : sig - type t - - val all : t - - type backend - - val mem : t -> backend -> bool - end - with type backend := t - - val supported : unit -> Set.t - val embeddable : unit -> Set.t - val recommended : unit -> Set.t -end - -module Timestamp : sig - type t - - val sleep : t -> unit - val of_float : float -> t - val to_float : t -> float -end - -module Loop : sig - module Flag : sig - type t = - | Backend of Backend.t - | Auto - | Noenv - | Forkcheck - | Noinotify - | Signalfd - | Nosigmask - | Notimerfd - - val to_int : t -> int - - module Set : sig - type elt := t - type t - - val empty : t - val singleton : elt -> t - val of_backend_set : Backend.Set.t -> t - val inter : t -> t -> t - val union : t -> t -> t - val negate : t -> t - val mem : t -> elt -> bool - end - end - - type t - - val now : t -> Timestamp.t - - val default : ?flags:Flag.Set.t -> unit -> t - (** The default event loop is the only one that can handle child watchers. *) - - val is_default : t -> bool - val create : ?flags:Flag.Set.t -> unit -> t - val destroy : t -> unit - val now_update : t -> unit - - type run = Once | Nowait - - val run : t -> run -> [ `No_more_active_watchers | `Otherwise ] - val run_until_done : t -> unit - val depth : t -> int - - type break = One | All | Cancel - - val break : t -> break -> unit - val backend : t -> Backend.t - val suspend : t -> unit - val resume : t -> unit - val ref : t -> unit - val unref : t -> unit - val feed_signal : signal:int -> unit - val feed_signal_event : t -> signal:int -> unit -end - -module type Watcher = sig - type t - (** The basic unit of interactions with an event loop. Created with a - callback that the event loop will trigger once the watcher becomes pending. *) - - val start : t -> Loop.t -> unit - (** [start t loop] starts the watcher and associates it to [loop]. You must - not use this watcher in another event loop. *) - - val is_active : t -> bool - (** [is_active t] returns [true] if [start t loop] has been called but [stop - t] has not. *) - - val is_pending : t -> bool - (** [is_pending t] returns [true] if the callback associated with [t] needs - to be invoked. *) - - val stop : t -> Loop.t -> unit - (** [stop t loop] the event loop will no longer trigger this watcher. [t] may - be started again with [t] *) - - val destroy : t -> unit - (** [destroy t] frees the memory allocated for [t]. After this call, you may - not use [t] in any way. You may only call [destroy t] if [is_active t] - and [is_pending t] are both [false]*) -end - -module Periodic : sig - include Watcher - - type kind = - | Regular of { offset : Timestamp.t; interval : Timestamp.t option } - | Custom of (t -> now:Timestamp.t -> Timestamp.t) - - val create : (t -> unit) -> kind -> t -end - -module Io : sig - module Event : sig - type t = Read | Write - - module Set : sig - type t - type event - - val equal : t -> t -> bool - val mem : t -> event -> bool - val create : ?read:bool -> ?write:bool -> unit -> t - val add : t -> event -> t - val inter : t -> t -> t - end - with type event := t - end - - include Watcher - - val fd : t -> Unix.file_descr - val modify : t -> Event.Set.t -> unit - - val create : - (t -> Unix.file_descr -> Event.Set.t -> unit) -> - Unix.file_descr -> - Event.Set.t -> - t -end - -module Timer : sig - include Watcher - - val create : ?repeat:float -> after:float -> (t -> unit) -> t - val remaining : t -> Loop.t -> Timestamp.t - val again : t -> Loop.t -> unit -end - -module Stat : sig - include Watcher - - val stat : t -> Unix.stats - (** [stat t] is only permitted to be called inside the callback to [create] *) - - val create : - ( ?interval:Timestamp.t -> path:string -> (t -> unit) -> t, - [ `Unimplemented ] ) - result -end - -module Child : sig - include Watcher - - type pid = Any | Pid of int - type trace = Terminate | Terminate_stop_or_continue - - val create : - ( (t -> pid:int -> Unix.process_status -> unit) -> pid -> trace -> t, - [ `Unimplemented ] ) - result -end - -module Signal : sig - include Watcher - - val create : (t -> unit) -> signal:int -> t -end - -module Cleanup : sig - include Watcher - - val create : (t -> unit) -> t -end - -module Async : sig - include Watcher - - val create : (t -> unit) -> t - val send : t -> Loop.t -> unit - val pending : t -> bool -end - -module Check : sig - include Watcher - - val create : (t -> unit) -> t -end - -module Prepare : sig - include Watcher - - val create : (t -> unit) -> t -end - -module Idle : sig - include Watcher - - val create : (t -> unit) -> t -end - -module Embed : sig - include Watcher - - type sweep = Automatic | Manual of (t -> unit) - - val create : sweep -> Loop.t -> t - val sweep : t -> Loop.t -> unit -end diff --git a/submodules/lev/lev/src/lev_stubs.c b/submodules/lev/lev/src/lev_stubs.c deleted file mode 100644 index d0ca3015c..000000000 --- a/submodules/lev/lev/src/lev_stubs.c +++ /dev/null @@ -1,718 +0,0 @@ -#include "ev.h" - -#include - -#include -#if (defined(__FreeBSD__) || defined(__OpenBSD__)) -#include -#endif -#define TAG_WEXITED 0 -#define TAG_WSIGNALED 1 -#define TAG_WSTOPPED 2 - -#include -#include -#include -#include -#include -#include -#define CAML_INTERNALS -#include -#undef CAML_INTERNALS -#include -#include - -#if _WIN32 -#define FD_val(value) win_CRT_fd_of_filedescr(value) -#else -#define FD_val(value) Int_val(value) -#endif - -#define Ev_val(__typ, __v) *(struct __typ **)Data_custom_val(__v) -#define Ev_watcher_val(v) *(struct ev_watcher **)Data_custom_val(v) -#define Ev_io_val(v) *(struct ev_io **)Data_custom_val(v) -#define Ev_child_val(v) *(struct ev_child **)Data_custom_val(v) -#define Ev_timer_val(v) *(struct ev_timer **)Data_custom_val(v) -#define Ev_periodic_val(v) *(struct ev_periodic **)Data_custom_val(v) -#define Ev_cleanup_val(v) *(struct ev_cleanup **)Data_custom_val(v) - -#define Cb_for(__t) \ - (void (*)(struct ev_loop *, struct __t *, int)) lev_watcher_cb - -#define DEF_CONST(__name, __value) \ - CAMLprim value __name(value v_unit) { \ - CAMLparam1(v_unit); \ - CAMLreturn(Val_long(__value)); \ - } - -#define DEF_BACKEND(__name, __value) \ - CAMLprim value lev_backend_##__name(value v_unit) { \ - CAMLparam1(v_unit); \ - CAMLreturn(Val_long(__value)); \ - } - -#define DEF_LOOP_FLAG(__name, __value) \ - CAMLprim value lev_loop_flags_##__name(value v_unit) { \ - CAMLparam1(v_unit); \ - CAMLreturn(Val_long(__value)); \ - } - -CAMLextern int caml_convert_signal_number(int); -CAMLextern int caml_rev_convert_signal_number(int); - -DEF_CONST(lev_loop_break_cancel_code, EVBREAK_CANCEL) -DEF_CONST(lev_loop_break_one_code, EVBREAK_ONE) -DEF_CONST(lev_loop_break_all_code, EVBREAK_ALL) - -DEF_CONST(lev_loop_run_once, EVRUN_ONCE); -DEF_CONST(lev_loop_run_nowait, EVRUN_NOWAIT); - -DEF_BACKEND(poll, EVBACKEND_POLL) -DEF_BACKEND(select, EVBACKEND_SELECT) -DEF_BACKEND(epoll, EVBACKEND_EPOLL) -DEF_BACKEND(kqueue, EVBACKEND_KQUEUE) -DEF_BACKEND(devpoll, EVBACKEND_DEVPOLL) -DEF_BACKEND(port, EVBACKEND_PORT) -DEF_BACKEND(linuxaio, EVBACKEND_LINUXAIO) -DEF_BACKEND(iouring, EVBACKEND_IOURING) - -DEF_LOOP_FLAG(auto, EVFLAG_AUTO) -DEF_LOOP_FLAG(noenv, EVFLAG_NOENV) -DEF_LOOP_FLAG(forkcheck, EVFLAG_FORKCHECK) -DEF_LOOP_FLAG(noinotify, EVFLAG_NOINOTIFY) -DEF_LOOP_FLAG(signalfd, EVFLAG_SIGNALFD) -DEF_LOOP_FLAG(nosigmask, EVFLAG_NOSIGMASK) -DEF_LOOP_FLAG(notimerfd, EVFLAG_NOTIMERFD) - -#define DEF_BACKEND_SET(__name, __value) \ - CAMLprim value lev_backend_##__name(value v_unit) { \ - CAMLparam1(v_unit); \ - CAMLreturn(Int_val(__value())); \ - } - -DEF_BACKEND_SET(supported, ev_supported_backends) -DEF_BACKEND_SET(recommended, ev_recommended_backends) -DEF_BACKEND_SET(embeddable, ev_embeddable_backends) - -#define DEF_STOP(__name) \ - CAMLprim value lev_##__name##_stop(value v_w, value v_ev) { \ - CAMLparam2(v_w, v_ev); \ - ev_##__name *w = Ev_val(ev_##__name, v_w); \ - struct ev_loop *ev = (struct ev_loop *)Nativeint_val(v_ev); \ - ev_##__name##_stop(ev, w); \ - CAMLreturn(Val_unit); \ - } - -DEF_STOP(cleanup) -DEF_STOP(io) -DEF_STOP(timer) -DEF_STOP(periodic) -DEF_STOP(signal) -DEF_STOP(stat) -DEF_STOP(embed) -DEF_STOP(idle) -DEF_STOP(check) -DEF_STOP(async) -DEF_STOP(prepare) -#if EV_CHILD_ENABLE -DEF_STOP(child) -#else -CAMLprim value lev_child_stop(value v_w, value v_ev) { - caml_failwith("unimplemented"); -} -#endif - -#define DEF_START(__name) \ - CAMLprim value lev_##__name##_start(value v_w, value v_ev) { \ - CAMLparam2(v_w, v_ev); \ - ev_##__name *w = Ev_val(ev_##__name, v_w); \ - struct ev_loop *ev = (struct ev_loop *)Nativeint_val(v_ev); \ - ev_##__name##_start(ev, w); \ - CAMLreturn(Val_unit); \ - } - -DEF_START(cleanup) -DEF_START(io) -DEF_START(timer) -DEF_START(periodic) -DEF_START(signal) -DEF_START(stat) -DEF_START(embed) -DEF_START(idle) -DEF_START(check) -DEF_START(async) -DEF_START(prepare) -#if EV_CHILD_ENABLE -DEF_START(child) -#else -CAMLprim value lev_child_start(value v_w, value v_ev) { - caml_failwith("unimplemented"); -} -#endif - -// TODO garbage collect loops themselves - -static int compare_watchers(value a, value b) { - return (int)((char *)Ev_watcher_val(a) - (char *)Ev_watcher_val(b)); -} - -static intnat hash_watcher(value watcher) { - return (intnat)Ev_watcher_val(watcher); -} - -struct periodic_cbs { - value watcher; - value reschedule; -}; - -static struct custom_operations watcher_ops = { - "lev.watcher", custom_finalize_default, compare_watchers, - hash_watcher, custom_serialize_default, custom_deserialize_default}; - -static struct custom_operations periodic_custom_ops = { - "lev.periodic", custom_finalize_default, compare_watchers, - hash_watcher, custom_serialize_default, custom_deserialize_default}; - -static struct custom_operations embed_manual_ops = { - "lev.embed", custom_finalize_default, compare_watchers, - hash_watcher, custom_serialize_default, custom_deserialize_default}; - -CAMLprim value lev_version(value v_unit) { - CAMLparam1(v_unit); - CAMLlocal1(v_version); - int major = ev_version_major(); - int minor = ev_version_minor(); - v_version = caml_alloc(2, 0); - Store_field(v_version, 0, Val_int(major)); - Store_field(v_version, 1, Val_int(minor)); - CAMLreturn(v_version); -} - -CAMLprim value lev_loop_backend(value v_loop) { - CAMLparam1(v_loop); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - CAMLreturn(Val_int(ev_backend(loop))); -} - -CAMLprim value lev_loop_depth(value v_loop) { - CAMLparam1(v_loop); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - CAMLreturn(Val_int(ev_depth(loop))); -} - -CAMLprim value lev_loop_now_update(value v_loop) { - CAMLparam1(v_loop); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_now_update(loop); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_loop_suspend(value v_loop) { - CAMLparam1(v_loop); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_suspend(loop); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_loop_ref(value v_loop) { - CAMLparam1(v_loop); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_ref(loop); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_loop_unref(value v_loop) { - CAMLparam1(v_loop); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_unref(loop); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_loop_resume(value v_loop) { - CAMLparam1(v_loop); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_resume(loop); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_loop_destroy(value v_loop) { - CAMLparam1(v_loop); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_loop_destroy(loop); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_loop_is_default(value v_loop) { - CAMLparam1(v_loop); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - CAMLreturn(Val_bool(ev_is_default_loop(loop))); -} - -CAMLprim value lev_loop_break(value v_loop, value v_break) { - CAMLparam2(v_loop, v_break); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_break(loop, Int_val(v_break)); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_ev_default(value v_flags) { - CAMLparam1(v_flags); - struct ev_loop *loop = ev_default_loop(Long_val(v_flags)); - if (!loop) { - caml_failwith("unable to create loop"); - } - CAMLreturn(caml_copy_nativeint((intnat)loop)); -} - -CAMLprim value lev_ev_now(value v_ev) { - CAMLparam1(v_ev); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_ev); - ev_tstamp now = ev_now(loop); - CAMLreturn(caml_copy_double(now)); -} - -CAMLprim value lev_sleep(value v_ts) { - CAMLparam1(v_ts); - ev_sleep(Double_val(v_ts)); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_ev_create(value v_flags) { - CAMLparam1(v_flags); - struct ev_loop *loop = ev_loop_new(Long_val(v_flags)); - if (!loop) { - caml_failwith("unable to create loop"); - } - CAMLreturn(caml_copy_nativeint((intnat)loop)); -} - -static void release_lock(EV_P) { caml_release_runtime_system(); } - -static void acquire_lock(EV_P) { caml_acquire_runtime_system(); } - -CAMLprim value lev_ev_run(value v_ev, value v_run) { - CAMLparam2(v_ev, v_run); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_ev); - int run = Int_val(v_run); - ev_set_loop_release_cb(loop, &release_lock, &acquire_lock); - bool ret = ev_run(loop, run); - CAMLreturn(Val_bool(ret)); -} - -static void lev_io_cb(EV_P_ ev_io *w, int revents) { - int fd = w->fd; - caml_callback2((value)w->data, Val_int(fd), Val_int(revents)); -} - -static void lev_watcher_cb(EV_P_ ev_watcher *w, int revents) { - caml_callback((value)w->data, Val_unit); -} - -static ev_tstamp lev_periodic_reschedule_cb(ev_periodic *w, ev_tstamp now) { - // TODO do we need this? - CAMLparam0(); - CAMLlocal1(v_stamp); - struct periodic_cbs *cbs = (struct periodic_cbs *)w->data; - v_stamp = caml_callback(cbs->reschedule, caml_copy_double(now)); - double result = Double_val(v_stamp); - CAMLdrop; - return result; -} - -static void lev_periodic_watcher_cb(EV_P_ ev_periodic *w, int revents) { - // TODO do we need this? - struct periodic_cbs *cbs = (struct periodic_cbs *)w->data; - caml_callback(cbs->watcher, Val_unit); -} - -CAMLprim value lev_io_read_code(value v_unit) { - CAMLparam1(v_unit); - CAMLreturn(Val_int(EV_READ)); -} - -CAMLprim value lev_io_write_code(value v_unit) { - CAMLparam1(v_unit); - CAMLreturn(Val_int(EV_WRITE)); -} - -CAMLprim value lev_io_fd(value v_io) { - CAMLparam1(v_io); - ev_io *io = Ev_io_val(v_io); - CAMLreturn(Val_int(io->fd)); -} - -CAMLprim value lev_io_create(value v_cb, value v_fd, value v_flags) { - CAMLparam3(v_cb, v_fd, v_flags); - CAMLlocal2(v_io, v_cb_applied); - ev_io *io = caml_stat_alloc(sizeof(ev_io)); - ev_io_init(io, lev_io_cb, FD_val(v_fd), Int_val(v_flags)); - v_io = caml_alloc_custom(&watcher_ops, sizeof(struct ev_io *), 0, 1); - Ev_io_val(v_io) = io; - v_cb_applied = caml_callback(v_cb, v_io); - io->data = (void *)v_cb_applied; - caml_register_generational_global_root((value *)(&(io->data))); - CAMLreturn(v_io); -} - -CAMLprim value lev_io_modify(value v_io, value v_flags) { - CAMLparam2(v_io, v_flags); - ev_io *io = Ev_io_val(v_io); - ev_io_modify(io, Int_val(v_flags)); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_timer_create(value v_cb, value v_after, value v_repeat) { - CAMLparam3(v_cb, v_after, v_repeat); - CAMLlocal2(v_timer, v_cb_applied); - ev_timer *timer = caml_stat_alloc(sizeof(ev_timer)); - ev_timer_init(timer, Cb_for(ev_timer), Double_val(v_after), - Double_val(v_repeat)); - v_timer = caml_alloc_custom(&watcher_ops, sizeof(struct ev_timer *), 0, 1); - Ev_timer_val(v_timer) = timer; - v_cb_applied = caml_callback(v_cb, v_timer); - timer->data = (void *)v_cb_applied; - caml_register_generational_global_root((value *)(&(timer->data))); - CAMLreturn(v_timer); -} - -CAMLprim value lev_timer_remaining(value v_timer, value v_ev) { - CAMLparam2(v_timer, v_ev); - ev_timer *timer = Ev_timer_val(v_timer); - struct ev_loop *ev = (struct ev_loop *)Nativeint_val(v_ev); - CAMLreturn(ev_timer_remaining(ev, timer)); -} - -CAMLprim value lev_timer_again(value v_timer, value v_ev) { - CAMLparam2(v_timer, v_ev); - ev_timer *timer = Ev_timer_val(v_timer); - struct ev_loop *ev = (struct ev_loop *)Nativeint_val(v_ev); - ev_timer_again(ev, timer); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_periodic_create_regular(value v_cb, value v_offset, - value v_interval) { - CAMLparam3(v_cb, v_offset, v_interval); - CAMLlocal2(v_periodic, v_cb_applied); - ev_periodic *periodic = caml_stat_alloc(sizeof(ev_periodic)); - ev_periodic_init(periodic, Cb_for(ev_periodic), Double_val(v_offset), - Double_val(v_interval), NULL); - v_periodic = - caml_alloc_custom(&watcher_ops, sizeof(struct ev_periodic *), 0, 1); - Ev_periodic_val(v_periodic) = periodic; - v_cb_applied = caml_callback(v_cb, v_periodic); - periodic->data = (void *)v_cb_applied; - caml_register_generational_global_root((value *)(&(periodic->data))); - CAMLreturn(v_periodic); -} - -CAMLprim value lev_periodic_create_custom(value v_cb, value v_reschedule) { - CAMLparam2(v_cb, v_reschedule); - CAMLlocal3(v_periodic, v_cb_applied, v_reschedule_applied); - ev_periodic *periodic = caml_stat_alloc(sizeof(ev_periodic)); - ev_periodic_init(periodic, lev_periodic_watcher_cb, 0, 0, - lev_periodic_reschedule_cb); - v_periodic = - caml_alloc_custom(&watcher_ops, sizeof(struct ev_periodic *), 0, 1); - Ev_periodic_val(v_periodic) = periodic; - struct periodic_cbs *cbs = caml_stat_alloc(sizeof(struct periodic_cbs)); - v_cb_applied = caml_callback(v_cb, v_periodic); - v_reschedule_applied = caml_callback(v_reschedule, v_periodic); - cbs->watcher = v_cb_applied; - cbs->reschedule = v_reschedule_applied; - periodic->data = (void *)cbs; - caml_register_generational_global_root((value *)(&(cbs->watcher))); - caml_register_generational_global_root((value *)(&(cbs->reschedule))); - CAMLreturn(v_periodic); -} - -CAMLprim value lev_periodic_destroy(value v_w) { - CAMLparam1(v_w); - ev_periodic *w = Ev_periodic_val(v_w); - if (w->reschedule_cb == NULL) { - caml_remove_generational_global_root((value *)(&(w->data))); - } else { - struct periodic_cbs *cbs = (struct periodic_cbs *)w->data; - caml_remove_generational_global_root(&(cbs->watcher)); - caml_remove_generational_global_root(&(cbs->reschedule)); - caml_stat_free(cbs); - } - caml_stat_free(w); - CAMLreturn(Val_unit); -} - -#define DEF_SIMPLE_CREATE(__name) \ - CAMLprim value lev_##__name##_create(value v_cb) { \ - CAMLparam1(v_cb); \ - CAMLlocal2(v_w, v_cb_applied); \ - ev_##__name *w = caml_stat_alloc(sizeof(ev_##__name)); \ - ev_##__name##_init(w, Cb_for(ev_##__name)); \ - v_w = caml_alloc_custom(&watcher_ops, sizeof(struct ev_##__name *), 0, 1); \ - Ev_val(ev_##__name, v_w) = w; \ - v_cb_applied = caml_callback(v_cb, v_w); \ - w->data = (void *)v_cb_applied; \ - caml_register_generational_global_root((value *)(&(w->data))); \ - CAMLreturn(v_w); \ - } - -DEF_SIMPLE_CREATE(cleanup) -DEF_SIMPLE_CREATE(async) -DEF_SIMPLE_CREATE(check) -DEF_SIMPLE_CREATE(prepare) -DEF_SIMPLE_CREATE(idle) - -#if EV_CHILD_ENABLE -static void lev_child_cb(EV_P_ ev_child *w, int revents) { - CAMLparam0(); - CAMLlocal1(v_status); - int status = w->rstatus; - if (WIFEXITED(status)) { - v_status = caml_alloc_small(1, TAG_WEXITED); - Field(v_status, 0) = Val_int(WEXITSTATUS(status)); - } else if (WIFSTOPPED(status)) { - v_status = caml_alloc_small(1, TAG_WSTOPPED); - Field(v_status, 0) = - Val_int(caml_rev_convert_signal_number(WSTOPSIG(status))); - } else { - v_status = caml_alloc_small(1, TAG_WSIGNALED); - Field(v_status, 0) = - Val_int(caml_rev_convert_signal_number(WTERMSIG(status))); - } - caml_callback2((value)w->data, Val_int(w->rpid), v_status); - CAMLdrop; -} - -CAMLprim value lev_child_create(value v_cb, value v_pid, value v_trace) { - CAMLparam3(v_cb, v_pid, v_trace); - int pid = Int_val(v_pid); - int trace = Int_val(v_trace); - CAMLlocal2(v_child, v_cb_applied); - ev_child *child = caml_stat_alloc(sizeof(ev_child)); - ev_child_init(child, lev_child_cb, pid, trace); - v_child = caml_alloc_custom(&watcher_ops, sizeof(struct ev_child *), 0, 1); - Ev_child_val(v_child) = child; - v_cb_applied = caml_callback(v_cb, v_child); - child->data = (void *)v_cb_applied; - caml_register_generational_global_root((value *)(&(child->data))); - CAMLreturn(v_child); -} -#else -CAMLprim value lev_child_create(value v_cb, value v_pid, value v_trace) { - caml_failwith("unimplemented"); -} -#endif - -CAMLprim value lev_embed_sweep(value v_embed, value v_loop) { - CAMLparam2(v_loop, v_embed); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_embed *embed = Ev_val(ev_embed, v_embed); - ev_embed_sweep(loop, embed); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_feed_signal(value v_signal) { - CAMLparam1(v_signal); - int signal = caml_convert_signal_number(Int_val(v_signal)); - ev_feed_signal(signal); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_loop_feed_signal_event(value v_loop, value v_signal) { - CAMLparam2(v_loop, v_signal); - int signal = caml_convert_signal_number(Int_val(v_signal)); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_feed_signal_event(loop, signal); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_signal_create(value v_cb, value v_signal) { - CAMLparam2(v_cb, v_signal); - CAMLlocal2(v_w, v_cb_applied); - ev_signal *w = caml_stat_alloc(sizeof(ev_signal)); - int signal = caml_convert_signal_number(Int_val(v_signal)); - ev_signal_init(w, Cb_for(ev_signal), signal); - v_w = caml_alloc_custom(&watcher_ops, sizeof(struct ev_signal *), 0, 1); - Ev_val(ev_signal, v_w) = w; - v_cb_applied = caml_callback(v_cb, v_w); - w->data = (void *)v_cb_applied; - caml_register_generational_global_root((value *)(&(w->data))); - CAMLreturn(v_w); -} - -CAMLprim value lev_async_send(value v_async, value v_loop) { - CAMLparam2(v_loop, v_async); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_async *async = Ev_val(ev_async, v_async); - ev_async_send(loop, async); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_async_pending(value v_async) { - CAMLparam1(v_async); - ev_async *async = Ev_val(ev_async, v_async); - CAMLreturn(Val_bool(ev_async_pending(async))); -} - -CAMLprim value lev_embed_create_automatic(value v_loop) { - CAMLparam1(v_loop); - CAMLlocal1(v_w); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_embed *w = caml_stat_alloc(sizeof(ev_embed)); - ev_embed_init(w, NULL, loop); - v_w = caml_alloc_custom(&embed_manual_ops, sizeof(struct ev_embed *), 0, 1); - Ev_val(ev_embed, v_w) = w; - CAMLreturn(v_w); -} - -CAMLprim value lev_embed_create_manual(value v_cb, value v_loop) { - CAMLparam2(v_cb, v_loop); - CAMLlocal2(v_w, v_cb_applied); - struct ev_loop *loop = (struct ev_loop *)Nativeint_val(v_loop); - ev_embed *w = caml_stat_alloc(sizeof(ev_embed)); - ev_embed_init(w, Cb_for(ev_embed), loop); - v_w = caml_alloc_custom(&watcher_ops, sizeof(struct ev_embed *), 0, 1); - Ev_val(ev_embed, v_w) = w; - v_cb_applied = caml_callback(v_cb, v_w); - w->data = (void *)v_cb_applied; - caml_register_generational_global_root((value *)(&(w->data))); - CAMLreturn(v_w); -} - -CAMLprim value lev_watcher_is_active(value v_w) { - CAMLparam1(v_w); - CAMLlocal1(v_active); - ev_watcher *w = Ev_val(ev_watcher, v_w); - v_active = Val_bool(ev_is_active(w)); - CAMLreturn(v_active); -} - -CAMLprim value lev_watcher_is_pending(value v_w) { - CAMLparam1(v_w); - CAMLlocal1(v_pending); - ev_watcher *w = Ev_val(ev_watcher, v_w); - v_pending = Val_bool(ev_is_pending(w)); - CAMLreturn(v_pending); -} - -CAMLprim value lev_watcher_destroy(value v_w) { - CAMLparam1(v_w); - ev_watcher *w = Ev_val(ev_watcher, v_w); - caml_remove_generational_global_root((value *)(&(w->data))); - caml_stat_free(w); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_embed_destroy(value v_embed) { - CAMLparam1(v_embed); - ev_embed *w = Ev_val(ev_embed, v_embed); - caml_stat_free(w); - CAMLreturn(Val_unit); -} - -CAMLprim value lev_periodic_custom_destroy(value v_periodic) { - CAMLparam1(v_periodic); - ev_periodic *w = Ev_periodic_val(v_periodic); - struct periodic_cbs *cbs = (struct periodic_cbs *)w->data; - caml_remove_generational_global_root(&(cbs->watcher)); - caml_remove_generational_global_root(&(cbs->reschedule)); - caml_stat_free(cbs); - caml_stat_free(w); - CAMLreturn(Val_unit); -} - -#ifdef _WIN32 - -CAMLprim value lev_stat_create(value v_cb, value v_path, value v_interval) { - caml_failwith("unimplemented on windows"); -} - -CAMLprim value lev_stat_stat(value v_w) { - caml_failwith("unimplemented on windows"); -} - -#else - -CAMLprim value lev_stat_create(value v_cb, value v_path, value v_interval) { - CAMLparam3(v_cb, v_path, v_interval); - CAMLlocal2(v_w, v_cb_applied); - ev_stat *w = caml_stat_alloc(sizeof(ev_stat)); - const char *path = String_val(v_path); - float interval = Double_val(v_interval); - ev_stat_init(w, Cb_for(ev_stat), path, interval); - v_w = caml_alloc_custom(&watcher_ops, sizeof(struct ev_stat *), 0, 1); - Ev_val(ev_stat, v_w) = w; - v_cb_applied = caml_callback(v_cb, v_w); - w->data = (void *)v_cb_applied; - caml_register_generational_global_root((value *)(&(w->data))); - CAMLreturn(v_w); -} - -// below is taken from OCaml's stat implementation - -/* Transform a (seconds, nanoseconds) time stamp (in the style of - struct timespec) to a number of seconds in floating-point. - Make sure the integer part of the result is always equal to [seconds] - (issue #9490). */ - -static double stat_timestamp(time_t sec, long nsec) { - /* The conversion of sec to FP is exact for the foreseeable future. - (It starts rounding when sec > 2^53, i.e. in 285 million years.) */ - double s = (double)sec; - /* The conversion of nsec to fraction of seconds can round. - Still, we have 0 <= n < 1.0. */ - double n = (double)nsec / 1e9; - /* The sum s + n can round up, hence s <= t + <= s + 1.0 */ - double t = s + n; - /* Detect the "round up to s + 1" case and decrease t so that - its integer part is s. */ - if (t == s + 1.0) - t = nextafter(t, s); - return t; -} - -static int file_kind_table[] = {S_IFREG, S_IFDIR, S_IFCHR, S_IFBLK, - S_IFLNK, S_IFIFO, S_IFSOCK}; - -static value cst_to_constr(int n, int *tbl, int size, int deflt) { - int i; - for (i = 0; i < size; i++) - if (n == tbl[i]) - return Val_int(i); - return Val_int(deflt); -} - -// TODO eventually use the same configure script as in ocaml's unix -#define NSEC(buf, field) 0 -#define Val_file_offset(fofs) caml_copy_int64(fofs) - -CAMLprim value lev_stat_stat(value v_w) { - CAMLparam1(v_w); - CAMLlocal5(v_atime, v_mtime, v_ctime, v_offset, v); - ev_stat *watcher_stat = Ev_val(ev_stat, v_w); - struct stat *stat = watcher_stat->data; - - v_atime = caml_copy_double(stat_timestamp(stat->st_atime, NSEC(buf, a))); - v_mtime = caml_copy_double(stat_timestamp(stat->st_mtime, NSEC(buf, m))); - v_ctime = caml_copy_double(stat_timestamp(stat->st_ctime, NSEC(buf, c))); - - bool use_64 = false; - v_offset = use_64 ? Val_file_offset(stat->st_size) : Val_int(stat->st_size); - - v = caml_alloc_small(12, 0); - Field(v, 0) = Val_int(stat->st_dev); - Field(v, 1) = Val_int(stat->st_ino); - Field(v, 2) = cst_to_constr(stat->st_mode & S_IFMT, file_kind_table, - sizeof(file_kind_table) / sizeof(int), 0); - Field(v, 3) = Val_int(stat->st_mode & 07777); - Field(v, 4) = Val_int(stat->st_nlink); - Field(v, 5) = Val_int(stat->st_uid); - Field(v, 6) = Val_int(stat->st_gid); - Field(v, 7) = Val_int(stat->st_rdev); - Field(v, 8) = v_offset; - Field(v, 9) = v_atime; - Field(v, 10) = v_mtime; - Field(v, 11) = v_ctime; - CAMLreturn(v); -} - -#endif diff --git a/submodules/lev/lev/test/dune b/submodules/lev/lev/test/dune deleted file mode 100644 index 5bc7a911b..000000000 --- a/submodules/lev/lev/test/dune +++ /dev/null @@ -1,52 +0,0 @@ -(library - (name lev_tests) - (modules lev_tests sockets) - (libraries - lev - ;; This is because of the (implicit_transitive_deps false) - ;; in dune-project - ppx_expect.config - ppx_expect.config_types - ppx_expect - base - ppx_inline_test.config) - (inline_tests) - (preprocess - (pps ppx_expect))) - -(library - (name lev_tests_unix) - (modules lev_tests_unix) - (libraries - lev - ;; This is because of the (implicit_transitive_deps false) - ;; in dune-project - ppx_expect.config - ppx_expect.config_types - ppx_expect - base - ppx_inline_test.config) - (inline_tests - (enabled_if - (= %{os_type} Unix))) - (preprocess - (pps ppx_expect))) - -(library - (name lev_tests_signals) - (modules lev_tests_signals) - (libraries - lev - threads.posix - ;; This is because of the (implicit_transitive_deps false) - ;; in dune-project - ppx_expect.config - ppx_expect.config_types - ppx_expect - base - ppx_inline_test.config) - (inline_tests - (enabled_if - (= %{os_type} Unix))) - (preprocess - (pps ppx_expect))) diff --git a/submodules/lev/lev/test/lev_tests.ml b/submodules/lev/lev/test/lev_tests.ml deleted file mode 100644 index c6d3bac0f..000000000 --- a/submodules/lev/lev/test/lev_tests.ml +++ /dev/null @@ -1,292 +0,0 @@ -open Printf -open Lev -module List = ListLabels - -let immediately = 0.00001 - -let%expect_test "version" = - let major, minor = ev_version () in - printf "version (%d, %d)\n" major minor; - [%expect {| version (4, 33) |}] - -let%expect_test "default" = - ignore (Loop.default ()); - [%expect {||}] - -let%expect_test "now" = - let loop = Loop.default () in - let (_ : Timestamp.t) = Loop.now loop in - [%expect {||}] - -let%expect_test "sleep" = - Timestamp.sleep (Timestamp.of_float 0.1); - [%expect {||}] - -let%expect_test "suspend/resume" = - let loop = Loop.create () in - Loop.suspend loop; - Loop.resume loop; - [%expect {||}] - -let%expect_test "create and run" = - let ev = Loop.create () in - (match Loop.run ev Nowait with - | `No_more_active_watchers -> () - | `Otherwise -> assert false); - [%expect {||}] - -let%expect_test "timer" = - let loop = Loop.create () in - let timer = - Timer.create ~after:0.001 (fun timer -> - print_endline "fired timer"; - Timer.stop timer loop) - in - Timer.start timer loop; - ignore (Lev.Loop.run loop Once); - [%expect {| - fired timer |}] - -let%expect_test "timer - not repeats" = - let loop = Loop.create () in - let timer = - Timer.create ~after:immediately (fun _ -> print_endline "fired timer") - in - Timer.start timer loop; - ignore (Lev.Loop.run loop Once); - ignore (Lev.Loop.run loop Once); - Timer.stop timer loop; - [%expect {| - fired timer |}] - -let%expect_test "timer - cancellation with stop" = - let loop = Loop.create () in - let timer = Timer.create ~after:6.5 (fun _ -> print_endline "fired timer") in - Timer.start timer loop; - ignore (Lev.Loop.run loop Nowait); - Timer.stop timer loop; - ignore (Lev.Loop.run loop Once); - [%expect {| |}] - -let%expect_test "periodic timer" = - let loop = Loop.create () in - let timer = - let count = ref 3 in - Timer.create ~after:0. ~repeat:0.02 (fun timer -> - if !count = 0 then - let () = print_endline "stopping timer" in - Timer.stop timer loop - else ( - decr count; - print_endline "fired timer")) - in - Timer.start timer loop; - ignore (Lev.Loop.run_until_done loop); - [%expect - {| - fired timer - fired timer - fired timer - stopping timer |}] - -let%expect_test "cleanup callbacks" = - let loop = Loop.create () in - let cleanup = Cleanup.create (fun _ -> print_endline "cleanup") in - Cleanup.start cleanup loop; - ignore (Loop.run loop Nowait); - Loop.destroy loop; - [%expect {| cleanup |}] - -let%expect_test "periodic - regular" = - let loop = Loop.create () in - let periodic = - Periodic.create - (fun p -> - print_endline "periodic fired"; - Periodic.stop p loop) - (Regular { offset = Timestamp.of_float 0.1; interval = None }) - in - Periodic.start periodic loop; - Loop.run_until_done loop; - [%expect {| periodic fired |}] - -let%expect_test "periodic - custom" = - let loop = Loop.create () in - let periodic = - Periodic.create - (fun p -> - print_endline "periodic fired"; - Periodic.stop p loop) - (Custom - (fun _ ~now -> - let now = Timestamp.to_float now in - Timestamp.of_float (now +. 0.2))) - in - Periodic.start periodic loop; - Loop.run_until_done loop; - [%expect {| periodic fired |}] - -let%expect_test "check/idle/prepare" = - let loop = Loop.create () in - let check = Check.create (fun _ -> print_endline "check") in - let idle = Idle.create (fun _ -> print_endline "idle") in - let prepare = Prepare.create (fun _ -> print_endline "prepare") in - [ Check.start check; Idle.start idle; Prepare.start prepare ] - |> List.iter ~f:(fun f -> f loop); - ignore (Loop.run loop Once); - [%expect {| - prepare - check - idle |}] - -let%expect_test "async" = - let loop = Loop.create () in - let async = Async.create (fun _ -> print_endline "async fired") in - let prepare = - Prepare.create (fun _ -> - print_endline "firing async"; - Async.send async loop) - in - Prepare.start prepare loop; - Async.start async loop; - ignore (Loop.run loop Nowait); - ignore (Loop.run loop Nowait); - [%expect - {| - firing async - async fired - firing async - async fired |}] - -let%expect_test "is_pending/is_active" = - let loop = Loop.create () in - let idle = Idle.create (fun _ -> print_endline "idle") in - let print_status () = - printf "pending = %b; active = %b\n" (Idle.is_pending idle) - (Idle.is_active idle) - in - print_status (); - Idle.start idle loop; - print_status (); - ignore (Loop.run loop Once); - print_status (); - Idle.stop idle loop; - print_status (); - [%expect - {| - pending = false; active = false - pending = false; active = true - idle - pending = false; active = true - pending = false; active = false |}] - -let%expect_test "destroy" = - let loop = Loop.create () in - let idle = - Idle.create (fun idle -> - print_endline "idle"; - Idle.stop idle loop) - in - Idle.start idle loop; - ignore (Loop.run loop Once); - assert (not (Idle.is_active idle)); - assert (not (Idle.is_pending idle)); - print_endline "destroying watcher"; - Idle.destroy idle; - [%expect {| - idle - destroying watcher |}] - -let%expect_test "timer - stops automatically" = - let loop = Loop.create () in - let another = ref true in - let timer = - Timer.create ~after:immediately (fun t -> - print_endline "timer fired"; - if !another then ( - another := false; - Timer.start t loop)) - in - Timer.start timer loop; - Loop.run_until_done loop; - [%expect {| - timer fired - timer fired |}] - -let%expect_test "timer/again cancels start" = - let loop = Loop.create () in - let count = ref 0 in - let timer = - Timer.create ~after:immediately (fun _ -> - incr count; - printf "timer fired %d\n" !count) - in - Timer.start timer loop; - ignore (Loop.run loop Once); - [%expect {| timer fired 1 |}]; - Timer.start timer loop; - ignore (Loop.run loop Once); - [%expect {| timer fired 2 |}]; - (* again does nothing because timer isn't periodic *) - Timer.again timer loop; - ignore (Loop.run loop Once); - [%expect {| |}] - -let%expect_test "timer/consecutive again" = - let loop = Loop.create () in - let now = Unix.time () in - let timer = - Timer.create ~after:1.0 (fun t -> - printf "timer fired after %f\n" (Unix.time () -. now); - Timer.stop t loop) - in - let control = - let count = ref 3 in - Timer.create ~after:immediately ~repeat:0.2 (fun t -> - if !count = 0 then Timer.stop t loop - else ( - decr count; - print_endline "resetting timer"; - Timer.again timer loop)) - in - Timer.start timer loop; - Timer.start control loop; - Loop.run_until_done loop; - [%expect {| - resetting timer - resetting timer - resetting timer |}] - -exception Idle - -let%expect_test "callback exception" = - let loop = Loop.create () in - let idle = Idle.create (fun _ -> raise Idle) in - Idle.start idle loop; - let with_idle () = - try ignore (Loop.run loop Once) with Idle -> print_endline "caught idle!" - in - with_idle (); - with_idle (); - [%expect {| - caught idle! - caught idle! |}] - -let%expect_test "unref" = - let loop = Loop.create () in - let check = Check.create (fun _ -> printf "only one iteration\n") in - Check.start check loop; - Loop.unref loop; - ignore (Loop.run_until_done loop); - [%expect {| - only one iteration - |}] - -let%expect_test "is_default" = - printf "is_default(default) = %b\n" (Loop.is_default (Loop.default ())); - printf "is_default(create) = %b\n" (Loop.is_default (Loop.create ())); - [%expect - {| - is_default(default) = true - is_default(create) = false - |}] diff --git a/submodules/lev/lev/test/lev_tests_signals.ml b/submodules/lev/lev/test/lev_tests_signals.ml deleted file mode 100644 index 27327f797..000000000 --- a/submodules/lev/lev/test/lev_tests_signals.ml +++ /dev/null @@ -1,53 +0,0 @@ -open Lev - -let flags = Loop.Flag.(Set.singleton Nosigmask) - -let%expect_test "signal handling" = - let signal = Sys.sigusr1 in - let loop = Loop.create ~flags () in - let signal_watcher = - Signal.create ~signal (fun t -> - print_endline "received signal"; - ignore (Unix.sigprocmask SIG_BLOCK [ signal ]); - Signal.stop t loop) - in - let idle = - Idle.create (fun idle -> - print_endline "sending signal"; - Unix.kill (Unix.getpid ()) signal; - Idle.stop idle loop) - in - Signal.start signal_watcher loop; - Idle.start idle loop; - Loop.run_until_done loop; - [%expect {| - sending signal - received signal |}] - -let%expect_test "manual signal feeding" = - let signal = Sys.sigusr2 in - ignore (Unix.sigprocmask SIG_BLOCK [ signal ]); - let thread = - Thread.create - (fun () -> - print_endline "thread: awaiting signal"; - ignore (Thread.wait_signal [ signal ]); - Loop.feed_signal ~signal; - print_endline "thread: awaited signal") - () - in - let loop = Loop.create () in - let signal_watcher = - Signal.create ~signal (fun w -> - print_endline "lev: received signal"; - Signal.stop w loop) - in - Signal.start signal_watcher loop; - Unix.kill (Unix.getpid ()) signal; - Loop.run_until_done loop; - Thread.join thread; - [%expect - {| - thread: awaiting signal - thread: awaited signal - lev: received signal |}] diff --git a/submodules/lev/lev/test/lev_tests_unix.ml b/submodules/lev/lev/test/lev_tests_unix.ml deleted file mode 100644 index cfce07e3e..000000000 --- a/submodules/lev/lev/test/lev_tests_unix.ml +++ /dev/null @@ -1,149 +0,0 @@ -open Printf -open Lev -module List = ListLabels - -let%expect_test "child" = - let loop = Loop.default () in - let stdin, stdin_w = Unix.pipe ~cloexec:true () in - let stdout_r, stdout = Unix.pipe ~cloexec:true () in - let stderr_r, stderr = Unix.pipe ~cloexec:true () in - Unix.close stdin_w; - Unix.close stdout_r; - Unix.close stderr_r; - let pid = - Unix.create_process "sh" [| "sh"; "-c"; "exit 42" |] stdin stdout stderr - in - let child = - match Child.create with - | Error `Unimplemented -> assert false - | Ok create -> - create - (fun t ~pid:pid' status -> - Child.stop t loop; - (match status with - | Unix.WEXITED i -> printf "exited with status %d\n" i - | _ -> assert false); - assert (pid = pid')) - (Pid pid) Terminate - in - Child.start child loop; - Loop.run_until_done loop; - [%expect {| exited with status 42 |}] - -let%expect_test "read from pipe" = - let r, w = Unix.pipe () in - Unix.set_nonblock r; - Unix.set_nonblock w; - let loop = Loop.create () in - let io_r = - Io.create - (fun io fd events -> - let b = Bytes.make 1 '0' in - match Unix.read fd b 0 1 with - | exception Unix.Unix_error (EAGAIN, _, _) -> () - | s -> - assert (Io.Event.Set.mem events Read); - assert (s = 1); - printf "read char %s\n" (Bytes.to_string b); - Unix.close r; - Io.stop io loop) - r - (Io.Event.Set.create ~read:true ()) - in - let io_w = - Io.create - (fun io fd events -> - assert (Io.Event.Set.mem events Write); - ignore (Unix.write fd (Bytes.make 1 'c') 0 1); - print_endline "written to pipe"; - Unix.close w; - Io.stop io loop) - w - (Io.Event.Set.create ~write:true ()) - in - Io.start io_r loop; - Io.start io_w loop; - ignore (Loop.run_until_done loop); - [%expect {| - written to pipe - read char c |}] - -let%expect_test "read when write end closed" = - let r, w = Unix.pipe ~cloexec:true () in - Unix.close w; - Unix.set_nonblock r; - let loop = Loop.create ~flags:(Loop.Flag.Set.singleton (Backend Select)) () in - let io_r = - Io.create - (fun io fd _events -> - let b = Bytes.make 1 '0' in - match Unix.read fd b 0 1 with - | exception Unix.Unix_error (EAGAIN, _, _) -> assert false - | 0 -> - Lev.Io.stop io loop; - print_endline "read 0 bytes" - | _ -> assert false) - r - (Io.Event.Set.create ~read:true ()) - in - Io.start io_r loop; - Loop.run_until_done loop; - [%expect {| - read 0 bytes - |}] - -let%expect_test "watch a closed fd" = - let r, w = Unix.pipe ~cloexec:true () in - Unix.set_nonblock r; - let loop = Loop.create ~flags:(Loop.Flag.Set.singleton (Backend Select)) () in - let io_r = - Io.create - (fun io fd _events -> - let b = Bytes.make 1 '0' in - match Unix.read fd b 0 1 with - | exception Unix.Unix_error (EBADF, _, _) -> - print_endline "received EBADF"; - Io.stop io loop - | _ -> assert false) - r - (Io.Event.Set.create ~read:true ()) - in - Io.start io_r loop; - let check = - Check.create (fun check -> - printf "closing after start\n"; - Unix.close w; - Unix.close r; - Check.stop check loop) - in - Check.start check loop; - (* XXX why doesn't [run_until_done] work here? *) - ignore (Loop.run loop Nowait); - ignore (Loop.run loop Nowait); - Loop.run_until_done loop; - [%expect {| - closing after start - received EBADF - |}] - -let%expect_test "write to closed reader" = - let r, w = Unix.pipe ~cloexec:true () in - let loop = Loop.create ~flags:(Loop.Flag.Set.singleton (Backend Select)) () in - let old_sigpipe = Sys.signal Sys.sigpipe Sys.Signal_ignore in - Unix.close r; - let io = - Io.create - (fun io fd _ -> - let bytes = Bytes.of_string "foobar" in - match Unix.single_write fd bytes 0 (Bytes.length bytes) with - | exception Unix.Unix_error (Unix.EPIPE, _, _) -> - print_endline "received epipe"; - Io.stop io loop - | _ -> assert false) - w - (Io.Event.Set.create ~write:true ()) - in - Io.start io loop; - Loop.run_until_done loop; - Sys.set_signal Sys.sigpipe old_sigpipe; - [%expect {| received epipe |}] diff --git a/submodules/lev/lev/test/sockets.ml b/submodules/lev/lev/test/sockets.ml deleted file mode 100644 index 1987aaf93..000000000 --- a/submodules/lev/lev/test/sockets.ml +++ /dev/null @@ -1,51 +0,0 @@ -let%expect_test "server & client" = - let server_sockaddr = Unix.ADDR_INET (Unix.inet_addr_loopback, 0) in - let domain = Unix.domain_of_sockaddr server_sockaddr in - let socket () = Unix.socket ~cloexec:true domain Unix.SOCK_STREAM 0 in - let loop = Lev.Loop.create () in - let client_sockaddr = ref None in - let server_ready = - let client () = - let fd = socket () in - print_endline "client: connecting"; - Unix.connect fd - (match !client_sockaddr with None -> assert false | Some s -> s); - Unix.close fd - in - Lev.Async.create (fun async -> - client (); - Lev.Async.stop async loop; - Lev.Async.destroy async) - in - Lev.Async.start server_ready loop; - let () = - let server_fd = socket () in - Unix.set_nonblock server_fd; - Unix.setsockopt server_fd Unix.SO_REUSEADDR true; - Unix.bind server_fd server_sockaddr; - Unix.listen server_fd 10; - client_sockaddr := Some (Unix.getsockname server_fd); - print_endline "server: listening"; - Lev.Async.send server_ready loop; - let io = - Lev.Io.create - (fun io _ _ -> - let client_fd, _sockaddr = Unix.accept ~cloexec:true server_fd in - print_endline "server: accepting client"; - Unix.close client_fd; - print_endline "server: terminating"; - Lev.Io.stop io loop; - Unix.close server_fd; - Lev.Io.destroy io) - server_fd - (Lev.Io.Event.Set.create ~read:true ()) - in - Lev.Io.start io loop - in - Lev.Loop.run_until_done loop; - [%expect - {| - server: listening - client: connecting - server: accepting client - server: terminating |}] diff --git a/submodules/lev/lev/vendor/Changes b/submodules/lev/lev/vendor/Changes deleted file mode 100644 index 2e8b807b6..000000000 --- a/submodules/lev/lev/vendor/Changes +++ /dev/null @@ -1,622 +0,0 @@ -Revision history for libev, a high-performance and full-featured event loop. - -TODO: for next ABI/API change, consider moving EV__IOFDSSET into io->fd instead and provide a getter. -TODO: document EV_TSTAMP_T - - - libev did not compile on systems lacking clock_gettime. - - due to a logic bug, timerfd availability did not always translate - into fewer wakeups - libev is now more aggressive in using - longer sleeps, even when timerfd is not in use. - -4.33 Wed Mar 18 13:22:29 CET 2020 - - no changes w.r.t. 4.32. - -4.32 (EV only) - - the 4.31 timerfd code wrongly changed the priority of the signal - fd watcher, which is usually harmless unless signal fds are - also used (found via cpan tester service). - - the documentation wrongly claimed that user may modify fd and events - members in io watchers when the watcher was stopped - (found by b_jonas). - - new ev_io_modify mutator which changes only the events member, - which can be faster. also added ev::io::set (int events) method - to ev++.h. - - officially allow a zero events mask for io watchers. this should - work with older libev versions as well but was not officially - allowed before. - - do not wake up every minute when timerfd is used to detect timejumps. - - do not wake up every minute when periodics are disabled and we have - a monotonic clock. - - support a lot more "uncommon" compile time configurations, - such as ev_embed enabled but ev_timer disabled. - - use a start/stop wrapper class to reduce code duplication in - ev++.h and make it needlessly more c++-y. - - the linux aio backend is no longer compiled in by default. - - update to libecb version 0x00010008. - -4.31 Fri Dec 20 21:58:29 CET 2019 - - handle backends with minimum wait time a bit better by not - waiting in the presence of already-expired timers - (behaviour reported by Felipe Gasper). - - new feature: use timerfd to detect timejumps quickly, - can be disabled with the new EVFLAG_NOTIMERFD loop flag. - - document EV_USE_SIGNALFD feature macro. - -4.30 (EV only) - - change non-autoconf test for __kernel_rwf_t by testing - LINUX_VERSION_CODE, the most direct test I could find. - - fix a bug in the io_uring backend that polled the wrong - backend fd, causing it to not work in many cases. - -4.29 (EV only) - - add io uring autoconf and non-autoconf detection. - - disable io_uring when some header files are too old. - -4.28 (EV only) - - linuxaio backend resulted in random memory corruption - when loop is forked. - - linuxaio backend might have tried to cancel an iocb - multiple times (was unable to trigger this). - - linuxaio backend now employs a generation counter to - avoid handling spurious events from cancelled requests. - - io_cancel can return EINTR, deal with it. also, assume - io_submit also returns EINTR. - - fix some other minor bugs in linuxaio backend. - - ev_tstamp type can now be overriden by defining EV_TSTAMP_T. - - cleanup: replace expect_true/false and noinline by their - libecb counterparts. - - move syscall infrastructure from ev_linuxaio.c to ev.c. - - prepare io_uring integration. - - tweak ev_floor. - - epoll, poll, win32 Sleep and other places that use millisecond - reslution now all try to round up times. - - solaris port backend didn't compile. - - abstract time constants into their macros, for more flexibility. - -4.27 Thu Jun 27 22:43:44 CEST 2019 - - linux aio backend almost completely rewritten to work around its - limitations. - - linux aio backend now requires linux 4.19+. - - epoll backend now mandatory for linux aio backend. - - fail assertions more aggressively on invalid fd's detected - in the event loop, do not just silently fd_kill in case of - user error. - - ev_io_start/ev_io_stop now verify the watcher fd using - a syscall when EV_VERIFY is 2 or higher. - -4.26 (EV only) - - update to libecb 0x00010006. - - new experimental linux aio backend (linux 4.18+). - - removed redundant 0-ptr check in ev_once. - - updated/extended ev_set_allocator documentation. - - replaced EMPTY2 macro by array_needsize_noinit. - - minor code cleanups. - - epoll backend now uses epoll_create1 also after fork. - -4.25 Fri Dec 21 07:49:20 CET 2018 - - INCOMPATIBLE CHANGE: EV_THROW was renamed to EV_NOEXCEPT - (EV_THROW still provided) and now uses noexcept on C++11 or newer. - - move the darwin select workaround higher in ev.c, as newer versions of - darwin managed to break their broken select even more. - - ANDROID => __ANDROID__ (reported by enh@google.com). - - disable epoll_create1 on android because it has broken header files - and google is unwilling to fix them (reported by enh@google.com). - - avoid a minor compilation warning on win32. - - c++: remove deprecated dynamic throw() specifications. - - c++: improve the (unsupported) bad_loop exception class. - - backport perl ev_periodic example to C, untested. - - update libecb, biggets change is to include a memory fence - in ECB_MEMORY_FENCE_RELEASE on x86/amd64. - - minor autoconf/automake modernisation. - -4.24 Wed Dec 28 05:19:55 CET 2016 - - bump version to 4.24, as the release tarball inexplicably - didn't have the right version in ev.h, even though the cvs-tagged - version did have the right one (reported by Ales Teska). - -4.23 Wed Nov 16 18:23:41 CET 2016 - - move some declarations at the beginning to help certain retarded - microsoft compilers, even though their documentation claims - otherwise (reported by Ruslan Osmanov). - -4.22 Sun Dec 20 22:11:50 CET 2015 - - when epoll detects unremovable fds in the fd set, rebuild - only the epoll descriptor, not the signal pipe, to avoid - SIGPIPE in ev_async_send. This doesn't solve it on fork, - so document what needs to be done in ev_loop_fork - (analyzed by Benjamin Mahler). - - remove superfluous sys/timeb.h include on win32 - (analyzed by Jason Madden). - - updated libecb. - -4.20 Sat Jun 20 13:01:43 CEST 2015 - - prefer noexcept over throw () with C++ 11. - - update ecb.h due to incompatibilities with c11. - - fix a potential aliasing issue when reading and writing - watcher callbacks. - -4.19 Thu Sep 25 08:18:25 CEST 2014 - - ev.h wasn't valid C++ anymore, which tripped compilers other than - clang, msvc or gcc (analyzed by Raphael 'kena' Poss). Unfortunately, - C++ doesn't support typedefs for function pointers fully, so the affected - declarations have to spell out the types each time. - - when not using autoconf, tighten the check for clock_gettime and related - functionality. - -4.18 Fri Sep 5 17:55:26 CEST 2014 - - events on files were not always generated properly with the - epoll backend (testcase by Assaf Inbal). - - mark event pipe fd as cloexec after a fork (analyzed by Sami Farin). - - (ecb) support m68k, m88k and sh (patch by Miod Vallat). - - use a reasonable fallback for EV_NSIG instead of erroring out - when we can't detect the signal set size. - - in the absence of autoconf, do not use the clock syscall - on glibc >= 2.17 (avoids the syscall AND -lrt on systems - doing clock_gettime in userspace). - - ensure extern "C" function pointers are used for externally-visible - loop callbacks (not watcher callbacks yet). - - (ecb) work around memory barriers and volatile apparently both being - broken in visual studio 2008 and later (analysed and patch by Nicolas Noble). - -4.15 Fri Mar 1 12:04:50 CET 2013 - - destroying a non-default loop would stop the global waitpid - watcher (Denis Bilenko). - - queueing pending watchers of higher priority from a watcher now invokes - them in a timely fashion (reported by Denis Bilenko). - - add throw() to all libev functions that cannot throw exceptions, for - further code size decrease when compiling for C++. - - add throw () to callbacks that must not throw exceptions (allocator, - syserr, loop acquire/release, periodic reschedule cbs). - - fix event_base_loop return code, add event_get_callback, event_base_new, - event_base_get_method calls to improve libevent 1.x emulation and add - some libevent 2.x functionality (based on a patch by Jeff Davey). - - add more memory fences to fix a bug reported by Jeff Davey. Better - be overfenced than underprotected. - - ev_run now returns a boolean status (true meaning watchers are - still active). - - ev_once: undef EV_ERROR in ev_kqueue.c, to avoid clashing with - libev's EV_ERROR (reported by 191919). - - (ecb) add memory fence support for xlC (Darin McBride). - - (ecb) add memory fence support for gcc-mips (Anton Kirilov). - - (ecb) add memory fence support for gcc-alpha (Christian Weisgerber). - - work around some kernels losing file descriptors by leaking - the kqueue descriptor in the child. - - work around linux inotify not reporting IN_ATTRIB changes for directories - in many cases. - - include sys/syscall.h instead of plain syscall.h. - - check for io watcher loops in ev_verify, check for the most - common reported usage bug in ev_io_start. - - choose socket vs. WSASocket at compiletime using EV_USE_WSASOCKET. - - always use WSASend/WSARecv directly on windows, hoping that this - works in all cases (unlike read/write/send/recv...). - - try to detect signals around a fork faster (test program by - Denis Bilenko). - - work around recent glibc versions that leak memory in realloc. - - rename ev::embed::set to ev::embed::set_embed to avoid clashing - the watcher base set (loop) method. - - rewrite the async/signal pipe logic to always keep a valid fd, which - simplifies (and hopefully correctifies :) the race checking - on fork, at the cost of one extra fd. - - add fat, msdos, jffs2, ramfs, ntfs and btrfs to the list of - inotify-supporting filesystems. - - move orig_CFLAGS assignment to after AC_INIT, as newer autoconf - versions ignore it before - (https://bugzilla.redhat.com/show_bug.cgi?id=908096). - - add some untested android support. - - enum expressions must be of type int (reported by Juan Pablo L). - -4.11 Sat Feb 4 19:52:39 CET 2012 - - INCOMPATIBLE CHANGE: ev_timer_again now clears the pending status, as - was documented already, but not implemented in the repeating case. - - new compiletime symbols: EV_NO_SMP and EV_NO_THREADS. - - fix a race where the workaround against the epoll fork bugs - caused signals to not be handled anymore. - - correct backend_fudge for most backends, and implement a windows - specific workaround to avoid looping because we call both - select and Sleep, both with different time resolutions. - - document range and guarantees of ev_sleep. - - document reasonable ranges for periodics interval and offset. - - rename backend_fudge to backend_mintime to avoid future confusion :) - - change the default periodic reschedule function to hopefully be more - exact and correct even in corner cases or in the far future. - - do not rely on -lm anymore: use it when available but use our - own floor () if it is missing. This should make it easier to embed, - as no external libraries are required. - - strategically import macros from libecb and mark rarely-used functions - as cache-cold (saving almost 2k code size on typical amd64 setups). - - add Symbols.ev and Symbols.event files, that were missing. - - fix backend_mintime value for epoll (was 1/1024, is 1/1000 now). - - fix #3 "be smart about timeouts" to not "deadlock" when - timeout == now, also improve the section overall. - - avoid "AVOIDING FINISHING BEFORE RETURNING" idiom. - - support new EV_API_STATIC mode to make all libev symbols - static. - - supply default CFLAGS of -g -O3 with gcc when original CFLAGS - were empty. - -4.04 Wed Feb 16 09:01:51 CET 2011 - - fix two problems in the native win32 backend, where reuse of fd's - with different underlying handles caused handles not to be removed - or added to the select set (analyzed and tested by Bert Belder). - - do no rely on ceil() in ev_e?poll.c. - - backport libev to HP-UX versions before 11 v3. - - configure did not detect nanosleep and clock_gettime properly when - they are available in the libc (as opposed to -lrt). - -4.03 Tue Jan 11 14:37:25 CET 2011 - - officially support polling files with all backends. - - support files, /dev/zero etc. the same way as select in the epoll - backend, by generating events on our own. - - ports backend: work around solaris bug 6874410 and many related ones - (EINTR, maybe more), with no performance loss (note that the solaris - bug report is actually wrong, reality is far more bizarre and broken - than that). - - define EV_READ/EV_WRITE as macros in event.h, as some programs use - #ifdef to test for them. - - new (experimental) function: ev_feed_signal. - - new (to become default) EVFLAG_NOSIGMASK flag. - - new EVBACKEND_MASK symbol. - - updated COMMON IDIOMS SECTION. - -4.01 Fri Nov 5 21:51:29 CET 2010 - - automake fucked it up, apparently, --add-missing -f is not quite enough - to make it update its files, so 4.00 didn't install ev++.h and - event.h on make install. grrr. - - ev_loop(count|depth) didn't return anything (Robin Haberkorn). - - change EV_UNDEF to 0xffffffff to silence some overzealous compilers. - - use "(libev) " prefix for all libev error messages now. - -4.00 Mon Oct 25 12:32:12 CEST 2010 - - "PORTING FROM LIBEV 3.X TO 4.X" (in ev.pod) is recommended reading. - - ev_embed_stop did not correctly stop the watcher (very good - testcase by Vladimir Timofeev). - - ev_run will now always update the current loop time - it erroneously - didn't when idle watchers were active, causing timers not to fire. - - fix a bug where a timeout of zero caused the timer not to fire - in the libevent emulation (testcase by Péter Szabó). - - applied win32 fixes by Michael Lenaghan (also James Mansion). - - replace EV_MINIMAL by EV_FEATURES. - - prefer EPOLL_CTL_ADD over EPOLL_CTL_MOD in some more cases, as it - seems the former is *much* faster than the latter. - - linux kernel version detection (for inotify bug workarounds) - did not work properly. - - reduce the number of spurious wake-ups with the ports backend. - - remove dependency on sys/queue.h on freebsd (patch by Vanilla Hsu). - - do async init within ev_async_start, not ev_async_set, which avoids - an API quirk where the set function must be called in the C++ API - even when there is nothing to set. - - add (undocumented) EV_ENABLE when adding events with kqueue, - this might help with OS X, which seems to need it despite documenting - not to need it (helpfully pointed out by Tilghman Lesher). - - do not use poll by default on freebsd, it's broken (what isn't - on freebsd...). - - allow to embed epoll on kernels >= 2.6.32. - - configure now prepends -O3, not appends it, so one can still - override it. - - ev.pod: greatly expanded the portability section, added a porting - section, a description of watcher states and made lots of minor fixes. - - disable poll backend on AIX, the poll header spams the namespace - and it's not worth working around dead platforms (reported - and analyzed by Aivars Kalvans). - - improve header file compatibility of the standalone eventfd code - in an obscure case. - - implement EV_AVOID_STDIO option. - - do not use sscanf to parse linux version number (smaller, faster, - no sscanf dependency). - - new EV_CHILD_ENABLE and EV_SIGNAL_ENABLE configurable settings. - - update libev.m4 HAVE_CLOCK_SYSCALL test for newer glibcs. - - add section on accept() problems to the manpage. - - rename EV_TIMEOUT to EV_TIMER. - - rename ev_loop_count/depth/verify/loop/unloop. - - remove ev_default_destroy and ev_default_fork. - - switch to two-digit minor version. - - work around an apparent gentoo compiler bug. - - define _DARWIN_UNLIMITED_SELECT. just so. - - use enum instead of #define for most constants. - - improve compatibility to older C++ compilers. - - (experimental) ev_run/ev_default_loop/ev_break/ev_loop_new have now - default arguments when compiled as C++. - - enable automake dependency tracking. - - ev_loop_new no longer leaks memory when loop creation failed. - - new ev_cleanup watcher type. - -3.9 Thu Dec 31 07:59:59 CET 2009 - - signalfd is no longer used by default and has to be requested - explicitly - this means that easy to catch bugs become hard to - catch race conditions, but the users have spoken. - - point out the unspecified signal mask in the documentation, and - that this is a race condition regardless of EV_SIGNALFD. - - backport inotify code to C89. - - inotify file descriptors could leak into child processes. - - ev_stat watchers could keep an erroneous extra ref on the loop, - preventing exit when unregistering all watchers (testcases - provided by ry@tinyclouds.org). - - implement EV_WIN32_HANDLE_TO_FD and EV_WIN32_CLOSE_FD configuration - symbols to make it easier for apps to do their own fd management. - - support EV_IDLE_ENABLE being disabled in ev++.h - (patch by Didier Spezia). - - take advantage of inotify_init1, if available, to set cloexec/nonblock - on fd creation, to avoid races. - - the signal handling pipe wasn't always initialised under windows - (analysed by lekma). - - changed minimum glibc requirement from glibc 2.9 to 2.7, for - signalfd. - - add missing string.h include (Denis F. Latypoff). - - only replace ev_stat.prev when we detect an actual difference, - so prev is (almost) always different to attr. this might - have caused the problems with 04_stat.t. - - add ev::timer->remaining () method to C++ API. - -3.8 Sun Aug 9 14:30:45 CEST 2009 - - incompatible change: do not necessarily reset signal handler - to SIG_DFL when a sighandler is stopped. - - ev_default_destroy did not properly free or zero some members, - potentially causing crashes and memory corruption on repeated - ev_default_destroy/ev_default_loop calls. - - take advantage of signalfd on GNU/Linux systems. - - document that the signal mask might be in an unspecified - state when using libev's signal handling. - - take advantage of some GNU/Linux calls to set cloexec/nonblock - on fd creation, to avoid race conditions. - -3.7 Fri Jul 17 16:36:32 CEST 2009 - - ev_unloop and ev_loop wrongly used a global variable to exit loops, - instead of using a per-loop variable (bug caught by accident...). - - the ev_set_io_collect_interval interpretation has changed. - - add new functionality: ev_set_userdata, ev_userdata, - ev_set_invoke_pending_cb, ev_set_loop_release_cb, - ev_invoke_pending, ev_pending_count, together with a long example - about thread locking. - - add ev_timer_remaining (as requested by Denis F. Latypoff). - - add ev_loop_depth. - - calling ev_unloop in fork/prepare watchers will no longer poll - for new events. - - Denis F. Latypoff corrected many typos in example code snippets. - - honor autoconf detection of EV_USE_CLOCK_SYSCALL, also double- - check that the syscall number is available before trying to - use it (reported by ry@tinyclouds). - - use GetSystemTimeAsFileTime instead of _timeb on windows, for - slightly higher accuracy. - - properly declare ev_loop_verify and ev_now_update even when - !EV_MULTIPLICITY. - - do not compile in any priority code when EV_MAXPRI == EV_MINPRI. - - support EV_MINIMAL==2 for a reduced API. - - actually 0-initialise struct sigaction when installing signals. - - add section on hibernate and stopped processes to ev_timer docs. - -3.6 Tue Apr 28 02:49:30 CEST 2009 - - multiple timers becoming ready within an event loop iteration - will be invoked in the "correct" order now. - - do not leave the event loop early just because we have no active - watchers, fixing a problem when embedding a kqueue loop - that has active kernel events but no registered watchers - (reported by blacksand blacksand). - - correctly zero the idx values for arrays, so destroying and - reinitialising the default loop actually works (patch by - Malek Hadj-Ali). - - implement ev_suspend and ev_resume. - - new EV_CUSTOM revents flag for use by applications. - - add documentation section about priorities. - - add a glossary to the documentation. - - extend the ev_fork description slightly. - - optimize a jump out of call_pending. - -3.53 Sun Feb 15 02:38:20 CET 2009 - - fix a bug in event pipe creation on win32 that would cause a - failed assertion on event loop creation (patch by Malek Hadj-Ali). - - probe for CLOCK_REALTIME support at runtime as well and fall - back to gettimeofday if there is an error, to support older - operating systems with newer header files/libraries. - - prefer gettimeofday over clock_gettime with USE_CLOCK_SYSCALL - (default most everywhere), otherwise not. - -3.52 Wed Jan 7 21:43:02 CET 2009 - - fix compilation of select backend in fd_set mode when NFDBITS is - missing (to get it to compile on QNX, reported by Rodrigo Campos). - - better select-nfds handling when select backend is in fd_set mode. - - diagnose fd_set overruns when select backend is in fd_set mode. - - due to a thinko, instead of disabling everything but - select on the borked OS X platform, everything but select was - allowed (reported by Emanuele Giaquinta). - - actually verify that local and remote port are matching in - libev's socketpair emulation, which makes denial-of-service - attacks harder (but not impossible - it's windows). Make sure - it even works under vista, which thinks that getpeer/sockname - should return fantasy port numbers. - - include "libev" in all assertion messages for potentially - clearer diagnostics. - - event_get_version (libevent compatibility) returned - a useless string instead of the expected version string - (patch by W.C.A. Wijngaards). - -3.51 Wed Dec 24 23:00:11 CET 2008 - - fix a bug where an inotify watcher was added twice, causing - freezes on hash collisions (reported and analysed by Graham Leggett). - - new config symbol, EV_USE_CLOCK_SYSCALL, to make libev use - a direct syscall - slower, but no dependency on librt et al. - - assume negative return values != -1 signals success of port_getn - (http://cvs.epicsol.org/cgi/viewcvs.cgi/epic5/source/newio.c?rev=1.52) - (no known failure reports, but it doesn't hurt). - - fork detection in ev_embed now stops and restarts the watcher - automatically. - - EXPERIMENTAL: default the method to operator () in ev++.h, - to make it nicer to use functors (requested by Benedek László). - - fixed const object callbacks in ev++.h. - - replaced loop_ref argument of watcher.set (loop) by a direct - ev_loop * in ev++.h, to avoid clashes with functor patch. - - do not try to watch the empty string via inotify. - - inotify watchers could be leaked under certain circumstances. - - OS X 10.5 is actually even more broken than earlier versions, - so fall back to select on that piece of garbage. - - fixed some weirdness in the ev_embed documentation. - -3.49 Wed Nov 19 11:26:53 CET 2008 - - ev_stat watchers will now use inotify as a mere hint on - kernels <2.6.25, or if the filesystem is not in the - "known to be good" list. - - better mingw32 compatibility (it's not as borked as native win32) - (analysed by Roger Pack). - - include stdio.h in the example program, as too many people are - confused by the weird C language otherwise. I guess the next thing - I get told is that the "..." ellipses in the examples don't compile - with their C compiler. - -3.48 Thu Oct 30 09:02:37 CET 2008 - - further optimise away the EPOLL_CTL_ADD/MOD combo in the epoll - backend by assuming the kernel event mask hasn't changed if - ADD fails with EEXIST. - - work around spurious event notification bugs in epoll by using - a 32-bit generation counter. recreate kernel state if we receive - spurious notifications or unwanted events. this is very costly, - but I didn't come up with this horrible design. - - use memset to initialise most arrays now and do away with the - init functions. - - expand time-out strategies into a "Be smart about timeouts" section. - - drop the "struct" from all ev_watcher declarations in the - documentation and did other clarifications (yeah, it was a mistake - to have a struct AND a function called ev_loop). - - fix a bug where ev_default would not initialise the default - loop again after it was destroyed with ev_default_destroy. - - rename syserr to ev_syserr to avoid name clashes when embedding, - do similar changes for event.c. - -3.45 Tue Oct 21 21:59:26 CEST 2008 - - disable inotify usage on linux <2.6.25, as it is broken - (reported by Yoann Vandoorselaere). - - ev_stat erroneously would try to add inotify watchers - even when inotify wasn't available (this should only - have a performance impact). - - ev_once now passes both timeout and io to the callback if both - occur concurrently, instead of giving timeouts precedence. - - disable EV_USE_INOTIFY when sys/inotify.h is too old. - -3.44 Mon Sep 29 05:18:39 CEST 2008 - - embed watchers now automatically invoke ev_loop_fork on the - embedded loop when the parent loop forks. - - new function: ev_now_update (loop). - - verify_watcher was not marked static. - - improve the "associating..." manpage section. - - documentation tweaks here and there. - -3.43 Sun Jul 6 05:34:41 CEST 2008 - - include more include files on windows to get struct _stati64 - (reported by Chris Hulbert, but doesn't quite fix his issue). - - add missing #include in ev.c on windows (reported by - Matt Tolton). - -3.42 Tue Jun 17 12:12:07 CEST 2008 - - work around yet another windows bug: FD_SET actually adds fd's - multiple times to the fd_*SET*, despite official MSN docs claiming - otherwise. Reported and well-analysed by Matt Tolton. - - define NFDBITS to 0 when EV_SELECT_IS_WINSOCKET to make it compile - (reported any analysed by Chris Hulbert). - - fix a bug in ev_ebadf (this function is only used to catch - programming errors in the libev user). reported by Matt Tolton. - - fix a bug in fd_intern on win32 (could lead to compile errors - under some circumstances, but would work correctly if it compiles). - reported by Matt Tolton. - - (try to) work around missing lstat on windows. - - pass in the write fd set as except fd set under windows. windows - is so uncontrollably lame that it requires this. this means that - switching off oobinline is not supported (but tcp/ip doesn't - have oob, so that would be stupid anyways. - - use posix module symbol to auto-detect monotonic clock presence - and some other default values. - -3.41 Fri May 23 18:42:54 CEST 2008 - - work around an obscure bug in winsocket select: if you - provide only empty fd sets then select returns WSAEINVAL. how sucky. - - improve timer scheduling stability and reduce use of time_epsilon. - - use 1-based 2-heap for EV_MINIMAL, simplifies code, reduces - codesize and makes for better cache-efficiency. - - use 3-based 4-heap for !EV_MINIMAL. this makes better use - of cpu cache lines and gives better growth behaviour than - 2-based heaps. - - cache timestamp within heap for !EV_MINIMAL, to avoid random - memory accesses. - - document/add EV_USE_4HEAP and EV_HEAP_CACHE_AT. - - fix a potential aliasing issue in ev_timer_again. - - add/document ev_periodic_at, retract direct access to ->at. - - improve ev_stat docs. - - add portability requirements section. - - fix manpage headers etc. - - normalise WSA error codes to lower range on windows. - - add consistency check code that can be called automatically - or on demand to check for internal structures (ev_loop_verify). - -3.31 Wed Apr 16 20:45:04 CEST 2008 - - added last minute fix for ev_poll.c by Brandon Black. - -3.3 Wed Apr 16 19:04:10 CEST 2008 - - event_base_loopexit should return 0 on success - (W.C.A. Wijngaards). - - added linux eventfd support. - - try to autodetect epoll and inotify support - by libc header version if not using autoconf. - - new symbols: EV_DEFAULT_UC and EV_DEFAULT_UC_. - - declare functions defined in ev.h as inline if - C99 or gcc are available. - - enable inlining with gcc versions 2 and 3. - - work around broken poll implementations potentially - not clearing revents field in ev_poll (Brandon Black) - (no such systems are known at this time). - - work around a bug in realloc on openbsd and darwin, - also makes the erroneous valgrind complaints - go away (noted by various people). - - fix ev_async_pending, add c++ wrapper for ev_async - (based on patch sent by Johannes Deisenhofer). - - add sensible set method to ev::embed. - - made integer constants type int in ev.h. - -3.2 Wed Apr 2 17:11:19 CEST 2008 - - fix a 64 bit overflow issue in the select backend, - by using fd_mask instead of int for the mask. - - rename internal sighandler to avoid clash with very old perls. - - entering ev_loop will not clear the ONESHOT or NONBLOCKING - flags of any outer loops anymore. - - add ev_async_pending. - -3.1 Thu Mar 13 13:45:22 CET 2008 - - implement ev_async watchers. - - only initialise signal pipe on demand. - - make use of sig_atomic_t configurable. - - improved documentation. - -3.0 Mon Jan 28 13:14:47 CET 2008 - - API/ABI bump to version 3.0. - - ev++.h includes "ev.h" by default now, not . - - slightly improved documentation. - - speed up signal detection after a fork. - - only optionally return trace status changed in ev_child - watchers. - - experimental (and undocumented) loop wrappers for ev++.h. - -2.01 Tue Dec 25 08:04:41 CET 2007 - - separate Changes file. - - fix ev_path_set => ev_stat_set typo. - - remove event_compat.h from the libev tarball. - - change how include files are found. - - doc updates. - - update licenses, explicitly allow for GPL relicensing. - -2.0 Sat Dec 22 17:47:03 CET 2007 - - new ev_sleep, ev_set_(io|timeout)_collect_interval. - - removed epoll from embeddable fd set. - - fix embed watchers. - - renamed ev_embed.loop to other. - - added exported Symbol tables. - - undefine member wrapper macros at the end of ev.c. - - respect EV_H in ev++.h. - -1.86 Tue Dec 18 02:36:57 CET 2007 - - fix memleak on loop destroy (not relevant for perl). - -1.85 Fri Dec 14 20:32:40 CET 2007 - - fix some aliasing issues w.r.t. timers and periodics - (not relevant for perl). - -(for historic versions refer to EV/Changes, found in the Perl interface) - -0.1 Wed Oct 31 21:31:48 CET 2007 - - original version; hacked together in <24h. - diff --git a/submodules/lev/lev/vendor/LICENSE b/submodules/lev/lev/vendor/LICENSE deleted file mode 100644 index 2fdabd48a..000000000 --- a/submodules/lev/lev/vendor/LICENSE +++ /dev/null @@ -1,37 +0,0 @@ -All files in libev are -Copyright (c)2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Alternatively, the contents of this package may be used under the terms -of the GNU General Public License ("GPL") version 2 or any later version, -in which case the provisions of the GPL are applicable instead of the -above. If you wish to allow the use of your version of this package only -under the terms of the GPL and not to allow others to use your version of -this file under the BSD license, indicate your decision by deleting the -provisions above and replace them with the notice and other provisions -required by the GPL in this and the other files of this package. If you do -not delete the provisions above, a recipient may use your version of this -file under either the BSD or the GPL. diff --git a/submodules/lev/lev/vendor/Makefile.am b/submodules/lev/lev/vendor/Makefile.am deleted file mode 100644 index 2814622d8..000000000 --- a/submodules/lev/lev/vendor/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -AUTOMAKE_OPTIONS = foreign - -VERSION_INFO = 4:0:0 - -EXTRA_DIST = LICENSE Changes libev.m4 autogen.sh \ - ev_vars.h ev_wrap.h \ - ev_epoll.c ev_select.c ev_poll.c ev_kqueue.c ev_port.c ev_linuxaio.c ev_iouring.c \ - ev_win32.c \ - ev.3 ev.pod Symbols.ev Symbols.event - -man_MANS = ev.3 - -include_HEADERS = ev.h ev++.h event.h - -lib_LTLIBRARIES = libev.la - -libev_la_SOURCES = ev.c event.c -libev_la_LDFLAGS = -version-info $(VERSION_INFO) - -ev.3: ev.pod - pod2man -n LIBEV -r "libev-$(VERSION)" -c "libev - high performance full featured event loop" -s3 <$< >$@ diff --git a/submodules/lev/lev/vendor/README b/submodules/lev/lev/vendor/README deleted file mode 100644 index a6da69a61..000000000 --- a/submodules/lev/lev/vendor/README +++ /dev/null @@ -1,59 +0,0 @@ -libev is a high-performance event loop/event model with lots of features. -(see benchmark at http://libev.schmorp.de/bench.html) - - -ABOUT - - Homepage: http://software.schmorp.de/pkg/libev - Mailinglist: libev@lists.schmorp.de - http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev - Library Documentation: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod - - Libev is modelled (very losely) after libevent and the Event perl - module, but is faster, scales better and is more correct, and also more - featureful. And also smaller. Yay. - - Some of the specialties of libev not commonly found elsewhere are: - - - extensive and detailed, readable documentation (not doxygen garbage). - - fully supports fork, can detect fork in various ways and automatically - re-arms kernel mechanisms that do not support fork. - - highly optimised select, poll, linux epoll, linux aio, bsd kqueue - and solaris event ports backends. - - filesystem object (path) watching (with optional linux inotify support). - - wallclock-based times (using absolute time, cron-like). - - relative timers/timeouts (handle time jumps). - - fast intra-thread communication between multiple - event loops (with optional fast linux eventfd backend). - - extremely easy to embed (fully documented, no dependencies, - autoconf supported but optional). - - very small codebase, no bloated library, simple code. - - fully extensible by being able to plug into the event loop, - integrate other event loops, integrate other event loop users. - - very little memory use (small watchers, small event loop data). - - optional C++ interface allowing method and function callbacks - at no extra memory or runtime overhead. - - optional Perl interface with similar characteristics (capable - of running Glib/Gtk2 on libev). - - support for other languages (multiple C++ interfaces, D, Ruby, - Python) available from third-parties. - - Examples of programs that embed libev: the EV perl module, auditd, - rxvt-unicode, gvpe (GNU Virtual Private Ethernet), the Deliantra MMORPG - server (http://www.deliantra.net/), Rubinius (a next-generation Ruby - VM), the Ebb web server, the Rev event toolkit. - - -CONTRIBUTORS - - libev was written and designed by Marc Lehmann and Emanuele Giaquinta. - - The following people sent in patches or made other noteworthy - contributions to the design (for minor patches, see the Changes - file. If I forgot to include you, please shout at me, it was an - accident): - - W.C.A. Wijngaards - Christopher Layne - Chris Brody - diff --git a/submodules/lev/lev/vendor/README.embed b/submodules/lev/lev/vendor/README.embed deleted file mode 100644 index 0d1bd5e19..000000000 --- a/submodules/lev/lev/vendor/README.embed +++ /dev/null @@ -1,3 +0,0 @@ -This file is now included in the main libev documentation, see - - http://cvs.schmorp.de/libev/ev.html diff --git a/submodules/lev/lev/vendor/Symbols.ev b/submodules/lev/lev/vendor/Symbols.ev deleted file mode 100644 index fe169fa06..000000000 --- a/submodules/lev/lev/vendor/Symbols.ev +++ /dev/null @@ -1,73 +0,0 @@ -ev_async_send -ev_async_start -ev_async_stop -ev_backend -ev_break -ev_check_start -ev_check_stop -ev_child_start -ev_child_stop -ev_cleanup_start -ev_cleanup_stop -ev_clear_pending -ev_default_loop -ev_default_loop_ptr -ev_depth -ev_embeddable_backends -ev_embed_start -ev_embed_stop -ev_embed_sweep -ev_feed_event -ev_feed_fd_event -ev_feed_signal -ev_feed_signal_event -ev_fork_start -ev_fork_stop -ev_idle_start -ev_idle_stop -ev_invoke -ev_invoke_pending -ev_io_start -ev_io_stop -ev_iteration -ev_loop_destroy -ev_loop_fork -ev_loop_new -ev_now -ev_now_update -ev_once -ev_pending_count -ev_periodic_again -ev_periodic_start -ev_periodic_stop -ev_prepare_start -ev_prepare_stop -ev_recommended_backends -ev_ref -ev_resume -ev_run -ev_set_allocator -ev_set_invoke_pending_cb -ev_set_io_collect_interval -ev_set_loop_release_cb -ev_set_syserr_cb -ev_set_timeout_collect_interval -ev_set_userdata -ev_signal_start -ev_signal_stop -ev_sleep -ev_stat_start -ev_stat_stat -ev_stat_stop -ev_supported_backends -ev_suspend -ev_time -ev_timer_again -ev_timer_remaining -ev_timer_start -ev_timer_stop -ev_unref -ev_userdata -ev_verify -ev_version_major -ev_version_minor diff --git a/submodules/lev/lev/vendor/Symbols.event b/submodules/lev/lev/vendor/Symbols.event deleted file mode 100644 index 799d4246e..000000000 --- a/submodules/lev/lev/vendor/Symbols.event +++ /dev/null @@ -1,24 +0,0 @@ -event_active -event_add -event_base_dispatch -event_base_free -event_base_get_method -event_base_loop -event_base_loopexit -event_base_new -event_base_once -event_base_priority_init -event_base_set -event_del -event_dispatch -event_get_callback -event_get_method -event_get_version -event_init -event_loop -event_loopexit -event_once -event_pending -event_priority_init -event_priority_set -event_set diff --git a/submodules/lev/lev/vendor/autogen.sh b/submodules/lev/lev/vendor/autogen.sh deleted file mode 100644 index 8056ee7f9..000000000 --- a/submodules/lev/lev/vendor/autogen.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -autoreconf --install --symlink --force diff --git a/submodules/lev/lev/vendor/configure.ac b/submodules/lev/lev/vendor/configure.ac deleted file mode 100644 index 196640b56..000000000 --- a/submodules/lev/lev/vendor/configure.ac +++ /dev/null @@ -1,27 +0,0 @@ -dnl also update ev.h! -AC_INIT([libev], [4.33]) - -orig_CFLAGS="$CFLAGS" - -AC_CONFIG_SRCDIR([ev_epoll.c]) -AM_INIT_AUTOMAKE - -AC_CONFIG_HEADERS([config.h]) -AM_MAINTAINER_MODE - -AC_PROG_CC - -dnl Supply default CFLAGS, if not specified -if test -z "$orig_CFLAGS"; then - if test x$GCC = xyes; then - CFLAGS="-g -O3" - fi -fi - -AC_PROG_INSTALL -AC_PROG_LIBTOOL - -m4_include([libev.m4]) - -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT diff --git a/submodules/lev/lev/vendor/ev++.h b/submodules/lev/lev/vendor/ev++.h deleted file mode 100644 index 22dfcf58d..000000000 --- a/submodules/lev/lev/vendor/ev++.h +++ /dev/null @@ -1,818 +0,0 @@ -/* - * libev simple C++ wrapper classes - * - * Copyright (c) 2007,2008,2010,2018,2020 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#ifndef EVPP_H__ -#define EVPP_H__ - -#ifdef EV_H -# include EV_H -#else -# include "ev.h" -#endif - -#ifndef EV_USE_STDEXCEPT -# define EV_USE_STDEXCEPT 1 -#endif - -#if EV_USE_STDEXCEPT -# include -#endif - -namespace ev { - - typedef ev_tstamp tstamp; - - enum { - UNDEF = EV_UNDEF, - NONE = EV_NONE, - READ = EV_READ, - WRITE = EV_WRITE, -#if EV_COMPAT3 - TIMEOUT = EV_TIMEOUT, -#endif - TIMER = EV_TIMER, - PERIODIC = EV_PERIODIC, - SIGNAL = EV_SIGNAL, - CHILD = EV_CHILD, - STAT = EV_STAT, - IDLE = EV_IDLE, - CHECK = EV_CHECK, - PREPARE = EV_PREPARE, - FORK = EV_FORK, - ASYNC = EV_ASYNC, - EMBED = EV_EMBED, -# undef ERROR // some systems stupidly #define ERROR - ERROR = EV_ERROR - }; - - enum - { - AUTO = EVFLAG_AUTO, - NOENV = EVFLAG_NOENV, - FORKCHECK = EVFLAG_FORKCHECK, - - SELECT = EVBACKEND_SELECT, - POLL = EVBACKEND_POLL, - EPOLL = EVBACKEND_EPOLL, - KQUEUE = EVBACKEND_KQUEUE, - DEVPOLL = EVBACKEND_DEVPOLL, - PORT = EVBACKEND_PORT - }; - - enum - { -#if EV_COMPAT3 - NONBLOCK = EVLOOP_NONBLOCK, - ONESHOT = EVLOOP_ONESHOT, -#endif - NOWAIT = EVRUN_NOWAIT, - ONCE = EVRUN_ONCE - }; - - enum how_t - { - ONE = EVBREAK_ONE, - ALL = EVBREAK_ALL - }; - - struct bad_loop -#if EV_USE_STDEXCEPT - : std::exception -#endif - { -#if EV_USE_STDEXCEPT - const char *what () const EV_NOEXCEPT - { - return "libev event loop cannot be initialized, bad value of LIBEV_FLAGS?"; - } -#endif - }; - -#ifdef EV_AX -# undef EV_AX -#endif - -#ifdef EV_AX_ -# undef EV_AX_ -#endif - -#if EV_MULTIPLICITY -# define EV_AX raw_loop -# define EV_AX_ raw_loop, -#else -# define EV_AX -# define EV_AX_ -#endif - - struct loop_ref - { - loop_ref (EV_P) EV_NOEXCEPT -#if EV_MULTIPLICITY - : EV_AX (EV_A) -#endif - { - } - - bool operator == (const loop_ref &other) const EV_NOEXCEPT - { -#if EV_MULTIPLICITY - return EV_AX == other.EV_AX; -#else - return true; -#endif - } - - bool operator != (const loop_ref &other) const EV_NOEXCEPT - { -#if EV_MULTIPLICITY - return ! (*this == other); -#else - return false; -#endif - } - -#if EV_MULTIPLICITY - bool operator == (const EV_P) const EV_NOEXCEPT - { - return this->EV_AX == EV_A; - } - - bool operator != (const EV_P) const EV_NOEXCEPT - { - return ! (*this == EV_A); - } - - operator struct ev_loop * () const EV_NOEXCEPT - { - return EV_AX; - } - - operator const struct ev_loop * () const EV_NOEXCEPT - { - return EV_AX; - } - - bool is_default () const EV_NOEXCEPT - { - return EV_AX == ev_default_loop (0); - } -#endif - -#if EV_COMPAT3 - void loop (int flags = 0) - { - ev_run (EV_AX_ flags); - } - - void unloop (how_t how = ONE) EV_NOEXCEPT - { - ev_break (EV_AX_ how); - } -#endif - - void run (int flags = 0) - { - ev_run (EV_AX_ flags); - } - - void break_loop (how_t how = ONE) EV_NOEXCEPT - { - ev_break (EV_AX_ how); - } - - void post_fork () EV_NOEXCEPT - { - ev_loop_fork (EV_AX); - } - - unsigned int backend () const EV_NOEXCEPT - { - return ev_backend (EV_AX); - } - - tstamp now () const EV_NOEXCEPT - { - return ev_now (EV_AX); - } - - void ref () EV_NOEXCEPT - { - ev_ref (EV_AX); - } - - void unref () EV_NOEXCEPT - { - ev_unref (EV_AX); - } - -#if EV_FEATURE_API - unsigned int iteration () const EV_NOEXCEPT - { - return ev_iteration (EV_AX); - } - - unsigned int depth () const EV_NOEXCEPT - { - return ev_depth (EV_AX); - } - - void set_io_collect_interval (tstamp interval) EV_NOEXCEPT - { - ev_set_io_collect_interval (EV_AX_ interval); - } - - void set_timeout_collect_interval (tstamp interval) EV_NOEXCEPT - { - ev_set_timeout_collect_interval (EV_AX_ interval); - } -#endif - - // function callback - void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void *arg = 0) EV_NOEXCEPT - { - ev_once (EV_AX_ fd, events, timeout, cb, arg); - } - - // method callback - template - void once (int fd, int events, tstamp timeout, K *object) EV_NOEXCEPT - { - once (fd, events, timeout, method_thunk, object); - } - - // default method == operator () - template - void once (int fd, int events, tstamp timeout, K *object) EV_NOEXCEPT - { - once (fd, events, timeout, method_thunk, object); - } - - template - static void method_thunk (int revents, void *arg) - { - (static_cast(arg)->*method) - (revents); - } - - // no-argument method callback - template - void once (int fd, int events, tstamp timeout, K *object) EV_NOEXCEPT - { - once (fd, events, timeout, method_noargs_thunk, object); - } - - template - static void method_noargs_thunk (int revents, void *arg) - { - (static_cast(arg)->*method) - (); - } - - // simpler function callback - template - void once (int fd, int events, tstamp timeout) EV_NOEXCEPT - { - once (fd, events, timeout, simpler_func_thunk); - } - - template - static void simpler_func_thunk (int revents, void *arg) - { - (*cb) - (revents); - } - - // simplest function callback - template - void once (int fd, int events, tstamp timeout) EV_NOEXCEPT - { - once (fd, events, timeout, simplest_func_thunk); - } - - template - static void simplest_func_thunk (int revents, void *arg) - { - (*cb) - (); - } - - void feed_fd_event (int fd, int revents) EV_NOEXCEPT - { - ev_feed_fd_event (EV_AX_ fd, revents); - } - - void feed_signal_event (int signum) EV_NOEXCEPT - { - ev_feed_signal_event (EV_AX_ signum); - } - -#if EV_MULTIPLICITY - struct ev_loop* EV_AX; -#endif - - }; - -#if EV_MULTIPLICITY - struct dynamic_loop : loop_ref - { - - dynamic_loop (unsigned int flags = AUTO) - : loop_ref (ev_loop_new (flags)) - { - if (!EV_AX) - throw bad_loop (); - } - - ~dynamic_loop () EV_NOEXCEPT - { - ev_loop_destroy (EV_AX); - EV_AX = 0; - } - - private: - - dynamic_loop (const dynamic_loop &); - - dynamic_loop & operator= (const dynamic_loop &); - - }; -#endif - - struct default_loop : loop_ref - { - default_loop (unsigned int flags = AUTO) -#if EV_MULTIPLICITY - : loop_ref (ev_default_loop (flags)) -#endif - { - if ( -#if EV_MULTIPLICITY - !EV_AX -#else - !ev_default_loop (flags) -#endif - ) - throw bad_loop (); - } - - private: - default_loop (const default_loop &); - default_loop &operator = (const default_loop &); - }; - - inline loop_ref get_default_loop () EV_NOEXCEPT - { -#if EV_MULTIPLICITY - return ev_default_loop (0); -#else - return loop_ref (); -#endif - } - -#undef EV_AX -#undef EV_AX_ - -#undef EV_PX -#undef EV_PX_ -#if EV_MULTIPLICITY -# define EV_PX loop_ref EV_A -# define EV_PX_ loop_ref EV_A_ -#else -# define EV_PX -# define EV_PX_ -#endif - - template - struct base : ev_watcher - { - // scoped pause/unpause of a watcher - struct freeze_guard - { - watcher &w; - bool active; - - freeze_guard (watcher *self) EV_NOEXCEPT - : w (*self), active (w.is_active ()) - { - if (active) w.stop (); - } - - ~freeze_guard () - { - if (active) w.start (); - } - }; - - #if EV_MULTIPLICITY - EV_PX; - - // loop set - void set (EV_P) EV_NOEXCEPT - { - this->EV_A = EV_A; - } - #endif - - base (EV_PX) EV_NOEXCEPT - #if EV_MULTIPLICITY - : EV_A (EV_A) - #endif - { - ev_init (this, 0); - } - - void set_ (const void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) EV_NOEXCEPT - { - this->data = (void *)data; - ev_set_cb (static_cast(this), cb); - } - - // function callback - template - void set (void *data = 0) EV_NOEXCEPT - { - set_ (data, function_thunk); - } - - template - static void function_thunk (EV_P_ ev_watcher *w, int revents) - { - function - (*static_cast(w), revents); - } - - // method callback - template - void set (K *object) EV_NOEXCEPT - { - set_ (object, method_thunk); - } - - // default method == operator () - template - void set (K *object) EV_NOEXCEPT - { - set_ (object, method_thunk); - } - - template - static void method_thunk (EV_P_ ev_watcher *w, int revents) - { - (static_cast(w->data)->*method) - (*static_cast(w), revents); - } - - // no-argument callback - template - void set (K *object) EV_NOEXCEPT - { - set_ (object, method_noargs_thunk); - } - - template - static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents) - { - (static_cast(w->data)->*method) - (); - } - - void operator ()(int events = EV_UNDEF) - { - return - ev_cb (static_cast(this)) - (static_cast(this), events); - } - - bool is_active () const EV_NOEXCEPT - { - return ev_is_active (static_cast(this)); - } - - bool is_pending () const EV_NOEXCEPT - { - return ev_is_pending (static_cast(this)); - } - - void feed_event (int revents) EV_NOEXCEPT - { - ev_feed_event (EV_A_ static_cast(this), revents); - } - }; - - inline tstamp now (EV_P) EV_NOEXCEPT - { - return ev_now (EV_A); - } - - inline void delay (tstamp interval) EV_NOEXCEPT - { - ev_sleep (interval); - } - - inline int version_major () EV_NOEXCEPT - { - return ev_version_major (); - } - - inline int version_minor () EV_NOEXCEPT - { - return ev_version_minor (); - } - - inline unsigned int supported_backends () EV_NOEXCEPT - { - return ev_supported_backends (); - } - - inline unsigned int recommended_backends () EV_NOEXCEPT - { - return ev_recommended_backends (); - } - - inline unsigned int embeddable_backends () EV_NOEXCEPT - { - return ev_embeddable_backends (); - } - - inline void set_allocator (void *(*cb)(void *ptr, long size) EV_NOEXCEPT) EV_NOEXCEPT - { - ev_set_allocator (cb); - } - - inline void set_syserr_cb (void (*cb)(const char *msg) EV_NOEXCEPT) EV_NOEXCEPT - { - ev_set_syserr_cb (cb); - } - - #if EV_MULTIPLICITY - #define EV_CONSTRUCT(cppstem,cstem) \ - (EV_PX = get_default_loop ()) EV_NOEXCEPT \ - : base (EV_A) \ - { \ - } - #else - #define EV_CONSTRUCT(cppstem,cstem) \ - () EV_NOEXCEPT \ - { \ - } - #endif - - /* using a template here would require quite a few more lines, - * so a macro solution was chosen */ - #define EV_BEGIN_WATCHER(cppstem,cstem) \ - \ - struct cppstem : base \ - { \ - void start () EV_NOEXCEPT \ - { \ - ev_ ## cstem ## _start (EV_A_ static_cast(this)); \ - } \ - \ - void stop () EV_NOEXCEPT \ - { \ - ev_ ## cstem ## _stop (EV_A_ static_cast(this)); \ - } \ - \ - cppstem EV_CONSTRUCT(cppstem,cstem) \ - \ - ~cppstem () EV_NOEXCEPT \ - { \ - stop (); \ - } \ - \ - using base::set; \ - \ - private: \ - \ - cppstem (const cppstem &o); \ - \ - cppstem &operator =(const cppstem &o); \ - \ - public: - - #define EV_END_WATCHER(cppstem,cstem) \ - }; - - EV_BEGIN_WATCHER (io, io) - void set (int fd, int events) EV_NOEXCEPT - { - freeze_guard freeze (this); - ev_io_set (static_cast(this), fd, events); - } - - void set (int events) EV_NOEXCEPT - { - freeze_guard freeze (this); - ev_io_modify (static_cast(this), events); - } - - void start (int fd, int events) EV_NOEXCEPT - { - set (fd, events); - start (); - } - EV_END_WATCHER (io, io) - - EV_BEGIN_WATCHER (timer, timer) - void set (ev_tstamp after, ev_tstamp repeat = 0.) EV_NOEXCEPT - { - freeze_guard freeze (this); - ev_timer_set (static_cast(this), after, repeat); - } - - void start (ev_tstamp after, ev_tstamp repeat = 0.) EV_NOEXCEPT - { - set (after, repeat); - start (); - } - - void again () EV_NOEXCEPT - { - ev_timer_again (EV_A_ static_cast(this)); - } - - ev_tstamp remaining () - { - return ev_timer_remaining (EV_A_ static_cast(this)); - } - EV_END_WATCHER (timer, timer) - - #if EV_PERIODIC_ENABLE - EV_BEGIN_WATCHER (periodic, periodic) - void set (ev_tstamp at, ev_tstamp interval = 0.) EV_NOEXCEPT - { - freeze_guard freeze (this); - ev_periodic_set (static_cast(this), at, interval, 0); - } - - void start (ev_tstamp at, ev_tstamp interval = 0.) EV_NOEXCEPT - { - set (at, interval); - start (); - } - - void again () EV_NOEXCEPT - { - ev_periodic_again (EV_A_ static_cast(this)); - } - EV_END_WATCHER (periodic, periodic) - #endif - - #if EV_SIGNAL_ENABLE - EV_BEGIN_WATCHER (sig, signal) - void set (int signum) EV_NOEXCEPT - { - freeze_guard freeze (this); - ev_signal_set (static_cast(this), signum); - } - - void start (int signum) EV_NOEXCEPT - { - set (signum); - start (); - } - EV_END_WATCHER (sig, signal) - #endif - - #if EV_CHILD_ENABLE - EV_BEGIN_WATCHER (child, child) - void set (int pid, int trace = 0) EV_NOEXCEPT - { - freeze_guard freeze (this); - ev_child_set (static_cast(this), pid, trace); - } - - void start (int pid, int trace = 0) EV_NOEXCEPT - { - set (pid, trace); - start (); - } - EV_END_WATCHER (child, child) - #endif - - #if EV_STAT_ENABLE - EV_BEGIN_WATCHER (stat, stat) - void set (const char *path, ev_tstamp interval = 0.) EV_NOEXCEPT - { - freeze_guard freeze (this); - ev_stat_set (static_cast(this), path, interval); - } - - void start (const char *path, ev_tstamp interval = 0.) EV_NOEXCEPT - { - stop (); - set (path, interval); - start (); - } - - void update () EV_NOEXCEPT - { - ev_stat_stat (EV_A_ static_cast(this)); - } - EV_END_WATCHER (stat, stat) - #endif - - #if EV_IDLE_ENABLE - EV_BEGIN_WATCHER (idle, idle) - void set () EV_NOEXCEPT { } - EV_END_WATCHER (idle, idle) - #endif - - #if EV_PREPARE_ENABLE - EV_BEGIN_WATCHER (prepare, prepare) - void set () EV_NOEXCEPT { } - EV_END_WATCHER (prepare, prepare) - #endif - - #if EV_CHECK_ENABLE - EV_BEGIN_WATCHER (check, check) - void set () EV_NOEXCEPT { } - EV_END_WATCHER (check, check) - #endif - - #if EV_EMBED_ENABLE - EV_BEGIN_WATCHER (embed, embed) - void set_embed (struct ev_loop *embedded_loop) EV_NOEXCEPT - { - freeze_guard freeze (this); - ev_embed_set (static_cast(this), embedded_loop); - } - - void start (struct ev_loop *embedded_loop) EV_NOEXCEPT - { - set (embedded_loop); - start (); - } - - void sweep () - { - ev_embed_sweep (EV_A_ static_cast(this)); - } - EV_END_WATCHER (embed, embed) - #endif - - #if EV_FORK_ENABLE - EV_BEGIN_WATCHER (fork, fork) - void set () EV_NOEXCEPT { } - EV_END_WATCHER (fork, fork) - #endif - - #if EV_ASYNC_ENABLE - EV_BEGIN_WATCHER (async, async) - void send () EV_NOEXCEPT - { - ev_async_send (EV_A_ static_cast(this)); - } - - bool async_pending () EV_NOEXCEPT - { - return ev_async_pending (static_cast(this)); - } - EV_END_WATCHER (async, async) - #endif - - #undef EV_PX - #undef EV_PX_ - #undef EV_CONSTRUCT - #undef EV_BEGIN_WATCHER - #undef EV_END_WATCHER -} - -#endif - diff --git a/submodules/lev/lev/vendor/ev.3 b/submodules/lev/lev/vendor/ev.3 deleted file mode 100644 index d13f247c9..000000000 --- a/submodules/lev/lev/vendor/ev.3 +++ /dev/null @@ -1,5819 +0,0 @@ -.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. \*(C+ will -.\" give a nicer C++. Capital omega is used to do unbreakable dashes and -.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, -.\" nothing in troff, for use with C<>. -.tr \(*W- -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -'br\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -. ds C` -. ds C' -'br\} -.\" -.\" Escape single quotes in literal strings from groff's Unicode transform. -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" -.\" If the F register is >0, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.\" -.\" Avoid warning from groff about undefined register 'F'. -.de IX -.. -.nr rF 0 -.if \n(.g .if rF .nr rF 1 -.if (\n(rF:(\n(.g==0)) \{\ -. if \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. if !\nF==2 \{\ -. nr % 0 -. nr F 2 -. \} -. \} -.\} -.rr rF -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "LIBEV 3" -.TH LIBEV 3 "2021-01-11" "libev-4.33" "libev - high performance full featured event loop" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.if n .ad l -.nh -.SH "NAME" -libev \- a high performance full\-featured event loop written in C -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -.Vb 1 -\& #include -.Ve -.SS "\s-1EXAMPLE PROGRAM\s0" -.IX Subsection "EXAMPLE PROGRAM" -.Vb 2 -\& // a single header file is required -\& #include -\& -\& #include // for puts -\& -\& // every watcher type has its own typedef\*(Aqd struct -\& // with the name ev_TYPE -\& ev_io stdin_watcher; -\& ev_timer timeout_watcher; -\& -\& // all watcher callbacks have a similar signature -\& // this callback is called when data is readable on stdin -\& static void -\& stdin_cb (EV_P_ ev_io *w, int revents) -\& { -\& puts ("stdin ready"); -\& // for one\-shot events, one must manually stop the watcher -\& // with its corresponding stop function. -\& ev_io_stop (EV_A_ w); -\& -\& // this causes all nested ev_run\*(Aqs to stop iterating -\& ev_break (EV_A_ EVBREAK_ALL); -\& } -\& -\& // another callback, this time for a time\-out -\& static void -\& timeout_cb (EV_P_ ev_timer *w, int revents) -\& { -\& puts ("timeout"); -\& // this causes the innermost ev_run to stop iterating -\& ev_break (EV_A_ EVBREAK_ONE); -\& } -\& -\& int -\& main (void) -\& { -\& // use the default event loop unless you have special needs -\& struct ev_loop *loop = EV_DEFAULT; -\& -\& // initialise an io watcher, then start it -\& // this one will watch for stdin to become readable -\& ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); -\& ev_io_start (loop, &stdin_watcher); -\& -\& // initialise a timer watcher, then start it -\& // simple non\-repeating 5.5 second timeout -\& ev_timer_init (&timeout_watcher, timeout_cb, 5.5, 0.); -\& ev_timer_start (loop, &timeout_watcher); -\& -\& // now wait for events to arrive -\& ev_run (loop, 0); -\& -\& // break was called, so exit -\& return 0; -\& } -.Ve -.SH "ABOUT THIS DOCUMENT" -.IX Header "ABOUT THIS DOCUMENT" -This document documents the libev software package. -.PP -The newest version of this document is also available as an html-formatted -web page you might find easier to navigate when reading it for the first -time: . -.PP -While this document tries to be as complete as possible in documenting -libev, its usage and the rationale behind its design, it is not a tutorial -on event-based programming, nor will it introduce event-based programming -with libev. -.PP -Familiarity with event based programming techniques in general is assumed -throughout this document. -.SH "WHAT TO READ WHEN IN A HURRY" -.IX Header "WHAT TO READ WHEN IN A HURRY" -This manual tries to be very detailed, but unfortunately, this also makes -it very long. If you just want to know the basics of libev, I suggest -reading \*(L"\s-1ANATOMY OF A WATCHER\*(R"\s0, then the \*(L"\s-1EXAMPLE PROGRAM\*(R"\s0 above and -look up the missing functions in \*(L"\s-1GLOBAL FUNCTIONS\*(R"\s0 and the \f(CW\*(C`ev_io\*(C'\fR and -\&\f(CW\*(C`ev_timer\*(C'\fR sections in \*(L"\s-1WATCHER TYPES\*(R"\s0. -.SH "ABOUT LIBEV" -.IX Header "ABOUT LIBEV" -Libev is an event loop: you register interest in certain events (such as a -file descriptor being readable or a timeout occurring), and it will manage -these event sources and provide your program with events. -.PP -To do this, it must take more or less complete control over your process -(or thread) by executing the \fIevent loop\fR handler, and will then -communicate events via a callback mechanism. -.PP -You register interest in certain events by registering so-called \fIevent -watchers\fR, which are relatively small C structures you initialise with the -details of the event, and then hand it over to libev by \fIstarting\fR the -watcher. -.SS "\s-1FEATURES\s0" -.IX Subsection "FEATURES" -Libev supports \f(CW\*(C`select\*(C'\fR, \f(CW\*(C`poll\*(C'\fR, the Linux-specific aio and \f(CW\*(C`epoll\*(C'\fR -interfaces, the BSD-specific \f(CW\*(C`kqueue\*(C'\fR and the Solaris-specific event port -mechanisms for file descriptor events (\f(CW\*(C`ev_io\*(C'\fR), the Linux \f(CW\*(C`inotify\*(C'\fR -interface (for \f(CW\*(C`ev_stat\*(C'\fR), Linux eventfd/signalfd (for faster and cleaner -inter-thread wakeup (\f(CW\*(C`ev_async\*(C'\fR)/signal handling (\f(CW\*(C`ev_signal\*(C'\fR)) relative -timers (\f(CW\*(C`ev_timer\*(C'\fR), absolute timers with customised rescheduling -(\f(CW\*(C`ev_periodic\*(C'\fR), synchronous signals (\f(CW\*(C`ev_signal\*(C'\fR), process status -change events (\f(CW\*(C`ev_child\*(C'\fR), and event watchers dealing with the event -loop mechanism itself (\f(CW\*(C`ev_idle\*(C'\fR, \f(CW\*(C`ev_embed\*(C'\fR, \f(CW\*(C`ev_prepare\*(C'\fR and -\&\f(CW\*(C`ev_check\*(C'\fR watchers) as well as file watchers (\f(CW\*(C`ev_stat\*(C'\fR) and even -limited support for fork events (\f(CW\*(C`ev_fork\*(C'\fR). -.PP -It also is quite fast (see this -benchmark comparing it to libevent -for example). -.SS "\s-1CONVENTIONS\s0" -.IX Subsection "CONVENTIONS" -Libev is very configurable. In this manual the default (and most common) -configuration will be described, which supports multiple event loops. For -more info about various configuration options please have a look at -\&\fB\s-1EMBED\s0\fR section in this manual. If libev was configured without support -for multiple event loops, then all functions taking an initial argument of -name \f(CW\*(C`loop\*(C'\fR (which is always of type \f(CW\*(C`struct ev_loop *\*(C'\fR) will not have -this argument. -.SS "\s-1TIME REPRESENTATION\s0" -.IX Subsection "TIME REPRESENTATION" -Libev represents time as a single floating point number, representing -the (fractional) number of seconds since the (\s-1POSIX\s0) epoch (in practice -somewhere near the beginning of 1970, details are complicated, don't -ask). This type is called \f(CW\*(C`ev_tstamp\*(C'\fR, which is what you should use -too. It usually aliases to the \f(CW\*(C`double\*(C'\fR type in C. When you need to do -any calculations on it, you should treat it as some floating point value. -.PP -Unlike the name component \f(CW\*(C`stamp\*(C'\fR might indicate, it is also used for -time differences (e.g. delays) throughout libev. -.SH "ERROR HANDLING" -.IX Header "ERROR HANDLING" -Libev knows three classes of errors: operating system errors, usage errors -and internal errors (bugs). -.PP -When libev catches an operating system error it cannot handle (for example -a system call indicating a condition libev cannot fix), it calls the callback -set via \f(CW\*(C`ev_set_syserr_cb\*(C'\fR, which is supposed to fix the problem or -abort. The default is to print a diagnostic message and to call \f(CW\*(C`abort -()\*(C'\fR. -.PP -When libev detects a usage error such as a negative timer interval, then -it will print a diagnostic message and abort (via the \f(CW\*(C`assert\*(C'\fR mechanism, -so \f(CW\*(C`NDEBUG\*(C'\fR will disable this checking): these are programming errors in -the libev caller and need to be fixed there. -.PP -Via the \f(CW\*(C`EV_FREQUENT\*(C'\fR macro you can compile in and/or enable extensive -consistency checking code inside libev that can be used to check for -internal inconsistencies, suually caused by application bugs. -.PP -Libev also has a few internal error-checking \f(CW\*(C`assert\*(C'\fRions. These do not -trigger under normal circumstances, as they indicate either a bug in libev -or worse. -.SH "GLOBAL FUNCTIONS" -.IX Header "GLOBAL FUNCTIONS" -These functions can be called anytime, even before initialising the -library in any way. -.IP "ev_tstamp ev_time ()" 4 -.IX Item "ev_tstamp ev_time ()" -Returns the current time as libev would use it. Please note that the -\&\f(CW\*(C`ev_now\*(C'\fR function is usually faster and also often returns the timestamp -you actually want to know. Also interesting is the combination of -\&\f(CW\*(C`ev_now_update\*(C'\fR and \f(CW\*(C`ev_now\*(C'\fR. -.IP "ev_sleep (ev_tstamp interval)" 4 -.IX Item "ev_sleep (ev_tstamp interval)" -Sleep for the given interval: The current thread will be blocked -until either it is interrupted or the given time interval has -passed (approximately \- it might return a bit earlier even if not -interrupted). Returns immediately if \f(CW\*(C`interval <= 0\*(C'\fR. -.Sp -Basically this is a sub-second-resolution \f(CW\*(C`sleep ()\*(C'\fR. -.Sp -The range of the \f(CW\*(C`interval\*(C'\fR is limited \- libev only guarantees to work -with sleep times of up to one day (\f(CW\*(C`interval <= 86400\*(C'\fR). -.IP "int ev_version_major ()" 4 -.IX Item "int ev_version_major ()" -.PD 0 -.IP "int ev_version_minor ()" 4 -.IX Item "int ev_version_minor ()" -.PD -You can find out the major and minor \s-1ABI\s0 version numbers of the library -you linked against by calling the functions \f(CW\*(C`ev_version_major\*(C'\fR and -\&\f(CW\*(C`ev_version_minor\*(C'\fR. If you want, you can compare against the global -symbols \f(CW\*(C`EV_VERSION_MAJOR\*(C'\fR and \f(CW\*(C`EV_VERSION_MINOR\*(C'\fR, which specify the -version of the library your program was compiled against. -.Sp -These version numbers refer to the \s-1ABI\s0 version of the library, not the -release version. -.Sp -Usually, it's a good idea to terminate if the major versions mismatch, -as this indicates an incompatible change. Minor versions are usually -compatible to older versions, so a larger minor version alone is usually -not a problem. -.Sp -Example: Make sure we haven't accidentally been linked against the wrong -version (note, however, that this will not detect other \s-1ABI\s0 mismatches, -such as \s-1LFS\s0 or reentrancy). -.Sp -.Vb 3 -\& assert (("libev version mismatch", -\& ev_version_major () == EV_VERSION_MAJOR -\& && ev_version_minor () >= EV_VERSION_MINOR)); -.Ve -.IP "unsigned int ev_supported_backends ()" 4 -.IX Item "unsigned int ev_supported_backends ()" -Return the set of all backends (i.e. their corresponding \f(CW\*(C`EV_BACKEND_*\*(C'\fR -value) compiled into this binary of libev (independent of their -availability on the system you are running on). See \f(CW\*(C`ev_default_loop\*(C'\fR for -a description of the set values. -.Sp -Example: make sure we have the epoll method, because yeah this is cool and -a must have and can we have a torrent of it please!!!11 -.Sp -.Vb 2 -\& assert (("sorry, no epoll, no sex", -\& ev_supported_backends () & EVBACKEND_EPOLL)); -.Ve -.IP "unsigned int ev_recommended_backends ()" 4 -.IX Item "unsigned int ev_recommended_backends ()" -Return the set of all backends compiled into this binary of libev and -also recommended for this platform, meaning it will work for most file -descriptor types. This set is often smaller than the one returned by -\&\f(CW\*(C`ev_supported_backends\*(C'\fR, as for example kqueue is broken on most BSDs -and will not be auto-detected unless you explicitly request it (assuming -you know what you are doing). This is the set of backends that libev will -probe for if you specify no backends explicitly. -.IP "unsigned int ev_embeddable_backends ()" 4 -.IX Item "unsigned int ev_embeddable_backends ()" -Returns the set of backends that are embeddable in other event loops. This -value is platform-specific but can include backends not available on the -current system. To find which embeddable backends might be supported on -the current system, you would need to look at \f(CW\*(C`ev_embeddable_backends () -& ev_supported_backends ()\*(C'\fR, likewise for recommended ones. -.Sp -See the description of \f(CW\*(C`ev_embed\*(C'\fR watchers for more info. -.IP "ev_set_allocator (void *(*cb)(void *ptr, long size) throw ())" 4 -.IX Item "ev_set_allocator (void *(*cb)(void *ptr, long size) throw ())" -Sets the allocation function to use (the prototype is similar \- the -semantics are identical to the \f(CW\*(C`realloc\*(C'\fR C89/SuS/POSIX function). It is -used to allocate and free memory (no surprises here). If it returns zero -when memory needs to be allocated (\f(CW\*(C`size != 0\*(C'\fR), the library might abort -or take some potentially destructive action. -.Sp -Since some systems (at least OpenBSD and Darwin) fail to implement -correct \f(CW\*(C`realloc\*(C'\fR semantics, libev will use a wrapper around the system -\&\f(CW\*(C`realloc\*(C'\fR and \f(CW\*(C`free\*(C'\fR functions by default. -.Sp -You could override this function in high-availability programs to, say, -free some memory if it cannot allocate memory, to use a special allocator, -or even to sleep a while and retry until some memory is available. -.Sp -Example: The following is the \f(CW\*(C`realloc\*(C'\fR function that libev itself uses -which should work with \f(CW\*(C`realloc\*(C'\fR and \f(CW\*(C`free\*(C'\fR functions of all kinds and -is probably a good basis for your own implementation. -.Sp -.Vb 5 -\& static void * -\& ev_realloc_emul (void *ptr, long size) EV_NOEXCEPT -\& { -\& if (size) -\& return realloc (ptr, size); -\& -\& free (ptr); -\& return 0; -\& } -.Ve -.Sp -Example: Replace the libev allocator with one that waits a bit and then -retries. -.Sp -.Vb 8 -\& static void * -\& persistent_realloc (void *ptr, size_t size) -\& { -\& if (!size) -\& { -\& free (ptr); -\& return 0; -\& } -\& -\& for (;;) -\& { -\& void *newptr = realloc (ptr, size); -\& -\& if (newptr) -\& return newptr; -\& -\& sleep (60); -\& } -\& } -\& -\& ... -\& ev_set_allocator (persistent_realloc); -.Ve -.IP "ev_set_syserr_cb (void (*cb)(const char *msg) throw ())" 4 -.IX Item "ev_set_syserr_cb (void (*cb)(const char *msg) throw ())" -Set the callback function to call on a retryable system call error (such -as failed select, poll, epoll_wait). The message is a printable string -indicating the system call or subsystem causing the problem. If this -callback is set, then libev will expect it to remedy the situation, no -matter what, when it returns. That is, libev will generally retry the -requested operation, or, if the condition doesn't go away, do bad stuff -(such as abort). -.Sp -Example: This is basically the same thing that libev does internally, too. -.Sp -.Vb 6 -\& static void -\& fatal_error (const char *msg) -\& { -\& perror (msg); -\& abort (); -\& } -\& -\& ... -\& ev_set_syserr_cb (fatal_error); -.Ve -.IP "ev_feed_signal (int signum)" 4 -.IX Item "ev_feed_signal (int signum)" -This function can be used to \*(L"simulate\*(R" a signal receive. It is completely -safe to call this function at any time, from any context, including signal -handlers or random threads. -.Sp -Its main use is to customise signal handling in your process, especially -in the presence of threads. For example, you could block signals -by default in all threads (and specifying \f(CW\*(C`EVFLAG_NOSIGMASK\*(C'\fR when -creating any loops), and in one thread, use \f(CW\*(C`sigwait\*(C'\fR or any other -mechanism to wait for signals, then \*(L"deliver\*(R" them to libev by calling -\&\f(CW\*(C`ev_feed_signal\*(C'\fR. -.SH "FUNCTIONS CONTROLLING EVENT LOOPS" -.IX Header "FUNCTIONS CONTROLLING EVENT LOOPS" -An event loop is described by a \f(CW\*(C`struct ev_loop *\*(C'\fR (the \f(CW\*(C`struct\*(C'\fR is -\&\fInot\fR optional in this case unless libev 3 compatibility is disabled, as -libev 3 had an \f(CW\*(C`ev_loop\*(C'\fR function colliding with the struct name). -.PP -The library knows two types of such loops, the \fIdefault\fR loop, which -supports child process events, and dynamically created event loops which -do not. -.IP "struct ev_loop *ev_default_loop (unsigned int flags)" 4 -.IX Item "struct ev_loop *ev_default_loop (unsigned int flags)" -This returns the \*(L"default\*(R" event loop object, which is what you should -normally use when you just need \*(L"the event loop\*(R". Event loop objects and -the \f(CW\*(C`flags\*(C'\fR parameter are described in more detail in the entry for -\&\f(CW\*(C`ev_loop_new\*(C'\fR. -.Sp -If the default loop is already initialised then this function simply -returns it (and ignores the flags. If that is troubling you, check -\&\f(CW\*(C`ev_backend ()\*(C'\fR afterwards). Otherwise it will create it with the given -flags, which should almost always be \f(CW0\fR, unless the caller is also the -one calling \f(CW\*(C`ev_run\*(C'\fR or otherwise qualifies as \*(L"the main program\*(R". -.Sp -If you don't know what event loop to use, use the one returned from this -function (or via the \f(CW\*(C`EV_DEFAULT\*(C'\fR macro). -.Sp -Note that this function is \fInot\fR thread-safe, so if you want to use it -from multiple threads, you have to employ some kind of mutex (note also -that this case is unlikely, as loops cannot be shared easily between -threads anyway). -.Sp -The default loop is the only loop that can handle \f(CW\*(C`ev_child\*(C'\fR watchers, -and to do this, it always registers a handler for \f(CW\*(C`SIGCHLD\*(C'\fR. If this is -a problem for your application you can either create a dynamic loop with -\&\f(CW\*(C`ev_loop_new\*(C'\fR which doesn't do that, or you can simply overwrite the -\&\f(CW\*(C`SIGCHLD\*(C'\fR signal handler \fIafter\fR calling \f(CW\*(C`ev_default_init\*(C'\fR. -.Sp -Example: This is the most typical usage. -.Sp -.Vb 2 -\& if (!ev_default_loop (0)) -\& fatal ("could not initialise libev, bad $LIBEV_FLAGS in environment?"); -.Ve -.Sp -Example: Restrict libev to the select and poll backends, and do not allow -environment settings to be taken into account: -.Sp -.Vb 1 -\& ev_default_loop (EVBACKEND_POLL | EVBACKEND_SELECT | EVFLAG_NOENV); -.Ve -.IP "struct ev_loop *ev_loop_new (unsigned int flags)" 4 -.IX Item "struct ev_loop *ev_loop_new (unsigned int flags)" -This will create and initialise a new event loop object. If the loop -could not be initialised, returns false. -.Sp -This function is thread-safe, and one common way to use libev with -threads is indeed to create one loop per thread, and using the default -loop in the \*(L"main\*(R" or \*(L"initial\*(R" thread. -.Sp -The flags argument can be used to specify special behaviour or specific -backends to use, and is usually specified as \f(CW0\fR (or \f(CW\*(C`EVFLAG_AUTO\*(C'\fR). -.Sp -The following flags are supported: -.RS 4 -.ie n .IP """EVFLAG_AUTO""" 4 -.el .IP "\f(CWEVFLAG_AUTO\fR" 4 -.IX Item "EVFLAG_AUTO" -The default flags value. Use this if you have no clue (it's the right -thing, believe me). -.ie n .IP """EVFLAG_NOENV""" 4 -.el .IP "\f(CWEVFLAG_NOENV\fR" 4 -.IX Item "EVFLAG_NOENV" -If this flag bit is or'ed into the flag value (or the program runs setuid -or setgid) then libev will \fInot\fR look at the environment variable -\&\f(CW\*(C`LIBEV_FLAGS\*(C'\fR. Otherwise (the default), this environment variable will -override the flags completely if it is found in the environment. This is -useful to try out specific backends to test their performance, to work -around bugs, or to make libev threadsafe (accessing environment variables -cannot be done in a threadsafe way, but usually it works if no other -thread modifies them). -.ie n .IP """EVFLAG_FORKCHECK""" 4 -.el .IP "\f(CWEVFLAG_FORKCHECK\fR" 4 -.IX Item "EVFLAG_FORKCHECK" -Instead of calling \f(CW\*(C`ev_loop_fork\*(C'\fR manually after a fork, you can also -make libev check for a fork in each iteration by enabling this flag. -.Sp -This works by calling \f(CW\*(C`getpid ()\*(C'\fR on every iteration of the loop, -and thus this might slow down your event loop if you do a lot of loop -iterations and little real work, but is usually not noticeable (on my -GNU/Linux system for example, \f(CW\*(C`getpid\*(C'\fR is actually a simple 5\-insn -sequence without a system call and thus \fIvery\fR fast, but my GNU/Linux -system also has \f(CW\*(C`pthread_atfork\*(C'\fR which is even faster). (Update: glibc -versions 2.25 apparently removed the \f(CW\*(C`getpid\*(C'\fR optimisation again). -.Sp -The big advantage of this flag is that you can forget about fork (and -forget about forgetting to tell libev about forking, although you still -have to ignore \f(CW\*(C`SIGPIPE\*(C'\fR) when you use this flag. -.Sp -This flag setting cannot be overridden or specified in the \f(CW\*(C`LIBEV_FLAGS\*(C'\fR -environment variable. -.ie n .IP """EVFLAG_NOINOTIFY""" 4 -.el .IP "\f(CWEVFLAG_NOINOTIFY\fR" 4 -.IX Item "EVFLAG_NOINOTIFY" -When this flag is specified, then libev will not attempt to use the -\&\fIinotify\fR \s-1API\s0 for its \f(CW\*(C`ev_stat\*(C'\fR watchers. Apart from debugging and -testing, this flag can be useful to conserve inotify file descriptors, as -otherwise each loop using \f(CW\*(C`ev_stat\*(C'\fR watchers consumes one inotify handle. -.ie n .IP """EVFLAG_SIGNALFD""" 4 -.el .IP "\f(CWEVFLAG_SIGNALFD\fR" 4 -.IX Item "EVFLAG_SIGNALFD" -When this flag is specified, then libev will attempt to use the -\&\fIsignalfd\fR \s-1API\s0 for its \f(CW\*(C`ev_signal\*(C'\fR (and \f(CW\*(C`ev_child\*(C'\fR) watchers. This \s-1API\s0 -delivers signals synchronously, which makes it both faster and might make -it possible to get the queued signal data. It can also simplify signal -handling with threads, as long as you properly block signals in your -threads that are not interested in handling them. -.Sp -Signalfd will not be used by default as this changes your signal mask, and -there are a lot of shoddy libraries and programs (glib's threadpool for -example) that can't properly initialise their signal masks. -.ie n .IP """EVFLAG_NOSIGMASK""" 4 -.el .IP "\f(CWEVFLAG_NOSIGMASK\fR" 4 -.IX Item "EVFLAG_NOSIGMASK" -When this flag is specified, then libev will avoid to modify the signal -mask. Specifically, this means you have to make sure signals are unblocked -when you want to receive them. -.Sp -This behaviour is useful when you want to do your own signal handling, or -want to handle signals only in specific threads and want to avoid libev -unblocking the signals. -.Sp -It's also required by \s-1POSIX\s0 in a threaded program, as libev calls -\&\f(CW\*(C`sigprocmask\*(C'\fR, whose behaviour is officially unspecified. -.ie n .IP """EVFLAG_NOTIMERFD""" 4 -.el .IP "\f(CWEVFLAG_NOTIMERFD\fR" 4 -.IX Item "EVFLAG_NOTIMERFD" -When this flag is specified, the libev will avoid using a \f(CW\*(C`timerfd\*(C'\fR to -detect time jumps. It will still be able to detect time jumps, but takes -longer and has a lower accuracy in doing so, but saves a file descriptor -per loop. -.Sp -The current implementation only tries to use a \f(CW\*(C`timerfd\*(C'\fR when the first -\&\f(CW\*(C`ev_periodic\*(C'\fR watcher is started and falls back on other methods if it -cannot be created, but this behaviour might change in the future. -.ie n .IP """EVBACKEND_SELECT"" (value 1, portable select backend)" 4 -.el .IP "\f(CWEVBACKEND_SELECT\fR (value 1, portable select backend)" 4 -.IX Item "EVBACKEND_SELECT (value 1, portable select backend)" -This is your standard \fBselect\fR\|(2) backend. Not \fIcompletely\fR standard, as -libev tries to roll its own fd_set with no limits on the number of fds, -but if that fails, expect a fairly low limit on the number of fds when -using this backend. It doesn't scale too well (O(highest_fd)), but its -usually the fastest backend for a low number of (low-numbered :) fds. -.Sp -To get good performance out of this backend you need a high amount of -parallelism (most of the file descriptors should be busy). If you are -writing a server, you should \f(CW\*(C`accept ()\*(C'\fR in a loop to accept as many -connections as possible during one iteration. You might also want to have -a look at \f(CW\*(C`ev_set_io_collect_interval ()\*(C'\fR to increase the amount of -readiness notifications you get per iteration. -.Sp -This backend maps \f(CW\*(C`EV_READ\*(C'\fR to the \f(CW\*(C`readfds\*(C'\fR set and \f(CW\*(C`EV_WRITE\*(C'\fR to the -\&\f(CW\*(C`writefds\*(C'\fR set (and to work around Microsoft Windows bugs, also onto the -\&\f(CW\*(C`exceptfds\*(C'\fR set on that platform). -.ie n .IP """EVBACKEND_POLL"" (value 2, poll backend, available everywhere except on windows)" 4 -.el .IP "\f(CWEVBACKEND_POLL\fR (value 2, poll backend, available everywhere except on windows)" 4 -.IX Item "EVBACKEND_POLL (value 2, poll backend, available everywhere except on windows)" -And this is your standard \fBpoll\fR\|(2) backend. It's more complicated -than select, but handles sparse fds better and has no artificial -limit on the number of fds you can use (except it will slow down -considerably with a lot of inactive fds). It scales similarly to select, -i.e. O(total_fds). See the entry for \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR, above, for -performance tips. -.Sp -This backend maps \f(CW\*(C`EV_READ\*(C'\fR to \f(CW\*(C`POLLIN | POLLERR | POLLHUP\*(C'\fR, and -\&\f(CW\*(C`EV_WRITE\*(C'\fR to \f(CW\*(C`POLLOUT | POLLERR | POLLHUP\*(C'\fR. -.ie n .IP """EVBACKEND_EPOLL"" (value 4, Linux)" 4 -.el .IP "\f(CWEVBACKEND_EPOLL\fR (value 4, Linux)" 4 -.IX Item "EVBACKEND_EPOLL (value 4, Linux)" -Use the Linux-specific \fBepoll\fR\|(7) interface (for both pre\- and post\-2.6.9 -kernels). -.Sp -For few fds, this backend is a bit little slower than poll and select, but -it scales phenomenally better. While poll and select usually scale like -O(total_fds) where total_fds is the total number of fds (or the highest -fd), epoll scales either O(1) or O(active_fds). -.Sp -The epoll mechanism deserves honorable mention as the most misdesigned -of the more advanced event mechanisms: mere annoyances include silently -dropping file descriptors, requiring a system call per change per file -descriptor (and unnecessary guessing of parameters), problems with dup, -returning before the timeout value, resulting in additional iterations -(and only giving 5ms accuracy while select on the same platform gives -0.1ms) and so on. The biggest issue is fork races, however \- if a program -forks then \fIboth\fR parent and child process have to recreate the epoll -set, which can take considerable time (one syscall per file descriptor) -and is of course hard to detect. -.Sp -Epoll is also notoriously buggy \- embedding epoll fds \fIshould\fR work, -but of course \fIdoesn't\fR, and epoll just loves to report events for -totally \fIdifferent\fR file descriptors (even already closed ones, so -one cannot even remove them from the set) than registered in the set -(especially on \s-1SMP\s0 systems). Libev tries to counter these spurious -notifications by employing an additional generation counter and comparing -that against the events to filter out spurious ones, recreating the set -when required. Epoll also erroneously rounds down timeouts, but gives you -no way to know when and by how much, so sometimes you have to busy-wait -because epoll returns immediately despite a nonzero timeout. And last -not least, it also refuses to work with some file descriptors which work -perfectly fine with \f(CW\*(C`select\*(C'\fR (files, many character devices...). -.Sp -Epoll is truly the train wreck among event poll mechanisms, a frankenpoll, -cobbled together in a hurry, no thought to design or interaction with -others. Oh, the pain, will it ever stop... -.Sp -While stopping, setting and starting an I/O watcher in the same iteration -will result in some caching, there is still a system call per such -incident (because the same \fIfile descriptor\fR could point to a different -\&\fIfile description\fR now), so its best to avoid that. Also, \f(CW\*(C`dup ()\*(C'\fR'ed -file descriptors might not work very well if you register events for both -file descriptors. -.Sp -Best performance from this backend is achieved by not unregistering all -watchers for a file descriptor until it has been closed, if possible, -i.e. keep at least one watcher active per fd at all times. Stopping and -starting a watcher (without re-setting it) also usually doesn't cause -extra overhead. A fork can both result in spurious notifications as well -as in libev having to destroy and recreate the epoll object, which can -take considerable time and thus should be avoided. -.Sp -All this means that, in practice, \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR can be as fast or -faster than epoll for maybe up to a hundred file descriptors, depending on -the usage. So sad. -.Sp -While nominally embeddable in other event loops, this feature is broken in -a lot of kernel revisions, but probably(!) works in current versions. -.Sp -This backend maps \f(CW\*(C`EV_READ\*(C'\fR and \f(CW\*(C`EV_WRITE\*(C'\fR in the same way as -\&\f(CW\*(C`EVBACKEND_POLL\*(C'\fR. -.ie n .IP """EVBACKEND_LINUXAIO"" (value 64, Linux)" 4 -.el .IP "\f(CWEVBACKEND_LINUXAIO\fR (value 64, Linux)" 4 -.IX Item "EVBACKEND_LINUXAIO (value 64, Linux)" -Use the Linux-specific Linux \s-1AIO\s0 (\fInot\fR \f(CWaio(7)\fR but \f(CWio_submit(2)\fR) event interface available in post\-4.18 kernels (but libev -only tries to use it in 4.19+). -.Sp -This is another Linux train wreck of an event interface. -.Sp -If this backend works for you (as of this writing, it was very -experimental), it is the best event interface available on Linux and might -be well worth enabling it \- if it isn't available in your kernel this will -be detected and this backend will be skipped. -.Sp -This backend can batch oneshot requests and supports a user-space ring -buffer to receive events. It also doesn't suffer from most of the design -problems of epoll (such as not being able to remove event sources from -the epoll set), and generally sounds too good to be true. Because, this -being the Linux kernel, of course it suffers from a whole new set of -limitations, forcing you to fall back to epoll, inheriting all its design -issues. -.Sp -For one, it is not easily embeddable (but probably could be done using -an event fd at some extra overhead). It also is subject to a system wide -limit that can be configured in \fI/proc/sys/fs/aio\-max\-nr\fR. If no \s-1AIO\s0 -requests are left, this backend will be skipped during initialisation, and -will switch to epoll when the loop is active. -.Sp -Most problematic in practice, however, is that not all file descriptors -work with it. For example, in Linux 5.1, \s-1TCP\s0 sockets, pipes, event fds, -files, \fI/dev/null\fR and many others are supported, but ttys do not work -properly (a known bug that the kernel developers don't care about, see -), so this is not -(yet?) a generic event polling interface. -.Sp -Overall, it seems the Linux developers just don't want it to have a -generic event handling mechanism other than \f(CW\*(C`select\*(C'\fR or \f(CW\*(C`poll\*(C'\fR. -.Sp -To work around all these problem, the current version of libev uses its -epoll backend as a fallback for file descriptor types that do not work. Or -falls back completely to epoll if the kernel acts up. -.Sp -This backend maps \f(CW\*(C`EV_READ\*(C'\fR and \f(CW\*(C`EV_WRITE\*(C'\fR in the same way as -\&\f(CW\*(C`EVBACKEND_POLL\*(C'\fR. -.ie n .IP """EVBACKEND_KQUEUE"" (value 8, most \s-1BSD\s0 clones)" 4 -.el .IP "\f(CWEVBACKEND_KQUEUE\fR (value 8, most \s-1BSD\s0 clones)" 4 -.IX Item "EVBACKEND_KQUEUE (value 8, most BSD clones)" -Kqueue deserves special mention, as at the time this backend was -implemented, it was broken on all BSDs except NetBSD (usually it doesn't -work reliably with anything but sockets and pipes, except on Darwin, -where of course it's completely useless). Unlike epoll, however, whose -brokenness is by design, these kqueue bugs can be (and mostly have been) -fixed without \s-1API\s0 changes to existing programs. For this reason it's not -being \*(L"auto-detected\*(R" on all platforms unless you explicitly specify it -in the flags (i.e. using \f(CW\*(C`EVBACKEND_KQUEUE\*(C'\fR) or libev was compiled on a -known-to-be-good (\-enough) system like NetBSD. -.Sp -You still can embed kqueue into a normal poll or select backend and use it -only for sockets (after having made sure that sockets work with kqueue on -the target platform). See \f(CW\*(C`ev_embed\*(C'\fR watchers for more info. -.Sp -It scales in the same way as the epoll backend, but the interface to the -kernel is more efficient (which says nothing about its actual speed, of -course). While stopping, setting and starting an I/O watcher does never -cause an extra system call as with \f(CW\*(C`EVBACKEND_EPOLL\*(C'\fR, it still adds up to -two event changes per incident. Support for \f(CW\*(C`fork ()\*(C'\fR is very bad (you -might have to leak fds on fork, but it's more sane than epoll) and it -drops fds silently in similarly hard-to-detect cases. -.Sp -This backend usually performs well under most conditions. -.Sp -While nominally embeddable in other event loops, this doesn't work -everywhere, so you might need to test for this. And since it is broken -almost everywhere, you should only use it when you have a lot of sockets -(for which it usually works), by embedding it into another event loop -(e.g. \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR (but \f(CW\*(C`poll\*(C'\fR is of course -also broken on \s-1OS X\s0)) and, did I mention it, using it only for sockets. -.Sp -This backend maps \f(CW\*(C`EV_READ\*(C'\fR into an \f(CW\*(C`EVFILT_READ\*(C'\fR kevent with -\&\f(CW\*(C`NOTE_EOF\*(C'\fR, and \f(CW\*(C`EV_WRITE\*(C'\fR into an \f(CW\*(C`EVFILT_WRITE\*(C'\fR kevent with -\&\f(CW\*(C`NOTE_EOF\*(C'\fR. -.ie n .IP """EVBACKEND_DEVPOLL"" (value 16, Solaris 8)" 4 -.el .IP "\f(CWEVBACKEND_DEVPOLL\fR (value 16, Solaris 8)" 4 -.IX Item "EVBACKEND_DEVPOLL (value 16, Solaris 8)" -This is not implemented yet (and might never be, unless you send me an -implementation). According to reports, \f(CW\*(C`/dev/poll\*(C'\fR only supports sockets -and is not embeddable, which would limit the usefulness of this backend -immensely. -.ie n .IP """EVBACKEND_PORT"" (value 32, Solaris 10)" 4 -.el .IP "\f(CWEVBACKEND_PORT\fR (value 32, Solaris 10)" 4 -.IX Item "EVBACKEND_PORT (value 32, Solaris 10)" -This uses the Solaris 10 event port mechanism. As with everything on Solaris, -it's really slow, but it still scales very well (O(active_fds)). -.Sp -While this backend scales well, it requires one system call per active -file descriptor per loop iteration. For small and medium numbers of file -descriptors a \*(L"slow\*(R" \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR backend -might perform better. -.Sp -On the positive side, this backend actually performed fully to -specification in all tests and is fully embeddable, which is a rare feat -among the OS-specific backends (I vastly prefer correctness over speed -hacks). -.Sp -On the negative side, the interface is \fIbizarre\fR \- so bizarre that -even sun itself gets it wrong in their code examples: The event polling -function sometimes returns events to the caller even though an error -occurred, but with no indication whether it has done so or not (yes, it's -even documented that way) \- deadly for edge-triggered interfaces where you -absolutely have to know whether an event occurred or not because you have -to re-arm the watcher. -.Sp -Fortunately libev seems to be able to work around these idiocies. -.Sp -This backend maps \f(CW\*(C`EV_READ\*(C'\fR and \f(CW\*(C`EV_WRITE\*(C'\fR in the same way as -\&\f(CW\*(C`EVBACKEND_POLL\*(C'\fR. -.ie n .IP """EVBACKEND_ALL""" 4 -.el .IP "\f(CWEVBACKEND_ALL\fR" 4 -.IX Item "EVBACKEND_ALL" -Try all backends (even potentially broken ones that wouldn't be tried -with \f(CW\*(C`EVFLAG_AUTO\*(C'\fR). Since this is a mask, you can do stuff such as -\&\f(CW\*(C`EVBACKEND_ALL & ~EVBACKEND_KQUEUE\*(C'\fR. -.Sp -It is definitely not recommended to use this flag, use whatever -\&\f(CW\*(C`ev_recommended_backends ()\*(C'\fR returns, or simply do not specify a backend -at all. -.ie n .IP """EVBACKEND_MASK""" 4 -.el .IP "\f(CWEVBACKEND_MASK\fR" 4 -.IX Item "EVBACKEND_MASK" -Not a backend at all, but a mask to select all backend bits from a -\&\f(CW\*(C`flags\*(C'\fR value, in case you want to mask out any backends from a flags -value (e.g. when modifying the \f(CW\*(C`LIBEV_FLAGS\*(C'\fR environment variable). -.RE -.RS 4 -.Sp -If one or more of the backend flags are or'ed into the flags value, -then only these backends will be tried (in the reverse order as listed -here). If none are specified, all backends in \f(CW\*(C`ev_recommended_backends -()\*(C'\fR will be tried. -.Sp -Example: Try to create a event loop that uses epoll and nothing else. -.Sp -.Vb 3 -\& struct ev_loop *epoller = ev_loop_new (EVBACKEND_EPOLL | EVFLAG_NOENV); -\& if (!epoller) -\& fatal ("no epoll found here, maybe it hides under your chair"); -.Ve -.Sp -Example: Use whatever libev has to offer, but make sure that kqueue is -used if available. -.Sp -.Vb 1 -\& struct ev_loop *loop = ev_loop_new (ev_recommended_backends () | EVBACKEND_KQUEUE); -.Ve -.Sp -Example: Similarly, on linux, you mgiht want to take advantage of the -linux aio backend if possible, but fall back to something else if that -isn't available. -.Sp -.Vb 1 -\& struct ev_loop *loop = ev_loop_new (ev_recommended_backends () | EVBACKEND_LINUXAIO); -.Ve -.RE -.IP "ev_loop_destroy (loop)" 4 -.IX Item "ev_loop_destroy (loop)" -Destroys an event loop object (frees all memory and kernel state -etc.). None of the active event watchers will be stopped in the normal -sense, so e.g. \f(CW\*(C`ev_is_active\*(C'\fR might still return true. It is your -responsibility to either stop all watchers cleanly yourself \fIbefore\fR -calling this function, or cope with the fact afterwards (which is usually -the easiest thing, you can just ignore the watchers and/or \f(CW\*(C`free ()\*(C'\fR them -for example). -.Sp -Note that certain global state, such as signal state (and installed signal -handlers), will not be freed by this function, and related watchers (such -as signal and child watchers) would need to be stopped manually. -.Sp -This function is normally used on loop objects allocated by -\&\f(CW\*(C`ev_loop_new\*(C'\fR, but it can also be used on the default loop returned by -\&\f(CW\*(C`ev_default_loop\*(C'\fR, in which case it is not thread-safe. -.Sp -Note that it is not advisable to call this function on the default loop -except in the rare occasion where you really need to free its resources. -If you need dynamically allocated loops it is better to use \f(CW\*(C`ev_loop_new\*(C'\fR -and \f(CW\*(C`ev_loop_destroy\*(C'\fR. -.IP "ev_loop_fork (loop)" 4 -.IX Item "ev_loop_fork (loop)" -This function sets a flag that causes subsequent \f(CW\*(C`ev_run\*(C'\fR iterations -to reinitialise the kernel state for backends that have one. Despite -the name, you can call it anytime you are allowed to start or stop -watchers (except inside an \f(CW\*(C`ev_prepare\*(C'\fR callback), but it makes most -sense after forking, in the child process. You \fImust\fR call it (or use -\&\f(CW\*(C`EVFLAG_FORKCHECK\*(C'\fR) in the child before resuming or calling \f(CW\*(C`ev_run\*(C'\fR. -.Sp -In addition, if you want to reuse a loop (via this function or -\&\f(CW\*(C`EVFLAG_FORKCHECK\*(C'\fR), you \fIalso\fR have to ignore \f(CW\*(C`SIGPIPE\*(C'\fR. -.Sp -Again, you \fIhave\fR to call it on \fIany\fR loop that you want to re-use after -a fork, \fIeven if you do not plan to use the loop in the parent\fR. This is -because some kernel interfaces *cough* \fIkqueue\fR *cough* do funny things -during fork. -.Sp -On the other hand, you only need to call this function in the child -process if and only if you want to use the event loop in the child. If -you just fork+exec or create a new loop in the child, you don't have to -call it at all (in fact, \f(CW\*(C`epoll\*(C'\fR is so badly broken that it makes a -difference, but libev will usually detect this case on its own and do a -costly reset of the backend). -.Sp -The function itself is quite fast and it's usually not a problem to call -it just in case after a fork. -.Sp -Example: Automate calling \f(CW\*(C`ev_loop_fork\*(C'\fR on the default loop when -using pthreads. -.Sp -.Vb 5 -\& static void -\& post_fork_child (void) -\& { -\& ev_loop_fork (EV_DEFAULT); -\& } -\& -\& ... -\& pthread_atfork (0, 0, post_fork_child); -.Ve -.IP "int ev_is_default_loop (loop)" 4 -.IX Item "int ev_is_default_loop (loop)" -Returns true when the given loop is, in fact, the default loop, and false -otherwise. -.IP "unsigned int ev_iteration (loop)" 4 -.IX Item "unsigned int ev_iteration (loop)" -Returns the current iteration count for the event loop, which is identical -to the number of times libev did poll for new events. It starts at \f(CW0\fR -and happily wraps around with enough iterations. -.Sp -This value can sometimes be useful as a generation counter of sorts (it -\&\*(L"ticks\*(R" the number of loop iterations), as it roughly corresponds with -\&\f(CW\*(C`ev_prepare\*(C'\fR and \f(CW\*(C`ev_check\*(C'\fR calls \- and is incremented between the -prepare and check phases. -.IP "unsigned int ev_depth (loop)" 4 -.IX Item "unsigned int ev_depth (loop)" -Returns the number of times \f(CW\*(C`ev_run\*(C'\fR was entered minus the number of -times \f(CW\*(C`ev_run\*(C'\fR was exited normally, in other words, the recursion depth. -.Sp -Outside \f(CW\*(C`ev_run\*(C'\fR, this number is zero. In a callback, this number is -\&\f(CW1\fR, unless \f(CW\*(C`ev_run\*(C'\fR was invoked recursively (or from another thread), -in which case it is higher. -.Sp -Leaving \f(CW\*(C`ev_run\*(C'\fR abnormally (setjmp/longjmp, cancelling the thread, -throwing an exception etc.), doesn't count as \*(L"exit\*(R" \- consider this -as a hint to avoid such ungentleman-like behaviour unless it's really -convenient, in which case it is fully supported. -.IP "unsigned int ev_backend (loop)" 4 -.IX Item "unsigned int ev_backend (loop)" -Returns one of the \f(CW\*(C`EVBACKEND_*\*(C'\fR flags indicating the event backend in -use. -.IP "ev_tstamp ev_now (loop)" 4 -.IX Item "ev_tstamp ev_now (loop)" -Returns the current \*(L"event loop time\*(R", which is the time the event loop -received events and started processing them. This timestamp does not -change as long as callbacks are being processed, and this is also the base -time used for relative timers. You can treat it as the timestamp of the -event occurring (or more correctly, libev finding out about it). -.IP "ev_now_update (loop)" 4 -.IX Item "ev_now_update (loop)" -Establishes the current time by querying the kernel, updating the time -returned by \f(CW\*(C`ev_now ()\*(C'\fR in the progress. This is a costly operation and -is usually done automatically within \f(CW\*(C`ev_run ()\*(C'\fR. -.Sp -This function is rarely useful, but when some event callback runs for a -very long time without entering the event loop, updating libev's idea of -the current time is a good idea. -.Sp -See also \*(L"The special problem of time updates\*(R" in the \f(CW\*(C`ev_timer\*(C'\fR section. -.IP "ev_suspend (loop)" 4 -.IX Item "ev_suspend (loop)" -.PD 0 -.IP "ev_resume (loop)" 4 -.IX Item "ev_resume (loop)" -.PD -These two functions suspend and resume an event loop, for use when the -loop is not used for a while and timeouts should not be processed. -.Sp -A typical use case would be an interactive program such as a game: When -the user presses \f(CW\*(C`^Z\*(C'\fR to suspend the game and resumes it an hour later it -would be best to handle timeouts as if no time had actually passed while -the program was suspended. This can be achieved by calling \f(CW\*(C`ev_suspend\*(C'\fR -in your \f(CW\*(C`SIGTSTP\*(C'\fR handler, sending yourself a \f(CW\*(C`SIGSTOP\*(C'\fR and calling -\&\f(CW\*(C`ev_resume\*(C'\fR directly afterwards to resume timer processing. -.Sp -Effectively, all \f(CW\*(C`ev_timer\*(C'\fR watchers will be delayed by the time spend -between \f(CW\*(C`ev_suspend\*(C'\fR and \f(CW\*(C`ev_resume\*(C'\fR, and all \f(CW\*(C`ev_periodic\*(C'\fR watchers -will be rescheduled (that is, they will lose any events that would have -occurred while suspended). -.Sp -After calling \f(CW\*(C`ev_suspend\*(C'\fR you \fBmust not\fR call \fIany\fR function on the -given loop other than \f(CW\*(C`ev_resume\*(C'\fR, and you \fBmust not\fR call \f(CW\*(C`ev_resume\*(C'\fR -without a previous call to \f(CW\*(C`ev_suspend\*(C'\fR. -.Sp -Calling \f(CW\*(C`ev_suspend\*(C'\fR/\f(CW\*(C`ev_resume\*(C'\fR has the side effect of updating the -event loop time (see \f(CW\*(C`ev_now_update\*(C'\fR). -.IP "bool ev_run (loop, int flags)" 4 -.IX Item "bool ev_run (loop, int flags)" -Finally, this is it, the event handler. This function usually is called -after you have initialised all your watchers and you want to start -handling events. It will ask the operating system for any new events, call -the watcher callbacks, and then repeat the whole process indefinitely: This -is why event loops are called \fIloops\fR. -.Sp -If the flags argument is specified as \f(CW0\fR, it will keep handling events -until either no event watchers are active anymore or \f(CW\*(C`ev_break\*(C'\fR was -called. -.Sp -The return value is false if there are no more active watchers (which -usually means \*(L"all jobs done\*(R" or \*(L"deadlock\*(R"), and true in all other cases -(which usually means " you should call \f(CW\*(C`ev_run\*(C'\fR again"). -.Sp -Please note that an explicit \f(CW\*(C`ev_break\*(C'\fR is usually better than -relying on all watchers to be stopped when deciding when a program has -finished (especially in interactive programs), but having a program -that automatically loops as long as it has to and no longer by virtue -of relying on its watchers stopping correctly, that is truly a thing of -beauty. -.Sp -This function is \fImostly\fR exception-safe \- you can break out of a -\&\f(CW\*(C`ev_run\*(C'\fR call by calling \f(CW\*(C`longjmp\*(C'\fR in a callback, throwing a \*(C+ -exception and so on. This does not decrement the \f(CW\*(C`ev_depth\*(C'\fR value, nor -will it clear any outstanding \f(CW\*(C`EVBREAK_ONE\*(C'\fR breaks. -.Sp -A flags value of \f(CW\*(C`EVRUN_NOWAIT\*(C'\fR will look for new events, will handle -those events and any already outstanding ones, but will not wait and -block your process in case there are no events and will return after one -iteration of the loop. This is sometimes useful to poll and handle new -events while doing lengthy calculations, to keep the program responsive. -.Sp -A flags value of \f(CW\*(C`EVRUN_ONCE\*(C'\fR will look for new events (waiting if -necessary) and will handle those and any already outstanding ones. It -will block your process until at least one new event arrives (which could -be an event internal to libev itself, so there is no guarantee that a -user-registered callback will be called), and will return after one -iteration of the loop. -.Sp -This is useful if you are waiting for some external event in conjunction -with something not expressible using other libev watchers (i.e. "roll your -own \f(CW\*(C`ev_run\*(C'\fR"). However, a pair of \f(CW\*(C`ev_prepare\*(C'\fR/\f(CW\*(C`ev_check\*(C'\fR watchers is -usually a better approach for this kind of thing. -.Sp -Here are the gory details of what \f(CW\*(C`ev_run\*(C'\fR does (this is for your -understanding, not a guarantee that things will work exactly like this in -future versions): -.Sp -.Vb 10 -\& \- Increment loop depth. -\& \- Reset the ev_break status. -\& \- Before the first iteration, call any pending watchers. -\& LOOP: -\& \- If EVFLAG_FORKCHECK was used, check for a fork. -\& \- If a fork was detected (by any means), queue and call all fork watchers. -\& \- Queue and call all prepare watchers. -\& \- If ev_break was called, goto FINISH. -\& \- If we have been forked, detach and recreate the kernel state -\& as to not disturb the other process. -\& \- Update the kernel state with all outstanding changes. -\& \- Update the "event loop time" (ev_now ()). -\& \- Calculate for how long to sleep or block, if at all -\& (active idle watchers, EVRUN_NOWAIT or not having -\& any active watchers at all will result in not sleeping). -\& \- Sleep if the I/O and timer collect interval say so. -\& \- Increment loop iteration counter. -\& \- Block the process, waiting for any events. -\& \- Queue all outstanding I/O (fd) events. -\& \- Update the "event loop time" (ev_now ()), and do time jump adjustments. -\& \- Queue all expired timers. -\& \- Queue all expired periodics. -\& \- Queue all idle watchers with priority higher than that of pending events. -\& \- Queue all check watchers. -\& \- Call all queued watchers in reverse order (i.e. check watchers first). -\& Signals, async and child watchers are implemented as I/O watchers, and -\& will be handled here by queueing them when their watcher gets executed. -\& \- If ev_break has been called, or EVRUN_ONCE or EVRUN_NOWAIT -\& were used, or there are no active watchers, goto FINISH, otherwise -\& continue with step LOOP. -\& FINISH: -\& \- Reset the ev_break status iff it was EVBREAK_ONE. -\& \- Decrement the loop depth. -\& \- Return. -.Ve -.Sp -Example: Queue some jobs and then loop until no events are outstanding -anymore. -.Sp -.Vb 4 -\& ... queue jobs here, make sure they register event watchers as long -\& ... as they still have work to do (even an idle watcher will do..) -\& ev_run (my_loop, 0); -\& ... jobs done or somebody called break. yeah! -.Ve -.IP "ev_break (loop, how)" 4 -.IX Item "ev_break (loop, how)" -Can be used to make a call to \f(CW\*(C`ev_run\*(C'\fR return early (but only after it -has processed all outstanding events). The \f(CW\*(C`how\*(C'\fR argument must be either -\&\f(CW\*(C`EVBREAK_ONE\*(C'\fR, which will make the innermost \f(CW\*(C`ev_run\*(C'\fR call return, or -\&\f(CW\*(C`EVBREAK_ALL\*(C'\fR, which will make all nested \f(CW\*(C`ev_run\*(C'\fR calls return. -.Sp -This \*(L"break state\*(R" will be cleared on the next call to \f(CW\*(C`ev_run\*(C'\fR. -.Sp -It is safe to call \f(CW\*(C`ev_break\*(C'\fR from outside any \f(CW\*(C`ev_run\*(C'\fR calls, too, in -which case it will have no effect. -.IP "ev_ref (loop)" 4 -.IX Item "ev_ref (loop)" -.PD 0 -.IP "ev_unref (loop)" 4 -.IX Item "ev_unref (loop)" -.PD -Ref/unref can be used to add or remove a reference count on the event -loop: Every watcher keeps one reference, and as long as the reference -count is nonzero, \f(CW\*(C`ev_run\*(C'\fR will not return on its own. -.Sp -This is useful when you have a watcher that you never intend to -unregister, but that nevertheless should not keep \f(CW\*(C`ev_run\*(C'\fR from -returning. In such a case, call \f(CW\*(C`ev_unref\*(C'\fR after starting, and \f(CW\*(C`ev_ref\*(C'\fR -before stopping it. -.Sp -As an example, libev itself uses this for its internal signal pipe: It -is not visible to the libev user and should not keep \f(CW\*(C`ev_run\*(C'\fR from -exiting if no event watchers registered by it are active. It is also an -excellent way to do this for generic recurring timers or from within -third-party libraries. Just remember to \fIunref after start\fR and \fIref -before stop\fR (but only if the watcher wasn't active before, or was active -before, respectively. Note also that libev might stop watchers itself -(e.g. non-repeating timers) in which case you have to \f(CW\*(C`ev_ref\*(C'\fR -in the callback). -.Sp -Example: Create a signal watcher, but keep it from keeping \f(CW\*(C`ev_run\*(C'\fR -running when nothing else is active. -.Sp -.Vb 4 -\& ev_signal exitsig; -\& ev_signal_init (&exitsig, sig_cb, SIGINT); -\& ev_signal_start (loop, &exitsig); -\& ev_unref (loop); -.Ve -.Sp -Example: For some weird reason, unregister the above signal handler again. -.Sp -.Vb 2 -\& ev_ref (loop); -\& ev_signal_stop (loop, &exitsig); -.Ve -.IP "ev_set_io_collect_interval (loop, ev_tstamp interval)" 4 -.IX Item "ev_set_io_collect_interval (loop, ev_tstamp interval)" -.PD 0 -.IP "ev_set_timeout_collect_interval (loop, ev_tstamp interval)" 4 -.IX Item "ev_set_timeout_collect_interval (loop, ev_tstamp interval)" -.PD -These advanced functions influence the time that libev will spend waiting -for events. Both time intervals are by default \f(CW0\fR, meaning that libev -will try to invoke timer/periodic callbacks and I/O callbacks with minimum -latency. -.Sp -Setting these to a higher value (the \f(CW\*(C`interval\*(C'\fR \fImust\fR be >= \f(CW0\fR) -allows libev to delay invocation of I/O and timer/periodic callbacks -to increase efficiency of loop iterations (or to increase power-saving -opportunities). -.Sp -The idea is that sometimes your program runs just fast enough to handle -one (or very few) event(s) per loop iteration. While this makes the -program responsive, it also wastes a lot of \s-1CPU\s0 time to poll for new -events, especially with backends like \f(CW\*(C`select ()\*(C'\fR which have a high -overhead for the actual polling but can deliver many events at once. -.Sp -By setting a higher \fIio collect interval\fR you allow libev to spend more -time collecting I/O events, so you can handle more events per iteration, -at the cost of increasing latency. Timeouts (both \f(CW\*(C`ev_periodic\*(C'\fR and -\&\f(CW\*(C`ev_timer\*(C'\fR) will not be affected. Setting this to a non-null value will -introduce an additional \f(CW\*(C`ev_sleep ()\*(C'\fR call into most loop iterations. The -sleep time ensures that libev will not poll for I/O events more often then -once per this interval, on average (as long as the host time resolution is -good enough). -.Sp -Likewise, by setting a higher \fItimeout collect interval\fR you allow libev -to spend more time collecting timeouts, at the expense of increased -latency/jitter/inexactness (the watcher callback will be called -later). \f(CW\*(C`ev_io\*(C'\fR watchers will not be affected. Setting this to a non-null -value will not introduce any overhead in libev. -.Sp -Many (busy) programs can usually benefit by setting the I/O collect -interval to a value near \f(CW0.1\fR or so, which is often enough for -interactive servers (of course not for games), likewise for timeouts. It -usually doesn't make much sense to set it to a lower value than \f(CW0.01\fR, -as this approaches the timing granularity of most systems. Note that if -you do transactions with the outside world and you can't increase the -parallelity, then this setting will limit your transaction rate (if you -need to poll once per transaction and the I/O collect interval is 0.01, -then you can't do more than 100 transactions per second). -.Sp -Setting the \fItimeout collect interval\fR can improve the opportunity for -saving power, as the program will \*(L"bundle\*(R" timer callback invocations that -are \*(L"near\*(R" in time together, by delaying some, thus reducing the number of -times the process sleeps and wakes up again. Another useful technique to -reduce iterations/wake\-ups is to use \f(CW\*(C`ev_periodic\*(C'\fR watchers and make sure -they fire on, say, one-second boundaries only. -.Sp -Example: we only need 0.1s timeout granularity, and we wish not to poll -more often than 100 times per second: -.Sp -.Vb 2 -\& ev_set_timeout_collect_interval (EV_DEFAULT_UC_ 0.1); -\& ev_set_io_collect_interval (EV_DEFAULT_UC_ 0.01); -.Ve -.IP "ev_invoke_pending (loop)" 4 -.IX Item "ev_invoke_pending (loop)" -This call will simply invoke all pending watchers while resetting their -pending state. Normally, \f(CW\*(C`ev_run\*(C'\fR does this automatically when required, -but when overriding the invoke callback this call comes handy. This -function can be invoked from a watcher \- this can be useful for example -when you want to do some lengthy calculation and want to pass further -event handling to another thread (you still have to make sure only one -thread executes within \f(CW\*(C`ev_invoke_pending\*(C'\fR or \f(CW\*(C`ev_run\*(C'\fR of course). -.IP "int ev_pending_count (loop)" 4 -.IX Item "int ev_pending_count (loop)" -Returns the number of pending watchers \- zero indicates that no watchers -are pending. -.IP "ev_set_invoke_pending_cb (loop, void (*invoke_pending_cb)(\s-1EV_P\s0))" 4 -.IX Item "ev_set_invoke_pending_cb (loop, void (*invoke_pending_cb)(EV_P))" -This overrides the invoke pending functionality of the loop: Instead of -invoking all pending watchers when there are any, \f(CW\*(C`ev_run\*(C'\fR will call -this callback instead. This is useful, for example, when you want to -invoke the actual watchers inside another context (another thread etc.). -.Sp -If you want to reset the callback, use \f(CW\*(C`ev_invoke_pending\*(C'\fR as new -callback. -.IP "ev_set_loop_release_cb (loop, void (*release)(\s-1EV_P\s0) throw (), void (*acquire)(\s-1EV_P\s0) throw ())" 4 -.IX Item "ev_set_loop_release_cb (loop, void (*release)(EV_P) throw (), void (*acquire)(EV_P) throw ())" -Sometimes you want to share the same loop between multiple threads. This -can be done relatively simply by putting mutex_lock/unlock calls around -each call to a libev function. -.Sp -However, \f(CW\*(C`ev_run\*(C'\fR can run an indefinite time, so it is not feasible -to wait for it to return. One way around this is to wake up the event -loop via \f(CW\*(C`ev_break\*(C'\fR and \f(CW\*(C`ev_async_send\*(C'\fR, another way is to set these -\&\fIrelease\fR and \fIacquire\fR callbacks on the loop. -.Sp -When set, then \f(CW\*(C`release\*(C'\fR will be called just before the thread is -suspended waiting for new events, and \f(CW\*(C`acquire\*(C'\fR is called just -afterwards. -.Sp -Ideally, \f(CW\*(C`release\*(C'\fR will just call your mutex_unlock function, and -\&\f(CW\*(C`acquire\*(C'\fR will just call the mutex_lock function again. -.Sp -While event loop modifications are allowed between invocations of -\&\f(CW\*(C`release\*(C'\fR and \f(CW\*(C`acquire\*(C'\fR (that's their only purpose after all), no -modifications done will affect the event loop, i.e. adding watchers will -have no effect on the set of file descriptors being watched, or the time -waited. Use an \f(CW\*(C`ev_async\*(C'\fR watcher to wake up \f(CW\*(C`ev_run\*(C'\fR when you want it -to take note of any changes you made. -.Sp -In theory, threads executing \f(CW\*(C`ev_run\*(C'\fR will be async-cancel safe between -invocations of \f(CW\*(C`release\*(C'\fR and \f(CW\*(C`acquire\*(C'\fR. -.Sp -See also the locking example in the \f(CW\*(C`THREADS\*(C'\fR section later in this -document. -.IP "ev_set_userdata (loop, void *data)" 4 -.IX Item "ev_set_userdata (loop, void *data)" -.PD 0 -.IP "void *ev_userdata (loop)" 4 -.IX Item "void *ev_userdata (loop)" -.PD -Set and retrieve a single \f(CW\*(C`void *\*(C'\fR associated with a loop. When -\&\f(CW\*(C`ev_set_userdata\*(C'\fR has never been called, then \f(CW\*(C`ev_userdata\*(C'\fR returns -\&\f(CW0\fR. -.Sp -These two functions can be used to associate arbitrary data with a loop, -and are intended solely for the \f(CW\*(C`invoke_pending_cb\*(C'\fR, \f(CW\*(C`release\*(C'\fR and -\&\f(CW\*(C`acquire\*(C'\fR callbacks described above, but of course can be (ab\-)used for -any other purpose as well. -.IP "ev_verify (loop)" 4 -.IX Item "ev_verify (loop)" -This function only does something when \f(CW\*(C`EV_VERIFY\*(C'\fR support has been -compiled in, which is the default for non-minimal builds. It tries to go -through all internal structures and checks them for validity. If anything -is found to be inconsistent, it will print an error message to standard -error and call \f(CW\*(C`abort ()\*(C'\fR. -.Sp -This can be used to catch bugs inside libev itself: under normal -circumstances, this function will never abort as of course libev keeps its -data structures consistent. -.SH "ANATOMY OF A WATCHER" -.IX Header "ANATOMY OF A WATCHER" -In the following description, uppercase \f(CW\*(C`TYPE\*(C'\fR in names stands for the -watcher type, e.g. \f(CW\*(C`ev_TYPE_start\*(C'\fR can mean \f(CW\*(C`ev_timer_start\*(C'\fR for timer -watchers and \f(CW\*(C`ev_io_start\*(C'\fR for I/O watchers. -.PP -A watcher is an opaque structure that you allocate and register to record -your interest in some event. To make a concrete example, imagine you want -to wait for \s-1STDIN\s0 to become readable, you would create an \f(CW\*(C`ev_io\*(C'\fR watcher -for that: -.PP -.Vb 5 -\& static void my_cb (struct ev_loop *loop, ev_io *w, int revents) -\& { -\& ev_io_stop (w); -\& ev_break (loop, EVBREAK_ALL); -\& } -\& -\& struct ev_loop *loop = ev_default_loop (0); -\& -\& ev_io stdin_watcher; -\& -\& ev_init (&stdin_watcher, my_cb); -\& ev_io_set (&stdin_watcher, STDIN_FILENO, EV_READ); -\& ev_io_start (loop, &stdin_watcher); -\& -\& ev_run (loop, 0); -.Ve -.PP -As you can see, you are responsible for allocating the memory for your -watcher structures (and it is \fIusually\fR a bad idea to do this on the -stack). -.PP -Each watcher has an associated watcher structure (called \f(CW\*(C`struct ev_TYPE\*(C'\fR -or simply \f(CW\*(C`ev_TYPE\*(C'\fR, as typedefs are provided for all watcher structs). -.PP -Each watcher structure must be initialised by a call to \f(CW\*(C`ev_init (watcher -*, callback)\*(C'\fR, which expects a callback to be provided. This callback is -invoked each time the event occurs (or, in the case of I/O watchers, each -time the event loop detects that the file descriptor given is readable -and/or writable). -.PP -Each watcher type further has its own \f(CW\*(C`ev_TYPE_set (watcher *, ...)\*(C'\fR -macro to configure it, with arguments specific to the watcher type. There -is also a macro to combine initialisation and setting in one call: \f(CW\*(C`ev_TYPE_init (watcher *, callback, ...)\*(C'\fR. -.PP -To make the watcher actually watch out for events, you have to start it -with a watcher-specific start function (\f(CW\*(C`ev_TYPE_start (loop, watcher -*)\*(C'\fR), and you can stop watching for events at any time by calling the -corresponding stop function (\f(CW\*(C`ev_TYPE_stop (loop, watcher *)\*(C'\fR. -.PP -As long as your watcher is active (has been started but not stopped) you -must not touch the values stored in it except when explicitly documented -otherwise. Most specifically you must never reinitialise it or call its -\&\f(CW\*(C`ev_TYPE_set\*(C'\fR macro. -.PP -Each and every callback receives the event loop pointer as first, the -registered watcher structure as second, and a bitset of received events as -third argument. -.PP -The received events usually include a single bit per event type received -(you can receive multiple events at the same time). The possible bit masks -are: -.ie n .IP """EV_READ""" 4 -.el .IP "\f(CWEV_READ\fR" 4 -.IX Item "EV_READ" -.PD 0 -.ie n .IP """EV_WRITE""" 4 -.el .IP "\f(CWEV_WRITE\fR" 4 -.IX Item "EV_WRITE" -.PD -The file descriptor in the \f(CW\*(C`ev_io\*(C'\fR watcher has become readable and/or -writable. -.ie n .IP """EV_TIMER""" 4 -.el .IP "\f(CWEV_TIMER\fR" 4 -.IX Item "EV_TIMER" -The \f(CW\*(C`ev_timer\*(C'\fR watcher has timed out. -.ie n .IP """EV_PERIODIC""" 4 -.el .IP "\f(CWEV_PERIODIC\fR" 4 -.IX Item "EV_PERIODIC" -The \f(CW\*(C`ev_periodic\*(C'\fR watcher has timed out. -.ie n .IP """EV_SIGNAL""" 4 -.el .IP "\f(CWEV_SIGNAL\fR" 4 -.IX Item "EV_SIGNAL" -The signal specified in the \f(CW\*(C`ev_signal\*(C'\fR watcher has been received by a thread. -.ie n .IP """EV_CHILD""" 4 -.el .IP "\f(CWEV_CHILD\fR" 4 -.IX Item "EV_CHILD" -The pid specified in the \f(CW\*(C`ev_child\*(C'\fR watcher has received a status change. -.ie n .IP """EV_STAT""" 4 -.el .IP "\f(CWEV_STAT\fR" 4 -.IX Item "EV_STAT" -The path specified in the \f(CW\*(C`ev_stat\*(C'\fR watcher changed its attributes somehow. -.ie n .IP """EV_IDLE""" 4 -.el .IP "\f(CWEV_IDLE\fR" 4 -.IX Item "EV_IDLE" -The \f(CW\*(C`ev_idle\*(C'\fR watcher has determined that you have nothing better to do. -.ie n .IP """EV_PREPARE""" 4 -.el .IP "\f(CWEV_PREPARE\fR" 4 -.IX Item "EV_PREPARE" -.PD 0 -.ie n .IP """EV_CHECK""" 4 -.el .IP "\f(CWEV_CHECK\fR" 4 -.IX Item "EV_CHECK" -.PD -All \f(CW\*(C`ev_prepare\*(C'\fR watchers are invoked just \fIbefore\fR \f(CW\*(C`ev_run\*(C'\fR starts to -gather new events, and all \f(CW\*(C`ev_check\*(C'\fR watchers are queued (not invoked) -just after \f(CW\*(C`ev_run\*(C'\fR has gathered them, but before it queues any callbacks -for any received events. That means \f(CW\*(C`ev_prepare\*(C'\fR watchers are the last -watchers invoked before the event loop sleeps or polls for new events, and -\&\f(CW\*(C`ev_check\*(C'\fR watchers will be invoked before any other watchers of the same -or lower priority within an event loop iteration. -.Sp -Callbacks of both watcher types can start and stop as many watchers as -they want, and all of them will be taken into account (for example, a -\&\f(CW\*(C`ev_prepare\*(C'\fR watcher might start an idle watcher to keep \f(CW\*(C`ev_run\*(C'\fR from -blocking). -.ie n .IP """EV_EMBED""" 4 -.el .IP "\f(CWEV_EMBED\fR" 4 -.IX Item "EV_EMBED" -The embedded event loop specified in the \f(CW\*(C`ev_embed\*(C'\fR watcher needs attention. -.ie n .IP """EV_FORK""" 4 -.el .IP "\f(CWEV_FORK\fR" 4 -.IX Item "EV_FORK" -The event loop has been resumed in the child process after fork (see -\&\f(CW\*(C`ev_fork\*(C'\fR). -.ie n .IP """EV_CLEANUP""" 4 -.el .IP "\f(CWEV_CLEANUP\fR" 4 -.IX Item "EV_CLEANUP" -The event loop is about to be destroyed (see \f(CW\*(C`ev_cleanup\*(C'\fR). -.ie n .IP """EV_ASYNC""" 4 -.el .IP "\f(CWEV_ASYNC\fR" 4 -.IX Item "EV_ASYNC" -The given async watcher has been asynchronously notified (see \f(CW\*(C`ev_async\*(C'\fR). -.ie n .IP """EV_CUSTOM""" 4 -.el .IP "\f(CWEV_CUSTOM\fR" 4 -.IX Item "EV_CUSTOM" -Not ever sent (or otherwise used) by libev itself, but can be freely used -by libev users to signal watchers (e.g. via \f(CW\*(C`ev_feed_event\*(C'\fR). -.ie n .IP """EV_ERROR""" 4 -.el .IP "\f(CWEV_ERROR\fR" 4 -.IX Item "EV_ERROR" -An unspecified error has occurred, the watcher has been stopped. This might -happen because the watcher could not be properly started because libev -ran out of memory, a file descriptor was found to be closed or any other -problem. Libev considers these application bugs. -.Sp -You best act on it by reporting the problem and somehow coping with the -watcher being stopped. Note that well-written programs should not receive -an error ever, so when your watcher receives it, this usually indicates a -bug in your program. -.Sp -Libev will usually signal a few \*(L"dummy\*(R" events together with an error, for -example it might indicate that a fd is readable or writable, and if your -callbacks is well-written it can just attempt the operation and cope with -the error from \fBread()\fR or \fBwrite()\fR. This will not work in multi-threaded -programs, though, as the fd could already be closed and reused for another -thing, so beware. -.SS "\s-1GENERIC WATCHER FUNCTIONS\s0" -.IX Subsection "GENERIC WATCHER FUNCTIONS" -.ie n .IP """ev_init"" (ev_TYPE *watcher, callback)" 4 -.el .IP "\f(CWev_init\fR (ev_TYPE *watcher, callback)" 4 -.IX Item "ev_init (ev_TYPE *watcher, callback)" -This macro initialises the generic portion of a watcher. The contents -of the watcher object can be arbitrary (so \f(CW\*(C`malloc\*(C'\fR will do). Only -the generic parts of the watcher are initialised, you \fIneed\fR to call -the type-specific \f(CW\*(C`ev_TYPE_set\*(C'\fR macro afterwards to initialise the -type-specific parts. For each type there is also a \f(CW\*(C`ev_TYPE_init\*(C'\fR macro -which rolls both calls into one. -.Sp -You can reinitialise a watcher at any time as long as it has been stopped -(or never started) and there are no pending events outstanding. -.Sp -The callback is always of type \f(CW\*(C`void (*)(struct ev_loop *loop, ev_TYPE *watcher, -int revents)\*(C'\fR. -.Sp -Example: Initialise an \f(CW\*(C`ev_io\*(C'\fR watcher in two steps. -.Sp -.Vb 3 -\& ev_io w; -\& ev_init (&w, my_cb); -\& ev_io_set (&w, STDIN_FILENO, EV_READ); -.Ve -.ie n .IP """ev_TYPE_set"" (ev_TYPE *watcher, [args])" 4 -.el .IP "\f(CWev_TYPE_set\fR (ev_TYPE *watcher, [args])" 4 -.IX Item "ev_TYPE_set (ev_TYPE *watcher, [args])" -This macro initialises the type-specific parts of a watcher. You need to -call \f(CW\*(C`ev_init\*(C'\fR at least once before you call this macro, but you can -call \f(CW\*(C`ev_TYPE_set\*(C'\fR any number of times. You must not, however, call this -macro on a watcher that is active (it can be pending, however, which is a -difference to the \f(CW\*(C`ev_init\*(C'\fR macro). -.Sp -Although some watcher types do not have type-specific arguments -(e.g. \f(CW\*(C`ev_prepare\*(C'\fR) you still need to call its \f(CW\*(C`set\*(C'\fR macro. -.Sp -See \f(CW\*(C`ev_init\*(C'\fR, above, for an example. -.ie n .IP """ev_TYPE_init"" (ev_TYPE *watcher, callback, [args])" 4 -.el .IP "\f(CWev_TYPE_init\fR (ev_TYPE *watcher, callback, [args])" 4 -.IX Item "ev_TYPE_init (ev_TYPE *watcher, callback, [args])" -This convenience macro rolls both \f(CW\*(C`ev_init\*(C'\fR and \f(CW\*(C`ev_TYPE_set\*(C'\fR macro -calls into a single call. This is the most convenient method to initialise -a watcher. The same limitations apply, of course. -.Sp -Example: Initialise and set an \f(CW\*(C`ev_io\*(C'\fR watcher in one step. -.Sp -.Vb 1 -\& ev_io_init (&w, my_cb, STDIN_FILENO, EV_READ); -.Ve -.ie n .IP """ev_TYPE_start"" (loop, ev_TYPE *watcher)" 4 -.el .IP "\f(CWev_TYPE_start\fR (loop, ev_TYPE *watcher)" 4 -.IX Item "ev_TYPE_start (loop, ev_TYPE *watcher)" -Starts (activates) the given watcher. Only active watchers will receive -events. If the watcher is already active nothing will happen. -.Sp -Example: Start the \f(CW\*(C`ev_io\*(C'\fR watcher that is being abused as example in this -whole section. -.Sp -.Vb 1 -\& ev_io_start (EV_DEFAULT_UC, &w); -.Ve -.ie n .IP """ev_TYPE_stop"" (loop, ev_TYPE *watcher)" 4 -.el .IP "\f(CWev_TYPE_stop\fR (loop, ev_TYPE *watcher)" 4 -.IX Item "ev_TYPE_stop (loop, ev_TYPE *watcher)" -Stops the given watcher if active, and clears the pending status (whether -the watcher was active or not). -.Sp -It is possible that stopped watchers are pending \- for example, -non-repeating timers are being stopped when they become pending \- but -calling \f(CW\*(C`ev_TYPE_stop\*(C'\fR ensures that the watcher is neither active nor -pending. If you want to free or reuse the memory used by the watcher it is -therefore a good idea to always call its \f(CW\*(C`ev_TYPE_stop\*(C'\fR function. -.IP "bool ev_is_active (ev_TYPE *watcher)" 4 -.IX Item "bool ev_is_active (ev_TYPE *watcher)" -Returns a true value iff the watcher is active (i.e. it has been started -and not yet been stopped). As long as a watcher is active you must not modify -it unless documented otherwise. -.IP "bool ev_is_pending (ev_TYPE *watcher)" 4 -.IX Item "bool ev_is_pending (ev_TYPE *watcher)" -Returns a true value iff the watcher is pending, (i.e. it has outstanding -events but its callback has not yet been invoked). As long as a watcher -is pending (but not active) you must not call an init function on it (but -\&\f(CW\*(C`ev_TYPE_set\*(C'\fR is safe), you must not change its priority, and you must -make sure the watcher is available to libev (e.g. you cannot \f(CW\*(C`free ()\*(C'\fR -it). -.IP "callback ev_cb (ev_TYPE *watcher)" 4 -.IX Item "callback ev_cb (ev_TYPE *watcher)" -Returns the callback currently set on the watcher. -.IP "ev_set_cb (ev_TYPE *watcher, callback)" 4 -.IX Item "ev_set_cb (ev_TYPE *watcher, callback)" -Change the callback. You can change the callback at virtually any time -(modulo threads). -.IP "ev_set_priority (ev_TYPE *watcher, int priority)" 4 -.IX Item "ev_set_priority (ev_TYPE *watcher, int priority)" -.PD 0 -.IP "int ev_priority (ev_TYPE *watcher)" 4 -.IX Item "int ev_priority (ev_TYPE *watcher)" -.PD -Set and query the priority of the watcher. The priority is a small -integer between \f(CW\*(C`EV_MAXPRI\*(C'\fR (default: \f(CW2\fR) and \f(CW\*(C`EV_MINPRI\*(C'\fR -(default: \f(CW\*(C`\-2\*(C'\fR). Pending watchers with higher priority will be invoked -before watchers with lower priority, but priority will not keep watchers -from being executed (except for \f(CW\*(C`ev_idle\*(C'\fR watchers). -.Sp -If you need to suppress invocation when higher priority events are pending -you need to look at \f(CW\*(C`ev_idle\*(C'\fR watchers, which provide this functionality. -.Sp -You \fImust not\fR change the priority of a watcher as long as it is active or -pending. -.Sp -Setting a priority outside the range of \f(CW\*(C`EV_MINPRI\*(C'\fR to \f(CW\*(C`EV_MAXPRI\*(C'\fR is -fine, as long as you do not mind that the priority value you query might -or might not have been clamped to the valid range. -.Sp -The default priority used by watchers when no priority has been set is -always \f(CW0\fR, which is supposed to not be too high and not be too low :). -.Sp -See \*(L"\s-1WATCHER PRIORITY MODELS\*(R"\s0, below, for a more thorough treatment of -priorities. -.IP "ev_invoke (loop, ev_TYPE *watcher, int revents)" 4 -.IX Item "ev_invoke (loop, ev_TYPE *watcher, int revents)" -Invoke the \f(CW\*(C`watcher\*(C'\fR with the given \f(CW\*(C`loop\*(C'\fR and \f(CW\*(C`revents\*(C'\fR. Neither -\&\f(CW\*(C`loop\*(C'\fR nor \f(CW\*(C`revents\*(C'\fR need to be valid as long as the watcher callback -can deal with that fact, as both are simply passed through to the -callback. -.IP "int ev_clear_pending (loop, ev_TYPE *watcher)" 4 -.IX Item "int ev_clear_pending (loop, ev_TYPE *watcher)" -If the watcher is pending, this function clears its pending status and -returns its \f(CW\*(C`revents\*(C'\fR bitset (as if its callback was invoked). If the -watcher isn't pending it does nothing and returns \f(CW0\fR. -.Sp -Sometimes it can be useful to \*(L"poll\*(R" a watcher instead of waiting for its -callback to be invoked, which can be accomplished with this function. -.IP "ev_feed_event (loop, ev_TYPE *watcher, int revents)" 4 -.IX Item "ev_feed_event (loop, ev_TYPE *watcher, int revents)" -Feeds the given event set into the event loop, as if the specified event -had happened for the specified watcher (which must be a pointer to an -initialised but not necessarily started event watcher). Obviously you must -not free the watcher as long as it has pending events. -.Sp -Stopping the watcher, letting libev invoke it, or calling -\&\f(CW\*(C`ev_clear_pending\*(C'\fR will clear the pending event, even if the watcher was -not started in the first place. -.Sp -See also \f(CW\*(C`ev_feed_fd_event\*(C'\fR and \f(CW\*(C`ev_feed_signal_event\*(C'\fR for related -functions that do not need a watcher. -.PP -See also the \*(L"\s-1ASSOCIATING CUSTOM DATA WITH A WATCHER\*(R"\s0 and \*(L"\s-1BUILDING YOUR -OWN COMPOSITE WATCHERS\*(R"\s0 idioms. -.SS "\s-1WATCHER STATES\s0" -.IX Subsection "WATCHER STATES" -There are various watcher states mentioned throughout this manual \- -active, pending and so on. In this section these states and the rules to -transition between them will be described in more detail \- and while these -rules might look complicated, they usually do \*(L"the right thing\*(R". -.IP "initialised" 4 -.IX Item "initialised" -Before a watcher can be registered with the event loop it has to be -initialised. This can be done with a call to \f(CW\*(C`ev_TYPE_init\*(C'\fR, or calls to -\&\f(CW\*(C`ev_init\*(C'\fR followed by the watcher-specific \f(CW\*(C`ev_TYPE_set\*(C'\fR function. -.Sp -In this state it is simply some block of memory that is suitable for -use in an event loop. It can be moved around, freed, reused etc. at -will \- as long as you either keep the memory contents intact, or call -\&\f(CW\*(C`ev_TYPE_init\*(C'\fR again. -.IP "started/running/active" 4 -.IX Item "started/running/active" -Once a watcher has been started with a call to \f(CW\*(C`ev_TYPE_start\*(C'\fR it becomes -property of the event loop, and is actively waiting for events. While in -this state it cannot be accessed (except in a few documented ways), moved, -freed or anything else \- the only legal thing is to keep a pointer to it, -and call libev functions on it that are documented to work on active watchers. -.IP "pending" 4 -.IX Item "pending" -If a watcher is active and libev determines that an event it is interested -in has occurred (such as a timer expiring), it will become pending. It will -stay in this pending state until either it is stopped or its callback is -about to be invoked, so it is not normally pending inside the watcher -callback. -.Sp -The watcher might or might not be active while it is pending (for example, -an expired non-repeating timer can be pending but no longer active). If it -is stopped, it can be freely accessed (e.g. by calling \f(CW\*(C`ev_TYPE_set\*(C'\fR), -but it is still property of the event loop at this time, so cannot be -moved, freed or reused. And if it is active the rules described in the -previous item still apply. -.Sp -It is also possible to feed an event on a watcher that is not active (e.g. -via \f(CW\*(C`ev_feed_event\*(C'\fR), in which case it becomes pending without being -active. -.IP "stopped" 4 -.IX Item "stopped" -A watcher can be stopped implicitly by libev (in which case it might still -be pending), or explicitly by calling its \f(CW\*(C`ev_TYPE_stop\*(C'\fR function. The -latter will clear any pending state the watcher might be in, regardless -of whether it was active or not, so stopping a watcher explicitly before -freeing it is often a good idea. -.Sp -While stopped (and not pending) the watcher is essentially in the -initialised state, that is, it can be reused, moved, modified in any way -you wish (but when you trash the memory block, you need to \f(CW\*(C`ev_TYPE_init\*(C'\fR -it again). -.SS "\s-1WATCHER PRIORITY MODELS\s0" -.IX Subsection "WATCHER PRIORITY MODELS" -Many event loops support \fIwatcher priorities\fR, which are usually small -integers that influence the ordering of event callback invocation -between watchers in some way, all else being equal. -.PP -In libev, watcher priorities can be set using \f(CW\*(C`ev_set_priority\*(C'\fR. See its -description for the more technical details such as the actual priority -range. -.PP -There are two common ways how these these priorities are being interpreted -by event loops: -.PP -In the more common lock-out model, higher priorities \*(L"lock out\*(R" invocation -of lower priority watchers, which means as long as higher priority -watchers receive events, lower priority watchers are not being invoked. -.PP -The less common only-for-ordering model uses priorities solely to order -callback invocation within a single event loop iteration: Higher priority -watchers are invoked before lower priority ones, but they all get invoked -before polling for new events. -.PP -Libev uses the second (only-for-ordering) model for all its watchers -except for idle watchers (which use the lock-out model). -.PP -The rationale behind this is that implementing the lock-out model for -watchers is not well supported by most kernel interfaces, and most event -libraries will just poll for the same events again and again as long as -their callbacks have not been executed, which is very inefficient in the -common case of one high-priority watcher locking out a mass of lower -priority ones. -.PP -Static (ordering) priorities are most useful when you have two or more -watchers handling the same resource: a typical usage example is having an -\&\f(CW\*(C`ev_io\*(C'\fR watcher to receive data, and an associated \f(CW\*(C`ev_timer\*(C'\fR to handle -timeouts. Under load, data might be received while the program handles -other jobs, but since timers normally get invoked first, the timeout -handler will be executed before checking for data. In that case, giving -the timer a lower priority than the I/O watcher ensures that I/O will be -handled first even under adverse conditions (which is usually, but not -always, what you want). -.PP -Since idle watchers use the \*(L"lock-out\*(R" model, meaning that idle watchers -will only be executed when no same or higher priority watchers have -received events, they can be used to implement the \*(L"lock-out\*(R" model when -required. -.PP -For example, to emulate how many other event libraries handle priorities, -you can associate an \f(CW\*(C`ev_idle\*(C'\fR watcher to each such watcher, and in -the normal watcher callback, you just start the idle watcher. The real -processing is done in the idle watcher callback. This causes libev to -continuously poll and process kernel event data for the watcher, but when -the lock-out case is known to be rare (which in turn is rare :), this is -workable. -.PP -Usually, however, the lock-out model implemented that way will perform -miserably under the type of load it was designed to handle. In that case, -it might be preferable to stop the real watcher before starting the -idle watcher, so the kernel will not have to process the event in case -the actual processing will be delayed for considerable time. -.PP -Here is an example of an I/O watcher that should run at a strictly lower -priority than the default, and which should only process data when no -other events are pending: -.PP -.Vb 2 -\& ev_idle idle; // actual processing watcher -\& ev_io io; // actual event watcher -\& -\& static void -\& io_cb (EV_P_ ev_io *w, int revents) -\& { -\& // stop the I/O watcher, we received the event, but -\& // are not yet ready to handle it. -\& ev_io_stop (EV_A_ w); -\& -\& // start the idle watcher to handle the actual event. -\& // it will not be executed as long as other watchers -\& // with the default priority are receiving events. -\& ev_idle_start (EV_A_ &idle); -\& } -\& -\& static void -\& idle_cb (EV_P_ ev_idle *w, int revents) -\& { -\& // actual processing -\& read (STDIN_FILENO, ...); -\& -\& // have to start the I/O watcher again, as -\& // we have handled the event -\& ev_io_start (EV_P_ &io); -\& } -\& -\& // initialisation -\& ev_idle_init (&idle, idle_cb); -\& ev_io_init (&io, io_cb, STDIN_FILENO, EV_READ); -\& ev_io_start (EV_DEFAULT_ &io); -.Ve -.PP -In the \*(L"real\*(R" world, it might also be beneficial to start a timer, so that -low-priority connections can not be locked out forever under load. This -enables your program to keep a lower latency for important connections -during short periods of high load, while not completely locking out less -important ones. -.SH "WATCHER TYPES" -.IX Header "WATCHER TYPES" -This section describes each watcher in detail, but will not repeat -information given in the last section. Any initialisation/set macros, -functions and members specific to the watcher type are explained. -.PP -Most members are additionally marked with either \fI[read\-only]\fR, meaning -that, while the watcher is active, you can look at the member and expect -some sensible content, but you must not modify it (you can modify it while -the watcher is stopped to your hearts content), or \fI[read\-write]\fR, which -means you can expect it to have some sensible content while the watcher is -active, but you can also modify it (within the same thread as the event -loop, i.e. without creating data races). Modifying it may not do something -sensible or take immediate effect (or do anything at all), but libev will -not crash or malfunction in any way. -.PP -In any case, the documentation for each member will explain what the -effects are, and if there are any additional access restrictions. -.ie n .SS """ev_io"" \- is this file descriptor readable or writable?" -.el .SS "\f(CWev_io\fP \- is this file descriptor readable or writable?" -.IX Subsection "ev_io - is this file descriptor readable or writable?" -I/O watchers check whether a file descriptor is readable or writable -in each iteration of the event loop, or, more precisely, when reading -would not block the process and writing would at least be able to write -some data. This behaviour is called level-triggering because you keep -receiving events as long as the condition persists. Remember you can stop -the watcher if you don't want to act on the event and neither want to -receive future events. -.PP -In general you can register as many read and/or write event watchers per -fd as you want (as long as you don't confuse yourself). Setting all file -descriptors to non-blocking mode is also usually a good idea (but not -required if you know what you are doing). -.PP -Another thing you have to watch out for is that it is quite easy to -receive \*(L"spurious\*(R" readiness notifications, that is, your callback might -be called with \f(CW\*(C`EV_READ\*(C'\fR but a subsequent \f(CW\*(C`read\*(C'\fR(2) will actually block -because there is no data. It is very easy to get into this situation even -with a relatively standard program structure. Thus it is best to always -use non-blocking I/O: An extra \f(CW\*(C`read\*(C'\fR(2) returning \f(CW\*(C`EAGAIN\*(C'\fR is far -preferable to a program hanging until some data arrives. -.PP -If you cannot run the fd in non-blocking mode (for example you should -not play around with an Xlib connection), then you have to separately -re-test whether a file descriptor is really ready with a known-to-be good -interface such as poll (fortunately in the case of Xlib, it already does -this on its own, so its quite safe to use). Some people additionally -use \f(CW\*(C`SIGALRM\*(C'\fR and an interval timer, just to be sure you won't block -indefinitely. -.PP -But really, best use non-blocking mode. -.PP -\fIThe special problem of disappearing file descriptors\fR -.IX Subsection "The special problem of disappearing file descriptors" -.PP -Some backends (e.g. kqueue, epoll, linuxaio) need to be told about closing -a file descriptor (either due to calling \f(CW\*(C`close\*(C'\fR explicitly or any other -means, such as \f(CW\*(C`dup2\*(C'\fR). The reason is that you register interest in some -file descriptor, but when it goes away, the operating system will silently -drop this interest. If another file descriptor with the same number then -is registered with libev, there is no efficient way to see that this is, -in fact, a different file descriptor. -.PP -To avoid having to explicitly tell libev about such cases, libev follows -the following policy: Each time \f(CW\*(C`ev_io_set\*(C'\fR is being called, libev -will assume that this is potentially a new file descriptor, otherwise -it is assumed that the file descriptor stays the same. That means that -you \fIhave\fR to call \f(CW\*(C`ev_io_set\*(C'\fR (or \f(CW\*(C`ev_io_init\*(C'\fR) when you change the -descriptor even if the file descriptor number itself did not change. -.PP -This is how one would do it normally anyway, the important point is that -the libev application should not optimise around libev but should leave -optimisations to libev. -.PP -\fIThe special problem of dup'ed file descriptors\fR -.IX Subsection "The special problem of dup'ed file descriptors" -.PP -Some backends (e.g. epoll), cannot register events for file descriptors, -but only events for the underlying file descriptions. That means when you -have \f(CW\*(C`dup ()\*(C'\fR'ed file descriptors or weirder constellations, and register -events for them, only one file descriptor might actually receive events. -.PP -There is no workaround possible except not registering events -for potentially \f(CW\*(C`dup ()\*(C'\fR'ed file descriptors, or to resort to -\&\f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR. -.PP -\fIThe special problem of files\fR -.IX Subsection "The special problem of files" -.PP -Many people try to use \f(CW\*(C`select\*(C'\fR (or libev) on file descriptors -representing files, and expect it to become ready when their program -doesn't block on disk accesses (which can take a long time on their own). -.PP -However, this cannot ever work in the \*(L"expected\*(R" way \- you get a readiness -notification as soon as the kernel knows whether and how much data is -there, and in the case of open files, that's always the case, so you -always get a readiness notification instantly, and your read (or possibly -write) will still block on the disk I/O. -.PP -Another way to view it is that in the case of sockets, pipes, character -devices and so on, there is another party (the sender) that delivers data -on its own, but in the case of files, there is no such thing: the disk -will not send data on its own, simply because it doesn't know what you -wish to read \- you would first have to request some data. -.PP -Since files are typically not-so-well supported by advanced notification -mechanism, libev tries hard to emulate \s-1POSIX\s0 behaviour with respect -to files, even though you should not use it. The reason for this is -convenience: sometimes you want to watch \s-1STDIN\s0 or \s-1STDOUT,\s0 which is -usually a tty, often a pipe, but also sometimes files or special devices -(for example, \f(CW\*(C`epoll\*(C'\fR on Linux works with \fI/dev/random\fR but not with -\&\fI/dev/urandom\fR), and even though the file might better be served with -asynchronous I/O instead of with non-blocking I/O, it is still useful when -it \*(L"just works\*(R" instead of freezing. -.PP -So avoid file descriptors pointing to files when you know it (e.g. use -libeio), but use them when it is convenient, e.g. for \s-1STDIN/STDOUT,\s0 or -when you rarely read from a file instead of from a socket, and want to -reuse the same code path. -.PP -\fIThe special problem of fork\fR -.IX Subsection "The special problem of fork" -.PP -Some backends (epoll, kqueue, linuxaio, iouring) do not support \f(CW\*(C`fork ()\*(C'\fR -at all or exhibit useless behaviour. Libev fully supports fork, but needs -to be told about it in the child if you want to continue to use it in the -child. -.PP -To support fork in your child processes, you have to call \f(CW\*(C`ev_loop_fork -()\*(C'\fR after a fork in the child, enable \f(CW\*(C`EVFLAG_FORKCHECK\*(C'\fR, or resort to -\&\f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR. -.PP -\fIThe special problem of \s-1SIGPIPE\s0\fR -.IX Subsection "The special problem of SIGPIPE" -.PP -While not really specific to libev, it is easy to forget about \f(CW\*(C`SIGPIPE\*(C'\fR: -when writing to a pipe whose other end has been closed, your program gets -sent a \s-1SIGPIPE,\s0 which, by default, aborts your program. For most programs -this is sensible behaviour, for daemons, this is usually undesirable. -.PP -So when you encounter spurious, unexplained daemon exits, make sure you -ignore \s-1SIGPIPE\s0 (and maybe make sure you log the exit status of your daemon -somewhere, as that would have given you a big clue). -.PP -\fIThe special problem of \f(BIaccept()\fIing when you can't\fR -.IX Subsection "The special problem of accept()ing when you can't" -.PP -Many implementations of the \s-1POSIX\s0 \f(CW\*(C`accept\*(C'\fR function (for example, -found in post\-2004 Linux) have the peculiar behaviour of not removing a -connection from the pending queue in all error cases. -.PP -For example, larger servers often run out of file descriptors (because -of resource limits), causing \f(CW\*(C`accept\*(C'\fR to fail with \f(CW\*(C`ENFILE\*(C'\fR but not -rejecting the connection, leading to libev signalling readiness on -the next iteration again (the connection still exists after all), and -typically causing the program to loop at 100% \s-1CPU\s0 usage. -.PP -Unfortunately, the set of errors that cause this issue differs between -operating systems, there is usually little the app can do to remedy the -situation, and no known thread-safe method of removing the connection to -cope with overload is known (to me). -.PP -One of the easiest ways to handle this situation is to just ignore it -\&\- when the program encounters an overload, it will just loop until the -situation is over. While this is a form of busy waiting, no \s-1OS\s0 offers an -event-based way to handle this situation, so it's the best one can do. -.PP -A better way to handle the situation is to log any errors other than -\&\f(CW\*(C`EAGAIN\*(C'\fR and \f(CW\*(C`EWOULDBLOCK\*(C'\fR, making sure not to flood the log with such -messages, and continue as usual, which at least gives the user an idea of -what could be wrong (\*(L"raise the ulimit!\*(R"). For extra points one could stop -the \f(CW\*(C`ev_io\*(C'\fR watcher on the listening fd \*(L"for a while\*(R", which reduces \s-1CPU\s0 -usage. -.PP -If your program is single-threaded, then you could also keep a dummy file -descriptor for overload situations (e.g. by opening \fI/dev/null\fR), and -when you run into \f(CW\*(C`ENFILE\*(C'\fR or \f(CW\*(C`EMFILE\*(C'\fR, close it, run \f(CW\*(C`accept\*(C'\fR, -close that fd, and create a new dummy fd. This will gracefully refuse -clients under typical overload conditions. -.PP -The last way to handle it is to simply log the error and \f(CW\*(C`exit\*(C'\fR, as -is often done with \f(CW\*(C`malloc\*(C'\fR failures, but this results in an easy -opportunity for a DoS attack. -.PP -\fIWatcher-Specific Functions\fR -.IX Subsection "Watcher-Specific Functions" -.IP "ev_io_init (ev_io *, callback, int fd, int events)" 4 -.IX Item "ev_io_init (ev_io *, callback, int fd, int events)" -.PD 0 -.IP "ev_io_set (ev_io *, int fd, int events)" 4 -.IX Item "ev_io_set (ev_io *, int fd, int events)" -.PD -Configures an \f(CW\*(C`ev_io\*(C'\fR watcher. The \f(CW\*(C`fd\*(C'\fR is the file descriptor to -receive events for and \f(CW\*(C`events\*(C'\fR is either \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR, both -\&\f(CW\*(C`EV_READ | EV_WRITE\*(C'\fR or \f(CW0\fR, to express the desire to receive the given -events. -.Sp -Note that setting the \f(CW\*(C`events\*(C'\fR to \f(CW0\fR and starting the watcher is -supported, but not specially optimized \- if your program sometimes happens -to generate this combination this is fine, but if it is easy to avoid -starting an io watcher watching for no events you should do so. -.IP "ev_io_modify (ev_io *, int events)" 4 -.IX Item "ev_io_modify (ev_io *, int events)" -Similar to \f(CW\*(C`ev_io_set\*(C'\fR, but only changes the requested events. Using this -might be faster with some backends, as libev can assume that the \f(CW\*(C`fd\*(C'\fR -still refers to the same underlying file description, something it cannot -do when using \f(CW\*(C`ev_io_set\*(C'\fR. -.IP "int fd [no\-modify]" 4 -.IX Item "int fd [no-modify]" -The file descriptor being watched. While it can be read at any time, you -must not modify this member even when the watcher is stopped \- always use -\&\f(CW\*(C`ev_io_set\*(C'\fR for that. -.IP "int events [no\-modify]" 4 -.IX Item "int events [no-modify]" -The set of events the fd is being watched for, among other flags. Remember -that this is a bit set \- to test for \f(CW\*(C`EV_READ\*(C'\fR, use \f(CW\*(C`w\->events & -EV_READ\*(C'\fR, and similarly for \f(CW\*(C`EV_WRITE\*(C'\fR. -.Sp -As with \f(CW\*(C`fd\*(C'\fR, you must not modify this member even when the watcher is -stopped, always use \f(CW\*(C`ev_io_set\*(C'\fR or \f(CW\*(C`ev_io_modify\*(C'\fR for that. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Call \f(CW\*(C`stdin_readable_cb\*(C'\fR when \s-1STDIN_FILENO\s0 has become, well -readable, but only once. Since it is likely line-buffered, you could -attempt to read a whole line in the callback. -.PP -.Vb 6 -\& static void -\& stdin_readable_cb (struct ev_loop *loop, ev_io *w, int revents) -\& { -\& ev_io_stop (loop, w); -\& .. read from stdin here (or from w\->fd) and handle any I/O errors -\& } -\& -\& ... -\& struct ev_loop *loop = ev_default_init (0); -\& ev_io stdin_readable; -\& ev_io_init (&stdin_readable, stdin_readable_cb, STDIN_FILENO, EV_READ); -\& ev_io_start (loop, &stdin_readable); -\& ev_run (loop, 0); -.Ve -.ie n .SS """ev_timer"" \- relative and optionally repeating timeouts" -.el .SS "\f(CWev_timer\fP \- relative and optionally repeating timeouts" -.IX Subsection "ev_timer - relative and optionally repeating timeouts" -Timer watchers are simple relative timers that generate an event after a -given time, and optionally repeating in regular intervals after that. -.PP -The timers are based on real time, that is, if you register an event that -times out after an hour and you reset your system clock to January last -year, it will still time out after (roughly) one hour. \*(L"Roughly\*(R" because -detecting time jumps is hard, and some inaccuracies are unavoidable (the -monotonic clock option helps a lot here). -.PP -The callback is guaranteed to be invoked only \fIafter\fR its timeout has -passed (not \fIat\fR, so on systems with very low-resolution clocks this -might introduce a small delay, see \*(L"the special problem of being too -early\*(R", below). If multiple timers become ready during the same loop -iteration then the ones with earlier time-out values are invoked before -ones of the same priority with later time-out values (but this is no -longer true when a callback calls \f(CW\*(C`ev_run\*(C'\fR recursively). -.PP -\fIBe smart about timeouts\fR -.IX Subsection "Be smart about timeouts" -.PP -Many real-world problems involve some kind of timeout, usually for error -recovery. A typical example is an \s-1HTTP\s0 request \- if the other side hangs, -you want to raise some error after a while. -.PP -What follows are some ways to handle this problem, from obvious and -inefficient to smart and efficient. -.PP -In the following, a 60 second activity timeout is assumed \- a timeout that -gets reset to 60 seconds each time there is activity (e.g. each time some -data or other life sign was received). -.IP "1. Use a timer and stop, reinitialise and start it on activity." 4 -.IX Item "1. Use a timer and stop, reinitialise and start it on activity." -This is the most obvious, but not the most simple way: In the beginning, -start the watcher: -.Sp -.Vb 2 -\& ev_timer_init (timer, callback, 60., 0.); -\& ev_timer_start (loop, timer); -.Ve -.Sp -Then, each time there is some activity, \f(CW\*(C`ev_timer_stop\*(C'\fR it, initialise it -and start it again: -.Sp -.Vb 3 -\& ev_timer_stop (loop, timer); -\& ev_timer_set (timer, 60., 0.); -\& ev_timer_start (loop, timer); -.Ve -.Sp -This is relatively simple to implement, but means that each time there is -some activity, libev will first have to remove the timer from its internal -data structure and then add it again. Libev tries to be fast, but it's -still not a constant-time operation. -.ie n .IP "2. Use a timer and re-start it with ""ev_timer_again"" inactivity." 4 -.el .IP "2. Use a timer and re-start it with \f(CWev_timer_again\fR inactivity." 4 -.IX Item "2. Use a timer and re-start it with ev_timer_again inactivity." -This is the easiest way, and involves using \f(CW\*(C`ev_timer_again\*(C'\fR instead of -\&\f(CW\*(C`ev_timer_start\*(C'\fR. -.Sp -To implement this, configure an \f(CW\*(C`ev_timer\*(C'\fR with a \f(CW\*(C`repeat\*(C'\fR value -of \f(CW60\fR and then call \f(CW\*(C`ev_timer_again\*(C'\fR at start and each time you -successfully read or write some data. If you go into an idle state where -you do not expect data to travel on the socket, you can \f(CW\*(C`ev_timer_stop\*(C'\fR -the timer, and \f(CW\*(C`ev_timer_again\*(C'\fR will automatically restart it if need be. -.Sp -That means you can ignore both the \f(CW\*(C`ev_timer_start\*(C'\fR function and the -\&\f(CW\*(C`after\*(C'\fR argument to \f(CW\*(C`ev_timer_set\*(C'\fR, and only ever use the \f(CW\*(C`repeat\*(C'\fR -member and \f(CW\*(C`ev_timer_again\*(C'\fR. -.Sp -At start: -.Sp -.Vb 3 -\& ev_init (timer, callback); -\& timer\->repeat = 60.; -\& ev_timer_again (loop, timer); -.Ve -.Sp -Each time there is some activity: -.Sp -.Vb 1 -\& ev_timer_again (loop, timer); -.Ve -.Sp -It is even possible to change the time-out on the fly, regardless of -whether the watcher is active or not: -.Sp -.Vb 2 -\& timer\->repeat = 30.; -\& ev_timer_again (loop, timer); -.Ve -.Sp -This is slightly more efficient then stopping/starting the timer each time -you want to modify its timeout value, as libev does not have to completely -remove and re-insert the timer from/into its internal data structure. -.Sp -It is, however, even simpler than the \*(L"obvious\*(R" way to do it. -.IP "3. Let the timer time out, but then re-arm it as required." 4 -.IX Item "3. Let the timer time out, but then re-arm it as required." -This method is more tricky, but usually most efficient: Most timeouts are -relatively long compared to the intervals between other activity \- in -our example, within 60 seconds, there are usually many I/O events with -associated activity resets. -.Sp -In this case, it would be more efficient to leave the \f(CW\*(C`ev_timer\*(C'\fR alone, -but remember the time of last activity, and check for a real timeout only -within the callback: -.Sp -.Vb 3 -\& ev_tstamp timeout = 60.; -\& ev_tstamp last_activity; // time of last activity -\& ev_timer timer; -\& -\& static void -\& callback (EV_P_ ev_timer *w, int revents) -\& { -\& // calculate when the timeout would happen -\& ev_tstamp after = last_activity \- ev_now (EV_A) + timeout; -\& -\& // if negative, it means we the timeout already occurred -\& if (after < 0.) -\& { -\& // timeout occurred, take action -\& } -\& else -\& { -\& // callback was invoked, but there was some recent -\& // activity. simply restart the timer to time out -\& // after "after" seconds, which is the earliest time -\& // the timeout can occur. -\& ev_timer_set (w, after, 0.); -\& ev_timer_start (EV_A_ w); -\& } -\& } -.Ve -.Sp -To summarise the callback: first calculate in how many seconds the -timeout will occur (by calculating the absolute time when it would occur, -\&\f(CW\*(C`last_activity + timeout\*(C'\fR, and subtracting the current time, \f(CW\*(C`ev_now -(EV_A)\*(C'\fR from that). -.Sp -If this value is negative, then we are already past the timeout, i.e. we -timed out, and need to do whatever is needed in this case. -.Sp -Otherwise, we now the earliest time at which the timeout would trigger, -and simply start the timer with this timeout value. -.Sp -In other words, each time the callback is invoked it will check whether -the timeout occurred. If not, it will simply reschedule itself to check -again at the earliest time it could time out. Rinse. Repeat. -.Sp -This scheme causes more callback invocations (about one every 60 seconds -minus half the average time between activity), but virtually no calls to -libev to change the timeout. -.Sp -To start the machinery, simply initialise the watcher and set -\&\f(CW\*(C`last_activity\*(C'\fR to the current time (meaning there was some activity just -now), then call the callback, which will \*(L"do the right thing\*(R" and start -the timer: -.Sp -.Vb 3 -\& last_activity = ev_now (EV_A); -\& ev_init (&timer, callback); -\& callback (EV_A_ &timer, 0); -.Ve -.Sp -When there is some activity, simply store the current time in -\&\f(CW\*(C`last_activity\*(C'\fR, no libev calls at all: -.Sp -.Vb 2 -\& if (activity detected) -\& last_activity = ev_now (EV_A); -.Ve -.Sp -When your timeout value changes, then the timeout can be changed by simply -providing a new value, stopping the timer and calling the callback, which -will again do the right thing (for example, time out immediately :). -.Sp -.Vb 3 -\& timeout = new_value; -\& ev_timer_stop (EV_A_ &timer); -\& callback (EV_A_ &timer, 0); -.Ve -.Sp -This technique is slightly more complex, but in most cases where the -time-out is unlikely to be triggered, much more efficient. -.IP "4. Wee, just use a double-linked list for your timeouts." 4 -.IX Item "4. Wee, just use a double-linked list for your timeouts." -If there is not one request, but many thousands (millions...), all -employing some kind of timeout with the same timeout value, then one can -do even better: -.Sp -When starting the timeout, calculate the timeout value and put the timeout -at the \fIend\fR of the list. -.Sp -Then use an \f(CW\*(C`ev_timer\*(C'\fR to fire when the timeout at the \fIbeginning\fR of -the list is expected to fire (for example, using the technique #3). -.Sp -When there is some activity, remove the timer from the list, recalculate -the timeout, append it to the end of the list again, and make sure to -update the \f(CW\*(C`ev_timer\*(C'\fR if it was taken from the beginning of the list. -.Sp -This way, one can manage an unlimited number of timeouts in O(1) time for -starting, stopping and updating the timers, at the expense of a major -complication, and having to use a constant timeout. The constant timeout -ensures that the list stays sorted. -.PP -So which method the best? -.PP -Method #2 is a simple no-brain-required solution that is adequate in most -situations. Method #3 requires a bit more thinking, but handles many cases -better, and isn't very complicated either. In most case, choosing either -one is fine, with #3 being better in typical situations. -.PP -Method #1 is almost always a bad idea, and buys you nothing. Method #4 is -rather complicated, but extremely efficient, something that really pays -off after the first million or so of active timers, i.e. it's usually -overkill :) -.PP -\fIThe special problem of being too early\fR -.IX Subsection "The special problem of being too early" -.PP -If you ask a timer to call your callback after three seconds, then -you expect it to be invoked after three seconds \- but of course, this -cannot be guaranteed to infinite precision. Less obviously, it cannot be -guaranteed to any precision by libev \- imagine somebody suspending the -process with a \s-1STOP\s0 signal for a few hours for example. -.PP -So, libev tries to invoke your callback as soon as possible \fIafter\fR the -delay has occurred, but cannot guarantee this. -.PP -A less obvious failure mode is calling your callback too early: many event -loops compare timestamps with a \*(L"elapsed delay >= requested delay\*(R", but -this can cause your callback to be invoked much earlier than you would -expect. -.PP -To see why, imagine a system with a clock that only offers full second -resolution (think windows if you can't come up with a broken enough \s-1OS\s0 -yourself). If you schedule a one-second timer at the time 500.9, then the -event loop will schedule your timeout to elapse at a system time of 500 -(500.9 truncated to the resolution) + 1, or 501. -.PP -If an event library looks at the timeout 0.1s later, it will see \*(L"501 >= -501\*(R" and invoke the callback 0.1s after it was started, even though a -one-second delay was requested \- this is being \*(L"too early\*(R", despite best -intentions. -.PP -This is the reason why libev will never invoke the callback if the elapsed -delay equals the requested delay, but only when the elapsed delay is -larger than the requested delay. In the example above, libev would only invoke -the callback at system time 502, or 1.1s after the timer was started. -.PP -So, while libev cannot guarantee that your callback will be invoked -exactly when requested, it \fIcan\fR and \fIdoes\fR guarantee that the requested -delay has actually elapsed, or in other words, it always errs on the \*(L"too -late\*(R" side of things. -.PP -\fIThe special problem of time updates\fR -.IX Subsection "The special problem of time updates" -.PP -Establishing the current time is a costly operation (it usually takes -at least one system call): \s-1EV\s0 therefore updates its idea of the current -time only before and after \f(CW\*(C`ev_run\*(C'\fR collects new events, which causes a -growing difference between \f(CW\*(C`ev_now ()\*(C'\fR and \f(CW\*(C`ev_time ()\*(C'\fR when handling -lots of events in one iteration. -.PP -The relative timeouts are calculated relative to the \f(CW\*(C`ev_now ()\*(C'\fR -time. This is usually the right thing as this timestamp refers to the time -of the event triggering whatever timeout you are modifying/starting. If -you suspect event processing to be delayed and you \fIneed\fR to base the -timeout on the current time, use something like the following to adjust -for it: -.PP -.Vb 1 -\& ev_timer_set (&timer, after + (ev_time () \- ev_now ()), 0.); -.Ve -.PP -If the event loop is suspended for a long time, you can also force an -update of the time returned by \f(CW\*(C`ev_now ()\*(C'\fR by calling \f(CW\*(C`ev_now_update -()\*(C'\fR, although that will push the event time of all outstanding events -further into the future. -.PP -\fIThe special problem of unsynchronised clocks\fR -.IX Subsection "The special problem of unsynchronised clocks" -.PP -Modern systems have a variety of clocks \- libev itself uses the normal -\&\*(L"wall clock\*(R" clock and, if available, the monotonic clock (to avoid time -jumps). -.PP -Neither of these clocks is synchronised with each other or any other clock -on the system, so \f(CW\*(C`ev_time ()\*(C'\fR might return a considerably different time -than \f(CW\*(C`gettimeofday ()\*(C'\fR or \f(CW\*(C`time ()\*(C'\fR. On a GNU/Linux system, for example, -a call to \f(CW\*(C`gettimeofday\*(C'\fR might return a second count that is one higher -than a directly following call to \f(CW\*(C`time\*(C'\fR. -.PP -The moral of this is to only compare libev-related timestamps with -\&\f(CW\*(C`ev_time ()\*(C'\fR and \f(CW\*(C`ev_now ()\*(C'\fR, at least if you want better precision than -a second or so. -.PP -One more problem arises due to this lack of synchronisation: if libev uses -the system monotonic clock and you compare timestamps from \f(CW\*(C`ev_time\*(C'\fR -or \f(CW\*(C`ev_now\*(C'\fR from when you started your timer and when your callback is -invoked, you will find that sometimes the callback is a bit \*(L"early\*(R". -.PP -This is because \f(CW\*(C`ev_timer\*(C'\fRs work in real time, not wall clock time, so -libev makes sure your callback is not invoked before the delay happened, -\&\fImeasured according to the real time\fR, not the system clock. -.PP -If your timeouts are based on a physical timescale (e.g. \*(L"time out this -connection after 100 seconds\*(R") then this shouldn't bother you as it is -exactly the right behaviour. -.PP -If you want to compare wall clock/system timestamps to your timers, then -you need to use \f(CW\*(C`ev_periodic\*(C'\fRs, as these are based on the wall clock -time, where your comparisons will always generate correct results. -.PP -\fIThe special problems of suspended animation\fR -.IX Subsection "The special problems of suspended animation" -.PP -When you leave the server world it is quite customary to hit machines that -can suspend/hibernate \- what happens to the clocks during such a suspend? -.PP -Some quick tests made with a Linux 2.6.28 indicate that a suspend freezes -all processes, while the clocks (\f(CW\*(C`times\*(C'\fR, \f(CW\*(C`CLOCK_MONOTONIC\*(C'\fR) continue -to run until the system is suspended, but they will not advance while the -system is suspended. That means, on resume, it will be as if the program -was frozen for a few seconds, but the suspend time will not be counted -towards \f(CW\*(C`ev_timer\*(C'\fR when a monotonic clock source is used. The real time -clock advanced as expected, but if it is used as sole clocksource, then a -long suspend would be detected as a time jump by libev, and timers would -be adjusted accordingly. -.PP -I would not be surprised to see different behaviour in different between -operating systems, \s-1OS\s0 versions or even different hardware. -.PP -The other form of suspend (job control, or sending a \s-1SIGSTOP\s0) will see a -time jump in the monotonic clocks and the realtime clock. If the program -is suspended for a very long time, and monotonic clock sources are in use, -then you can expect \f(CW\*(C`ev_timer\*(C'\fRs to expire as the full suspension time -will be counted towards the timers. When no monotonic clock source is in -use, then libev will again assume a timejump and adjust accordingly. -.PP -It might be beneficial for this latter case to call \f(CW\*(C`ev_suspend\*(C'\fR -and \f(CW\*(C`ev_resume\*(C'\fR in code that handles \f(CW\*(C`SIGTSTP\*(C'\fR, to at least get -deterministic behaviour in this case (you can do nothing against -\&\f(CW\*(C`SIGSTOP\*(C'\fR). -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_timer_init (ev_timer *, callback, ev_tstamp after, ev_tstamp repeat)" 4 -.IX Item "ev_timer_init (ev_timer *, callback, ev_tstamp after, ev_tstamp repeat)" -.PD 0 -.IP "ev_timer_set (ev_timer *, ev_tstamp after, ev_tstamp repeat)" 4 -.IX Item "ev_timer_set (ev_timer *, ev_tstamp after, ev_tstamp repeat)" -.PD -Configure the timer to trigger after \f(CW\*(C`after\*(C'\fR seconds (fractional and -negative values are supported). If \f(CW\*(C`repeat\*(C'\fR is \f(CW0.\fR, then it will -automatically be stopped once the timeout is reached. If it is positive, -then the timer will automatically be configured to trigger again \f(CW\*(C`repeat\*(C'\fR -seconds later, again, and again, until stopped manually. -.Sp -The timer itself will do a best-effort at avoiding drift, that is, if -you configure a timer to trigger every 10 seconds, then it will normally -trigger at exactly 10 second intervals. If, however, your program cannot -keep up with the timer (because it takes longer than those 10 seconds to -do stuff) the timer will not fire more than once per event loop iteration. -.IP "ev_timer_again (loop, ev_timer *)" 4 -.IX Item "ev_timer_again (loop, ev_timer *)" -This will act as if the timer timed out, and restarts it again if it is -repeating. It basically works like calling \f(CW\*(C`ev_timer_stop\*(C'\fR, updating the -timeout to the \f(CW\*(C`repeat\*(C'\fR value and calling \f(CW\*(C`ev_timer_start\*(C'\fR. -.Sp -The exact semantics are as in the following rules, all of which will be -applied to the watcher: -.RS 4 -.IP "If the timer is pending, the pending status is always cleared." 4 -.IX Item "If the timer is pending, the pending status is always cleared." -.PD 0 -.IP "If the timer is started but non-repeating, stop it (as if it timed out, without invoking it)." 4 -.IX Item "If the timer is started but non-repeating, stop it (as if it timed out, without invoking it)." -.ie n .IP "If the timer is repeating, make the ""repeat"" value the new timeout and start the timer, if necessary." 4 -.el .IP "If the timer is repeating, make the \f(CWrepeat\fR value the new timeout and start the timer, if necessary." 4 -.IX Item "If the timer is repeating, make the repeat value the new timeout and start the timer, if necessary." -.RE -.RS 4 -.PD -.Sp -This sounds a bit complicated, see \*(L"Be smart about timeouts\*(R", above, for a -usage example. -.RE -.IP "ev_tstamp ev_timer_remaining (loop, ev_timer *)" 4 -.IX Item "ev_tstamp ev_timer_remaining (loop, ev_timer *)" -Returns the remaining time until a timer fires. If the timer is active, -then this time is relative to the current event loop time, otherwise it's -the timeout value currently configured. -.Sp -That is, after an \f(CW\*(C`ev_timer_set (w, 5, 7)\*(C'\fR, \f(CW\*(C`ev_timer_remaining\*(C'\fR returns -\&\f(CW5\fR. When the timer is started and one second passes, \f(CW\*(C`ev_timer_remaining\*(C'\fR -will return \f(CW4\fR. When the timer expires and is restarted, it will return -roughly \f(CW7\fR (likely slightly less as callback invocation takes some time, -too), and so on. -.IP "ev_tstamp repeat [read\-write]" 4 -.IX Item "ev_tstamp repeat [read-write]" -The current \f(CW\*(C`repeat\*(C'\fR value. Will be used each time the watcher times out -or \f(CW\*(C`ev_timer_again\*(C'\fR is called, and determines the next timeout (if any), -which is also when any modifications are taken into account. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Create a timer that fires after 60 seconds. -.PP -.Vb 5 -\& static void -\& one_minute_cb (struct ev_loop *loop, ev_timer *w, int revents) -\& { -\& .. one minute over, w is actually stopped right here -\& } -\& -\& ev_timer mytimer; -\& ev_timer_init (&mytimer, one_minute_cb, 60., 0.); -\& ev_timer_start (loop, &mytimer); -.Ve -.PP -Example: Create a timeout timer that times out after 10 seconds of -inactivity. -.PP -.Vb 5 -\& static void -\& timeout_cb (struct ev_loop *loop, ev_timer *w, int revents) -\& { -\& .. ten seconds without any activity -\& } -\& -\& ev_timer mytimer; -\& ev_timer_init (&mytimer, timeout_cb, 0., 10.); /* note, only repeat used */ -\& ev_timer_again (&mytimer); /* start timer */ -\& ev_run (loop, 0); -\& -\& // and in some piece of code that gets executed on any "activity": -\& // reset the timeout to start ticking again at 10 seconds -\& ev_timer_again (&mytimer); -.Ve -.ie n .SS """ev_periodic"" \- to cron or not to cron?" -.el .SS "\f(CWev_periodic\fP \- to cron or not to cron?" -.IX Subsection "ev_periodic - to cron or not to cron?" -Periodic watchers are also timers of a kind, but they are very versatile -(and unfortunately a bit complex). -.PP -Unlike \f(CW\*(C`ev_timer\*(C'\fR, periodic watchers are not based on real time (or -relative time, the physical time that passes) but on wall clock time -(absolute time, the thing you can read on your calendar or clock). The -difference is that wall clock time can run faster or slower than real -time, and time jumps are not uncommon (e.g. when you adjust your -wrist-watch). -.PP -You can tell a periodic watcher to trigger after some specific point -in time: for example, if you tell a periodic watcher to trigger \*(L"in 10 -seconds\*(R" (by specifying e.g. \f(CW\*(C`ev_now () + 10.\*(C'\fR, that is, an absolute time -not a delay) and then reset your system clock to January of the previous -year, then it will take a year or more to trigger the event (unlike an -\&\f(CW\*(C`ev_timer\*(C'\fR, which would still trigger roughly 10 seconds after starting -it, as it uses a relative timeout). -.PP -\&\f(CW\*(C`ev_periodic\*(C'\fR watchers can also be used to implement vastly more complex -timers, such as triggering an event on each \*(L"midnight, local time\*(R", or -other complicated rules. This cannot easily be done with \f(CW\*(C`ev_timer\*(C'\fR -watchers, as those cannot react to time jumps. -.PP -As with timers, the callback is guaranteed to be invoked only when the -point in time where it is supposed to trigger has passed. If multiple -timers become ready during the same loop iteration then the ones with -earlier time-out values are invoked before ones with later time-out values -(but this is no longer true when a callback calls \f(CW\*(C`ev_run\*(C'\fR recursively). -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_periodic_init (ev_periodic *, callback, ev_tstamp offset, ev_tstamp interval, reschedule_cb)" 4 -.IX Item "ev_periodic_init (ev_periodic *, callback, ev_tstamp offset, ev_tstamp interval, reschedule_cb)" -.PD 0 -.IP "ev_periodic_set (ev_periodic *, ev_tstamp offset, ev_tstamp interval, reschedule_cb)" 4 -.IX Item "ev_periodic_set (ev_periodic *, ev_tstamp offset, ev_tstamp interval, reschedule_cb)" -.PD -Lots of arguments, let's sort it out... There are basically three modes of -operation, and we will explain them from simplest to most complex: -.RS 4 -.IP "\(bu" 4 -absolute timer (offset = absolute time, interval = 0, reschedule_cb = 0) -.Sp -In this configuration the watcher triggers an event after the wall clock -time \f(CW\*(C`offset\*(C'\fR has passed. It will not repeat and will not adjust when a -time jump occurs, that is, if it is to be run at January 1st 2011 then it -will be stopped and invoked when the system clock reaches or surpasses -this point in time. -.IP "\(bu" 4 -repeating interval timer (offset = offset within interval, interval > 0, reschedule_cb = 0) -.Sp -In this mode the watcher will always be scheduled to time out at the next -\&\f(CW\*(C`offset + N * interval\*(C'\fR time (for some integer N, which can also be -negative) and then repeat, regardless of any time jumps. The \f(CW\*(C`offset\*(C'\fR -argument is merely an offset into the \f(CW\*(C`interval\*(C'\fR periods. -.Sp -This can be used to create timers that do not drift with respect to the -system clock, for example, here is an \f(CW\*(C`ev_periodic\*(C'\fR that triggers each -hour, on the hour (with respect to \s-1UTC\s0): -.Sp -.Vb 1 -\& ev_periodic_set (&periodic, 0., 3600., 0); -.Ve -.Sp -This doesn't mean there will always be 3600 seconds in between triggers, -but only that the callback will be called when the system time shows a -full hour (\s-1UTC\s0), or more correctly, when the system time is evenly divisible -by 3600. -.Sp -Another way to think about it (for the mathematically inclined) is that -\&\f(CW\*(C`ev_periodic\*(C'\fR will try to run the callback in this mode at the next possible -time where \f(CW\*(C`time = offset (mod interval)\*(C'\fR, regardless of any time jumps. -.Sp -The \f(CW\*(C`interval\*(C'\fR \fI\s-1MUST\s0\fR be positive, and for numerical stability, the -interval value should be higher than \f(CW\*(C`1/8192\*(C'\fR (which is around 100 -microseconds) and \f(CW\*(C`offset\*(C'\fR should be higher than \f(CW0\fR and should have -at most a similar magnitude as the current time (say, within a factor of -ten). Typical values for offset are, in fact, \f(CW0\fR or something between -\&\f(CW0\fR and \f(CW\*(C`interval\*(C'\fR, which is also the recommended range. -.Sp -Note also that there is an upper limit to how often a timer can fire (\s-1CPU\s0 -speed for example), so if \f(CW\*(C`interval\*(C'\fR is very small then timing stability -will of course deteriorate. Libev itself tries to be exact to be about one -millisecond (if the \s-1OS\s0 supports it and the machine is fast enough). -.IP "\(bu" 4 -manual reschedule mode (offset ignored, interval ignored, reschedule_cb = callback) -.Sp -In this mode the values for \f(CW\*(C`interval\*(C'\fR and \f(CW\*(C`offset\*(C'\fR are both being -ignored. Instead, each time the periodic watcher gets scheduled, the -reschedule callback will be called with the watcher as first, and the -current time as second argument. -.Sp -\&\s-1NOTE:\s0 \fIThis callback \s-1MUST NOT\s0 stop or destroy any periodic watcher, ever, -or make \s-1ANY\s0 other event loop modifications whatsoever, unless explicitly -allowed by documentation here\fR. -.Sp -If you need to stop it, return \f(CW\*(C`now + 1e30\*(C'\fR (or so, fudge fudge) and stop -it afterwards (e.g. by starting an \f(CW\*(C`ev_prepare\*(C'\fR watcher, which is the -only event loop modification you are allowed to do). -.Sp -The callback prototype is \f(CW\*(C`ev_tstamp (*reschedule_cb)(ev_periodic -*w, ev_tstamp now)\*(C'\fR, e.g.: -.Sp -.Vb 5 -\& static ev_tstamp -\& my_rescheduler (ev_periodic *w, ev_tstamp now) -\& { -\& return now + 60.; -\& } -.Ve -.Sp -It must return the next time to trigger, based on the passed time value -(that is, the lowest time value larger than to the second argument). It -will usually be called just before the callback will be triggered, but -might be called at other times, too. -.Sp -\&\s-1NOTE:\s0 \fIThis callback must always return a time that is higher than or -equal to the passed \f(CI\*(C`now\*(C'\fI value\fR. -.Sp -This can be used to create very complex timers, such as a timer that -triggers on \*(L"next midnight, local time\*(R". To do this, you would calculate -the next midnight after \f(CW\*(C`now\*(C'\fR and return the timestamp value for -this. Here is a (completely untested, no error checking) example on how to -do this: -.Sp -.Vb 1 -\& #include -\& -\& static ev_tstamp -\& my_rescheduler (ev_periodic *w, ev_tstamp now) -\& { -\& time_t tnow = (time_t)now; -\& struct tm tm; -\& localtime_r (&tnow, &tm); -\& -\& tm.tm_sec = tm.tm_min = tm.tm_hour = 0; // midnight current day -\& ++tm.tm_mday; // midnight next day -\& -\& return mktime (&tm); -\& } -.Ve -.Sp -Note: this code might run into trouble on days that have more then two -midnights (beginning and end). -.RE -.RS 4 -.RE -.IP "ev_periodic_again (loop, ev_periodic *)" 4 -.IX Item "ev_periodic_again (loop, ev_periodic *)" -Simply stops and restarts the periodic watcher again. This is only useful -when you changed some parameters or the reschedule callback would return -a different time than the last time it was called (e.g. in a crond like -program when the crontabs have changed). -.IP "ev_tstamp ev_periodic_at (ev_periodic *)" 4 -.IX Item "ev_tstamp ev_periodic_at (ev_periodic *)" -When active, returns the absolute time that the watcher is supposed -to trigger next. This is not the same as the \f(CW\*(C`offset\*(C'\fR argument to -\&\f(CW\*(C`ev_periodic_set\*(C'\fR, but indeed works even in interval and manual -rescheduling modes. -.IP "ev_tstamp offset [read\-write]" 4 -.IX Item "ev_tstamp offset [read-write]" -When repeating, this contains the offset value, otherwise this is the -absolute point in time (the \f(CW\*(C`offset\*(C'\fR value passed to \f(CW\*(C`ev_periodic_set\*(C'\fR, -although libev might modify this value for better numerical stability). -.Sp -Can be modified any time, but changes only take effect when the periodic -timer fires or \f(CW\*(C`ev_periodic_again\*(C'\fR is being called. -.IP "ev_tstamp interval [read\-write]" 4 -.IX Item "ev_tstamp interval [read-write]" -The current interval value. Can be modified any time, but changes only -take effect when the periodic timer fires or \f(CW\*(C`ev_periodic_again\*(C'\fR is being -called. -.IP "ev_tstamp (*reschedule_cb)(ev_periodic *w, ev_tstamp now) [read\-write]" 4 -.IX Item "ev_tstamp (*reschedule_cb)(ev_periodic *w, ev_tstamp now) [read-write]" -The current reschedule callback, or \f(CW0\fR, if this functionality is -switched off. Can be changed any time, but changes only take effect when -the periodic timer fires or \f(CW\*(C`ev_periodic_again\*(C'\fR is being called. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Call a callback every hour, or, more precisely, whenever the -system time is divisible by 3600. The callback invocation times have -potentially a lot of jitter, but good long-term stability. -.PP -.Vb 5 -\& static void -\& clock_cb (struct ev_loop *loop, ev_periodic *w, int revents) -\& { -\& ... its now a full hour (UTC, or TAI or whatever your clock follows) -\& } -\& -\& ev_periodic hourly_tick; -\& ev_periodic_init (&hourly_tick, clock_cb, 0., 3600., 0); -\& ev_periodic_start (loop, &hourly_tick); -.Ve -.PP -Example: The same as above, but use a reschedule callback to do it: -.PP -.Vb 1 -\& #include -\& -\& static ev_tstamp -\& my_scheduler_cb (ev_periodic *w, ev_tstamp now) -\& { -\& return now + (3600. \- fmod (now, 3600.)); -\& } -\& -\& ev_periodic_init (&hourly_tick, clock_cb, 0., 0., my_scheduler_cb); -.Ve -.PP -Example: Call a callback every hour, starting now: -.PP -.Vb 4 -\& ev_periodic hourly_tick; -\& ev_periodic_init (&hourly_tick, clock_cb, -\& fmod (ev_now (loop), 3600.), 3600., 0); -\& ev_periodic_start (loop, &hourly_tick); -.Ve -.ie n .SS """ev_signal"" \- signal me when a signal gets signalled!" -.el .SS "\f(CWev_signal\fP \- signal me when a signal gets signalled!" -.IX Subsection "ev_signal - signal me when a signal gets signalled!" -Signal watchers will trigger an event when the process receives a specific -signal one or more times. Even though signals are very asynchronous, libev -will try its best to deliver signals synchronously, i.e. as part of the -normal event processing, like any other event. -.PP -If you want signals to be delivered truly asynchronously, just use -\&\f(CW\*(C`sigaction\*(C'\fR as you would do without libev and forget about sharing -the signal. You can even use \f(CW\*(C`ev_async\*(C'\fR from a signal handler to -synchronously wake up an event loop. -.PP -You can configure as many watchers as you like for the same signal, but -only within the same loop, i.e. you can watch for \f(CW\*(C`SIGINT\*(C'\fR in your -default loop and for \f(CW\*(C`SIGIO\*(C'\fR in another loop, but you cannot watch for -\&\f(CW\*(C`SIGINT\*(C'\fR in both the default loop and another loop at the same time. At -the moment, \f(CW\*(C`SIGCHLD\*(C'\fR is permanently tied to the default loop. -.PP -Only after the first watcher for a signal is started will libev actually -register something with the kernel. It thus coexists with your own signal -handlers as long as you don't register any with libev for the same signal. -.PP -If possible and supported, libev will install its handlers with -\&\f(CW\*(C`SA_RESTART\*(C'\fR (or equivalent) behaviour enabled, so system calls should -not be unduly interrupted. If you have a problem with system calls getting -interrupted by signals you can block all signals in an \f(CW\*(C`ev_check\*(C'\fR watcher -and unblock them in an \f(CW\*(C`ev_prepare\*(C'\fR watcher. -.PP -\fIThe special problem of inheritance over fork/execve/pthread_create\fR -.IX Subsection "The special problem of inheritance over fork/execve/pthread_create" -.PP -Both the signal mask (\f(CW\*(C`sigprocmask\*(C'\fR) and the signal disposition -(\f(CW\*(C`sigaction\*(C'\fR) are unspecified after starting a signal watcher (and after -stopping it again), that is, libev might or might not block the signal, -and might or might not set or restore the installed signal handler (but -see \f(CW\*(C`EVFLAG_NOSIGMASK\*(C'\fR). -.PP -While this does not matter for the signal disposition (libev never -sets signals to \f(CW\*(C`SIG_IGN\*(C'\fR, so handlers will be reset to \f(CW\*(C`SIG_DFL\*(C'\fR on -\&\f(CW\*(C`execve\*(C'\fR), this matters for the signal mask: many programs do not expect -certain signals to be blocked. -.PP -This means that before calling \f(CW\*(C`exec\*(C'\fR (from the child) you should reset -the signal mask to whatever \*(L"default\*(R" you expect (all clear is a good -choice usually). -.PP -The simplest way to ensure that the signal mask is reset in the child is -to install a fork handler with \f(CW\*(C`pthread_atfork\*(C'\fR that resets it. That will -catch fork calls done by libraries (such as the libc) as well. -.PP -In current versions of libev, the signal will not be blocked indefinitely -unless you use the \f(CW\*(C`signalfd\*(C'\fR \s-1API\s0 (\f(CW\*(C`EV_SIGNALFD\*(C'\fR). While this reduces -the window of opportunity for problems, it will not go away, as libev -\&\fIhas\fR to modify the signal mask, at least temporarily. -.PP -So I can't stress this enough: \fIIf you do not reset your signal mask when -you expect it to be empty, you have a race condition in your code\fR. This -is not a libev-specific thing, this is true for most event libraries. -.PP -\fIThe special problem of threads signal handling\fR -.IX Subsection "The special problem of threads signal handling" -.PP -\&\s-1POSIX\s0 threads has problematic signal handling semantics, specifically, -a lot of functionality (sigfd, sigwait etc.) only really works if all -threads in a process block signals, which is hard to achieve. -.PP -When you want to use sigwait (or mix libev signal handling with your own -for the same signals), you can tackle this problem by globally blocking -all signals before creating any threads (or creating them with a fully set -sigprocmask) and also specifying the \f(CW\*(C`EVFLAG_NOSIGMASK\*(C'\fR when creating -loops. Then designate one thread as \*(L"signal receiver thread\*(R" which handles -these signals. You can pass on any signals that libev might be interested -in by calling \f(CW\*(C`ev_feed_signal\*(C'\fR. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_signal_init (ev_signal *, callback, int signum)" 4 -.IX Item "ev_signal_init (ev_signal *, callback, int signum)" -.PD 0 -.IP "ev_signal_set (ev_signal *, int signum)" 4 -.IX Item "ev_signal_set (ev_signal *, int signum)" -.PD -Configures the watcher to trigger on the given signal number (usually one -of the \f(CW\*(C`SIGxxx\*(C'\fR constants). -.IP "int signum [read\-only]" 4 -.IX Item "int signum [read-only]" -The signal the watcher watches out for. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Try to exit cleanly on \s-1SIGINT.\s0 -.PP -.Vb 5 -\& static void -\& sigint_cb (struct ev_loop *loop, ev_signal *w, int revents) -\& { -\& ev_break (loop, EVBREAK_ALL); -\& } -\& -\& ev_signal signal_watcher; -\& ev_signal_init (&signal_watcher, sigint_cb, SIGINT); -\& ev_signal_start (loop, &signal_watcher); -.Ve -.ie n .SS """ev_child"" \- watch out for process status changes" -.el .SS "\f(CWev_child\fP \- watch out for process status changes" -.IX Subsection "ev_child - watch out for process status changes" -Child watchers trigger when your process receives a \s-1SIGCHLD\s0 in response to -some child status changes (most typically when a child of yours dies or -exits). It is permissible to install a child watcher \fIafter\fR the child -has been forked (which implies it might have already exited), as long -as the event loop isn't entered (or is continued from a watcher), i.e., -forking and then immediately registering a watcher for the child is fine, -but forking and registering a watcher a few event loop iterations later or -in the next callback invocation is not. -.PP -Only the default event loop is capable of handling signals, and therefore -you can only register child watchers in the default event loop. -.PP -Due to some design glitches inside libev, child watchers will always be -handled at maximum priority (their priority is set to \f(CW\*(C`EV_MAXPRI\*(C'\fR by -libev) -.PP -\fIProcess Interaction\fR -.IX Subsection "Process Interaction" -.PP -Libev grabs \f(CW\*(C`SIGCHLD\*(C'\fR as soon as the default event loop is -initialised. This is necessary to guarantee proper behaviour even if the -first child watcher is started after the child exits. The occurrence -of \f(CW\*(C`SIGCHLD\*(C'\fR is recorded asynchronously, but child reaping is done -synchronously as part of the event loop processing. Libev always reaps all -children, even ones not watched. -.PP -\fIOverriding the Built-In Processing\fR -.IX Subsection "Overriding the Built-In Processing" -.PP -Libev offers no special support for overriding the built-in child -processing, but if your application collides with libev's default child -handler, you can override it easily by installing your own handler for -\&\f(CW\*(C`SIGCHLD\*(C'\fR after initialising the default loop, and making sure the -default loop never gets destroyed. You are encouraged, however, to use an -event-based approach to child reaping and thus use libev's support for -that, so other libev users can use \f(CW\*(C`ev_child\*(C'\fR watchers freely. -.PP -\fIStopping the Child Watcher\fR -.IX Subsection "Stopping the Child Watcher" -.PP -Currently, the child watcher never gets stopped, even when the -child terminates, so normally one needs to stop the watcher in the -callback. Future versions of libev might stop the watcher automatically -when a child exit is detected (calling \f(CW\*(C`ev_child_stop\*(C'\fR twice is not a -problem). -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_child_init (ev_child *, callback, int pid, int trace)" 4 -.IX Item "ev_child_init (ev_child *, callback, int pid, int trace)" -.PD 0 -.IP "ev_child_set (ev_child *, int pid, int trace)" 4 -.IX Item "ev_child_set (ev_child *, int pid, int trace)" -.PD -Configures the watcher to wait for status changes of process \f(CW\*(C`pid\*(C'\fR (or -\&\fIany\fR process if \f(CW\*(C`pid\*(C'\fR is specified as \f(CW0\fR). The callback can look -at the \f(CW\*(C`rstatus\*(C'\fR member of the \f(CW\*(C`ev_child\*(C'\fR watcher structure to see -the status word (use the macros from \f(CW\*(C`sys/wait.h\*(C'\fR and see your systems -\&\f(CW\*(C`waitpid\*(C'\fR documentation). The \f(CW\*(C`rpid\*(C'\fR member contains the pid of the -process causing the status change. \f(CW\*(C`trace\*(C'\fR must be either \f(CW0\fR (only -activate the watcher when the process terminates) or \f(CW1\fR (additionally -activate the watcher when the process is stopped or continued). -.IP "int pid [read\-only]" 4 -.IX Item "int pid [read-only]" -The process id this watcher watches out for, or \f(CW0\fR, meaning any process id. -.IP "int rpid [read\-write]" 4 -.IX Item "int rpid [read-write]" -The process id that detected a status change. -.IP "int rstatus [read\-write]" 4 -.IX Item "int rstatus [read-write]" -The process exit/trace status caused by \f(CW\*(C`rpid\*(C'\fR (see your systems -\&\f(CW\*(C`waitpid\*(C'\fR and \f(CW\*(C`sys/wait.h\*(C'\fR documentation for details). -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: \f(CW\*(C`fork()\*(C'\fR a new process and install a child handler to wait for -its completion. -.PP -.Vb 1 -\& ev_child cw; -\& -\& static void -\& child_cb (EV_P_ ev_child *w, int revents) -\& { -\& ev_child_stop (EV_A_ w); -\& printf ("process %d exited with status %x\en", w\->rpid, w\->rstatus); -\& } -\& -\& pid_t pid = fork (); -\& -\& if (pid < 0) -\& // error -\& else if (pid == 0) -\& { -\& // the forked child executes here -\& exit (1); -\& } -\& else -\& { -\& ev_child_init (&cw, child_cb, pid, 0); -\& ev_child_start (EV_DEFAULT_ &cw); -\& } -.Ve -.ie n .SS """ev_stat"" \- did the file attributes just change?" -.el .SS "\f(CWev_stat\fP \- did the file attributes just change?" -.IX Subsection "ev_stat - did the file attributes just change?" -This watches a file system path for attribute changes. That is, it calls -\&\f(CW\*(C`stat\*(C'\fR on that path in regular intervals (or when the \s-1OS\s0 says it changed) -and sees if it changed compared to the last time, invoking the callback -if it did. Starting the watcher \f(CW\*(C`stat\*(C'\fR's the file, so only changes that -happen after the watcher has been started will be reported. -.PP -The path does not need to exist: changing from \*(L"path exists\*(R" to \*(L"path does -not exist\*(R" is a status change like any other. The condition \*(L"path does not -exist\*(R" (or more correctly \*(L"path cannot be stat'ed\*(R") is signified by the -\&\f(CW\*(C`st_nlink\*(C'\fR field being zero (which is otherwise always forced to be at -least one) and all the other fields of the stat buffer having unspecified -contents. -.PP -The path \fImust not\fR end in a slash or contain special components such as -\&\f(CW\*(C`.\*(C'\fR or \f(CW\*(C`..\*(C'\fR. The path \fIshould\fR be absolute: If it is relative and -your working directory changes, then the behaviour is undefined. -.PP -Since there is no portable change notification interface available, the -portable implementation simply calls \f(CWstat(2)\fR regularly on the path -to see if it changed somehow. You can specify a recommended polling -interval for this case. If you specify a polling interval of \f(CW0\fR (highly -recommended!) then a \fIsuitable, unspecified default\fR value will be used -(which you can expect to be around five seconds, although this might -change dynamically). Libev will also impose a minimum interval which is -currently around \f(CW0.1\fR, but that's usually overkill. -.PP -This watcher type is not meant for massive numbers of stat watchers, -as even with OS-supported change notifications, this can be -resource-intensive. -.PP -At the time of this writing, the only OS-specific interface implemented -is the Linux inotify interface (implementing kqueue support is left as an -exercise for the reader. Note, however, that the author sees no way of -implementing \f(CW\*(C`ev_stat\*(C'\fR semantics with kqueue, except as a hint). -.PP -\fI\s-1ABI\s0 Issues (Largefile Support)\fR -.IX Subsection "ABI Issues (Largefile Support)" -.PP -Libev by default (unless the user overrides this) uses the default -compilation environment, which means that on systems with large file -support disabled by default, you get the 32 bit version of the stat -structure. When using the library from programs that change the \s-1ABI\s0 to -use 64 bit file offsets the programs will fail. In that case you have to -compile libev with the same flags to get binary compatibility. This is -obviously the case with any flags that change the \s-1ABI,\s0 but the problem is -most noticeably displayed with ev_stat and large file support. -.PP -The solution for this is to lobby your distribution maker to make large -file interfaces available by default (as e.g. FreeBSD does) and not -optional. Libev cannot simply switch on large file support because it has -to exchange stat structures with application programs compiled using the -default compilation environment. -.PP -\fIInotify and Kqueue\fR -.IX Subsection "Inotify and Kqueue" -.PP -When \f(CW\*(C`inotify (7)\*(C'\fR support has been compiled into libev and present at -runtime, it will be used to speed up change detection where possible. The -inotify descriptor will be created lazily when the first \f(CW\*(C`ev_stat\*(C'\fR -watcher is being started. -.PP -Inotify presence does not change the semantics of \f(CW\*(C`ev_stat\*(C'\fR watchers -except that changes might be detected earlier, and in some cases, to avoid -making regular \f(CW\*(C`stat\*(C'\fR calls. Even in the presence of inotify support -there are many cases where libev has to resort to regular \f(CW\*(C`stat\*(C'\fR polling, -but as long as kernel 2.6.25 or newer is used (2.6.24 and older have too -many bugs), the path exists (i.e. stat succeeds), and the path resides on -a local filesystem (libev currently assumes only ext2/3, jfs, reiserfs and -xfs are fully working) libev usually gets away without polling. -.PP -There is no support for kqueue, as apparently it cannot be used to -implement this functionality, due to the requirement of having a file -descriptor open on the object at all times, and detecting renames, unlinks -etc. is difficult. -.PP -\fI\f(CI\*(C`stat ()\*(C'\fI is a synchronous operation\fR -.IX Subsection "stat () is a synchronous operation" -.PP -Libev doesn't normally do any kind of I/O itself, and so is not blocking -the process. The exception are \f(CW\*(C`ev_stat\*(C'\fR watchers \- those call \f(CW\*(C`stat -()\*(C'\fR, which is a synchronous operation. -.PP -For local paths, this usually doesn't matter: unless the system is very -busy or the intervals between stat's are large, a stat call will be fast, -as the path data is usually in memory already (except when starting the -watcher). -.PP -For networked file systems, calling \f(CW\*(C`stat ()\*(C'\fR can block an indefinite -time due to network issues, and even under good conditions, a stat call -often takes multiple milliseconds. -.PP -Therefore, it is best to avoid using \f(CW\*(C`ev_stat\*(C'\fR watchers on networked -paths, although this is fully supported by libev. -.PP -\fIThe special problem of stat time resolution\fR -.IX Subsection "The special problem of stat time resolution" -.PP -The \f(CW\*(C`stat ()\*(C'\fR system call only supports full-second resolution portably, -and even on systems where the resolution is higher, most file systems -still only support whole seconds. -.PP -That means that, if the time is the only thing that changes, you can -easily miss updates: on the first update, \f(CW\*(C`ev_stat\*(C'\fR detects a change and -calls your callback, which does something. When there is another update -within the same second, \f(CW\*(C`ev_stat\*(C'\fR will be unable to detect unless the -stat data does change in other ways (e.g. file size). -.PP -The solution to this is to delay acting on a change for slightly more -than a second (or till slightly after the next full second boundary), using -a roughly one-second-delay \f(CW\*(C`ev_timer\*(C'\fR (e.g. \f(CW\*(C`ev_timer_set (w, 0., 1.02); -ev_timer_again (loop, w)\*(C'\fR). -.PP -The \f(CW.02\fR offset is added to work around small timing inconsistencies -of some operating systems (where the second counter of the current time -might be be delayed. One such system is the Linux kernel, where a call to -\&\f(CW\*(C`gettimeofday\*(C'\fR might return a timestamp with a full second later than -a subsequent \f(CW\*(C`time\*(C'\fR call \- if the equivalent of \f(CW\*(C`time ()\*(C'\fR is used to -update file times then there will be a small window where the kernel uses -the previous second to update file times but libev might already execute -the timer callback). -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_stat_init (ev_stat *, callback, const char *path, ev_tstamp interval)" 4 -.IX Item "ev_stat_init (ev_stat *, callback, const char *path, ev_tstamp interval)" -.PD 0 -.IP "ev_stat_set (ev_stat *, const char *path, ev_tstamp interval)" 4 -.IX Item "ev_stat_set (ev_stat *, const char *path, ev_tstamp interval)" -.PD -Configures the watcher to wait for status changes of the given -\&\f(CW\*(C`path\*(C'\fR. The \f(CW\*(C`interval\*(C'\fR is a hint on how quickly a change is expected to -be detected and should normally be specified as \f(CW0\fR to let libev choose -a suitable value. The memory pointed to by \f(CW\*(C`path\*(C'\fR must point to the same -path for as long as the watcher is active. -.Sp -The callback will receive an \f(CW\*(C`EV_STAT\*(C'\fR event when a change was detected, -relative to the attributes at the time the watcher was started (or the -last change was detected). -.IP "ev_stat_stat (loop, ev_stat *)" 4 -.IX Item "ev_stat_stat (loop, ev_stat *)" -Updates the stat buffer immediately with new values. If you change the -watched path in your callback, you could call this function to avoid -detecting this change (while introducing a race condition if you are not -the only one changing the path). Can also be useful simply to find out the -new values. -.IP "ev_statdata attr [read\-only]" 4 -.IX Item "ev_statdata attr [read-only]" -The most-recently detected attributes of the file. Although the type is -\&\f(CW\*(C`ev_statdata\*(C'\fR, this is usually the (or one of the) \f(CW\*(C`struct stat\*(C'\fR types -suitable for your system, but you can only rely on the POSIX-standardised -members to be present. If the \f(CW\*(C`st_nlink\*(C'\fR member is \f(CW0\fR, then there was -some error while \f(CW\*(C`stat\*(C'\fRing the file. -.IP "ev_statdata prev [read\-only]" 4 -.IX Item "ev_statdata prev [read-only]" -The previous attributes of the file. The callback gets invoked whenever -\&\f(CW\*(C`prev\*(C'\fR != \f(CW\*(C`attr\*(C'\fR, or, more precisely, one or more of these members -differ: \f(CW\*(C`st_dev\*(C'\fR, \f(CW\*(C`st_ino\*(C'\fR, \f(CW\*(C`st_mode\*(C'\fR, \f(CW\*(C`st_nlink\*(C'\fR, \f(CW\*(C`st_uid\*(C'\fR, -\&\f(CW\*(C`st_gid\*(C'\fR, \f(CW\*(C`st_rdev\*(C'\fR, \f(CW\*(C`st_size\*(C'\fR, \f(CW\*(C`st_atime\*(C'\fR, \f(CW\*(C`st_mtime\*(C'\fR, \f(CW\*(C`st_ctime\*(C'\fR. -.IP "ev_tstamp interval [read\-only]" 4 -.IX Item "ev_tstamp interval [read-only]" -The specified interval. -.IP "const char *path [read\-only]" 4 -.IX Item "const char *path [read-only]" -The file system path that is being watched. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Watch \f(CW\*(C`/etc/passwd\*(C'\fR for attribute changes. -.PP -.Vb 10 -\& static void -\& passwd_cb (struct ev_loop *loop, ev_stat *w, int revents) -\& { -\& /* /etc/passwd changed in some way */ -\& if (w\->attr.st_nlink) -\& { -\& printf ("passwd current size %ld\en", (long)w\->attr.st_size); -\& printf ("passwd current atime %ld\en", (long)w\->attr.st_mtime); -\& printf ("passwd current mtime %ld\en", (long)w\->attr.st_mtime); -\& } -\& else -\& /* you shalt not abuse printf for puts */ -\& puts ("wow, /etc/passwd is not there, expect problems. " -\& "if this is windows, they already arrived\en"); -\& } -\& -\& ... -\& ev_stat passwd; -\& -\& ev_stat_init (&passwd, passwd_cb, "/etc/passwd", 0.); -\& ev_stat_start (loop, &passwd); -.Ve -.PP -Example: Like above, but additionally use a one-second delay so we do not -miss updates (however, frequent updates will delay processing, too, so -one might do the work both on \f(CW\*(C`ev_stat\*(C'\fR callback invocation \fIand\fR on -\&\f(CW\*(C`ev_timer\*(C'\fR callback invocation). -.PP -.Vb 2 -\& static ev_stat passwd; -\& static ev_timer timer; -\& -\& static void -\& timer_cb (EV_P_ ev_timer *w, int revents) -\& { -\& ev_timer_stop (EV_A_ w); -\& -\& /* now it\*(Aqs one second after the most recent passwd change */ -\& } -\& -\& static void -\& stat_cb (EV_P_ ev_stat *w, int revents) -\& { -\& /* reset the one\-second timer */ -\& ev_timer_again (EV_A_ &timer); -\& } -\& -\& ... -\& ev_stat_init (&passwd, stat_cb, "/etc/passwd", 0.); -\& ev_stat_start (loop, &passwd); -\& ev_timer_init (&timer, timer_cb, 0., 1.02); -.Ve -.ie n .SS """ev_idle"" \- when you've got nothing better to do..." -.el .SS "\f(CWev_idle\fP \- when you've got nothing better to do..." -.IX Subsection "ev_idle - when you've got nothing better to do..." -Idle watchers trigger events when no other events of the same or higher -priority are pending (prepare, check and other idle watchers do not count -as receiving \*(L"events\*(R"). -.PP -That is, as long as your process is busy handling sockets or timeouts -(or even signals, imagine) of the same or higher priority it will not be -triggered. But when your process is idle (or only lower-priority watchers -are pending), the idle watchers are being called once per event loop -iteration \- until stopped, that is, or your process receives more events -and becomes busy again with higher priority stuff. -.PP -The most noteworthy effect is that as long as any idle watchers are -active, the process will not block when waiting for new events. -.PP -Apart from keeping your process non-blocking (which is a useful -effect on its own sometimes), idle watchers are a good place to do -\&\*(L"pseudo-background processing\*(R", or delay processing stuff to after the -event loop has handled all outstanding events. -.PP -\fIAbusing an \f(CI\*(C`ev_idle\*(C'\fI watcher for its side-effect\fR -.IX Subsection "Abusing an ev_idle watcher for its side-effect" -.PP -As long as there is at least one active idle watcher, libev will never -sleep unnecessarily. Or in other words, it will loop as fast as possible. -For this to work, the idle watcher doesn't need to be invoked at all \- the -lowest priority will do. -.PP -This mode of operation can be useful together with an \f(CW\*(C`ev_check\*(C'\fR watcher, -to do something on each event loop iteration \- for example to balance load -between different connections. -.PP -See \*(L"Abusing an ev_check watcher for its side-effect\*(R" for a longer -example. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_idle_init (ev_idle *, callback)" 4 -.IX Item "ev_idle_init (ev_idle *, callback)" -Initialises and configures the idle watcher \- it has no parameters of any -kind. There is a \f(CW\*(C`ev_idle_set\*(C'\fR macro, but using it is utterly pointless, -believe me. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Dynamically allocate an \f(CW\*(C`ev_idle\*(C'\fR watcher, start it, and in the -callback, free it. Also, use no error checking, as usual. -.PP -.Vb 5 -\& static void -\& idle_cb (struct ev_loop *loop, ev_idle *w, int revents) -\& { -\& // stop the watcher -\& ev_idle_stop (loop, w); -\& -\& // now we can free it -\& free (w); -\& -\& // now do something you wanted to do when the program has -\& // no longer anything immediate to do. -\& } -\& -\& ev_idle *idle_watcher = malloc (sizeof (ev_idle)); -\& ev_idle_init (idle_watcher, idle_cb); -\& ev_idle_start (loop, idle_watcher); -.Ve -.ie n .SS """ev_prepare"" and ""ev_check"" \- customise your event loop!" -.el .SS "\f(CWev_prepare\fP and \f(CWev_check\fP \- customise your event loop!" -.IX Subsection "ev_prepare and ev_check - customise your event loop!" -Prepare and check watchers are often (but not always) used in pairs: -prepare watchers get invoked before the process blocks and check watchers -afterwards. -.PP -You \fImust not\fR call \f(CW\*(C`ev_run\*(C'\fR (or similar functions that enter the -current event loop) or \f(CW\*(C`ev_loop_fork\*(C'\fR from either \f(CW\*(C`ev_prepare\*(C'\fR or -\&\f(CW\*(C`ev_check\*(C'\fR watchers. Other loops than the current one are fine, -however. The rationale behind this is that you do not need to check -for recursion in those watchers, i.e. the sequence will always be -\&\f(CW\*(C`ev_prepare\*(C'\fR, blocking, \f(CW\*(C`ev_check\*(C'\fR so if you have one watcher of each -kind they will always be called in pairs bracketing the blocking call. -.PP -Their main purpose is to integrate other event mechanisms into libev and -their use is somewhat advanced. They could be used, for example, to track -variable changes, implement your own watchers, integrate net-snmp or a -coroutine library and lots more. They are also occasionally useful if -you cache some data and want to flush it before blocking (for example, -in X programs you might want to do an \f(CW\*(C`XFlush ()\*(C'\fR in an \f(CW\*(C`ev_prepare\*(C'\fR -watcher). -.PP -This is done by examining in each prepare call which file descriptors -need to be watched by the other library, registering \f(CW\*(C`ev_io\*(C'\fR watchers -for them and starting an \f(CW\*(C`ev_timer\*(C'\fR watcher for any timeouts (many -libraries provide exactly this functionality). Then, in the check watcher, -you check for any events that occurred (by checking the pending status -of all watchers and stopping them) and call back into the library. The -I/O and timer callbacks will never actually be called (but must be valid -nevertheless, because you never know, you know?). -.PP -As another example, the Perl Coro module uses these hooks to integrate -coroutines into libev programs, by yielding to other active coroutines -during each prepare and only letting the process block if no coroutines -are ready to run (it's actually more complicated: it only runs coroutines -with priority higher than or equal to the event loop and one coroutine -of lower priority, but only once, using idle watchers to keep the event -loop from blocking if lower-priority coroutines are active, thus mapping -low-priority coroutines to idle/background tasks). -.PP -When used for this purpose, it is recommended to give \f(CW\*(C`ev_check\*(C'\fR watchers -highest (\f(CW\*(C`EV_MAXPRI\*(C'\fR) priority, to ensure that they are being run before -any other watchers after the poll (this doesn't matter for \f(CW\*(C`ev_prepare\*(C'\fR -watchers). -.PP -Also, \f(CW\*(C`ev_check\*(C'\fR watchers (and \f(CW\*(C`ev_prepare\*(C'\fR watchers, too) should not -activate (\*(L"feed\*(R") events into libev. While libev fully supports this, they -might get executed before other \f(CW\*(C`ev_check\*(C'\fR watchers did their job. As -\&\f(CW\*(C`ev_check\*(C'\fR watchers are often used to embed other (non-libev) event -loops those other event loops might be in an unusable state until their -\&\f(CW\*(C`ev_check\*(C'\fR watcher ran (always remind yourself to coexist peacefully with -others). -.PP -\fIAbusing an \f(CI\*(C`ev_check\*(C'\fI watcher for its side-effect\fR -.IX Subsection "Abusing an ev_check watcher for its side-effect" -.PP -\&\f(CW\*(C`ev_check\*(C'\fR (and less often also \f(CW\*(C`ev_prepare\*(C'\fR) watchers can also be -useful because they are called once per event loop iteration. For -example, if you want to handle a large number of connections fairly, you -normally only do a bit of work for each active connection, and if there -is more work to do, you wait for the next event loop iteration, so other -connections have a chance of making progress. -.PP -Using an \f(CW\*(C`ev_check\*(C'\fR watcher is almost enough: it will be called on the -next event loop iteration. However, that isn't as soon as possible \- -without external events, your \f(CW\*(C`ev_check\*(C'\fR watcher will not be invoked. -.PP -This is where \f(CW\*(C`ev_idle\*(C'\fR watchers come in handy \- all you need is a -single global idle watcher that is active as long as you have one active -\&\f(CW\*(C`ev_check\*(C'\fR watcher. The \f(CW\*(C`ev_idle\*(C'\fR watcher makes sure the event loop -will not sleep, and the \f(CW\*(C`ev_check\*(C'\fR watcher makes sure a callback gets -invoked. Neither watcher alone can do that. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_prepare_init (ev_prepare *, callback)" 4 -.IX Item "ev_prepare_init (ev_prepare *, callback)" -.PD 0 -.IP "ev_check_init (ev_check *, callback)" 4 -.IX Item "ev_check_init (ev_check *, callback)" -.PD -Initialises and configures the prepare or check watcher \- they have no -parameters of any kind. There are \f(CW\*(C`ev_prepare_set\*(C'\fR and \f(CW\*(C`ev_check_set\*(C'\fR -macros, but using them is utterly, utterly, utterly and completely -pointless. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -There are a number of principal ways to embed other event loops or modules -into libev. Here are some ideas on how to include libadns into libev -(there is a Perl module named \f(CW\*(C`EV::ADNS\*(C'\fR that does this, which you could -use as a working example. Another Perl module named \f(CW\*(C`EV::Glib\*(C'\fR embeds a -Glib main context into libev, and finally, \f(CW\*(C`Glib::EV\*(C'\fR embeds \s-1EV\s0 into the -Glib event loop). -.PP -Method 1: Add \s-1IO\s0 watchers and a timeout watcher in a prepare handler, -and in a check watcher, destroy them and call into libadns. What follows -is pseudo-code only of course. This requires you to either use a low -priority for the check watcher or use \f(CW\*(C`ev_clear_pending\*(C'\fR explicitly, as -the callbacks for the IO/timeout watchers might not have been called yet. -.PP -.Vb 2 -\& static ev_io iow [nfd]; -\& static ev_timer tw; -\& -\& static void -\& io_cb (struct ev_loop *loop, ev_io *w, int revents) -\& { -\& } -\& -\& // create io watchers for each fd and a timer before blocking -\& static void -\& adns_prepare_cb (struct ev_loop *loop, ev_prepare *w, int revents) -\& { -\& int timeout = 3600000; -\& struct pollfd fds [nfd]; -\& // actual code will need to loop here and realloc etc. -\& adns_beforepoll (ads, fds, &nfd, &timeout, timeval_from (ev_time ())); -\& -\& /* the callback is illegal, but won\*(Aqt be called as we stop during check */ -\& ev_timer_init (&tw, 0, timeout * 1e\-3, 0.); -\& ev_timer_start (loop, &tw); -\& -\& // create one ev_io per pollfd -\& for (int i = 0; i < nfd; ++i) -\& { -\& ev_io_init (iow + i, io_cb, fds [i].fd, -\& ((fds [i].events & POLLIN ? EV_READ : 0) -\& | (fds [i].events & POLLOUT ? EV_WRITE : 0))); -\& -\& fds [i].revents = 0; -\& ev_io_start (loop, iow + i); -\& } -\& } -\& -\& // stop all watchers after blocking -\& static void -\& adns_check_cb (struct ev_loop *loop, ev_check *w, int revents) -\& { -\& ev_timer_stop (loop, &tw); -\& -\& for (int i = 0; i < nfd; ++i) -\& { -\& // set the relevant poll flags -\& // could also call adns_processreadable etc. here -\& struct pollfd *fd = fds + i; -\& int revents = ev_clear_pending (iow + i); -\& if (revents & EV_READ ) fd\->revents |= fd\->events & POLLIN; -\& if (revents & EV_WRITE) fd\->revents |= fd\->events & POLLOUT; -\& -\& // now stop the watcher -\& ev_io_stop (loop, iow + i); -\& } -\& -\& adns_afterpoll (adns, fds, nfd, timeval_from (ev_now (loop)); -\& } -.Ve -.PP -Method 2: This would be just like method 1, but you run \f(CW\*(C`adns_afterpoll\*(C'\fR -in the prepare watcher and would dispose of the check watcher. -.PP -Method 3: If the module to be embedded supports explicit event -notification (libadns does), you can also make use of the actual watcher -callbacks, and only destroy/create the watchers in the prepare watcher. -.PP -.Vb 5 -\& static void -\& timer_cb (EV_P_ ev_timer *w, int revents) -\& { -\& adns_state ads = (adns_state)w\->data; -\& update_now (EV_A); -\& -\& adns_processtimeouts (ads, &tv_now); -\& } -\& -\& static void -\& io_cb (EV_P_ ev_io *w, int revents) -\& { -\& adns_state ads = (adns_state)w\->data; -\& update_now (EV_A); -\& -\& if (revents & EV_READ ) adns_processreadable (ads, w\->fd, &tv_now); -\& if (revents & EV_WRITE) adns_processwriteable (ads, w\->fd, &tv_now); -\& } -\& -\& // do not ever call adns_afterpoll -.Ve -.PP -Method 4: Do not use a prepare or check watcher because the module you -want to embed is not flexible enough to support it. Instead, you can -override their poll function. The drawback with this solution is that the -main loop is now no longer controllable by \s-1EV.\s0 The \f(CW\*(C`Glib::EV\*(C'\fR module uses -this approach, effectively embedding \s-1EV\s0 as a client into the horrible -libglib event loop. -.PP -.Vb 4 -\& static gint -\& event_poll_func (GPollFD *fds, guint nfds, gint timeout) -\& { -\& int got_events = 0; -\& -\& for (n = 0; n < nfds; ++n) -\& // create/start io watcher that sets the relevant bits in fds[n] and increment got_events -\& -\& if (timeout >= 0) -\& // create/start timer -\& -\& // poll -\& ev_run (EV_A_ 0); -\& -\& // stop timer again -\& if (timeout >= 0) -\& ev_timer_stop (EV_A_ &to); -\& -\& // stop io watchers again \- their callbacks should have set -\& for (n = 0; n < nfds; ++n) -\& ev_io_stop (EV_A_ iow [n]); -\& -\& return got_events; -\& } -.Ve -.ie n .SS """ev_embed"" \- when one backend isn't enough..." -.el .SS "\f(CWev_embed\fP \- when one backend isn't enough..." -.IX Subsection "ev_embed - when one backend isn't enough..." -This is a rather advanced watcher type that lets you embed one event loop -into another (currently only \f(CW\*(C`ev_io\*(C'\fR events are supported in the embedded -loop, other types of watchers might be handled in a delayed or incorrect -fashion and must not be used). -.PP -There are primarily two reasons you would want that: work around bugs and -prioritise I/O. -.PP -As an example for a bug workaround, the kqueue backend might only support -sockets on some platform, so it is unusable as generic backend, but you -still want to make use of it because you have many sockets and it scales -so nicely. In this case, you would create a kqueue-based loop and embed -it into your default loop (which might use e.g. poll). Overall operation -will be a bit slower because first libev has to call \f(CW\*(C`poll\*(C'\fR and then -\&\f(CW\*(C`kevent\*(C'\fR, but at least you can use both mechanisms for what they are -best: \f(CW\*(C`kqueue\*(C'\fR for scalable sockets and \f(CW\*(C`poll\*(C'\fR if you want it to work :) -.PP -As for prioritising I/O: under rare circumstances you have the case where -some fds have to be watched and handled very quickly (with low latency), -and even priorities and idle watchers might have too much overhead. In -this case you would put all the high priority stuff in one loop and all -the rest in a second one, and embed the second one in the first. -.PP -As long as the watcher is active, the callback will be invoked every -time there might be events pending in the embedded loop. The callback -must then call \f(CW\*(C`ev_embed_sweep (mainloop, watcher)\*(C'\fR to make a single -sweep and invoke their callbacks (the callback doesn't need to invoke the -\&\f(CW\*(C`ev_embed_sweep\*(C'\fR function directly, it could also start an idle watcher -to give the embedded loop strictly lower priority for example). -.PP -You can also set the callback to \f(CW0\fR, in which case the embed watcher -will automatically execute the embedded loop sweep whenever necessary. -.PP -Fork detection will be handled transparently while the \f(CW\*(C`ev_embed\*(C'\fR watcher -is active, i.e., the embedded loop will automatically be forked when the -embedding loop forks. In other cases, the user is responsible for calling -\&\f(CW\*(C`ev_loop_fork\*(C'\fR on the embedded loop. -.PP -Unfortunately, not all backends are embeddable: only the ones returned by -\&\f(CW\*(C`ev_embeddable_backends\*(C'\fR are, which, unfortunately, does not include any -portable one. -.PP -So when you want to use this feature you will always have to be prepared -that you cannot get an embeddable loop. The recommended way to get around -this is to have a separate variables for your embeddable loop, try to -create it, and if that fails, use the normal loop for everything. -.PP -\fI\f(CI\*(C`ev_embed\*(C'\fI and fork\fR -.IX Subsection "ev_embed and fork" -.PP -While the \f(CW\*(C`ev_embed\*(C'\fR watcher is running, forks in the embedding loop will -automatically be applied to the embedded loop as well, so no special -fork handling is required in that case. When the watcher is not running, -however, it is still the task of the libev user to call \f(CW\*(C`ev_loop_fork ()\*(C'\fR -as applicable. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_embed_init (ev_embed *, callback, struct ev_loop *embedded_loop)" 4 -.IX Item "ev_embed_init (ev_embed *, callback, struct ev_loop *embedded_loop)" -.PD 0 -.IP "ev_embed_set (ev_embed *, struct ev_loop *embedded_loop)" 4 -.IX Item "ev_embed_set (ev_embed *, struct ev_loop *embedded_loop)" -.PD -Configures the watcher to embed the given loop, which must be -embeddable. If the callback is \f(CW0\fR, then \f(CW\*(C`ev_embed_sweep\*(C'\fR will be -invoked automatically, otherwise it is the responsibility of the callback -to invoke it (it will continue to be called until the sweep has been done, -if you do not want that, you need to temporarily stop the embed watcher). -.IP "ev_embed_sweep (loop, ev_embed *)" 4 -.IX Item "ev_embed_sweep (loop, ev_embed *)" -Make a single, non-blocking sweep over the embedded loop. This works -similarly to \f(CW\*(C`ev_run (embedded_loop, EVRUN_NOWAIT)\*(C'\fR, but in the most -appropriate way for embedded loops. -.IP "struct ev_loop *other [read\-only]" 4 -.IX Item "struct ev_loop *other [read-only]" -The embedded event loop. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Try to get an embeddable event loop and embed it into the default -event loop. If that is not possible, use the default loop. The default -loop is stored in \f(CW\*(C`loop_hi\*(C'\fR, while the embeddable loop is stored in -\&\f(CW\*(C`loop_lo\*(C'\fR (which is \f(CW\*(C`loop_hi\*(C'\fR in the case no embeddable loop can be -used). -.PP -.Vb 3 -\& struct ev_loop *loop_hi = ev_default_init (0); -\& struct ev_loop *loop_lo = 0; -\& ev_embed embed; -\& -\& // see if there is a chance of getting one that works -\& // (remember that a flags value of 0 means autodetection) -\& loop_lo = ev_embeddable_backends () & ev_recommended_backends () -\& ? ev_loop_new (ev_embeddable_backends () & ev_recommended_backends ()) -\& : 0; -\& -\& // if we got one, then embed it, otherwise default to loop_hi -\& if (loop_lo) -\& { -\& ev_embed_init (&embed, 0, loop_lo); -\& ev_embed_start (loop_hi, &embed); -\& } -\& else -\& loop_lo = loop_hi; -.Ve -.PP -Example: Check if kqueue is available but not recommended and create -a kqueue backend for use with sockets (which usually work with any -kqueue implementation). Store the kqueue/socket\-only event loop in -\&\f(CW\*(C`loop_socket\*(C'\fR. (One might optionally use \f(CW\*(C`EVFLAG_NOENV\*(C'\fR, too). -.PP -.Vb 3 -\& struct ev_loop *loop = ev_default_init (0); -\& struct ev_loop *loop_socket = 0; -\& ev_embed embed; -\& -\& if (ev_supported_backends () & ~ev_recommended_backends () & EVBACKEND_KQUEUE) -\& if ((loop_socket = ev_loop_new (EVBACKEND_KQUEUE)) -\& { -\& ev_embed_init (&embed, 0, loop_socket); -\& ev_embed_start (loop, &embed); -\& } -\& -\& if (!loop_socket) -\& loop_socket = loop; -\& -\& // now use loop_socket for all sockets, and loop for everything else -.Ve -.ie n .SS """ev_fork"" \- the audacity to resume the event loop after a fork" -.el .SS "\f(CWev_fork\fP \- the audacity to resume the event loop after a fork" -.IX Subsection "ev_fork - the audacity to resume the event loop after a fork" -Fork watchers are called when a \f(CW\*(C`fork ()\*(C'\fR was detected (usually because -whoever is a good citizen cared to tell libev about it by calling -\&\f(CW\*(C`ev_loop_fork\*(C'\fR). The invocation is done before the event loop blocks next -and before \f(CW\*(C`ev_check\*(C'\fR watchers are being called, and only in the child -after the fork. If whoever good citizen calling \f(CW\*(C`ev_default_fork\*(C'\fR cheats -and calls it in the wrong process, the fork handlers will be invoked, too, -of course. -.PP -\fIThe special problem of life after fork \- how is it possible?\fR -.IX Subsection "The special problem of life after fork - how is it possible?" -.PP -Most uses of \f(CW\*(C`fork ()\*(C'\fR consist of forking, then some simple calls to set -up/change the process environment, followed by a call to \f(CW\*(C`exec()\*(C'\fR. This -sequence should be handled by libev without any problems. -.PP -This changes when the application actually wants to do event handling -in the child, or both parent in child, in effect \*(L"continuing\*(R" after the -fork. -.PP -The default mode of operation (for libev, with application help to detect -forks) is to duplicate all the state in the child, as would be expected -when \fIeither\fR the parent \fIor\fR the child process continues. -.PP -When both processes want to continue using libev, then this is usually the -wrong result. In that case, usually one process (typically the parent) is -supposed to continue with all watchers in place as before, while the other -process typically wants to start fresh, i.e. without any active watchers. -.PP -The cleanest and most efficient way to achieve that with libev is to -simply create a new event loop, which of course will be \*(L"empty\*(R", and -use that for new watchers. This has the advantage of not touching more -memory than necessary, and thus avoiding the copy-on-write, and the -disadvantage of having to use multiple event loops (which do not support -signal watchers). -.PP -When this is not possible, or you want to use the default loop for -other reasons, then in the process that wants to start \*(L"fresh\*(R", call -\&\f(CW\*(C`ev_loop_destroy (EV_DEFAULT)\*(C'\fR followed by \f(CW\*(C`ev_default_loop (...)\*(C'\fR. -Destroying the default loop will \*(L"orphan\*(R" (not stop) all registered -watchers, so you have to be careful not to execute code that modifies -those watchers. Note also that in that case, you have to re-register any -signal watchers. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_fork_init (ev_fork *, callback)" 4 -.IX Item "ev_fork_init (ev_fork *, callback)" -Initialises and configures the fork watcher \- it has no parameters of any -kind. There is a \f(CW\*(C`ev_fork_set\*(C'\fR macro, but using it is utterly pointless, -really. -.ie n .SS """ev_cleanup"" \- even the best things end" -.el .SS "\f(CWev_cleanup\fP \- even the best things end" -.IX Subsection "ev_cleanup - even the best things end" -Cleanup watchers are called just before the event loop is being destroyed -by a call to \f(CW\*(C`ev_loop_destroy\*(C'\fR. -.PP -While there is no guarantee that the event loop gets destroyed, cleanup -watchers provide a convenient method to install cleanup hooks for your -program, worker threads and so on \- you just to make sure to destroy the -loop when you want them to be invoked. -.PP -Cleanup watchers are invoked in the same way as any other watcher. Unlike -all other watchers, they do not keep a reference to the event loop (which -makes a lot of sense if you think about it). Like all other watchers, you -can call libev functions in the callback, except \f(CW\*(C`ev_cleanup_start\*(C'\fR. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_cleanup_init (ev_cleanup *, callback)" 4 -.IX Item "ev_cleanup_init (ev_cleanup *, callback)" -Initialises and configures the cleanup watcher \- it has no parameters of -any kind. There is a \f(CW\*(C`ev_cleanup_set\*(C'\fR macro, but using it is utterly -pointless, I assure you. -.PP -Example: Register an atexit handler to destroy the default loop, so any -cleanup functions are called. -.PP -.Vb 5 -\& static void -\& program_exits (void) -\& { -\& ev_loop_destroy (EV_DEFAULT_UC); -\& } -\& -\& ... -\& atexit (program_exits); -.Ve -.ie n .SS """ev_async"" \- how to wake up an event loop" -.el .SS "\f(CWev_async\fP \- how to wake up an event loop" -.IX Subsection "ev_async - how to wake up an event loop" -In general, you cannot use an \f(CW\*(C`ev_loop\*(C'\fR from multiple threads or other -asynchronous sources such as signal handlers (as opposed to multiple event -loops \- those are of course safe to use in different threads). -.PP -Sometimes, however, you need to wake up an event loop you do not control, -for example because it belongs to another thread. This is what \f(CW\*(C`ev_async\*(C'\fR -watchers do: as long as the \f(CW\*(C`ev_async\*(C'\fR watcher is active, you can signal -it by calling \f(CW\*(C`ev_async_send\*(C'\fR, which is thread\- and signal safe. -.PP -This functionality is very similar to \f(CW\*(C`ev_signal\*(C'\fR watchers, as signals, -too, are asynchronous in nature, and signals, too, will be compressed -(i.e. the number of callback invocations may be less than the number of -\&\f(CW\*(C`ev_async_send\*(C'\fR calls). In fact, you could use signal watchers as a kind -of \*(L"global async watchers\*(R" by using a watcher on an otherwise unused -signal, and \f(CW\*(C`ev_feed_signal\*(C'\fR to signal this watcher from another thread, -even without knowing which loop owns the signal. -.PP -\fIQueueing\fR -.IX Subsection "Queueing" -.PP -\&\f(CW\*(C`ev_async\*(C'\fR does not support queueing of data in any way. The reason -is that the author does not know of a simple (or any) algorithm for a -multiple-writer-single-reader queue that works in all cases and doesn't -need elaborate support such as pthreads or unportable memory access -semantics. -.PP -That means that if you want to queue data, you have to provide your own -queue. But at least I can tell you how to implement locking around your -queue: -.IP "queueing from a signal handler context" 4 -.IX Item "queueing from a signal handler context" -To implement race-free queueing, you simply add to the queue in the signal -handler but you block the signal handler in the watcher callback. Here is -an example that does that for some fictitious \s-1SIGUSR1\s0 handler: -.Sp -.Vb 1 -\& static ev_async mysig; -\& -\& static void -\& sigusr1_handler (void) -\& { -\& sometype data; -\& -\& // no locking etc. -\& queue_put (data); -\& ev_async_send (EV_DEFAULT_ &mysig); -\& } -\& -\& static void -\& mysig_cb (EV_P_ ev_async *w, int revents) -\& { -\& sometype data; -\& sigset_t block, prev; -\& -\& sigemptyset (&block); -\& sigaddset (&block, SIGUSR1); -\& sigprocmask (SIG_BLOCK, &block, &prev); -\& -\& while (queue_get (&data)) -\& process (data); -\& -\& if (sigismember (&prev, SIGUSR1) -\& sigprocmask (SIG_UNBLOCK, &block, 0); -\& } -.Ve -.Sp -(Note: pthreads in theory requires you to use \f(CW\*(C`pthread_setmask\*(C'\fR -instead of \f(CW\*(C`sigprocmask\*(C'\fR when you use threads, but libev doesn't do it -either...). -.IP "queueing from a thread context" 4 -.IX Item "queueing from a thread context" -The strategy for threads is different, as you cannot (easily) block -threads but you can easily preempt them, so to queue safely you need to -employ a traditional mutex lock, such as in this pthread example: -.Sp -.Vb 2 -\& static ev_async mysig; -\& static pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZER; -\& -\& static void -\& otherthread (void) -\& { -\& // only need to lock the actual queueing operation -\& pthread_mutex_lock (&mymutex); -\& queue_put (data); -\& pthread_mutex_unlock (&mymutex); -\& -\& ev_async_send (EV_DEFAULT_ &mysig); -\& } -\& -\& static void -\& mysig_cb (EV_P_ ev_async *w, int revents) -\& { -\& pthread_mutex_lock (&mymutex); -\& -\& while (queue_get (&data)) -\& process (data); -\& -\& pthread_mutex_unlock (&mymutex); -\& } -.Ve -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_async_init (ev_async *, callback)" 4 -.IX Item "ev_async_init (ev_async *, callback)" -Initialises and configures the async watcher \- it has no parameters of any -kind. There is a \f(CW\*(C`ev_async_set\*(C'\fR macro, but using it is utterly pointless, -trust me. -.IP "ev_async_send (loop, ev_async *)" 4 -.IX Item "ev_async_send (loop, ev_async *)" -Sends/signals/activates the given \f(CW\*(C`ev_async\*(C'\fR watcher, that is, feeds -an \f(CW\*(C`EV_ASYNC\*(C'\fR event on the watcher into the event loop, and instantly -returns. -.Sp -Unlike \f(CW\*(C`ev_feed_event\*(C'\fR, this call is safe to do from other threads, -signal or similar contexts (see the discussion of \f(CW\*(C`EV_ATOMIC_T\*(C'\fR in the -embedding section below on what exactly this means). -.Sp -Note that, as with other watchers in libev, multiple events might get -compressed into a single callback invocation (another way to look at -this is that \f(CW\*(C`ev_async\*(C'\fR watchers are level-triggered: they are set on -\&\f(CW\*(C`ev_async_send\*(C'\fR, reset when the event loop detects that). -.Sp -This call incurs the overhead of at most one extra system call per event -loop iteration, if the event loop is blocked, and no syscall at all if -the event loop (or your program) is processing events. That means that -repeated calls are basically free (there is no need to avoid calls for -performance reasons) and that the overhead becomes smaller (typically -zero) under load. -.IP "bool = ev_async_pending (ev_async *)" 4 -.IX Item "bool = ev_async_pending (ev_async *)" -Returns a non-zero value when \f(CW\*(C`ev_async_send\*(C'\fR has been called on the -watcher but the event has not yet been processed (or even noted) by the -event loop. -.Sp -\&\f(CW\*(C`ev_async_send\*(C'\fR sets a flag in the watcher and wakes up the loop. When -the loop iterates next and checks for the watcher to have become active, -it will reset the flag again. \f(CW\*(C`ev_async_pending\*(C'\fR can be used to very -quickly check whether invoking the loop might be a good idea. -.Sp -Not that this does \fInot\fR check whether the watcher itself is pending, -only whether it has been requested to make this watcher pending: there -is a time window between the event loop checking and resetting the async -notification, and the callback being invoked. -.SH "OTHER FUNCTIONS" -.IX Header "OTHER FUNCTIONS" -There are some other functions of possible interest. Described. Here. Now. -.IP "ev_once (loop, int fd, int events, ev_tstamp timeout, callback, arg)" 4 -.IX Item "ev_once (loop, int fd, int events, ev_tstamp timeout, callback, arg)" -This function combines a simple timer and an I/O watcher, calls your -callback on whichever event happens first and automatically stops both -watchers. This is useful if you want to wait for a single event on an fd -or timeout without having to allocate/configure/start/stop/free one or -more watchers yourself. -.Sp -If \f(CW\*(C`fd\*(C'\fR is less than 0, then no I/O watcher will be started and the -\&\f(CW\*(C`events\*(C'\fR argument is being ignored. Otherwise, an \f(CW\*(C`ev_io\*(C'\fR watcher for -the given \f(CW\*(C`fd\*(C'\fR and \f(CW\*(C`events\*(C'\fR set will be created and started. -.Sp -If \f(CW\*(C`timeout\*(C'\fR is less than 0, then no timeout watcher will be -started. Otherwise an \f(CW\*(C`ev_timer\*(C'\fR watcher with after = \f(CW\*(C`timeout\*(C'\fR (and -repeat = 0) will be started. \f(CW0\fR is a valid timeout. -.Sp -The callback has the type \f(CW\*(C`void (*cb)(int revents, void *arg)\*(C'\fR and is -passed an \f(CW\*(C`revents\*(C'\fR set like normal event callbacks (a combination of -\&\f(CW\*(C`EV_ERROR\*(C'\fR, \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR or \f(CW\*(C`EV_TIMER\*(C'\fR) and the \f(CW\*(C`arg\*(C'\fR -value passed to \f(CW\*(C`ev_once\*(C'\fR. Note that it is possible to receive \fIboth\fR -a timeout and an io event at the same time \- you probably should give io -events precedence. -.Sp -Example: wait up to ten seconds for data to appear on \s-1STDIN_FILENO.\s0 -.Sp -.Vb 7 -\& static void stdin_ready (int revents, void *arg) -\& { -\& if (revents & EV_READ) -\& /* stdin might have data for us, joy! */; -\& else if (revents & EV_TIMER) -\& /* doh, nothing entered */; -\& } -\& -\& ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0); -.Ve -.IP "ev_feed_fd_event (loop, int fd, int revents)" 4 -.IX Item "ev_feed_fd_event (loop, int fd, int revents)" -Feed an event on the given fd, as if a file descriptor backend detected -the given events. -.IP "ev_feed_signal_event (loop, int signum)" 4 -.IX Item "ev_feed_signal_event (loop, int signum)" -Feed an event as if the given signal occurred. See also \f(CW\*(C`ev_feed_signal\*(C'\fR, -which is async-safe. -.SH "COMMON OR USEFUL IDIOMS (OR BOTH)" -.IX Header "COMMON OR USEFUL IDIOMS (OR BOTH)" -This section explains some common idioms that are not immediately -obvious. Note that examples are sprinkled over the whole manual, and this -section only contains stuff that wouldn't fit anywhere else. -.SS "\s-1ASSOCIATING CUSTOM DATA WITH A WATCHER\s0" -.IX Subsection "ASSOCIATING CUSTOM DATA WITH A WATCHER" -Each watcher has, by default, a \f(CW\*(C`void *data\*(C'\fR member that you can read -or modify at any time: libev will completely ignore it. This can be used -to associate arbitrary data with your watcher. If you need more data and -don't want to allocate memory separately and store a pointer to it in that -data member, you can also \*(L"subclass\*(R" the watcher type and provide your own -data: -.PP -.Vb 7 -\& struct my_io -\& { -\& ev_io io; -\& int otherfd; -\& void *somedata; -\& struct whatever *mostinteresting; -\& }; -\& -\& ... -\& struct my_io w; -\& ev_io_init (&w.io, my_cb, fd, EV_READ); -.Ve -.PP -And since your callback will be called with a pointer to the watcher, you -can cast it back to your own type: -.PP -.Vb 5 -\& static void my_cb (struct ev_loop *loop, ev_io *w_, int revents) -\& { -\& struct my_io *w = (struct my_io *)w_; -\& ... -\& } -.Ve -.PP -More interesting and less C\-conformant ways of casting your callback -function type instead have been omitted. -.SS "\s-1BUILDING YOUR OWN COMPOSITE WATCHERS\s0" -.IX Subsection "BUILDING YOUR OWN COMPOSITE WATCHERS" -Another common scenario is to use some data structure with multiple -embedded watchers, in effect creating your own watcher that combines -multiple libev event sources into one \*(L"super-watcher\*(R": -.PP -.Vb 6 -\& struct my_biggy -\& { -\& int some_data; -\& ev_timer t1; -\& ev_timer t2; -\& } -.Ve -.PP -In this case getting the pointer to \f(CW\*(C`my_biggy\*(C'\fR is a bit more -complicated: Either you store the address of your \f(CW\*(C`my_biggy\*(C'\fR struct in -the \f(CW\*(C`data\*(C'\fR member of the watcher (for woozies or \*(C+ coders), or you need -to use some pointer arithmetic using \f(CW\*(C`offsetof\*(C'\fR inside your watchers (for -real programmers): -.PP -.Vb 1 -\& #include -\& -\& static void -\& t1_cb (EV_P_ ev_timer *w, int revents) -\& { -\& struct my_biggy big = (struct my_biggy *) -\& (((char *)w) \- offsetof (struct my_biggy, t1)); -\& } -\& -\& static void -\& t2_cb (EV_P_ ev_timer *w, int revents) -\& { -\& struct my_biggy big = (struct my_biggy *) -\& (((char *)w) \- offsetof (struct my_biggy, t2)); -\& } -.Ve -.SS "\s-1AVOIDING FINISHING BEFORE RETURNING\s0" -.IX Subsection "AVOIDING FINISHING BEFORE RETURNING" -Often you have structures like this in event-based programs: -.PP -.Vb 4 -\& callback () -\& { -\& free (request); -\& } -\& -\& request = start_new_request (..., callback); -.Ve -.PP -The intent is to start some \*(L"lengthy\*(R" operation. The \f(CW\*(C`request\*(C'\fR could be -used to cancel the operation, or do other things with it. -.PP -It's not uncommon to have code paths in \f(CW\*(C`start_new_request\*(C'\fR that -immediately invoke the callback, for example, to report errors. Or you add -some caching layer that finds that it can skip the lengthy aspects of the -operation and simply invoke the callback with the result. -.PP -The problem here is that this will happen \fIbefore\fR \f(CW\*(C`start_new_request\*(C'\fR -has returned, so \f(CW\*(C`request\*(C'\fR is not set. -.PP -Even if you pass the request by some safer means to the callback, you -might want to do something to the request after starting it, such as -canceling it, which probably isn't working so well when the callback has -already been invoked. -.PP -A common way around all these issues is to make sure that -\&\f(CW\*(C`start_new_request\*(C'\fR \fIalways\fR returns before the callback is invoked. If -\&\f(CW\*(C`start_new_request\*(C'\fR immediately knows the result, it can artificially -delay invoking the callback by using a \f(CW\*(C`prepare\*(C'\fR or \f(CW\*(C`idle\*(C'\fR watcher for -example, or more sneakily, by reusing an existing (stopped) watcher and -pushing it into the pending queue: -.PP -.Vb 2 -\& ev_set_cb (watcher, callback); -\& ev_feed_event (EV_A_ watcher, 0); -.Ve -.PP -This way, \f(CW\*(C`start_new_request\*(C'\fR can safely return before the callback is -invoked, while not delaying callback invocation too much. -.SS "\s-1MODEL/NESTED EVENT LOOP INVOCATIONS AND EXIT CONDITIONS\s0" -.IX Subsection "MODEL/NESTED EVENT LOOP INVOCATIONS AND EXIT CONDITIONS" -Often (especially in \s-1GUI\s0 toolkits) there are places where you have -\&\fImodal\fR interaction, which is most easily implemented by recursively -invoking \f(CW\*(C`ev_run\*(C'\fR. -.PP -This brings the problem of exiting \- a callback might want to finish the -main \f(CW\*(C`ev_run\*(C'\fR call, but not the nested one (e.g. user clicked \*(L"Quit\*(R", but -a modal \*(L"Are you sure?\*(R" dialog is still waiting), or just the nested one -and not the main one (e.g. user clocked \*(L"Ok\*(R" in a modal dialog), or some -other combination: In these cases, a simple \f(CW\*(C`ev_break\*(C'\fR will not work. -.PP -The solution is to maintain \*(L"break this loop\*(R" variable for each \f(CW\*(C`ev_run\*(C'\fR -invocation, and use a loop around \f(CW\*(C`ev_run\*(C'\fR until the condition is -triggered, using \f(CW\*(C`EVRUN_ONCE\*(C'\fR: -.PP -.Vb 2 -\& // main loop -\& int exit_main_loop = 0; -\& -\& while (!exit_main_loop) -\& ev_run (EV_DEFAULT_ EVRUN_ONCE); -\& -\& // in a modal watcher -\& int exit_nested_loop = 0; -\& -\& while (!exit_nested_loop) -\& ev_run (EV_A_ EVRUN_ONCE); -.Ve -.PP -To exit from any of these loops, just set the corresponding exit variable: -.PP -.Vb 2 -\& // exit modal loop -\& exit_nested_loop = 1; -\& -\& // exit main program, after modal loop is finished -\& exit_main_loop = 1; -\& -\& // exit both -\& exit_main_loop = exit_nested_loop = 1; -.Ve -.SS "\s-1THREAD LOCKING EXAMPLE\s0" -.IX Subsection "THREAD LOCKING EXAMPLE" -Here is a fictitious example of how to run an event loop in a different -thread from where callbacks are being invoked and watchers are -created/added/removed. -.PP -For a real-world example, see the \f(CW\*(C`EV::Loop::Async\*(C'\fR perl module, -which uses exactly this technique (which is suited for many high-level -languages). -.PP -The example uses a pthread mutex to protect the loop data, a condition -variable to wait for callback invocations, an async watcher to notify the -event loop thread and an unspecified mechanism to wake up the main thread. -.PP -First, you need to associate some data with the event loop: -.PP -.Vb 6 -\& typedef struct { -\& pthread_mutex_t lock; /* global loop lock */ -\& pthread_t tid; -\& pthread_cond_t invoke_cv; -\& ev_async async_w; -\& } userdata; -\& -\& void prepare_loop (EV_P) -\& { -\& // for simplicity, we use a static userdata struct. -\& static userdata u; -\& -\& ev_async_init (&u.async_w, async_cb); -\& ev_async_start (EV_A_ &u.async_w); -\& -\& pthread_mutex_init (&u.lock, 0); -\& pthread_cond_init (&u.invoke_cv, 0); -\& -\& // now associate this with the loop -\& ev_set_userdata (EV_A_ &u); -\& ev_set_invoke_pending_cb (EV_A_ l_invoke); -\& ev_set_loop_release_cb (EV_A_ l_release, l_acquire); -\& -\& // then create the thread running ev_run -\& pthread_create (&u.tid, 0, l_run, EV_A); -\& } -.Ve -.PP -The callback for the \f(CW\*(C`ev_async\*(C'\fR watcher does nothing: the watcher is used -solely to wake up the event loop so it takes notice of any new watchers -that might have been added: -.PP -.Vb 5 -\& static void -\& async_cb (EV_P_ ev_async *w, int revents) -\& { -\& // just used for the side effects -\& } -.Ve -.PP -The \f(CW\*(C`l_release\*(C'\fR and \f(CW\*(C`l_acquire\*(C'\fR callbacks simply unlock/lock the mutex -protecting the loop data, respectively. -.PP -.Vb 6 -\& static void -\& l_release (EV_P) -\& { -\& userdata *u = ev_userdata (EV_A); -\& pthread_mutex_unlock (&u\->lock); -\& } -\& -\& static void -\& l_acquire (EV_P) -\& { -\& userdata *u = ev_userdata (EV_A); -\& pthread_mutex_lock (&u\->lock); -\& } -.Ve -.PP -The event loop thread first acquires the mutex, and then jumps straight -into \f(CW\*(C`ev_run\*(C'\fR: -.PP -.Vb 4 -\& void * -\& l_run (void *thr_arg) -\& { -\& struct ev_loop *loop = (struct ev_loop *)thr_arg; -\& -\& l_acquire (EV_A); -\& pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0); -\& ev_run (EV_A_ 0); -\& l_release (EV_A); -\& -\& return 0; -\& } -.Ve -.PP -Instead of invoking all pending watchers, the \f(CW\*(C`l_invoke\*(C'\fR callback will -signal the main thread via some unspecified mechanism (signals? pipe -writes? \f(CW\*(C`Async::Interrupt\*(C'\fR?) and then waits until all pending watchers -have been called (in a while loop because a) spurious wakeups are possible -and b) skipping inter-thread-communication when there are no pending -watchers is very beneficial): -.PP -.Vb 4 -\& static void -\& l_invoke (EV_P) -\& { -\& userdata *u = ev_userdata (EV_A); -\& -\& while (ev_pending_count (EV_A)) -\& { -\& wake_up_other_thread_in_some_magic_or_not_so_magic_way (); -\& pthread_cond_wait (&u\->invoke_cv, &u\->lock); -\& } -\& } -.Ve -.PP -Now, whenever the main thread gets told to invoke pending watchers, it -will grab the lock, call \f(CW\*(C`ev_invoke_pending\*(C'\fR and then signal the loop -thread to continue: -.PP -.Vb 4 -\& static void -\& real_invoke_pending (EV_P) -\& { -\& userdata *u = ev_userdata (EV_A); -\& -\& pthread_mutex_lock (&u\->lock); -\& ev_invoke_pending (EV_A); -\& pthread_cond_signal (&u\->invoke_cv); -\& pthread_mutex_unlock (&u\->lock); -\& } -.Ve -.PP -Whenever you want to start/stop a watcher or do other modifications to an -event loop, you will now have to lock: -.PP -.Vb 2 -\& ev_timer timeout_watcher; -\& userdata *u = ev_userdata (EV_A); -\& -\& ev_timer_init (&timeout_watcher, timeout_cb, 5.5, 0.); -\& -\& pthread_mutex_lock (&u\->lock); -\& ev_timer_start (EV_A_ &timeout_watcher); -\& ev_async_send (EV_A_ &u\->async_w); -\& pthread_mutex_unlock (&u\->lock); -.Ve -.PP -Note that sending the \f(CW\*(C`ev_async\*(C'\fR watcher is required because otherwise -an event loop currently blocking in the kernel will have no knowledge -about the newly added timer. By waking up the loop it will pick up any new -watchers in the next event loop iteration. -.SS "\s-1THREADS, COROUTINES, CONTINUATIONS, QUEUES... INSTEAD OF CALLBACKS\s0" -.IX Subsection "THREADS, COROUTINES, CONTINUATIONS, QUEUES... INSTEAD OF CALLBACKS" -While the overhead of a callback that e.g. schedules a thread is small, it -is still an overhead. If you embed libev, and your main usage is with some -kind of threads or coroutines, you might want to customise libev so that -doesn't need callbacks anymore. -.PP -Imagine you have coroutines that you can switch to using a function -\&\f(CW\*(C`switch_to (coro)\*(C'\fR, that libev runs in a coroutine called \f(CW\*(C`libev_coro\*(C'\fR -and that due to some magic, the currently active coroutine is stored in a -global called \f(CW\*(C`current_coro\*(C'\fR. Then you can build your own \*(L"wait for libev -event\*(R" primitive by changing \f(CW\*(C`EV_CB_DECLARE\*(C'\fR and \f(CW\*(C`EV_CB_INVOKE\*(C'\fR (note -the differing \f(CW\*(C`;\*(C'\fR conventions): -.PP -.Vb 2 -\& #define EV_CB_DECLARE(type) struct my_coro *cb; -\& #define EV_CB_INVOKE(watcher) switch_to ((watcher)\->cb) -.Ve -.PP -That means instead of having a C callback function, you store the -coroutine to switch to in each watcher, and instead of having libev call -your callback, you instead have it switch to that coroutine. -.PP -A coroutine might now wait for an event with a function called -\&\f(CW\*(C`wait_for_event\*(C'\fR. (the watcher needs to be started, as always, but it doesn't -matter when, or whether the watcher is active or not when this function is -called): -.PP -.Vb 6 -\& void -\& wait_for_event (ev_watcher *w) -\& { -\& ev_set_cb (w, current_coro); -\& switch_to (libev_coro); -\& } -.Ve -.PP -That basically suspends the coroutine inside \f(CW\*(C`wait_for_event\*(C'\fR and -continues the libev coroutine, which, when appropriate, switches back to -this or any other coroutine. -.PP -You can do similar tricks if you have, say, threads with an event queue \- -instead of storing a coroutine, you store the queue object and instead of -switching to a coroutine, you push the watcher onto the queue and notify -any waiters. -.PP -To embed libev, see \*(L"\s-1EMBEDDING\*(R"\s0, but in short, it's easiest to create two -files, \fImy_ev.h\fR and \fImy_ev.c\fR that include the respective libev files: -.PP -.Vb 4 -\& // my_ev.h -\& #define EV_CB_DECLARE(type) struct my_coro *cb; -\& #define EV_CB_INVOKE(watcher) switch_to ((watcher)\->cb) -\& #include "../libev/ev.h" -\& -\& // my_ev.c -\& #define EV_H "my_ev.h" -\& #include "../libev/ev.c" -.Ve -.PP -And then use \fImy_ev.h\fR when you would normally use \fIev.h\fR, and compile -\&\fImy_ev.c\fR into your project. When properly specifying include paths, you -can even use \fIev.h\fR as header file name directly. -.SH "LIBEVENT EMULATION" -.IX Header "LIBEVENT EMULATION" -Libev offers a compatibility emulation layer for libevent. It cannot -emulate the internals of libevent, so here are some usage hints: -.IP "\(bu" 4 -Only the libevent\-1.4.1\-beta \s-1API\s0 is being emulated. -.Sp -This was the newest libevent version available when libev was implemented, -and is still mostly unchanged in 2010. -.IP "\(bu" 4 -Use it by including , as usual. -.IP "\(bu" 4 -The following members are fully supported: ev_base, ev_callback, -ev_arg, ev_fd, ev_res, ev_events. -.IP "\(bu" 4 -Avoid using ev_flags and the EVLIST_*\-macros, while it is -maintained by libev, it does not work exactly the same way as in libevent (consider -it a private \s-1API\s0). -.IP "\(bu" 4 -Priorities are not currently supported. Initialising priorities -will fail and all watchers will have the same priority, even though there -is an ev_pri field. -.IP "\(bu" 4 -In libevent, the last base created gets the signals, in libev, the -base that registered the signal gets the signals. -.IP "\(bu" 4 -Other members are not supported. -.IP "\(bu" 4 -The libev emulation is \fInot\fR \s-1ABI\s0 compatible to libevent, you need -to use the libev header file and library. -.SH "\*(C+ SUPPORT" -.IX Header " SUPPORT" -.SS "C \s-1API\s0" -.IX Subsection "C API" -The normal C \s-1API\s0 should work fine when used from \*(C+: both ev.h and the -libev sources can be compiled as \*(C+. Therefore, code that uses the C \s-1API\s0 -will work fine. -.PP -Proper exception specifications might have to be added to callbacks passed -to libev: exceptions may be thrown only from watcher callbacks, all other -callbacks (allocator, syserr, loop acquire/release and periodic reschedule -callbacks) must not throw exceptions, and might need a \f(CW\*(C`noexcept\*(C'\fR -specification. If you have code that needs to be compiled as both C and -\&\*(C+ you can use the \f(CW\*(C`EV_NOEXCEPT\*(C'\fR macro for this: -.PP -.Vb 6 -\& static void -\& fatal_error (const char *msg) EV_NOEXCEPT -\& { -\& perror (msg); -\& abort (); -\& } -\& -\& ... -\& ev_set_syserr_cb (fatal_error); -.Ve -.PP -The only \s-1API\s0 functions that can currently throw exceptions are \f(CW\*(C`ev_run\*(C'\fR, -\&\f(CW\*(C`ev_invoke\*(C'\fR, \f(CW\*(C`ev_invoke_pending\*(C'\fR and \f(CW\*(C`ev_loop_destroy\*(C'\fR (the latter -because it runs cleanup watchers). -.PP -Throwing exceptions in watcher callbacks is only supported if libev itself -is compiled with a \*(C+ compiler or your C and \*(C+ environments allow -throwing exceptions through C libraries (most do). -.SS "\*(C+ \s-1API\s0" -.IX Subsection " API" -Libev comes with some simplistic wrapper classes for \*(C+ that mainly allow -you to use some convenience methods to start/stop watchers and also change -the callback model to a model using method callbacks on objects. -.PP -To use it, -.PP -.Vb 1 -\& #include -.Ve -.PP -This automatically includes \fIev.h\fR and puts all of its definitions (many -of them macros) into the global namespace. All \*(C+ specific things are -put into the \f(CW\*(C`ev\*(C'\fR namespace. It should support all the same embedding -options as \fIev.h\fR, most notably \f(CW\*(C`EV_MULTIPLICITY\*(C'\fR. -.PP -Care has been taken to keep the overhead low. The only data member the \*(C+ -classes add (compared to plain C\-style watchers) is the event loop pointer -that the watcher is associated with (or no additional members at all if -you disable \f(CW\*(C`EV_MULTIPLICITY\*(C'\fR when embedding libev). -.PP -Currently, functions, static and non-static member functions and classes -with \f(CW\*(C`operator ()\*(C'\fR can be used as callbacks. Other types should be easy -to add as long as they only need one additional pointer for context. If -you need support for other types of functors please contact the author -(preferably after implementing it). -.PP -For all this to work, your \*(C+ compiler either has to use the same calling -conventions as your C compiler (for static member functions), or you have -to embed libev and compile libev itself as \*(C+. -.PP -Here is a list of things available in the \f(CW\*(C`ev\*(C'\fR namespace: -.ie n .IP """ev::READ"", ""ev::WRITE"" etc." 4 -.el .IP "\f(CWev::READ\fR, \f(CWev::WRITE\fR etc." 4 -.IX Item "ev::READ, ev::WRITE etc." -These are just enum values with the same values as the \f(CW\*(C`EV_READ\*(C'\fR etc. -macros from \fIev.h\fR. -.ie n .IP """ev::tstamp"", ""ev::now""" 4 -.el .IP "\f(CWev::tstamp\fR, \f(CWev::now\fR" 4 -.IX Item "ev::tstamp, ev::now" -Aliases to the same types/functions as with the \f(CW\*(C`ev_\*(C'\fR prefix. -.ie n .IP """ev::io"", ""ev::timer"", ""ev::periodic"", ""ev::idle"", ""ev::sig"" etc." 4 -.el .IP "\f(CWev::io\fR, \f(CWev::timer\fR, \f(CWev::periodic\fR, \f(CWev::idle\fR, \f(CWev::sig\fR etc." 4 -.IX Item "ev::io, ev::timer, ev::periodic, ev::idle, ev::sig etc." -For each \f(CW\*(C`ev_TYPE\*(C'\fR watcher in \fIev.h\fR there is a corresponding class of -the same name in the \f(CW\*(C`ev\*(C'\fR namespace, with the exception of \f(CW\*(C`ev_signal\*(C'\fR -which is called \f(CW\*(C`ev::sig\*(C'\fR to avoid clashes with the \f(CW\*(C`signal\*(C'\fR macro -defined by many implementations. -.Sp -All of those classes have these methods: -.RS 4 -.IP "ev::TYPE::TYPE ()" 4 -.IX Item "ev::TYPE::TYPE ()" -.PD 0 -.IP "ev::TYPE::TYPE (loop)" 4 -.IX Item "ev::TYPE::TYPE (loop)" -.IP "ev::TYPE::~TYPE" 4 -.IX Item "ev::TYPE::~TYPE" -.PD -The constructor (optionally) takes an event loop to associate the watcher -with. If it is omitted, it will use \f(CW\*(C`EV_DEFAULT\*(C'\fR. -.Sp -The constructor calls \f(CW\*(C`ev_init\*(C'\fR for you, which means you have to call the -\&\f(CW\*(C`set\*(C'\fR method before starting it. -.Sp -It will not set a callback, however: You have to call the templated \f(CW\*(C`set\*(C'\fR -method to set a callback before you can start the watcher. -.Sp -(The reason why you have to use a method is a limitation in \*(C+ which does -not allow explicit template arguments for constructors). -.Sp -The destructor automatically stops the watcher if it is active. -.IP "w\->set (object *)" 4 -.IX Item "w->set (object *)" -This method sets the callback method to call. The method has to have a -signature of \f(CW\*(C`void (*)(ev_TYPE &, int)\*(C'\fR, it receives the watcher as -first argument and the \f(CW\*(C`revents\*(C'\fR as second. The object must be given as -parameter and is stored in the \f(CW\*(C`data\*(C'\fR member of the watcher. -.Sp -This method synthesizes efficient thunking code to call your method from -the C callback that libev requires. If your compiler can inline your -callback (i.e. it is visible to it at the place of the \f(CW\*(C`set\*(C'\fR call and -your compiler is good :), then the method will be fully inlined into the -thunking function, making it as fast as a direct C callback. -.Sp -Example: simple class declaration and watcher initialisation -.Sp -.Vb 4 -\& struct myclass -\& { -\& void io_cb (ev::io &w, int revents) { } -\& } -\& -\& myclass obj; -\& ev::io iow; -\& iow.set (&obj); -.Ve -.IP "w\->set (object *)" 4 -.IX Item "w->set (object *)" -This is a variation of a method callback \- leaving out the method to call -will default the method to \f(CW\*(C`operator ()\*(C'\fR, which makes it possible to use -functor objects without having to manually specify the \f(CW\*(C`operator ()\*(C'\fR all -the time. Incidentally, you can then also leave out the template argument -list. -.Sp -The \f(CW\*(C`operator ()\*(C'\fR method prototype must be \f(CW\*(C`void operator ()(watcher &w, -int revents)\*(C'\fR. -.Sp -See the method\-\f(CW\*(C`set\*(C'\fR above for more details. -.Sp -Example: use a functor object as callback. -.Sp -.Vb 7 -\& struct myfunctor -\& { -\& void operator() (ev::io &w, int revents) -\& { -\& ... -\& } -\& } -\& -\& myfunctor f; -\& -\& ev::io w; -\& w.set (&f); -.Ve -.IP "w\->set (void *data = 0)" 4 -.IX Item "w->set (void *data = 0)" -Also sets a callback, but uses a static method or plain function as -callback. The optional \f(CW\*(C`data\*(C'\fR argument will be stored in the watcher's -\&\f(CW\*(C`data\*(C'\fR member and is free for you to use. -.Sp -The prototype of the \f(CW\*(C`function\*(C'\fR must be \f(CW\*(C`void (*)(ev::TYPE &w, int)\*(C'\fR. -.Sp -See the method\-\f(CW\*(C`set\*(C'\fR above for more details. -.Sp -Example: Use a plain function as callback. -.Sp -.Vb 2 -\& static void io_cb (ev::io &w, int revents) { } -\& iow.set (); -.Ve -.IP "w\->set (loop)" 4 -.IX Item "w->set (loop)" -Associates a different \f(CW\*(C`struct ev_loop\*(C'\fR with this watcher. You can only -do this when the watcher is inactive (and not pending either). -.IP "w\->set ([arguments])" 4 -.IX Item "w->set ([arguments])" -Basically the same as \f(CW\*(C`ev_TYPE_set\*(C'\fR (except for \f(CW\*(C`ev::embed\*(C'\fR watchers>), -with the same arguments. Either this method or a suitable start method -must be called at least once. Unlike the C counterpart, an active watcher -gets automatically stopped and restarted when reconfiguring it with this -method. -.Sp -For \f(CW\*(C`ev::embed\*(C'\fR watchers this method is called \f(CW\*(C`set_embed\*(C'\fR, to avoid -clashing with the \f(CW\*(C`set (loop)\*(C'\fR method. -.Sp -For \f(CW\*(C`ev::io\*(C'\fR watchers there is an additional \f(CW\*(C`set\*(C'\fR method that acepts a -new event mask only, and internally calls \f(CW\*(C`ev_io_modfify\*(C'\fR. -.IP "w\->start ()" 4 -.IX Item "w->start ()" -Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the -constructor already stores the event loop. -.IP "w\->start ([arguments])" 4 -.IX Item "w->start ([arguments])" -Instead of calling \f(CW\*(C`set\*(C'\fR and \f(CW\*(C`start\*(C'\fR methods separately, it is often -convenient to wrap them in one call. Uses the same type of arguments as -the configure \f(CW\*(C`set\*(C'\fR method of the watcher. -.IP "w\->stop ()" 4 -.IX Item "w->stop ()" -Stops the watcher if it is active. Again, no \f(CW\*(C`loop\*(C'\fR argument. -.ie n .IP "w\->again () (""ev::timer"", ""ev::periodic"" only)" 4 -.el .IP "w\->again () (\f(CWev::timer\fR, \f(CWev::periodic\fR only)" 4 -.IX Item "w->again () (ev::timer, ev::periodic only)" -For \f(CW\*(C`ev::timer\*(C'\fR and \f(CW\*(C`ev::periodic\*(C'\fR, this invokes the corresponding -\&\f(CW\*(C`ev_TYPE_again\*(C'\fR function. -.ie n .IP "w\->sweep () (""ev::embed"" only)" 4 -.el .IP "w\->sweep () (\f(CWev::embed\fR only)" 4 -.IX Item "w->sweep () (ev::embed only)" -Invokes \f(CW\*(C`ev_embed_sweep\*(C'\fR. -.ie n .IP "w\->update () (""ev::stat"" only)" 4 -.el .IP "w\->update () (\f(CWev::stat\fR only)" 4 -.IX Item "w->update () (ev::stat only)" -Invokes \f(CW\*(C`ev_stat_stat\*(C'\fR. -.RE -.RS 4 -.RE -.PP -Example: Define a class with two I/O and idle watchers, start the I/O -watchers in the constructor. -.PP -.Vb 5 -\& class myclass -\& { -\& ev::io io ; void io_cb (ev::io &w, int revents); -\& ev::io io2 ; void io2_cb (ev::io &w, int revents); -\& ev::idle idle; void idle_cb (ev::idle &w, int revents); -\& -\& myclass (int fd) -\& { -\& io .set (this); -\& io2 .set (this); -\& idle.set (this); -\& -\& io.set (fd, ev::WRITE); // configure the watcher -\& io.start (); // start it whenever convenient -\& -\& io2.start (fd, ev::READ); // set + start in one call -\& } -\& }; -.Ve -.SH "OTHER LANGUAGE BINDINGS" -.IX Header "OTHER LANGUAGE BINDINGS" -Libev does not offer other language bindings itself, but bindings for a -number of languages exist in the form of third-party packages. If you know -any interesting language binding in addition to the ones listed here, drop -me a note. -.IP "Perl" 4 -.IX Item "Perl" -The \s-1EV\s0 module implements the full libev \s-1API\s0 and is actually used to test -libev. \s-1EV\s0 is developed together with libev. Apart from the \s-1EV\s0 core module, -there are additional modules that implement libev-compatible interfaces -to \f(CW\*(C`libadns\*(C'\fR (\f(CW\*(C`EV::ADNS\*(C'\fR, but \f(CW\*(C`AnyEvent::DNS\*(C'\fR is preferred nowadays), -\&\f(CW\*(C`Net::SNMP\*(C'\fR (\f(CW\*(C`Net::SNMP::EV\*(C'\fR) and the \f(CW\*(C`libglib\*(C'\fR event core (\f(CW\*(C`Glib::EV\*(C'\fR -and \f(CW\*(C`EV::Glib\*(C'\fR). -.Sp -It can be found and installed via \s-1CPAN,\s0 its homepage is at -. -.IP "Python" 4 -.IX Item "Python" -Python bindings can be found at . It -seems to be quite complete and well-documented. -.IP "Ruby" 4 -.IX Item "Ruby" -Tony Arcieri has written a ruby extension that offers access to a subset -of the libev \s-1API\s0 and adds file handle abstractions, asynchronous \s-1DNS\s0 and -more on top of it. It can be found via gem servers. Its homepage is at -. -.Sp -Roger Pack reports that using the link order \f(CW\*(C`\-lws2_32 \-lmsvcrt\-ruby\-190\*(C'\fR -makes rev work even on mingw. -.IP "Haskell" 4 -.IX Item "Haskell" -A haskell binding to libev is available at -. -.IP "D" 4 -.IX Item "D" -Leandro Lucarella has written a D language binding (\fIev.d\fR) for libev, to -be found at . -.IP "Ocaml" 4 -.IX Item "Ocaml" -Erkki Seppala has written Ocaml bindings for libev, to be found at -. -.IP "Lua" 4 -.IX Item "Lua" -Brian Maher has written a partial interface to libev for lua (at the -time of this writing, only \f(CW\*(C`ev_io\*(C'\fR and \f(CW\*(C`ev_timer\*(C'\fR), to be found at -. -.IP "Javascript" 4 -.IX Item "Javascript" -Node.js () uses libev as the underlying event library. -.IP "Others" 4 -.IX Item "Others" -There are others, and I stopped counting. -.SH "MACRO MAGIC" -.IX Header "MACRO MAGIC" -Libev can be compiled with a variety of options, the most fundamental -of which is \f(CW\*(C`EV_MULTIPLICITY\*(C'\fR. This option determines whether (most) -functions and callbacks have an initial \f(CW\*(C`struct ev_loop *\*(C'\fR argument. -.PP -To make it easier to write programs that cope with either variant, the -following macros are defined: -.ie n .IP """EV_A"", ""EV_A_""" 4 -.el .IP "\f(CWEV_A\fR, \f(CWEV_A_\fR" 4 -.IX Item "EV_A, EV_A_" -This provides the loop \fIargument\fR for functions, if one is required (\*(L"ev -loop argument\*(R"). The \f(CW\*(C`EV_A\*(C'\fR form is used when this is the sole argument, -\&\f(CW\*(C`EV_A_\*(C'\fR is used when other arguments are following. Example: -.Sp -.Vb 3 -\& ev_unref (EV_A); -\& ev_timer_add (EV_A_ watcher); -\& ev_run (EV_A_ 0); -.Ve -.Sp -It assumes the variable \f(CW\*(C`loop\*(C'\fR of type \f(CW\*(C`struct ev_loop *\*(C'\fR is in scope, -which is often provided by the following macro. -.ie n .IP """EV_P"", ""EV_P_""" 4 -.el .IP "\f(CWEV_P\fR, \f(CWEV_P_\fR" 4 -.IX Item "EV_P, EV_P_" -This provides the loop \fIparameter\fR for functions, if one is required (\*(L"ev -loop parameter\*(R"). The \f(CW\*(C`EV_P\*(C'\fR form is used when this is the sole parameter, -\&\f(CW\*(C`EV_P_\*(C'\fR is used when other parameters are following. Example: -.Sp -.Vb 2 -\& // this is how ev_unref is being declared -\& static void ev_unref (EV_P); -\& -\& // this is how you can declare your typical callback -\& static void cb (EV_P_ ev_timer *w, int revents) -.Ve -.Sp -It declares a parameter \f(CW\*(C`loop\*(C'\fR of type \f(CW\*(C`struct ev_loop *\*(C'\fR, quite -suitable for use with \f(CW\*(C`EV_A\*(C'\fR. -.ie n .IP """EV_DEFAULT"", ""EV_DEFAULT_""" 4 -.el .IP "\f(CWEV_DEFAULT\fR, \f(CWEV_DEFAULT_\fR" 4 -.IX Item "EV_DEFAULT, EV_DEFAULT_" -Similar to the other two macros, this gives you the value of the default -loop, if multiple loops are supported (\*(L"ev loop default\*(R"). The default loop -will be initialised if it isn't already initialised. -.Sp -For non-multiplicity builds, these macros do nothing, so you always have -to initialise the loop somewhere. -.ie n .IP """EV_DEFAULT_UC"", ""EV_DEFAULT_UC_""" 4 -.el .IP "\f(CWEV_DEFAULT_UC\fR, \f(CWEV_DEFAULT_UC_\fR" 4 -.IX Item "EV_DEFAULT_UC, EV_DEFAULT_UC_" -Usage identical to \f(CW\*(C`EV_DEFAULT\*(C'\fR and \f(CW\*(C`EV_DEFAULT_\*(C'\fR, but requires that the -default loop has been initialised (\f(CW\*(C`UC\*(C'\fR == unchecked). Their behaviour -is undefined when the default loop has not been initialised by a previous -execution of \f(CW\*(C`EV_DEFAULT\*(C'\fR, \f(CW\*(C`EV_DEFAULT_\*(C'\fR or \f(CW\*(C`ev_default_init (...)\*(C'\fR. -.Sp -It is often prudent to use \f(CW\*(C`EV_DEFAULT\*(C'\fR when initialising the first -watcher in a function but use \f(CW\*(C`EV_DEFAULT_UC\*(C'\fR afterwards. -.PP -Example: Declare and initialise a check watcher, utilising the above -macros so it will work regardless of whether multiple loops are supported -or not. -.PP -.Vb 5 -\& static void -\& check_cb (EV_P_ ev_timer *w, int revents) -\& { -\& ev_check_stop (EV_A_ w); -\& } -\& -\& ev_check check; -\& ev_check_init (&check, check_cb); -\& ev_check_start (EV_DEFAULT_ &check); -\& ev_run (EV_DEFAULT_ 0); -.Ve -.SH "EMBEDDING" -.IX Header "EMBEDDING" -Libev can (and often is) directly embedded into host -applications. Examples of applications that embed it include the Deliantra -Game Server, the \s-1EV\s0 perl module, the \s-1GNU\s0 Virtual Private Ethernet (gvpe) -and rxvt-unicode. -.PP -The goal is to enable you to just copy the necessary files into your -source directory without having to change even a single line in them, so -you can easily upgrade by simply copying (or having a checked-out copy of -libev somewhere in your source tree). -.SS "\s-1FILESETS\s0" -.IX Subsection "FILESETS" -Depending on what features you need you need to include one or more sets of files -in your application. -.PP -\fI\s-1CORE EVENT LOOP\s0\fR -.IX Subsection "CORE EVENT LOOP" -.PP -To include only the libev core (all the \f(CW\*(C`ev_*\*(C'\fR functions), with manual -configuration (no autoconf): -.PP -.Vb 2 -\& #define EV_STANDALONE 1 -\& #include "ev.c" -.Ve -.PP -This will automatically include \fIev.h\fR, too, and should be done in a -single C source file only to provide the function implementations. To use -it, do the same for \fIev.h\fR in all files wishing to use this \s-1API\s0 (best -done by writing a wrapper around \fIev.h\fR that you can include instead and -where you can put other configuration options): -.PP -.Vb 2 -\& #define EV_STANDALONE 1 -\& #include "ev.h" -.Ve -.PP -Both header files and implementation files can be compiled with a \*(C+ -compiler (at least, that's a stated goal, and breakage will be treated -as a bug). -.PP -You need the following files in your source tree, or in a directory -in your include path (e.g. in libev/ when using \-Ilibev): -.PP -.Vb 4 -\& ev.h -\& ev.c -\& ev_vars.h -\& ev_wrap.h -\& -\& ev_win32.c required on win32 platforms only -\& -\& ev_select.c only when select backend is enabled -\& ev_poll.c only when poll backend is enabled -\& ev_epoll.c only when the epoll backend is enabled -\& ev_linuxaio.c only when the linux aio backend is enabled -\& ev_iouring.c only when the linux io_uring backend is enabled -\& ev_kqueue.c only when the kqueue backend is enabled -\& ev_port.c only when the solaris port backend is enabled -.Ve -.PP -\&\fIev.c\fR includes the backend files directly when enabled, so you only need -to compile this single file. -.PP -\fI\s-1LIBEVENT COMPATIBILITY API\s0\fR -.IX Subsection "LIBEVENT COMPATIBILITY API" -.PP -To include the libevent compatibility \s-1API,\s0 also include: -.PP -.Vb 1 -\& #include "event.c" -.Ve -.PP -in the file including \fIev.c\fR, and: -.PP -.Vb 1 -\& #include "event.h" -.Ve -.PP -in the files that want to use the libevent \s-1API.\s0 This also includes \fIev.h\fR. -.PP -You need the following additional files for this: -.PP -.Vb 2 -\& event.h -\& event.c -.Ve -.PP -\fI\s-1AUTOCONF SUPPORT\s0\fR -.IX Subsection "AUTOCONF SUPPORT" -.PP -Instead of using \f(CW\*(C`EV_STANDALONE=1\*(C'\fR and providing your configuration in -whatever way you want, you can also \f(CW\*(C`m4_include([libev.m4])\*(C'\fR in your -\&\fIconfigure.ac\fR and leave \f(CW\*(C`EV_STANDALONE\*(C'\fR undefined. \fIev.c\fR will then -include \fIconfig.h\fR and configure itself accordingly. -.PP -For this of course you need the m4 file: -.PP -.Vb 1 -\& libev.m4 -.Ve -.SS "\s-1PREPROCESSOR SYMBOLS/MACROS\s0" -.IX Subsection "PREPROCESSOR SYMBOLS/MACROS" -Libev can be configured via a variety of preprocessor symbols you have to -define before including (or compiling) any of its files. The default in -the absence of autoconf is documented for every option. -.PP -Symbols marked with \*(L"(h)\*(R" do not change the \s-1ABI,\s0 and can have different -values when compiling libev vs. including \fIev.h\fR, so it is permissible -to redefine them before including \fIev.h\fR without breaking compatibility -to a compiled library. All other symbols change the \s-1ABI,\s0 which means all -users of libev and the libev code itself must be compiled with compatible -settings. -.IP "\s-1EV_COMPAT3\s0 (h)" 4 -.IX Item "EV_COMPAT3 (h)" -Backwards compatibility is a major concern for libev. This is why this -release of libev comes with wrappers for the functions and symbols that -have been renamed between libev version 3 and 4. -.Sp -You can disable these wrappers (to test compatibility with future -versions) by defining \f(CW\*(C`EV_COMPAT3\*(C'\fR to \f(CW0\fR when compiling your -sources. This has the additional advantage that you can drop the \f(CW\*(C`struct\*(C'\fR -from \f(CW\*(C`struct ev_loop\*(C'\fR declarations, as libev will provide an \f(CW\*(C`ev_loop\*(C'\fR -typedef in that case. -.Sp -In some future version, the default for \f(CW\*(C`EV_COMPAT3\*(C'\fR will become \f(CW0\fR, -and in some even more future version the compatibility code will be -removed completely. -.IP "\s-1EV_STANDALONE\s0 (h)" 4 -.IX Item "EV_STANDALONE (h)" -Must always be \f(CW1\fR if you do not use autoconf configuration, which -keeps libev from including \fIconfig.h\fR, and it also defines dummy -implementations for some libevent functions (such as logging, which is not -supported). It will also not define any of the structs usually found in -\&\fIevent.h\fR that are not directly supported by the libev core alone. -.Sp -In standalone mode, libev will still try to automatically deduce the -configuration, but has to be more conservative. -.IP "\s-1EV_USE_FLOOR\s0" 4 -.IX Item "EV_USE_FLOOR" -If defined to be \f(CW1\fR, libev will use the \f(CW\*(C`floor ()\*(C'\fR function for its -periodic reschedule calculations, otherwise libev will fall back on a -portable (slower) implementation. If you enable this, you usually have to -link against libm or something equivalent. Enabling this when the \f(CW\*(C`floor\*(C'\fR -function is not available will fail, so the safe default is to not enable -this. -.IP "\s-1EV_USE_MONOTONIC\s0" 4 -.IX Item "EV_USE_MONOTONIC" -If defined to be \f(CW1\fR, libev will try to detect the availability of the -monotonic clock option at both compile time and runtime. Otherwise no -use of the monotonic clock option will be attempted. If you enable this, -you usually have to link against librt or something similar. Enabling it -when the functionality isn't available is safe, though, although you have -to make sure you link against any libraries where the \f(CW\*(C`clock_gettime\*(C'\fR -function is hiding in (often \fI\-lrt\fR). See also \f(CW\*(C`EV_USE_CLOCK_SYSCALL\*(C'\fR. -.IP "\s-1EV_USE_REALTIME\s0" 4 -.IX Item "EV_USE_REALTIME" -If defined to be \f(CW1\fR, libev will try to detect the availability of the -real-time clock option at compile time (and assume its availability -at runtime if successful). Otherwise no use of the real-time clock -option will be attempted. This effectively replaces \f(CW\*(C`gettimeofday\*(C'\fR -by \f(CW\*(C`clock_get (CLOCK_REALTIME, ...)\*(C'\fR and will not normally affect -correctness. See the note about libraries in the description of -\&\f(CW\*(C`EV_USE_MONOTONIC\*(C'\fR, though. Defaults to the opposite value of -\&\f(CW\*(C`EV_USE_CLOCK_SYSCALL\*(C'\fR. -.IP "\s-1EV_USE_CLOCK_SYSCALL\s0" 4 -.IX Item "EV_USE_CLOCK_SYSCALL" -If defined to be \f(CW1\fR, libev will try to use a direct syscall instead -of calling the system-provided \f(CW\*(C`clock_gettime\*(C'\fR function. This option -exists because on GNU/Linux, \f(CW\*(C`clock_gettime\*(C'\fR is in \f(CW\*(C`librt\*(C'\fR, but \f(CW\*(C`librt\*(C'\fR -unconditionally pulls in \f(CW\*(C`libpthread\*(C'\fR, slowing down single-threaded -programs needlessly. Using a direct syscall is slightly slower (in -theory), because no optimised vdso implementation can be used, but avoids -the pthread dependency. Defaults to \f(CW1\fR on GNU/Linux with glibc 2.x or -higher, as it simplifies linking (no need for \f(CW\*(C`\-lrt\*(C'\fR). -.IP "\s-1EV_USE_NANOSLEEP\s0" 4 -.IX Item "EV_USE_NANOSLEEP" -If defined to be \f(CW1\fR, libev will assume that \f(CW\*(C`nanosleep ()\*(C'\fR is available -and will use it for delays. Otherwise it will use \f(CW\*(C`select ()\*(C'\fR. -.IP "\s-1EV_USE_EVENTFD\s0" 4 -.IX Item "EV_USE_EVENTFD" -If defined to be \f(CW1\fR, then libev will assume that \f(CW\*(C`eventfd ()\*(C'\fR is -available and will probe for kernel support at runtime. This will improve -\&\f(CW\*(C`ev_signal\*(C'\fR and \f(CW\*(C`ev_async\*(C'\fR performance and reduce resource consumption. -If undefined, it will be enabled if the headers indicate GNU/Linux + Glibc -2.7 or newer, otherwise disabled. -.IP "\s-1EV_USE_SIGNALFD\s0" 4 -.IX Item "EV_USE_SIGNALFD" -If defined to be \f(CW1\fR, then libev will assume that \f(CW\*(C`signalfd ()\*(C'\fR is -available and will probe for kernel support at runtime. This enables -the use of \s-1EVFLAG_SIGNALFD\s0 for faster and simpler signal handling. If -undefined, it will be enabled if the headers indicate GNU/Linux + Glibc -2.7 or newer, otherwise disabled. -.IP "\s-1EV_USE_TIMERFD\s0" 4 -.IX Item "EV_USE_TIMERFD" -If defined to be \f(CW1\fR, then libev will assume that \f(CW\*(C`timerfd ()\*(C'\fR is -available and will probe for kernel support at runtime. This allows -libev to detect time jumps accurately. If undefined, it will be enabled -if the headers indicate GNU/Linux + Glibc 2.8 or newer and define -\&\f(CW\*(C`TFD_TIMER_CANCEL_ON_SET\*(C'\fR, otherwise disabled. -.IP "\s-1EV_USE_EVENTFD\s0" 4 -.IX Item "EV_USE_EVENTFD" -If defined to be \f(CW1\fR, then libev will assume that \f(CW\*(C`eventfd ()\*(C'\fR is -available and will probe for kernel support at runtime. This will improve -\&\f(CW\*(C`ev_signal\*(C'\fR and \f(CW\*(C`ev_async\*(C'\fR performance and reduce resource consumption. -If undefined, it will be enabled if the headers indicate GNU/Linux + Glibc -2.7 or newer, otherwise disabled. -.IP "\s-1EV_USE_SELECT\s0" 4 -.IX Item "EV_USE_SELECT" -If undefined or defined to be \f(CW1\fR, libev will compile in support for the -\&\f(CW\*(C`select\*(C'\fR(2) backend. No attempt at auto-detection will be done: if no -other method takes over, select will be it. Otherwise the select backend -will not be compiled in. -.IP "\s-1EV_SELECT_USE_FD_SET\s0" 4 -.IX Item "EV_SELECT_USE_FD_SET" -If defined to \f(CW1\fR, then the select backend will use the system \f(CW\*(C`fd_set\*(C'\fR -structure. This is useful if libev doesn't compile due to a missing -\&\f(CW\*(C`NFDBITS\*(C'\fR or \f(CW\*(C`fd_mask\*(C'\fR definition or it mis-guesses the bitset layout -on exotic systems. This usually limits the range of file descriptors to -some low limit such as 1024 or might have other limitations (winsocket -only allows 64 sockets). The \f(CW\*(C`FD_SETSIZE\*(C'\fR macro, set before compilation, -configures the maximum size of the \f(CW\*(C`fd_set\*(C'\fR. -.IP "\s-1EV_SELECT_IS_WINSOCKET\s0" 4 -.IX Item "EV_SELECT_IS_WINSOCKET" -When defined to \f(CW1\fR, the select backend will assume that -select/socket/connect etc. don't understand file descriptors but -wants osf handles on win32 (this is the case when the select to -be used is the winsock select). This means that it will call -\&\f(CW\*(C`_get_osfhandle\*(C'\fR on the fd to convert it to an \s-1OS\s0 handle. Otherwise, -it is assumed that all these functions actually work on fds, even -on win32. Should not be defined on non\-win32 platforms. -.IP "\s-1EV_FD_TO_WIN32_HANDLE\s0(fd)" 4 -.IX Item "EV_FD_TO_WIN32_HANDLE(fd)" -If \f(CW\*(C`EV_SELECT_IS_WINSOCKET\*(C'\fR is enabled, then libev needs a way to map -file descriptors to socket handles. When not defining this symbol (the -default), then libev will call \f(CW\*(C`_get_osfhandle\*(C'\fR, which is usually -correct. In some cases, programs use their own file descriptor management, -in which case they can provide this function to map fds to socket handles. -.IP "\s-1EV_WIN32_HANDLE_TO_FD\s0(handle)" 4 -.IX Item "EV_WIN32_HANDLE_TO_FD(handle)" -If \f(CW\*(C`EV_SELECT_IS_WINSOCKET\*(C'\fR then libev maps handles to file descriptors -using the standard \f(CW\*(C`_open_osfhandle\*(C'\fR function. For programs implementing -their own fd to handle mapping, overwriting this function makes it easier -to do so. This can be done by defining this macro to an appropriate value. -.IP "\s-1EV_WIN32_CLOSE_FD\s0(fd)" 4 -.IX Item "EV_WIN32_CLOSE_FD(fd)" -If programs implement their own fd to handle mapping on win32, then this -macro can be used to override the \f(CW\*(C`close\*(C'\fR function, useful to unregister -file descriptors again. Note that the replacement function has to close -the underlying \s-1OS\s0 handle. -.IP "\s-1EV_USE_WSASOCKET\s0" 4 -.IX Item "EV_USE_WSASOCKET" -If defined to be \f(CW1\fR, libev will use \f(CW\*(C`WSASocket\*(C'\fR to create its internal -communication socket, which works better in some environments. Otherwise, -the normal \f(CW\*(C`socket\*(C'\fR function will be used, which works better in other -environments. -.IP "\s-1EV_USE_POLL\s0" 4 -.IX Item "EV_USE_POLL" -If defined to be \f(CW1\fR, libev will compile in support for the \f(CW\*(C`poll\*(C'\fR(2) -backend. Otherwise it will be enabled on non\-win32 platforms. It -takes precedence over select. -.IP "\s-1EV_USE_EPOLL\s0" 4 -.IX Item "EV_USE_EPOLL" -If defined to be \f(CW1\fR, libev will compile in support for the Linux -\&\f(CW\*(C`epoll\*(C'\fR(7) backend. Its availability will be detected at runtime, -otherwise another method will be used as fallback. This is the preferred -backend for GNU/Linux systems. If undefined, it will be enabled if the -headers indicate GNU/Linux + Glibc 2.4 or newer, otherwise disabled. -.IP "\s-1EV_USE_LINUXAIO\s0" 4 -.IX Item "EV_USE_LINUXAIO" -If defined to be \f(CW1\fR, libev will compile in support for the Linux aio -backend (\f(CW\*(C`EV_USE_EPOLL\*(C'\fR must also be enabled). If undefined, it will be -enabled on linux, otherwise disabled. -.IP "\s-1EV_USE_IOURING\s0" 4 -.IX Item "EV_USE_IOURING" -If defined to be \f(CW1\fR, libev will compile in support for the Linux -io_uring backend (\f(CW\*(C`EV_USE_EPOLL\*(C'\fR must also be enabled). Due to it's -current limitations it has to be requested explicitly. If undefined, it -will be enabled on linux, otherwise disabled. -.IP "\s-1EV_USE_KQUEUE\s0" 4 -.IX Item "EV_USE_KQUEUE" -If defined to be \f(CW1\fR, libev will compile in support for the \s-1BSD\s0 style -\&\f(CW\*(C`kqueue\*(C'\fR(2) backend. Its actual availability will be detected at runtime, -otherwise another method will be used as fallback. This is the preferred -backend for \s-1BSD\s0 and BSD-like systems, although on most BSDs kqueue only -supports some types of fds correctly (the only platform we found that -supports ptys for example was NetBSD), so kqueue might be compiled in, but -not be used unless explicitly requested. The best way to use it is to find -out whether kqueue supports your type of fd properly and use an embedded -kqueue loop. -.IP "\s-1EV_USE_PORT\s0" 4 -.IX Item "EV_USE_PORT" -If defined to be \f(CW1\fR, libev will compile in support for the Solaris -10 port style backend. Its availability will be detected at runtime, -otherwise another method will be used as fallback. This is the preferred -backend for Solaris 10 systems. -.IP "\s-1EV_USE_DEVPOLL\s0" 4 -.IX Item "EV_USE_DEVPOLL" -Reserved for future expansion, works like the \s-1USE\s0 symbols above. -.IP "\s-1EV_USE_INOTIFY\s0" 4 -.IX Item "EV_USE_INOTIFY" -If defined to be \f(CW1\fR, libev will compile in support for the Linux inotify -interface to speed up \f(CW\*(C`ev_stat\*(C'\fR watchers. Its actual availability will -be detected at runtime. If undefined, it will be enabled if the headers -indicate GNU/Linux + Glibc 2.4 or newer, otherwise disabled. -.IP "\s-1EV_NO_SMP\s0" 4 -.IX Item "EV_NO_SMP" -If defined to be \f(CW1\fR, libev will assume that memory is always coherent -between threads, that is, threads can be used, but threads never run on -different cpus (or different cpu cores). This reduces dependencies -and makes libev faster. -.IP "\s-1EV_NO_THREADS\s0" 4 -.IX Item "EV_NO_THREADS" -If defined to be \f(CW1\fR, libev will assume that it will never be called from -different threads (that includes signal handlers), which is a stronger -assumption than \f(CW\*(C`EV_NO_SMP\*(C'\fR, above. This reduces dependencies and makes -libev faster. -.IP "\s-1EV_ATOMIC_T\s0" 4 -.IX Item "EV_ATOMIC_T" -Libev requires an integer type (suitable for storing \f(CW0\fR or \f(CW1\fR) whose -access is atomic with respect to other threads or signal contexts. No -such type is easily found in the C language, so you can provide your own -type that you know is safe for your purposes. It is used both for signal -handler \*(L"locking\*(R" as well as for signal and thread safety in \f(CW\*(C`ev_async\*(C'\fR -watchers. -.Sp -In the absence of this define, libev will use \f(CW\*(C`sig_atomic_t volatile\*(C'\fR -(from \fIsignal.h\fR), which is usually good enough on most platforms. -.IP "\s-1EV_H\s0 (h)" 4 -.IX Item "EV_H (h)" -The name of the \fIev.h\fR header file used to include it. The default if -undefined is \f(CW"ev.h"\fR in \fIevent.h\fR, \fIev.c\fR and \fIev++.h\fR. This can be -used to virtually rename the \fIev.h\fR header file in case of conflicts. -.IP "\s-1EV_CONFIG_H\s0 (h)" 4 -.IX Item "EV_CONFIG_H (h)" -If \f(CW\*(C`EV_STANDALONE\*(C'\fR isn't \f(CW1\fR, this variable can be used to override -\&\fIev.c\fR's idea of where to find the \fIconfig.h\fR file, similarly to -\&\f(CW\*(C`EV_H\*(C'\fR, above. -.IP "\s-1EV_EVENT_H\s0 (h)" 4 -.IX Item "EV_EVENT_H (h)" -Similarly to \f(CW\*(C`EV_H\*(C'\fR, this macro can be used to override \fIevent.c\fR's idea -of how the \fIevent.h\fR header can be found, the default is \f(CW"event.h"\fR. -.IP "\s-1EV_PROTOTYPES\s0 (h)" 4 -.IX Item "EV_PROTOTYPES (h)" -If defined to be \f(CW0\fR, then \fIev.h\fR will not define any function -prototypes, but still define all the structs and other symbols. This is -occasionally useful if you want to provide your own wrapper functions -around libev functions. -.IP "\s-1EV_MULTIPLICITY\s0" 4 -.IX Item "EV_MULTIPLICITY" -If undefined or defined to \f(CW1\fR, then all event-loop-specific functions -will have the \f(CW\*(C`struct ev_loop *\*(C'\fR as first argument, and you can create -additional independent event loops. Otherwise there will be no support -for multiple event loops and there is no first event loop pointer -argument. Instead, all functions act on the single default loop. -.Sp -Note that \f(CW\*(C`EV_DEFAULT\*(C'\fR and \f(CW\*(C`EV_DEFAULT_\*(C'\fR will no longer provide a -default loop when multiplicity is switched off \- you always have to -initialise the loop manually in this case. -.IP "\s-1EV_MINPRI\s0" 4 -.IX Item "EV_MINPRI" -.PD 0 -.IP "\s-1EV_MAXPRI\s0" 4 -.IX Item "EV_MAXPRI" -.PD -The range of allowed priorities. \f(CW\*(C`EV_MINPRI\*(C'\fR must be smaller or equal to -\&\f(CW\*(C`EV_MAXPRI\*(C'\fR, but otherwise there are no non-obvious limitations. You can -provide for more priorities by overriding those symbols (usually defined -to be \f(CW\*(C`\-2\*(C'\fR and \f(CW2\fR, respectively). -.Sp -When doing priority-based operations, libev usually has to linearly search -all the priorities, so having many of them (hundreds) uses a lot of space -and time, so using the defaults of five priorities (\-2 .. +2) is usually -fine. -.Sp -If your embedding application does not need any priorities, defining these -both to \f(CW0\fR will save some memory and \s-1CPU.\s0 -.IP "\s-1EV_PERIODIC_ENABLE, EV_IDLE_ENABLE, EV_EMBED_ENABLE, EV_STAT_ENABLE, EV_PREPARE_ENABLE, EV_CHECK_ENABLE, EV_FORK_ENABLE, EV_SIGNAL_ENABLE, EV_ASYNC_ENABLE, EV_CHILD_ENABLE.\s0" 4 -.IX Item "EV_PERIODIC_ENABLE, EV_IDLE_ENABLE, EV_EMBED_ENABLE, EV_STAT_ENABLE, EV_PREPARE_ENABLE, EV_CHECK_ENABLE, EV_FORK_ENABLE, EV_SIGNAL_ENABLE, EV_ASYNC_ENABLE, EV_CHILD_ENABLE." -If undefined or defined to be \f(CW1\fR (and the platform supports it), then -the respective watcher type is supported. If defined to be \f(CW0\fR, then it -is not. Disabling watcher types mainly saves code size. -.IP "\s-1EV_FEATURES\s0" 4 -.IX Item "EV_FEATURES" -If you need to shave off some kilobytes of code at the expense of some -speed (but with the full \s-1API\s0), you can define this symbol to request -certain subsets of functionality. The default is to enable all features -that can be enabled on the platform. -.Sp -A typical way to use this symbol is to define it to \f(CW0\fR (or to a bitset -with some broad features you want) and then selectively re-enable -additional parts you want, for example if you want everything minimal, -but multiple event loop support, async and child watchers and the poll -backend, use this: -.Sp -.Vb 5 -\& #define EV_FEATURES 0 -\& #define EV_MULTIPLICITY 1 -\& #define EV_USE_POLL 1 -\& #define EV_CHILD_ENABLE 1 -\& #define EV_ASYNC_ENABLE 1 -.Ve -.Sp -The actual value is a bitset, it can be a combination of the following -values (by default, all of these are enabled): -.RS 4 -.ie n .IP "1 \- faster/larger code" 4 -.el .IP "\f(CW1\fR \- faster/larger code" 4 -.IX Item "1 - faster/larger code" -Use larger code to speed up some operations. -.Sp -Currently this is used to override some inlining decisions (enlarging the -code size by roughly 30% on amd64). -.Sp -When optimising for size, use of compiler flags such as \f(CW\*(C`\-Os\*(C'\fR with -gcc is recommended, as well as \f(CW\*(C`\-DNDEBUG\*(C'\fR, as libev contains a number of -assertions. -.Sp -The default is off when \f(CW\*(C`_\|_OPTIMIZE_SIZE_\|_\*(C'\fR is defined by your compiler -(e.g. gcc with \f(CW\*(C`\-Os\*(C'\fR). -.ie n .IP "2 \- faster/larger data structures" 4 -.el .IP "\f(CW2\fR \- faster/larger data structures" 4 -.IX Item "2 - faster/larger data structures" -Replaces the small 2\-heap for timer management by a faster 4\-heap, larger -hash table sizes and so on. This will usually further increase code size -and can additionally have an effect on the size of data structures at -runtime. -.Sp -The default is off when \f(CW\*(C`_\|_OPTIMIZE_SIZE_\|_\*(C'\fR is defined by your compiler -(e.g. gcc with \f(CW\*(C`\-Os\*(C'\fR). -.ie n .IP "4 \- full \s-1API\s0 configuration" 4 -.el .IP "\f(CW4\fR \- full \s-1API\s0 configuration" 4 -.IX Item "4 - full API configuration" -This enables priorities (sets \f(CW\*(C`EV_MAXPRI\*(C'\fR=2 and \f(CW\*(C`EV_MINPRI\*(C'\fR=\-2), and -enables multiplicity (\f(CW\*(C`EV_MULTIPLICITY\*(C'\fR=1). -.ie n .IP "8 \- full \s-1API\s0" 4 -.el .IP "\f(CW8\fR \- full \s-1API\s0" 4 -.IX Item "8 - full API" -This enables a lot of the \*(L"lesser used\*(R" \s-1API\s0 functions. See \f(CW\*(C`ev.h\*(C'\fR for -details on which parts of the \s-1API\s0 are still available without this -feature, and do not complain if this subset changes over time. -.ie n .IP "16 \- enable all optional watcher types" 4 -.el .IP "\f(CW16\fR \- enable all optional watcher types" 4 -.IX Item "16 - enable all optional watcher types" -Enables all optional watcher types. If you want to selectively enable -only some watcher types other than I/O and timers (e.g. prepare, -embed, async, child...) you can enable them manually by defining -\&\f(CW\*(C`EV_watchertype_ENABLE\*(C'\fR to \f(CW1\fR instead. -.ie n .IP "32 \- enable all backends" 4 -.el .IP "\f(CW32\fR \- enable all backends" 4 -.IX Item "32 - enable all backends" -This enables all backends \- without this feature, you need to enable at -least one backend manually (\f(CW\*(C`EV_USE_SELECT\*(C'\fR is a good choice). -.ie n .IP "64 \- enable OS-specific ""helper"" APIs" 4 -.el .IP "\f(CW64\fR \- enable OS-specific ``helper'' APIs" 4 -.IX Item "64 - enable OS-specific helper APIs" -Enable inotify, eventfd, signalfd and similar OS-specific helper APIs by -default. -.RE -.RS 4 -.Sp -Compiling with \f(CW\*(C`gcc \-Os \-DEV_STANDALONE \-DEV_USE_EPOLL=1 \-DEV_FEATURES=0\*(C'\fR -reduces the compiled size of libev from 24.7Kb code/2.8Kb data to 6.5Kb -code/0.3Kb data on my GNU/Linux amd64 system, while still giving you I/O -watchers, timers and monotonic clock support. -.Sp -With an intelligent-enough linker (gcc+binutils are intelligent enough -when you use \f(CW\*(C`\-Wl,\-\-gc\-sections \-ffunction\-sections\*(C'\fR) functions unused by -your program might be left out as well \- a binary starting a timer and an -I/O watcher then might come out at only 5Kb. -.RE -.IP "\s-1EV_API_STATIC\s0" 4 -.IX Item "EV_API_STATIC" -If this symbol is defined (by default it is not), then all identifiers -will have static linkage. This means that libev will not export any -identifiers, and you cannot link against libev anymore. This can be useful -when you embed libev, only want to use libev functions in a single file, -and do not want its identifiers to be visible. -.Sp -To use this, define \f(CW\*(C`EV_API_STATIC\*(C'\fR and include \fIev.c\fR in the file that -wants to use libev. -.Sp -This option only works when libev is compiled with a C compiler, as \*(C+ -doesn't support the required declaration syntax. -.IP "\s-1EV_AVOID_STDIO\s0" 4 -.IX Item "EV_AVOID_STDIO" -If this is set to \f(CW1\fR at compiletime, then libev will avoid using stdio -functions (printf, scanf, perror etc.). This will increase the code size -somewhat, but if your program doesn't otherwise depend on stdio and your -libc allows it, this avoids linking in the stdio library which is quite -big. -.Sp -Note that error messages might become less precise when this option is -enabled. -.IP "\s-1EV_NSIG\s0" 4 -.IX Item "EV_NSIG" -The highest supported signal number, +1 (or, the number of -signals): Normally, libev tries to deduce the maximum number of signals -automatically, but sometimes this fails, in which case it can be -specified. Also, using a lower number than detected (\f(CW32\fR should be -good for about any system in existence) can save some memory, as libev -statically allocates some 12\-24 bytes per signal number. -.IP "\s-1EV_PID_HASHSIZE\s0" 4 -.IX Item "EV_PID_HASHSIZE" -\&\f(CW\*(C`ev_child\*(C'\fR watchers use a small hash table to distribute workload by -pid. The default size is \f(CW16\fR (or \f(CW1\fR with \f(CW\*(C`EV_FEATURES\*(C'\fR disabled), -usually more than enough. If you need to manage thousands of children you -might want to increase this value (\fImust\fR be a power of two). -.IP "\s-1EV_INOTIFY_HASHSIZE\s0" 4 -.IX Item "EV_INOTIFY_HASHSIZE" -\&\f(CW\*(C`ev_stat\*(C'\fR watchers use a small hash table to distribute workload by -inotify watch id. The default size is \f(CW16\fR (or \f(CW1\fR with \f(CW\*(C`EV_FEATURES\*(C'\fR -disabled), usually more than enough. If you need to manage thousands of -\&\f(CW\*(C`ev_stat\*(C'\fR watchers you might want to increase this value (\fImust\fR be a -power of two). -.IP "\s-1EV_USE_4HEAP\s0" 4 -.IX Item "EV_USE_4HEAP" -Heaps are not very cache-efficient. To improve the cache-efficiency of the -timer and periodics heaps, libev uses a 4\-heap when this symbol is defined -to \f(CW1\fR. The 4\-heap uses more complicated (longer) code but has noticeably -faster performance with many (thousands) of watchers. -.Sp -The default is \f(CW1\fR, unless \f(CW\*(C`EV_FEATURES\*(C'\fR overrides it, in which case it -will be \f(CW0\fR. -.IP "\s-1EV_HEAP_CACHE_AT\s0" 4 -.IX Item "EV_HEAP_CACHE_AT" -Heaps are not very cache-efficient. To improve the cache-efficiency of the -timer and periodics heaps, libev can cache the timestamp (\fIat\fR) within -the heap structure (selected by defining \f(CW\*(C`EV_HEAP_CACHE_AT\*(C'\fR to \f(CW1\fR), -which uses 8\-12 bytes more per watcher and a few hundred bytes more code, -but avoids random read accesses on heap changes. This improves performance -noticeably with many (hundreds) of watchers. -.Sp -The default is \f(CW1\fR, unless \f(CW\*(C`EV_FEATURES\*(C'\fR overrides it, in which case it -will be \f(CW0\fR. -.IP "\s-1EV_VERIFY\s0" 4 -.IX Item "EV_VERIFY" -Controls how much internal verification (see \f(CW\*(C`ev_verify ()\*(C'\fR) will -be done: If set to \f(CW0\fR, no internal verification code will be compiled -in. If set to \f(CW1\fR, then verification code will be compiled in, but not -called. If set to \f(CW2\fR, then the internal verification code will be -called once per loop, which can slow down libev. If set to \f(CW3\fR, then the -verification code will be called very frequently, which will slow down -libev considerably. -.Sp -Verification errors are reported via C's \f(CW\*(C`assert\*(C'\fR mechanism, so if you -disable that (e.g. by defining \f(CW\*(C`NDEBUG\*(C'\fR) then no errors will be reported. -.Sp -The default is \f(CW1\fR, unless \f(CW\*(C`EV_FEATURES\*(C'\fR overrides it, in which case it -will be \f(CW0\fR. -.IP "\s-1EV_COMMON\s0" 4 -.IX Item "EV_COMMON" -By default, all watchers have a \f(CW\*(C`void *data\*(C'\fR member. By redefining -this macro to something else you can include more and other types of -members. You have to define it each time you include one of the files, -though, and it must be identical each time. -.Sp -For example, the perl \s-1EV\s0 module uses something like this: -.Sp -.Vb 3 -\& #define EV_COMMON \e -\& SV *self; /* contains this struct */ \e -\& SV *cb_sv, *fh /* note no trailing ";" */ -.Ve -.IP "\s-1EV_CB_DECLARE\s0 (type)" 4 -.IX Item "EV_CB_DECLARE (type)" -.PD 0 -.IP "\s-1EV_CB_INVOKE\s0 (watcher, revents)" 4 -.IX Item "EV_CB_INVOKE (watcher, revents)" -.IP "ev_set_cb (ev, cb)" 4 -.IX Item "ev_set_cb (ev, cb)" -.PD -Can be used to change the callback member declaration in each watcher, -and the way callbacks are invoked and set. Must expand to a struct member -definition and a statement, respectively. See the \fIev.h\fR header file for -their default definitions. One possible use for overriding these is to -avoid the \f(CW\*(C`struct ev_loop *\*(C'\fR as first argument in all cases, or to use -method calls instead of plain function calls in \*(C+. -.SS "\s-1EXPORTED API SYMBOLS\s0" -.IX Subsection "EXPORTED API SYMBOLS" -If you need to re-export the \s-1API\s0 (e.g. via a \s-1DLL\s0) and you need a list of -exported symbols, you can use the provided \fISymbol.*\fR files which list -all public symbols, one per line: -.PP -.Vb 2 -\& Symbols.ev for libev proper -\& Symbols.event for the libevent emulation -.Ve -.PP -This can also be used to rename all public symbols to avoid clashes with -multiple versions of libev linked together (which is obviously bad in -itself, but sometimes it is inconvenient to avoid this). -.PP -A sed command like this will create wrapper \f(CW\*(C`#define\*(C'\fR's that you need to -include before including \fIev.h\fR: -.PP -.Vb 1 -\& wrap.h -.Ve -.PP -This would create a file \fIwrap.h\fR which essentially looks like this: -.PP -.Vb 4 -\& #define ev_backend myprefix_ev_backend -\& #define ev_check_start myprefix_ev_check_start -\& #define ev_check_stop myprefix_ev_check_stop -\& ... -.Ve -.SS "\s-1EXAMPLES\s0" -.IX Subsection "EXAMPLES" -For a real-world example of a program the includes libev -verbatim, you can have a look at the \s-1EV\s0 perl module -(). It has the libev files in -the \fIlibev/\fR subdirectory and includes them in the \fI\s-1EV/EVAPI\s0.h\fR (public -interface) and \fI\s-1EV\s0.xs\fR (implementation) files. Only the \fI\s-1EV\s0.xs\fR file -will be compiled. It is pretty complex because it provides its own header -file. -.PP -The usage in rxvt-unicode is simpler. It has a \fIev_cpp.h\fR header file -that everybody includes and which overrides some configure choices: -.PP -.Vb 8 -\& #define EV_FEATURES 8 -\& #define EV_USE_SELECT 1 -\& #define EV_PREPARE_ENABLE 1 -\& #define EV_IDLE_ENABLE 1 -\& #define EV_SIGNAL_ENABLE 1 -\& #define EV_CHILD_ENABLE 1 -\& #define EV_USE_STDEXCEPT 0 -\& #define EV_CONFIG_H -\& -\& #include "ev++.h" -.Ve -.PP -And a \fIev_cpp.C\fR implementation file that contains libev proper and is compiled: -.PP -.Vb 2 -\& #include "ev_cpp.h" -\& #include "ev.c" -.Ve -.SH "INTERACTION WITH OTHER PROGRAMS, LIBRARIES OR THE ENVIRONMENT" -.IX Header "INTERACTION WITH OTHER PROGRAMS, LIBRARIES OR THE ENVIRONMENT" -.SS "\s-1THREADS AND COROUTINES\s0" -.IX Subsection "THREADS AND COROUTINES" -\fI\s-1THREADS\s0\fR -.IX Subsection "THREADS" -.PP -All libev functions are reentrant and thread-safe unless explicitly -documented otherwise, but libev implements no locking itself. This means -that you can use as many loops as you want in parallel, as long as there -are no concurrent calls into any libev function with the same loop -parameter (\f(CW\*(C`ev_default_*\*(C'\fR calls have an implicit default loop parameter, -of course): libev guarantees that different event loops share no data -structures that need any locking. -.PP -Or to put it differently: calls with different loop parameters can be done -concurrently from multiple threads, calls with the same loop parameter -must be done serially (but can be done from different threads, as long as -only one thread ever is inside a call at any point in time, e.g. by using -a mutex per loop). -.PP -Specifically to support threads (and signal handlers), libev implements -so-called \f(CW\*(C`ev_async\*(C'\fR watchers, which allow some limited form of -concurrency on the same event loop, namely waking it up \*(L"from the -outside\*(R". -.PP -If you want to know which design (one loop, locking, or multiple loops -without or something else still) is best for your problem, then I cannot -help you, but here is some generic advice: -.IP "\(bu" 4 -most applications have a main thread: use the default libev loop -in that thread, or create a separate thread running only the default loop. -.Sp -This helps integrating other libraries or software modules that use libev -themselves and don't care/know about threading. -.IP "\(bu" 4 -one loop per thread is usually a good model. -.Sp -Doing this is almost never wrong, sometimes a better-performance model -exists, but it is always a good start. -.IP "\(bu" 4 -other models exist, such as the leader/follower pattern, where one -loop is handed through multiple threads in a kind of round-robin fashion. -.Sp -Choosing a model is hard \- look around, learn, know that usually you can do -better than you currently do :\-) -.IP "\(bu" 4 -often you need to talk to some other thread which blocks in the -event loop. -.Sp -\&\f(CW\*(C`ev_async\*(C'\fR watchers can be used to wake them up from other threads safely -(or from signal contexts...). -.Sp -An example use would be to communicate signals or other events that only -work in the default loop by registering the signal watcher with the -default loop and triggering an \f(CW\*(C`ev_async\*(C'\fR watcher from the default loop -watcher callback into the event loop interested in the signal. -.PP -See also \*(L"\s-1THREAD LOCKING EXAMPLE\*(R"\s0. -.PP -\fI\s-1COROUTINES\s0\fR -.IX Subsection "COROUTINES" -.PP -Libev is very accommodating to coroutines (\*(L"cooperative threads\*(R"): -libev fully supports nesting calls to its functions from different -coroutines (e.g. you can call \f(CW\*(C`ev_run\*(C'\fR on the same loop from two -different coroutines, and switch freely between both coroutines running -the loop, as long as you don't confuse yourself). The only exception is -that you must not do this from \f(CW\*(C`ev_periodic\*(C'\fR reschedule callbacks. -.PP -Care has been taken to ensure that libev does not keep local state inside -\&\f(CW\*(C`ev_run\*(C'\fR, and other calls do not usually allow for coroutine switches as -they do not call any callbacks. -.SS "\s-1COMPILER WARNINGS\s0" -.IX Subsection "COMPILER WARNINGS" -Depending on your compiler and compiler settings, you might get no or a -lot of warnings when compiling libev code. Some people are apparently -scared by this. -.PP -However, these are unavoidable for many reasons. For one, each compiler -has different warnings, and each user has different tastes regarding -warning options. \*(L"Warn-free\*(R" code therefore cannot be a goal except when -targeting a specific compiler and compiler-version. -.PP -Another reason is that some compiler warnings require elaborate -workarounds, or other changes to the code that make it less clear and less -maintainable. -.PP -And of course, some compiler warnings are just plain stupid, or simply -wrong (because they don't actually warn about the condition their message -seems to warn about). For example, certain older gcc versions had some -warnings that resulted in an extreme number of false positives. These have -been fixed, but some people still insist on making code warn-free with -such buggy versions. -.PP -While libev is written to generate as few warnings as possible, -\&\*(L"warn-free\*(R" code is not a goal, and it is recommended not to build libev -with any compiler warnings enabled unless you are prepared to cope with -them (e.g. by ignoring them). Remember that warnings are just that: -warnings, not errors, or proof of bugs. -.SS "\s-1VALGRIND\s0" -.IX Subsection "VALGRIND" -Valgrind has a special section here because it is a popular tool that is -highly useful. Unfortunately, valgrind reports are very hard to interpret. -.PP -If you think you found a bug (memory leak, uninitialised data access etc.) -in libev, then check twice: If valgrind reports something like: -.PP -.Vb 3 -\& ==2274== definitely lost: 0 bytes in 0 blocks. -\& ==2274== possibly lost: 0 bytes in 0 blocks. -\& ==2274== still reachable: 256 bytes in 1 blocks. -.Ve -.PP -Then there is no memory leak, just as memory accounted to global variables -is not a memleak \- the memory is still being referenced, and didn't leak. -.PP -Similarly, under some circumstances, valgrind might report kernel bugs -as if it were a bug in libev (e.g. in realloc or in the poll backend, -although an acceptable workaround has been found here), or it might be -confused. -.PP -Keep in mind that valgrind is a very good tool, but only a tool. Don't -make it into some kind of religion. -.PP -If you are unsure about something, feel free to contact the mailing list -with the full valgrind report and an explanation on why you think this -is a bug in libev (best check the archives, too :). However, don't be -annoyed when you get a brisk \*(L"this is no bug\*(R" answer and take the chance -of learning how to interpret valgrind properly. -.PP -If you need, for some reason, empty reports from valgrind for your project -I suggest using suppression lists. -.SH "PORTABILITY NOTES" -.IX Header "PORTABILITY NOTES" -.SS "\s-1GNU/LINUX 32 BIT LIMITATIONS\s0" -.IX Subsection "GNU/LINUX 32 BIT LIMITATIONS" -GNU/Linux is the only common platform that supports 64 bit file/large file -interfaces but \fIdisables\fR them by default. -.PP -That means that libev compiled in the default environment doesn't support -files larger than 2GiB or so, which mainly affects \f(CW\*(C`ev_stat\*(C'\fR watchers. -.PP -Unfortunately, many programs try to work around this GNU/Linux issue -by enabling the large file \s-1API,\s0 which makes them incompatible with the -standard libev compiled for their system. -.PP -Likewise, libev cannot enable the large file \s-1API\s0 itself as this would -suddenly make it incompatible to the default compile time environment, -i.e. all programs not using special compile switches. -.SS "\s-1OS/X AND DARWIN BUGS\s0" -.IX Subsection "OS/X AND DARWIN BUGS" -The whole thing is a bug if you ask me \- basically any system interface -you touch is broken, whether it is locales, poll, kqueue or even the -OpenGL drivers. -.PP -\fI\f(CI\*(C`kqueue\*(C'\fI is buggy\fR -.IX Subsection "kqueue is buggy" -.PP -The kqueue syscall is broken in all known versions \- most versions support -only sockets, many support pipes. -.PP -Libev tries to work around this by not using \f(CW\*(C`kqueue\*(C'\fR by default on this -rotten platform, but of course you can still ask for it when creating a -loop \- embedding a socket-only kqueue loop into a select-based one is -probably going to work well. -.PP -\fI\f(CI\*(C`poll\*(C'\fI is buggy\fR -.IX Subsection "poll is buggy" -.PP -Instead of fixing \f(CW\*(C`kqueue\*(C'\fR, Apple replaced their (working) \f(CW\*(C`poll\*(C'\fR -implementation by something calling \f(CW\*(C`kqueue\*(C'\fR internally around the 10.5.6 -release, so now \f(CW\*(C`kqueue\*(C'\fR \fIand\fR \f(CW\*(C`poll\*(C'\fR are broken. -.PP -Libev tries to work around this by not using \f(CW\*(C`poll\*(C'\fR by default on -this rotten platform, but of course you can still ask for it when creating -a loop. -.PP -\fI\f(CI\*(C`select\*(C'\fI is buggy\fR -.IX Subsection "select is buggy" -.PP -All that's left is \f(CW\*(C`select\*(C'\fR, and of course Apple found a way to fuck this -one up as well: On \s-1OS/X,\s0 \f(CW\*(C`select\*(C'\fR actively limits the number of file -descriptors you can pass in to 1024 \- your program suddenly crashes when -you use more. -.PP -There is an undocumented \*(L"workaround\*(R" for this \- defining -\&\f(CW\*(C`_DARWIN_UNLIMITED_SELECT\*(C'\fR, which libev tries to use, so select \fIshould\fR -work on \s-1OS/X.\s0 -.SS "\s-1SOLARIS PROBLEMS AND WORKAROUNDS\s0" -.IX Subsection "SOLARIS PROBLEMS AND WORKAROUNDS" -\fI\f(CI\*(C`errno\*(C'\fI reentrancy\fR -.IX Subsection "errno reentrancy" -.PP -The default compile environment on Solaris is unfortunately so -thread-unsafe that you can't even use components/libraries compiled -without \f(CW\*(C`\-D_REENTRANT\*(C'\fR in a threaded program, which, of course, isn't -defined by default. A valid, if stupid, implementation choice. -.PP -If you want to use libev in threaded environments you have to make sure -it's compiled with \f(CW\*(C`_REENTRANT\*(C'\fR defined. -.PP -\fIEvent port backend\fR -.IX Subsection "Event port backend" -.PP -The scalable event interface for Solaris is called \*(L"event -ports\*(R". Unfortunately, this mechanism is very buggy in all major -releases. If you run into high \s-1CPU\s0 usage, your program freezes or you get -a large number of spurious wakeups, make sure you have all the relevant -and latest kernel patches applied. No, I don't know which ones, but there -are multiple ones to apply, and afterwards, event ports actually work -great. -.PP -If you can't get it to work, you can try running the program by setting -the environment variable \f(CW\*(C`LIBEV_FLAGS=3\*(C'\fR to only allow \f(CW\*(C`poll\*(C'\fR and -\&\f(CW\*(C`select\*(C'\fR backends. -.SS "\s-1AIX POLL BUG\s0" -.IX Subsection "AIX POLL BUG" -\&\s-1AIX\s0 unfortunately has a broken \f(CW\*(C`poll.h\*(C'\fR header. Libev works around -this by trying to avoid the poll backend altogether (i.e. it's not even -compiled in), which normally isn't a big problem as \f(CW\*(C`select\*(C'\fR works fine -with large bitsets on \s-1AIX,\s0 and \s-1AIX\s0 is dead anyway. -.SS "\s-1WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS\s0" -.IX Subsection "WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS" -\fIGeneral issues\fR -.IX Subsection "General issues" -.PP -Win32 doesn't support any of the standards (e.g. \s-1POSIX\s0) that libev -requires, and its I/O model is fundamentally incompatible with the \s-1POSIX\s0 -model. Libev still offers limited functionality on this platform in -the form of the \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR backend, and only supports socket -descriptors. This only applies when using Win32 natively, not when using -e.g. cygwin. Actually, it only applies to the microsofts own compilers, -as every compiler comes with a slightly differently broken/incompatible -environment. -.PP -Lifting these limitations would basically require the full -re-implementation of the I/O system. If you are into this kind of thing, -then note that glib does exactly that for you in a very portable way (note -also that glib is the slowest event library known to man). -.PP -There is no supported compilation method available on windows except -embedding it into other applications. -.PP -Sensible signal handling is officially unsupported by Microsoft \- libev -tries its best, but under most conditions, signals will simply not work. -.PP -Not a libev limitation but worth mentioning: windows apparently doesn't -accept large writes: instead of resulting in a partial write, windows will -either accept everything or return \f(CW\*(C`ENOBUFS\*(C'\fR if the buffer is too large, -so make sure you only write small amounts into your sockets (less than a -megabyte seems safe, but this apparently depends on the amount of memory -available). -.PP -Due to the many, low, and arbitrary limits on the win32 platform and -the abysmal performance of winsockets, using a large number of sockets -is not recommended (and not reasonable). If your program needs to use -more than a hundred or so sockets, then likely it needs to use a totally -different implementation for windows, as libev offers the \s-1POSIX\s0 readiness -notification model, which cannot be implemented efficiently on windows -(due to Microsoft monopoly games). -.PP -A typical way to use libev under windows is to embed it (see the embedding -section for details) and use the following \fIevwrap.h\fR header file instead -of \fIev.h\fR: -.PP -.Vb 2 -\& #define EV_STANDALONE /* keeps ev from requiring config.h */ -\& #define EV_SELECT_IS_WINSOCKET 1 /* configure libev for windows select */ -\& -\& #include "ev.h" -.Ve -.PP -And compile the following \fIevwrap.c\fR file into your project (make sure -you do \fInot\fR compile the \fIev.c\fR or any other embedded source files!): -.PP -.Vb 2 -\& #include "evwrap.h" -\& #include "ev.c" -.Ve -.PP -\fIThe winsocket \f(CI\*(C`select\*(C'\fI function\fR -.IX Subsection "The winsocket select function" -.PP -The winsocket \f(CW\*(C`select\*(C'\fR function doesn't follow \s-1POSIX\s0 in that it -requires socket \fIhandles\fR and not socket \fIfile descriptors\fR (it is -also extremely buggy). This makes select very inefficient, and also -requires a mapping from file descriptors to socket handles (the Microsoft -C runtime provides the function \f(CW\*(C`_open_osfhandle\*(C'\fR for this). See the -discussion of the \f(CW\*(C`EV_SELECT_USE_FD_SET\*(C'\fR, \f(CW\*(C`EV_SELECT_IS_WINSOCKET\*(C'\fR and -\&\f(CW\*(C`EV_FD_TO_WIN32_HANDLE\*(C'\fR preprocessor symbols for more info. -.PP -The configuration for a \*(L"naked\*(R" win32 using the Microsoft runtime -libraries and raw winsocket select is: -.PP -.Vb 2 -\& #define EV_USE_SELECT 1 -\& #define EV_SELECT_IS_WINSOCKET 1 /* forces EV_SELECT_USE_FD_SET, too */ -.Ve -.PP -Note that winsockets handling of fd sets is O(n), so you can easily get a -complexity in the O(nX) range when using win32. -.PP -\fILimited number of file descriptors\fR -.IX Subsection "Limited number of file descriptors" -.PP -Windows has numerous arbitrary (and low) limits on things. -.PP -Early versions of winsocket's select only supported waiting for a maximum -of \f(CW64\fR handles (probably owning to the fact that all windows kernels -can only wait for \f(CW64\fR things at the same time internally; Microsoft -recommends spawning a chain of threads and wait for 63 handles and the -previous thread in each. Sounds great!). -.PP -Newer versions support more handles, but you need to define \f(CW\*(C`FD_SETSIZE\*(C'\fR -to some high number (e.g. \f(CW2048\fR) before compiling the winsocket select -call (which might be in libev or elsewhere, for example, perl and many -other interpreters do their own select emulation on windows). -.PP -Another limit is the number of file descriptors in the Microsoft runtime -libraries, which by default is \f(CW64\fR (there must be a hidden \fI64\fR -fetish or something like this inside Microsoft). You can increase this -by calling \f(CW\*(C`_setmaxstdio\*(C'\fR, which can increase this limit to \f(CW2048\fR -(another arbitrary limit), but is broken in many versions of the Microsoft -runtime libraries. This might get you to about \f(CW512\fR or \f(CW2048\fR sockets -(depending on windows version and/or the phase of the moon). To get more, -you need to wrap all I/O functions and provide your own fd management, but -the cost of calling select (O(nX)) will likely make this unworkable. -.SS "\s-1PORTABILITY REQUIREMENTS\s0" -.IX Subsection "PORTABILITY REQUIREMENTS" -In addition to a working ISO-C implementation and of course the -backend-specific APIs, libev relies on a few additional extensions: -.ie n .IP """void (*)(ev_watcher_type *, int revents)"" must have compatible calling conventions regardless of ""ev_watcher_type *""." 4 -.el .IP "\f(CWvoid (*)(ev_watcher_type *, int revents)\fR must have compatible calling conventions regardless of \f(CWev_watcher_type *\fR." 4 -.IX Item "void (*)(ev_watcher_type *, int revents) must have compatible calling conventions regardless of ev_watcher_type *." -Libev assumes not only that all watcher pointers have the same internal -structure (guaranteed by \s-1POSIX\s0 but not by \s-1ISO C\s0 for example), but it also -assumes that the same (machine) code can be used to call any watcher -callback: The watcher callbacks have different type signatures, but libev -calls them using an \f(CW\*(C`ev_watcher *\*(C'\fR internally. -.IP "null pointers and integer zero are represented by 0 bytes" 4 -.IX Item "null pointers and integer zero are represented by 0 bytes" -Libev uses \f(CW\*(C`memset\*(C'\fR to initialise structs and arrays to \f(CW0\fR bytes, and -relies on this setting pointers and integers to null. -.IP "pointer accesses must be thread-atomic" 4 -.IX Item "pointer accesses must be thread-atomic" -Accessing a pointer value must be atomic, it must both be readable and -writable in one piece \- this is the case on all current architectures. -.ie n .IP """sig_atomic_t volatile"" must be thread-atomic as well" 4 -.el .IP "\f(CWsig_atomic_t volatile\fR must be thread-atomic as well" 4 -.IX Item "sig_atomic_t volatile must be thread-atomic as well" -The type \f(CW\*(C`sig_atomic_t volatile\*(C'\fR (or whatever is defined as -\&\f(CW\*(C`EV_ATOMIC_T\*(C'\fR) must be atomic with respect to accesses from different -threads. This is not part of the specification for \f(CW\*(C`sig_atomic_t\*(C'\fR, but is -believed to be sufficiently portable. -.ie n .IP """sigprocmask"" must work in a threaded environment" 4 -.el .IP "\f(CWsigprocmask\fR must work in a threaded environment" 4 -.IX Item "sigprocmask must work in a threaded environment" -Libev uses \f(CW\*(C`sigprocmask\*(C'\fR to temporarily block signals. This is not -allowed in a threaded program (\f(CW\*(C`pthread_sigmask\*(C'\fR has to be used). Typical -pthread implementations will either allow \f(CW\*(C`sigprocmask\*(C'\fR in the \*(L"main -thread\*(R" or will block signals process-wide, both behaviours would -be compatible with libev. Interaction between \f(CW\*(C`sigprocmask\*(C'\fR and -\&\f(CW\*(C`pthread_sigmask\*(C'\fR could complicate things, however. -.Sp -The most portable way to handle signals is to block signals in all threads -except the initial one, and run the signal handling loop in the initial -thread as well. -.ie n .IP """long"" must be large enough for common memory allocation sizes" 4 -.el .IP "\f(CWlong\fR must be large enough for common memory allocation sizes" 4 -.IX Item "long must be large enough for common memory allocation sizes" -To improve portability and simplify its \s-1API,\s0 libev uses \f(CW\*(C`long\*(C'\fR internally -instead of \f(CW\*(C`size_t\*(C'\fR when allocating its data structures. On non-POSIX -systems (Microsoft...) this might be unexpectedly low, but is still at -least 31 bits everywhere, which is enough for hundreds of millions of -watchers. -.ie n .IP """double"" must hold a time value in seconds with enough accuracy" 4 -.el .IP "\f(CWdouble\fR must hold a time value in seconds with enough accuracy" 4 -.IX Item "double must hold a time value in seconds with enough accuracy" -The type \f(CW\*(C`double\*(C'\fR is used to represent timestamps. It is required to -have at least 51 bits of mantissa (and 9 bits of exponent), which is -good enough for at least into the year 4000 with millisecond accuracy -(the design goal for libev). This requirement is overfulfilled by -implementations using \s-1IEEE 754,\s0 which is basically all existing ones. -.Sp -With \s-1IEEE 754\s0 doubles, you get microsecond accuracy until at least the -year 2255 (and millisecond accuracy till the year 287396 \- by then, libev -is either obsolete or somebody patched it to use \f(CW\*(C`long double\*(C'\fR or -something like that, just kidding). -.PP -If you know of other additional requirements drop me a note. -.SH "ALGORITHMIC COMPLEXITIES" -.IX Header "ALGORITHMIC COMPLEXITIES" -In this section the complexities of (many of) the algorithms used inside -libev will be documented. For complexity discussions about backends see -the documentation for \f(CW\*(C`ev_default_init\*(C'\fR. -.PP -All of the following are about amortised time: If an array needs to be -extended, libev needs to realloc and move the whole array, but this -happens asymptotically rarer with higher number of elements, so O(1) might -mean that libev does a lengthy realloc operation in rare cases, but on -average it is much faster and asymptotically approaches constant time. -.IP "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" 4 -.IX Item "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" -This means that, when you have a watcher that triggers in one hour and -there are 100 watchers that would trigger before that, then inserting will -have to skip roughly seven (\f(CW\*(C`ld 100\*(C'\fR) of these watchers. -.IP "Changing timer/periodic watchers (by autorepeat or calling again): O(log skipped_other_timers)" 4 -.IX Item "Changing timer/periodic watchers (by autorepeat or calling again): O(log skipped_other_timers)" -That means that changing a timer costs less than removing/adding them, -as only the relative motion in the event queue has to be paid for. -.IP "Starting io/check/prepare/idle/signal/child/fork/async watchers: O(1)" 4 -.IX Item "Starting io/check/prepare/idle/signal/child/fork/async watchers: O(1)" -These just add the watcher into an array or at the head of a list. -.IP "Stopping check/prepare/idle/fork/async watchers: O(1)" 4 -.IX Item "Stopping check/prepare/idle/fork/async watchers: O(1)" -.PD 0 -.IP "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % \s-1EV_PID_HASHSIZE\s0))" 4 -.IX Item "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % EV_PID_HASHSIZE))" -.PD -These watchers are stored in lists, so they need to be walked to find the -correct watcher to remove. The lists are usually short (you don't usually -have many watchers waiting for the same fd or signal: one is typical, two -is rare). -.IP "Finding the next timer in each loop iteration: O(1)" 4 -.IX Item "Finding the next timer in each loop iteration: O(1)" -By virtue of using a binary or 4\-heap, the next timer is always found at a -fixed position in the storage array. -.IP "Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)" 4 -.IX Item "Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)" -A change means an I/O watcher gets started or stopped, which requires -libev to recalculate its status (and possibly tell the kernel, depending -on backend and whether \f(CW\*(C`ev_io_set\*(C'\fR was used). -.IP "Activating one watcher (putting it into the pending state): O(1)" 4 -.IX Item "Activating one watcher (putting it into the pending state): O(1)" -.PD 0 -.IP "Priority handling: O(number_of_priorities)" 4 -.IX Item "Priority handling: O(number_of_priorities)" -.PD -Priorities are implemented by allocating some space for each -priority. When doing priority-based operations, libev usually has to -linearly search all the priorities, but starting/stopping and activating -watchers becomes O(1) with respect to priority handling. -.IP "Sending an ev_async: O(1)" 4 -.IX Item "Sending an ev_async: O(1)" -.PD 0 -.IP "Processing ev_async_send: O(number_of_async_watchers)" 4 -.IX Item "Processing ev_async_send: O(number_of_async_watchers)" -.IP "Processing signals: O(max_signal_number)" 4 -.IX Item "Processing signals: O(max_signal_number)" -.PD -Sending involves a system call \fIiff\fR there were no other \f(CW\*(C`ev_async_send\*(C'\fR -calls in the current loop iteration and the loop is currently -blocked. Checking for async and signal events involves iterating over all -running async watchers or all signal numbers. -.SH "PORTING FROM LIBEV 3.X TO 4.X" -.IX Header "PORTING FROM LIBEV 3.X TO 4.X" -The major version 4 introduced some incompatible changes to the \s-1API.\s0 -.PP -At the moment, the \f(CW\*(C`ev.h\*(C'\fR header file provides compatibility definitions -for all changes, so most programs should still compile. The compatibility -layer might be removed in later versions of libev, so better update to the -new \s-1API\s0 early than late. -.ie n .IP """EV_COMPAT3"" backwards compatibility mechanism" 4 -.el .IP "\f(CWEV_COMPAT3\fR backwards compatibility mechanism" 4 -.IX Item "EV_COMPAT3 backwards compatibility mechanism" -The backward compatibility mechanism can be controlled by -\&\f(CW\*(C`EV_COMPAT3\*(C'\fR. See \*(L"\s-1PREPROCESSOR SYMBOLS/MACROS\*(R"\s0 in the \*(L"\s-1EMBEDDING\*(R"\s0 -section. -.ie n .IP """ev_default_destroy"" and ""ev_default_fork"" have been removed" 4 -.el .IP "\f(CWev_default_destroy\fR and \f(CWev_default_fork\fR have been removed" 4 -.IX Item "ev_default_destroy and ev_default_fork have been removed" -These calls can be replaced easily by their \f(CW\*(C`ev_loop_xxx\*(C'\fR counterparts: -.Sp -.Vb 2 -\& ev_loop_destroy (EV_DEFAULT_UC); -\& ev_loop_fork (EV_DEFAULT); -.Ve -.IP "function/symbol renames" 4 -.IX Item "function/symbol renames" -A number of functions and symbols have been renamed: -.Sp -.Vb 3 -\& ev_loop => ev_run -\& EVLOOP_NONBLOCK => EVRUN_NOWAIT -\& EVLOOP_ONESHOT => EVRUN_ONCE -\& -\& ev_unloop => ev_break -\& EVUNLOOP_CANCEL => EVBREAK_CANCEL -\& EVUNLOOP_ONE => EVBREAK_ONE -\& EVUNLOOP_ALL => EVBREAK_ALL -\& -\& EV_TIMEOUT => EV_TIMER -\& -\& ev_loop_count => ev_iteration -\& ev_loop_depth => ev_depth -\& ev_loop_verify => ev_verify -.Ve -.Sp -Most functions working on \f(CW\*(C`struct ev_loop\*(C'\fR objects don't have an -\&\f(CW\*(C`ev_loop_\*(C'\fR prefix, so it was removed; \f(CW\*(C`ev_loop\*(C'\fR, \f(CW\*(C`ev_unloop\*(C'\fR and -associated constants have been renamed to not collide with the \f(CW\*(C`struct -ev_loop\*(C'\fR anymore and \f(CW\*(C`EV_TIMER\*(C'\fR now follows the same naming scheme -as all other watcher types. Note that \f(CW\*(C`ev_loop_fork\*(C'\fR is still called -\&\f(CW\*(C`ev_loop_fork\*(C'\fR because it would otherwise clash with the \f(CW\*(C`ev_fork\*(C'\fR -typedef. -.ie n .IP """EV_MINIMAL"" mechanism replaced by ""EV_FEATURES""" 4 -.el .IP "\f(CWEV_MINIMAL\fR mechanism replaced by \f(CWEV_FEATURES\fR" 4 -.IX Item "EV_MINIMAL mechanism replaced by EV_FEATURES" -The preprocessor symbol \f(CW\*(C`EV_MINIMAL\*(C'\fR has been replaced by a different -mechanism, \f(CW\*(C`EV_FEATURES\*(C'\fR. Programs using \f(CW\*(C`EV_MINIMAL\*(C'\fR usually compile -and work, but the library code will of course be larger. -.SH "GLOSSARY" -.IX Header "GLOSSARY" -.IP "active" 4 -.IX Item "active" -A watcher is active as long as it has been started and not yet stopped. -See \*(L"\s-1WATCHER STATES\*(R"\s0 for details. -.IP "application" 4 -.IX Item "application" -In this document, an application is whatever is using libev. -.IP "backend" 4 -.IX Item "backend" -The part of the code dealing with the operating system interfaces. -.IP "callback" 4 -.IX Item "callback" -The address of a function that is called when some event has been -detected. Callbacks are being passed the event loop, the watcher that -received the event, and the actual event bitset. -.IP "callback/watcher invocation" 4 -.IX Item "callback/watcher invocation" -The act of calling the callback associated with a watcher. -.IP "event" 4 -.IX Item "event" -A change of state of some external event, such as data now being available -for reading on a file descriptor, time having passed or simply not having -any other events happening anymore. -.Sp -In libev, events are represented as single bits (such as \f(CW\*(C`EV_READ\*(C'\fR or -\&\f(CW\*(C`EV_TIMER\*(C'\fR). -.IP "event library" 4 -.IX Item "event library" -A software package implementing an event model and loop. -.IP "event loop" 4 -.IX Item "event loop" -An entity that handles and processes external events and converts them -into callback invocations. -.IP "event model" 4 -.IX Item "event model" -The model used to describe how an event loop handles and processes -watchers and events. -.IP "pending" 4 -.IX Item "pending" -A watcher is pending as soon as the corresponding event has been -detected. See \*(L"\s-1WATCHER STATES\*(R"\s0 for details. -.IP "real time" 4 -.IX Item "real time" -The physical time that is observed. It is apparently strictly monotonic :) -.IP "wall-clock time" 4 -.IX Item "wall-clock time" -The time and date as shown on clocks. Unlike real time, it can actually -be wrong and jump forwards and backwards, e.g. when you adjust your -clock. -.IP "watcher" 4 -.IX Item "watcher" -A data structure that describes interest in certain events. Watchers need -to be started (attached to an event loop) before they can receive events. -.SH "AUTHOR" -.IX Header "AUTHOR" -Marc Lehmann , with repeated corrections by Mikael -Magnusson and Emanuele Giaquinta, and minor corrections by many others. diff --git a/submodules/lev/lev/vendor/ev.c b/submodules/lev/lev/vendor/ev.c deleted file mode 100644 index f2067ed3b..000000000 --- a/submodules/lev/lev/vendor/ev.c +++ /dev/null @@ -1,5631 +0,0 @@ -/* - * libev event processing core, watcher management - * - * Copyright (c) 2007-2020 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -/* this big block deduces configuration from config.h */ -#ifndef EV_STANDALONE -# ifdef EV_CONFIG_H -# include EV_CONFIG_H -# else -# include "config.h" -# endif - -# if HAVE_FLOOR -# ifndef EV_USE_FLOOR -# define EV_USE_FLOOR 1 -# endif -# endif - -# if HAVE_CLOCK_SYSCALL -# ifndef EV_USE_CLOCK_SYSCALL -# define EV_USE_CLOCK_SYSCALL 1 -# ifndef EV_USE_REALTIME -# define EV_USE_REALTIME 0 -# endif -# ifndef EV_USE_MONOTONIC -# define EV_USE_MONOTONIC 1 -# endif -# endif -# elif !defined EV_USE_CLOCK_SYSCALL -# define EV_USE_CLOCK_SYSCALL 0 -# endif - -# if HAVE_CLOCK_GETTIME -# ifndef EV_USE_MONOTONIC -# define EV_USE_MONOTONIC 1 -# endif -# ifndef EV_USE_REALTIME -# define EV_USE_REALTIME 0 -# endif -# else -# ifndef EV_USE_MONOTONIC -# define EV_USE_MONOTONIC 0 -# endif -# ifndef EV_USE_REALTIME -# define EV_USE_REALTIME 0 -# endif -# endif - -# if HAVE_NANOSLEEP -# ifndef EV_USE_NANOSLEEP -# define EV_USE_NANOSLEEP EV_FEATURE_OS -# endif -# else -# undef EV_USE_NANOSLEEP -# define EV_USE_NANOSLEEP 0 -# endif - -# if HAVE_SELECT && HAVE_SYS_SELECT_H -# ifndef EV_USE_SELECT -# define EV_USE_SELECT EV_FEATURE_BACKENDS -# endif -# else -# undef EV_USE_SELECT -# define EV_USE_SELECT 0 -# endif - -# if HAVE_POLL && HAVE_POLL_H -# ifndef EV_USE_POLL -# define EV_USE_POLL EV_FEATURE_BACKENDS -# endif -# else -# undef EV_USE_POLL -# define EV_USE_POLL 0 -# endif - -# if HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H -# ifndef EV_USE_EPOLL -# define EV_USE_EPOLL EV_FEATURE_BACKENDS -# endif -# else -# undef EV_USE_EPOLL -# define EV_USE_EPOLL 0 -# endif - -# if HAVE_LINUX_AIO_ABI_H -# ifndef EV_USE_LINUXAIO -# define EV_USE_LINUXAIO 0 /* was: EV_FEATURE_BACKENDS, always off by default */ -# endif -# else -# undef EV_USE_LINUXAIO -# define EV_USE_LINUXAIO 0 -# endif - -# if HAVE_LINUX_FS_H && HAVE_SYS_TIMERFD_H && HAVE_KERNEL_RWF_T -# ifndef EV_USE_IOURING -# define EV_USE_IOURING EV_FEATURE_BACKENDS -# endif -# else -# undef EV_USE_IOURING -# define EV_USE_IOURING 0 -# endif - -# if HAVE_KQUEUE && HAVE_SYS_EVENT_H -# ifndef EV_USE_KQUEUE -# define EV_USE_KQUEUE EV_FEATURE_BACKENDS -# endif -# else -# undef EV_USE_KQUEUE -# define EV_USE_KQUEUE 0 -# endif - -# if HAVE_PORT_H && HAVE_PORT_CREATE -# ifndef EV_USE_PORT -# define EV_USE_PORT EV_FEATURE_BACKENDS -# endif -# else -# undef EV_USE_PORT -# define EV_USE_PORT 0 -# endif - -# if HAVE_INOTIFY_INIT && HAVE_SYS_INOTIFY_H -# ifndef EV_USE_INOTIFY -# define EV_USE_INOTIFY EV_FEATURE_OS -# endif -# else -# undef EV_USE_INOTIFY -# define EV_USE_INOTIFY 0 -# endif - -# if HAVE_SIGNALFD && HAVE_SYS_SIGNALFD_H -# ifndef EV_USE_SIGNALFD -# define EV_USE_SIGNALFD EV_FEATURE_OS -# endif -# else -# undef EV_USE_SIGNALFD -# define EV_USE_SIGNALFD 0 -# endif - -# if HAVE_EVENTFD -# ifndef EV_USE_EVENTFD -# define EV_USE_EVENTFD EV_FEATURE_OS -# endif -# else -# undef EV_USE_EVENTFD -# define EV_USE_EVENTFD 0 -# endif - -# if HAVE_SYS_TIMERFD_H -# ifndef EV_USE_TIMERFD -# define EV_USE_TIMERFD EV_FEATURE_OS -# endif -# else -# undef EV_USE_TIMERFD -# define EV_USE_TIMERFD 0 -# endif - -#endif - -/* OS X, in its infinite idiocy, actually HARDCODES - * a limit of 1024 into their select. Where people have brains, - * OS X engineers apparently have a vacuum. Or maybe they were - * ordered to have a vacuum, or they do anything for money. - * This might help. Or not. - * Note that this must be defined early, as other include files - * will rely on this define as well. - */ -#define _DARWIN_UNLIMITED_SELECT 1 - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#ifdef EV_H -# include EV_H -#else -# include "ev.h" -#endif - -#if EV_NO_THREADS -# undef EV_NO_SMP -# define EV_NO_SMP 1 -# undef ECB_NO_THREADS -# define ECB_NO_THREADS 1 -#endif -#if EV_NO_SMP -# undef EV_NO_SMP -# define ECB_NO_SMP 1 -#endif - -#ifndef _WIN32 -# include -# include -# include -#else -# include -# define WIN32_LEAN_AND_MEAN -# include -# include -# ifndef EV_SELECT_IS_WINSOCKET -# define EV_SELECT_IS_WINSOCKET 1 -# endif -# undef EV_AVOID_STDIO -#endif - -/* this block tries to deduce configuration from header-defined symbols and defaults */ - -/* try to deduce the maximum number of signals on this platform */ -#if defined EV_NSIG -/* use what's provided */ -#elif defined NSIG -# define EV_NSIG (NSIG) -#elif defined _NSIG -# define EV_NSIG (_NSIG) -#elif defined SIGMAX -# define EV_NSIG (SIGMAX+1) -#elif defined SIG_MAX -# define EV_NSIG (SIG_MAX+1) -#elif defined _SIG_MAX -# define EV_NSIG (_SIG_MAX+1) -#elif defined MAXSIG -# define EV_NSIG (MAXSIG+1) -#elif defined MAX_SIG -# define EV_NSIG (MAX_SIG+1) -#elif defined SIGARRAYSIZE -# define EV_NSIG (SIGARRAYSIZE) /* Assume ary[SIGARRAYSIZE] */ -#elif defined _sys_nsig -# define EV_NSIG (_sys_nsig) /* Solaris 2.5 */ -#else -# define EV_NSIG (8 * sizeof (sigset_t) + 1) -#endif - -#ifndef EV_USE_FLOOR -# define EV_USE_FLOOR 0 -#endif - -#ifndef EV_USE_CLOCK_SYSCALL -# if __linux && __GLIBC__ == 2 && __GLIBC_MINOR__ < 17 -# define EV_USE_CLOCK_SYSCALL EV_FEATURE_OS -# else -# define EV_USE_CLOCK_SYSCALL 0 -# endif -#endif - -#if !(_POSIX_TIMERS > 0) -# ifndef EV_USE_MONOTONIC -# define EV_USE_MONOTONIC 0 -# endif -# ifndef EV_USE_REALTIME -# define EV_USE_REALTIME 0 -# endif -#endif - -#ifndef EV_USE_MONOTONIC -# if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0 -# define EV_USE_MONOTONIC EV_FEATURE_OS -# else -# define EV_USE_MONOTONIC 0 -# endif -#endif - -#ifndef EV_USE_REALTIME -# define EV_USE_REALTIME !EV_USE_CLOCK_SYSCALL -#endif - -#ifndef EV_USE_NANOSLEEP -# if _POSIX_C_SOURCE >= 199309L -# define EV_USE_NANOSLEEP EV_FEATURE_OS -# else -# define EV_USE_NANOSLEEP 0 -# endif -#endif - -#ifndef EV_USE_SELECT -# define EV_USE_SELECT EV_FEATURE_BACKENDS -#endif - -#ifndef EV_USE_POLL -# ifdef _WIN32 -# define EV_USE_POLL 0 -# else -# define EV_USE_POLL EV_FEATURE_BACKENDS -# endif -#endif - -#ifndef EV_USE_EPOLL -# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) -# define EV_USE_EPOLL EV_FEATURE_BACKENDS -# else -# define EV_USE_EPOLL 0 -# endif -#endif - -#ifndef EV_USE_KQUEUE -# define EV_USE_KQUEUE 0 -#endif - -#ifndef EV_USE_PORT -# define EV_USE_PORT 0 -#endif - -#ifndef EV_USE_LINUXAIO -# if __linux /* libev currently assumes linux/aio_abi.h is always available on linux */ -# define EV_USE_LINUXAIO 0 /* was: 1, always off by default */ -# else -# define EV_USE_LINUXAIO 0 -# endif -#endif - -#ifndef EV_USE_IOURING -# if __linux /* later checks might disable again */ -# define EV_USE_IOURING 1 -# else -# define EV_USE_IOURING 0 -# endif -#endif - -#ifndef EV_USE_INOTIFY -# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) -# define EV_USE_INOTIFY EV_FEATURE_OS -# else -# define EV_USE_INOTIFY 0 -# endif -#endif - -#ifndef EV_PID_HASHSIZE -# define EV_PID_HASHSIZE EV_FEATURE_DATA ? 16 : 1 -#endif - -#ifndef EV_INOTIFY_HASHSIZE -# define EV_INOTIFY_HASHSIZE EV_FEATURE_DATA ? 16 : 1 -#endif - -#ifndef EV_USE_EVENTFD -# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) -# define EV_USE_EVENTFD EV_FEATURE_OS -# else -# define EV_USE_EVENTFD 0 -# endif -#endif - -#ifndef EV_USE_SIGNALFD -# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) -# define EV_USE_SIGNALFD EV_FEATURE_OS -# else -# define EV_USE_SIGNALFD 0 -# endif -#endif - -#ifndef EV_USE_TIMERFD -# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)) -# define EV_USE_TIMERFD EV_FEATURE_OS -# else -# define EV_USE_TIMERFD 0 -# endif -#endif - -#if 0 /* debugging */ -# define EV_VERIFY 3 -# define EV_USE_4HEAP 1 -# define EV_HEAP_CACHE_AT 1 -#endif - -#ifndef EV_VERIFY -# define EV_VERIFY (EV_FEATURE_API ? 1 : 0) -#endif - -#ifndef EV_USE_4HEAP -# define EV_USE_4HEAP EV_FEATURE_DATA -#endif - -#ifndef EV_HEAP_CACHE_AT -# define EV_HEAP_CACHE_AT EV_FEATURE_DATA -#endif - -#ifdef __ANDROID__ -/* supposedly, android doesn't typedef fd_mask */ -# undef EV_USE_SELECT -# define EV_USE_SELECT 0 -/* supposedly, we need to include syscall.h, not sys/syscall.h, so just disable */ -# undef EV_USE_CLOCK_SYSCALL -# define EV_USE_CLOCK_SYSCALL 0 -#endif - -/* aix's poll.h seems to cause lots of trouble */ -#ifdef _AIX -/* AIX has a completely broken poll.h header */ -# undef EV_USE_POLL -# define EV_USE_POLL 0 -#endif - -/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ -/* which makes programs even slower. might work on other unices, too. */ -#if EV_USE_CLOCK_SYSCALL -# include -# ifdef SYS_clock_gettime -# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts)) -# undef EV_USE_MONOTONIC -# define EV_USE_MONOTONIC 1 -# define EV_NEED_SYSCALL 1 -# else -# undef EV_USE_CLOCK_SYSCALL -# define EV_USE_CLOCK_SYSCALL 0 -# endif -#endif - -/* this block fixes any misconfiguration where we know we run into trouble otherwise */ - -#ifndef CLOCK_MONOTONIC -# undef EV_USE_MONOTONIC -# define EV_USE_MONOTONIC 0 -#endif - -#ifndef CLOCK_REALTIME -# undef EV_USE_REALTIME -# define EV_USE_REALTIME 0 -#endif - -#if !EV_STAT_ENABLE -# undef EV_USE_INOTIFY -# define EV_USE_INOTIFY 0 -#endif - -#if __linux && EV_USE_IOURING -# include -# if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0) -# undef EV_USE_IOURING -# define EV_USE_IOURING 0 -# endif -#endif - -#if !EV_USE_NANOSLEEP -/* hp-ux has it in sys/time.h, which we unconditionally include above */ -# if !defined _WIN32 && !defined __hpux -# include -# endif -#endif - -#if EV_USE_LINUXAIO -# include -# if SYS_io_getevents && EV_USE_EPOLL /* linuxaio backend requires epoll backend */ -# define EV_NEED_SYSCALL 1 -# else -# undef EV_USE_LINUXAIO -# define EV_USE_LINUXAIO 0 -# endif -#endif - -#if EV_USE_IOURING -# include -# if !SYS_io_uring_register && __linux && !__alpha -# define SYS_io_uring_setup 425 -# define SYS_io_uring_enter 426 -# define SYS_io_uring_register 427 -# endif -# if SYS_io_uring_setup && EV_USE_EPOLL /* iouring backend requires epoll backend */ -# define EV_NEED_SYSCALL 1 -# else -# undef EV_USE_IOURING -# define EV_USE_IOURING 0 -# endif -#endif - -#if EV_USE_INOTIFY -# include -# include -/* some very old inotify.h headers don't have IN_DONT_FOLLOW */ -# ifndef IN_DONT_FOLLOW -# undef EV_USE_INOTIFY -# define EV_USE_INOTIFY 0 -# endif -#endif - -#if EV_USE_EVENTFD -/* our minimum requirement is glibc 2.7 which has the stub, but not the full header */ -# include -# ifndef EFD_NONBLOCK -# define EFD_NONBLOCK O_NONBLOCK -# endif -# ifndef EFD_CLOEXEC -# ifdef O_CLOEXEC -# define EFD_CLOEXEC O_CLOEXEC -# else -# define EFD_CLOEXEC 02000000 -# endif -# endif -EV_CPP(extern "C") int (eventfd) (unsigned int initval, int flags); -#endif - -#if EV_USE_SIGNALFD -/* our minimum requirement is glibc 2.7 which has the stub, but not the full header */ -# include -# ifndef SFD_NONBLOCK -# define SFD_NONBLOCK O_NONBLOCK -# endif -# ifndef SFD_CLOEXEC -# ifdef O_CLOEXEC -# define SFD_CLOEXEC O_CLOEXEC -# else -# define SFD_CLOEXEC 02000000 -# endif -# endif -EV_CPP (extern "C") int (signalfd) (int fd, const sigset_t *mask, int flags); - -struct signalfd_siginfo -{ - uint32_t ssi_signo; - char pad[128 - sizeof (uint32_t)]; -}; -#endif - -/* for timerfd, libev core requires TFD_TIMER_CANCEL_ON_SET &c */ -#if EV_USE_TIMERFD -# include -/* timerfd is only used for periodics */ -# if !(defined (TFD_TIMER_CANCEL_ON_SET) && defined (TFD_CLOEXEC) && defined (TFD_NONBLOCK)) || !EV_PERIODIC_ENABLE -# undef EV_USE_TIMERFD -# define EV_USE_TIMERFD 0 -# endif -#endif - -/*****************************************************************************/ - -#if EV_VERIFY >= 3 -# define EV_FREQUENT_CHECK ev_verify (EV_A) -#else -# define EV_FREQUENT_CHECK do { } while (0) -#endif - -/* - * This is used to work around floating point rounding problems. - * This value is good at least till the year 4000. - */ -#define MIN_INTERVAL 0.0001220703125 /* 1/2**13, good till 4000 */ -/*#define MIN_INTERVAL 0.00000095367431640625 /* 1/2**20, good till 2200 */ - -#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ -#define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */ -#define MAX_BLOCKTIME2 1500001.07 /* same, but when timerfd is used to detect jumps, also safe delay to not overflow */ - -/* find a portable timestamp that is "always" in the future but fits into time_t. - * this is quite hard, and we are mostly guessing - we handle 32 bit signed/unsigned time_t, - * and sizes larger than 32 bit, and maybe the unlikely floating point time_t */ -#define EV_TSTAMP_HUGE \ - (sizeof (time_t) >= 8 ? 10000000000000. \ - : 0 < (time_t)4294967295 ? 4294967295. \ - : 2147483647.) \ - -#ifndef EV_TS_CONST -# define EV_TS_CONST(nv) nv -# define EV_TS_TO_MSEC(a) a * 1e3 + 0.9999 -# define EV_TS_FROM_USEC(us) us * 1e-6 -# define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0) -# define EV_TS_SET(ts,t) do { ts.tv_sec = (long)t; ts.tv_nsec = (long)((t - ts.tv_sec) * 1e9); } while (0) -# define EV_TV_GET(tv) ((tv).tv_sec + (tv).tv_usec * 1e-6) -# define EV_TS_GET(ts) ((ts).tv_sec + (ts).tv_nsec * 1e-9) -#endif - -/* the following is ecb.h embedded into libev - use update_ev_c to update from an external copy */ -/* ECB.H BEGIN */ -/* - * libecb - http://software.schmorp.de/pkg/libecb - * - * Copyright (©) 2009-2015,2018-2020 Marc Alexander Lehmann - * Copyright (©) 2011 Emanuele Giaquinta - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#ifndef ECB_H -#define ECB_H - -/* 16 bits major, 16 bits minor */ -#define ECB_VERSION 0x00010008 - -#include /* for memcpy */ - -#if defined (_WIN32) && !defined (__MINGW32__) - typedef signed char int8_t; - typedef unsigned char uint8_t; - typedef signed char int_fast8_t; - typedef unsigned char uint_fast8_t; - typedef signed short int16_t; - typedef unsigned short uint16_t; - typedef signed int int_fast16_t; - typedef unsigned int uint_fast16_t; - typedef signed int int32_t; - typedef unsigned int uint32_t; - typedef signed int int_fast32_t; - typedef unsigned int uint_fast32_t; - #if __GNUC__ - typedef signed long long int64_t; - typedef unsigned long long uint64_t; - #else /* _MSC_VER || __BORLANDC__ */ - typedef signed __int64 int64_t; - typedef unsigned __int64 uint64_t; - #endif - typedef int64_t int_fast64_t; - typedef uint64_t uint_fast64_t; - #ifdef _WIN64 - #define ECB_PTRSIZE 8 - typedef uint64_t uintptr_t; - typedef int64_t intptr_t; - #else - #define ECB_PTRSIZE 4 - typedef uint32_t uintptr_t; - typedef int32_t intptr_t; - #endif -#else - #include - #if (defined INTPTR_MAX ? INTPTR_MAX : ULONG_MAX) > 0xffffffffU - #define ECB_PTRSIZE 8 - #else - #define ECB_PTRSIZE 4 - #endif -#endif - -#define ECB_GCC_AMD64 (__amd64 || __amd64__ || __x86_64 || __x86_64__) -#define ECB_MSVC_AMD64 (_M_AMD64 || _M_X64) - -#ifndef ECB_OPTIMIZE_SIZE - #if __OPTIMIZE_SIZE__ - #define ECB_OPTIMIZE_SIZE 1 - #else - #define ECB_OPTIMIZE_SIZE 0 - #endif -#endif - -/* work around x32 idiocy by defining proper macros */ -#if ECB_GCC_AMD64 || ECB_MSVC_AMD64 - #if _ILP32 - #define ECB_AMD64_X32 1 - #else - #define ECB_AMD64 1 - #endif -#endif - -/* many compilers define _GNUC_ to some versions but then only implement - * what their idiot authors think are the "more important" extensions, - * causing enormous grief in return for some better fake benchmark numbers. - * or so. - * we try to detect these and simply assume they are not gcc - if they have - * an issue with that they should have done it right in the first place. - */ -#if !defined __GNUC_MINOR__ || defined __INTEL_COMPILER || defined __SUNPRO_C || defined __SUNPRO_CC || defined __llvm__ || defined __clang__ - #define ECB_GCC_VERSION(major,minor) 0 -#else - #define ECB_GCC_VERSION(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) -#endif - -#define ECB_CLANG_VERSION(major,minor) (__clang_major__ > (major) || (__clang_major__ == (major) && __clang_minor__ >= (minor))) - -#if __clang__ && defined __has_builtin - #define ECB_CLANG_BUILTIN(x) __has_builtin (x) -#else - #define ECB_CLANG_BUILTIN(x) 0 -#endif - -#if __clang__ && defined __has_extension - #define ECB_CLANG_EXTENSION(x) __has_extension (x) -#else - #define ECB_CLANG_EXTENSION(x) 0 -#endif - -#define ECB_CPP (__cplusplus+0) -#define ECB_CPP11 (__cplusplus >= 201103L) -#define ECB_CPP14 (__cplusplus >= 201402L) -#define ECB_CPP17 (__cplusplus >= 201703L) - -#if ECB_CPP - #define ECB_C 0 - #define ECB_STDC_VERSION 0 -#else - #define ECB_C 1 - #define ECB_STDC_VERSION __STDC_VERSION__ -#endif - -#define ECB_C99 (ECB_STDC_VERSION >= 199901L) -#define ECB_C11 (ECB_STDC_VERSION >= 201112L) -#define ECB_C17 (ECB_STDC_VERSION >= 201710L) - -#if ECB_CPP - #define ECB_EXTERN_C extern "C" - #define ECB_EXTERN_C_BEG ECB_EXTERN_C { - #define ECB_EXTERN_C_END } -#else - #define ECB_EXTERN_C extern - #define ECB_EXTERN_C_BEG - #define ECB_EXTERN_C_END -#endif - -/*****************************************************************************/ - -/* ECB_NO_THREADS - ecb is not used by multiple threads, ever */ -/* ECB_NO_SMP - ecb might be used in multiple threads, but only on a single cpu */ - -#if ECB_NO_THREADS - #define ECB_NO_SMP 1 -#endif - -#if ECB_NO_SMP - #define ECB_MEMORY_FENCE do { } while (0) -#endif - -/* http://www-01.ibm.com/support/knowledgecenter/SSGH3R_13.1.0/com.ibm.xlcpp131.aix.doc/compiler_ref/compiler_builtins.html */ -#if __xlC__ && ECB_CPP - #include -#endif - -#if 1400 <= _MSC_VER - #include /* fence functions _ReadBarrier, also bit search functions _BitScanReverse */ -#endif - -#ifndef ECB_MEMORY_FENCE - #if ECB_GCC_VERSION(2,5) || defined __INTEL_COMPILER || (__llvm__ && __GNUC__) || __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110 - #define ECB_MEMORY_FENCE_RELAXED __asm__ __volatile__ ("" : : : "memory") - #if __i386 || __i386__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory") - #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("" : : : "memory") - #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("" : : : "memory") - #elif ECB_GCC_AMD64 - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory") - #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("" : : : "memory") - #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("" : : : "memory") - #elif __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory") - #elif defined __ARM_ARCH_2__ \ - || defined __ARM_ARCH_3__ || defined __ARM_ARCH_3M__ \ - || defined __ARM_ARCH_4__ || defined __ARM_ARCH_4T__ \ - || defined __ARM_ARCH_5__ || defined __ARM_ARCH_5E__ \ - || defined __ARM_ARCH_5T__ || defined __ARM_ARCH_5TE__ \ - || defined __ARM_ARCH_5TEJ__ - /* should not need any, unless running old code on newer cpu - arm doesn't support that */ - #elif defined __ARM_ARCH_6__ || defined __ARM_ARCH_6J__ \ - || defined __ARM_ARCH_6K__ || defined __ARM_ARCH_6ZK__ \ - || defined __ARM_ARCH_6T2__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mcr p15,0,%0,c7,c10,5" : : "r" (0) : "memory") - #elif defined __ARM_ARCH_7__ || defined __ARM_ARCH_7A__ \ - || defined __ARM_ARCH_7R__ || defined __ARM_ARCH_7M__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb" : : : "memory") - #elif __aarch64__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb ish" : : : "memory") - #elif (__sparc || __sparc__) && !(__sparc_v8__ || defined __sparcv8) - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad" : : : "memory") - #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad" : : : "memory") - #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore | #StoreStore") - #elif defined __s390__ || defined __s390x__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("bcr 15,0" : : : "memory") - #elif defined __mips__ - /* GNU/Linux emulates sync on mips1 architectures, so we force its use */ - /* anybody else who still uses mips1 is supposed to send in their version, with detection code. */ - #define ECB_MEMORY_FENCE __asm__ __volatile__ (".set mips2; sync; .set mips0" : : : "memory") - #elif defined __alpha__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mb" : : : "memory") - #elif defined __hppa__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory") - #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("") - #elif defined __ia64__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mf" : : : "memory") - #elif defined __m68k__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory") - #elif defined __m88k__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("tb1 0,%%r0,128" : : : "memory") - #elif defined __sh__ - #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory") - #endif - #endif -#endif - -#ifndef ECB_MEMORY_FENCE - #if ECB_GCC_VERSION(4,7) - /* see comment below (stdatomic.h) about the C11 memory model. */ - #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST) - #define ECB_MEMORY_FENCE_ACQUIRE __atomic_thread_fence (__ATOMIC_ACQUIRE) - #define ECB_MEMORY_FENCE_RELEASE __atomic_thread_fence (__ATOMIC_RELEASE) - #define ECB_MEMORY_FENCE_RELAXED __atomic_thread_fence (__ATOMIC_RELAXED) - - #elif ECB_CLANG_EXTENSION(c_atomic) - /* see comment below (stdatomic.h) about the C11 memory model. */ - #define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST) - #define ECB_MEMORY_FENCE_ACQUIRE __c11_atomic_thread_fence (__ATOMIC_ACQUIRE) - #define ECB_MEMORY_FENCE_RELEASE __c11_atomic_thread_fence (__ATOMIC_RELEASE) - #define ECB_MEMORY_FENCE_RELAXED __c11_atomic_thread_fence (__ATOMIC_RELAXED) - - #elif ECB_GCC_VERSION(4,4) || defined __INTEL_COMPILER || defined __clang__ - #define ECB_MEMORY_FENCE __sync_synchronize () - #elif _MSC_VER >= 1500 /* VC++ 2008 */ - /* apparently, microsoft broke all the memory barrier stuff in Visual Studio 2008... */ - #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier) - #define ECB_MEMORY_FENCE _ReadWriteBarrier (); MemoryBarrier() - #define ECB_MEMORY_FENCE_ACQUIRE _ReadWriteBarrier (); MemoryBarrier() /* according to msdn, _ReadBarrier is not a load fence */ - #define ECB_MEMORY_FENCE_RELEASE _WriteBarrier (); MemoryBarrier() - #elif _MSC_VER >= 1400 /* VC++ 2005 */ - #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier) - #define ECB_MEMORY_FENCE _ReadWriteBarrier () - #define ECB_MEMORY_FENCE_ACQUIRE _ReadWriteBarrier () /* according to msdn, _ReadBarrier is not a load fence */ - #define ECB_MEMORY_FENCE_RELEASE _WriteBarrier () - #elif defined _WIN32 - #include - #define ECB_MEMORY_FENCE MemoryBarrier () /* actually just xchg on x86... scary */ - #elif __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110 - #include - #define ECB_MEMORY_FENCE __machine_rw_barrier () - #define ECB_MEMORY_FENCE_ACQUIRE __machine_acq_barrier () - #define ECB_MEMORY_FENCE_RELEASE __machine_rel_barrier () - #define ECB_MEMORY_FENCE_RELAXED __compiler_barrier () - #elif __xlC__ - #define ECB_MEMORY_FENCE __sync () - #endif -#endif - -#ifndef ECB_MEMORY_FENCE - #if ECB_C11 && !defined __STDC_NO_ATOMICS__ - /* we assume that these memory fences work on all variables/all memory accesses, */ - /* not just C11 atomics and atomic accesses */ - #include - #define ECB_MEMORY_FENCE atomic_thread_fence (memory_order_seq_cst) - #define ECB_MEMORY_FENCE_ACQUIRE atomic_thread_fence (memory_order_acquire) - #define ECB_MEMORY_FENCE_RELEASE atomic_thread_fence (memory_order_release) - #endif -#endif - -#ifndef ECB_MEMORY_FENCE - #if !ECB_AVOID_PTHREADS - /* - * if you get undefined symbol references to pthread_mutex_lock, - * or failure to find pthread.h, then you should implement - * the ECB_MEMORY_FENCE operations for your cpu/compiler - * OR provide pthread.h and link against the posix thread library - * of your system. - */ - #include - #define ECB_NEEDS_PTHREADS 1 - #define ECB_MEMORY_FENCE_NEEDS_PTHREADS 1 - - static pthread_mutex_t ecb_mf_lock = PTHREAD_MUTEX_INITIALIZER; - #define ECB_MEMORY_FENCE do { pthread_mutex_lock (&ecb_mf_lock); pthread_mutex_unlock (&ecb_mf_lock); } while (0) - #endif -#endif - -#if !defined ECB_MEMORY_FENCE_ACQUIRE && defined ECB_MEMORY_FENCE - #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE -#endif - -#if !defined ECB_MEMORY_FENCE_RELEASE && defined ECB_MEMORY_FENCE - #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE -#endif - -#if !defined ECB_MEMORY_FENCE_RELAXED && defined ECB_MEMORY_FENCE - #define ECB_MEMORY_FENCE_RELAXED ECB_MEMORY_FENCE /* very heavy-handed */ -#endif - -/*****************************************************************************/ - -#if ECB_CPP - #define ecb_inline static inline -#elif ECB_GCC_VERSION(2,5) - #define ecb_inline static __inline__ -#elif ECB_C99 - #define ecb_inline static inline -#else - #define ecb_inline static -#endif - -#if ECB_GCC_VERSION(3,3) - #define ecb_restrict __restrict__ -#elif ECB_C99 - #define ecb_restrict restrict -#else - #define ecb_restrict -#endif - -typedef int ecb_bool; - -#define ECB_CONCAT_(a, b) a ## b -#define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) -#define ECB_STRINGIFY_(a) # a -#define ECB_STRINGIFY(a) ECB_STRINGIFY_(a) -#define ECB_STRINGIFY_EXPR(expr) ((expr), ECB_STRINGIFY_ (expr)) - -#define ecb_function_ ecb_inline - -#if ECB_GCC_VERSION(3,1) || ECB_CLANG_VERSION(2,8) - #define ecb_attribute(attrlist) __attribute__ (attrlist) -#else - #define ecb_attribute(attrlist) -#endif - -#if ECB_GCC_VERSION(3,1) || ECB_CLANG_BUILTIN(__builtin_constant_p) - #define ecb_is_constant(expr) __builtin_constant_p (expr) -#else - /* possible C11 impl for integral types - typedef struct ecb_is_constant_struct ecb_is_constant_struct; - #define ecb_is_constant(expr) _Generic ((1 ? (struct ecb_is_constant_struct *)0 : (void *)((expr) - (expr)), ecb_is_constant_struct *: 0, default: 1)) */ - - #define ecb_is_constant(expr) 0 -#endif - -#if ECB_GCC_VERSION(3,1) || ECB_CLANG_BUILTIN(__builtin_expect) - #define ecb_expect(expr,value) __builtin_expect ((expr),(value)) -#else - #define ecb_expect(expr,value) (expr) -#endif - -#if ECB_GCC_VERSION(3,1) || ECB_CLANG_BUILTIN(__builtin_prefetch) - #define ecb_prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) -#else - #define ecb_prefetch(addr,rw,locality) -#endif - -/* no emulation for ecb_decltype */ -#if ECB_CPP11 - // older implementations might have problems with decltype(x)::type, work around it - template struct ecb_decltype_t { typedef T type; }; - #define ecb_decltype(x) ecb_decltype_t::type -#elif ECB_GCC_VERSION(3,0) || ECB_CLANG_VERSION(2,8) - #define ecb_decltype(x) __typeof__ (x) -#endif - -#if _MSC_VER >= 1300 - #define ecb_deprecated __declspec (deprecated) -#else - #define ecb_deprecated ecb_attribute ((__deprecated__)) -#endif - -#if _MSC_VER >= 1500 - #define ecb_deprecated_message(msg) __declspec (deprecated (msg)) -#elif ECB_GCC_VERSION(4,5) - #define ecb_deprecated_message(msg) ecb_attribute ((__deprecated__ (msg)) -#else - #define ecb_deprecated_message(msg) ecb_deprecated -#endif - -#if _MSC_VER >= 1400 - #define ecb_noinline __declspec (noinline) -#else - #define ecb_noinline ecb_attribute ((__noinline__)) -#endif - -#define ecb_unused ecb_attribute ((__unused__)) -#define ecb_const ecb_attribute ((__const__)) -#define ecb_pure ecb_attribute ((__pure__)) - -#if ECB_C11 || __IBMC_NORETURN - /* http://www-01.ibm.com/support/knowledgecenter/SSGH3R_13.1.0/com.ibm.xlcpp131.aix.doc/language_ref/noreturn.html */ - #define ecb_noreturn _Noreturn -#elif ECB_CPP11 - #define ecb_noreturn [[noreturn]] -#elif _MSC_VER >= 1200 - /* http://msdn.microsoft.com/en-us/library/k6ktzx3s.aspx */ - #define ecb_noreturn __declspec (noreturn) -#else - #define ecb_noreturn ecb_attribute ((__noreturn__)) -#endif - -#if ECB_GCC_VERSION(4,3) - #define ecb_artificial ecb_attribute ((__artificial__)) - #define ecb_hot ecb_attribute ((__hot__)) - #define ecb_cold ecb_attribute ((__cold__)) -#else - #define ecb_artificial - #define ecb_hot - #define ecb_cold -#endif - -/* put around conditional expressions if you are very sure that the */ -/* expression is mostly true or mostly false. note that these return */ -/* booleans, not the expression. */ -#define ecb_expect_false(expr) ecb_expect (!!(expr), 0) -#define ecb_expect_true(expr) ecb_expect (!!(expr), 1) -/* for compatibility to the rest of the world */ -#define ecb_likely(expr) ecb_expect_true (expr) -#define ecb_unlikely(expr) ecb_expect_false (expr) - -/* count trailing zero bits and count # of one bits */ -#if ECB_GCC_VERSION(3,4) \ - || (ECB_CLANG_BUILTIN(__builtin_clz) && ECB_CLANG_BUILTIN(__builtin_clzll) \ - && ECB_CLANG_BUILTIN(__builtin_ctz) && ECB_CLANG_BUILTIN(__builtin_ctzll) \ - && ECB_CLANG_BUILTIN(__builtin_popcount)) - /* we assume int == 32 bit, long == 32 or 64 bit and long long == 64 bit */ - #define ecb_ld32(x) (__builtin_clz (x) ^ 31) - #define ecb_ld64(x) (__builtin_clzll (x) ^ 63) - #define ecb_ctz32(x) __builtin_ctz (x) - #define ecb_ctz64(x) __builtin_ctzll (x) - #define ecb_popcount32(x) __builtin_popcount (x) - /* no popcountll */ -#else - ecb_function_ ecb_const int ecb_ctz32 (uint32_t x); - ecb_function_ ecb_const int - ecb_ctz32 (uint32_t x) - { -#if 1400 <= _MSC_VER && (_M_IX86 || _M_X64 || _M_IA64 || _M_ARM) - unsigned long r; - _BitScanForward (&r, x); - return (int)r; -#else - int r = 0; - - x &= ~x + 1; /* this isolates the lowest bit */ - -#if ECB_branchless_on_i386 - r += !!(x & 0xaaaaaaaa) << 0; - r += !!(x & 0xcccccccc) << 1; - r += !!(x & 0xf0f0f0f0) << 2; - r += !!(x & 0xff00ff00) << 3; - r += !!(x & 0xffff0000) << 4; -#else - if (x & 0xaaaaaaaa) r += 1; - if (x & 0xcccccccc) r += 2; - if (x & 0xf0f0f0f0) r += 4; - if (x & 0xff00ff00) r += 8; - if (x & 0xffff0000) r += 16; -#endif - - return r; -#endif - } - - ecb_function_ ecb_const int ecb_ctz64 (uint64_t x); - ecb_function_ ecb_const int - ecb_ctz64 (uint64_t x) - { -#if 1400 <= _MSC_VER && (_M_X64 || _M_IA64 || _M_ARM) - unsigned long r; - _BitScanForward64 (&r, x); - return (int)r; -#else - int shift = x & 0xffffffff ? 0 : 32; - return ecb_ctz32 (x >> shift) + shift; -#endif - } - - ecb_function_ ecb_const int ecb_popcount32 (uint32_t x); - ecb_function_ ecb_const int - ecb_popcount32 (uint32_t x) - { - x -= (x >> 1) & 0x55555555; - x = ((x >> 2) & 0x33333333) + (x & 0x33333333); - x = ((x >> 4) + x) & 0x0f0f0f0f; - x *= 0x01010101; - - return x >> 24; - } - - ecb_function_ ecb_const int ecb_ld32 (uint32_t x); - ecb_function_ ecb_const int ecb_ld32 (uint32_t x) - { -#if 1400 <= _MSC_VER && (_M_IX86 || _M_X64 || _M_IA64 || _M_ARM) - unsigned long r; - _BitScanReverse (&r, x); - return (int)r; -#else - int r = 0; - - if (x >> 16) { x >>= 16; r += 16; } - if (x >> 8) { x >>= 8; r += 8; } - if (x >> 4) { x >>= 4; r += 4; } - if (x >> 2) { x >>= 2; r += 2; } - if (x >> 1) { r += 1; } - - return r; -#endif - } - - ecb_function_ ecb_const int ecb_ld64 (uint64_t x); - ecb_function_ ecb_const int ecb_ld64 (uint64_t x) - { -#if 1400 <= _MSC_VER && (_M_X64 || _M_IA64 || _M_ARM) - unsigned long r; - _BitScanReverse64 (&r, x); - return (int)r; -#else - int r = 0; - - if (x >> 32) { x >>= 32; r += 32; } - - return r + ecb_ld32 (x); -#endif - } -#endif - -ecb_function_ ecb_const ecb_bool ecb_is_pot32 (uint32_t x); -ecb_function_ ecb_const ecb_bool ecb_is_pot32 (uint32_t x) { return !(x & (x - 1)); } -ecb_function_ ecb_const ecb_bool ecb_is_pot64 (uint64_t x); -ecb_function_ ecb_const ecb_bool ecb_is_pot64 (uint64_t x) { return !(x & (x - 1)); } - -ecb_function_ ecb_const uint8_t ecb_bitrev8 (uint8_t x); -ecb_function_ ecb_const uint8_t ecb_bitrev8 (uint8_t x) -{ - return ( (x * 0x0802U & 0x22110U) - | (x * 0x8020U & 0x88440U)) * 0x10101U >> 16; -} - -ecb_function_ ecb_const uint16_t ecb_bitrev16 (uint16_t x); -ecb_function_ ecb_const uint16_t ecb_bitrev16 (uint16_t x) -{ - x = ((x >> 1) & 0x5555) | ((x & 0x5555) << 1); - x = ((x >> 2) & 0x3333) | ((x & 0x3333) << 2); - x = ((x >> 4) & 0x0f0f) | ((x & 0x0f0f) << 4); - x = ( x >> 8 ) | ( x << 8); - - return x; -} - -ecb_function_ ecb_const uint32_t ecb_bitrev32 (uint32_t x); -ecb_function_ ecb_const uint32_t ecb_bitrev32 (uint32_t x) -{ - x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1); - x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2); - x = ((x >> 4) & 0x0f0f0f0f) | ((x & 0x0f0f0f0f) << 4); - x = ((x >> 8) & 0x00ff00ff) | ((x & 0x00ff00ff) << 8); - x = ( x >> 16 ) | ( x << 16); - - return x; -} - -/* popcount64 is only available on 64 bit cpus as gcc builtin */ -/* so for this version we are lazy */ -ecb_function_ ecb_const int ecb_popcount64 (uint64_t x); -ecb_function_ ecb_const int -ecb_popcount64 (uint64_t x) -{ - return ecb_popcount32 (x) + ecb_popcount32 (x >> 32); -} - -ecb_inline ecb_const uint8_t ecb_rotl8 (uint8_t x, unsigned int count); -ecb_inline ecb_const uint8_t ecb_rotr8 (uint8_t x, unsigned int count); -ecb_inline ecb_const uint16_t ecb_rotl16 (uint16_t x, unsigned int count); -ecb_inline ecb_const uint16_t ecb_rotr16 (uint16_t x, unsigned int count); -ecb_inline ecb_const uint32_t ecb_rotl32 (uint32_t x, unsigned int count); -ecb_inline ecb_const uint32_t ecb_rotr32 (uint32_t x, unsigned int count); -ecb_inline ecb_const uint64_t ecb_rotl64 (uint64_t x, unsigned int count); -ecb_inline ecb_const uint64_t ecb_rotr64 (uint64_t x, unsigned int count); - -ecb_inline ecb_const uint8_t ecb_rotl8 (uint8_t x, unsigned int count) { return (x >> ( 8 - count)) | (x << count); } -ecb_inline ecb_const uint8_t ecb_rotr8 (uint8_t x, unsigned int count) { return (x << ( 8 - count)) | (x >> count); } -ecb_inline ecb_const uint16_t ecb_rotl16 (uint16_t x, unsigned int count) { return (x >> (16 - count)) | (x << count); } -ecb_inline ecb_const uint16_t ecb_rotr16 (uint16_t x, unsigned int count) { return (x << (16 - count)) | (x >> count); } -ecb_inline ecb_const uint32_t ecb_rotl32 (uint32_t x, unsigned int count) { return (x >> (32 - count)) | (x << count); } -ecb_inline ecb_const uint32_t ecb_rotr32 (uint32_t x, unsigned int count) { return (x << (32 - count)) | (x >> count); } -ecb_inline ecb_const uint64_t ecb_rotl64 (uint64_t x, unsigned int count) { return (x >> (64 - count)) | (x << count); } -ecb_inline ecb_const uint64_t ecb_rotr64 (uint64_t x, unsigned int count) { return (x << (64 - count)) | (x >> count); } - -#if ECB_CPP - -inline uint8_t ecb_ctz (uint8_t v) { return ecb_ctz32 (v); } -inline uint16_t ecb_ctz (uint16_t v) { return ecb_ctz32 (v); } -inline uint32_t ecb_ctz (uint32_t v) { return ecb_ctz32 (v); } -inline uint64_t ecb_ctz (uint64_t v) { return ecb_ctz64 (v); } - -inline bool ecb_is_pot (uint8_t v) { return ecb_is_pot32 (v); } -inline bool ecb_is_pot (uint16_t v) { return ecb_is_pot32 (v); } -inline bool ecb_is_pot (uint32_t v) { return ecb_is_pot32 (v); } -inline bool ecb_is_pot (uint64_t v) { return ecb_is_pot64 (v); } - -inline int ecb_ld (uint8_t v) { return ecb_ld32 (v); } -inline int ecb_ld (uint16_t v) { return ecb_ld32 (v); } -inline int ecb_ld (uint32_t v) { return ecb_ld32 (v); } -inline int ecb_ld (uint64_t v) { return ecb_ld64 (v); } - -inline int ecb_popcount (uint8_t v) { return ecb_popcount32 (v); } -inline int ecb_popcount (uint16_t v) { return ecb_popcount32 (v); } -inline int ecb_popcount (uint32_t v) { return ecb_popcount32 (v); } -inline int ecb_popcount (uint64_t v) { return ecb_popcount64 (v); } - -inline uint8_t ecb_bitrev (uint8_t v) { return ecb_bitrev8 (v); } -inline uint16_t ecb_bitrev (uint16_t v) { return ecb_bitrev16 (v); } -inline uint32_t ecb_bitrev (uint32_t v) { return ecb_bitrev32 (v); } - -inline uint8_t ecb_rotl (uint8_t v, unsigned int count) { return ecb_rotl8 (v, count); } -inline uint16_t ecb_rotl (uint16_t v, unsigned int count) { return ecb_rotl16 (v, count); } -inline uint32_t ecb_rotl (uint32_t v, unsigned int count) { return ecb_rotl32 (v, count); } -inline uint64_t ecb_rotl (uint64_t v, unsigned int count) { return ecb_rotl64 (v, count); } - -inline uint8_t ecb_rotr (uint8_t v, unsigned int count) { return ecb_rotr8 (v, count); } -inline uint16_t ecb_rotr (uint16_t v, unsigned int count) { return ecb_rotr16 (v, count); } -inline uint32_t ecb_rotr (uint32_t v, unsigned int count) { return ecb_rotr32 (v, count); } -inline uint64_t ecb_rotr (uint64_t v, unsigned int count) { return ecb_rotr64 (v, count); } - -#endif - -#if ECB_GCC_VERSION(4,3) || (ECB_CLANG_BUILTIN(__builtin_bswap32) && ECB_CLANG_BUILTIN(__builtin_bswap64)) - #if ECB_GCC_VERSION(4,8) || ECB_CLANG_BUILTIN(__builtin_bswap16) - #define ecb_bswap16(x) __builtin_bswap16 (x) - #else - #define ecb_bswap16(x) (__builtin_bswap32 (x) >> 16) - #endif - #define ecb_bswap32(x) __builtin_bswap32 (x) - #define ecb_bswap64(x) __builtin_bswap64 (x) -#elif _MSC_VER - #include - #define ecb_bswap16(x) ((uint16_t)_byteswap_ushort ((uint16_t)(x))) - #define ecb_bswap32(x) ((uint32_t)_byteswap_ulong ((uint32_t)(x))) - #define ecb_bswap64(x) ((uint64_t)_byteswap_uint64 ((uint64_t)(x))) -#else - ecb_function_ ecb_const uint16_t ecb_bswap16 (uint16_t x); - ecb_function_ ecb_const uint16_t - ecb_bswap16 (uint16_t x) - { - return ecb_rotl16 (x, 8); - } - - ecb_function_ ecb_const uint32_t ecb_bswap32 (uint32_t x); - ecb_function_ ecb_const uint32_t - ecb_bswap32 (uint32_t x) - { - return (((uint32_t)ecb_bswap16 (x)) << 16) | ecb_bswap16 (x >> 16); - } - - ecb_function_ ecb_const uint64_t ecb_bswap64 (uint64_t x); - ecb_function_ ecb_const uint64_t - ecb_bswap64 (uint64_t x) - { - return (((uint64_t)ecb_bswap32 (x)) << 32) | ecb_bswap32 (x >> 32); - } -#endif - -#if ECB_GCC_VERSION(4,5) || ECB_CLANG_BUILTIN(__builtin_unreachable) - #define ecb_unreachable() __builtin_unreachable () -#else - /* this seems to work fine, but gcc always emits a warning for it :/ */ - ecb_inline ecb_noreturn void ecb_unreachable (void); - ecb_inline ecb_noreturn void ecb_unreachable (void) { } -#endif - -/* try to tell the compiler that some condition is definitely true */ -#define ecb_assume(cond) if (!(cond)) ecb_unreachable (); else 0 - -ecb_inline ecb_const uint32_t ecb_byteorder_helper (void); -ecb_inline ecb_const uint32_t -ecb_byteorder_helper (void) -{ - /* the union code still generates code under pressure in gcc, */ - /* but less than using pointers, and always seems to */ - /* successfully return a constant. */ - /* the reason why we have this horrible preprocessor mess */ - /* is to avoid it in all cases, at least on common architectures */ - /* or when using a recent enough gcc version (>= 4.6) */ -#if (defined __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) \ - || ((__i386 || __i386__ || _M_IX86 || ECB_GCC_AMD64 || ECB_MSVC_AMD64) && !__VOS__) - #define ECB_LITTLE_ENDIAN 1 - return 0x44332211; -#elif (defined __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) \ - || ((__AARCH64EB__ || __MIPSEB__ || __ARMEB__) && !__VOS__) - #define ECB_BIG_ENDIAN 1 - return 0x11223344; -#else - union - { - uint8_t c[4]; - uint32_t u; - } u = { 0x11, 0x22, 0x33, 0x44 }; - return u.u; -#endif -} - -ecb_inline ecb_const ecb_bool ecb_big_endian (void); -ecb_inline ecb_const ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11223344; } -ecb_inline ecb_const ecb_bool ecb_little_endian (void); -ecb_inline ecb_const ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () == 0x44332211; } - -/*****************************************************************************/ -/* unaligned load/store */ - -ecb_inline uint_fast16_t ecb_be_u16_to_host (uint_fast16_t v) { return ecb_little_endian () ? ecb_bswap16 (v) : v; } -ecb_inline uint_fast32_t ecb_be_u32_to_host (uint_fast32_t v) { return ecb_little_endian () ? ecb_bswap32 (v) : v; } -ecb_inline uint_fast64_t ecb_be_u64_to_host (uint_fast64_t v) { return ecb_little_endian () ? ecb_bswap64 (v) : v; } - -ecb_inline uint_fast16_t ecb_le_u16_to_host (uint_fast16_t v) { return ecb_big_endian () ? ecb_bswap16 (v) : v; } -ecb_inline uint_fast32_t ecb_le_u32_to_host (uint_fast32_t v) { return ecb_big_endian () ? ecb_bswap32 (v) : v; } -ecb_inline uint_fast64_t ecb_le_u64_to_host (uint_fast64_t v) { return ecb_big_endian () ? ecb_bswap64 (v) : v; } - -ecb_inline uint_fast16_t ecb_peek_u16_u (const void *ptr) { uint16_t v; memcpy (&v, ptr, sizeof (v)); return v; } -ecb_inline uint_fast32_t ecb_peek_u32_u (const void *ptr) { uint32_t v; memcpy (&v, ptr, sizeof (v)); return v; } -ecb_inline uint_fast64_t ecb_peek_u64_u (const void *ptr) { uint64_t v; memcpy (&v, ptr, sizeof (v)); return v; } - -ecb_inline uint_fast16_t ecb_peek_be_u16_u (const void *ptr) { return ecb_be_u16_to_host (ecb_peek_u16_u (ptr)); } -ecb_inline uint_fast32_t ecb_peek_be_u32_u (const void *ptr) { return ecb_be_u32_to_host (ecb_peek_u32_u (ptr)); } -ecb_inline uint_fast64_t ecb_peek_be_u64_u (const void *ptr) { return ecb_be_u64_to_host (ecb_peek_u64_u (ptr)); } - -ecb_inline uint_fast16_t ecb_peek_le_u16_u (const void *ptr) { return ecb_le_u16_to_host (ecb_peek_u16_u (ptr)); } -ecb_inline uint_fast32_t ecb_peek_le_u32_u (const void *ptr) { return ecb_le_u32_to_host (ecb_peek_u32_u (ptr)); } -ecb_inline uint_fast64_t ecb_peek_le_u64_u (const void *ptr) { return ecb_le_u64_to_host (ecb_peek_u64_u (ptr)); } - -ecb_inline uint_fast16_t ecb_host_to_be_u16 (uint_fast16_t v) { return ecb_little_endian () ? ecb_bswap16 (v) : v; } -ecb_inline uint_fast32_t ecb_host_to_be_u32 (uint_fast32_t v) { return ecb_little_endian () ? ecb_bswap32 (v) : v; } -ecb_inline uint_fast64_t ecb_host_to_be_u64 (uint_fast64_t v) { return ecb_little_endian () ? ecb_bswap64 (v) : v; } - -ecb_inline uint_fast16_t ecb_host_to_le_u16 (uint_fast16_t v) { return ecb_big_endian () ? ecb_bswap16 (v) : v; } -ecb_inline uint_fast32_t ecb_host_to_le_u32 (uint_fast32_t v) { return ecb_big_endian () ? ecb_bswap32 (v) : v; } -ecb_inline uint_fast64_t ecb_host_to_le_u64 (uint_fast64_t v) { return ecb_big_endian () ? ecb_bswap64 (v) : v; } - -ecb_inline void ecb_poke_u16_u (void *ptr, uint16_t v) { memcpy (ptr, &v, sizeof (v)); } -ecb_inline void ecb_poke_u32_u (void *ptr, uint32_t v) { memcpy (ptr, &v, sizeof (v)); } -ecb_inline void ecb_poke_u64_u (void *ptr, uint64_t v) { memcpy (ptr, &v, sizeof (v)); } - -ecb_inline void ecb_poke_be_u16_u (void *ptr, uint_fast16_t v) { ecb_poke_u16_u (ptr, ecb_host_to_be_u16 (v)); } -ecb_inline void ecb_poke_be_u32_u (void *ptr, uint_fast32_t v) { ecb_poke_u32_u (ptr, ecb_host_to_be_u32 (v)); } -ecb_inline void ecb_poke_be_u64_u (void *ptr, uint_fast64_t v) { ecb_poke_u64_u (ptr, ecb_host_to_be_u64 (v)); } - -ecb_inline void ecb_poke_le_u16_u (void *ptr, uint_fast16_t v) { ecb_poke_u16_u (ptr, ecb_host_to_le_u16 (v)); } -ecb_inline void ecb_poke_le_u32_u (void *ptr, uint_fast32_t v) { ecb_poke_u32_u (ptr, ecb_host_to_le_u32 (v)); } -ecb_inline void ecb_poke_le_u64_u (void *ptr, uint_fast64_t v) { ecb_poke_u64_u (ptr, ecb_host_to_le_u64 (v)); } - -#if ECB_CPP - -inline uint8_t ecb_bswap (uint8_t v) { return v; } -inline uint16_t ecb_bswap (uint16_t v) { return ecb_bswap16 (v); } -inline uint32_t ecb_bswap (uint32_t v) { return ecb_bswap32 (v); } -inline uint64_t ecb_bswap (uint64_t v) { return ecb_bswap64 (v); } - -template inline T ecb_be_to_host (T v) { return ecb_little_endian () ? ecb_bswap (v) : v; } -template inline T ecb_le_to_host (T v) { return ecb_big_endian () ? ecb_bswap (v) : v; } -template inline T ecb_peek (const void *ptr) { return *(const T *)ptr; } -template inline T ecb_peek_be (const void *ptr) { return ecb_be_to_host (ecb_peek (ptr)); } -template inline T ecb_peek_le (const void *ptr) { return ecb_le_to_host (ecb_peek (ptr)); } -template inline T ecb_peek_u (const void *ptr) { T v; memcpy (&v, ptr, sizeof (v)); return v; } -template inline T ecb_peek_be_u (const void *ptr) { return ecb_be_to_host (ecb_peek_u (ptr)); } -template inline T ecb_peek_le_u (const void *ptr) { return ecb_le_to_host (ecb_peek_u (ptr)); } - -template inline T ecb_host_to_be (T v) { return ecb_little_endian () ? ecb_bswap (v) : v; } -template inline T ecb_host_to_le (T v) { return ecb_big_endian () ? ecb_bswap (v) : v; } -template inline void ecb_poke (void *ptr, T v) { *(T *)ptr = v; } -template inline void ecb_poke_be (void *ptr, T v) { return ecb_poke (ptr, ecb_host_to_be (v)); } -template inline void ecb_poke_le (void *ptr, T v) { return ecb_poke (ptr, ecb_host_to_le (v)); } -template inline void ecb_poke_u (void *ptr, T v) { memcpy (ptr, &v, sizeof (v)); } -template inline void ecb_poke_be_u (void *ptr, T v) { return ecb_poke_u (ptr, ecb_host_to_be (v)); } -template inline void ecb_poke_le_u (void *ptr, T v) { return ecb_poke_u (ptr, ecb_host_to_le (v)); } - -#endif - -/*****************************************************************************/ - -#if ECB_GCC_VERSION(3,0) || ECB_C99 - #define ecb_mod(m,n) ((m) % (n) + ((m) % (n) < 0 ? (n) : 0)) -#else - #define ecb_mod(m,n) ((m) < 0 ? ((n) - 1 - ((-1 - (m)) % (n))) : ((m) % (n))) -#endif - -#if ECB_CPP - template - static inline T ecb_div_rd (T val, T div) - { - return val < 0 ? - ((-val + div - 1) / div) : (val ) / div; - } - template - static inline T ecb_div_ru (T val, T div) - { - return val < 0 ? - ((-val ) / div) : (val + div - 1) / div; - } -#else - #define ecb_div_rd(val,div) ((val) < 0 ? - ((-(val) + (div) - 1) / (div)) : ((val) ) / (div)) - #define ecb_div_ru(val,div) ((val) < 0 ? - ((-(val) ) / (div)) : ((val) + (div) - 1) / (div)) -#endif - -#if ecb_cplusplus_does_not_suck - /* does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm) */ - template - static inline int ecb_array_length (const T (&arr)[N]) - { - return N; - } -#else - #define ecb_array_length(name) (sizeof (name) / sizeof (name [0])) -#endif - -/*****************************************************************************/ - -ecb_function_ ecb_const uint32_t ecb_binary16_to_binary32 (uint32_t x); -ecb_function_ ecb_const uint32_t -ecb_binary16_to_binary32 (uint32_t x) -{ - unsigned int s = (x & 0x8000) << (31 - 15); - int e = (x >> 10) & 0x001f; - unsigned int m = x & 0x03ff; - - if (ecb_expect_false (e == 31)) - /* infinity or NaN */ - e = 255 - (127 - 15); - else if (ecb_expect_false (!e)) - { - if (ecb_expect_true (!m)) - /* zero, handled by code below by forcing e to 0 */ - e = 0 - (127 - 15); - else - { - /* subnormal, renormalise */ - unsigned int s = 10 - ecb_ld32 (m); - - m = (m << s) & 0x3ff; /* mask implicit bit */ - e -= s - 1; - } - } - - /* e and m now are normalised, or zero, (or inf or nan) */ - e += 127 - 15; - - return s | (e << 23) | (m << (23 - 10)); -} - -ecb_function_ ecb_const uint16_t ecb_binary32_to_binary16 (uint32_t x); -ecb_function_ ecb_const uint16_t -ecb_binary32_to_binary16 (uint32_t x) -{ - unsigned int s = (x >> 16) & 0x00008000; /* sign bit, the easy part */ - unsigned int e = ((x >> 23) & 0x000000ff) - (127 - 15); /* the desired exponent */ - unsigned int m = x & 0x007fffff; - - x &= 0x7fffffff; - - /* if it's within range of binary16 normals, use fast path */ - if (ecb_expect_true (0x38800000 <= x && x <= 0x477fefff)) - { - /* mantissa round-to-even */ - m += 0x00000fff + ((m >> (23 - 10)) & 1); - - /* handle overflow */ - if (ecb_expect_false (m >= 0x00800000)) - { - m >>= 1; - e += 1; - } - - return s | (e << 10) | (m >> (23 - 10)); - } - - /* handle large numbers and infinity */ - if (ecb_expect_true (0x477fefff < x && x <= 0x7f800000)) - return s | 0x7c00; - - /* handle zero, subnormals and small numbers */ - if (ecb_expect_true (x < 0x38800000)) - { - /* zero */ - if (ecb_expect_true (!x)) - return s; - - /* handle subnormals */ - - /* too small, will be zero */ - if (e < (14 - 24)) /* might not be sharp, but is good enough */ - return s; - - m |= 0x00800000; /* make implicit bit explicit */ - - /* very tricky - we need to round to the nearest e (+10) bit value */ - { - unsigned int bits = 14 - e; - unsigned int half = (1 << (bits - 1)) - 1; - unsigned int even = (m >> bits) & 1; - - /* if this overflows, we will end up with a normalised number */ - m = (m + half + even) >> bits; - } - - return s | m; - } - - /* handle NaNs, preserve leftmost nan bits, but make sure we don't turn them into infinities */ - m >>= 13; - - return s | 0x7c00 | m | !m; -} - -/*******************************************************************************/ -/* floating point stuff, can be disabled by defining ECB_NO_LIBM */ - -/* basically, everything uses "ieee pure-endian" floating point numbers */ -/* the only noteworthy exception is ancient armle, which uses order 43218765 */ -#if 0 \ - || __i386 || __i386__ \ - || ECB_GCC_AMD64 \ - || __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ \ - || defined __s390__ || defined __s390x__ \ - || defined __mips__ \ - || defined __alpha__ \ - || defined __hppa__ \ - || defined __ia64__ \ - || defined __m68k__ \ - || defined __m88k__ \ - || defined __sh__ \ - || defined _M_IX86 || defined ECB_MSVC_AMD64 || defined _M_IA64 \ - || (defined __arm__ && (defined __ARM_EABI__ || defined __EABI__ || defined __VFP_FP__ || defined _WIN32_WCE || defined __ANDROID__)) \ - || defined __aarch64__ - #define ECB_STDFP 1 -#else - #define ECB_STDFP 0 -#endif - -#ifndef ECB_NO_LIBM - - #include /* for frexp*, ldexp*, INFINITY, NAN */ - - /* only the oldest of old doesn't have this one. solaris. */ - #ifdef INFINITY - #define ECB_INFINITY INFINITY - #else - #define ECB_INFINITY HUGE_VAL - #endif - - #ifdef NAN - #define ECB_NAN NAN - #else - #define ECB_NAN ECB_INFINITY - #endif - - #if ECB_C99 || _XOPEN_VERSION >= 600 || _POSIX_VERSION >= 200112L - #define ecb_ldexpf(x,e) ldexpf ((x), (e)) - #define ecb_frexpf(x,e) frexpf ((x), (e)) - #else - #define ecb_ldexpf(x,e) (float) ldexp ((double) (x), (e)) - #define ecb_frexpf(x,e) (float) frexp ((double) (x), (e)) - #endif - - /* convert a float to ieee single/binary32 */ - ecb_function_ ecb_const uint32_t ecb_float_to_binary32 (float x); - ecb_function_ ecb_const uint32_t - ecb_float_to_binary32 (float x) - { - uint32_t r; - - #if ECB_STDFP - memcpy (&r, &x, 4); - #else - /* slow emulation, works for anything but -0 */ - uint32_t m; - int e; - - if (x == 0e0f ) return 0x00000000U; - if (x > +3.40282346638528860e+38f) return 0x7f800000U; - if (x < -3.40282346638528860e+38f) return 0xff800000U; - if (x != x ) return 0x7fbfffffU; - - m = ecb_frexpf (x, &e) * 0x1000000U; - - r = m & 0x80000000U; - - if (r) - m = -m; - - if (e <= -126) - { - m &= 0xffffffU; - m >>= (-125 - e); - e = -126; - } - - r |= (e + 126) << 23; - r |= m & 0x7fffffU; - #endif - - return r; - } - - /* converts an ieee single/binary32 to a float */ - ecb_function_ ecb_const float ecb_binary32_to_float (uint32_t x); - ecb_function_ ecb_const float - ecb_binary32_to_float (uint32_t x) - { - float r; - - #if ECB_STDFP - memcpy (&r, &x, 4); - #else - /* emulation, only works for normals and subnormals and +0 */ - int neg = x >> 31; - int e = (x >> 23) & 0xffU; - - x &= 0x7fffffU; - - if (e) - x |= 0x800000U; - else - e = 1; - - /* we distrust ldexpf a bit and do the 2**-24 scaling by an extra multiply */ - r = ecb_ldexpf (x * (0.5f / 0x800000U), e - 126); - - r = neg ? -r : r; - #endif - - return r; - } - - /* convert a double to ieee double/binary64 */ - ecb_function_ ecb_const uint64_t ecb_double_to_binary64 (double x); - ecb_function_ ecb_const uint64_t - ecb_double_to_binary64 (double x) - { - uint64_t r; - - #if ECB_STDFP - memcpy (&r, &x, 8); - #else - /* slow emulation, works for anything but -0 */ - uint64_t m; - int e; - - if (x == 0e0 ) return 0x0000000000000000U; - if (x > +1.79769313486231470e+308) return 0x7ff0000000000000U; - if (x < -1.79769313486231470e+308) return 0xfff0000000000000U; - if (x != x ) return 0X7ff7ffffffffffffU; - - m = frexp (x, &e) * 0x20000000000000U; - - r = m & 0x8000000000000000;; - - if (r) - m = -m; - - if (e <= -1022) - { - m &= 0x1fffffffffffffU; - m >>= (-1021 - e); - e = -1022; - } - - r |= ((uint64_t)(e + 1022)) << 52; - r |= m & 0xfffffffffffffU; - #endif - - return r; - } - - /* converts an ieee double/binary64 to a double */ - ecb_function_ ecb_const double ecb_binary64_to_double (uint64_t x); - ecb_function_ ecb_const double - ecb_binary64_to_double (uint64_t x) - { - double r; - - #if ECB_STDFP - memcpy (&r, &x, 8); - #else - /* emulation, only works for normals and subnormals and +0 */ - int neg = x >> 63; - int e = (x >> 52) & 0x7ffU; - - x &= 0xfffffffffffffU; - - if (e) - x |= 0x10000000000000U; - else - e = 1; - - /* we distrust ldexp a bit and do the 2**-53 scaling by an extra multiply */ - r = ldexp (x * (0.5 / 0x10000000000000U), e - 1022); - - r = neg ? -r : r; - #endif - - return r; - } - - /* convert a float to ieee half/binary16 */ - ecb_function_ ecb_const uint16_t ecb_float_to_binary16 (float x); - ecb_function_ ecb_const uint16_t - ecb_float_to_binary16 (float x) - { - return ecb_binary32_to_binary16 (ecb_float_to_binary32 (x)); - } - - /* convert an ieee half/binary16 to float */ - ecb_function_ ecb_const float ecb_binary16_to_float (uint16_t x); - ecb_function_ ecb_const float - ecb_binary16_to_float (uint16_t x) - { - return ecb_binary32_to_float (ecb_binary16_to_binary32 (x)); - } - -#endif - -#endif - -/* ECB.H END */ - -#if ECB_MEMORY_FENCE_NEEDS_PTHREADS -/* if your architecture doesn't need memory fences, e.g. because it is - * single-cpu/core, or if you use libev in a project that doesn't use libev - * from multiple threads, then you can define ECB_NO_THREADS when compiling - * libev, in which cases the memory fences become nops. - * alternatively, you can remove this #error and link against libpthread, - * which will then provide the memory fences. - */ -# error "memory fences not defined for your architecture, please report" -#endif - -#ifndef ECB_MEMORY_FENCE -# define ECB_MEMORY_FENCE do { } while (0) -# define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE -# define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE -#endif - -#define inline_size ecb_inline - -#if EV_FEATURE_CODE -# define inline_speed ecb_inline -#else -# define inline_speed ecb_noinline static -#endif - -/*****************************************************************************/ -/* raw syscall wrappers */ - -#if EV_NEED_SYSCALL - -#include - -/* - * define some syscall wrappers for common architectures - * this is mostly for nice looks during debugging, not performance. - * our syscalls return < 0, not == -1, on error. which is good - * enough for linux aio. - * TODO: arm is also common nowadays, maybe even mips and x86 - * TODO: after implementing this, it suddenly looks like overkill, but its hard to remove... - */ -#if __GNUC__ && __linux && ECB_AMD64 && !EV_FEATURE_CODE - /* the costly errno access probably kills this for size optimisation */ - - #define ev_syscall(nr,narg,arg1,arg2,arg3,arg4,arg5,arg6) \ - ({ \ - long res; \ - register unsigned long r6 __asm__ ("r9" ); \ - register unsigned long r5 __asm__ ("r8" ); \ - register unsigned long r4 __asm__ ("r10"); \ - register unsigned long r3 __asm__ ("rdx"); \ - register unsigned long r2 __asm__ ("rsi"); \ - register unsigned long r1 __asm__ ("rdi"); \ - if (narg >= 6) r6 = (unsigned long)(arg6); \ - if (narg >= 5) r5 = (unsigned long)(arg5); \ - if (narg >= 4) r4 = (unsigned long)(arg4); \ - if (narg >= 3) r3 = (unsigned long)(arg3); \ - if (narg >= 2) r2 = (unsigned long)(arg2); \ - if (narg >= 1) r1 = (unsigned long)(arg1); \ - __asm__ __volatile__ ( \ - "syscall\n\t" \ - : "=a" (res) \ - : "0" (nr), "r" (r1), "r" (r2), "r" (r3), "r" (r4), "r" (r5) \ - : "cc", "r11", "cx", "memory"); \ - errno = -res; \ - res; \ - }) - -#endif - -#ifdef ev_syscall - #define ev_syscall0(nr) ev_syscall (nr, 0, 0, 0, 0, 0, 0, 0) - #define ev_syscall1(nr,arg1) ev_syscall (nr, 1, arg1, 0, 0, 0, 0, 0) - #define ev_syscall2(nr,arg1,arg2) ev_syscall (nr, 2, arg1, arg2, 0, 0, 0, 0) - #define ev_syscall3(nr,arg1,arg2,arg3) ev_syscall (nr, 3, arg1, arg2, arg3, 0, 0, 0) - #define ev_syscall4(nr,arg1,arg2,arg3,arg4) ev_syscall (nr, 3, arg1, arg2, arg3, arg4, 0, 0) - #define ev_syscall5(nr,arg1,arg2,arg3,arg4,arg5) ev_syscall (nr, 5, arg1, arg2, arg3, arg4, arg5, 0) - #define ev_syscall6(nr,arg1,arg2,arg3,arg4,arg5,arg6) ev_syscall (nr, 6, arg1, arg2, arg3, arg4, arg5,arg6) -#else - #define ev_syscall0(nr) syscall (nr) - #define ev_syscall1(nr,arg1) syscall (nr, arg1) - #define ev_syscall2(nr,arg1,arg2) syscall (nr, arg1, arg2) - #define ev_syscall3(nr,arg1,arg2,arg3) syscall (nr, arg1, arg2, arg3) - #define ev_syscall4(nr,arg1,arg2,arg3,arg4) syscall (nr, arg1, arg2, arg3, arg4) - #define ev_syscall5(nr,arg1,arg2,arg3,arg4,arg5) syscall (nr, arg1, arg2, arg3, arg4, arg5) - #define ev_syscall6(nr,arg1,arg2,arg3,arg4,arg5,arg6) syscall (nr, arg1, arg2, arg3, arg4, arg5,arg6) -#endif - -#endif - -/*****************************************************************************/ - -#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) - -#if EV_MINPRI == EV_MAXPRI -# define ABSPRI(w) (((W)w), 0) -#else -# define ABSPRI(w) (((W)w)->priority - EV_MINPRI) -#endif - -#define EMPTY /* required for microsofts broken pseudo-c compiler */ - -typedef ev_watcher *W; -typedef ev_watcher_list *WL; -typedef ev_watcher_time *WT; - -#define ev_active(w) ((W)(w))->active -#define ev_at(w) ((WT)(w))->at - -#if EV_USE_REALTIME -/* sig_atomic_t is used to avoid per-thread variables or locking but still */ -/* giving it a reasonably high chance of working on typical architectures */ -static EV_ATOMIC_T have_realtime; /* did clock_gettime (CLOCK_REALTIME) work? */ -#endif - -#if EV_USE_MONOTONIC -static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ -#endif - -#ifndef EV_FD_TO_WIN32_HANDLE -# define EV_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd) -#endif -#ifndef EV_WIN32_HANDLE_TO_FD -# define EV_WIN32_HANDLE_TO_FD(handle) _open_osfhandle (handle, 0) -#endif -#ifndef EV_WIN32_CLOSE_FD -# define EV_WIN32_CLOSE_FD(fd) close (fd) -#endif - -#ifdef _WIN32 -# include "ev_win32.c" -#endif - -/*****************************************************************************/ - -#if EV_USE_LINUXAIO -# include /* probably only needed for aio_context_t */ -#endif - -/* define a suitable floor function (only used by periodics atm) */ - -#if EV_USE_FLOOR -# include -# define ev_floor(v) floor (v) -#else - -#include - -/* a floor() replacement function, should be independent of ev_tstamp type */ -ecb_noinline -static ev_tstamp -ev_floor (ev_tstamp v) -{ - /* the choice of shift factor is not terribly important */ -#if FLT_RADIX != 2 /* assume FLT_RADIX == 10 */ - const ev_tstamp shift = sizeof (unsigned long) >= 8 ? 10000000000000000000. : 1000000000.; -#else - const ev_tstamp shift = sizeof (unsigned long) >= 8 ? 18446744073709551616. : 4294967296.; -#endif - - /* special treatment for negative arguments */ - if (ecb_expect_false (v < 0.)) - { - ev_tstamp f = -ev_floor (-v); - - return f - (f == v ? 0 : 1); - } - - /* argument too large for an unsigned long? then reduce it */ - if (ecb_expect_false (v >= shift)) - { - ev_tstamp f; - - if (v == v - 1.) - return v; /* very large numbers are assumed to be integer */ - - f = shift * ev_floor (v * (1. / shift)); - return f + ev_floor (v - f); - } - - /* fits into an unsigned long */ - return (unsigned long)v; -} - -#endif - -/*****************************************************************************/ - -#ifdef __linux -# include -#endif - -ecb_noinline ecb_cold -static unsigned int -ev_linux_version (void) -{ -#ifdef __linux - unsigned int v = 0; - struct utsname buf; - int i; - char *p = buf.release; - - if (uname (&buf)) - return 0; - - for (i = 3+1; --i; ) - { - unsigned int c = 0; - - for (;;) - { - if (*p >= '0' && *p <= '9') - c = c * 10 + *p++ - '0'; - else - { - p += *p == '.'; - break; - } - } - - v = (v << 8) | c; - } - - return v; -#else - return 0; -#endif -} - -/*****************************************************************************/ - -#if EV_AVOID_STDIO -ecb_noinline ecb_cold -static void -ev_printerr (const char *msg) -{ - write (STDERR_FILENO, msg, strlen (msg)); -} -#endif - -static void (*syserr_cb)(const char *msg) EV_NOEXCEPT; - -ecb_cold -void -ev_set_syserr_cb (void (*cb)(const char *msg) EV_NOEXCEPT) EV_NOEXCEPT -{ - syserr_cb = cb; -} - -ecb_noinline ecb_cold -static void -ev_syserr (const char *msg) -{ - if (!msg) - msg = "(libev) system error"; - - if (syserr_cb) - syserr_cb (msg); - else - { -#if EV_AVOID_STDIO - ev_printerr (msg); - ev_printerr (": "); - ev_printerr (strerror (errno)); - ev_printerr ("\n"); -#else - perror (msg); -#endif - abort (); - } -} - -static void * -ev_realloc_emul (void *ptr, long size) EV_NOEXCEPT -{ - /* some systems, notably openbsd and darwin, fail to properly - * implement realloc (x, 0) (as required by both ansi c-89 and - * the single unix specification, so work around them here. - * recently, also (at least) fedora and debian started breaking it, - * despite documenting it otherwise. - */ - - if (size) - return realloc (ptr, size); - - free (ptr); - return 0; -} - -static void *(*alloc)(void *ptr, long size) EV_NOEXCEPT = ev_realloc_emul; - -ecb_cold -void -ev_set_allocator (void *(*cb)(void *ptr, long size) EV_NOEXCEPT) EV_NOEXCEPT -{ - alloc = cb; -} - -inline_speed void * -ev_realloc (void *ptr, long size) -{ - ptr = alloc (ptr, size); - - if (!ptr && size) - { -#if EV_AVOID_STDIO - ev_printerr ("(libev) memory allocation failed, aborting.\n"); -#else - fprintf (stderr, "(libev) cannot allocate %ld bytes, aborting.", size); -#endif - abort (); - } - - return ptr; -} - -#define ev_malloc(size) ev_realloc (0, (size)) -#define ev_free(ptr) ev_realloc ((ptr), 0) - -/*****************************************************************************/ - -/* set in reify when reification needed */ -#define EV_ANFD_REIFY 1 - -/* file descriptor info structure */ -typedef struct -{ - WL head; - unsigned char events; /* the events watched for */ - unsigned char reify; /* flag set when this ANFD needs reification (EV_ANFD_REIFY, EV__IOFDSET) */ - unsigned char emask; /* some backends store the actual kernel mask in here */ - unsigned char eflags; /* flags field for use by backends */ -#if EV_USE_EPOLL - unsigned int egen; /* generation counter to counter epoll bugs */ -#endif -#if EV_SELECT_IS_WINSOCKET || EV_USE_IOCP - SOCKET handle; -#endif -#if EV_USE_IOCP - OVERLAPPED or, ow; -#endif -} ANFD; - -/* stores the pending event set for a given watcher */ -typedef struct -{ - W w; - int events; /* the pending event set for the given watcher */ -} ANPENDING; - -#if EV_USE_INOTIFY -/* hash table entry per inotify-id */ -typedef struct -{ - WL head; -} ANFS; -#endif - -/* Heap Entry */ -#if EV_HEAP_CACHE_AT - /* a heap element */ - typedef struct { - ev_tstamp at; - WT w; - } ANHE; - - #define ANHE_w(he) (he).w /* access watcher, read-write */ - #define ANHE_at(he) (he).at /* access cached at, read-only */ - #define ANHE_at_cache(he) (he).at = (he).w->at /* update at from watcher */ -#else - /* a heap element */ - typedef WT ANHE; - - #define ANHE_w(he) (he) - #define ANHE_at(he) (he)->at - #define ANHE_at_cache(he) -#endif - -#if EV_MULTIPLICITY - - struct ev_loop - { - ev_tstamp ev_rt_now; - #define ev_rt_now ((loop)->ev_rt_now) - #define VAR(name,decl) decl; - #include "ev_vars.h" - #undef VAR - }; - #include "ev_wrap.h" - - static struct ev_loop default_loop_struct; - EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */ - -#else - - EV_API_DECL ev_tstamp ev_rt_now = EV_TS_CONST (0.); /* needs to be initialised to make it a definition despite extern */ - #define VAR(name,decl) static decl; - #include "ev_vars.h" - #undef VAR - - static int ev_default_loop_ptr; - -#endif - -#if EV_FEATURE_API -# define EV_RELEASE_CB if (ecb_expect_false (release_cb)) release_cb (EV_A) -# define EV_ACQUIRE_CB if (ecb_expect_false (acquire_cb)) acquire_cb (EV_A) -# define EV_INVOKE_PENDING invoke_cb (EV_A) -#else -# define EV_RELEASE_CB (void)0 -# define EV_ACQUIRE_CB (void)0 -# define EV_INVOKE_PENDING ev_invoke_pending (EV_A) -#endif - -#define EVBREAK_RECURSE 0x80 - -/*****************************************************************************/ - -#ifndef EV_HAVE_EV_TIME -ev_tstamp -ev_time (void) EV_NOEXCEPT -{ -#if EV_USE_REALTIME - if (ecb_expect_true (have_realtime)) - { - struct timespec ts; - clock_gettime (CLOCK_REALTIME, &ts); - return EV_TS_GET (ts); - } -#endif - - { - struct timeval tv; - gettimeofday (&tv, 0); - return EV_TV_GET (tv); - } -} -#endif - -inline_size ev_tstamp -get_clock (void) -{ -#if EV_USE_MONOTONIC - if (ecb_expect_true (have_monotonic)) - { - struct timespec ts; - clock_gettime (CLOCK_MONOTONIC, &ts); - return EV_TS_GET (ts); - } -#endif - - return ev_time (); -} - -#if EV_MULTIPLICITY -ev_tstamp -ev_now (EV_P) EV_NOEXCEPT -{ - return ev_rt_now; -} -#endif - -void -ev_sleep (ev_tstamp delay) EV_NOEXCEPT -{ - if (delay > EV_TS_CONST (0.)) - { -#if EV_USE_NANOSLEEP - struct timespec ts; - - EV_TS_SET (ts, delay); - nanosleep (&ts, 0); -#elif defined _WIN32 - /* maybe this should round up, as ms is very low resolution */ - /* compared to select (µs) or nanosleep (ns) */ - Sleep ((unsigned long)(EV_TS_TO_MSEC (delay))); -#else - struct timeval tv; - - /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */ - /* something not guaranteed by newer posix versions, but guaranteed */ - /* by older ones */ - EV_TV_SET (tv, delay); - select (0, 0, 0, 0, &tv); -#endif - } -} - -/*****************************************************************************/ - -#define MALLOC_ROUND 4096 /* prefer to allocate in chunks of this size, must be 2**n and >> 4 longs */ - -/* find a suitable new size for the given array, */ -/* hopefully by rounding to a nice-to-malloc size */ -inline_size int -array_nextsize (int elem, int cur, int cnt) -{ - int ncur = cur + 1; - - do - ncur <<= 1; - while (cnt > ncur); - - /* if size is large, round to MALLOC_ROUND - 4 * longs to accommodate malloc overhead */ - if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4) - { - ncur *= elem; - ncur = (ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1); - ncur = ncur - sizeof (void *) * 4; - ncur /= elem; - } - - return ncur; -} - -ecb_noinline ecb_cold -static void * -array_realloc (int elem, void *base, int *cur, int cnt) -{ - *cur = array_nextsize (elem, *cur, cnt); - return ev_realloc (base, elem * *cur); -} - -#define array_needsize_noinit(base,offset,count) - -#define array_needsize_zerofill(base,offset,count) \ - memset ((void *)(base + offset), 0, sizeof (*(base)) * (count)) - -#define array_needsize(type,base,cur,cnt,init) \ - if (ecb_expect_false ((cnt) > (cur))) \ - { \ - ecb_unused int ocur_ = (cur); \ - (base) = (type *)array_realloc \ - (sizeof (type), (base), &(cur), (cnt)); \ - init ((base), ocur_, ((cur) - ocur_)); \ - } - -#if 0 -#define array_slim(type,stem) \ - if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ - { \ - stem ## max = array_roundsize (stem ## cnt >> 1); \ - base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\ - fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ - } -#endif - -#define array_free(stem, idx) \ - ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; stem ## s idx = 0 - -/*****************************************************************************/ - -/* dummy callback for pending events */ -ecb_noinline -static void -pendingcb (EV_P_ ev_prepare *w, int revents) -{ -} - -ecb_noinline -void -ev_feed_event (EV_P_ void *w, int revents) EV_NOEXCEPT -{ - W w_ = (W)w; - int pri = ABSPRI (w_); - - if (ecb_expect_false (w_->pending)) - pendings [pri][w_->pending - 1].events |= revents; - else - { - w_->pending = ++pendingcnt [pri]; - array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, array_needsize_noinit); - pendings [pri][w_->pending - 1].w = w_; - pendings [pri][w_->pending - 1].events = revents; - } - - pendingpri = NUMPRI - 1; -} - -inline_speed void -feed_reverse (EV_P_ W w) -{ - array_needsize (W, rfeeds, rfeedmax, rfeedcnt + 1, array_needsize_noinit); - rfeeds [rfeedcnt++] = w; -} - -inline_size void -feed_reverse_done (EV_P_ int revents) -{ - do - ev_feed_event (EV_A_ rfeeds [--rfeedcnt], revents); - while (rfeedcnt); -} - -inline_speed void -queue_events (EV_P_ W *events, int eventcnt, int type) -{ - int i; - - for (i = 0; i < eventcnt; ++i) - ev_feed_event (EV_A_ events [i], type); -} - -/*****************************************************************************/ - -inline_speed void -fd_event_nocheck (EV_P_ int fd, int revents) -{ - ANFD *anfd = anfds + fd; - ev_io *w; - - for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) - { - int ev = w->events & revents; - - if (ev) - ev_feed_event (EV_A_ (W)w, ev); - } -} - -/* do not submit kernel events for fds that have reify set */ -/* because that means they changed while we were polling for new events */ -inline_speed void -fd_event (EV_P_ int fd, int revents) -{ - ANFD *anfd = anfds + fd; - - if (ecb_expect_true (!anfd->reify)) - fd_event_nocheck (EV_A_ fd, revents); -} - -void -ev_feed_fd_event (EV_P_ int fd, int revents) EV_NOEXCEPT -{ - if (fd >= 0 && fd < anfdmax) - fd_event_nocheck (EV_A_ fd, revents); -} - -/* make sure the external fd watch events are in-sync */ -/* with the kernel/libev internal state */ -inline_size void -fd_reify (EV_P) -{ - int i; - - /* most backends do not modify the fdchanges list in backend_modfiy. - * except io_uring, which has fixed-size buffers which might force us - * to handle events in backend_modify, causing fdchanges to be amended, - * which could result in an endless loop. - * to avoid this, we do not dynamically handle fds that were added - * during fd_reify. that means that for those backends, fdchangecnt - * might be non-zero during poll, which must cause them to not block. - * to not put too much of a burden on other backends, this detail - * needs to be handled in the backend. - */ - int changecnt = fdchangecnt; - -#if EV_SELECT_IS_WINSOCKET || EV_USE_IOCP - for (i = 0; i < changecnt; ++i) - { - int fd = fdchanges [i]; - ANFD *anfd = anfds + fd; - - if (anfd->reify & EV__IOFDSET && anfd->head) - { - SOCKET handle = EV_FD_TO_WIN32_HANDLE (fd); - - if (handle != anfd->handle) - { - unsigned long arg; - - assert (("libev: only socket fds supported in this configuration", ioctlsocket (handle, FIONREAD, &arg) == 0)); - - /* handle changed, but fd didn't - we need to do it in two steps */ - backend_modify (EV_A_ fd, anfd->events, 0); - anfd->events = 0; - anfd->handle = handle; - } - } - } -#endif - - for (i = 0; i < changecnt; ++i) - { - int fd = fdchanges [i]; - ANFD *anfd = anfds + fd; - ev_io *w; - - unsigned char o_events = anfd->events; - unsigned char o_reify = anfd->reify; - - anfd->reify = 0; - - /*if (ecb_expect_true (o_reify & EV_ANFD_REIFY)) probably a deoptimisation */ - { - anfd->events = 0; - - for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) - anfd->events |= (unsigned char)w->events; - - if (o_events != anfd->events) - o_reify = EV__IOFDSET; /* actually |= */ - } - - if (o_reify & EV__IOFDSET) - backend_modify (EV_A_ fd, o_events, anfd->events); - } - - /* normally, fdchangecnt hasn't changed. if it has, then new fds have been added. - * this is a rare case (see beginning comment in this function), so we copy them to the - * front and hope the backend handles this case. - */ - if (ecb_expect_false (fdchangecnt != changecnt)) - memmove (fdchanges, fdchanges + changecnt, (fdchangecnt - changecnt) * sizeof (*fdchanges)); - - fdchangecnt -= changecnt; -} - -/* something about the given fd changed */ -inline_size -void -fd_change (EV_P_ int fd, int flags) -{ - unsigned char reify = anfds [fd].reify; - anfds [fd].reify = reify | flags; - - if (ecb_expect_true (!reify)) - { - ++fdchangecnt; - array_needsize (int, fdchanges, fdchangemax, fdchangecnt, array_needsize_noinit); - fdchanges [fdchangecnt - 1] = fd; - } -} - -/* the given fd is invalid/unusable, so make sure it doesn't hurt us anymore */ -inline_speed ecb_cold void -fd_kill (EV_P_ int fd) -{ - ev_io *w; - - while ((w = (ev_io *)anfds [fd].head)) - { - ev_io_stop (EV_A_ w); - ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); - } -} - -/* check whether the given fd is actually valid, for error recovery */ -inline_size ecb_cold int -fd_valid (int fd) -{ -#ifdef _WIN32 - return EV_FD_TO_WIN32_HANDLE (fd) != -1; -#else - return fcntl (fd, F_GETFD) != -1; -#endif -} - -/* called on EBADF to verify fds */ -ecb_noinline ecb_cold -static void -fd_ebadf (EV_P) -{ - int fd; - - for (fd = 0; fd < anfdmax; ++fd) - if (anfds [fd].events) - if (!fd_valid (fd) && errno == EBADF) - fd_kill (EV_A_ fd); -} - -/* called on ENOMEM in select/poll to kill some fds and retry */ -ecb_noinline ecb_cold -static void -fd_enomem (EV_P) -{ - int fd; - - for (fd = anfdmax; fd--; ) - if (anfds [fd].events) - { - fd_kill (EV_A_ fd); - break; - } -} - -/* usually called after fork if backend needs to re-arm all fds from scratch */ -ecb_noinline -static void -fd_rearm_all (EV_P) -{ - int fd; - - for (fd = 0; fd < anfdmax; ++fd) - if (anfds [fd].events) - { - anfds [fd].events = 0; - anfds [fd].emask = 0; - fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY); - } -} - -/* used to prepare libev internal fd's */ -/* this is not fork-safe */ -inline_speed void -fd_intern (int fd) -{ -#ifdef _WIN32 - unsigned long arg = 1; - ioctlsocket (EV_FD_TO_WIN32_HANDLE (fd), FIONBIO, &arg); -#else - fcntl (fd, F_SETFD, FD_CLOEXEC); - fcntl (fd, F_SETFL, O_NONBLOCK); -#endif -} - -/*****************************************************************************/ - -/* - * the heap functions want a real array index. array index 0 is guaranteed to not - * be in-use at any time. the first heap entry is at array [HEAP0]. DHEAP gives - * the branching factor of the d-tree. - */ - -/* - * at the moment we allow libev the luxury of two heaps, - * a small-code-size 2-heap one and a ~1.5kb larger 4-heap - * which is more cache-efficient. - * the difference is about 5% with 50000+ watchers. - */ -#if EV_USE_4HEAP - -#define DHEAP 4 -#define HEAP0 (DHEAP - 1) /* index of first element in heap */ -#define HPARENT(k) ((((k) - HEAP0 - 1) / DHEAP) + HEAP0) -#define UPHEAP_DONE(p,k) ((p) == (k)) - -/* away from the root */ -inline_speed void -downheap (ANHE *heap, int N, int k) -{ - ANHE he = heap [k]; - ANHE *E = heap + N + HEAP0; - - for (;;) - { - ev_tstamp minat; - ANHE *minpos; - ANHE *pos = heap + DHEAP * (k - HEAP0) + HEAP0 + 1; - - /* find minimum child */ - if (ecb_expect_true (pos + DHEAP - 1 < E)) - { - /* fast path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); - if ( minat > ANHE_at (pos [1])) (minpos = pos + 1), (minat = ANHE_at (*minpos)); - if ( minat > ANHE_at (pos [2])) (minpos = pos + 2), (minat = ANHE_at (*minpos)); - if ( minat > ANHE_at (pos [3])) (minpos = pos + 3), (minat = ANHE_at (*minpos)); - } - else if (pos < E) - { - /* slow path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); - if (pos + 1 < E && minat > ANHE_at (pos [1])) (minpos = pos + 1), (minat = ANHE_at (*minpos)); - if (pos + 2 < E && minat > ANHE_at (pos [2])) (minpos = pos + 2), (minat = ANHE_at (*minpos)); - if (pos + 3 < E && minat > ANHE_at (pos [3])) (minpos = pos + 3), (minat = ANHE_at (*minpos)); - } - else - break; - - if (ANHE_at (he) <= minat) - break; - - heap [k] = *minpos; - ev_active (ANHE_w (*minpos)) = k; - - k = minpos - heap; - } - - heap [k] = he; - ev_active (ANHE_w (he)) = k; -} - -#else /* not 4HEAP */ - -#define HEAP0 1 -#define HPARENT(k) ((k) >> 1) -#define UPHEAP_DONE(p,k) (!(p)) - -/* away from the root */ -inline_speed void -downheap (ANHE *heap, int N, int k) -{ - ANHE he = heap [k]; - - for (;;) - { - int c = k << 1; - - if (c >= N + HEAP0) - break; - - c += c + 1 < N + HEAP0 && ANHE_at (heap [c]) > ANHE_at (heap [c + 1]) - ? 1 : 0; - - if (ANHE_at (he) <= ANHE_at (heap [c])) - break; - - heap [k] = heap [c]; - ev_active (ANHE_w (heap [k])) = k; - - k = c; - } - - heap [k] = he; - ev_active (ANHE_w (he)) = k; -} -#endif - -/* towards the root */ -inline_speed void -upheap (ANHE *heap, int k) -{ - ANHE he = heap [k]; - - for (;;) - { - int p = HPARENT (k); - - if (UPHEAP_DONE (p, k) || ANHE_at (heap [p]) <= ANHE_at (he)) - break; - - heap [k] = heap [p]; - ev_active (ANHE_w (heap [k])) = k; - k = p; - } - - heap [k] = he; - ev_active (ANHE_w (he)) = k; -} - -/* move an element suitably so it is in a correct place */ -inline_size void -adjustheap (ANHE *heap, int N, int k) -{ - if (k > HEAP0 && ANHE_at (heap [k]) <= ANHE_at (heap [HPARENT (k)])) - upheap (heap, k); - else - downheap (heap, N, k); -} - -/* rebuild the heap: this function is used only once and executed rarely */ -inline_size void -reheap (ANHE *heap, int N) -{ - int i; - - /* we don't use floyds algorithm, upheap is simpler and is more cache-efficient */ - /* also, this is easy to implement and correct for both 2-heaps and 4-heaps */ - for (i = 0; i < N; ++i) - upheap (heap, i + HEAP0); -} - -/*****************************************************************************/ - -/* associate signal watchers to a signal */ -typedef struct -{ - EV_ATOMIC_T pending; -#if EV_MULTIPLICITY - EV_P; -#endif - WL head; -} ANSIG; - -static ANSIG signals [EV_NSIG - 1]; - -/*****************************************************************************/ - -#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE - -ecb_noinline ecb_cold -static void -evpipe_init (EV_P) -{ - if (!ev_is_active (&pipe_w)) - { - int fds [2]; - -# if EV_USE_EVENTFD - fds [0] = -1; - fds [1] = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC); - if (fds [1] < 0 && errno == EINVAL) - fds [1] = eventfd (0, 0); - - if (fds [1] < 0) -# endif - { - while (pipe (fds)) - ev_syserr ("(libev) error creating signal/async pipe"); - - fd_intern (fds [0]); - } - - evpipe [0] = fds [0]; - - if (evpipe [1] < 0) - evpipe [1] = fds [1]; /* first call, set write fd */ - else - { - /* on subsequent calls, do not change evpipe [1] */ - /* so that evpipe_write can always rely on its value. */ - /* this branch does not do anything sensible on windows, */ - /* so must not be executed on windows */ - - dup2 (fds [1], evpipe [1]); - close (fds [1]); - } - - fd_intern (evpipe [1]); - - ev_io_set (&pipe_w, evpipe [0] < 0 ? evpipe [1] : evpipe [0], EV_READ); - ev_io_start (EV_A_ &pipe_w); - ev_unref (EV_A); /* watcher should not keep loop alive */ - } -} - -inline_speed void -evpipe_write (EV_P_ EV_ATOMIC_T *flag) -{ - ECB_MEMORY_FENCE; /* push out the write before this function was called, acquire flag */ - - if (ecb_expect_true (*flag)) - return; - - *flag = 1; - ECB_MEMORY_FENCE_RELEASE; /* make sure flag is visible before the wakeup */ - - pipe_write_skipped = 1; - - ECB_MEMORY_FENCE; /* make sure pipe_write_skipped is visible before we check pipe_write_wanted */ - - if (pipe_write_wanted) - { - int old_errno; - - pipe_write_skipped = 0; - ECB_MEMORY_FENCE_RELEASE; - - old_errno = errno; /* save errno because write will clobber it */ - -#if EV_USE_EVENTFD - if (evpipe [0] < 0) - { - uint64_t counter = 1; - write (evpipe [1], &counter, sizeof (uint64_t)); - } - else -#endif - { -#ifdef _WIN32 - WSABUF buf; - DWORD sent; - buf.buf = (char *)&buf; - buf.len = 1; - WSASend (EV_FD_TO_WIN32_HANDLE (evpipe [1]), &buf, 1, &sent, 0, 0, 0); -#else - write (evpipe [1], &(evpipe [1]), 1); -#endif - } - - errno = old_errno; - } -} - -/* called whenever the libev signal pipe */ -/* got some events (signal, async) */ -static void -pipecb (EV_P_ ev_io *iow, int revents) -{ - int i; - - if (revents & EV_READ) - { -#if EV_USE_EVENTFD - if (evpipe [0] < 0) - { - uint64_t counter; - read (evpipe [1], &counter, sizeof (uint64_t)); - } - else -#endif - { - char dummy[4]; -#ifdef _WIN32 - WSABUF buf; - DWORD recvd; - DWORD flags = 0; - buf.buf = dummy; - buf.len = sizeof (dummy); - WSARecv (EV_FD_TO_WIN32_HANDLE (evpipe [0]), &buf, 1, &recvd, &flags, 0, 0); -#else - read (evpipe [0], &dummy, sizeof (dummy)); -#endif - } - } - - pipe_write_skipped = 0; - - ECB_MEMORY_FENCE; /* push out skipped, acquire flags */ - -#if EV_SIGNAL_ENABLE - if (sig_pending) - { - sig_pending = 0; - - ECB_MEMORY_FENCE; - - for (i = EV_NSIG - 1; i--; ) - if (ecb_expect_false (signals [i].pending)) - ev_feed_signal_event (EV_A_ i + 1); - } -#endif - -#if EV_ASYNC_ENABLE - if (async_pending) - { - async_pending = 0; - - ECB_MEMORY_FENCE; - - for (i = asynccnt; i--; ) - if (asyncs [i]->sent) - { - asyncs [i]->sent = 0; - ECB_MEMORY_FENCE_RELEASE; - ev_feed_event (EV_A_ asyncs [i], EV_ASYNC); - } - } -#endif -} - -/*****************************************************************************/ - -void -ev_feed_signal (int signum) EV_NOEXCEPT -{ -#if EV_MULTIPLICITY - EV_P; - ECB_MEMORY_FENCE_ACQUIRE; - EV_A = signals [signum - 1].loop; - - if (!EV_A) - return; -#endif - - signals [signum - 1].pending = 1; - evpipe_write (EV_A_ &sig_pending); -} - -static void -ev_sighandler (int signum) -{ -#ifdef _WIN32 - signal (signum, ev_sighandler); -#endif - - ev_feed_signal (signum); -} - -ecb_noinline -void -ev_feed_signal_event (EV_P_ int signum) EV_NOEXCEPT -{ - WL w; - - if (ecb_expect_false (signum <= 0 || signum >= EV_NSIG)) - return; - - --signum; - -#if EV_MULTIPLICITY - /* it is permissible to try to feed a signal to the wrong loop */ - /* or, likely more useful, feeding a signal nobody is waiting for */ - - if (ecb_expect_false (signals [signum].loop != EV_A)) - return; -#endif - - signals [signum].pending = 0; - ECB_MEMORY_FENCE_RELEASE; - - for (w = signals [signum].head; w; w = w->next) - ev_feed_event (EV_A_ (W)w, EV_SIGNAL); -} - -#if EV_USE_SIGNALFD -static void -sigfdcb (EV_P_ ev_io *iow, int revents) -{ - struct signalfd_siginfo si[2], *sip; /* these structs are big */ - - for (;;) - { - ssize_t res = read (sigfd, si, sizeof (si)); - - /* not ISO-C, as res might be -1, but works with SuS */ - for (sip = si; (char *)sip < (char *)si + res; ++sip) - ev_feed_signal_event (EV_A_ sip->ssi_signo); - - if (res < (ssize_t)sizeof (si)) - break; - } -} -#endif - -#endif - -/*****************************************************************************/ - -#if EV_CHILD_ENABLE -static WL childs [EV_PID_HASHSIZE]; - -static ev_signal childev; - -#ifndef WIFCONTINUED -# define WIFCONTINUED(status) 0 -#endif - -/* handle a single child status event */ -inline_speed void -child_reap (EV_P_ int chain, int pid, int status) -{ - ev_child *w; - int traced = WIFSTOPPED (status) || WIFCONTINUED (status); - - for (w = (ev_child *)childs [chain & ((EV_PID_HASHSIZE) - 1)]; w; w = (ev_child *)((WL)w)->next) - { - if ((w->pid == pid || !w->pid) - && (!traced || (w->flags & 1))) - { - ev_set_priority (w, EV_MAXPRI); /* need to do it *now*, this *must* be the same prio as the signal watcher itself */ - w->rpid = pid; - w->rstatus = status; - ev_feed_event (EV_A_ (W)w, EV_CHILD); - } - } -} - -#ifndef WCONTINUED -# define WCONTINUED 0 -#endif - -/* called on sigchld etc., calls waitpid */ -static void -childcb (EV_P_ ev_signal *sw, int revents) -{ - int pid, status; - - /* some systems define WCONTINUED but then fail to support it (linux 2.4) */ - if (0 >= (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED))) - if (!WCONTINUED - || errno != EINVAL - || 0 >= (pid = waitpid (-1, &status, WNOHANG | WUNTRACED))) - return; - - /* make sure we are called again until all children have been reaped */ - /* we need to do it this way so that the callback gets called before we continue */ - ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); - - child_reap (EV_A_ pid, pid, status); - if ((EV_PID_HASHSIZE) > 1) - child_reap (EV_A_ 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */ -} - -#endif - -/*****************************************************************************/ - -#if EV_USE_TIMERFD - -static void periodics_reschedule (EV_P); - -static void -timerfdcb (EV_P_ ev_io *iow, int revents) -{ - struct itimerspec its = { 0 }; - - its.it_value.tv_sec = ev_rt_now + (int)MAX_BLOCKTIME2; - timerfd_settime (timerfd, TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET, &its, 0); - - ev_rt_now = ev_time (); - /* periodics_reschedule only needs ev_rt_now */ - /* but maybe in the future we want the full treatment. */ - /* - now_floor = EV_TS_CONST (0.); - time_update (EV_A_ EV_TSTAMP_HUGE); - */ -#if EV_PERIODIC_ENABLE - periodics_reschedule (EV_A); -#endif -} - -ecb_noinline ecb_cold -static void -evtimerfd_init (EV_P) -{ - if (!ev_is_active (&timerfd_w)) - { - timerfd = timerfd_create (CLOCK_REALTIME, TFD_NONBLOCK | TFD_CLOEXEC); - - if (timerfd >= 0) - { - fd_intern (timerfd); /* just to be sure */ - - ev_io_init (&timerfd_w, timerfdcb, timerfd, EV_READ); - ev_set_priority (&timerfd_w, EV_MINPRI); - ev_io_start (EV_A_ &timerfd_w); - ev_unref (EV_A); /* watcher should not keep loop alive */ - - /* (re-) arm timer */ - timerfdcb (EV_A_ 0, 0); - } - } -} - -#endif - -/*****************************************************************************/ - -#if EV_USE_IOCP -# include "ev_iocp.c" -#endif -#if EV_USE_PORT -# include "ev_port.c" -#endif -#if EV_USE_KQUEUE -# include "ev_kqueue.c" -#endif -#if EV_USE_EPOLL -# include "ev_epoll.c" -#endif -#if EV_USE_LINUXAIO -# include "ev_linuxaio.c" -#endif -#if EV_USE_IOURING -# include "ev_iouring.c" -#endif -#if EV_USE_POLL -# include "ev_poll.c" -#endif -#if EV_USE_SELECT -# include "ev_select.c" -#endif - -ecb_cold int -ev_version_major (void) EV_NOEXCEPT -{ - return EV_VERSION_MAJOR; -} - -ecb_cold int -ev_version_minor (void) EV_NOEXCEPT -{ - return EV_VERSION_MINOR; -} - -/* return true if we are running with elevated privileges and should ignore env variables */ -inline_size ecb_cold int -enable_secure (void) -{ -#ifdef _WIN32 - return 0; -#else - return getuid () != geteuid () - || getgid () != getegid (); -#endif -} - -ecb_cold -unsigned int -ev_supported_backends (void) EV_NOEXCEPT -{ - unsigned int flags = 0; - - if (EV_USE_PORT ) flags |= EVBACKEND_PORT; - if (EV_USE_KQUEUE ) flags |= EVBACKEND_KQUEUE; - if (EV_USE_EPOLL ) flags |= EVBACKEND_EPOLL; - if (EV_USE_LINUXAIO ) flags |= EVBACKEND_LINUXAIO; - if (EV_USE_IOURING && ev_linux_version () >= 0x050601) flags |= EVBACKEND_IOURING; /* 5.6.1+ */ - if (EV_USE_POLL ) flags |= EVBACKEND_POLL; - if (EV_USE_SELECT ) flags |= EVBACKEND_SELECT; - - return flags; -} - -ecb_cold -unsigned int -ev_recommended_backends (void) EV_NOEXCEPT -{ - unsigned int flags = ev_supported_backends (); - -#ifndef __NetBSD__ - /* kqueue is borked on everything but netbsd apparently */ - /* it usually doesn't work correctly on anything but sockets and pipes */ - flags &= ~EVBACKEND_KQUEUE; -#endif -#ifdef __APPLE__ - /* only select works correctly on that "unix-certified" platform */ - flags &= ~EVBACKEND_KQUEUE; /* horribly broken, even for sockets */ - flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */ -#endif -#ifdef __FreeBSD__ - flags &= ~EVBACKEND_POLL; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */ -#endif - - /* TODO: linuxaio is very experimental */ -#if !EV_RECOMMEND_LINUXAIO - flags &= ~EVBACKEND_LINUXAIO; -#endif - /* TODO: iouring is super experimental */ -#if !EV_RECOMMEND_IOURING - flags &= ~EVBACKEND_IOURING; -#endif - - return flags; -} - -ecb_cold -unsigned int -ev_embeddable_backends (void) EV_NOEXCEPT -{ - int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT | EVBACKEND_IOURING; - - /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ - if (ev_linux_version () < 0x020620) /* disable it on linux < 2.6.32 */ - flags &= ~EVBACKEND_EPOLL; - - /* EVBACKEND_LINUXAIO is theoretically embeddable, but suffers from a performance overhead */ - - return flags; -} - -unsigned int -ev_backend (EV_P) EV_NOEXCEPT -{ - return backend; -} - -#if EV_FEATURE_API -unsigned int -ev_iteration (EV_P) EV_NOEXCEPT -{ - return loop_count; -} - -unsigned int -ev_depth (EV_P) EV_NOEXCEPT -{ - return loop_depth; -} - -void -ev_set_io_collect_interval (EV_P_ ev_tstamp interval) EV_NOEXCEPT -{ - io_blocktime = interval; -} - -void -ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_NOEXCEPT -{ - timeout_blocktime = interval; -} - -void -ev_set_userdata (EV_P_ void *data) EV_NOEXCEPT -{ - userdata = data; -} - -void * -ev_userdata (EV_P) EV_NOEXCEPT -{ - return userdata; -} - -void -ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_NOEXCEPT -{ - invoke_cb = invoke_pending_cb; -} - -void -ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_NOEXCEPT, void (*acquire)(EV_P) EV_NOEXCEPT) EV_NOEXCEPT -{ - release_cb = release; - acquire_cb = acquire; -} -#endif - -/* initialise a loop structure, must be zero-initialised */ -ecb_noinline ecb_cold -static void -loop_init (EV_P_ unsigned int flags) EV_NOEXCEPT -{ - if (!backend) - { - origflags = flags; - -#if EV_USE_REALTIME - if (!have_realtime) - { - struct timespec ts; - - if (!clock_gettime (CLOCK_REALTIME, &ts)) - have_realtime = 1; - } -#endif - -#if EV_USE_MONOTONIC - if (!have_monotonic) - { - struct timespec ts; - - if (!clock_gettime (CLOCK_MONOTONIC, &ts)) - have_monotonic = 1; - } -#endif - - /* pid check not overridable via env */ -#ifndef _WIN32 - if (flags & EVFLAG_FORKCHECK) - curpid = getpid (); -#endif - - if (!(flags & EVFLAG_NOENV) - && !enable_secure () - && getenv ("LIBEV_FLAGS")) - flags = atoi (getenv ("LIBEV_FLAGS")); - - ev_rt_now = ev_time (); - mn_now = get_clock (); - now_floor = mn_now; - rtmn_diff = ev_rt_now - mn_now; -#if EV_FEATURE_API - invoke_cb = ev_invoke_pending; -#endif - - io_blocktime = 0.; - timeout_blocktime = 0.; - backend = 0; - backend_fd = -1; - sig_pending = 0; -#if EV_ASYNC_ENABLE - async_pending = 0; -#endif - pipe_write_skipped = 0; - pipe_write_wanted = 0; - evpipe [0] = -1; - evpipe [1] = -1; -#if EV_USE_INOTIFY - fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2; -#endif -#if EV_USE_SIGNALFD - sigfd = flags & EVFLAG_SIGNALFD ? -2 : -1; -#endif -#if EV_USE_TIMERFD - timerfd = flags & EVFLAG_NOTIMERFD ? -1 : -2; -#endif - - if (!(flags & EVBACKEND_MASK)) - flags |= ev_recommended_backends (); - -#if EV_USE_IOCP - if (!backend && (flags & EVBACKEND_IOCP )) backend = iocp_init (EV_A_ flags); -#endif -#if EV_USE_PORT - if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags); -#endif -#if EV_USE_KQUEUE - if (!backend && (flags & EVBACKEND_KQUEUE )) backend = kqueue_init (EV_A_ flags); -#endif -#if EV_USE_IOURING - if (!backend && (flags & EVBACKEND_IOURING )) backend = iouring_init (EV_A_ flags); -#endif -#if EV_USE_LINUXAIO - if (!backend && (flags & EVBACKEND_LINUXAIO)) backend = linuxaio_init (EV_A_ flags); -#endif -#if EV_USE_EPOLL - if (!backend && (flags & EVBACKEND_EPOLL )) backend = epoll_init (EV_A_ flags); -#endif -#if EV_USE_POLL - if (!backend && (flags & EVBACKEND_POLL )) backend = poll_init (EV_A_ flags); -#endif -#if EV_USE_SELECT - if (!backend && (flags & EVBACKEND_SELECT )) backend = select_init (EV_A_ flags); -#endif - - ev_prepare_init (&pending_w, pendingcb); - -#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE - ev_init (&pipe_w, pipecb); - ev_set_priority (&pipe_w, EV_MAXPRI); -#endif - } -} - -/* free up a loop structure */ -ecb_cold -void -ev_loop_destroy (EV_P) -{ - int i; - -#if EV_MULTIPLICITY - /* mimic free (0) */ - if (!EV_A) - return; -#endif - -#if EV_CLEANUP_ENABLE - /* queue cleanup watchers (and execute them) */ - if (ecb_expect_false (cleanupcnt)) - { - queue_events (EV_A_ (W *)cleanups, cleanupcnt, EV_CLEANUP); - EV_INVOKE_PENDING; - } -#endif - -#if EV_CHILD_ENABLE - if (ev_is_default_loop (EV_A) && ev_is_active (&childev)) - { - ev_ref (EV_A); /* child watcher */ - ev_signal_stop (EV_A_ &childev); - } -#endif - - if (ev_is_active (&pipe_w)) - { - /*ev_ref (EV_A);*/ - /*ev_io_stop (EV_A_ &pipe_w);*/ - - if (evpipe [0] >= 0) EV_WIN32_CLOSE_FD (evpipe [0]); - if (evpipe [1] >= 0) EV_WIN32_CLOSE_FD (evpipe [1]); - } - -#if EV_USE_SIGNALFD - if (ev_is_active (&sigfd_w)) - close (sigfd); -#endif - -#if EV_USE_TIMERFD - if (ev_is_active (&timerfd_w)) - close (timerfd); -#endif - -#if EV_USE_INOTIFY - if (fs_fd >= 0) - close (fs_fd); -#endif - - if (backend_fd >= 0) - close (backend_fd); - -#if EV_USE_IOCP - if (backend == EVBACKEND_IOCP ) iocp_destroy (EV_A); -#endif -#if EV_USE_PORT - if (backend == EVBACKEND_PORT ) port_destroy (EV_A); -#endif -#if EV_USE_KQUEUE - if (backend == EVBACKEND_KQUEUE ) kqueue_destroy (EV_A); -#endif -#if EV_USE_IOURING - if (backend == EVBACKEND_IOURING ) iouring_destroy (EV_A); -#endif -#if EV_USE_LINUXAIO - if (backend == EVBACKEND_LINUXAIO) linuxaio_destroy (EV_A); -#endif -#if EV_USE_EPOLL - if (backend == EVBACKEND_EPOLL ) epoll_destroy (EV_A); -#endif -#if EV_USE_POLL - if (backend == EVBACKEND_POLL ) poll_destroy (EV_A); -#endif -#if EV_USE_SELECT - if (backend == EVBACKEND_SELECT ) select_destroy (EV_A); -#endif - - for (i = NUMPRI; i--; ) - { - array_free (pending, [i]); -#if EV_IDLE_ENABLE - array_free (idle, [i]); -#endif - } - - ev_free (anfds); anfds = 0; anfdmax = 0; - - /* have to use the microsoft-never-gets-it-right macro */ - array_free (rfeed, EMPTY); - array_free (fdchange, EMPTY); - array_free (timer, EMPTY); -#if EV_PERIODIC_ENABLE - array_free (periodic, EMPTY); -#endif -#if EV_FORK_ENABLE - array_free (fork, EMPTY); -#endif -#if EV_CLEANUP_ENABLE - array_free (cleanup, EMPTY); -#endif - array_free (prepare, EMPTY); - array_free (check, EMPTY); -#if EV_ASYNC_ENABLE - array_free (async, EMPTY); -#endif - - backend = 0; - -#if EV_MULTIPLICITY - if (ev_is_default_loop (EV_A)) -#endif - ev_default_loop_ptr = 0; -#if EV_MULTIPLICITY - else - ev_free (EV_A); -#endif -} - -#if EV_USE_INOTIFY -inline_size void infy_fork (EV_P); -#endif - -inline_size void -loop_fork (EV_P) -{ -#if EV_USE_PORT - if (backend == EVBACKEND_PORT ) port_fork (EV_A); -#endif -#if EV_USE_KQUEUE - if (backend == EVBACKEND_KQUEUE ) kqueue_fork (EV_A); -#endif -#if EV_USE_IOURING - if (backend == EVBACKEND_IOURING ) iouring_fork (EV_A); -#endif -#if EV_USE_LINUXAIO - if (backend == EVBACKEND_LINUXAIO) linuxaio_fork (EV_A); -#endif -#if EV_USE_EPOLL - if (backend == EVBACKEND_EPOLL ) epoll_fork (EV_A); -#endif -#if EV_USE_INOTIFY - infy_fork (EV_A); -#endif - - if (postfork != 2) - { - #if EV_USE_SIGNALFD - /* surprisingly, nothing needs to be done for signalfd, accoridng to docs, it does the right thing on fork */ - #endif - - #if EV_USE_TIMERFD - if (ev_is_active (&timerfd_w)) - { - ev_ref (EV_A); - ev_io_stop (EV_A_ &timerfd_w); - - close (timerfd); - timerfd = -2; - - evtimerfd_init (EV_A); - /* reschedule periodics, in case we missed something */ - ev_feed_event (EV_A_ &timerfd_w, EV_CUSTOM); - } - #endif - - #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE - if (ev_is_active (&pipe_w)) - { - /* pipe_write_wanted must be false now, so modifying fd vars should be safe */ - - ev_ref (EV_A); - ev_io_stop (EV_A_ &pipe_w); - - if (evpipe [0] >= 0) - EV_WIN32_CLOSE_FD (evpipe [0]); - - evpipe_init (EV_A); - /* iterate over everything, in case we missed something before */ - ev_feed_event (EV_A_ &pipe_w, EV_CUSTOM); - } - #endif - } - - postfork = 0; -} - -#if EV_MULTIPLICITY - -ecb_cold -struct ev_loop * -ev_loop_new (unsigned int flags) EV_NOEXCEPT -{ - EV_P = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop)); - - memset (EV_A, 0, sizeof (struct ev_loop)); - loop_init (EV_A_ flags); - - if (ev_backend (EV_A)) - return EV_A; - - ev_free (EV_A); - return 0; -} - -#endif /* multiplicity */ - -#if EV_VERIFY -ecb_noinline ecb_cold -static void -verify_watcher (EV_P_ W w) -{ - assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI)); - - if (w->pending) - assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w)); -} - -ecb_noinline ecb_cold -static void -verify_heap (EV_P_ ANHE *heap, int N) -{ - int i; - - for (i = HEAP0; i < N + HEAP0; ++i) - { - assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i)); - assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i]))); - assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i])))); - - verify_watcher (EV_A_ (W)ANHE_w (heap [i])); - } -} - -ecb_noinline ecb_cold -static void -array_verify (EV_P_ W *ws, int cnt) -{ - while (cnt--) - { - assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1)); - verify_watcher (EV_A_ ws [cnt]); - } -} -#endif - -#if EV_FEATURE_API -void ecb_cold -ev_verify (EV_P) EV_NOEXCEPT -{ -#if EV_VERIFY - int i; - WL w, w2; - - assert (activecnt >= -1); - - assert (fdchangemax >= fdchangecnt); - for (i = 0; i < fdchangecnt; ++i) - assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0)); - - assert (anfdmax >= 0); - for (i = 0; i < anfdmax; ++i) - { - int j = 0; - - for (w = w2 = anfds [i].head; w; w = w->next) - { - verify_watcher (EV_A_ (W)w); - - if (j++ & 1) - { - assert (("libev: io watcher list contains a loop", w != w2)); - w2 = w2->next; - } - - assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1)); - assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i)); - } - } - - assert (timermax >= timercnt); - verify_heap (EV_A_ timers, timercnt); - -#if EV_PERIODIC_ENABLE - assert (periodicmax >= periodiccnt); - verify_heap (EV_A_ periodics, periodiccnt); -#endif - - for (i = NUMPRI; i--; ) - { - assert (pendingmax [i] >= pendingcnt [i]); -#if EV_IDLE_ENABLE - assert (idleall >= 0); - assert (idlemax [i] >= idlecnt [i]); - array_verify (EV_A_ (W *)idles [i], idlecnt [i]); -#endif - } - -#if EV_FORK_ENABLE - assert (forkmax >= forkcnt); - array_verify (EV_A_ (W *)forks, forkcnt); -#endif - -#if EV_CLEANUP_ENABLE - assert (cleanupmax >= cleanupcnt); - array_verify (EV_A_ (W *)cleanups, cleanupcnt); -#endif - -#if EV_ASYNC_ENABLE - assert (asyncmax >= asynccnt); - array_verify (EV_A_ (W *)asyncs, asynccnt); -#endif - -#if EV_PREPARE_ENABLE - assert (preparemax >= preparecnt); - array_verify (EV_A_ (W *)prepares, preparecnt); -#endif - -#if EV_CHECK_ENABLE - assert (checkmax >= checkcnt); - array_verify (EV_A_ (W *)checks, checkcnt); -#endif - -# if 0 -#if EV_CHILD_ENABLE - for (w = (ev_child *)childs [chain & ((EV_PID_HASHSIZE) - 1)]; w; w = (ev_child *)((WL)w)->next) - for (signum = EV_NSIG; signum--; ) if (signals [signum].pending) -#endif -# endif -#endif -} -#endif - -#if EV_MULTIPLICITY -ecb_cold -struct ev_loop * -#else -int -#endif -ev_default_loop (unsigned int flags) EV_NOEXCEPT -{ - if (!ev_default_loop_ptr) - { -#if EV_MULTIPLICITY - EV_P = ev_default_loop_ptr = &default_loop_struct; -#else - ev_default_loop_ptr = 1; -#endif - - loop_init (EV_A_ flags); - - if (ev_backend (EV_A)) - { -#if EV_CHILD_ENABLE - ev_signal_init (&childev, childcb, SIGCHLD); - ev_set_priority (&childev, EV_MAXPRI); - ev_signal_start (EV_A_ &childev); - ev_unref (EV_A); /* child watcher should not keep loop alive */ -#endif - } - else - ev_default_loop_ptr = 0; - } - - return ev_default_loop_ptr; -} - -void -ev_loop_fork (EV_P) EV_NOEXCEPT -{ - postfork = 1; -} - -/*****************************************************************************/ - -void -ev_invoke (EV_P_ void *w, int revents) -{ - EV_CB_INVOKE ((W)w, revents); -} - -unsigned int -ev_pending_count (EV_P) EV_NOEXCEPT -{ - int pri; - unsigned int count = 0; - - for (pri = NUMPRI; pri--; ) - count += pendingcnt [pri]; - - return count; -} - -ecb_noinline -void -ev_invoke_pending (EV_P) -{ - pendingpri = NUMPRI; - - do - { - --pendingpri; - - /* pendingpri possibly gets modified in the inner loop */ - while (pendingcnt [pendingpri]) - { - ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri]; - - p->w->pending = 0; - EV_CB_INVOKE (p->w, p->events); - EV_FREQUENT_CHECK; - } - } - while (pendingpri); -} - -#if EV_IDLE_ENABLE -/* make idle watchers pending. this handles the "call-idle */ -/* only when higher priorities are idle" logic */ -inline_size void -idle_reify (EV_P) -{ - if (ecb_expect_false (idleall)) - { - int pri; - - for (pri = NUMPRI; pri--; ) - { - if (pendingcnt [pri]) - break; - - if (idlecnt [pri]) - { - queue_events (EV_A_ (W *)idles [pri], idlecnt [pri], EV_IDLE); - break; - } - } - } -} -#endif - -/* make timers pending */ -inline_size void -timers_reify (EV_P) -{ - EV_FREQUENT_CHECK; - - if (timercnt && ANHE_at (timers [HEAP0]) < mn_now) - { - do - { - ev_timer *w = (ev_timer *)ANHE_w (timers [HEAP0]); - - /*assert (("libev: inactive timer on timer heap detected", ev_is_active (w)));*/ - - /* first reschedule or stop timer */ - if (w->repeat) - { - ev_at (w) += w->repeat; - if (ev_at (w) < mn_now) - ev_at (w) = mn_now; - - assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > EV_TS_CONST (0.))); - - ANHE_at_cache (timers [HEAP0]); - downheap (timers, timercnt, HEAP0); - } - else - ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ - - EV_FREQUENT_CHECK; - feed_reverse (EV_A_ (W)w); - } - while (timercnt && ANHE_at (timers [HEAP0]) < mn_now); - - feed_reverse_done (EV_A_ EV_TIMER); - } -} - -#if EV_PERIODIC_ENABLE - -ecb_noinline -static void -periodic_recalc (EV_P_ ev_periodic *w) -{ - ev_tstamp interval = w->interval > MIN_INTERVAL ? w->interval : MIN_INTERVAL; - ev_tstamp at = w->offset + interval * ev_floor ((ev_rt_now - w->offset) / interval); - - /* the above almost always errs on the low side */ - while (at <= ev_rt_now) - { - ev_tstamp nat = at + w->interval; - - /* when resolution fails us, we use ev_rt_now */ - if (ecb_expect_false (nat == at)) - { - at = ev_rt_now; - break; - } - - at = nat; - } - - ev_at (w) = at; -} - -/* make periodics pending */ -inline_size void -periodics_reify (EV_P) -{ - EV_FREQUENT_CHECK; - - while (periodiccnt && ANHE_at (periodics [HEAP0]) < ev_rt_now) - { - do - { - ev_periodic *w = (ev_periodic *)ANHE_w (periodics [HEAP0]); - - /*assert (("libev: inactive timer on periodic heap detected", ev_is_active (w)));*/ - - /* first reschedule or stop timer */ - if (w->reschedule_cb) - { - ev_at (w) = w->reschedule_cb (w, ev_rt_now); - - assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now)); - - ANHE_at_cache (periodics [HEAP0]); - downheap (periodics, periodiccnt, HEAP0); - } - else if (w->interval) - { - periodic_recalc (EV_A_ w); - ANHE_at_cache (periodics [HEAP0]); - downheap (periodics, periodiccnt, HEAP0); - } - else - ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ - - EV_FREQUENT_CHECK; - feed_reverse (EV_A_ (W)w); - } - while (periodiccnt && ANHE_at (periodics [HEAP0]) < ev_rt_now); - - feed_reverse_done (EV_A_ EV_PERIODIC); - } -} - -/* simply recalculate all periodics */ -/* TODO: maybe ensure that at least one event happens when jumping forward? */ -ecb_noinline ecb_cold -static void -periodics_reschedule (EV_P) -{ - int i; - - /* adjust periodics after time jump */ - for (i = HEAP0; i < periodiccnt + HEAP0; ++i) - { - ev_periodic *w = (ev_periodic *)ANHE_w (periodics [i]); - - if (w->reschedule_cb) - ev_at (w) = w->reschedule_cb (w, ev_rt_now); - else if (w->interval) - periodic_recalc (EV_A_ w); - - ANHE_at_cache (periodics [i]); - } - - reheap (periodics, periodiccnt); -} -#endif - -/* adjust all timers by a given offset */ -ecb_noinline ecb_cold -static void -timers_reschedule (EV_P_ ev_tstamp adjust) -{ - int i; - - for (i = 0; i < timercnt; ++i) - { - ANHE *he = timers + i + HEAP0; - ANHE_w (*he)->at += adjust; - ANHE_at_cache (*he); - } -} - -/* fetch new monotonic and realtime times from the kernel */ -/* also detect if there was a timejump, and act accordingly */ -inline_speed void -time_update (EV_P_ ev_tstamp max_block) -{ -#if EV_USE_MONOTONIC - if (ecb_expect_true (have_monotonic)) - { - int i; - ev_tstamp odiff = rtmn_diff; - - mn_now = get_clock (); - - /* only fetch the realtime clock every 0.5*MIN_TIMEJUMP seconds */ - /* interpolate in the meantime */ - if (ecb_expect_true (mn_now - now_floor < EV_TS_CONST (MIN_TIMEJUMP * .5))) - { - ev_rt_now = rtmn_diff + mn_now; - return; - } - - now_floor = mn_now; - ev_rt_now = ev_time (); - - /* loop a few times, before making important decisions. - * on the choice of "4": one iteration isn't enough, - * in case we get preempted during the calls to - * ev_time and get_clock. a second call is almost guaranteed - * to succeed in that case, though. and looping a few more times - * doesn't hurt either as we only do this on time-jumps or - * in the unlikely event of having been preempted here. - */ - for (i = 4; --i; ) - { - ev_tstamp diff; - rtmn_diff = ev_rt_now - mn_now; - - diff = odiff - rtmn_diff; - - if (ecb_expect_true ((diff < EV_TS_CONST (0.) ? -diff : diff) < EV_TS_CONST (MIN_TIMEJUMP))) - return; /* all is well */ - - ev_rt_now = ev_time (); - mn_now = get_clock (); - now_floor = mn_now; - } - - /* no timer adjustment, as the monotonic clock doesn't jump */ - /* timers_reschedule (EV_A_ rtmn_diff - odiff) */ -# if EV_PERIODIC_ENABLE - periodics_reschedule (EV_A); -# endif - } - else -#endif - { - ev_rt_now = ev_time (); - - if (ecb_expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + EV_TS_CONST (MIN_TIMEJUMP))) - { - /* adjust timers. this is easy, as the offset is the same for all of them */ - timers_reschedule (EV_A_ ev_rt_now - mn_now); -#if EV_PERIODIC_ENABLE - periodics_reschedule (EV_A); -#endif - } - - mn_now = ev_rt_now; - } -} - -int -ev_run (EV_P_ int flags) -{ -#if EV_FEATURE_API - ++loop_depth; -#endif - - assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE)); - - loop_done = EVBREAK_CANCEL; - - EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */ - - do - { -#if EV_VERIFY >= 2 - ev_verify (EV_A); -#endif - -#ifndef _WIN32 - if (ecb_expect_false (curpid)) /* penalise the forking check even more */ - if (ecb_expect_false (getpid () != curpid)) - { - curpid = getpid (); - postfork = 1; - } -#endif - -#if EV_FORK_ENABLE - /* we might have forked, so queue fork handlers */ - if (ecb_expect_false (postfork)) - if (forkcnt) - { - queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); - EV_INVOKE_PENDING; - } -#endif - -#if EV_PREPARE_ENABLE - /* queue prepare watchers (and execute them) */ - if (ecb_expect_false (preparecnt)) - { - queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); - EV_INVOKE_PENDING; - } -#endif - - if (ecb_expect_false (loop_done)) - break; - - /* we might have forked, so reify kernel state if necessary */ - if (ecb_expect_false (postfork)) - loop_fork (EV_A); - - /* update fd-related kernel structures */ - fd_reify (EV_A); - - /* calculate blocking time */ - { - ev_tstamp waittime = 0.; - ev_tstamp sleeptime = 0.; - - /* remember old timestamp for io_blocktime calculation */ - ev_tstamp prev_mn_now = mn_now; - - /* update time to cancel out callback processing overhead */ - time_update (EV_A_ EV_TS_CONST (EV_TSTAMP_HUGE)); - - /* from now on, we want a pipe-wake-up */ - pipe_write_wanted = 1; - - ECB_MEMORY_FENCE; /* make sure pipe_write_wanted is visible before we check for potential skips */ - - if (ecb_expect_true (!(flags & EVRUN_NOWAIT || idleall || !activecnt || pipe_write_skipped))) - { - waittime = EV_TS_CONST (MAX_BLOCKTIME); - -#if EV_USE_MONOTONIC - if (ecb_expect_true (have_monotonic)) - { -#if EV_USE_TIMERFD - /* sleep a lot longer when we can reliably detect timejumps */ - if (ecb_expect_true (timerfd != -1)) - waittime = EV_TS_CONST (MAX_BLOCKTIME2); -#endif -#if !EV_PERIODIC_ENABLE - /* without periodics but with monotonic clock there is no need */ - /* for any time jump detection, so sleep longer */ - waittime = EV_TS_CONST (MAX_BLOCKTIME2); -#endif - } -#endif - - if (timercnt) - { - ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now; - if (waittime > to) waittime = to; - } - -#if EV_PERIODIC_ENABLE - if (periodiccnt) - { - ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now; - if (waittime > to) waittime = to; - } -#endif - - /* don't let timeouts decrease the waittime below timeout_blocktime */ - if (ecb_expect_false (waittime < timeout_blocktime)) - waittime = timeout_blocktime; - - /* now there are two more special cases left, either we have - * already-expired timers, so we should not sleep, or we have timers - * that expire very soon, in which case we need to wait for a minimum - * amount of time for some event loop backends. - */ - if (ecb_expect_false (waittime < backend_mintime)) - waittime = waittime <= EV_TS_CONST (0.) - ? EV_TS_CONST (0.) - : backend_mintime; - - /* extra check because io_blocktime is commonly 0 */ - if (ecb_expect_false (io_blocktime)) - { - sleeptime = io_blocktime - (mn_now - prev_mn_now); - - if (sleeptime > waittime - backend_mintime) - sleeptime = waittime - backend_mintime; - - if (ecb_expect_true (sleeptime > EV_TS_CONST (0.))) - { - ev_sleep (sleeptime); - waittime -= sleeptime; - } - } - } - -#if EV_FEATURE_API - ++loop_count; -#endif - assert ((loop_done = EVBREAK_RECURSE, 1)); /* assert for side effect */ - backend_poll (EV_A_ waittime); - assert ((loop_done = EVBREAK_CANCEL, 1)); /* assert for side effect */ - - pipe_write_wanted = 0; /* just an optimisation, no fence needed */ - - ECB_MEMORY_FENCE_ACQUIRE; - if (pipe_write_skipped) - { - assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w))); - ev_feed_event (EV_A_ &pipe_w, EV_CUSTOM); - } - - /* update ev_rt_now, do magic */ - time_update (EV_A_ waittime + sleeptime); - } - - /* queue pending timers and reschedule them */ - timers_reify (EV_A); /* relative timers called last */ -#if EV_PERIODIC_ENABLE - periodics_reify (EV_A); /* absolute timers called first */ -#endif - -#if EV_IDLE_ENABLE - /* queue idle watchers unless other events are pending */ - idle_reify (EV_A); -#endif - -#if EV_CHECK_ENABLE - /* queue check watchers, to be executed first */ - if (ecb_expect_false (checkcnt)) - queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); -#endif - - EV_INVOKE_PENDING; - } - while (ecb_expect_true ( - activecnt - && !loop_done - && !(flags & (EVRUN_ONCE | EVRUN_NOWAIT)) - )); - - if (loop_done == EVBREAK_ONE) - loop_done = EVBREAK_CANCEL; - -#if EV_FEATURE_API - --loop_depth; -#endif - - return activecnt; -} - -void -ev_break (EV_P_ int how) EV_NOEXCEPT -{ - loop_done = how; -} - -void -ev_ref (EV_P) EV_NOEXCEPT -{ - ++activecnt; -} - -void -ev_unref (EV_P) EV_NOEXCEPT -{ - --activecnt; -} - -void -ev_now_update (EV_P) EV_NOEXCEPT -{ - time_update (EV_A_ EV_TSTAMP_HUGE); -} - -void -ev_suspend (EV_P) EV_NOEXCEPT -{ - ev_now_update (EV_A); -} - -void -ev_resume (EV_P) EV_NOEXCEPT -{ - ev_tstamp mn_prev = mn_now; - - ev_now_update (EV_A); - timers_reschedule (EV_A_ mn_now - mn_prev); -#if EV_PERIODIC_ENABLE - /* TODO: really do this? */ - periodics_reschedule (EV_A); -#endif -} - -/*****************************************************************************/ -/* singly-linked list management, used when the expected list length is short */ - -inline_size void -wlist_add (WL *head, WL elem) -{ - elem->next = *head; - *head = elem; -} - -inline_size void -wlist_del (WL *head, WL elem) -{ - while (*head) - { - if (ecb_expect_true (*head == elem)) - { - *head = elem->next; - break; - } - - head = &(*head)->next; - } -} - -/* internal, faster, version of ev_clear_pending */ -inline_speed void -clear_pending (EV_P_ W w) -{ - if (w->pending) - { - pendings [ABSPRI (w)][w->pending - 1].w = (W)&pending_w; - w->pending = 0; - } -} - -int -ev_clear_pending (EV_P_ void *w) EV_NOEXCEPT -{ - W w_ = (W)w; - int pending = w_->pending; - - if (ecb_expect_true (pending)) - { - ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1; - p->w = (W)&pending_w; - w_->pending = 0; - return p->events; - } - else - return 0; -} - -inline_size void -pri_adjust (EV_P_ W w) -{ - int pri = ev_priority (w); - pri = pri < EV_MINPRI ? EV_MINPRI : pri; - pri = pri > EV_MAXPRI ? EV_MAXPRI : pri; - ev_set_priority (w, pri); -} - -inline_speed void -ev_start (EV_P_ W w, int active) -{ - pri_adjust (EV_A_ w); - w->active = active; - ev_ref (EV_A); -} - -inline_size void -ev_stop (EV_P_ W w) -{ - ev_unref (EV_A); - w->active = 0; -} - -/*****************************************************************************/ - -ecb_noinline -void -ev_io_start (EV_P_ ev_io *w) EV_NOEXCEPT -{ - int fd = w->fd; - - if (ecb_expect_false (ev_is_active (w))) - return; - - assert (("libev: ev_io_start called with negative fd", fd >= 0)); - assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE)))); - -#if EV_VERIFY >= 2 - assert (("libev: ev_io_start called on watcher with invalid fd", fd_valid (fd))); -#endif - EV_FREQUENT_CHECK; - - ev_start (EV_A_ (W)w, 1); - array_needsize (ANFD, anfds, anfdmax, fd + 1, array_needsize_zerofill); - wlist_add (&anfds[fd].head, (WL)w); - - /* common bug, apparently */ - assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w)); - - fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY); - w->events &= ~EV__IOFDSET; - - EV_FREQUENT_CHECK; -} - -ecb_noinline -void -ev_io_stop (EV_P_ ev_io *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax)); - -#if EV_VERIFY >= 2 - assert (("libev: ev_io_stop called on watcher with invalid fd", fd_valid (w->fd))); -#endif - EV_FREQUENT_CHECK; - - wlist_del (&anfds[w->fd].head, (WL)w); - ev_stop (EV_A_ (W)w); - - fd_change (EV_A_ w->fd, EV_ANFD_REIFY); - - EV_FREQUENT_CHECK; -} - -ecb_noinline -void -ev_timer_start (EV_P_ ev_timer *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - - ev_at (w) += mn_now; - - assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); - - EV_FREQUENT_CHECK; - - ++timercnt; - ev_start (EV_A_ (W)w, timercnt + HEAP0 - 1); - array_needsize (ANHE, timers, timermax, ev_active (w) + 1, array_needsize_noinit); - ANHE_w (timers [ev_active (w)]) = (WT)w; - ANHE_at_cache (timers [ev_active (w)]); - upheap (timers, ev_active (w)); - - EV_FREQUENT_CHECK; - - /*assert (("libev: internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/ -} - -ecb_noinline -void -ev_timer_stop (EV_P_ ev_timer *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - { - int active = ev_active (w); - - assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w)); - - --timercnt; - - if (ecb_expect_true (active < timercnt + HEAP0)) - { - timers [active] = timers [timercnt + HEAP0]; - adjustheap (timers, timercnt, active); - } - } - - ev_at (w) -= mn_now; - - ev_stop (EV_A_ (W)w); - - EV_FREQUENT_CHECK; -} - -ecb_noinline -void -ev_timer_again (EV_P_ ev_timer *w) EV_NOEXCEPT -{ - EV_FREQUENT_CHECK; - - clear_pending (EV_A_ (W)w); - - if (ev_is_active (w)) - { - if (w->repeat) - { - ev_at (w) = mn_now + w->repeat; - ANHE_at_cache (timers [ev_active (w)]); - adjustheap (timers, timercnt, ev_active (w)); - } - else - ev_timer_stop (EV_A_ w); - } - else if (w->repeat) - { - ev_at (w) = w->repeat; - ev_timer_start (EV_A_ w); - } - - EV_FREQUENT_CHECK; -} - -ev_tstamp -ev_timer_remaining (EV_P_ ev_timer *w) EV_NOEXCEPT -{ - return ev_at (w) - (ev_is_active (w) ? mn_now : EV_TS_CONST (0.)); -} - -#if EV_PERIODIC_ENABLE -ecb_noinline -void -ev_periodic_start (EV_P_ ev_periodic *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - -#if EV_USE_TIMERFD - if (timerfd == -2) - evtimerfd_init (EV_A); -#endif - - if (w->reschedule_cb) - ev_at (w) = w->reschedule_cb (w, ev_rt_now); - else if (w->interval) - { - assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.)); - periodic_recalc (EV_A_ w); - } - else - ev_at (w) = w->offset; - - EV_FREQUENT_CHECK; - - ++periodiccnt; - ev_start (EV_A_ (W)w, periodiccnt + HEAP0 - 1); - array_needsize (ANHE, periodics, periodicmax, ev_active (w) + 1, array_needsize_noinit); - ANHE_w (periodics [ev_active (w)]) = (WT)w; - ANHE_at_cache (periodics [ev_active (w)]); - upheap (periodics, ev_active (w)); - - EV_FREQUENT_CHECK; - - /*assert (("libev: internal periodic heap corruption", ANHE_w (periodics [ev_active (w)]) == (WT)w));*/ -} - -ecb_noinline -void -ev_periodic_stop (EV_P_ ev_periodic *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - { - int active = ev_active (w); - - assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w)); - - --periodiccnt; - - if (ecb_expect_true (active < periodiccnt + HEAP0)) - { - periodics [active] = periodics [periodiccnt + HEAP0]; - adjustheap (periodics, periodiccnt, active); - } - } - - ev_stop (EV_A_ (W)w); - - EV_FREQUENT_CHECK; -} - -ecb_noinline -void -ev_periodic_again (EV_P_ ev_periodic *w) EV_NOEXCEPT -{ - /* TODO: use adjustheap and recalculation */ - ev_periodic_stop (EV_A_ w); - ev_periodic_start (EV_A_ w); -} -#endif - -#ifndef SA_RESTART -# define SA_RESTART 0 -#endif - -#if EV_SIGNAL_ENABLE - -ecb_noinline -void -ev_signal_start (EV_P_ ev_signal *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - - assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG)); - -#if EV_MULTIPLICITY - assert (("libev: a signal must not be attached to two different loops", - !signals [w->signum - 1].loop || signals [w->signum - 1].loop == loop)); - - signals [w->signum - 1].loop = EV_A; - ECB_MEMORY_FENCE_RELEASE; -#endif - - EV_FREQUENT_CHECK; - -#if EV_USE_SIGNALFD - if (sigfd == -2) - { - sigfd = signalfd (-1, &sigfd_set, SFD_NONBLOCK | SFD_CLOEXEC); - if (sigfd < 0 && errno == EINVAL) - sigfd = signalfd (-1, &sigfd_set, 0); /* retry without flags */ - - if (sigfd >= 0) - { - fd_intern (sigfd); /* doing it twice will not hurt */ - - sigemptyset (&sigfd_set); - - ev_io_init (&sigfd_w, sigfdcb, sigfd, EV_READ); - ev_set_priority (&sigfd_w, EV_MAXPRI); - ev_io_start (EV_A_ &sigfd_w); - ev_unref (EV_A); /* signalfd watcher should not keep loop alive */ - } - } - - if (sigfd >= 0) - { - /* TODO: check .head */ - sigaddset (&sigfd_set, w->signum); - sigprocmask (SIG_BLOCK, &sigfd_set, 0); - - signalfd (sigfd, &sigfd_set, 0); - } -#endif - - ev_start (EV_A_ (W)w, 1); - wlist_add (&signals [w->signum - 1].head, (WL)w); - - if (!((WL)w)->next) -# if EV_USE_SIGNALFD - if (sigfd < 0) /*TODO*/ -# endif - { -# ifdef _WIN32 - evpipe_init (EV_A); - - signal (w->signum, ev_sighandler); -# else - struct sigaction sa; - - evpipe_init (EV_A); - - sa.sa_handler = ev_sighandler; - sigfillset (&sa.sa_mask); - sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ - sigaction (w->signum, &sa, 0); - - if (origflags & EVFLAG_NOSIGMASK) - { - sigemptyset (&sa.sa_mask); - sigaddset (&sa.sa_mask, w->signum); - sigprocmask (SIG_UNBLOCK, &sa.sa_mask, 0); - } -#endif - } - - EV_FREQUENT_CHECK; -} - -ecb_noinline -void -ev_signal_stop (EV_P_ ev_signal *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - wlist_del (&signals [w->signum - 1].head, (WL)w); - ev_stop (EV_A_ (W)w); - - if (!signals [w->signum - 1].head) - { -#if EV_MULTIPLICITY - signals [w->signum - 1].loop = 0; /* unattach from signal */ -#endif -#if EV_USE_SIGNALFD - if (sigfd >= 0) - { - sigset_t ss; - - sigemptyset (&ss); - sigaddset (&ss, w->signum); - sigdelset (&sigfd_set, w->signum); - - signalfd (sigfd, &sigfd_set, 0); - sigprocmask (SIG_UNBLOCK, &ss, 0); - } - else -#endif - signal (w->signum, SIG_DFL); - } - - EV_FREQUENT_CHECK; -} - -#endif - -#if EV_CHILD_ENABLE - -void -ev_child_start (EV_P_ ev_child *w) EV_NOEXCEPT -{ -#if EV_MULTIPLICITY - assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); -#endif - if (ecb_expect_false (ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - ev_start (EV_A_ (W)w, 1); - wlist_add (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); - - EV_FREQUENT_CHECK; -} - -void -ev_child_stop (EV_P_ ev_child *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - wlist_del (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); - ev_stop (EV_A_ (W)w); - - EV_FREQUENT_CHECK; -} - -#endif - -#if EV_STAT_ENABLE - -# ifdef _WIN32 -# undef lstat -# define lstat(a,b) _stati64 (a,b) -# endif - -#define DEF_STAT_INTERVAL 5.0074891 -#define NFS_STAT_INTERVAL 30.1074891 /* for filesystems potentially failing inotify */ -#define MIN_STAT_INTERVAL 0.1074891 - -ecb_noinline static void stat_timer_cb (EV_P_ ev_timer *w_, int revents); - -#if EV_USE_INOTIFY - -/* the * 2 is to allow for alignment padding, which for some reason is >> 8 */ -# define EV_INOTIFY_BUFSIZE (sizeof (struct inotify_event) * 2 + NAME_MAX) - -ecb_noinline -static void -infy_add (EV_P_ ev_stat *w) -{ - w->wd = inotify_add_watch (fs_fd, w->path, - IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF | IN_MODIFY - | IN_CREATE | IN_DELETE | IN_MOVED_FROM | IN_MOVED_TO - | IN_DONT_FOLLOW | IN_MASK_ADD); - - if (w->wd >= 0) - { - struct statfs sfs; - - /* now local changes will be tracked by inotify, but remote changes won't */ - /* unless the filesystem is known to be local, we therefore still poll */ - /* also do poll on <2.6.25, but with normal frequency */ - - if (!fs_2625) - w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; - else if (!statfs (w->path, &sfs) - && (sfs.f_type == 0x1373 /* devfs */ - || sfs.f_type == 0x4006 /* fat */ - || sfs.f_type == 0x4d44 /* msdos */ - || sfs.f_type == 0xEF53 /* ext2/3 */ - || sfs.f_type == 0x72b6 /* jffs2 */ - || sfs.f_type == 0x858458f6 /* ramfs */ - || sfs.f_type == 0x5346544e /* ntfs */ - || sfs.f_type == 0x3153464a /* jfs */ - || sfs.f_type == 0x9123683e /* btrfs */ - || sfs.f_type == 0x52654973 /* reiser3 */ - || sfs.f_type == 0x01021994 /* tmpfs */ - || sfs.f_type == 0x58465342 /* xfs */)) - w->timer.repeat = 0.; /* filesystem is local, kernel new enough */ - else - w->timer.repeat = w->interval ? w->interval : NFS_STAT_INTERVAL; /* remote, use reduced frequency */ - } - else - { - /* can't use inotify, continue to stat */ - w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; - - /* if path is not there, monitor some parent directory for speedup hints */ - /* note that exceeding the hardcoded path limit is not a correctness issue, */ - /* but an efficiency issue only */ - if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096) - { - char path [4096]; - strcpy (path, w->path); - - do - { - int mask = IN_MASK_ADD | IN_DELETE_SELF | IN_MOVE_SELF - | (errno == EACCES ? IN_ATTRIB : IN_CREATE | IN_MOVED_TO); - - char *pend = strrchr (path, '/'); - - if (!pend || pend == path) - break; - - *pend = 0; - w->wd = inotify_add_watch (fs_fd, path, mask); - } - while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); - } - } - - if (w->wd >= 0) - wlist_add (&fs_hash [w->wd & ((EV_INOTIFY_HASHSIZE) - 1)].head, (WL)w); - - /* now re-arm timer, if required */ - if (ev_is_active (&w->timer)) ev_ref (EV_A); - ev_timer_again (EV_A_ &w->timer); - if (ev_is_active (&w->timer)) ev_unref (EV_A); -} - -ecb_noinline -static void -infy_del (EV_P_ ev_stat *w) -{ - int slot; - int wd = w->wd; - - if (wd < 0) - return; - - w->wd = -2; - slot = wd & ((EV_INOTIFY_HASHSIZE) - 1); - wlist_del (&fs_hash [slot].head, (WL)w); - - /* remove this watcher, if others are watching it, they will rearm */ - inotify_rm_watch (fs_fd, wd); -} - -ecb_noinline -static void -infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) -{ - if (slot < 0) - /* overflow, need to check for all hash slots */ - for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot) - infy_wd (EV_A_ slot, wd, ev); - else - { - WL w_; - - for (w_ = fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head; w_; ) - { - ev_stat *w = (ev_stat *)w_; - w_ = w_->next; /* lets us remove this watcher and all before it */ - - if (w->wd == wd || wd == -1) - { - if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF)) - { - wlist_del (&fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head, (WL)w); - w->wd = -1; - infy_add (EV_A_ w); /* re-add, no matter what */ - } - - stat_timer_cb (EV_A_ &w->timer, 0); - } - } - } -} - -static void -infy_cb (EV_P_ ev_io *w, int revents) -{ - char buf [EV_INOTIFY_BUFSIZE]; - int ofs; - int len = read (fs_fd, buf, sizeof (buf)); - - for (ofs = 0; ofs < len; ) - { - struct inotify_event *ev = (struct inotify_event *)(buf + ofs); - infy_wd (EV_A_ ev->wd, ev->wd, ev); - ofs += sizeof (struct inotify_event) + ev->len; - } -} - -inline_size ecb_cold -void -ev_check_2625 (EV_P) -{ - /* kernels < 2.6.25 are borked - * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html - */ - if (ev_linux_version () < 0x020619) - return; - - fs_2625 = 1; -} - -inline_size int -infy_newfd (void) -{ -#if defined IN_CLOEXEC && defined IN_NONBLOCK - int fd = inotify_init1 (IN_CLOEXEC | IN_NONBLOCK); - if (fd >= 0) - return fd; -#endif - return inotify_init (); -} - -inline_size void -infy_init (EV_P) -{ - if (fs_fd != -2) - return; - - fs_fd = -1; - - ev_check_2625 (EV_A); - - fs_fd = infy_newfd (); - - if (fs_fd >= 0) - { - fd_intern (fs_fd); - ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ); - ev_set_priority (&fs_w, EV_MAXPRI); - ev_io_start (EV_A_ &fs_w); - ev_unref (EV_A); - } -} - -inline_size void -infy_fork (EV_P) -{ - int slot; - - if (fs_fd < 0) - return; - - ev_ref (EV_A); - ev_io_stop (EV_A_ &fs_w); - close (fs_fd); - fs_fd = infy_newfd (); - - if (fs_fd >= 0) - { - fd_intern (fs_fd); - ev_io_set (&fs_w, fs_fd, EV_READ); - ev_io_start (EV_A_ &fs_w); - ev_unref (EV_A); - } - - for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot) - { - WL w_ = fs_hash [slot].head; - fs_hash [slot].head = 0; - - while (w_) - { - ev_stat *w = (ev_stat *)w_; - w_ = w_->next; /* lets us add this watcher */ - - w->wd = -1; - - if (fs_fd >= 0) - infy_add (EV_A_ w); /* re-add, no matter what */ - else - { - w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; - if (ev_is_active (&w->timer)) ev_ref (EV_A); - ev_timer_again (EV_A_ &w->timer); - if (ev_is_active (&w->timer)) ev_unref (EV_A); - } - } - } -} - -#endif - -#ifdef _WIN32 -# define EV_LSTAT(p,b) _stati64 (p, b) -#else -# define EV_LSTAT(p,b) lstat (p, b) -#endif - -void -ev_stat_stat (EV_P_ ev_stat *w) EV_NOEXCEPT -{ - if (lstat (w->path, &w->attr) < 0) - w->attr.st_nlink = 0; - else if (!w->attr.st_nlink) - w->attr.st_nlink = 1; -} - -ecb_noinline -static void -stat_timer_cb (EV_P_ ev_timer *w_, int revents) -{ - ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer)); - - ev_statdata prev = w->attr; - ev_stat_stat (EV_A_ w); - - /* memcmp doesn't work on netbsd, they.... do stuff to their struct stat */ - if ( - prev.st_dev != w->attr.st_dev - || prev.st_ino != w->attr.st_ino - || prev.st_mode != w->attr.st_mode - || prev.st_nlink != w->attr.st_nlink - || prev.st_uid != w->attr.st_uid - || prev.st_gid != w->attr.st_gid - || prev.st_rdev != w->attr.st_rdev - || prev.st_size != w->attr.st_size - || prev.st_atime != w->attr.st_atime - || prev.st_mtime != w->attr.st_mtime - || prev.st_ctime != w->attr.st_ctime - ) { - /* we only update w->prev on actual differences */ - /* in case we test more often than invoke the callback, */ - /* to ensure that prev is always different to attr */ - w->prev = prev; - - #if EV_USE_INOTIFY - if (fs_fd >= 0) - { - infy_del (EV_A_ w); - infy_add (EV_A_ w); - ev_stat_stat (EV_A_ w); /* avoid race... */ - } - #endif - - ev_feed_event (EV_A_ w, EV_STAT); - } -} - -void -ev_stat_start (EV_P_ ev_stat *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - - ev_stat_stat (EV_A_ w); - - if (w->interval < MIN_STAT_INTERVAL && w->interval) - w->interval = MIN_STAT_INTERVAL; - - ev_timer_init (&w->timer, stat_timer_cb, 0., w->interval ? w->interval : DEF_STAT_INTERVAL); - ev_set_priority (&w->timer, ev_priority (w)); - -#if EV_USE_INOTIFY - infy_init (EV_A); - - if (fs_fd >= 0) - infy_add (EV_A_ w); - else -#endif - { - ev_timer_again (EV_A_ &w->timer); - ev_unref (EV_A); - } - - ev_start (EV_A_ (W)w, 1); - - EV_FREQUENT_CHECK; -} - -void -ev_stat_stop (EV_P_ ev_stat *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - -#if EV_USE_INOTIFY - infy_del (EV_A_ w); -#endif - - if (ev_is_active (&w->timer)) - { - ev_ref (EV_A); - ev_timer_stop (EV_A_ &w->timer); - } - - ev_stop (EV_A_ (W)w); - - EV_FREQUENT_CHECK; -} -#endif - -#if EV_IDLE_ENABLE -void -ev_idle_start (EV_P_ ev_idle *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - - pri_adjust (EV_A_ (W)w); - - EV_FREQUENT_CHECK; - - { - int active = ++idlecnt [ABSPRI (w)]; - - ++idleall; - ev_start (EV_A_ (W)w, active); - - array_needsize (ev_idle *, idles [ABSPRI (w)], idlemax [ABSPRI (w)], active, array_needsize_noinit); - idles [ABSPRI (w)][active - 1] = w; - } - - EV_FREQUENT_CHECK; -} - -void -ev_idle_stop (EV_P_ ev_idle *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - { - int active = ev_active (w); - - idles [ABSPRI (w)][active - 1] = idles [ABSPRI (w)][--idlecnt [ABSPRI (w)]]; - ev_active (idles [ABSPRI (w)][active - 1]) = active; - - ev_stop (EV_A_ (W)w); - --idleall; - } - - EV_FREQUENT_CHECK; -} -#endif - -#if EV_PREPARE_ENABLE -void -ev_prepare_start (EV_P_ ev_prepare *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - ev_start (EV_A_ (W)w, ++preparecnt); - array_needsize (ev_prepare *, prepares, preparemax, preparecnt, array_needsize_noinit); - prepares [preparecnt - 1] = w; - - EV_FREQUENT_CHECK; -} - -void -ev_prepare_stop (EV_P_ ev_prepare *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - { - int active = ev_active (w); - - prepares [active - 1] = prepares [--preparecnt]; - ev_active (prepares [active - 1]) = active; - } - - ev_stop (EV_A_ (W)w); - - EV_FREQUENT_CHECK; -} -#endif - -#if EV_CHECK_ENABLE -void -ev_check_start (EV_P_ ev_check *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - ev_start (EV_A_ (W)w, ++checkcnt); - array_needsize (ev_check *, checks, checkmax, checkcnt, array_needsize_noinit); - checks [checkcnt - 1] = w; - - EV_FREQUENT_CHECK; -} - -void -ev_check_stop (EV_P_ ev_check *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - { - int active = ev_active (w); - - checks [active - 1] = checks [--checkcnt]; - ev_active (checks [active - 1]) = active; - } - - ev_stop (EV_A_ (W)w); - - EV_FREQUENT_CHECK; -} -#endif - -#if EV_EMBED_ENABLE -ecb_noinline -void -ev_embed_sweep (EV_P_ ev_embed *w) EV_NOEXCEPT -{ - ev_run (w->other, EVRUN_NOWAIT); -} - -static void -embed_io_cb (EV_P_ ev_io *io, int revents) -{ - ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io)); - - if (ev_cb (w)) - ev_feed_event (EV_A_ (W)w, EV_EMBED); - else - ev_run (w->other, EVRUN_NOWAIT); -} - -static void -embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents) -{ - ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare)); - - { - EV_P = w->other; - - while (fdchangecnt) - { - fd_reify (EV_A); - ev_run (EV_A_ EVRUN_NOWAIT); - } - } -} - -#if EV_FORK_ENABLE -static void -embed_fork_cb (EV_P_ ev_fork *fork_w, int revents) -{ - ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork)); - - ev_embed_stop (EV_A_ w); - - { - EV_P = w->other; - - ev_loop_fork (EV_A); - ev_run (EV_A_ EVRUN_NOWAIT); - } - - ev_embed_start (EV_A_ w); -} -#endif - -#if 0 -static void -embed_idle_cb (EV_P_ ev_idle *idle, int revents) -{ - ev_idle_stop (EV_A_ idle); -} -#endif - -void -ev_embed_start (EV_P_ ev_embed *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - - { - EV_P = w->other; - assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ())); - ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ); - } - - EV_FREQUENT_CHECK; - - ev_set_priority (&w->io, ev_priority (w)); - ev_io_start (EV_A_ &w->io); - - ev_prepare_init (&w->prepare, embed_prepare_cb); - ev_set_priority (&w->prepare, EV_MINPRI); - ev_prepare_start (EV_A_ &w->prepare); - -#if EV_FORK_ENABLE - ev_fork_init (&w->fork, embed_fork_cb); - ev_fork_start (EV_A_ &w->fork); -#endif - - /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ - - ev_start (EV_A_ (W)w, 1); - - EV_FREQUENT_CHECK; -} - -void -ev_embed_stop (EV_P_ ev_embed *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - ev_io_stop (EV_A_ &w->io); - ev_prepare_stop (EV_A_ &w->prepare); -#if EV_FORK_ENABLE - ev_fork_stop (EV_A_ &w->fork); -#endif - - ev_stop (EV_A_ (W)w); - - EV_FREQUENT_CHECK; -} -#endif - -#if EV_FORK_ENABLE -void -ev_fork_start (EV_P_ ev_fork *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - ev_start (EV_A_ (W)w, ++forkcnt); - array_needsize (ev_fork *, forks, forkmax, forkcnt, array_needsize_noinit); - forks [forkcnt - 1] = w; - - EV_FREQUENT_CHECK; -} - -void -ev_fork_stop (EV_P_ ev_fork *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - { - int active = ev_active (w); - - forks [active - 1] = forks [--forkcnt]; - ev_active (forks [active - 1]) = active; - } - - ev_stop (EV_A_ (W)w); - - EV_FREQUENT_CHECK; -} -#endif - -#if EV_CLEANUP_ENABLE -void -ev_cleanup_start (EV_P_ ev_cleanup *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - ev_start (EV_A_ (W)w, ++cleanupcnt); - array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, array_needsize_noinit); - cleanups [cleanupcnt - 1] = w; - - /* cleanup watchers should never keep a refcount on the loop */ - ev_unref (EV_A); - EV_FREQUENT_CHECK; -} - -void -ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - ev_ref (EV_A); - - { - int active = ev_active (w); - - cleanups [active - 1] = cleanups [--cleanupcnt]; - ev_active (cleanups [active - 1]) = active; - } - - ev_stop (EV_A_ (W)w); - - EV_FREQUENT_CHECK; -} -#endif - -#if EV_ASYNC_ENABLE -void -ev_async_start (EV_P_ ev_async *w) EV_NOEXCEPT -{ - if (ecb_expect_false (ev_is_active (w))) - return; - - w->sent = 0; - - evpipe_init (EV_A); - - EV_FREQUENT_CHECK; - - ev_start (EV_A_ (W)w, ++asynccnt); - array_needsize (ev_async *, asyncs, asyncmax, asynccnt, array_needsize_noinit); - asyncs [asynccnt - 1] = w; - - EV_FREQUENT_CHECK; -} - -void -ev_async_stop (EV_P_ ev_async *w) EV_NOEXCEPT -{ - clear_pending (EV_A_ (W)w); - if (ecb_expect_false (!ev_is_active (w))) - return; - - EV_FREQUENT_CHECK; - - { - int active = ev_active (w); - - asyncs [active - 1] = asyncs [--asynccnt]; - ev_active (asyncs [active - 1]) = active; - } - - ev_stop (EV_A_ (W)w); - - EV_FREQUENT_CHECK; -} - -void -ev_async_send (EV_P_ ev_async *w) EV_NOEXCEPT -{ - w->sent = 1; - evpipe_write (EV_A_ &async_pending); -} -#endif - -/*****************************************************************************/ - -struct ev_once -{ - ev_io io; - ev_timer to; - void (*cb)(int revents, void *arg); - void *arg; -}; - -static void -once_cb (EV_P_ struct ev_once *once, int revents) -{ - void (*cb)(int revents, void *arg) = once->cb; - void *arg = once->arg; - - ev_io_stop (EV_A_ &once->io); - ev_timer_stop (EV_A_ &once->to); - ev_free (once); - - cb (revents, arg); -} - -static void -once_cb_io (EV_P_ ev_io *w, int revents) -{ - struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)); - - once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->to)); -} - -static void -once_cb_to (EV_P_ ev_timer *w, int revents) -{ - struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)); - - once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io)); -} - -void -ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_NOEXCEPT -{ - struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); - - once->cb = cb; - once->arg = arg; - - ev_init (&once->io, once_cb_io); - if (fd >= 0) - { - ev_io_set (&once->io, fd, events); - ev_io_start (EV_A_ &once->io); - } - - ev_init (&once->to, once_cb_to); - if (timeout >= 0.) - { - ev_timer_set (&once->to, timeout, 0.); - ev_timer_start (EV_A_ &once->to); - } -} - -/*****************************************************************************/ - -#if EV_WALK_ENABLE -ecb_cold -void -ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) EV_NOEXCEPT -{ - int i, j; - ev_watcher_list *wl, *wn; - - if (types & (EV_IO | EV_EMBED)) - for (i = 0; i < anfdmax; ++i) - for (wl = anfds [i].head; wl; ) - { - wn = wl->next; - -#if EV_EMBED_ENABLE - if (ev_cb ((ev_io *)wl) == embed_io_cb) - { - if (types & EV_EMBED) - cb (EV_A_ EV_EMBED, ((char *)wl) - offsetof (struct ev_embed, io)); - } - else -#endif -#if EV_USE_INOTIFY - if (ev_cb ((ev_io *)wl) == infy_cb) - ; - else -#endif - if ((ev_io *)wl != &pipe_w) - if (types & EV_IO) - cb (EV_A_ EV_IO, wl); - - wl = wn; - } - - if (types & (EV_TIMER | EV_STAT)) - for (i = timercnt + HEAP0; i-- > HEAP0; ) -#if EV_STAT_ENABLE - /*TODO: timer is not always active*/ - if (ev_cb ((ev_timer *)ANHE_w (timers [i])) == stat_timer_cb) - { - if (types & EV_STAT) - cb (EV_A_ EV_STAT, ((char *)ANHE_w (timers [i])) - offsetof (struct ev_stat, timer)); - } - else -#endif - if (types & EV_TIMER) - cb (EV_A_ EV_TIMER, ANHE_w (timers [i])); - -#if EV_PERIODIC_ENABLE - if (types & EV_PERIODIC) - for (i = periodiccnt + HEAP0; i-- > HEAP0; ) - cb (EV_A_ EV_PERIODIC, ANHE_w (periodics [i])); -#endif - -#if EV_IDLE_ENABLE - if (types & EV_IDLE) - for (j = NUMPRI; j--; ) - for (i = idlecnt [j]; i--; ) - cb (EV_A_ EV_IDLE, idles [j][i]); -#endif - -#if EV_FORK_ENABLE - if (types & EV_FORK) - for (i = forkcnt; i--; ) - if (ev_cb (forks [i]) != embed_fork_cb) - cb (EV_A_ EV_FORK, forks [i]); -#endif - -#if EV_ASYNC_ENABLE - if (types & EV_ASYNC) - for (i = asynccnt; i--; ) - cb (EV_A_ EV_ASYNC, asyncs [i]); -#endif - -#if EV_PREPARE_ENABLE - if (types & EV_PREPARE) - for (i = preparecnt; i--; ) -# if EV_EMBED_ENABLE - if (ev_cb (prepares [i]) != embed_prepare_cb) -# endif - cb (EV_A_ EV_PREPARE, prepares [i]); -#endif - -#if EV_CHECK_ENABLE - if (types & EV_CHECK) - for (i = checkcnt; i--; ) - cb (EV_A_ EV_CHECK, checks [i]); -#endif - -#if EV_SIGNAL_ENABLE - if (types & EV_SIGNAL) - for (i = 0; i < EV_NSIG - 1; ++i) - for (wl = signals [i].head; wl; ) - { - wn = wl->next; - cb (EV_A_ EV_SIGNAL, wl); - wl = wn; - } -#endif - -#if EV_CHILD_ENABLE - if (types & EV_CHILD) - for (i = (EV_PID_HASHSIZE); i--; ) - for (wl = childs [i]; wl; ) - { - wn = wl->next; - cb (EV_A_ EV_CHILD, wl); - wl = wn; - } -#endif -/* EV_STAT 0x00001000 /* stat data changed */ -/* EV_EMBED 0x00010000 /* embedded event loop needs sweep */ -} -#endif - -#if EV_MULTIPLICITY - #include "ev_wrap.h" -#endif - diff --git a/submodules/lev/lev/vendor/ev.h b/submodules/lev/lev/vendor/ev.h deleted file mode 100644 index 4669c39b6..000000000 --- a/submodules/lev/lev/vendor/ev.h +++ /dev/null @@ -1,860 +0,0 @@ -/* - * libev native API header - * - * Copyright (c) 2007-2020 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#ifndef EV_H_ -#define EV_H_ - -#ifdef __cplusplus -# define EV_CPP(x) x -# if __cplusplus >= 201103L -# define EV_NOEXCEPT noexcept -# else -# define EV_NOEXCEPT -# endif -#else -# define EV_CPP(x) -# define EV_NOEXCEPT -#endif -#define EV_THROW EV_NOEXCEPT /* pre-4.25, do not use in new code */ - -EV_CPP(extern "C" {) - -/*****************************************************************************/ - -/* pre-4.0 compatibility */ -#ifndef EV_COMPAT3 -# define EV_COMPAT3 1 -#endif - -#ifndef EV_FEATURES -# if defined __OPTIMIZE_SIZE__ -# define EV_FEATURES 0x7c -# else -# define EV_FEATURES 0x7f -# endif -#endif - -#define EV_FEATURE_CODE ((EV_FEATURES) & 1) -#define EV_FEATURE_DATA ((EV_FEATURES) & 2) -#define EV_FEATURE_CONFIG ((EV_FEATURES) & 4) -#define EV_FEATURE_API ((EV_FEATURES) & 8) -#define EV_FEATURE_WATCHERS ((EV_FEATURES) & 16) -#define EV_FEATURE_BACKENDS ((EV_FEATURES) & 32) -#define EV_FEATURE_OS ((EV_FEATURES) & 64) - -/* these priorities are inclusive, higher priorities will be invoked earlier */ -#ifndef EV_MINPRI -# define EV_MINPRI (EV_FEATURE_CONFIG ? -2 : 0) -#endif -#ifndef EV_MAXPRI -# define EV_MAXPRI (EV_FEATURE_CONFIG ? +2 : 0) -#endif - -#ifndef EV_MULTIPLICITY -# define EV_MULTIPLICITY EV_FEATURE_CONFIG -#endif - -#ifndef EV_PERIODIC_ENABLE -# define EV_PERIODIC_ENABLE EV_FEATURE_WATCHERS -#endif - -#ifndef EV_STAT_ENABLE -# define EV_STAT_ENABLE EV_FEATURE_WATCHERS -#endif - -#ifndef EV_PREPARE_ENABLE -# define EV_PREPARE_ENABLE EV_FEATURE_WATCHERS -#endif - -#ifndef EV_CHECK_ENABLE -# define EV_CHECK_ENABLE EV_FEATURE_WATCHERS -#endif - -#ifndef EV_IDLE_ENABLE -# define EV_IDLE_ENABLE EV_FEATURE_WATCHERS -#endif - -#ifndef EV_FORK_ENABLE -# define EV_FORK_ENABLE EV_FEATURE_WATCHERS -#endif - -#ifndef EV_CLEANUP_ENABLE -# define EV_CLEANUP_ENABLE EV_FEATURE_WATCHERS -#endif - -#ifndef EV_SIGNAL_ENABLE -# define EV_SIGNAL_ENABLE EV_FEATURE_WATCHERS -#endif - -#ifndef EV_CHILD_ENABLE -# ifdef _WIN32 -# define EV_CHILD_ENABLE 0 -# else -# define EV_CHILD_ENABLE EV_FEATURE_WATCHERS -#endif -#endif - -#ifndef EV_ASYNC_ENABLE -# define EV_ASYNC_ENABLE EV_FEATURE_WATCHERS -#endif - -#ifndef EV_EMBED_ENABLE -# define EV_EMBED_ENABLE EV_FEATURE_WATCHERS -#endif - -#ifndef EV_WALK_ENABLE -# define EV_WALK_ENABLE 0 /* not yet */ -#endif - -/*****************************************************************************/ - -#if EV_CHILD_ENABLE && !EV_SIGNAL_ENABLE -# undef EV_SIGNAL_ENABLE -# define EV_SIGNAL_ENABLE 1 -#endif - -/*****************************************************************************/ - -#ifndef EV_TSTAMP_T -# define EV_TSTAMP_T double -#endif -typedef EV_TSTAMP_T ev_tstamp; - -#include /* for memmove */ - -#ifndef EV_ATOMIC_T -# include -# define EV_ATOMIC_T sig_atomic_t volatile -#endif - -#if EV_STAT_ENABLE -# ifdef _WIN32 -# include -# include -# endif -# include -#endif - -/* support multiple event loops? */ -#if EV_MULTIPLICITY -struct ev_loop; -# define EV_P struct ev_loop *loop /* a loop as sole parameter in a declaration */ -# define EV_P_ EV_P, /* a loop as first of multiple parameters */ -# define EV_A loop /* a loop as sole argument to a function call */ -# define EV_A_ EV_A, /* a loop as first of multiple arguments */ -# define EV_DEFAULT_UC ev_default_loop_uc_ () /* the default loop, if initialised, as sole arg */ -# define EV_DEFAULT_UC_ EV_DEFAULT_UC, /* the default loop as first of multiple arguments */ -# define EV_DEFAULT ev_default_loop (0) /* the default loop as sole arg */ -# define EV_DEFAULT_ EV_DEFAULT, /* the default loop as first of multiple arguments */ -#else -# define EV_P void -# define EV_P_ -# define EV_A -# define EV_A_ -# define EV_DEFAULT -# define EV_DEFAULT_ -# define EV_DEFAULT_UC -# define EV_DEFAULT_UC_ -# undef EV_EMBED_ENABLE -#endif - -/* EV_INLINE is used for functions in header files */ -#if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3 -# define EV_INLINE static inline -#else -# define EV_INLINE static -#endif - -#ifdef EV_API_STATIC -# define EV_API_DECL static -#else -# define EV_API_DECL extern -#endif - -/* EV_PROTOTYPES can be used to switch of prototype declarations */ -#ifndef EV_PROTOTYPES -# define EV_PROTOTYPES 1 -#endif - -/*****************************************************************************/ - -#define EV_VERSION_MAJOR 4 -#define EV_VERSION_MINOR 33 - -/* eventmask, revents, events... */ -enum { - EV_UNDEF = (int)0xFFFFFFFF, /* guaranteed to be invalid */ - EV_NONE = 0x00, /* no events */ - EV_READ = 0x01, /* ev_io detected read will not block */ - EV_WRITE = 0x02, /* ev_io detected write will not block */ - EV__IOFDSET = 0x80, /* internal use only */ - EV_IO = EV_READ, /* alias for type-detection */ - EV_TIMER = 0x00000100, /* timer timed out */ -#if EV_COMPAT3 - EV_TIMEOUT = EV_TIMER, /* pre 4.0 API compatibility */ -#endif - EV_PERIODIC = 0x00000200, /* periodic timer timed out */ - EV_SIGNAL = 0x00000400, /* signal was received */ - EV_CHILD = 0x00000800, /* child/pid had status change */ - EV_STAT = 0x00001000, /* stat data changed */ - EV_IDLE = 0x00002000, /* event loop is idling */ - EV_PREPARE = 0x00004000, /* event loop about to poll */ - EV_CHECK = 0x00008000, /* event loop finished poll */ - EV_EMBED = 0x00010000, /* embedded event loop needs sweep */ - EV_FORK = 0x00020000, /* event loop resumed in child */ - EV_CLEANUP = 0x00040000, /* event loop resumed in child */ - EV_ASYNC = 0x00080000, /* async intra-loop signal */ - EV_CUSTOM = 0x01000000, /* for use by user code */ - EV_ERROR = (int)0x80000000 /* sent when an error occurs */ -}; - -/* can be used to add custom fields to all watchers, while losing binary compatibility */ -#ifndef EV_COMMON -# define EV_COMMON void *data; -#endif - -#ifndef EV_CB_DECLARE -# define EV_CB_DECLARE(type) void (*cb)(EV_P_ struct type *w, int revents); -#endif -#ifndef EV_CB_INVOKE -# define EV_CB_INVOKE(watcher,revents) (watcher)->cb (EV_A_ (watcher), (revents)) -#endif - -/* not official, do not use */ -#define EV_CB(type,name) void name (EV_P_ struct ev_ ## type *w, int revents) - -/* - * struct member types: - * private: you may look at them, but not change them, - * and they might not mean anything to you. - * ro: can be read anytime, but only changed when the watcher isn't active. - * rw: can be read and modified anytime, even when the watcher is active. - * - * some internal details that might be helpful for debugging: - * - * active is either 0, which means the watcher is not active, - * or the array index of the watcher (periodics, timers) - * or the array index + 1 (most other watchers) - * or simply 1 for watchers that aren't in some array. - * pending is either 0, in which case the watcher isn't, - * or the array index + 1 in the pendings array. - */ - -#if EV_MINPRI == EV_MAXPRI -# define EV_DECL_PRIORITY -#elif !defined (EV_DECL_PRIORITY) -# define EV_DECL_PRIORITY int priority; -#endif - -/* shared by all watchers */ -#define EV_WATCHER(type) \ - int active; /* private */ \ - int pending; /* private */ \ - EV_DECL_PRIORITY /* private */ \ - EV_COMMON /* rw */ \ - EV_CB_DECLARE (type) /* private */ - -#define EV_WATCHER_LIST(type) \ - EV_WATCHER (type) \ - struct ev_watcher_list *next; /* private */ - -#define EV_WATCHER_TIME(type) \ - EV_WATCHER (type) \ - ev_tstamp at; /* private */ - -/* base class, nothing to see here unless you subclass */ -typedef struct ev_watcher -{ - EV_WATCHER (ev_watcher) -} ev_watcher; - -/* base class, nothing to see here unless you subclass */ -typedef struct ev_watcher_list -{ - EV_WATCHER_LIST (ev_watcher_list) -} ev_watcher_list; - -/* base class, nothing to see here unless you subclass */ -typedef struct ev_watcher_time -{ - EV_WATCHER_TIME (ev_watcher_time) -} ev_watcher_time; - -/* invoked when fd is either EV_READable or EV_WRITEable */ -/* revent EV_READ, EV_WRITE */ -typedef struct ev_io -{ - EV_WATCHER_LIST (ev_io) - - int fd; /* ro */ - int events; /* ro */ -} ev_io; - -/* invoked after a specific time, repeatable (based on monotonic clock) */ -/* revent EV_TIMEOUT */ -typedef struct ev_timer -{ - EV_WATCHER_TIME (ev_timer) - - ev_tstamp repeat; /* rw */ -} ev_timer; - -/* invoked at some specific time, possibly repeating at regular intervals (based on UTC) */ -/* revent EV_PERIODIC */ -typedef struct ev_periodic -{ - EV_WATCHER_TIME (ev_periodic) - - ev_tstamp offset; /* rw */ - ev_tstamp interval; /* rw */ - ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) EV_NOEXCEPT; /* rw */ -} ev_periodic; - -/* invoked when the given signal has been received */ -/* revent EV_SIGNAL */ -typedef struct ev_signal -{ - EV_WATCHER_LIST (ev_signal) - - int signum; /* ro */ -} ev_signal; - -/* invoked when sigchld is received and waitpid indicates the given pid */ -/* revent EV_CHILD */ -/* does not support priorities */ -typedef struct ev_child -{ - EV_WATCHER_LIST (ev_child) - - int flags; /* private */ - int pid; /* ro */ - int rpid; /* rw, holds the received pid */ - int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */ -} ev_child; - -#if EV_STAT_ENABLE -/* st_nlink = 0 means missing file or other error */ -# ifdef _WIN32 -typedef struct _stati64 ev_statdata; -# else -typedef struct stat ev_statdata; -# endif - -/* invoked each time the stat data changes for a given path */ -/* revent EV_STAT */ -typedef struct ev_stat -{ - EV_WATCHER_LIST (ev_stat) - - ev_timer timer; /* private */ - ev_tstamp interval; /* ro */ - const char *path; /* ro */ - ev_statdata prev; /* ro */ - ev_statdata attr; /* ro */ - - int wd; /* wd for inotify, fd for kqueue */ -} ev_stat; -#endif - -/* invoked when the nothing else needs to be done, keeps the process from blocking */ -/* revent EV_IDLE */ -typedef struct ev_idle -{ - EV_WATCHER (ev_idle) -} ev_idle; - -/* invoked for each run of the mainloop, just before the blocking call */ -/* you can still change events in any way you like */ -/* revent EV_PREPARE */ -typedef struct ev_prepare -{ - EV_WATCHER (ev_prepare) -} ev_prepare; - -/* invoked for each run of the mainloop, just after the blocking call */ -/* revent EV_CHECK */ -typedef struct ev_check -{ - EV_WATCHER (ev_check) -} ev_check; - -/* the callback gets invoked before check in the child process when a fork was detected */ -/* revent EV_FORK */ -typedef struct ev_fork -{ - EV_WATCHER (ev_fork) -} ev_fork; - -/* is invoked just before the loop gets destroyed */ -/* revent EV_CLEANUP */ -typedef struct ev_cleanup -{ - EV_WATCHER (ev_cleanup) -} ev_cleanup; - -#if EV_EMBED_ENABLE -/* used to embed an event loop inside another */ -/* the callback gets invoked when the event loop has handled events, and can be 0 */ -typedef struct ev_embed -{ - EV_WATCHER (ev_embed) - - struct ev_loop *other; /* ro */ -#undef EV_IO_ENABLE -#define EV_IO_ENABLE 1 - ev_io io; /* private */ -#undef EV_PREPARE_ENABLE -#define EV_PREPARE_ENABLE 1 - ev_prepare prepare; /* private */ - ev_check check; /* unused */ - ev_timer timer; /* unused */ - ev_periodic periodic; /* unused */ - ev_idle idle; /* unused */ - ev_fork fork; /* private */ - ev_cleanup cleanup; /* unused */ -} ev_embed; -#endif - -#if EV_ASYNC_ENABLE -/* invoked when somebody calls ev_async_send on the watcher */ -/* revent EV_ASYNC */ -typedef struct ev_async -{ - EV_WATCHER (ev_async) - - EV_ATOMIC_T sent; /* private */ -} ev_async; - -# define ev_async_pending(w) (+(w)->sent) -#endif - -/* the presence of this union forces similar struct layout */ -union ev_any_watcher -{ - struct ev_watcher w; - struct ev_watcher_list wl; - - struct ev_io io; - struct ev_timer timer; - struct ev_periodic periodic; - struct ev_signal signal; - struct ev_child child; -#if EV_STAT_ENABLE - struct ev_stat stat; -#endif -#if EV_IDLE_ENABLE - struct ev_idle idle; -#endif - struct ev_prepare prepare; - struct ev_check check; -#if EV_FORK_ENABLE - struct ev_fork fork; -#endif -#if EV_CLEANUP_ENABLE - struct ev_cleanup cleanup; -#endif -#if EV_EMBED_ENABLE - struct ev_embed embed; -#endif -#if EV_ASYNC_ENABLE - struct ev_async async; -#endif -}; - -/* flag bits for ev_default_loop and ev_loop_new */ -enum { - /* the default */ - EVFLAG_AUTO = 0x00000000U, /* not quite a mask */ - /* flag bits */ - EVFLAG_NOENV = 0x01000000U, /* do NOT consult environment */ - EVFLAG_FORKCHECK = 0x02000000U, /* check for a fork in each iteration */ - /* debugging/feature disable */ - EVFLAG_NOINOTIFY = 0x00100000U, /* do not attempt to use inotify */ -#if EV_COMPAT3 - EVFLAG_NOSIGFD = 0, /* compatibility to pre-3.9 */ -#endif - EVFLAG_SIGNALFD = 0x00200000U, /* attempt to use signalfd */ - EVFLAG_NOSIGMASK = 0x00400000U, /* avoid modifying the signal mask */ - EVFLAG_NOTIMERFD = 0x00800000U /* avoid creating a timerfd */ -}; - -/* method bits to be ored together */ -enum { - EVBACKEND_SELECT = 0x00000001U, /* available just about anywhere */ - EVBACKEND_POLL = 0x00000002U, /* !win, !aix, broken on osx */ - EVBACKEND_EPOLL = 0x00000004U, /* linux */ - EVBACKEND_KQUEUE = 0x00000008U, /* bsd, broken on osx */ - EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */ - EVBACKEND_PORT = 0x00000020U, /* solaris 10 */ - EVBACKEND_LINUXAIO = 0x00000040U, /* linux AIO, 4.19+ */ - EVBACKEND_IOURING = 0x00000080U, /* linux io_uring, 5.1+ */ - EVBACKEND_ALL = 0x000000FFU, /* all known backends */ - EVBACKEND_MASK = 0x0000FFFFU /* all future backends */ -}; - -#if EV_PROTOTYPES -EV_API_DECL int ev_version_major (void) EV_NOEXCEPT; -EV_API_DECL int ev_version_minor (void) EV_NOEXCEPT; - -EV_API_DECL unsigned int ev_supported_backends (void) EV_NOEXCEPT; -EV_API_DECL unsigned int ev_recommended_backends (void) EV_NOEXCEPT; -EV_API_DECL unsigned int ev_embeddable_backends (void) EV_NOEXCEPT; - -EV_API_DECL ev_tstamp ev_time (void) EV_NOEXCEPT; -EV_API_DECL void ev_sleep (ev_tstamp delay) EV_NOEXCEPT; /* sleep for a while */ - -/* Sets the allocation function to use, works like realloc. - * It is used to allocate and free memory. - * If it returns zero when memory needs to be allocated, the library might abort - * or take some potentially destructive action. - * The default is your system realloc function. - */ -EV_API_DECL void ev_set_allocator (void *(*cb)(void *ptr, long size) EV_NOEXCEPT) EV_NOEXCEPT; - -/* set the callback function to call on a - * retryable syscall error - * (such as failed select, poll, epoll_wait) - */ -EV_API_DECL void ev_set_syserr_cb (void (*cb)(const char *msg) EV_NOEXCEPT) EV_NOEXCEPT; - -#if EV_MULTIPLICITY - -/* the default loop is the only one that handles signals and child watchers */ -/* you can call this as often as you like */ -EV_API_DECL struct ev_loop *ev_default_loop (unsigned int flags EV_CPP (= 0)) EV_NOEXCEPT; - -#ifdef EV_API_STATIC -EV_API_DECL struct ev_loop *ev_default_loop_ptr; -#endif - -EV_INLINE struct ev_loop * -ev_default_loop_uc_ (void) EV_NOEXCEPT -{ - extern struct ev_loop *ev_default_loop_ptr; - - return ev_default_loop_ptr; -} - -EV_INLINE int -ev_is_default_loop (EV_P) EV_NOEXCEPT -{ - return EV_A == EV_DEFAULT_UC; -} - -/* create and destroy alternative loops that don't handle signals */ -EV_API_DECL struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)) EV_NOEXCEPT; - -EV_API_DECL ev_tstamp ev_now (EV_P) EV_NOEXCEPT; /* time w.r.t. timers and the eventloop, updated after each poll */ - -#else - -EV_API_DECL int ev_default_loop (unsigned int flags EV_CPP (= 0)) EV_NOEXCEPT; /* returns true when successful */ - -EV_API_DECL ev_tstamp ev_rt_now; - -EV_INLINE ev_tstamp -ev_now (void) EV_NOEXCEPT -{ - return ev_rt_now; -} - -/* looks weird, but ev_is_default_loop (EV_A) still works if this exists */ -EV_INLINE int -ev_is_default_loop (void) EV_NOEXCEPT -{ - return 1; -} - -#endif /* multiplicity */ - -/* destroy event loops, also works for the default loop */ -EV_API_DECL void ev_loop_destroy (EV_P); - -/* this needs to be called after fork, to duplicate the loop */ -/* when you want to re-use it in the child */ -/* you can call it in either the parent or the child */ -/* you can actually call it at any time, anywhere :) */ -EV_API_DECL void ev_loop_fork (EV_P) EV_NOEXCEPT; - -EV_API_DECL unsigned int ev_backend (EV_P) EV_NOEXCEPT; /* backend in use by loop */ - -EV_API_DECL void ev_now_update (EV_P) EV_NOEXCEPT; /* update event loop time */ - -#if EV_WALK_ENABLE -/* walk (almost) all watchers in the loop of a given type, invoking the */ -/* callback on every such watcher. The callback might stop the watcher, */ -/* but do nothing else with the loop */ -EV_API_DECL void ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) EV_NOEXCEPT; -#endif - -#endif /* prototypes */ - -/* ev_run flags values */ -enum { - EVRUN_NOWAIT = 1, /* do not block/wait */ - EVRUN_ONCE = 2 /* block *once* only */ -}; - -/* ev_break how values */ -enum { - EVBREAK_CANCEL = 0, /* undo unloop */ - EVBREAK_ONE = 1, /* unloop once */ - EVBREAK_ALL = 2 /* unloop all loops */ -}; - -#if EV_PROTOTYPES -EV_API_DECL int ev_run (EV_P_ int flags EV_CPP (= 0)); -EV_API_DECL void ev_break (EV_P_ int how EV_CPP (= EVBREAK_ONE)) EV_NOEXCEPT; /* break out of the loop */ - -/* - * ref/unref can be used to add or remove a refcount on the mainloop. every watcher - * keeps one reference. if you have a long-running watcher you never unregister that - * should not keep ev_loop from running, unref() after starting, and ref() before stopping. - */ -EV_API_DECL void ev_ref (EV_P) EV_NOEXCEPT; -EV_API_DECL void ev_unref (EV_P) EV_NOEXCEPT; - -/* - * convenience function, wait for a single event, without registering an event watcher - * if timeout is < 0, do wait indefinitely - */ -EV_API_DECL void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_NOEXCEPT; - -EV_API_DECL void ev_invoke_pending (EV_P); /* invoke all pending watchers */ - -# if EV_FEATURE_API -EV_API_DECL unsigned int ev_iteration (EV_P) EV_NOEXCEPT; /* number of loop iterations */ -EV_API_DECL unsigned int ev_depth (EV_P) EV_NOEXCEPT; /* #ev_loop enters - #ev_loop leaves */ -EV_API_DECL void ev_verify (EV_P) EV_NOEXCEPT; /* abort if loop data corrupted */ - -EV_API_DECL void ev_set_io_collect_interval (EV_P_ ev_tstamp interval) EV_NOEXCEPT; /* sleep at least this time, default 0 */ -EV_API_DECL void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_NOEXCEPT; /* sleep at least this time, default 0 */ - -/* advanced stuff for threading etc. support, see docs */ -EV_API_DECL void ev_set_userdata (EV_P_ void *data) EV_NOEXCEPT; -EV_API_DECL void *ev_userdata (EV_P) EV_NOEXCEPT; -typedef void (*ev_loop_callback)(EV_P); -EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_NOEXCEPT; -/* C++ doesn't allow the use of the ev_loop_callback typedef here, so we need to spell it out */ -EV_API_DECL void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_NOEXCEPT, void (*acquire)(EV_P) EV_NOEXCEPT) EV_NOEXCEPT; - -EV_API_DECL unsigned int ev_pending_count (EV_P) EV_NOEXCEPT; /* number of pending events, if any */ - -/* - * stop/start the timer handling. - */ -EV_API_DECL void ev_suspend (EV_P) EV_NOEXCEPT; -EV_API_DECL void ev_resume (EV_P) EV_NOEXCEPT; -#endif - -#endif - -/* these may evaluate ev multiple times, and the other arguments at most once */ -/* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */ -#define ev_init(ev,cb_) do { \ - ((ev_watcher *)(void *)(ev))->active = \ - ((ev_watcher *)(void *)(ev))->pending = 0; \ - ev_set_priority ((ev), 0); \ - ev_set_cb ((ev), cb_); \ -} while (0) - -#define ev_io_modify(ev,events_) do { (ev)->events = (ev)->events & EV__IOFDSET | (events_); } while (0) -#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_) | EV__IOFDSET; } while (0) -#define ev_timer_set(ev,after_,repeat_) do { ((ev_watcher_time *)(ev))->at = (after_); (ev)->repeat = (repeat_); } while (0) -#define ev_periodic_set(ev,ofs_,ival_,rcb_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb = (rcb_); } while (0) -#define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0) -#define ev_child_set(ev,pid_,trace_) do { (ev)->pid = (pid_); (ev)->flags = !!(trace_); } while (0) -#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); (ev)->wd = -2; } while (0) -#define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */ -#define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */ -#define ev_check_set(ev) /* nop, yes, this is a serious in-joke */ -#define ev_embed_set(ev,other_) do { (ev)->other = (other_); } while (0) -#define ev_fork_set(ev) /* nop, yes, this is a serious in-joke */ -#define ev_cleanup_set(ev) /* nop, yes, this is a serious in-joke */ -#define ev_async_set(ev) /* nop, yes, this is a serious in-joke */ - -#define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0) -#define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } while (0) -#define ev_periodic_init(ev,cb,ofs,ival,rcb) do { ev_init ((ev), (cb)); ev_periodic_set ((ev),(ofs),(ival),(rcb)); } while (0) -#define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0) -#define ev_child_init(ev,cb,pid,trace) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid),(trace)); } while (0) -#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_stat_set ((ev),(path),(interval)); } while (0) -#define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0) -#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0) -#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0) -#define ev_embed_init(ev,cb,other) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(other)); } while (0) -#define ev_fork_init(ev,cb) do { ev_init ((ev), (cb)); ev_fork_set ((ev)); } while (0) -#define ev_cleanup_init(ev,cb) do { ev_init ((ev), (cb)); ev_cleanup_set ((ev)); } while (0) -#define ev_async_init(ev,cb) do { ev_init ((ev), (cb)); ev_async_set ((ev)); } while (0) - -#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ -#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */ - -#define ev_cb_(ev) (ev)->cb /* rw */ -#define ev_cb(ev) (memmove (&ev_cb_ (ev), &((ev_watcher *)(ev))->cb, sizeof (ev_cb_ (ev))), (ev)->cb) - -#if EV_MINPRI == EV_MAXPRI -# define ev_priority(ev) ((ev), EV_MINPRI) -# define ev_set_priority(ev,pri) ((ev), (pri)) -#else -# define ev_priority(ev) (+(((ev_watcher *)(void *)(ev))->priority)) -# define ev_set_priority(ev,pri) ( (ev_watcher *)(void *)(ev))->priority = (pri) -#endif - -#define ev_periodic_at(ev) (+((ev_watcher_time *)(ev))->at) - -#ifndef ev_set_cb -/* memmove is used here to avoid strict aliasing violations, and hopefully is optimized out by any reasonable compiler */ -# define ev_set_cb(ev,cb_) (ev_cb_ (ev) = (cb_), memmove (&((ev_watcher *)(ev))->cb, &ev_cb_ (ev), sizeof (ev_cb_ (ev)))) -#endif - -/* stopping (enabling, adding) a watcher does nothing if it is already running */ -/* stopping (disabling, deleting) a watcher does nothing unless it's already running */ -#if EV_PROTOTYPES - -/* feeds an event into a watcher as if the event actually occurred */ -/* accepts any ev_watcher type */ -EV_API_DECL void ev_feed_event (EV_P_ void *w, int revents) EV_NOEXCEPT; -EV_API_DECL void ev_feed_fd_event (EV_P_ int fd, int revents) EV_NOEXCEPT; -#if EV_SIGNAL_ENABLE -EV_API_DECL void ev_feed_signal (int signum) EV_NOEXCEPT; -EV_API_DECL void ev_feed_signal_event (EV_P_ int signum) EV_NOEXCEPT; -#endif -EV_API_DECL void ev_invoke (EV_P_ void *w, int revents); -EV_API_DECL int ev_clear_pending (EV_P_ void *w) EV_NOEXCEPT; - -EV_API_DECL void ev_io_start (EV_P_ ev_io *w) EV_NOEXCEPT; -EV_API_DECL void ev_io_stop (EV_P_ ev_io *w) EV_NOEXCEPT; - -EV_API_DECL void ev_timer_start (EV_P_ ev_timer *w) EV_NOEXCEPT; -EV_API_DECL void ev_timer_stop (EV_P_ ev_timer *w) EV_NOEXCEPT; -/* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */ -EV_API_DECL void ev_timer_again (EV_P_ ev_timer *w) EV_NOEXCEPT; -/* return remaining time */ -EV_API_DECL ev_tstamp ev_timer_remaining (EV_P_ ev_timer *w) EV_NOEXCEPT; - -#if EV_PERIODIC_ENABLE -EV_API_DECL void ev_periodic_start (EV_P_ ev_periodic *w) EV_NOEXCEPT; -EV_API_DECL void ev_periodic_stop (EV_P_ ev_periodic *w) EV_NOEXCEPT; -EV_API_DECL void ev_periodic_again (EV_P_ ev_periodic *w) EV_NOEXCEPT; -#endif - -/* only supported in the default loop */ -#if EV_SIGNAL_ENABLE -EV_API_DECL void ev_signal_start (EV_P_ ev_signal *w) EV_NOEXCEPT; -EV_API_DECL void ev_signal_stop (EV_P_ ev_signal *w) EV_NOEXCEPT; -#endif - -/* only supported in the default loop */ -# if EV_CHILD_ENABLE -EV_API_DECL void ev_child_start (EV_P_ ev_child *w) EV_NOEXCEPT; -EV_API_DECL void ev_child_stop (EV_P_ ev_child *w) EV_NOEXCEPT; -# endif - -# if EV_STAT_ENABLE -EV_API_DECL void ev_stat_start (EV_P_ ev_stat *w) EV_NOEXCEPT; -EV_API_DECL void ev_stat_stop (EV_P_ ev_stat *w) EV_NOEXCEPT; -EV_API_DECL void ev_stat_stat (EV_P_ ev_stat *w) EV_NOEXCEPT; -# endif - -# if EV_IDLE_ENABLE -EV_API_DECL void ev_idle_start (EV_P_ ev_idle *w) EV_NOEXCEPT; -EV_API_DECL void ev_idle_stop (EV_P_ ev_idle *w) EV_NOEXCEPT; -# endif - -#if EV_PREPARE_ENABLE -EV_API_DECL void ev_prepare_start (EV_P_ ev_prepare *w) EV_NOEXCEPT; -EV_API_DECL void ev_prepare_stop (EV_P_ ev_prepare *w) EV_NOEXCEPT; -#endif - -#if EV_CHECK_ENABLE -EV_API_DECL void ev_check_start (EV_P_ ev_check *w) EV_NOEXCEPT; -EV_API_DECL void ev_check_stop (EV_P_ ev_check *w) EV_NOEXCEPT; -#endif - -# if EV_FORK_ENABLE -EV_API_DECL void ev_fork_start (EV_P_ ev_fork *w) EV_NOEXCEPT; -EV_API_DECL void ev_fork_stop (EV_P_ ev_fork *w) EV_NOEXCEPT; -# endif - -# if EV_CLEANUP_ENABLE -EV_API_DECL void ev_cleanup_start (EV_P_ ev_cleanup *w) EV_NOEXCEPT; -EV_API_DECL void ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_NOEXCEPT; -# endif - -# if EV_EMBED_ENABLE -/* only supported when loop to be embedded is in fact embeddable */ -EV_API_DECL void ev_embed_start (EV_P_ ev_embed *w) EV_NOEXCEPT; -EV_API_DECL void ev_embed_stop (EV_P_ ev_embed *w) EV_NOEXCEPT; -EV_API_DECL void ev_embed_sweep (EV_P_ ev_embed *w) EV_NOEXCEPT; -# endif - -# if EV_ASYNC_ENABLE -EV_API_DECL void ev_async_start (EV_P_ ev_async *w) EV_NOEXCEPT; -EV_API_DECL void ev_async_stop (EV_P_ ev_async *w) EV_NOEXCEPT; -EV_API_DECL void ev_async_send (EV_P_ ev_async *w) EV_NOEXCEPT; -# endif - -#if EV_COMPAT3 - #define EVLOOP_NONBLOCK EVRUN_NOWAIT - #define EVLOOP_ONESHOT EVRUN_ONCE - #define EVUNLOOP_CANCEL EVBREAK_CANCEL - #define EVUNLOOP_ONE EVBREAK_ONE - #define EVUNLOOP_ALL EVBREAK_ALL - #if EV_PROTOTYPES - EV_INLINE void ev_loop (EV_P_ int flags) { ev_run (EV_A_ flags); } - EV_INLINE void ev_unloop (EV_P_ int how ) { ev_break (EV_A_ how ); } - EV_INLINE void ev_default_destroy (void) { ev_loop_destroy (EV_DEFAULT); } - EV_INLINE void ev_default_fork (void) { ev_loop_fork (EV_DEFAULT); } - #if EV_FEATURE_API - EV_INLINE unsigned int ev_loop_count (EV_P) { return ev_iteration (EV_A); } - EV_INLINE unsigned int ev_loop_depth (EV_P) { return ev_depth (EV_A); } - EV_INLINE void ev_loop_verify (EV_P) { ev_verify (EV_A); } - #endif - #endif -#else - typedef struct ev_loop ev_loop; -#endif - -#endif - -EV_CPP(}) - -#endif - diff --git a/submodules/lev/lev/vendor/ev.pod b/submodules/lev/lev/vendor/ev.pod deleted file mode 100644 index f6fb2b7a4..000000000 --- a/submodules/lev/lev/vendor/ev.pod +++ /dev/null @@ -1,5741 +0,0 @@ -=encoding utf-8 - -=head1 NAME - -libev - a high performance full-featured event loop written in C - -=head1 SYNOPSIS - - #include - -=head2 EXAMPLE PROGRAM - - // a single header file is required - #include - - #include // for puts - - // every watcher type has its own typedef'd struct - // with the name ev_TYPE - ev_io stdin_watcher; - ev_timer timeout_watcher; - - // all watcher callbacks have a similar signature - // this callback is called when data is readable on stdin - static void - stdin_cb (EV_P_ ev_io *w, int revents) - { - puts ("stdin ready"); - // for one-shot events, one must manually stop the watcher - // with its corresponding stop function. - ev_io_stop (EV_A_ w); - - // this causes all nested ev_run's to stop iterating - ev_break (EV_A_ EVBREAK_ALL); - } - - // another callback, this time for a time-out - static void - timeout_cb (EV_P_ ev_timer *w, int revents) - { - puts ("timeout"); - // this causes the innermost ev_run to stop iterating - ev_break (EV_A_ EVBREAK_ONE); - } - - int - main (void) - { - // use the default event loop unless you have special needs - struct ev_loop *loop = EV_DEFAULT; - - // initialise an io watcher, then start it - // this one will watch for stdin to become readable - ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); - ev_io_start (loop, &stdin_watcher); - - // initialise a timer watcher, then start it - // simple non-repeating 5.5 second timeout - ev_timer_init (&timeout_watcher, timeout_cb, 5.5, 0.); - ev_timer_start (loop, &timeout_watcher); - - // now wait for events to arrive - ev_run (loop, 0); - - // break was called, so exit - return 0; - } - -=head1 ABOUT THIS DOCUMENT - -This document documents the libev software package. - -The newest version of this document is also available as an html-formatted -web page you might find easier to navigate when reading it for the first -time: L. - -While this document tries to be as complete as possible in documenting -libev, its usage and the rationale behind its design, it is not a tutorial -on event-based programming, nor will it introduce event-based programming -with libev. - -Familiarity with event based programming techniques in general is assumed -throughout this document. - -=head1 WHAT TO READ WHEN IN A HURRY - -This manual tries to be very detailed, but unfortunately, this also makes -it very long. If you just want to know the basics of libev, I suggest -reading L, then the L above and -look up the missing functions in L and the C and -C sections in L. - -=head1 ABOUT LIBEV - -Libev is an event loop: you register interest in certain events (such as a -file descriptor being readable or a timeout occurring), and it will manage -these event sources and provide your program with events. - -To do this, it must take more or less complete control over your process -(or thread) by executing the I handler, and will then -communicate events via a callback mechanism. - -You register interest in certain events by registering so-called I, which are relatively small C structures you initialise with the -details of the event, and then hand it over to libev by I the -watcher. - -=head2 FEATURES - -Libev supports C (files, many character devices...). - -Epoll is truly the train wreck among event poll mechanisms, a frankenpoll, -cobbled together in a hurry, no thought to design or interaction with -others. Oh, the pain, will it ever stop... - -While stopping, setting and starting an I/O watcher in the same iteration -will result in some caching, there is still a system call per such -incident (because the same I could point to a different -I now), so its best to avoid that. Also, C'ed -file descriptors might not work very well if you register events for both -file descriptors. - -Best performance from this backend is achieved by not unregistering all -watchers for a file descriptor until it has been closed, if possible, -i.e. keep at least one watcher active per fd at all times. Stopping and -starting a watcher (without re-setting it) also usually doesn't cause -extra overhead. A fork can both result in spurious notifications as well -as in libev having to destroy and recreate the epoll object, which can -take considerable time and thus should be avoided. - -All this means that, in practice, C can be as fast or -faster than epoll for maybe up to a hundred file descriptors, depending on -the usage. So sad. - -While nominally embeddable in other event loops, this feature is broken in -a lot of kernel revisions, but probably(!) works in current versions. - -This backend maps C and C in the same way as -C. - -=item C (value 64, Linux) - -Use the Linux-specific Linux AIO (I C<< aio(7) >> but C<< -io_submit(2) >>) event interface available in post-4.18 kernels (but libev -only tries to use it in 4.19+). - -This is another Linux train wreck of an event interface. - -If this backend works for you (as of this writing, it was very -experimental), it is the best event interface available on Linux and might -be well worth enabling it - if it isn't available in your kernel this will -be detected and this backend will be skipped. - -This backend can batch oneshot requests and supports a user-space ring -buffer to receive events. It also doesn't suffer from most of the design -problems of epoll (such as not being able to remove event sources from -the epoll set), and generally sounds too good to be true. Because, this -being the Linux kernel, of course it suffers from a whole new set of -limitations, forcing you to fall back to epoll, inheriting all its design -issues. - -For one, it is not easily embeddable (but probably could be done using -an event fd at some extra overhead). It also is subject to a system wide -limit that can be configured in F. If no AIO -requests are left, this backend will be skipped during initialisation, and -will switch to epoll when the loop is active. - -Most problematic in practice, however, is that not all file descriptors -work with it. For example, in Linux 5.1, TCP sockets, pipes, event fds, -files, F and many others are supported, but ttys do not work -properly (a known bug that the kernel developers don't care about, see -L), so this is not -(yet?) a generic event polling interface. - -Overall, it seems the Linux developers just don't want it to have a -generic event handling mechanism other than C which have a high -overhead for the actual polling but can deliver many events at once. - -By setting a higher I you allow libev to spend more -time collecting I/O events, so you can handle more events per iteration, -at the cost of increasing latency. Timeouts (both C and -C) will not be affected. Setting this to a non-null value will -introduce an additional C call into most loop iterations. The -sleep time ensures that libev will not poll for I/O events more often then -once per this interval, on average (as long as the host time resolution is -good enough). - -Likewise, by setting a higher I you allow libev -to spend more time collecting timeouts, at the expense of increased -latency/jitter/inexactness (the watcher callback will be called -later). C watchers will not be affected. Setting this to a non-null -value will not introduce any overhead in libev. - -Many (busy) programs can usually benefit by setting the I/O collect -interval to a value near C<0.1> or so, which is often enough for -interactive servers (of course not for games), likewise for timeouts. It -usually doesn't make much sense to set it to a lower value than C<0.01>, -as this approaches the timing granularity of most systems. Note that if -you do transactions with the outside world and you can't increase the -parallelity, then this setting will limit your transaction rate (if you -need to poll once per transaction and the I/O collect interval is 0.01, -then you can't do more than 100 transactions per second). - -Setting the I can improve the opportunity for -saving power, as the program will "bundle" timer callback invocations that -are "near" in time together, by delaying some, thus reducing the number of -times the process sleeps and wakes up again. Another useful technique to -reduce iterations/wake-ups is to use C watchers and make sure -they fire on, say, one-second boundaries only. - -Example: we only need 0.1s timeout granularity, and we wish not to poll -more often than 100 times per second: - - ev_set_timeout_collect_interval (EV_DEFAULT_UC_ 0.1); - ev_set_io_collect_interval (EV_DEFAULT_UC_ 0.01); - -=item ev_invoke_pending (loop) - -This call will simply invoke all pending watchers while resetting their -pending state. Normally, C does this automatically when required, -but when overriding the invoke callback this call comes handy. This -function can be invoked from a watcher - this can be useful for example -when you want to do some lengthy calculation and want to pass further -event handling to another thread (you still have to make sure only one -thread executes within C or C of course). - -=item int ev_pending_count (loop) - -Returns the number of pending watchers - zero indicates that no watchers -are pending. - -=item ev_set_invoke_pending_cb (loop, void (*invoke_pending_cb)(EV_P)) - -This overrides the invoke pending functionality of the loop: Instead of -invoking all pending watchers when there are any, C will call -this callback instead. This is useful, for example, when you want to -invoke the actual watchers inside another context (another thread etc.). - -If you want to reset the callback, use C as new -callback. - -=item ev_set_loop_release_cb (loop, void (*release)(EV_P) throw (), void (*acquire)(EV_P) throw ()) - -Sometimes you want to share the same loop between multiple threads. This -can be done relatively simply by putting mutex_lock/unlock calls around -each call to a libev function. - -However, C can run an indefinite time, so it is not feasible -to wait for it to return. One way around this is to wake up the event -loop via C and C, another way is to set these -I and I callbacks on the loop. - -When set, then C will be called just before the thread is -suspended waiting for new events, and C is called just -afterwards. - -Ideally, C will just call your mutex_unlock function, and -C will just call the mutex_lock function again. - -While event loop modifications are allowed between invocations of -C and C (that's their only purpose after all), no -modifications done will affect the event loop, i.e. adding watchers will -have no effect on the set of file descriptors being watched, or the time -waited. Use an C watcher to wake up C when you want it -to take note of any changes you made. - -In theory, threads executing C will be async-cancel safe between -invocations of C and C. - -See also the locking example in the C section later in this -document. - -=item ev_set_userdata (loop, void *data) - -=item void *ev_userdata (loop) - -Set and retrieve a single C associated with a loop. When -C has never been called, then C returns -C<0>. - -These two functions can be used to associate arbitrary data with a loop, -and are intended solely for the C, C and -C callbacks described above, but of course can be (ab-)used for -any other purpose as well. - -=item ev_verify (loop) - -This function only does something when C support has been -compiled in, which is the default for non-minimal builds. It tries to go -through all internal structures and checks them for validity. If anything -is found to be inconsistent, it will print an error message to standard -error and call C. - -This can be used to catch bugs inside libev itself: under normal -circumstances, this function will never abort as of course libev keeps its -data structures consistent. - -=back - - -=head1 ANATOMY OF A WATCHER - -In the following description, uppercase C in names stands for the -watcher type, e.g. C can mean C for timer -watchers and C for I/O watchers. - -A watcher is an opaque structure that you allocate and register to record -your interest in some event. To make a concrete example, imagine you want -to wait for STDIN to become readable, you would create an C watcher -for that: - - static void my_cb (struct ev_loop *loop, ev_io *w, int revents) - { - ev_io_stop (w); - ev_break (loop, EVBREAK_ALL); - } - - struct ev_loop *loop = ev_default_loop (0); - - ev_io stdin_watcher; - - ev_init (&stdin_watcher, my_cb); - ev_io_set (&stdin_watcher, STDIN_FILENO, EV_READ); - ev_io_start (loop, &stdin_watcher); - - ev_run (loop, 0); - -As you can see, you are responsible for allocating the memory for your -watcher structures (and it is I a bad idea to do this on the -stack). - -Each watcher has an associated watcher structure (called C -or simply C, as typedefs are provided for all watcher structs). - -Each watcher structure must be initialised by a call to C, which expects a callback to be provided. This callback is -invoked each time the event occurs (or, in the case of I/O watchers, each -time the event loop detects that the file descriptor given is readable -and/or writable). - -Each watcher type further has its own C<< ev_TYPE_set (watcher *, ...) >> -macro to configure it, with arguments specific to the watcher type. There -is also a macro to combine initialisation and setting in one call: C<< -ev_TYPE_init (watcher *, callback, ...) >>. - -To make the watcher actually watch out for events, you have to start it -with a watcher-specific start function (C<< ev_TYPE_start (loop, watcher -*) >>), and you can stop watching for events at any time by calling the -corresponding stop function (C<< ev_TYPE_stop (loop, watcher *) >>. - -As long as your watcher is active (has been started but not stopped) you -must not touch the values stored in it except when explicitly documented -otherwise. Most specifically you must never reinitialise it or call its -C macro. - -Each and every callback receives the event loop pointer as first, the -registered watcher structure as second, and a bitset of received events as -third argument. - -The received events usually include a single bit per event type received -(you can receive multiple events at the same time). The possible bit masks -are: - -=over 4 - -=item C - -=item C - -The file descriptor in the C watcher has become readable and/or -writable. - -=item C - -The C watcher has timed out. - -=item C - -The C watcher has timed out. - -=item C - -The signal specified in the C watcher has been received by a thread. - -=item C - -The pid specified in the C watcher has received a status change. - -=item C - -The path specified in the C watcher changed its attributes somehow. - -=item C - -The C watcher has determined that you have nothing better to do. - -=item C - -=item C - -All C watchers are invoked just I C starts to -gather new events, and all C watchers are queued (not invoked) -just after C has gathered them, but before it queues any callbacks -for any received events. That means C watchers are the last -watchers invoked before the event loop sleeps or polls for new events, and -C watchers will be invoked before any other watchers of the same -or lower priority within an event loop iteration. - -Callbacks of both watcher types can start and stop as many watchers as -they want, and all of them will be taken into account (for example, a -C watcher might start an idle watcher to keep C from -blocking). - -=item C - -The embedded event loop specified in the C watcher needs attention. - -=item C - -The event loop has been resumed in the child process after fork (see -C). - -=item C - -The event loop is about to be destroyed (see C). - -=item C - -The given async watcher has been asynchronously notified (see C). - -=item C - -Not ever sent (or otherwise used) by libev itself, but can be freely used -by libev users to signal watchers (e.g. via C). - -=item C - -An unspecified error has occurred, the watcher has been stopped. This might -happen because the watcher could not be properly started because libev -ran out of memory, a file descriptor was found to be closed or any other -problem. Libev considers these application bugs. - -You best act on it by reporting the problem and somehow coping with the -watcher being stopped. Note that well-written programs should not receive -an error ever, so when your watcher receives it, this usually indicates a -bug in your program. - -Libev will usually signal a few "dummy" events together with an error, for -example it might indicate that a fd is readable or writable, and if your -callbacks is well-written it can just attempt the operation and cope with -the error from read() or write(). This will not work in multi-threaded -programs, though, as the fd could already be closed and reused for another -thing, so beware. - -=back - -=head2 GENERIC WATCHER FUNCTIONS - -=over 4 - -=item C (ev_TYPE *watcher, callback) - -This macro initialises the generic portion of a watcher. The contents -of the watcher object can be arbitrary (so C will do). Only -the generic parts of the watcher are initialised, you I to call -the type-specific C macro afterwards to initialise the -type-specific parts. For each type there is also a C macro -which rolls both calls into one. - -You can reinitialise a watcher at any time as long as it has been stopped -(or never started) and there are no pending events outstanding. - -The callback is always of type C. - -Example: Initialise an C watcher in two steps. - - ev_io w; - ev_init (&w, my_cb); - ev_io_set (&w, STDIN_FILENO, EV_READ); - -=item C (ev_TYPE *watcher, [args]) - -This macro initialises the type-specific parts of a watcher. You need to -call C at least once before you call this macro, but you can -call C any number of times. You must not, however, call this -macro on a watcher that is active (it can be pending, however, which is a -difference to the C macro). - -Although some watcher types do not have type-specific arguments -(e.g. C) you still need to call its C macro. - -See C, above, for an example. - -=item C (ev_TYPE *watcher, callback, [args]) - -This convenience macro rolls both C and C macro -calls into a single call. This is the most convenient method to initialise -a watcher. The same limitations apply, of course. - -Example: Initialise and set an C watcher in one step. - - ev_io_init (&w, my_cb, STDIN_FILENO, EV_READ); - -=item C (loop, ev_TYPE *watcher) - -Starts (activates) the given watcher. Only active watchers will receive -events. If the watcher is already active nothing will happen. - -Example: Start the C watcher that is being abused as example in this -whole section. - - ev_io_start (EV_DEFAULT_UC, &w); - -=item C (loop, ev_TYPE *watcher) - -Stops the given watcher if active, and clears the pending status (whether -the watcher was active or not). - -It is possible that stopped watchers are pending - for example, -non-repeating timers are being stopped when they become pending - but -calling C ensures that the watcher is neither active nor -pending. If you want to free or reuse the memory used by the watcher it is -therefore a good idea to always call its C function. - -=item bool ev_is_active (ev_TYPE *watcher) - -Returns a true value iff the watcher is active (i.e. it has been started -and not yet been stopped). As long as a watcher is active you must not modify -it unless documented otherwise. - -=item bool ev_is_pending (ev_TYPE *watcher) - -Returns a true value iff the watcher is pending, (i.e. it has outstanding -events but its callback has not yet been invoked). As long as a watcher -is pending (but not active) you must not call an init function on it (but -C is safe), you must not change its priority, and you must -make sure the watcher is available to libev (e.g. you cannot C -it). - -=item callback ev_cb (ev_TYPE *watcher) - -Returns the callback currently set on the watcher. - -=item ev_set_cb (ev_TYPE *watcher, callback) - -Change the callback. You can change the callback at virtually any time -(modulo threads). - -=item ev_set_priority (ev_TYPE *watcher, int priority) - -=item int ev_priority (ev_TYPE *watcher) - -Set and query the priority of the watcher. The priority is a small -integer between C (default: C<2>) and C -(default: C<-2>). Pending watchers with higher priority will be invoked -before watchers with lower priority, but priority will not keep watchers -from being executed (except for C watchers). - -If you need to suppress invocation when higher priority events are pending -you need to look at C watchers, which provide this functionality. - -You I change the priority of a watcher as long as it is active or -pending. - -Setting a priority outside the range of C to C is -fine, as long as you do not mind that the priority value you query might -or might not have been clamped to the valid range. - -The default priority used by watchers when no priority has been set is -always C<0>, which is supposed to not be too high and not be too low :). - -See L, below, for a more thorough treatment of -priorities. - -=item ev_invoke (loop, ev_TYPE *watcher, int revents) - -Invoke the C with the given C and C. Neither -C nor C need to be valid as long as the watcher callback -can deal with that fact, as both are simply passed through to the -callback. - -=item int ev_clear_pending (loop, ev_TYPE *watcher) - -If the watcher is pending, this function clears its pending status and -returns its C bitset (as if its callback was invoked). If the -watcher isn't pending it does nothing and returns C<0>. - -Sometimes it can be useful to "poll" a watcher instead of waiting for its -callback to be invoked, which can be accomplished with this function. - -=item ev_feed_event (loop, ev_TYPE *watcher, int revents) - -Feeds the given event set into the event loop, as if the specified event -had happened for the specified watcher (which must be a pointer to an -initialised but not necessarily started event watcher). Obviously you must -not free the watcher as long as it has pending events. - -Stopping the watcher, letting libev invoke it, or calling -C will clear the pending event, even if the watcher was -not started in the first place. - -See also C and C for related -functions that do not need a watcher. - -=back - -See also the L and L idioms. - -=head2 WATCHER STATES - -There are various watcher states mentioned throughout this manual - -active, pending and so on. In this section these states and the rules to -transition between them will be described in more detail - and while these -rules might look complicated, they usually do "the right thing". - -=over 4 - -=item initialised - -Before a watcher can be registered with the event loop it has to be -initialised. This can be done with a call to C, or calls to -C followed by the watcher-specific C function. - -In this state it is simply some block of memory that is suitable for -use in an event loop. It can be moved around, freed, reused etc. at -will - as long as you either keep the memory contents intact, or call -C again. - -=item started/running/active - -Once a watcher has been started with a call to C it becomes -property of the event loop, and is actively waiting for events. While in -this state it cannot be accessed (except in a few documented ways), moved, -freed or anything else - the only legal thing is to keep a pointer to it, -and call libev functions on it that are documented to work on active watchers. - -=item pending - -If a watcher is active and libev determines that an event it is interested -in has occurred (such as a timer expiring), it will become pending. It will -stay in this pending state until either it is stopped or its callback is -about to be invoked, so it is not normally pending inside the watcher -callback. - -The watcher might or might not be active while it is pending (for example, -an expired non-repeating timer can be pending but no longer active). If it -is stopped, it can be freely accessed (e.g. by calling C), -but it is still property of the event loop at this time, so cannot be -moved, freed or reused. And if it is active the rules described in the -previous item still apply. - -It is also possible to feed an event on a watcher that is not active (e.g. -via C), in which case it becomes pending without being -active. - -=item stopped - -A watcher can be stopped implicitly by libev (in which case it might still -be pending), or explicitly by calling its C function. The -latter will clear any pending state the watcher might be in, regardless -of whether it was active or not, so stopping a watcher explicitly before -freeing it is often a good idea. - -While stopped (and not pending) the watcher is essentially in the -initialised state, that is, it can be reused, moved, modified in any way -you wish (but when you trash the memory block, you need to C -it again). - -=back - -=head2 WATCHER PRIORITY MODELS - -Many event loops support I, which are usually small -integers that influence the ordering of event callback invocation -between watchers in some way, all else being equal. - -In libev, watcher priorities can be set using C. See its -description for the more technical details such as the actual priority -range. - -There are two common ways how these these priorities are being interpreted -by event loops: - -In the more common lock-out model, higher priorities "lock out" invocation -of lower priority watchers, which means as long as higher priority -watchers receive events, lower priority watchers are not being invoked. - -The less common only-for-ordering model uses priorities solely to order -callback invocation within a single event loop iteration: Higher priority -watchers are invoked before lower priority ones, but they all get invoked -before polling for new events. - -Libev uses the second (only-for-ordering) model for all its watchers -except for idle watchers (which use the lock-out model). - -The rationale behind this is that implementing the lock-out model for -watchers is not well supported by most kernel interfaces, and most event -libraries will just poll for the same events again and again as long as -their callbacks have not been executed, which is very inefficient in the -common case of one high-priority watcher locking out a mass of lower -priority ones. - -Static (ordering) priorities are most useful when you have two or more -watchers handling the same resource: a typical usage example is having an -C watcher to receive data, and an associated C to handle -timeouts. Under load, data might be received while the program handles -other jobs, but since timers normally get invoked first, the timeout -handler will be executed before checking for data. In that case, giving -the timer a lower priority than the I/O watcher ensures that I/O will be -handled first even under adverse conditions (which is usually, but not -always, what you want). - -Since idle watchers use the "lock-out" model, meaning that idle watchers -will only be executed when no same or higher priority watchers have -received events, they can be used to implement the "lock-out" model when -required. - -For example, to emulate how many other event libraries handle priorities, -you can associate an C watcher to each such watcher, and in -the normal watcher callback, you just start the idle watcher. The real -processing is done in the idle watcher callback. This causes libev to -continuously poll and process kernel event data for the watcher, but when -the lock-out case is known to be rare (which in turn is rare :), this is -workable. - -Usually, however, the lock-out model implemented that way will perform -miserably under the type of load it was designed to handle. In that case, -it might be preferable to stop the real watcher before starting the -idle watcher, so the kernel will not have to process the event in case -the actual processing will be delayed for considerable time. - -Here is an example of an I/O watcher that should run at a strictly lower -priority than the default, and which should only process data when no -other events are pending: - - ev_idle idle; // actual processing watcher - ev_io io; // actual event watcher - - static void - io_cb (EV_P_ ev_io *w, int revents) - { - // stop the I/O watcher, we received the event, but - // are not yet ready to handle it. - ev_io_stop (EV_A_ w); - - // start the idle watcher to handle the actual event. - // it will not be executed as long as other watchers - // with the default priority are receiving events. - ev_idle_start (EV_A_ &idle); - } - - static void - idle_cb (EV_P_ ev_idle *w, int revents) - { - // actual processing - read (STDIN_FILENO, ...); - - // have to start the I/O watcher again, as - // we have handled the event - ev_io_start (EV_P_ &io); - } - - // initialisation - ev_idle_init (&idle, idle_cb); - ev_io_init (&io, io_cb, STDIN_FILENO, EV_READ); - ev_io_start (EV_DEFAULT_ &io); - -In the "real" world, it might also be beneficial to start a timer, so that -low-priority connections can not be locked out forever under load. This -enables your program to keep a lower latency for important connections -during short periods of high load, while not completely locking out less -important ones. - - -=head1 WATCHER TYPES - -This section describes each watcher in detail, but will not repeat -information given in the last section. Any initialisation/set macros, -functions and members specific to the watcher type are explained. - -Most members are additionally marked with either I<[read-only]>, meaning -that, while the watcher is active, you can look at the member and expect -some sensible content, but you must not modify it (you can modify it while -the watcher is stopped to your hearts content), or I<[read-write]>, which -means you can expect it to have some sensible content while the watcher is -active, but you can also modify it (within the same thread as the event -loop, i.e. without creating data races). Modifying it may not do something -sensible or take immediate effect (or do anything at all), but libev will -not crash or malfunction in any way. - -In any case, the documentation for each member will explain what the -effects are, and if there are any additional access restrictions. - -=head2 C - is this file descriptor readable or writable? - -I/O watchers check whether a file descriptor is readable or writable -in each iteration of the event loop, or, more precisely, when reading -would not block the process and writing would at least be able to write -some data. This behaviour is called level-triggering because you keep -receiving events as long as the condition persists. Remember you can stop -the watcher if you don't want to act on the event and neither want to -receive future events. - -In general you can register as many read and/or write event watchers per -fd as you want (as long as you don't confuse yourself). Setting all file -descriptors to non-blocking mode is also usually a good idea (but not -required if you know what you are doing). - -Another thing you have to watch out for is that it is quite easy to -receive "spurious" readiness notifications, that is, your callback might -be called with C but a subsequent C(2) will actually block -because there is no data. It is very easy to get into this situation even -with a relatively standard program structure. Thus it is best to always -use non-blocking I/O: An extra C(2) returning C is far -preferable to a program hanging until some data arrives. - -If you cannot run the fd in non-blocking mode (for example you should -not play around with an Xlib connection), then you have to separately -re-test whether a file descriptor is really ready with a known-to-be good -interface such as poll (fortunately in the case of Xlib, it already does -this on its own, so its quite safe to use). Some people additionally -use C and an interval timer, just to be sure you won't block -indefinitely. - -But really, best use non-blocking mode. - -=head3 The special problem of disappearing file descriptors - -Some backends (e.g. kqueue, epoll, linuxaio) need to be told about closing -a file descriptor (either due to calling C explicitly or any other -means, such as C). The reason is that you register interest in some -file descriptor, but when it goes away, the operating system will silently -drop this interest. If another file descriptor with the same number then -is registered with libev, there is no efficient way to see that this is, -in fact, a different file descriptor. - -To avoid having to explicitly tell libev about such cases, libev follows -the following policy: Each time C is being called, libev -will assume that this is potentially a new file descriptor, otherwise -it is assumed that the file descriptor stays the same. That means that -you I to call C (or C) when you change the -descriptor even if the file descriptor number itself did not change. - -This is how one would do it normally anyway, the important point is that -the libev application should not optimise around libev but should leave -optimisations to libev. - -=head3 The special problem of dup'ed file descriptors - -Some backends (e.g. epoll), cannot register events for file descriptors, -but only events for the underlying file descriptions. That means when you -have C'ed file descriptors or weirder constellations, and register -events for them, only one file descriptor might actually receive events. - -There is no workaround possible except not registering events -for potentially C'ed file descriptors, or to resort to -C or C. - -=head3 The special problem of files - -Many people try to use C. - -=item EV_USE_EVENTFD - -If defined to be C<1>, then libev will assume that C is -available and will probe for kernel support at runtime. This will improve -C and C performance and reduce resource consumption. -If undefined, it will be enabled if the headers indicate GNU/Linux + Glibc -2.7 or newer, otherwise disabled. - -=item EV_USE_SIGNALFD - -If defined to be C<1>, then libev will assume that C is -available and will probe for kernel support at runtime. This enables -the use of EVFLAG_SIGNALFD for faster and simpler signal handling. If -undefined, it will be enabled if the headers indicate GNU/Linux + Glibc -2.7 or newer, otherwise disabled. - -=item EV_USE_TIMERFD - -If defined to be C<1>, then libev will assume that C is -available and will probe for kernel support at runtime. This allows -libev to detect time jumps accurately. If undefined, it will be enabled -if the headers indicate GNU/Linux + Glibc 2.8 or newer and define -C, otherwise disabled. - -=item EV_USE_EVENTFD - -If defined to be C<1>, then libev will assume that C is -available and will probe for kernel support at runtime. This will improve -C and C performance and reduce resource consumption. -If undefined, it will be enabled if the headers indicate GNU/Linux + Glibc -2.7 or newer, otherwise disabled. - -=item EV_USE_SELECT - -If undefined or defined to be C<1>, libev will compile in support for the -C is buggy - -All that's left is C actively limits the number of file -descriptors you can pass in to 1024 - your program suddenly crashes when -you use more. - -There is an undocumented "workaround" for this - defining -C<_DARWIN_UNLIMITED_SELECT>, which libev tries to use, so select I -work on OS/X. - -=head2 SOLARIS PROBLEMS AND WORKAROUNDS - -=head3 C reentrancy - -The default compile environment on Solaris is unfortunately so -thread-unsafe that you can't even use components/libraries compiled -without C<-D_REENTRANT> in a threaded program, which, of course, isn't -defined by default. A valid, if stupid, implementation choice. - -If you want to use libev in threaded environments you have to make sure -it's compiled with C<_REENTRANT> defined. - -=head3 Event port backend - -The scalable event interface for Solaris is called "event -ports". Unfortunately, this mechanism is very buggy in all major -releases. If you run into high CPU usage, your program freezes or you get -a large number of spurious wakeups, make sure you have all the relevant -and latest kernel patches applied. No, I don't know which ones, but there -are multiple ones to apply, and afterwards, event ports actually work -great. - -If you can't get it to work, you can try running the program by setting -the environment variable C to only allow C and -C works fine -with large bitsets on AIX, and AIX is dead anyway. - -=head2 WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS - -=head3 General issues - -Win32 doesn't support any of the standards (e.g. POSIX) that libev -requires, and its I/O model is fundamentally incompatible with the POSIX -model. Libev still offers limited functionality on this platform in -the form of the C backend, and only supports socket -descriptors. This only applies when using Win32 natively, not when using -e.g. cygwin. Actually, it only applies to the microsofts own compilers, -as every compiler comes with a slightly differently broken/incompatible -environment. - -Lifting these limitations would basically require the full -re-implementation of the I/O system. If you are into this kind of thing, -then note that glib does exactly that for you in a very portable way (note -also that glib is the slowest event library known to man). - -There is no supported compilation method available on windows except -embedding it into other applications. - -Sensible signal handling is officially unsupported by Microsoft - libev -tries its best, but under most conditions, signals will simply not work. - -Not a libev limitation but worth mentioning: windows apparently doesn't -accept large writes: instead of resulting in a partial write, windows will -either accept everything or return C if the buffer is too large, -so make sure you only write small amounts into your sockets (less than a -megabyte seems safe, but this apparently depends on the amount of memory -available). - -Due to the many, low, and arbitrary limits on the win32 platform and -the abysmal performance of winsockets, using a large number of sockets -is not recommended (and not reasonable). If your program needs to use -more than a hundred or so sockets, then likely it needs to use a totally -different implementation for windows, as libev offers the POSIX readiness -notification model, which cannot be implemented efficiently on windows -(due to Microsoft monopoly games). - -A typical way to use libev under windows is to embed it (see the embedding -section for details) and use the following F header file instead -of F: - - #define EV_STANDALONE /* keeps ev from requiring config.h */ - #define EV_SELECT_IS_WINSOCKET 1 /* configure libev for windows select */ - - #include "ev.h" - -And compile the following F file into your project (make sure -you do I compile the F or any other embedded source files!): - - #include "evwrap.h" - #include "ev.c" - -=head3 The winsocket C function doesn't follow POSIX in that it -requires socket I and not socket I (it is -also extremely buggy). This makes select very inefficient, and also -requires a mapping from file descriptors to socket handles (the Microsoft -C runtime provides the function C<_open_osfhandle> for this). See the -discussion of the C, C and -C preprocessor symbols for more info. - -The configuration for a "naked" win32 using the Microsoft runtime -libraries and raw winsocket select is: - - #define EV_USE_SELECT 1 - #define EV_SELECT_IS_WINSOCKET 1 /* forces EV_SELECT_USE_FD_SET, too */ - -Note that winsockets handling of fd sets is O(n), so you can easily get a -complexity in the O(n²) range when using win32. - -=head3 Limited number of file descriptors - -Windows has numerous arbitrary (and low) limits on things. - -Early versions of winsocket's select only supported waiting for a maximum -of C<64> handles (probably owning to the fact that all windows kernels -can only wait for C<64> things at the same time internally; Microsoft -recommends spawning a chain of threads and wait for 63 handles and the -previous thread in each. Sounds great!). - -Newer versions support more handles, but you need to define C -to some high number (e.g. C<2048>) before compiling the winsocket select -call (which might be in libev or elsewhere, for example, perl and many -other interpreters do their own select emulation on windows). - -Another limit is the number of file descriptors in the Microsoft runtime -libraries, which by default is C<64> (there must be a hidden I<64> -fetish or something like this inside Microsoft). You can increase this -by calling C<_setmaxstdio>, which can increase this limit to C<2048> -(another arbitrary limit), but is broken in many versions of the Microsoft -runtime libraries. This might get you to about C<512> or C<2048> sockets -(depending on windows version and/or the phase of the moon). To get more, -you need to wrap all I/O functions and provide your own fd management, but -the cost of calling select (O(n²)) will likely make this unworkable. - -=head2 PORTABILITY REQUIREMENTS - -In addition to a working ISO-C implementation and of course the -backend-specific APIs, libev relies on a few additional extensions: - -=over 4 - -=item C must have compatible -calling conventions regardless of C. - -Libev assumes not only that all watcher pointers have the same internal -structure (guaranteed by POSIX but not by ISO C for example), but it also -assumes that the same (machine) code can be used to call any watcher -callback: The watcher callbacks have different type signatures, but libev -calls them using an C internally. - -=item null pointers and integer zero are represented by 0 bytes - -Libev uses C to initialise structs and arrays to C<0> bytes, and -relies on this setting pointers and integers to null. - -=item pointer accesses must be thread-atomic - -Accessing a pointer value must be atomic, it must both be readable and -writable in one piece - this is the case on all current architectures. - -=item C must be thread-atomic as well - -The type C (or whatever is defined as -C) must be atomic with respect to accesses from different -threads. This is not part of the specification for C, but is -believed to be sufficiently portable. - -=item C must work in a threaded environment - -Libev uses C to temporarily block signals. This is not -allowed in a threaded program (C has to be used). Typical -pthread implementations will either allow C in the "main -thread" or will block signals process-wide, both behaviours would -be compatible with libev. Interaction between C and -C could complicate things, however. - -The most portable way to handle signals is to block signals in all threads -except the initial one, and run the signal handling loop in the initial -thread as well. - -=item C must be large enough for common memory allocation sizes - -To improve portability and simplify its API, libev uses C internally -instead of C when allocating its data structures. On non-POSIX -systems (Microsoft...) this might be unexpectedly low, but is still at -least 31 bits everywhere, which is enough for hundreds of millions of -watchers. - -=item C must hold a time value in seconds with enough accuracy - -The type C is used to represent timestamps. It is required to -have at least 51 bits of mantissa (and 9 bits of exponent), which is -good enough for at least into the year 4000 with millisecond accuracy -(the design goal for libev). This requirement is overfulfilled by -implementations using IEEE 754, which is basically all existing ones. - -With IEEE 754 doubles, you get microsecond accuracy until at least the -year 2255 (and millisecond accuracy till the year 287396 - by then, libev -is either obsolete or somebody patched it to use C or -something like that, just kidding). - -=back - -If you know of other additional requirements drop me a note. - - -=head1 ALGORITHMIC COMPLEXITIES - -In this section the complexities of (many of) the algorithms used inside -libev will be documented. For complexity discussions about backends see -the documentation for C. - -All of the following are about amortised time: If an array needs to be -extended, libev needs to realloc and move the whole array, but this -happens asymptotically rarer with higher number of elements, so O(1) might -mean that libev does a lengthy realloc operation in rare cases, but on -average it is much faster and asymptotically approaches constant time. - -=over 4 - -=item Starting and stopping timer/periodic watchers: O(log skipped_other_timers) - -This means that, when you have a watcher that triggers in one hour and -there are 100 watchers that would trigger before that, then inserting will -have to skip roughly seven (C) of these watchers. - -=item Changing timer/periodic watchers (by autorepeat or calling again): O(log skipped_other_timers) - -That means that changing a timer costs less than removing/adding them, -as only the relative motion in the event queue has to be paid for. - -=item Starting io/check/prepare/idle/signal/child/fork/async watchers: O(1) - -These just add the watcher into an array or at the head of a list. - -=item Stopping check/prepare/idle/fork/async watchers: O(1) - -=item Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % EV_PID_HASHSIZE)) - -These watchers are stored in lists, so they need to be walked to find the -correct watcher to remove. The lists are usually short (you don't usually -have many watchers waiting for the same fd or signal: one is typical, two -is rare). - -=item Finding the next timer in each loop iteration: O(1) - -By virtue of using a binary or 4-heap, the next timer is always found at a -fixed position in the storage array. - -=item Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd) - -A change means an I/O watcher gets started or stopped, which requires -libev to recalculate its status (and possibly tell the kernel, depending -on backend and whether C was used). - -=item Activating one watcher (putting it into the pending state): O(1) - -=item Priority handling: O(number_of_priorities) - -Priorities are implemented by allocating some space for each -priority. When doing priority-based operations, libev usually has to -linearly search all the priorities, but starting/stopping and activating -watchers becomes O(1) with respect to priority handling. - -=item Sending an ev_async: O(1) - -=item Processing ev_async_send: O(number_of_async_watchers) - -=item Processing signals: O(max_signal_number) - -Sending involves a system call I there were no other C -calls in the current loop iteration and the loop is currently -blocked. Checking for async and signal events involves iterating over all -running async watchers or all signal numbers. - -=back - - -=head1 PORTING FROM LIBEV 3.X TO 4.X - -The major version 4 introduced some incompatible changes to the API. - -At the moment, the C header file provides compatibility definitions -for all changes, so most programs should still compile. The compatibility -layer might be removed in later versions of libev, so better update to the -new API early than late. - -=over 4 - -=item C backwards compatibility mechanism - -The backward compatibility mechanism can be controlled by -C. See L in the L -section. - -=item C and C have been removed - -These calls can be replaced easily by their C counterparts: - - ev_loop_destroy (EV_DEFAULT_UC); - ev_loop_fork (EV_DEFAULT); - -=item function/symbol renames - -A number of functions and symbols have been renamed: - - ev_loop => ev_run - EVLOOP_NONBLOCK => EVRUN_NOWAIT - EVLOOP_ONESHOT => EVRUN_ONCE - - ev_unloop => ev_break - EVUNLOOP_CANCEL => EVBREAK_CANCEL - EVUNLOOP_ONE => EVBREAK_ONE - EVUNLOOP_ALL => EVBREAK_ALL - - EV_TIMEOUT => EV_TIMER - - ev_loop_count => ev_iteration - ev_loop_depth => ev_depth - ev_loop_verify => ev_verify - -Most functions working on C objects don't have an -C prefix, so it was removed; C, C and -associated constants have been renamed to not collide with the C anymore and C now follows the same naming scheme -as all other watcher types. Note that C is still called -C because it would otherwise clash with the C -typedef. - -=item C mechanism replaced by C - -The preprocessor symbol C has been replaced by a different -mechanism, C. Programs using C usually compile -and work, but the library code will of course be larger. - -=back - - -=head1 GLOSSARY - -=over 4 - -=item active - -A watcher is active as long as it has been started and not yet stopped. -See L for details. - -=item application - -In this document, an application is whatever is using libev. - -=item backend - -The part of the code dealing with the operating system interfaces. - -=item callback - -The address of a function that is called when some event has been -detected. Callbacks are being passed the event loop, the watcher that -received the event, and the actual event bitset. - -=item callback/watcher invocation - -The act of calling the callback associated with a watcher. - -=item event - -A change of state of some external event, such as data now being available -for reading on a file descriptor, time having passed or simply not having -any other events happening anymore. - -In libev, events are represented as single bits (such as C or -C). - -=item event library - -A software package implementing an event model and loop. - -=item event loop - -An entity that handles and processes external events and converts them -into callback invocations. - -=item event model - -The model used to describe how an event loop handles and processes -watchers and events. - -=item pending - -A watcher is pending as soon as the corresponding event has been -detected. See L for details. - -=item real time - -The physical time that is observed. It is apparently strictly monotonic :) - -=item wall-clock time - -The time and date as shown on clocks. Unlike real time, it can actually -be wrong and jump forwards and backwards, e.g. when you adjust your -clock. - -=item watcher - -A data structure that describes interest in certain events. Watchers need -to be started (attached to an event loop) before they can receive events. - -=back - -=head1 AUTHOR - -Marc Lehmann , with repeated corrections by Mikael -Magnusson and Emanuele Giaquinta, and minor corrections by many others. - diff --git a/submodules/lev/lev/vendor/ev_epoll.c b/submodules/lev/lev/vendor/ev_epoll.c deleted file mode 100644 index 58cfa684d..000000000 --- a/submodules/lev/lev/vendor/ev_epoll.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - * libev epoll fd activity backend - * - * Copyright (c) 2007,2008,2009,2010,2011,2016,2017,2019 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -/* - * general notes about epoll: - * - * a) epoll silently removes fds from the fd set. as nothing tells us - * that an fd has been removed otherwise, we have to continually - * "rearm" fds that we suspect *might* have changed (same - * problem with kqueue, but much less costly there). - * b) the fact that ADD != MOD creates a lot of extra syscalls due to a) - * and seems not to have any advantage. - * c) the inability to handle fork or file descriptors (think dup) - * limits the applicability over poll, so this is not a generic - * poll replacement. - * d) epoll doesn't work the same as select with many file descriptors - * (such as files). while not critical, no other advanced interface - * seems to share this (rather non-unixy) limitation. - * e) epoll claims to be embeddable, but in practise you never get - * a ready event for the epoll fd (broken: <=2.6.26, working: >=2.6.32). - * f) epoll_ctl returning EPERM means the fd is always ready. - * - * lots of "weird code" and complication handling in this file is due - * to these design problems with epoll, as we try very hard to avoid - * epoll_ctl syscalls for common usage patterns and handle the breakage - * ensuing from receiving events for closed and otherwise long gone - * file descriptors. - */ - -#include - -#define EV_EMASK_EPERM 0x80 - -static void -epoll_modify (EV_P_ int fd, int oev, int nev) -{ - struct epoll_event ev; - unsigned char oldmask; - - /* - * we handle EPOLL_CTL_DEL by ignoring it here - * on the assumption that the fd is gone anyways - * if that is wrong, we have to handle the spurious - * event in epoll_poll. - * if the fd is added again, we try to ADD it, and, if that - * fails, we assume it still has the same eventmask. - */ - if (!nev) - return; - - oldmask = anfds [fd].emask; - anfds [fd].emask = nev; - - /* store the generation counter in the upper 32 bits, the fd in the lower 32 bits */ - ev.data.u64 = (uint64_t)(uint32_t)fd - | ((uint64_t)(uint32_t)++anfds [fd].egen << 32); - ev.events = (nev & EV_READ ? EPOLLIN : 0) - | (nev & EV_WRITE ? EPOLLOUT : 0); - - if (ecb_expect_true (!epoll_ctl (backend_fd, oev && oldmask != nev ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, fd, &ev))) - return; - - if (ecb_expect_true (errno == ENOENT)) - { - /* if ENOENT then the fd went away, so try to do the right thing */ - if (!nev) - goto dec_egen; - - if (!epoll_ctl (backend_fd, EPOLL_CTL_ADD, fd, &ev)) - return; - } - else if (ecb_expect_true (errno == EEXIST)) - { - /* EEXIST means we ignored a previous DEL, but the fd is still active */ - /* if the kernel mask is the same as the new mask, we assume it hasn't changed */ - if (oldmask == nev) - goto dec_egen; - - if (!epoll_ctl (backend_fd, EPOLL_CTL_MOD, fd, &ev)) - return; - } - else if (ecb_expect_true (errno == EPERM)) - { - /* EPERM means the fd is always ready, but epoll is too snobbish */ - /* to handle it, unlike select or poll. */ - anfds [fd].emask = EV_EMASK_EPERM; - - /* add fd to epoll_eperms, if not already inside */ - if (!(oldmask & EV_EMASK_EPERM)) - { - array_needsize (int, epoll_eperms, epoll_epermmax, epoll_epermcnt + 1, array_needsize_noinit); - epoll_eperms [epoll_epermcnt++] = fd; - } - - return; - } - else - assert (("libev: I/O watcher with invalid fd found in epoll_ctl", errno != EBADF && errno != ELOOP && errno != EINVAL)); - - fd_kill (EV_A_ fd); - -dec_egen: - /* we didn't successfully call epoll_ctl, so decrement the generation counter again */ - --anfds [fd].egen; -} - -static void -epoll_poll (EV_P_ ev_tstamp timeout) -{ - int i; - int eventcnt; - - if (ecb_expect_false (epoll_epermcnt)) - timeout = EV_TS_CONST (0.); - - /* epoll wait times cannot be larger than (LONG_MAX - 999UL) / HZ msecs, which is below */ - /* the default libev max wait time, however. */ - EV_RELEASE_CB; - eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, EV_TS_TO_MSEC (timeout)); - EV_ACQUIRE_CB; - - if (ecb_expect_false (eventcnt < 0)) - { - if (errno != EINTR) - ev_syserr ("(libev) epoll_wait"); - - return; - } - - for (i = 0; i < eventcnt; ++i) - { - struct epoll_event *ev = epoll_events + i; - - int fd = (uint32_t)ev->data.u64; /* mask out the lower 32 bits */ - int want = anfds [fd].events; - int got = (ev->events & (EPOLLOUT | EPOLLERR | EPOLLHUP) ? EV_WRITE : 0) - | (ev->events & (EPOLLIN | EPOLLERR | EPOLLHUP) ? EV_READ : 0); - - /* - * check for spurious notification. - * this only finds spurious notifications on egen updates - * other spurious notifications will be found by epoll_ctl, below - * we assume that fd is always in range, as we never shrink the anfds array - */ - if (ecb_expect_false ((uint32_t)anfds [fd].egen != (uint32_t)(ev->data.u64 >> 32))) - { - /* recreate kernel state */ - postfork |= 2; - continue; - } - - if (ecb_expect_false (got & ~want)) - { - anfds [fd].emask = want; - - /* - * we received an event but are not interested in it, try mod or del - * this often happens because we optimistically do not unregister fds - * when we are no longer interested in them, but also when we get spurious - * notifications for fds from another process. this is partially handled - * above with the gencounter check (== our fd is not the event fd), and - * partially here, when epoll_ctl returns an error (== a child has the fd - * but we closed it). - * note: for events such as POLLHUP, where we can't know whether it refers - * to EV_READ or EV_WRITE, we might issue redundant EPOLL_CTL_MOD calls. - */ - ev->events = (want & EV_READ ? EPOLLIN : 0) - | (want & EV_WRITE ? EPOLLOUT : 0); - - /* pre-2.6.9 kernels require a non-null pointer with EPOLL_CTL_DEL, */ - /* which is fortunately easy to do for us. */ - if (epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev)) - { - postfork |= 2; /* an error occurred, recreate kernel state */ - continue; - } - } - - fd_event (EV_A_ fd, got); - } - - /* if the receive array was full, increase its size */ - if (ecb_expect_false (eventcnt == epoll_eventmax)) - { - ev_free (epoll_events); - epoll_eventmax = array_nextsize (sizeof (struct epoll_event), epoll_eventmax, epoll_eventmax + 1); - epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); - } - - /* now synthesize events for all fds where epoll fails, while select works... */ - for (i = epoll_epermcnt; i--; ) - { - int fd = epoll_eperms [i]; - unsigned char events = anfds [fd].events & (EV_READ | EV_WRITE); - - if (anfds [fd].emask & EV_EMASK_EPERM && events) - fd_event (EV_A_ fd, events); - else - { - epoll_eperms [i] = epoll_eperms [--epoll_epermcnt]; - anfds [fd].emask = 0; - } - } -} - -static int -epoll_epoll_create (void) -{ - int fd; - -#if defined EPOLL_CLOEXEC && !defined __ANDROID__ - fd = epoll_create1 (EPOLL_CLOEXEC); - - if (fd < 0 && (errno == EINVAL || errno == ENOSYS)) -#endif - { - fd = epoll_create (256); - - if (fd >= 0) - fcntl (fd, F_SETFD, FD_CLOEXEC); - } - - return fd; -} - -inline_size -int -epoll_init (EV_P_ int flags) -{ - if ((backend_fd = epoll_epoll_create ()) < 0) - return 0; - - backend_mintime = EV_TS_CONST (1e-3); /* epoll does sometimes return early, this is just to avoid the worst */ - backend_modify = epoll_modify; - backend_poll = epoll_poll; - - epoll_eventmax = 64; /* initial number of events receivable per poll */ - epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); - - return EVBACKEND_EPOLL; -} - -inline_size -void -epoll_destroy (EV_P) -{ - ev_free (epoll_events); - array_free (epoll_eperm, EMPTY); -} - -ecb_cold -static void -epoll_fork (EV_P) -{ - close (backend_fd); - - while ((backend_fd = epoll_epoll_create ()) < 0) - ev_syserr ("(libev) epoll_create"); - - fd_rearm_all (EV_A); -} - diff --git a/submodules/lev/lev/vendor/ev_iouring.c b/submodules/lev/lev/vendor/ev_iouring.c deleted file mode 100644 index 23788ea24..000000000 --- a/submodules/lev/lev/vendor/ev_iouring.c +++ /dev/null @@ -1,712 +0,0 @@ -/* - * libev linux io_uring fd activity backend - * - * Copyright (c) 2019-2020 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -/* - * general notes about linux io_uring: - * - * a) it's the best interface I have seen so far. on linux. - * b) best is not necessarily very good. - * c) it's better than the aio mess, doesn't suffer from the fork problems - * of linux aio or epoll and so on and so on. and you could do event stuff - * without any syscalls. what's not to like? - * d) ok, it's vastly more complex, but that's ok, really. - * e) why two mmaps instead of one? one would be more space-efficient, - * and I can't see what benefit two would have (other than being - * somehow resizable/relocatable, but that's apparently not possible). - * f) hmm, it's practically undebuggable (gdb can't access the memory, and - * the bizarre way structure offsets are communicated makes it hard to - * just print the ring buffer heads, even *iff* the memory were visible - * in gdb. but then, that's also ok, really. - * g) well, you cannot specify a timeout when waiting for events. no, - * seriously, the interface doesn't support a timeout. never seen _that_ - * before. sure, you can use a timerfd, but that's another syscall - * you could have avoided. overall, this bizarre omission smells - * like a µ-optimisation by the io_uring author for his personal - * applications, to the detriment of everybody else who just wants - * an event loop. but, umm, ok, if that's all, it could be worse. - * (from what I gather from the author Jens Axboe, it simply didn't - * occur to him, and he made good on it by adding an unlimited number - * of timeouts later :). - * h) initially there was a hardcoded limit of 4096 outstanding events. - * later versions not only bump this to 32k, but also can handle - * an unlimited amount of events, so this only affects the batch size. - * i) unlike linux aio, you *can* register more then the limit - * of fd events. while early verisons of io_uring signalled an overflow - * and you ended up getting wet. 5.5+ does not do this anymore. - * j) but, oh my! it had exactly the same bugs as the linux aio backend, - * where some undocumented poll combinations just fail. fortunately, - * after finally reaching the author, he was more than willing to fix - * this probably in 5.6+. - * k) overall, the *API* itself is, I dare to say, not a total trainwreck. - * once the bugs ae fixed (probably in 5.6+), it will be without - * competition. - */ - -/* TODO: use internal TIMEOUT */ -/* TODO: take advantage of single mmap, NODROP etc. */ -/* TODO: resize cq/sq size independently */ - -#include -#include -#include -#include - -#define IOURING_INIT_ENTRIES 32 - -/*****************************************************************************/ -/* syscall wrapdadoop - this section has the raw api/abi definitions */ - -#include -#include - -/* mostly directly taken from the kernel or documentation */ - -struct io_uring_sqe -{ - __u8 opcode; - __u8 flags; - __u16 ioprio; - __s32 fd; - union { - __u64 off; - __u64 addr2; - }; - __u64 addr; - __u32 len; - union { - __kernel_rwf_t rw_flags; - __u32 fsync_flags; - __u16 poll_events; - __u32 sync_range_flags; - __u32 msg_flags; - __u32 timeout_flags; - __u32 accept_flags; - __u32 cancel_flags; - __u32 open_flags; - __u32 statx_flags; - __u32 fadvise_advice; - }; - __u64 user_data; - union { - __u16 buf_index; - __u16 personality; - __u64 __pad2[3]; - }; -}; - -struct io_uring_cqe -{ - __u64 user_data; - __s32 res; - __u32 flags; -}; - -struct io_sqring_offsets -{ - __u32 head; - __u32 tail; - __u32 ring_mask; - __u32 ring_entries; - __u32 flags; - __u32 dropped; - __u32 array; - __u32 resv1; - __u64 resv2; -}; - -struct io_cqring_offsets -{ - __u32 head; - __u32 tail; - __u32 ring_mask; - __u32 ring_entries; - __u32 overflow; - __u32 cqes; - __u64 resv[2]; -}; - -struct io_uring_params -{ - __u32 sq_entries; - __u32 cq_entries; - __u32 flags; - __u32 sq_thread_cpu; - __u32 sq_thread_idle; - __u32 features; - __u32 resv[4]; - struct io_sqring_offsets sq_off; - struct io_cqring_offsets cq_off; -}; - -#define IORING_FEAT_SINGLE_MMAP 0x00000001 -#define IORING_FEAT_NODROP 0x00000002 -#define IORING_FEAT_SUBMIT_STABLE 0x00000004 - -#define IORING_SETUP_CQSIZE 0x00000008 -#define IORING_SETUP_CLAMP 0x00000010 - -#define IORING_OP_POLL_ADD 6 -#define IORING_OP_POLL_REMOVE 7 -#define IORING_OP_TIMEOUT 11 -#define IORING_OP_TIMEOUT_REMOVE 12 - -#define IORING_REGISTER_EVENTFD 4 -#define IORING_REGISTER_EVENTFD_ASYNC 7 -#define IORING_REGISTER_PROBE 8 - -#define IO_URING_OP_SUPPORTED 1 - -struct io_uring_probe_op { - __u8 op; - __u8 resv; - __u16 flags; - __u32 resv2; -}; - -struct io_uring_probe -{ - __u8 last_op; - __u8 ops_len; - __u16 resv; - __u32 resv2[3]; - struct io_uring_probe_op ops[0]; -}; - -/* relative or absolute, reference clock is CLOCK_MONOTONIC */ -struct iouring_kernel_timespec -{ - int64_t tv_sec; - long long tv_nsec; -}; - -#define IORING_TIMEOUT_ABS 0x00000001 - -#define IORING_ENTER_GETEVENTS 0x01 - -#define IORING_OFF_SQ_RING 0x00000000ULL -#define IORING_OFF_SQES 0x10000000ULL - -#define IORING_FEAT_SINGLE_MMAP 0x00000001 -#define IORING_FEAT_NODROP 0x00000002 -#define IORING_FEAT_SUBMIT_STABLE 0x00000004 - -inline_size -int -evsys_io_uring_setup (unsigned entries, struct io_uring_params *params) -{ - return ev_syscall2 (SYS_io_uring_setup, entries, params); -} - -inline_size -int -evsys_io_uring_enter (int fd, unsigned to_submit, unsigned min_complete, unsigned flags, const sigset_t *sig, size_t sigsz) -{ - return ev_syscall6 (SYS_io_uring_enter, fd, to_submit, min_complete, flags, sig, sigsz); -} - -inline_size -int -evsys_io_uring_register (unsigned int fd, unsigned int opcode, void *arg, unsigned int nr_args) -{ - return ev_syscall4 (SYS_io_uring_register, fd, opcode, arg, nr_args); -} - -/*****************************************************************************/ -/* actual backend implementation */ - -/* we hope that volatile will make the compiler access this variables only once */ -#define EV_SQ_VAR(name) *(volatile unsigned *)((char *)iouring_ring + iouring_sq_ ## name) -#define EV_CQ_VAR(name) *(volatile unsigned *)((char *)iouring_ring + iouring_cq_ ## name) - -/* the index array */ -#define EV_SQ_ARRAY ((unsigned *)((char *)iouring_ring + iouring_sq_array)) - -/* the submit/completion queue entries */ -#define EV_SQES ((struct io_uring_sqe *) iouring_sqes) -#define EV_CQES ((struct io_uring_cqe *)((char *)iouring_ring + iouring_cq_cqes)) - -inline_speed -int -iouring_enter (EV_P_ ev_tstamp timeout) -{ - int res; - - EV_RELEASE_CB; - - res = evsys_io_uring_enter (iouring_fd, iouring_to_submit, 1, - timeout > EV_TS_CONST (0.) ? IORING_ENTER_GETEVENTS : 0, 0, 0); - - assert (("libev: io_uring_enter did not consume all sqes", (res < 0 || res == iouring_to_submit))); - - iouring_to_submit = 0; - - EV_ACQUIRE_CB; - - return res; -} - -/* TODO: can we move things around so we don't need this forward-reference? */ -static void -iouring_poll (EV_P_ ev_tstamp timeout); - -static -struct io_uring_sqe * -iouring_sqe_get (EV_P) -{ - unsigned tail; - - for (;;) - { - tail = EV_SQ_VAR (tail); - - if (ecb_expect_true (tail + 1 - EV_SQ_VAR (head) <= EV_SQ_VAR (ring_entries))) - break; /* whats the problem, we have free sqes */ - - /* queue full, need to flush and possibly handle some events */ - -#if EV_FEATURE_CODE - /* first we ask the kernel nicely, most often this frees up some sqes */ - int res = iouring_enter (EV_A_ EV_TS_CONST (0.)); - - ECB_MEMORY_FENCE_ACQUIRE; /* better safe than sorry */ - - if (res >= 0) - continue; /* yes, it worked, try again */ -#endif - - /* some problem, possibly EBUSY - do the full poll and let it handle any issues */ - - iouring_poll (EV_A_ EV_TS_CONST (0.)); - /* iouring_poll should have done ECB_MEMORY_FENCE_ACQUIRE for us */ - } - - /*assert (("libev: io_uring queue full after flush", tail + 1 - EV_SQ_VAR (head) <= EV_SQ_VAR (ring_entries)));*/ - - return EV_SQES + (tail & EV_SQ_VAR (ring_mask)); -} - -inline_size -void -iouring_sqe_submit (EV_P_ struct io_uring_sqe *sqe) -{ - unsigned idx = sqe - EV_SQES; - - EV_SQ_ARRAY [idx] = idx; - ECB_MEMORY_FENCE_RELEASE; - ++EV_SQ_VAR (tail); - /*ECB_MEMORY_FENCE_RELEASE; /* for the time being we assume this is not needed */ - ++iouring_to_submit; -} - -/*****************************************************************************/ - -/* when the timerfd expires we simply note the fact, - * as the purpose of the timerfd is to wake us up, nothing else. - * the next iteration should re-set it. - */ -static void -iouring_tfd_cb (EV_P_ struct ev_io *w, int revents) -{ - iouring_tfd_to = EV_TSTAMP_HUGE; -} - -/* called for full and partial cleanup */ -ecb_cold -static int -iouring_internal_destroy (EV_P) -{ - close (iouring_tfd); - close (iouring_fd); - - if (iouring_ring != MAP_FAILED) munmap (iouring_ring, iouring_ring_size); - if (iouring_sqes != MAP_FAILED) munmap (iouring_sqes, iouring_sqes_size); - - if (ev_is_active (&iouring_tfd_w)) - { - ev_ref (EV_A); - ev_io_stop (EV_A_ &iouring_tfd_w); - } -} - -ecb_cold -static int -iouring_internal_init (EV_P) -{ - struct io_uring_params params = { 0 }; - uint32_t sq_size, cq_size; - - params.flags = IORING_SETUP_CLAMP; - - iouring_to_submit = 0; - - iouring_tfd = -1; - iouring_ring = MAP_FAILED; - iouring_sqes = MAP_FAILED; - - if (!have_monotonic) /* cannot really happen, but what if11 */ - return -1; - - iouring_fd = evsys_io_uring_setup (iouring_entries, ¶ms); - - if (iouring_fd < 0) - return -1; - - if ((~params.features) & (IORING_FEAT_NODROP | IORING_FEAT_SINGLE_MMAP | IORING_FEAT_SUBMIT_STABLE)) - return -1; /* we require the above features */ - - /* TODO: remember somehow whether our queue size has been clamped */ - - sq_size = params.sq_off.array + params.sq_entries * sizeof (unsigned); - cq_size = params.cq_off.cqes + params.cq_entries * sizeof (struct io_uring_cqe); - - iouring_ring_size = sq_size > cq_size ? sq_size : cq_size; - iouring_sqes_size = params.sq_entries * sizeof (struct io_uring_sqe); - - iouring_ring = mmap (0, iouring_ring_size, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_POPULATE, iouring_fd, IORING_OFF_SQ_RING); - iouring_sqes = mmap (0, iouring_sqes_size, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_POPULATE, iouring_fd, IORING_OFF_SQES); - - if (iouring_ring == MAP_FAILED || iouring_sqes == MAP_FAILED) - return -1; - - iouring_sq_head = params.sq_off.head; - iouring_sq_tail = params.sq_off.tail; - iouring_sq_ring_mask = params.sq_off.ring_mask; - iouring_sq_ring_entries = params.sq_off.ring_entries; - iouring_sq_flags = params.sq_off.flags; - iouring_sq_dropped = params.sq_off.dropped; - iouring_sq_array = params.sq_off.array; - - iouring_cq_head = params.cq_off.head; - iouring_cq_tail = params.cq_off.tail; - iouring_cq_ring_mask = params.cq_off.ring_mask; - iouring_cq_ring_entries = params.cq_off.ring_entries; - iouring_cq_overflow = params.cq_off.overflow; - iouring_cq_cqes = params.cq_off.cqes; - - iouring_tfd_to = EV_TSTAMP_HUGE; - - iouring_tfd = timerfd_create (CLOCK_MONOTONIC, TFD_CLOEXEC); - - if (iouring_tfd < 0) - return -1; - - return 0; -} - -ecb_cold -static void -iouring_fork (EV_P) -{ - iouring_internal_destroy (EV_A); - - while (iouring_internal_init (EV_A) < 0) - ev_syserr ("(libev) io_uring_setup"); - - fd_rearm_all (EV_A); - - ev_io_stop (EV_A_ &iouring_tfd_w); - ev_io_set (EV_A_ &iouring_tfd_w, iouring_tfd, EV_READ); - ev_io_start (EV_A_ &iouring_tfd_w); -} - -/*****************************************************************************/ - -static void -iouring_modify (EV_P_ int fd, int oev, int nev) -{ - if (oev) - { - /* we assume the sqe's are all "properly" initialised */ - struct io_uring_sqe *sqe = iouring_sqe_get (EV_A); - sqe->opcode = IORING_OP_POLL_REMOVE; - sqe->fd = fd; - /* Jens Axboe notified me that user_data is not what is documented, but is - * some kind of unique ID that has to match, otherwise the request cannot - * be removed. Since we don't *really* have that, we pass in the old - * generation counter - if that fails, too bad, it will hopefully be removed - * at close time and then be ignored. */ - sqe->addr = (uint32_t)fd | ((__u64)(uint32_t)anfds [fd].egen << 32); - sqe->user_data = (uint64_t)-1; - iouring_sqe_submit (EV_A_ sqe); - - /* increment generation counter to avoid handling old events */ - ++anfds [fd].egen; - } - - if (nev) - { - struct io_uring_sqe *sqe = iouring_sqe_get (EV_A); - sqe->opcode = IORING_OP_POLL_ADD; - sqe->fd = fd; - sqe->addr = 0; - sqe->user_data = (uint32_t)fd | ((__u64)(uint32_t)anfds [fd].egen << 32); - sqe->poll_events = - (nev & EV_READ ? POLLIN : 0) - | (nev & EV_WRITE ? POLLOUT : 0); - iouring_sqe_submit (EV_A_ sqe); - } -} - -inline_size -void -iouring_tfd_update (EV_P_ ev_tstamp timeout) -{ - ev_tstamp tfd_to = mn_now + timeout; - - /* we assume there will be many iterations per timer change, so - * we only re-set the timerfd when we have to because its expiry - * is too late. - */ - if (ecb_expect_false (tfd_to < iouring_tfd_to)) - { - struct itimerspec its; - - iouring_tfd_to = tfd_to; - EV_TS_SET (its.it_interval, 0.); - EV_TS_SET (its.it_value, tfd_to); - - if (timerfd_settime (iouring_tfd, TFD_TIMER_ABSTIME, &its, 0) < 0) - assert (("libev: iouring timerfd_settime failed", 0)); - } -} - -inline_size -void -iouring_process_cqe (EV_P_ struct io_uring_cqe *cqe) -{ - int fd = cqe->user_data & 0xffffffffU; - uint32_t gen = cqe->user_data >> 32; - int res = cqe->res; - - /* user_data -1 is a remove that we are not atm. interested in */ - if (cqe->user_data == (uint64_t)-1) - return; - - assert (("libev: io_uring fd must be in-bounds", fd >= 0 && fd < anfdmax)); - - /* documentation lies, of course. the result value is NOT like - * normal syscalls, but like linux raw syscalls, i.e. negative - * error numbers. fortunate, as otherwise there would be no way - * to get error codes at all. still, why not document this? - */ - - /* ignore event if generation doesn't match */ - /* other than skipping removal events, */ - /* this should actually be very rare */ - if (ecb_expect_false (gen != (uint32_t)anfds [fd].egen)) - return; - - if (ecb_expect_false (res < 0)) - { - /*TODO: EINVAL handling (was something failed with this fd)*/ - - if (res == -EBADF) - { - assert (("libev: event loop rejected bad fd", res != -EBADF)); - fd_kill (EV_A_ fd); - } - else - { - errno = -res; - ev_syserr ("(libev) IORING_OP_POLL_ADD"); - } - - return; - } - - /* feed events, we do not expect or handle POLLNVAL */ - fd_event ( - EV_A_ - fd, - (res & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) - | (res & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) - ); - - /* io_uring is oneshot, so we need to re-arm the fd next iteration */ - /* this also means we usually have to do at least one syscall per iteration */ - anfds [fd].events = 0; - fd_change (EV_A_ fd, EV_ANFD_REIFY); -} - -/* called when the event queue overflows */ -ecb_cold -static void -iouring_overflow (EV_P) -{ - /* we have two options, resize the queue (by tearing down - * everything and recreating it, or living with it - * and polling. - * we implement this by resizing the queue, and, if that fails, - * we just recreate the state on every failure, which - * kind of is a very inefficient poll. - * one danger is, due to the bios toward lower fds, - * we will only really get events for those, so - * maybe we need a poll() fallback, after all. - */ - /*EV_CQ_VAR (overflow) = 0;*/ /* need to do this if we keep the state and poll manually */ - - fd_rearm_all (EV_A); - - /* we double the size until we hit the hard-to-probe maximum */ - if (!iouring_max_entries) - { - iouring_entries <<= 1; - iouring_fork (EV_A); - } - else - { - /* we hit the kernel limit, we should fall back to something else. - * we can either poll() a few times and hope for the best, - * poll always, or switch to epoll. - * TODO: is this necessary with newer kernels? - */ - - iouring_internal_destroy (EV_A); - - /* this should make it so that on return, we don't call any uring functions */ - iouring_to_submit = 0; - - for (;;) - { - backend = epoll_init (EV_A_ 0); - - if (backend) - break; - - ev_syserr ("(libev) iouring switch to epoll"); - } - } -} - -/* handle any events in the completion queue, return true if there were any */ -static int -iouring_handle_cq (EV_P) -{ - unsigned head, tail, mask; - - head = EV_CQ_VAR (head); - ECB_MEMORY_FENCE_ACQUIRE; - tail = EV_CQ_VAR (tail); - - if (head == tail) - return 0; - - /* it can only overflow if we have events, yes, yes? */ - if (ecb_expect_false (EV_CQ_VAR (overflow))) - { - iouring_overflow (EV_A); - return 1; - } - - mask = EV_CQ_VAR (ring_mask); - - do - iouring_process_cqe (EV_A_ &EV_CQES [head++ & mask]); - while (head != tail); - - EV_CQ_VAR (head) = head; - ECB_MEMORY_FENCE_RELEASE; - - return 1; -} - -static void -iouring_poll (EV_P_ ev_tstamp timeout) -{ - /* if we have events, no need for extra syscalls, but we might have to queue events */ - /* we also clar the timeout if there are outstanding fdchanges */ - /* the latter should only happen if both the sq and cq are full, most likely */ - /* because we have a lot of event sources that immediately complete */ - /* TODO: fdchacngecnt is always 0 because fd_reify does not have two buffers yet */ - if (iouring_handle_cq (EV_A) || fdchangecnt) - timeout = EV_TS_CONST (0.); - else - /* no events, so maybe wait for some */ - iouring_tfd_update (EV_A_ timeout); - - /* only enter the kernel if we have something to submit, or we need to wait */ - if (timeout || iouring_to_submit) - { - int res = iouring_enter (EV_A_ timeout); - - if (ecb_expect_false (res < 0)) - if (errno == EINTR) - /* ignore */; - else if (errno == EBUSY) - /* cq full, cannot submit - should be rare because we flush the cq first, so simply ignore */; - else - ev_syserr ("(libev) iouring setup"); - else - iouring_handle_cq (EV_A); - } -} - -inline_size -int -iouring_init (EV_P_ int flags) -{ - iouring_entries = IOURING_INIT_ENTRIES; - iouring_max_entries = 0; - - if (iouring_internal_init (EV_A) < 0) - { - iouring_internal_destroy (EV_A); - return 0; - } - - ev_io_init (&iouring_tfd_w, iouring_tfd_cb, iouring_tfd, EV_READ); - ev_set_priority (&iouring_tfd_w, EV_MINPRI); - ev_io_start (EV_A_ &iouring_tfd_w); - ev_unref (EV_A); /* watcher should not keep loop alive */ - - backend_modify = iouring_modify; - backend_poll = iouring_poll; - - return EVBACKEND_IOURING; -} - -inline_size -void -iouring_destroy (EV_P) -{ - iouring_internal_destroy (EV_A); -} - diff --git a/submodules/lev/lev/vendor/ev_kqueue.c b/submodules/lev/lev/vendor/ev_kqueue.c deleted file mode 100644 index 69c5147f1..000000000 --- a/submodules/lev/lev/vendor/ev_kqueue.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * libev kqueue backend - * - * Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2016,2019 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#include -#include -#include -#include -#include - -inline_speed -void -kqueue_change (EV_P_ int fd, int filter, int flags, int fflags) -{ - ++kqueue_changecnt; - array_needsize (struct kevent, kqueue_changes, kqueue_changemax, kqueue_changecnt, array_needsize_noinit); - - EV_SET (&kqueue_changes [kqueue_changecnt - 1], fd, filter, flags, fflags, 0, 0); -} - -/* OS X at least needs this */ -#ifndef EV_ENABLE -# define EV_ENABLE 0 -#endif -#ifndef NOTE_EOF -# define NOTE_EOF 0 -#endif - -static void -kqueue_modify (EV_P_ int fd, int oev, int nev) -{ - if (oev != nev) - { - if (oev & EV_READ) - kqueue_change (EV_A_ fd, EVFILT_READ , EV_DELETE, 0); - - if (oev & EV_WRITE) - kqueue_change (EV_A_ fd, EVFILT_WRITE, EV_DELETE, 0); - } - - /* to detect close/reopen reliably, we have to re-add */ - /* event requests even when oev == nev */ - - if (nev & EV_READ) - kqueue_change (EV_A_ fd, EVFILT_READ , EV_ADD | EV_ENABLE, NOTE_EOF); - - if (nev & EV_WRITE) - kqueue_change (EV_A_ fd, EVFILT_WRITE, EV_ADD | EV_ENABLE, NOTE_EOF); -} - -static void -kqueue_poll (EV_P_ ev_tstamp timeout) -{ - int res, i; - struct timespec ts; - - /* need to resize so there is enough space for errors */ - if (kqueue_changecnt > kqueue_eventmax) - { - ev_free (kqueue_events); - kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt); - kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); - } - - EV_RELEASE_CB; - EV_TS_SET (ts, timeout); - res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts); - EV_ACQUIRE_CB; - kqueue_changecnt = 0; - - if (ecb_expect_false (res < 0)) - { - if (errno != EINTR) - ev_syserr ("(libev) kqueue kevent"); - - return; - } - - for (i = 0; i < res; ++i) - { - int fd = kqueue_events [i].ident; - - if (ecb_expect_false (kqueue_events [i].flags & EV_ERROR)) - { - int err = kqueue_events [i].data; - - /* we are only interested in errors for fds that we are interested in :) */ - if (anfds [fd].events) - { - if (err == ENOENT) /* resubmit changes on ENOENT */ - kqueue_modify (EV_A_ fd, 0, anfds [fd].events); - else if (err == EBADF) /* on EBADF, we re-check the fd */ - { - if (fd_valid (fd)) - kqueue_modify (EV_A_ fd, 0, anfds [fd].events); - else - { - assert (("libev: kqueue found invalid fd", 0)); - fd_kill (EV_A_ fd); - } - } - else /* on all other errors, we error out on the fd */ - { - assert (("libev: kqueue found invalid fd", 0)); - fd_kill (EV_A_ fd); - } - } - } - else - fd_event ( - EV_A_ - fd, - kqueue_events [i].filter == EVFILT_READ ? EV_READ - : kqueue_events [i].filter == EVFILT_WRITE ? EV_WRITE - : 0 - ); - } - - if (ecb_expect_false (res == kqueue_eventmax)) - { - ev_free (kqueue_events); - kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_eventmax + 1); - kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); - } -} - -inline_size -int -kqueue_init (EV_P_ int flags) -{ - /* initialize the kernel queue */ - kqueue_fd_pid = getpid (); - if ((backend_fd = kqueue ()) < 0) - return 0; - - fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ - - backend_mintime = EV_TS_CONST (1e-9); /* apparently, they did the right thing in freebsd */ - backend_modify = kqueue_modify; - backend_poll = kqueue_poll; - - kqueue_eventmax = 64; /* initial number of events receivable per poll */ - kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); - - kqueue_changes = 0; - kqueue_changemax = 0; - kqueue_changecnt = 0; - - return EVBACKEND_KQUEUE; -} - -inline_size -void -kqueue_destroy (EV_P) -{ - ev_free (kqueue_events); - ev_free (kqueue_changes); -} - -inline_size -void -kqueue_fork (EV_P) -{ - /* some BSD kernels don't just destroy the kqueue itself, - * but also close the fd, which isn't documented, and - * impossible to support properly. - * we remember the pid of the kqueue call and only close - * the fd if the pid is still the same. - * this leaks fds on sane kernels, but BSD interfaces are - * notoriously buggy and rarely get fixed. - */ - pid_t newpid = getpid (); - - if (newpid == kqueue_fd_pid) - close (backend_fd); - - kqueue_fd_pid = newpid; - while ((backend_fd = kqueue ()) < 0) - ev_syserr ("(libev) kqueue"); - - fcntl (backend_fd, F_SETFD, FD_CLOEXEC); - - /* re-register interest in fds */ - fd_rearm_all (EV_A); -} - -/* sys/event.h defines EV_ERROR */ -#undef EV_ERROR - diff --git a/submodules/lev/lev/vendor/ev_linuxaio.c b/submodules/lev/lev/vendor/ev_linuxaio.c deleted file mode 100644 index 4687a703e..000000000 --- a/submodules/lev/lev/vendor/ev_linuxaio.c +++ /dev/null @@ -1,620 +0,0 @@ -/* - * libev linux aio fd activity backend - * - * Copyright (c) 2019 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -/* - * general notes about linux aio: - * - * a) at first, the linux aio IOCB_CMD_POLL functionality introduced in - * 4.18 looks too good to be true: both watchers and events can be - * batched, and events can even be handled in userspace using - * a ring buffer shared with the kernel. watchers can be canceled - * regardless of whether the fd has been closed. no problems with fork. - * ok, the ring buffer is 200% undocumented (there isn't even a - * header file), but otherwise, it's pure bliss! - * b) ok, watchers are one-shot, so you have to re-arm active ones - * on every iteration. so much for syscall-less event handling, - * but at least these re-arms can be batched, no big deal, right? - * c) well, linux as usual: the documentation lies to you: io_submit - * sometimes returns EINVAL because the kernel doesn't feel like - * handling your poll mask - ttys can be polled for POLLOUT, - * POLLOUT|POLLIN, but polling for POLLIN fails. just great, - * so we have to fall back to something else (hello, epoll), - * but at least the fallback can be slow, because these are - * exceptional cases, right? - * d) hmm, you have to tell the kernel the maximum number of watchers - * you want to queue when initialising the aio context. but of - * course the real limit is magically calculated in the kernel, and - * is often higher then we asked for. so we just have to destroy - * the aio context and re-create it a bit larger if we hit the limit. - * (starts to remind you of epoll? well, it's a bit more deterministic - * and less gambling, but still ugly as hell). - * e) that's when you find out you can also hit an arbitrary system-wide - * limit. or the kernel simply doesn't want to handle your watchers. - * what the fuck do we do then? you guessed it, in the middle - * of event handling we have to switch to 100% epoll polling. and - * that better is as fast as normal epoll polling, so you practically - * have to use the normal epoll backend with all its quirks. - * f) end result of this train wreck: it inherits all the disadvantages - * from epoll, while adding a number on its own. why even bother to use - * it? because if conditions are right and your fds are supported and you - * don't hit a limit, this backend is actually faster, doesn't gamble with - * your fds, batches watchers and events and doesn't require costly state - * recreates. well, until it does. - * g) all of this makes this backend use almost twice as much code as epoll. - * which in turn uses twice as much code as poll. and that#s not counting - * the fact that this backend also depends on the epoll backend, making - * it three times as much code as poll, or kqueue. - * h) bleah. why can't linux just do kqueue. sure kqueue is ugly, but by now - * it's clear that whatever linux comes up with is far, far, far worse. - */ - -#include /* actually linux/time.h, but we must assume they are compatible */ -#include -#include - -/*****************************************************************************/ -/* syscall wrapdadoop - this section has the raw api/abi definitions */ - -#include /* no glibc wrappers */ - -/* aio_abi.h is not versioned in any way, so we cannot test for its existance */ -#define IOCB_CMD_POLL 5 - -/* taken from linux/fs/aio.c. yup, that's a .c file. - * not only is this totally undocumented, not even the source code - * can tell you what the future semantics of compat_features and - * incompat_features are, or what header_length actually is for. - */ -#define AIO_RING_MAGIC 0xa10a10a1 -#define EV_AIO_RING_INCOMPAT_FEATURES 0 -struct aio_ring -{ - unsigned id; /* kernel internal index number */ - unsigned nr; /* number of io_events */ - unsigned head; /* Written to by userland or by kernel. */ - unsigned tail; - - unsigned magic; - unsigned compat_features; - unsigned incompat_features; - unsigned header_length; /* size of aio_ring */ - - struct io_event io_events[0]; -}; - -inline_size -int -evsys_io_setup (unsigned nr_events, aio_context_t *ctx_idp) -{ - return ev_syscall2 (SYS_io_setup, nr_events, ctx_idp); -} - -inline_size -int -evsys_io_destroy (aio_context_t ctx_id) -{ - return ev_syscall1 (SYS_io_destroy, ctx_id); -} - -inline_size -int -evsys_io_submit (aio_context_t ctx_id, long nr, struct iocb *cbp[]) -{ - return ev_syscall3 (SYS_io_submit, ctx_id, nr, cbp); -} - -inline_size -int -evsys_io_cancel (aio_context_t ctx_id, struct iocb *cbp, struct io_event *result) -{ - return ev_syscall3 (SYS_io_cancel, ctx_id, cbp, result); -} - -inline_size -int -evsys_io_getevents (aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout) -{ - return ev_syscall5 (SYS_io_getevents, ctx_id, min_nr, nr, events, timeout); -} - -/*****************************************************************************/ -/* actual backed implementation */ - -ecb_cold -static int -linuxaio_nr_events (EV_P) -{ - /* we start with 16 iocbs and incraese from there - * that's tiny, but the kernel has a rather low system-wide - * limit that can be reached quickly, so let's be parsimonious - * with this resource. - * Rest assured, the kernel generously rounds up small and big numbers - * in different ways (but doesn't seem to charge you for it). - * The 15 here is because the kernel usually has a power of two as aio-max-nr, - * and this helps to take advantage of that limit. - */ - - /* we try to fill 4kB pages exactly. - * the ring buffer header is 32 bytes, every io event is 32 bytes. - * the kernel takes the io requests number, doubles it, adds 2 - * and adds the ring buffer. - * the way we use this is by starting low, and then roughly doubling the - * size each time we hit a limit. - */ - - int requests = 15 << linuxaio_iteration; - int one_page = (4096 - / sizeof (struct io_event) ) / 2; /* how many fit into one page */ - int first_page = ((4096 - sizeof (struct aio_ring)) - / sizeof (struct io_event) - 2) / 2; /* how many fit into the first page */ - - /* if everything fits into one page, use count exactly */ - if (requests > first_page) - /* otherwise, round down to full pages and add the first page */ - requests = requests / one_page * one_page + first_page; - - return requests; -} - -/* we use out own wrapper structure in case we ever want to do something "clever" */ -typedef struct aniocb -{ - struct iocb io; - /*int inuse;*/ -} *ANIOCBP; - -inline_size -void -linuxaio_array_needsize_iocbp (ANIOCBP *base, int offset, int count) -{ - while (count--) - { - /* TODO: quite the overhead to allocate every iocb separately, maybe use our own allocator? */ - ANIOCBP iocb = (ANIOCBP)ev_malloc (sizeof (*iocb)); - - /* full zero initialise is probably not required at the moment, but - * this is not well documented, so we better do it. - */ - memset (iocb, 0, sizeof (*iocb)); - - iocb->io.aio_lio_opcode = IOCB_CMD_POLL; - iocb->io.aio_fildes = offset; - - base [offset++] = iocb; - } -} - -ecb_cold -static void -linuxaio_free_iocbp (EV_P) -{ - while (linuxaio_iocbpmax--) - ev_free (linuxaio_iocbps [linuxaio_iocbpmax]); - - linuxaio_iocbpmax = 0; /* next resize will completely reallocate the array, at some overhead */ -} - -static void -linuxaio_modify (EV_P_ int fd, int oev, int nev) -{ - array_needsize (ANIOCBP, linuxaio_iocbps, linuxaio_iocbpmax, fd + 1, linuxaio_array_needsize_iocbp); - ANIOCBP iocb = linuxaio_iocbps [fd]; - ANFD *anfd = &anfds [fd]; - - if (ecb_expect_false (iocb->io.aio_reqprio < 0)) - { - /* we handed this fd over to epoll, so undo this first */ - /* we do it manually because the optimisations on epoll_modify won't do us any good */ - epoll_ctl (backend_fd, EPOLL_CTL_DEL, fd, 0); - anfd->emask = 0; - iocb->io.aio_reqprio = 0; - } - else if (ecb_expect_false (iocb->io.aio_buf)) - { - /* iocb active, so cancel it first before resubmit */ - /* this assumes we only ever get one call per fd per loop iteration */ - for (;;) - { - /* on all relevant kernels, io_cancel fails with EINPROGRESS on "success" */ - if (ecb_expect_false (evsys_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0) == 0)) - break; - - if (ecb_expect_true (errno == EINPROGRESS)) - break; - - /* the EINPROGRESS test is for nicer error message. clumsy. */ - if (errno != EINTR) - { - assert (("libev: linuxaio unexpected io_cancel failed", errno != EINTR && errno != EINPROGRESS)); - break; - } - } - - /* increment generation counter to avoid handling old events */ - ++anfd->egen; - } - - iocb->io.aio_buf = (nev & EV_READ ? POLLIN : 0) - | (nev & EV_WRITE ? POLLOUT : 0); - - if (nev) - { - iocb->io.aio_data = (uint32_t)fd | ((__u64)(uint32_t)anfd->egen << 32); - - /* queue iocb up for io_submit */ - /* this assumes we only ever get one call per fd per loop iteration */ - ++linuxaio_submitcnt; - array_needsize (struct iocb *, linuxaio_submits, linuxaio_submitmax, linuxaio_submitcnt, array_needsize_noinit); - linuxaio_submits [linuxaio_submitcnt - 1] = &iocb->io; - } -} - -static void -linuxaio_epoll_cb (EV_P_ struct ev_io *w, int revents) -{ - epoll_poll (EV_A_ 0); -} - -inline_speed -void -linuxaio_fd_rearm (EV_P_ int fd) -{ - anfds [fd].events = 0; - linuxaio_iocbps [fd]->io.aio_buf = 0; - fd_change (EV_A_ fd, EV_ANFD_REIFY); -} - -static void -linuxaio_parse_events (EV_P_ struct io_event *ev, int nr) -{ - while (nr) - { - int fd = ev->data & 0xffffffff; - uint32_t gen = ev->data >> 32; - int res = ev->res; - - assert (("libev: iocb fd must be in-bounds", fd >= 0 && fd < anfdmax)); - - /* only accept events if generation counter matches */ - if (ecb_expect_true (gen == (uint32_t)anfds [fd].egen)) - { - /* feed events, we do not expect or handle POLLNVAL */ - fd_event ( - EV_A_ - fd, - (res & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) - | (res & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) - ); - - /* linux aio is oneshot: rearm fd. TODO: this does more work than strictly needed */ - linuxaio_fd_rearm (EV_A_ fd); - } - - --nr; - ++ev; - } -} - -/* get any events from ring buffer, return true if any were handled */ -static int -linuxaio_get_events_from_ring (EV_P) -{ - struct aio_ring *ring = (struct aio_ring *)linuxaio_ctx; - unsigned head, tail; - - /* the kernel reads and writes both of these variables, */ - /* as a C extension, we assume that volatile use here */ - /* both makes reads atomic and once-only */ - head = *(volatile unsigned *)&ring->head; - ECB_MEMORY_FENCE_ACQUIRE; - tail = *(volatile unsigned *)&ring->tail; - - if (head == tail) - return 0; - - /* parse all available events, but only once, to avoid starvation */ - if (ecb_expect_true (tail > head)) /* normal case around */ - linuxaio_parse_events (EV_A_ ring->io_events + head, tail - head); - else /* wrapped around */ - { - linuxaio_parse_events (EV_A_ ring->io_events + head, ring->nr - head); - linuxaio_parse_events (EV_A_ ring->io_events, tail); - } - - ECB_MEMORY_FENCE_RELEASE; - /* as an extension to C, we hope that the volatile will make this atomic and once-only */ - *(volatile unsigned *)&ring->head = tail; - - return 1; -} - -inline_size -int -linuxaio_ringbuf_valid (EV_P) -{ - struct aio_ring *ring = (struct aio_ring *)linuxaio_ctx; - - return ecb_expect_true (ring->magic == AIO_RING_MAGIC) - && ring->incompat_features == EV_AIO_RING_INCOMPAT_FEATURES - && ring->header_length == sizeof (struct aio_ring); /* TODO: or use it to find io_event[0]? */ -} - -/* read at least one event from kernel, or timeout */ -inline_size -void -linuxaio_get_events (EV_P_ ev_tstamp timeout) -{ - struct timespec ts; - struct io_event ioev[8]; /* 256 octet stack space */ - int want = 1; /* how many events to request */ - int ringbuf_valid = linuxaio_ringbuf_valid (EV_A); - - if (ecb_expect_true (ringbuf_valid)) - { - /* if the ring buffer has any events, we don't wait or call the kernel at all */ - if (linuxaio_get_events_from_ring (EV_A)) - return; - - /* if the ring buffer is empty, and we don't have a timeout, then don't call the kernel */ - if (!timeout) - return; - } - else - /* no ringbuffer, request slightly larger batch */ - want = sizeof (ioev) / sizeof (ioev [0]); - - /* no events, so wait for some - * for fairness reasons, we do this in a loop, to fetch all events - */ - for (;;) - { - int res; - - EV_RELEASE_CB; - - EV_TS_SET (ts, timeout); - res = evsys_io_getevents (linuxaio_ctx, 1, want, ioev, &ts); - - EV_ACQUIRE_CB; - - if (res < 0) - if (errno == EINTR) - /* ignored, retry */; - else - ev_syserr ("(libev) linuxaio io_getevents"); - else if (res) - { - /* at least one event available, handle them */ - linuxaio_parse_events (EV_A_ ioev, res); - - if (ecb_expect_true (ringbuf_valid)) - { - /* if we have a ring buffer, handle any remaining events in it */ - linuxaio_get_events_from_ring (EV_A); - - /* at this point, we should have handled all outstanding events */ - break; - } - else if (res < want) - /* otherwise, if there were fewere events than we wanted, we assume there are no more */ - break; - } - else - break; /* no events from the kernel, we are done */ - - timeout = EV_TS_CONST (0.); /* only wait in the first iteration */ - } -} - -inline_size -int -linuxaio_io_setup (EV_P) -{ - linuxaio_ctx = 0; - return evsys_io_setup (linuxaio_nr_events (EV_A), &linuxaio_ctx); -} - -static void -linuxaio_poll (EV_P_ ev_tstamp timeout) -{ - int submitted; - - /* first phase: submit new iocbs */ - - /* io_submit might return less than the requested number of iocbs */ - /* this is, afaics, only because of errors, but we go by the book and use a loop, */ - /* which allows us to pinpoint the erroneous iocb */ - for (submitted = 0; submitted < linuxaio_submitcnt; ) - { - int res = evsys_io_submit (linuxaio_ctx, linuxaio_submitcnt - submitted, linuxaio_submits + submitted); - - if (ecb_expect_false (res < 0)) - if (errno == EINVAL) - { - /* This happens for unsupported fds, officially, but in my testing, - * also randomly happens for supported fds. We fall back to good old - * poll() here, under the assumption that this is a very rare case. - * See https://lore.kernel.org/patchwork/patch/1047453/ to see - * discussion about such a case (ttys) where polling for POLLIN - * fails but POLLIN|POLLOUT works. - */ - struct iocb *iocb = linuxaio_submits [submitted]; - epoll_modify (EV_A_ iocb->aio_fildes, 0, anfds [iocb->aio_fildes].events); - iocb->aio_reqprio = -1; /* mark iocb as epoll */ - - res = 1; /* skip this iocb - another iocb, another chance */ - } - else if (errno == EAGAIN) - { - /* This happens when the ring buffer is full, or some other shit we - * don't know and isn't documented. Most likely because we have too - * many requests and linux aio can't be assed to handle them. - * In this case, we try to allocate a larger ring buffer, freeing - * ours first. This might fail, in which case we have to fall back to 100% - * epoll. - * God, how I hate linux not getting its act together. Ever. - */ - evsys_io_destroy (linuxaio_ctx); - linuxaio_submitcnt = 0; - - /* rearm all fds with active iocbs */ - { - int fd; - for (fd = 0; fd < linuxaio_iocbpmax; ++fd) - if (linuxaio_iocbps [fd]->io.aio_buf) - linuxaio_fd_rearm (EV_A_ fd); - } - - ++linuxaio_iteration; - if (linuxaio_io_setup (EV_A) < 0) - { - /* TODO: rearm all and recreate epoll backend from scratch */ - /* TODO: might be more prudent? */ - - /* to bad, we can't get a new aio context, go 100% epoll */ - linuxaio_free_iocbp (EV_A); - ev_io_stop (EV_A_ &linuxaio_epoll_w); - ev_ref (EV_A); - linuxaio_ctx = 0; - - backend = EVBACKEND_EPOLL; - backend_modify = epoll_modify; - backend_poll = epoll_poll; - } - - timeout = EV_TS_CONST (0.); - /* it's easiest to handle this mess in another iteration */ - return; - } - else if (errno == EBADF) - { - assert (("libev: event loop rejected bad fd", errno != EBADF)); - fd_kill (EV_A_ linuxaio_submits [submitted]->aio_fildes); - - res = 1; /* skip this iocb */ - } - else if (errno == EINTR) /* not seen in reality, not documented */ - res = 0; /* silently ignore and retry */ - else - { - ev_syserr ("(libev) linuxaio io_submit"); - res = 0; - } - - submitted += res; - } - - linuxaio_submitcnt = 0; - - /* second phase: fetch and parse events */ - - linuxaio_get_events (EV_A_ timeout); -} - -inline_size -int -linuxaio_init (EV_P_ int flags) -{ - /* would be great to have a nice test for IOCB_CMD_POLL instead */ - /* also: test some semi-common fd types, such as files and ttys in recommended_backends */ - /* 4.18 introduced IOCB_CMD_POLL, 4.19 made epoll work, and we need that */ - if (ev_linux_version () < 0x041300) - return 0; - - if (!epoll_init (EV_A_ 0)) - return 0; - - linuxaio_iteration = 0; - - if (linuxaio_io_setup (EV_A) < 0) - { - epoll_destroy (EV_A); - return 0; - } - - ev_io_init (&linuxaio_epoll_w, linuxaio_epoll_cb, backend_fd, EV_READ); - ev_set_priority (&linuxaio_epoll_w, EV_MAXPRI); - ev_io_start (EV_A_ &linuxaio_epoll_w); - ev_unref (EV_A); /* watcher should not keep loop alive */ - - backend_modify = linuxaio_modify; - backend_poll = linuxaio_poll; - - linuxaio_iocbpmax = 0; - linuxaio_iocbps = 0; - - linuxaio_submits = 0; - linuxaio_submitmax = 0; - linuxaio_submitcnt = 0; - - return EVBACKEND_LINUXAIO; -} - -inline_size -void -linuxaio_destroy (EV_P) -{ - epoll_destroy (EV_A); - linuxaio_free_iocbp (EV_A); - evsys_io_destroy (linuxaio_ctx); /* fails in child, aio context is destroyed */ -} - -ecb_cold -static void -linuxaio_fork (EV_P) -{ - linuxaio_submitcnt = 0; /* all pointers were invalidated */ - linuxaio_free_iocbp (EV_A); /* this frees all iocbs, which is very heavy-handed */ - evsys_io_destroy (linuxaio_ctx); /* fails in child, aio context is destroyed */ - - linuxaio_iteration = 0; /* we start over in the child */ - - while (linuxaio_io_setup (EV_A) < 0) - ev_syserr ("(libev) linuxaio io_setup"); - - /* forking epoll should also effectively unregister all fds from the backend */ - epoll_fork (EV_A); - /* epoll_fork already did this. hopefully */ - /*fd_rearm_all (EV_A);*/ - - ev_io_stop (EV_A_ &linuxaio_epoll_w); - ev_io_set (EV_A_ &linuxaio_epoll_w, backend_fd, EV_READ); - ev_io_start (EV_A_ &linuxaio_epoll_w); -} - diff --git a/submodules/lev/lev/vendor/ev_poll.c b/submodules/lev/lev/vendor/ev_poll.c deleted file mode 100644 index e5508ddb0..000000000 --- a/submodules/lev/lev/vendor/ev_poll.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * libev poll fd activity backend - * - * Copyright (c) 2007,2008,2009,2010,2011,2016,2019 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#include - -inline_size -void -array_needsize_pollidx (int *base, int offset, int count) -{ - /* using memset (.., -1, ...) is tempting, we we try - * to be ultraportable - */ - base += offset; - while (count--) - *base++ = -1; -} - -static void -poll_modify (EV_P_ int fd, int oev, int nev) -{ - int idx; - - if (oev == nev) - return; - - array_needsize (int, pollidxs, pollidxmax, fd + 1, array_needsize_pollidx); - - idx = pollidxs [fd]; - - if (idx < 0) /* need to allocate a new pollfd */ - { - pollidxs [fd] = idx = pollcnt++; - array_needsize (struct pollfd, polls, pollmax, pollcnt, array_needsize_noinit); - polls [idx].fd = fd; - } - - assert (polls [idx].fd == fd); - - if (nev) - polls [idx].events = - (nev & EV_READ ? POLLIN : 0) - | (nev & EV_WRITE ? POLLOUT : 0); - else /* remove pollfd */ - { - pollidxs [fd] = -1; - - if (ecb_expect_true (idx < --pollcnt)) - { - polls [idx] = polls [pollcnt]; - pollidxs [polls [idx].fd] = idx; - } - } -} - -static void -poll_poll (EV_P_ ev_tstamp timeout) -{ - struct pollfd *p; - int res; - - EV_RELEASE_CB; - res = poll (polls, pollcnt, EV_TS_TO_MSEC (timeout)); - EV_ACQUIRE_CB; - - if (ecb_expect_false (res < 0)) - { - if (errno == EBADF) - fd_ebadf (EV_A); - else if (errno == ENOMEM && !syserr_cb) - fd_enomem (EV_A); - else if (errno != EINTR) - ev_syserr ("(libev) poll"); - } - else - for (p = polls; res; ++p) - { - assert (("libev: poll returned illegal result, broken BSD kernel?", p < polls + pollcnt)); - - if (ecb_expect_false (p->revents)) /* this expect is debatable */ - { - --res; - - if (ecb_expect_false (p->revents & POLLNVAL)) - { - assert (("libev: poll found invalid fd in poll set", 0)); - fd_kill (EV_A_ p->fd); - } - else - fd_event ( - EV_A_ - p->fd, - (p->revents & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) - | (p->revents & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) - ); - } - } -} - -inline_size -int -poll_init (EV_P_ int flags) -{ - backend_mintime = EV_TS_CONST (1e-3); - backend_modify = poll_modify; - backend_poll = poll_poll; - - pollidxs = 0; pollidxmax = 0; - polls = 0; pollmax = 0; pollcnt = 0; - - return EVBACKEND_POLL; -} - -inline_size -void -poll_destroy (EV_P) -{ - ev_free (pollidxs); - ev_free (polls); -} - diff --git a/submodules/lev/lev/vendor/ev_port.c b/submodules/lev/lev/vendor/ev_port.c deleted file mode 100644 index d611459a7..000000000 --- a/submodules/lev/lev/vendor/ev_port.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * libev solaris event port backend - * - * Copyright (c) 2007,2008,2009,2010,2011,2019 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -/* useful reading: - * - * https://archive.is/jN6Ck (random results) - * https://archive.is/bBikp (just totally broken) - * https://archive.is/eJhmu (manpage ETIME) - * https://archive.is/RbgYw (implementation ETIME) - * http://www.mail-archive.com/networking-discuss@opensolaris.org/msg11898.html ETIME vs. nget - * http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/event_port.c (libc) - * http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/fs/portfs/port.c#1325 (kernel) - */ - -#include -#include -#include -#include -#include -#include - -inline_speed -void -port_associate_and_check (EV_P_ int fd, int ev) -{ - if (0 > - port_associate ( - backend_fd, PORT_SOURCE_FD, fd, - (ev & EV_READ ? POLLIN : 0) - | (ev & EV_WRITE ? POLLOUT : 0), - 0 - ) - ) - { - if (errno == EBADFD) - { - assert (("libev: port_associate found invalid fd", errno != EBADFD)); - fd_kill (EV_A_ fd); - } - else - ev_syserr ("(libev) port_associate"); - } -} - -static void -port_modify (EV_P_ int fd, int oev, int nev) -{ - /* we need to reassociate no matter what, as closes are - * once more silently being discarded. - */ - if (!nev) - { - if (oev) - port_dissociate (backend_fd, PORT_SOURCE_FD, fd); - } - else - port_associate_and_check (EV_A_ fd, nev); -} - -static void -port_poll (EV_P_ ev_tstamp timeout) -{ - int res, i; - struct timespec ts; - uint_t nget = 1; - - /* we initialise this to something we will skip in the loop, as */ - /* port_getn can return with nget unchanged, but no indication */ - /* whether it was the original value or has been updated :/ */ - port_events [0].portev_source = 0; - - EV_RELEASE_CB; - EV_TS_SET (ts, timeout); - res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts); - EV_ACQUIRE_CB; - - /* port_getn may or may not set nget on error */ - /* so we rely on port_events [0].portev_source not being updated */ - if (res == -1 && errno != ETIME && errno != EINTR) - ev_syserr ("(libev) port_getn (see https://archive.is/jN6Ck, try LIBEV_FLAGS=3 env variable)"); - - for (i = 0; i < nget; ++i) - { - if (port_events [i].portev_source == PORT_SOURCE_FD) - { - int fd = port_events [i].portev_object; - - fd_event ( - EV_A_ - fd, - (port_events [i].portev_events & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) - | (port_events [i].portev_events & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) - ); - - fd_change (EV_A_ fd, EV__IOFDSET); - } - } - - if (ecb_expect_false (nget == port_eventmax)) - { - ev_free (port_events); - port_eventmax = array_nextsize (sizeof (port_event_t), port_eventmax, port_eventmax + 1); - port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax); - } -} - -inline_size -int -port_init (EV_P_ int flags) -{ - /* Initialize the kernel queue */ - if ((backend_fd = port_create ()) < 0) - return 0; - - assert (("libev: PORT_SOURCE_FD must not be zero", PORT_SOURCE_FD)); - - fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ - - /* if my reading of the opensolaris kernel sources are correct, then - * opensolaris does something very stupid: it checks if the time has already - * elapsed and doesn't round up if that is the case, otherwise it DOES round - * up. Since we can't know what the case is, we need to guess by using a - * "large enough" timeout. Normally, 1e-9 would be correct. - */ - backend_mintime = EV_TS_CONST (1e-3); /* needed to compensate for port_getn returning early */ - backend_modify = port_modify; - backend_poll = port_poll; - - port_eventmax = 64; /* initial number of events receivable per poll */ - port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax); - - return EVBACKEND_PORT; -} - -inline_size -void -port_destroy (EV_P) -{ - ev_free (port_events); -} - -inline_size -void -port_fork (EV_P) -{ - close (backend_fd); - - while ((backend_fd = port_create ()) < 0) - ev_syserr ("(libev) port"); - - fcntl (backend_fd, F_SETFD, FD_CLOEXEC); - - /* re-register interest in fds */ - fd_rearm_all (EV_A); -} - diff --git a/submodules/lev/lev/vendor/ev_select.c b/submodules/lev/lev/vendor/ev_select.c deleted file mode 100644 index b862c8113..000000000 --- a/submodules/lev/lev/vendor/ev_select.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * libev select fd activity backend - * - * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#ifndef _WIN32 -/* for unix systems */ -# include -# ifndef __hpux -/* for REAL unix systems */ -# include -# endif -#endif - -#ifndef EV_SELECT_USE_FD_SET -# ifdef NFDBITS -# define EV_SELECT_USE_FD_SET 0 -# else -# define EV_SELECT_USE_FD_SET 1 -# endif -#endif - -#if EV_SELECT_IS_WINSOCKET -# undef EV_SELECT_USE_FD_SET -# define EV_SELECT_USE_FD_SET 1 -# undef NFDBITS -# define NFDBITS 0 -#endif - -#if !EV_SELECT_USE_FD_SET -# define NFDBYTES (NFDBITS / 8) -#endif - -#include - -static void -select_modify (EV_P_ int fd, int oev, int nev) -{ - if (oev == nev) - return; - - { -#if EV_SELECT_USE_FD_SET - - #if EV_SELECT_IS_WINSOCKET - SOCKET handle = anfds [fd].handle; - #else - int handle = fd; - #endif - - assert (("libev: fd >= FD_SETSIZE passed to fd_set-based select backend", fd < FD_SETSIZE)); - - /* FD_SET is broken on windows (it adds the fd to a set twice or more, - * which eventually leads to overflows). Need to call it only on changes. - */ - #if EV_SELECT_IS_WINSOCKET - if ((oev ^ nev) & EV_READ) - #endif - if (nev & EV_READ) - FD_SET (handle, (fd_set *)vec_ri); - else - FD_CLR (handle, (fd_set *)vec_ri); - - #if EV_SELECT_IS_WINSOCKET - if ((oev ^ nev) & EV_WRITE) - #endif - if (nev & EV_WRITE) - FD_SET (handle, (fd_set *)vec_wi); - else - FD_CLR (handle, (fd_set *)vec_wi); - -#else - - int word = fd / NFDBITS; - fd_mask mask = 1UL << (fd % NFDBITS); - - if (ecb_expect_false (vec_max <= word)) - { - int new_max = word + 1; - - vec_ri = ev_realloc (vec_ri, new_max * NFDBYTES); - vec_ro = ev_realloc (vec_ro, new_max * NFDBYTES); /* could free/malloc */ - vec_wi = ev_realloc (vec_wi, new_max * NFDBYTES); - vec_wo = ev_realloc (vec_wo, new_max * NFDBYTES); /* could free/malloc */ - #ifdef _WIN32 - vec_eo = ev_realloc (vec_eo, new_max * NFDBYTES); /* could free/malloc */ - #endif - - for (; vec_max < new_max; ++vec_max) - ((fd_mask *)vec_ri) [vec_max] = - ((fd_mask *)vec_wi) [vec_max] = 0; - } - - ((fd_mask *)vec_ri) [word] |= mask; - if (!(nev & EV_READ)) - ((fd_mask *)vec_ri) [word] &= ~mask; - - ((fd_mask *)vec_wi) [word] |= mask; - if (!(nev & EV_WRITE)) - ((fd_mask *)vec_wi) [word] &= ~mask; -#endif - } -} - -static void -select_poll (EV_P_ ev_tstamp timeout) -{ - struct timeval tv; - int res; - int fd_setsize; - - EV_RELEASE_CB; - EV_TV_SET (tv, timeout); - -#if EV_SELECT_USE_FD_SET - fd_setsize = sizeof (fd_set); -#else - fd_setsize = vec_max * NFDBYTES; -#endif - - memcpy (vec_ro, vec_ri, fd_setsize); - memcpy (vec_wo, vec_wi, fd_setsize); - -#ifdef _WIN32 - /* pass in the write set as except set. - * the idea behind this is to work around a windows bug that causes - * errors to be reported as an exception and not by setting - * the writable bit. this is so uncontrollably lame. - */ - memcpy (vec_eo, vec_wi, fd_setsize); - res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, (fd_set *)vec_eo, &tv); -#elif EV_SELECT_USE_FD_SET - fd_setsize = anfdmax < FD_SETSIZE ? anfdmax : FD_SETSIZE; - res = select (fd_setsize, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv); -#else - res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv); -#endif - EV_ACQUIRE_CB; - - if (ecb_expect_false (res < 0)) - { - #if EV_SELECT_IS_WINSOCKET - errno = WSAGetLastError (); - #endif - #ifdef WSABASEERR - /* on windows, select returns incompatible error codes, fix this */ - if (errno >= WSABASEERR && errno < WSABASEERR + 1000) - if (errno == WSAENOTSOCK) - errno = EBADF; - else - errno -= WSABASEERR; - #endif - - #ifdef _WIN32 - /* select on windows erroneously returns EINVAL when no fd sets have been - * provided (this is documented). what microsoft doesn't tell you that this bug - * exists even when the fd sets _are_ provided, so we have to check for this bug - * here and emulate by sleeping manually. - * we also get EINVAL when the timeout is invalid, but we ignore this case here - * and assume that EINVAL always means: you have to wait manually. - */ - if (errno == EINVAL) - { - if (timeout) - { - unsigned long ms = EV_TS_TO_MSEC (timeout); - Sleep (ms ? ms : 1); - } - - return; - } - #endif - - if (errno == EBADF) - fd_ebadf (EV_A); - else if (errno == ENOMEM && !syserr_cb) - fd_enomem (EV_A); - else if (errno != EINTR) - ev_syserr ("(libev) select"); - - return; - } - -#if EV_SELECT_USE_FD_SET - - { - int fd; - - for (fd = 0; fd < anfdmax; ++fd) - if (anfds [fd].events) - { - int events = 0; - #if EV_SELECT_IS_WINSOCKET - SOCKET handle = anfds [fd].handle; - #else - int handle = fd; - #endif - - if (FD_ISSET (handle, (fd_set *)vec_ro)) events |= EV_READ; - if (FD_ISSET (handle, (fd_set *)vec_wo)) events |= EV_WRITE; - #ifdef _WIN32 - if (FD_ISSET (handle, (fd_set *)vec_eo)) events |= EV_WRITE; - #endif - - if (ecb_expect_true (events)) - fd_event (EV_A_ fd, events); - } - } - -#else - - { - int word, bit; - for (word = vec_max; word--; ) - { - fd_mask word_r = ((fd_mask *)vec_ro) [word]; - fd_mask word_w = ((fd_mask *)vec_wo) [word]; - #ifdef _WIN32 - word_w |= ((fd_mask *)vec_eo) [word]; - #endif - - if (word_r || word_w) - for (bit = NFDBITS; bit--; ) - { - fd_mask mask = 1UL << bit; - int events = 0; - - events |= word_r & mask ? EV_READ : 0; - events |= word_w & mask ? EV_WRITE : 0; - - if (ecb_expect_true (events)) - fd_event (EV_A_ word * NFDBITS + bit, events); - } - } - } - -#endif -} - -inline_size -int -select_init (EV_P_ int flags) -{ - backend_mintime = EV_TS_CONST (1e-6); - backend_modify = select_modify; - backend_poll = select_poll; - -#if EV_SELECT_USE_FD_SET - vec_ri = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_ri); - vec_ro = ev_malloc (sizeof (fd_set)); - vec_wi = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_wi); - vec_wo = ev_malloc (sizeof (fd_set)); - #ifdef _WIN32 - vec_eo = ev_malloc (sizeof (fd_set)); - #endif -#else - vec_max = 0; - vec_ri = 0; - vec_ro = 0; - vec_wi = 0; - vec_wo = 0; - #ifdef _WIN32 - vec_eo = 0; - #endif -#endif - - return EVBACKEND_SELECT; -} - -inline_size -void -select_destroy (EV_P) -{ - ev_free (vec_ri); - ev_free (vec_ro); - ev_free (vec_wi); - ev_free (vec_wo); - #ifdef _WIN32 - ev_free (vec_eo); - #endif -} - diff --git a/submodules/lev/lev/vendor/ev_vars.h b/submodules/lev/lev/vendor/ev_vars.h deleted file mode 100644 index 5ce8301c9..000000000 --- a/submodules/lev/lev/vendor/ev_vars.h +++ /dev/null @@ -1,247 +0,0 @@ -/* - * loop member variable declarations - * - * Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2019 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#define VARx(type,name) VAR(name, type name) - -VARx(ev_tstamp, now_floor) /* last time we refreshed rt_time */ -VARx(ev_tstamp, mn_now) /* monotonic clock "now" */ -VARx(ev_tstamp, rtmn_diff) /* difference realtime - monotonic time */ - -/* for reverse feeding of events */ -VARx(W *, rfeeds) -VARx(int, rfeedmax) -VARx(int, rfeedcnt) - -VAR (pendings, ANPENDING *pendings [NUMPRI]) -VAR (pendingmax, int pendingmax [NUMPRI]) -VAR (pendingcnt, int pendingcnt [NUMPRI]) -VARx(int, pendingpri) /* highest priority currently pending */ -VARx(ev_prepare, pending_w) /* dummy pending watcher */ - -VARx(ev_tstamp, io_blocktime) -VARx(ev_tstamp, timeout_blocktime) - -VARx(int, backend) -VARx(int, activecnt) /* total number of active events ("refcount") */ -VARx(EV_ATOMIC_T, loop_done) /* signal by ev_break */ - -VARx(int, backend_fd) -VARx(ev_tstamp, backend_mintime) /* assumed typical timer resolution */ -VAR (backend_modify, void (*backend_modify)(EV_P_ int fd, int oev, int nev)) -VAR (backend_poll , void (*backend_poll)(EV_P_ ev_tstamp timeout)) - -VARx(ANFD *, anfds) -VARx(int, anfdmax) - -VAR (evpipe, int evpipe [2]) -VARx(ev_io, pipe_w) -VARx(EV_ATOMIC_T, pipe_write_wanted) -VARx(EV_ATOMIC_T, pipe_write_skipped) - -#if !defined(_WIN32) || EV_GENWRAP -VARx(pid_t, curpid) -#endif - -VARx(char, postfork) /* true if we need to recreate kernel state after fork */ - -#if EV_USE_SELECT || EV_GENWRAP -VARx(void *, vec_ri) -VARx(void *, vec_ro) -VARx(void *, vec_wi) -VARx(void *, vec_wo) -#if defined(_WIN32) || EV_GENWRAP -VARx(void *, vec_eo) -#endif -VARx(int, vec_max) -#endif - -#if EV_USE_POLL || EV_GENWRAP -VARx(struct pollfd *, polls) -VARx(int, pollmax) -VARx(int, pollcnt) -VARx(int *, pollidxs) /* maps fds into structure indices */ -VARx(int, pollidxmax) -#endif - -#if EV_USE_EPOLL || EV_GENWRAP -VARx(struct epoll_event *, epoll_events) -VARx(int, epoll_eventmax) -VARx(int *, epoll_eperms) -VARx(int, epoll_epermcnt) -VARx(int, epoll_epermmax) -#endif - -#if EV_USE_LINUXAIO || EV_GENWRAP -VARx(aio_context_t, linuxaio_ctx) -VARx(int, linuxaio_iteration) -VARx(struct aniocb **, linuxaio_iocbps) -VARx(int, linuxaio_iocbpmax) -VARx(struct iocb **, linuxaio_submits) -VARx(int, linuxaio_submitcnt) -VARx(int, linuxaio_submitmax) -VARx(ev_io, linuxaio_epoll_w) -#endif - -#if EV_USE_IOURING || EV_GENWRAP -VARx(int, iouring_fd) -VARx(unsigned, iouring_to_submit); -VARx(int, iouring_entries) -VARx(int, iouring_max_entries) -VARx(void *, iouring_ring) -VARx(void *, iouring_sqes) -VARx(uint32_t, iouring_ring_size) -VARx(uint32_t, iouring_sqes_size) -VARx(uint32_t, iouring_sq_head) -VARx(uint32_t, iouring_sq_tail) -VARx(uint32_t, iouring_sq_ring_mask) -VARx(uint32_t, iouring_sq_ring_entries) -VARx(uint32_t, iouring_sq_flags) -VARx(uint32_t, iouring_sq_dropped) -VARx(uint32_t, iouring_sq_array) -VARx(uint32_t, iouring_cq_head) -VARx(uint32_t, iouring_cq_tail) -VARx(uint32_t, iouring_cq_ring_mask) -VARx(uint32_t, iouring_cq_ring_entries) -VARx(uint32_t, iouring_cq_overflow) -VARx(uint32_t, iouring_cq_cqes) -VARx(ev_tstamp, iouring_tfd_to) -VARx(int, iouring_tfd) -VARx(ev_io, iouring_tfd_w) -#endif - -#if EV_USE_KQUEUE || EV_GENWRAP -VARx(pid_t, kqueue_fd_pid) -VARx(struct kevent *, kqueue_changes) -VARx(int, kqueue_changemax) -VARx(int, kqueue_changecnt) -VARx(struct kevent *, kqueue_events) -VARx(int, kqueue_eventmax) -#endif - -#if EV_USE_PORT || EV_GENWRAP -VARx(struct port_event *, port_events) -VARx(int, port_eventmax) -#endif - -#if EV_USE_IOCP || EV_GENWRAP -VARx(HANDLE, iocp) -#endif - -VARx(int *, fdchanges) -VARx(int, fdchangemax) -VARx(int, fdchangecnt) - -VARx(ANHE *, timers) -VARx(int, timermax) -VARx(int, timercnt) - -#if EV_PERIODIC_ENABLE || EV_GENWRAP -VARx(ANHE *, periodics) -VARx(int, periodicmax) -VARx(int, periodiccnt) -#endif - -#if EV_IDLE_ENABLE || EV_GENWRAP -VAR (idles, ev_idle **idles [NUMPRI]) -VAR (idlemax, int idlemax [NUMPRI]) -VAR (idlecnt, int idlecnt [NUMPRI]) -#endif -VARx(int, idleall) /* total number */ - -VARx(struct ev_prepare **, prepares) -VARx(int, preparemax) -VARx(int, preparecnt) - -VARx(struct ev_check **, checks) -VARx(int, checkmax) -VARx(int, checkcnt) - -#if EV_FORK_ENABLE || EV_GENWRAP -VARx(struct ev_fork **, forks) -VARx(int, forkmax) -VARx(int, forkcnt) -#endif - -#if EV_CLEANUP_ENABLE || EV_GENWRAP -VARx(struct ev_cleanup **, cleanups) -VARx(int, cleanupmax) -VARx(int, cleanupcnt) -#endif - -#if EV_ASYNC_ENABLE || EV_GENWRAP -VARx(EV_ATOMIC_T, async_pending) -VARx(struct ev_async **, asyncs) -VARx(int, asyncmax) -VARx(int, asynccnt) -#endif - -#if EV_USE_INOTIFY || EV_GENWRAP -VARx(int, fs_fd) -VARx(ev_io, fs_w) -VARx(char, fs_2625) /* whether we are running in linux 2.6.25 or newer */ -VAR (fs_hash, ANFS fs_hash [EV_INOTIFY_HASHSIZE]) -#endif - -VARx(EV_ATOMIC_T, sig_pending) -#if EV_USE_SIGNALFD || EV_GENWRAP -VARx(int, sigfd) -VARx(ev_io, sigfd_w) -VARx(sigset_t, sigfd_set) -#endif - -#if EV_USE_TIMERFD || EV_GENWRAP -VARx(int, timerfd) /* timerfd for time jump detection */ -VARx(ev_io, timerfd_w) -#endif - -VARx(unsigned int, origflags) /* original loop flags */ - -#if EV_FEATURE_API || EV_GENWRAP -VARx(unsigned int, loop_count) /* total number of loop iterations/blocks */ -VARx(unsigned int, loop_depth) /* #ev_run enters - #ev_run leaves */ - -VARx(void *, userdata) -/* C++ doesn't support the ev_loop_callback typedef here. stinks. */ -VAR (release_cb, void (*release_cb)(EV_P) EV_NOEXCEPT) -VAR (acquire_cb, void (*acquire_cb)(EV_P) EV_NOEXCEPT) -VAR (invoke_cb , ev_loop_callback invoke_cb) -#endif - -#undef VARx - diff --git a/submodules/lev/lev/vendor/ev_win32.c b/submodules/lev/lev/vendor/ev_win32.c deleted file mode 100644 index 97344c3e1..000000000 --- a/submodules/lev/lev/vendor/ev_win32.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * libev win32 compatibility cruft (_not_ a backend) - * - * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#ifdef _WIN32 - -/* note: the comment below could not be substantiated, but what would I care */ -/* MSDN says this is required to handle SIGFPE */ -/* my wild guess would be that using something floating-pointy is required */ -/* for the crt to do something about it */ -volatile double SIGFPE_REQ = 0.0f; - -static SOCKET -ev_tcp_socket (void) -{ -#if EV_USE_WSASOCKET - return WSASocket (AF_INET, SOCK_STREAM, 0, 0, 0, 0); -#else - return socket (AF_INET, SOCK_STREAM, 0); -#endif -} - -/* oh, the humanity! */ -static int -ev_pipe (int filedes [2]) -{ - struct sockaddr_in addr = { 0 }; - int addr_size = sizeof (addr); - struct sockaddr_in adr2; - int adr2_size = sizeof (adr2); - SOCKET listener; - SOCKET sock [2] = { -1, -1 }; - - if ((listener = ev_tcp_socket ()) == INVALID_SOCKET) - return -1; - - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - addr.sin_port = 0; - - if (bind (listener, (struct sockaddr *)&addr, addr_size)) - goto fail; - - if (getsockname (listener, (struct sockaddr *)&addr, &addr_size)) - goto fail; - - if (listen (listener, 1)) - goto fail; - - if ((sock [0] = ev_tcp_socket ()) == INVALID_SOCKET) - goto fail; - - if (connect (sock [0], (struct sockaddr *)&addr, addr_size)) - goto fail; - - /* TODO: returns INVALID_SOCKET on winsock accept, not < 0. fix it */ - /* when convenient, probably by just removing error checking altogether? */ - if ((sock [1] = accept (listener, 0, 0)) < 0) - goto fail; - - /* windows vista returns fantasy port numbers for sockets: - * example for two interconnected tcp sockets: - * - * (Socket::unpack_sockaddr_in getsockname $sock0)[0] == 53364 - * (Socket::unpack_sockaddr_in getpeername $sock0)[0] == 53363 - * (Socket::unpack_sockaddr_in getsockname $sock1)[0] == 53363 - * (Socket::unpack_sockaddr_in getpeername $sock1)[0] == 53365 - * - * wow! tridirectional sockets! - * - * this way of checking ports seems to work: - */ - if (getpeername (sock [0], (struct sockaddr *)&addr, &addr_size)) - goto fail; - - if (getsockname (sock [1], (struct sockaddr *)&adr2, &adr2_size)) - goto fail; - - errno = WSAEINVAL; - if (addr_size != adr2_size - || addr.sin_addr.s_addr != adr2.sin_addr.s_addr /* just to be sure, I mean, it's windows */ - || addr.sin_port != adr2.sin_port) - goto fail; - - closesocket (listener); - -#if EV_SELECT_IS_WINSOCKET - filedes [0] = EV_WIN32_HANDLE_TO_FD (sock [0]); - filedes [1] = EV_WIN32_HANDLE_TO_FD (sock [1]); -#else - /* when select isn't winsocket, we also expect socket, connect, accept etc. - * to work on fds */ - filedes [0] = sock [0]; - filedes [1] = sock [1]; -#endif - - return 0; - -fail: - closesocket (listener); - - if (sock [0] != INVALID_SOCKET) closesocket (sock [0]); - if (sock [1] != INVALID_SOCKET) closesocket (sock [1]); - - return -1; -} - -#undef pipe -#define pipe(filedes) ev_pipe (filedes) - -#define EV_HAVE_EV_TIME 1 -ev_tstamp -ev_time (void) -{ - FILETIME ft; - ULARGE_INTEGER ui; - - GetSystemTimeAsFileTime (&ft); - ui.u.LowPart = ft.dwLowDateTime; - ui.u.HighPart = ft.dwHighDateTime; - - /* also, msvc cannot convert ulonglong to double... yes, it is that sucky */ - return EV_TS_FROM_USEC (((LONGLONG)(ui.QuadPart - 116444736000000000) * 1e-1)); -} - -#endif - diff --git a/submodules/lev/lev/vendor/ev_wrap.h b/submodules/lev/lev/vendor/ev_wrap.h deleted file mode 100644 index b038bb9a0..000000000 --- a/submodules/lev/lev/vendor/ev_wrap.h +++ /dev/null @@ -1,268 +0,0 @@ -/* DO NOT EDIT, automatically generated by update_ev_wrap */ -#ifndef EV_WRAP_H -#define EV_WRAP_H -#define acquire_cb ((loop)->acquire_cb) -#define activecnt ((loop)->activecnt) -#define anfdmax ((loop)->anfdmax) -#define anfds ((loop)->anfds) -#define async_pending ((loop)->async_pending) -#define asynccnt ((loop)->asynccnt) -#define asyncmax ((loop)->asyncmax) -#define asyncs ((loop)->asyncs) -#define backend ((loop)->backend) -#define backend_fd ((loop)->backend_fd) -#define backend_mintime ((loop)->backend_mintime) -#define backend_modify ((loop)->backend_modify) -#define backend_poll ((loop)->backend_poll) -#define checkcnt ((loop)->checkcnt) -#define checkmax ((loop)->checkmax) -#define checks ((loop)->checks) -#define cleanupcnt ((loop)->cleanupcnt) -#define cleanupmax ((loop)->cleanupmax) -#define cleanups ((loop)->cleanups) -#define curpid ((loop)->curpid) -#define epoll_epermcnt ((loop)->epoll_epermcnt) -#define epoll_epermmax ((loop)->epoll_epermmax) -#define epoll_eperms ((loop)->epoll_eperms) -#define epoll_eventmax ((loop)->epoll_eventmax) -#define epoll_events ((loop)->epoll_events) -#define evpipe ((loop)->evpipe) -#define fdchangecnt ((loop)->fdchangecnt) -#define fdchangemax ((loop)->fdchangemax) -#define fdchanges ((loop)->fdchanges) -#define forkcnt ((loop)->forkcnt) -#define forkmax ((loop)->forkmax) -#define forks ((loop)->forks) -#define fs_2625 ((loop)->fs_2625) -#define fs_fd ((loop)->fs_fd) -#define fs_hash ((loop)->fs_hash) -#define fs_w ((loop)->fs_w) -#define idleall ((loop)->idleall) -#define idlecnt ((loop)->idlecnt) -#define idlemax ((loop)->idlemax) -#define idles ((loop)->idles) -#define invoke_cb ((loop)->invoke_cb) -#define io_blocktime ((loop)->io_blocktime) -#define iocp ((loop)->iocp) -#define iouring_cq_cqes ((loop)->iouring_cq_cqes) -#define iouring_cq_head ((loop)->iouring_cq_head) -#define iouring_cq_overflow ((loop)->iouring_cq_overflow) -#define iouring_cq_ring_entries ((loop)->iouring_cq_ring_entries) -#define iouring_cq_ring_mask ((loop)->iouring_cq_ring_mask) -#define iouring_cq_tail ((loop)->iouring_cq_tail) -#define iouring_entries ((loop)->iouring_entries) -#define iouring_fd ((loop)->iouring_fd) -#define iouring_max_entries ((loop)->iouring_max_entries) -#define iouring_ring ((loop)->iouring_ring) -#define iouring_ring_size ((loop)->iouring_ring_size) -#define iouring_sq_array ((loop)->iouring_sq_array) -#define iouring_sq_dropped ((loop)->iouring_sq_dropped) -#define iouring_sq_flags ((loop)->iouring_sq_flags) -#define iouring_sq_head ((loop)->iouring_sq_head) -#define iouring_sq_ring_entries ((loop)->iouring_sq_ring_entries) -#define iouring_sq_ring_mask ((loop)->iouring_sq_ring_mask) -#define iouring_sq_tail ((loop)->iouring_sq_tail) -#define iouring_sqes ((loop)->iouring_sqes) -#define iouring_sqes_size ((loop)->iouring_sqes_size) -#define iouring_tfd ((loop)->iouring_tfd) -#define iouring_tfd_to ((loop)->iouring_tfd_to) -#define iouring_tfd_w ((loop)->iouring_tfd_w) -#define iouring_to_submit ((loop)->iouring_to_submit) -#define kqueue_changecnt ((loop)->kqueue_changecnt) -#define kqueue_changemax ((loop)->kqueue_changemax) -#define kqueue_changes ((loop)->kqueue_changes) -#define kqueue_eventmax ((loop)->kqueue_eventmax) -#define kqueue_events ((loop)->kqueue_events) -#define kqueue_fd_pid ((loop)->kqueue_fd_pid) -#define linuxaio_ctx ((loop)->linuxaio_ctx) -#define linuxaio_epoll_w ((loop)->linuxaio_epoll_w) -#define linuxaio_iocbpmax ((loop)->linuxaio_iocbpmax) -#define linuxaio_iocbps ((loop)->linuxaio_iocbps) -#define linuxaio_iteration ((loop)->linuxaio_iteration) -#define linuxaio_submitcnt ((loop)->linuxaio_submitcnt) -#define linuxaio_submitmax ((loop)->linuxaio_submitmax) -#define linuxaio_submits ((loop)->linuxaio_submits) -#define loop_count ((loop)->loop_count) -#define loop_depth ((loop)->loop_depth) -#define loop_done ((loop)->loop_done) -#define mn_now ((loop)->mn_now) -#define now_floor ((loop)->now_floor) -#define origflags ((loop)->origflags) -#define pending_w ((loop)->pending_w) -#define pendingcnt ((loop)->pendingcnt) -#define pendingmax ((loop)->pendingmax) -#define pendingpri ((loop)->pendingpri) -#define pendings ((loop)->pendings) -#define periodiccnt ((loop)->periodiccnt) -#define periodicmax ((loop)->periodicmax) -#define periodics ((loop)->periodics) -#define pipe_w ((loop)->pipe_w) -#define pipe_write_skipped ((loop)->pipe_write_skipped) -#define pipe_write_wanted ((loop)->pipe_write_wanted) -#define pollcnt ((loop)->pollcnt) -#define pollidxmax ((loop)->pollidxmax) -#define pollidxs ((loop)->pollidxs) -#define pollmax ((loop)->pollmax) -#define polls ((loop)->polls) -#define port_eventmax ((loop)->port_eventmax) -#define port_events ((loop)->port_events) -#define postfork ((loop)->postfork) -#define preparecnt ((loop)->preparecnt) -#define preparemax ((loop)->preparemax) -#define prepares ((loop)->prepares) -#define release_cb ((loop)->release_cb) -#define rfeedcnt ((loop)->rfeedcnt) -#define rfeedmax ((loop)->rfeedmax) -#define rfeeds ((loop)->rfeeds) -#define rtmn_diff ((loop)->rtmn_diff) -#define sig_pending ((loop)->sig_pending) -#define sigfd ((loop)->sigfd) -#define sigfd_set ((loop)->sigfd_set) -#define sigfd_w ((loop)->sigfd_w) -#define timeout_blocktime ((loop)->timeout_blocktime) -#define timercnt ((loop)->timercnt) -#define timerfd ((loop)->timerfd) -#define timerfd_w ((loop)->timerfd_w) -#define timermax ((loop)->timermax) -#define timers ((loop)->timers) -#define userdata ((loop)->userdata) -#define vec_eo ((loop)->vec_eo) -#define vec_max ((loop)->vec_max) -#define vec_ri ((loop)->vec_ri) -#define vec_ro ((loop)->vec_ro) -#define vec_wi ((loop)->vec_wi) -#define vec_wo ((loop)->vec_wo) -#else -#undef EV_WRAP_H -#undef acquire_cb -#undef activecnt -#undef anfdmax -#undef anfds -#undef async_pending -#undef asynccnt -#undef asyncmax -#undef asyncs -#undef backend -#undef backend_fd -#undef backend_mintime -#undef backend_modify -#undef backend_poll -#undef checkcnt -#undef checkmax -#undef checks -#undef cleanupcnt -#undef cleanupmax -#undef cleanups -#undef curpid -#undef epoll_epermcnt -#undef epoll_epermmax -#undef epoll_eperms -#undef epoll_eventmax -#undef epoll_events -#undef evpipe -#undef fdchangecnt -#undef fdchangemax -#undef fdchanges -#undef forkcnt -#undef forkmax -#undef forks -#undef fs_2625 -#undef fs_fd -#undef fs_hash -#undef fs_w -#undef idleall -#undef idlecnt -#undef idlemax -#undef idles -#undef invoke_cb -#undef io_blocktime -#undef iocp -#undef iouring_cq_cqes -#undef iouring_cq_head -#undef iouring_cq_overflow -#undef iouring_cq_ring_entries -#undef iouring_cq_ring_mask -#undef iouring_cq_tail -#undef iouring_entries -#undef iouring_fd -#undef iouring_max_entries -#undef iouring_ring -#undef iouring_ring_size -#undef iouring_sq_array -#undef iouring_sq_dropped -#undef iouring_sq_flags -#undef iouring_sq_head -#undef iouring_sq_ring_entries -#undef iouring_sq_ring_mask -#undef iouring_sq_tail -#undef iouring_sqes -#undef iouring_sqes_size -#undef iouring_tfd -#undef iouring_tfd_to -#undef iouring_tfd_w -#undef iouring_to_submit -#undef kqueue_changecnt -#undef kqueue_changemax -#undef kqueue_changes -#undef kqueue_eventmax -#undef kqueue_events -#undef kqueue_fd_pid -#undef linuxaio_ctx -#undef linuxaio_epoll_w -#undef linuxaio_iocbpmax -#undef linuxaio_iocbps -#undef linuxaio_iteration -#undef linuxaio_submitcnt -#undef linuxaio_submitmax -#undef linuxaio_submits -#undef loop_count -#undef loop_depth -#undef loop_done -#undef mn_now -#undef now_floor -#undef origflags -#undef pending_w -#undef pendingcnt -#undef pendingmax -#undef pendingpri -#undef pendings -#undef periodiccnt -#undef periodicmax -#undef periodics -#undef pipe_w -#undef pipe_write_skipped -#undef pipe_write_wanted -#undef pollcnt -#undef pollidxmax -#undef pollidxs -#undef pollmax -#undef polls -#undef port_eventmax -#undef port_events -#undef postfork -#undef preparecnt -#undef preparemax -#undef prepares -#undef release_cb -#undef rfeedcnt -#undef rfeedmax -#undef rfeeds -#undef rtmn_diff -#undef sig_pending -#undef sigfd -#undef sigfd_set -#undef sigfd_w -#undef timeout_blocktime -#undef timercnt -#undef timerfd -#undef timerfd_w -#undef timermax -#undef timers -#undef userdata -#undef vec_eo -#undef vec_max -#undef vec_ri -#undef vec_ro -#undef vec_wi -#undef vec_wo -#endif diff --git a/submodules/lev/lev/vendor/event.c b/submodules/lev/lev/vendor/event.c deleted file mode 100644 index 5586cd353..000000000 --- a/submodules/lev/lev/vendor/event.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * libevent compatibility layer - * - * Copyright (c) 2007,2008,2009,2010,2012 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#include -#include -#include - -#ifdef EV_EVENT_H -# include EV_EVENT_H -#else -# include "event.h" -#endif - -#if EV_MULTIPLICITY -# define dLOOPev struct ev_loop *loop = (struct ev_loop *)ev->ev_base -# define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base -#else -# define dLOOPev -# define dLOOPbase -#endif - -/* never accessed, will always be cast from/to ev_loop */ -struct event_base -{ - int dummy; -}; - -static struct event_base *ev_x_cur; - -static ev_tstamp -ev_tv_get (struct timeval *tv) -{ - if (tv) - { - ev_tstamp after = tv->tv_sec + tv->tv_usec * 1e-6; - return after ? after : 1e-6; - } - else - return -1.; -} - -#define EVENT_STRINGIFY(s) # s -#define EVENT_VERSION(a,b) EVENT_STRINGIFY (a) "." EVENT_STRINGIFY (b) - -const char * -event_get_version (void) -{ - /* returns ABI, not API or library, version */ - return EVENT_VERSION (EV_VERSION_MAJOR, EV_VERSION_MINOR); -} - -const char * -event_get_method (void) -{ - return "libev"; -} - -void *event_init (void) -{ -#if EV_MULTIPLICITY - if (ev_x_cur) - ev_x_cur = (struct event_base *)ev_loop_new (EVFLAG_AUTO); - else - ev_x_cur = (struct event_base *)ev_default_loop (EVFLAG_AUTO); -#else - assert (("libev: multiple event bases not supported when not compiled with EV_MULTIPLICITY", !ev_x_cur)); - - ev_x_cur = (struct event_base *)(long)ev_default_loop (EVFLAG_AUTO); -#endif - - return ev_x_cur; -} - -const char * -event_base_get_method (const struct event_base *base) -{ - return "libev"; -} - -struct event_base * -event_base_new (void) -{ -#if EV_MULTIPLICITY - return (struct event_base *)ev_loop_new (EVFLAG_AUTO); -#else - assert (("libev: multiple event bases not supported when not compiled with EV_MULTIPLICITY")); - return NULL; -#endif -} - -void event_base_free (struct event_base *base) -{ - dLOOPbase; - -#if EV_MULTIPLICITY - if (!ev_is_default_loop (loop)) - ev_loop_destroy (loop); -#endif -} - -int event_dispatch (void) -{ - return event_base_dispatch (ev_x_cur); -} - -#ifdef EV_STANDALONE -void event_set_log_callback (event_log_cb cb) -{ - /* nop */ -} -#endif - -int event_loop (int flags) -{ - return event_base_loop (ev_x_cur, flags); -} - -int event_loopexit (struct timeval *tv) -{ - return event_base_loopexit (ev_x_cur, tv); -} - -event_callback_fn event_get_callback -(const struct event *ev) -{ - return ev->ev_callback; -} - -static void -ev_x_cb (struct event *ev, int revents) -{ - revents &= EV_READ | EV_WRITE | EV_TIMER | EV_SIGNAL; - - ev->ev_res = revents; - ev->ev_callback (ev->ev_fd, (short)revents, ev->ev_arg); -} - -static void -ev_x_cb_sig (EV_P_ struct ev_signal *w, int revents) -{ - struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.sig)); - - if (revents & EV_ERROR) - event_del (ev); - - ev_x_cb (ev, revents); -} - -static void -ev_x_cb_io (EV_P_ struct ev_io *w, int revents) -{ - struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.io)); - - if ((revents & EV_ERROR) || !(ev->ev_events & EV_PERSIST)) - event_del (ev); - - ev_x_cb (ev, revents); -} - -static void -ev_x_cb_to (EV_P_ struct ev_timer *w, int revents) -{ - struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, to)); - - event_del (ev); - - ev_x_cb (ev, revents); -} - -void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg) -{ - if (events & EV_SIGNAL) - ev_init (&ev->iosig.sig, ev_x_cb_sig); - else - ev_init (&ev->iosig.io, ev_x_cb_io); - - ev_init (&ev->to, ev_x_cb_to); - - ev->ev_base = ev_x_cur; /* not threadsafe, but it's how libevent works */ - ev->ev_fd = fd; - ev->ev_events = events; - ev->ev_pri = 0; - ev->ev_callback = cb; - ev->ev_arg = arg; - ev->ev_res = 0; - ev->ev_flags = EVLIST_INIT; -} - -int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) -{ - return event_base_once (ev_x_cur, fd, events, cb, arg, tv); -} - -int event_add (struct event *ev, struct timeval *tv) -{ - dLOOPev; - - if (ev->ev_events & EV_SIGNAL) - { - if (!ev_is_active (&ev->iosig.sig)) - { - ev_signal_set (&ev->iosig.sig, ev->ev_fd); - ev_signal_start (EV_A_ &ev->iosig.sig); - - ev->ev_flags |= EVLIST_SIGNAL; - } - } - else if (ev->ev_events & (EV_READ | EV_WRITE)) - { - if (!ev_is_active (&ev->iosig.io)) - { - ev_io_set (&ev->iosig.io, ev->ev_fd, ev->ev_events & (EV_READ | EV_WRITE)); - ev_io_start (EV_A_ &ev->iosig.io); - - ev->ev_flags |= EVLIST_INSERTED; - } - } - - if (tv) - { - ev->to.repeat = ev_tv_get (tv); - ev_timer_again (EV_A_ &ev->to); - ev->ev_flags |= EVLIST_TIMEOUT; - } - else - { - ev_timer_stop (EV_A_ &ev->to); - ev->ev_flags &= ~EVLIST_TIMEOUT; - } - - ev->ev_flags |= EVLIST_ACTIVE; - - return 0; -} - -int event_del (struct event *ev) -{ - dLOOPev; - - if (ev->ev_events & EV_SIGNAL) - ev_signal_stop (EV_A_ &ev->iosig.sig); - else if (ev->ev_events & (EV_READ | EV_WRITE)) - ev_io_stop (EV_A_ &ev->iosig.io); - - if (ev_is_active (&ev->to)) - ev_timer_stop (EV_A_ &ev->to); - - ev->ev_flags = EVLIST_INIT; - - return 0; -} - -void event_active (struct event *ev, int res, short ncalls) -{ - dLOOPev; - - if (res & EV_TIMEOUT) - ev_feed_event (EV_A_ &ev->to, res & EV_TIMEOUT); - - if (res & EV_SIGNAL) - ev_feed_event (EV_A_ &ev->iosig.sig, res & EV_SIGNAL); - - if (res & (EV_READ | EV_WRITE)) - ev_feed_event (EV_A_ &ev->iosig.io, res & (EV_READ | EV_WRITE)); -} - -int event_pending (struct event *ev, short events, struct timeval *tv) -{ - short revents = 0; - dLOOPev; - - if (ev->ev_events & EV_SIGNAL) - { - /* sig */ - if (ev_is_active (&ev->iosig.sig) || ev_is_pending (&ev->iosig.sig)) - revents |= EV_SIGNAL; - } - else if (ev->ev_events & (EV_READ | EV_WRITE)) - { - /* io */ - if (ev_is_active (&ev->iosig.io) || ev_is_pending (&ev->iosig.io)) - revents |= ev->ev_events & (EV_READ | EV_WRITE); - } - - if (ev->ev_events & EV_TIMEOUT || ev_is_active (&ev->to) || ev_is_pending (&ev->to)) - { - revents |= EV_TIMEOUT; - - if (tv) - { - ev_tstamp at = ev_now (EV_A); - - tv->tv_sec = (long)at; - tv->tv_usec = (long)((at - (ev_tstamp)tv->tv_sec) * 1e6); - } - } - - return events & revents; -} - -int event_priority_init (int npri) -{ - return event_base_priority_init (ev_x_cur, npri); -} - -int event_priority_set (struct event *ev, int pri) -{ - ev->ev_pri = pri; - - return 0; -} - -int event_base_set (struct event_base *base, struct event *ev) -{ - ev->ev_base = base; - - return 0; -} - -int event_base_loop (struct event_base *base, int flags) -{ - dLOOPbase; - - return !ev_run (EV_A_ flags); -} - -int event_base_dispatch (struct event_base *base) -{ - return event_base_loop (base, 0); -} - -static void -ev_x_loopexit_cb (int revents, void *base) -{ - dLOOPbase; - - ev_break (EV_A_ EVBREAK_ONE); -} - -int event_base_loopexit (struct event_base *base, struct timeval *tv) -{ - ev_tstamp after = ev_tv_get (tv); - dLOOPbase; - - ev_once (EV_A_ -1, 0, after >= 0. ? after : 0., ev_x_loopexit_cb, (void *)base); - - return 0; -} - -struct ev_x_once -{ - int fd; - void (*cb)(int, short, void *); - void *arg; -}; - -static void -ev_x_once_cb (int revents, void *arg) -{ - struct ev_x_once *once = (struct ev_x_once *)arg; - - once->cb (once->fd, (short)revents, once->arg); - free (once); -} - -int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) -{ - struct ev_x_once *once = (struct ev_x_once *)malloc (sizeof (struct ev_x_once)); - dLOOPbase; - - if (!once) - return -1; - - once->fd = fd; - once->cb = cb; - once->arg = arg; - - ev_once (EV_A_ fd, events & (EV_READ | EV_WRITE), ev_tv_get (tv), ev_x_once_cb, (void *)once); - - return 0; -} - -int event_base_priority_init (struct event_base *base, int npri) -{ - /*dLOOPbase;*/ - - return 0; -} - diff --git a/submodules/lev/lev/vendor/event.h b/submodules/lev/lev/vendor/event.h deleted file mode 100644 index aa81928f3..000000000 --- a/submodules/lev/lev/vendor/event.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * libevent compatibility header, only core events supported - * - * Copyright (c) 2007,2008,2010,2012 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#ifndef EVENT_H_ -#define EVENT_H_ - -#ifdef EV_H -# include EV_H -#else -# include "ev.h" -#endif - -#ifndef EVLOOP_NONBLOCK -# define EVLOOP_NONBLOCK EVRUN_NOWAIT -#endif -#ifndef EVLOOP_ONESHOT -# define EVLOOP_ONESHOT EVRUN_ONCE -#endif -#ifndef EV_TIMEOUT -# define EV_TIMEOUT EV_TIMER -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* we need sys/time.h for struct timeval only */ -#if !defined (WIN32) || defined (__MINGW32__) -# include /* mingw seems to need this, for whatever reason */ -# include -#endif - -struct event_base; - -#define EVLIST_TIMEOUT 0x01 -#define EVLIST_INSERTED 0x02 -#define EVLIST_SIGNAL 0x04 -#define EVLIST_ACTIVE 0x08 -#define EVLIST_INTERNAL 0x10 -#define EVLIST_INIT 0x80 - -typedef void (*event_callback_fn)(int, short, void *); - -struct event -{ - /* libev watchers we map onto */ - union { - struct ev_io io; - struct ev_signal sig; - } iosig; - struct ev_timer to; - - /* compatibility slots */ - struct event_base *ev_base; - event_callback_fn ev_callback; - void *ev_arg; - int ev_fd; - int ev_pri; - int ev_res; - int ev_flags; - short ev_events; -}; - -event_callback_fn event_get_callback (const struct event *ev); - -#define EV_READ EV_READ -#define EV_WRITE EV_WRITE -#define EV_PERSIST 0x10 -#define EV_ET 0x20 /* nop */ - -#define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) -#define EVENT_FD(ev) ((int) (ev)->ev_fd) - -#define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT) - -#define evtimer_add(ev,tv) event_add (ev, tv) -#define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data) -#define evtimer_del(ev) event_del (ev) -#define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv) -#define evtimer_initialized(ev) event_initialized (ev) - -#define timeout_add(ev,tv) evtimer_add (ev, tv) -#define timeout_set(ev,cb,data) evtimer_set (ev, cb, data) -#define timeout_del(ev) evtimer_del (ev) -#define timeout_pending(ev,tv) evtimer_pending (ev, tv) -#define timeout_initialized(ev) evtimer_initialized (ev) - -#define signal_add(ev,tv) event_add (ev, tv) -#define signal_set(ev,sig,cb,data) event_set (ev, sig, EV_SIGNAL | EV_PERSIST, cb, data) -#define signal_del(ev) event_del (ev) -#define signal_pending(ev,tv) event_pending (ev, EV_SIGNAL, tv) -#define signal_initialized(ev) event_initialized (ev) - -const char *event_get_version (void); -const char *event_get_method (void); - -void *event_init (void); -void event_base_free (struct event_base *base); - -#define EVLOOP_ONCE EVLOOP_ONESHOT -int event_loop (int); -int event_loopexit (struct timeval *tv); -int event_dispatch (void); - -#define _EVENT_LOG_DEBUG 0 -#define _EVENT_LOG_MSG 1 -#define _EVENT_LOG_WARN 2 -#define _EVENT_LOG_ERR 3 -typedef void (*event_log_cb)(int severity, const char *msg); -void event_set_log_callback(event_log_cb cb); - -void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); -int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); - -int event_add (struct event *ev, struct timeval *tv); -int event_del (struct event *ev); -void event_active (struct event *ev, int res, short ncalls); /* ncalls is being ignored */ - -int event_pending (struct event *ev, short, struct timeval *tv); - -int event_priority_init (int npri); -int event_priority_set (struct event *ev, int pri); - -struct event_base *event_base_new (void); -const char *event_base_get_method (const struct event_base *); -int event_base_set (struct event_base *base, struct event *ev); -int event_base_loop (struct event_base *base, int); -int event_base_loopexit (struct event_base *base, struct timeval *tv); -int event_base_dispatch (struct event_base *base); -int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); -int event_base_priority_init (struct event_base *base, int fd); - -/* next line is different in the libevent+libev version */ -/*libevent-include*/ - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/submodules/lev/lev/vendor/event_compat.h b/submodules/lev/lev/vendor/event_compat.h deleted file mode 100644 index c62802c6a..000000000 --- a/submodules/lev/lev/vendor/event_compat.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2000-2004 Niels Provos - * Copyright (c) 2008 Marc Alexander Lehmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# include -# undef WIN32_LEAN_AND_MEAN -typedef unsigned char u_char; -typedef unsigned short u_short; -#else -# include -# include -# include -#endif - -#include - -/* Fix so that ppl dont have to run with */ -#ifndef TAILQ_ENTRY -#define _EVENT_DEFINED_TQENTRY -#define TAILQ_ENTRY(type) \ -struct { \ - struct type *tqe_next; /* next element */ \ - struct type **tqe_prev; /* address of previous next element */ \ -} -#endif /* !TAILQ_ENTRY */ -#ifndef RB_ENTRY -#define _EVENT_DEFINED_RBENTRY -#define RB_ENTRY(type) \ -struct { \ - struct type *rbe_left; /* left element */ \ - struct type *rbe_right; /* right element */ \ - struct type *rbe_parent; /* parent element */ \ - int rbe_color; /* node color */ \ -} -#endif /* !RB_ENTRY */ - -/* - * Key-Value pairs. Can be used for HTTP headers but also for - * query argument parsing. - */ -struct evkeyval { - TAILQ_ENTRY(evkeyval) next; - - char *key; - char *value; -}; - -#ifdef _EVENT_DEFINED_TQENTRY -#undef TAILQ_ENTRY -struct event_list; -struct evkeyvalq; -#undef _EVENT_DEFINED_TQENTRY -#else -TAILQ_HEAD (event_list, event); -TAILQ_HEAD (evkeyvalq, evkeyval); -#endif /* _EVENT_DEFINED_TQENTRY */ -#ifdef _EVENT_DEFINED_RBENTRY -#undef RB_ENTRY -#undef _EVENT_DEFINED_RBENTRY -#endif /* _EVENT_DEFINED_RBENTRY */ - -struct eventop { - char *name; - void *(*init)(struct event_base *); - int (*add)(void *, struct event *); - int (*del)(void *, struct event *); - int (*recalc)(struct event_base *, void *, int); - int (*dispatch)(struct event_base *, void *, struct timeval *); - void (*dealloc)(struct event_base *, void *); -}; - -/* These functions deal with buffering input and output */ - -struct evbuffer { - u_char *buffer; - u_char *orig_buffer; - - size_t misalign; - size_t totallen; - size_t off; - - void (*cb)(struct evbuffer *, size_t, size_t, void *); - void *cbarg; -}; - -/* Just for error reporting - use other constants otherwise */ -#define EVBUFFER_READ 0x01 -#define EVBUFFER_WRITE 0x02 -#define EVBUFFER_EOF 0x10 -#define EVBUFFER_ERROR 0x20 -#define EVBUFFER_TIMEOUT 0x40 - -struct bufferevent; -typedef void (*evbuffercb)(struct bufferevent *, void *); -typedef void (*everrorcb)(struct bufferevent *, short what, void *); - -struct event_watermark { - size_t low; - size_t high; -}; - -struct bufferevent { - struct event ev_read; - struct event ev_write; - - struct evbuffer *input; - struct evbuffer *output; - - struct event_watermark wm_read; - struct event_watermark wm_write; - - evbuffercb readcb; - evbuffercb writecb; - everrorcb errorcb; - void *cbarg; - - int timeout_read; /* in seconds */ - int timeout_write; /* in seconds */ - - short enabled; /* events that are currently enabled */ -}; - -struct bufferevent *bufferevent_new(int fd, - evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg); -int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev); -int bufferevent_priority_set(struct bufferevent *bufev, int pri); -void bufferevent_free(struct bufferevent *bufev); -int bufferevent_write(struct bufferevent *bufev, const void *data, size_t size); -int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf); -size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size); -int bufferevent_enable(struct bufferevent *bufev, short event); -int bufferevent_disable(struct bufferevent *bufev, short event); -void bufferevent_settimeout(struct bufferevent *bufev, - int timeout_read, int timeout_write); - -#define EVBUFFER_LENGTH(x) (x)->off -#define EVBUFFER_DATA(x) (x)->buffer -#define EVBUFFER_INPUT(x) (x)->input -#define EVBUFFER_OUTPUT(x) (x)->output - -struct evbuffer *evbuffer_new(void); -void evbuffer_free(struct evbuffer *); -int evbuffer_expand(struct evbuffer *, size_t); -int evbuffer_add(struct evbuffer *, const void *, size_t); -int evbuffer_remove(struct evbuffer *, void *, size_t); -char *evbuffer_readline(struct evbuffer *); -int evbuffer_add_buffer(struct evbuffer *, struct evbuffer *); -int evbuffer_add_printf(struct evbuffer *, const char *fmt, ...); -int evbuffer_add_vprintf(struct evbuffer *, const char *fmt, va_list ap); -void evbuffer_drain(struct evbuffer *, size_t); -int evbuffer_write(struct evbuffer *, int); -int evbuffer_read(struct evbuffer *, int, int); -u_char *evbuffer_find(struct evbuffer *, const u_char *, size_t); -void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, size_t, void *), void *); - -/* - * Marshaling tagged data - We assume that all tags are inserted in their - * numeric order - so that unknown tags will always be higher than the - * known ones - and we can just ignore the end of an event buffer. - */ - -void evtag_init(void); - -void evtag_marshal(struct evbuffer *evbuf, uint32_t tag, const void *data, - uint32_t len); - -void encode_int(struct evbuffer *evbuf, uint32_t number); - -void evtag_marshal_int(struct evbuffer *evbuf, uint32_t tag, uint32_t integer); - -void evtag_marshal_string(struct evbuffer *buf, uint32_t tag, - const char *string); - -void evtag_marshal_timeval(struct evbuffer *evbuf, uint32_t tag, - struct timeval *tv); - -int evtag_unmarshal(struct evbuffer *src, uint32_t *ptag, struct evbuffer *dst); -int evtag_peek(struct evbuffer *evbuf, uint32_t *ptag); -int evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength); -int evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength); -int evtag_consume(struct evbuffer *evbuf); - -int evtag_unmarshal_int(struct evbuffer *evbuf, uint32_t need_tag, - uint32_t *pinteger); - -int evtag_unmarshal_fixed(struct evbuffer *src, uint32_t need_tag, void *data, - size_t len); - -int evtag_unmarshal_string(struct evbuffer *evbuf, uint32_t need_tag, - char **pstring); - -int evtag_unmarshal_timeval(struct evbuffer *evbuf, uint32_t need_tag, - struct timeval *ptv); - -#ifdef __cplusplus -} -#endif diff --git a/submodules/lev/lev/vendor/import_libevent b/submodules/lev/lev/vendor/import_libevent deleted file mode 100755 index 80d6bc1d1..000000000 --- a/submodules/lev/lev/vendor/import_libevent +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/sh - -LE=../libevent-1.4.3-stable - -if ! [ -e evbuffer.c ]; then - echo do not run this programm unless you know what you are doing - exit 1 -fi - -# this program combines libev and libevent into a single package - -cvs update -AdP libev -rsync -avP libev/. . --exclude CVS - -rm -f configure.ac - -cp $LE/evdns.h . - -perl -i -pe 's%^/.libevent-include./%#include "event_compat.h"%' event.h - -perl -ne ' - s/\s+char buf\[64\];/\tchar buf[96];/; - if (/#include "event.h"/) { - print "#ifndef EV_STANDALONE\n$_#endif\n"; - next; - } - if (/#include "misc.h"/) { - print "#ifndef EV_STANDALONE\n$_#endif\n"; - next; - } - if (/#include "(unistd.h|sys\/time.h)"/) { - print "#ifndef WIN32\n$_#endif\n"; - next; - } - next if /#include "log.h"/; - - print; -' <$LE/evdns.c >evdns.c - -cp $LE/autogen.sh . -cp $LE/epoll_sub.c . -cp $LE/evbuffer.c . -cp $LE/buffer.c . -cp $LE/evhttp.h . -cp $LE/evutil.h . -cp $LE/evutil.c . -cp $LE/event-config.h . -cp $LE/event-internal.h . -cp $LE/evrpc.h . -cp $LE/evrpc.c . -cp $LE/evrpc-internal.h . -cp $LE/http.c . -cp $LE/event_tagging.c . -cp $LE/http-internal.h . -cp $LE/strlcpy-internal.h . -cp $LE/log.c . -cp $LE/log.h . -cp $LE/strlcpy.c . -rsync -a $LE/WIN32* $LE/sample $LE/test $LE/compat . --del -#rename 's/libevent/libev/' WIN32-Prj/lib* -cp $LE/aclocal.m4 . -#cp $LE/acconfig.h . -cp $LE/config.h.in . -cp $LE/event_rpcgen.py . -cp $LE/*.3 . - -#perl -i -pe 's/libevent/libev/g' sample/Makefile.am -#perl -i -pe 's/libevent/libev/g' test/Makefile.am - -perl -i -pe 's/#include $/#include "event.h"/' test/*.c - -perl -i -ne ' - next if /"event-internal.h"/; - s/base\d?->sig.ev_signal_added/0/; - s/base\d?->sig.ev_signal_pair\[0\]/-1/; - s/base->sig.evsignal_caught/0/; - next if /^\ttest_signal_(dealloc|pipeloss|switchbase|assert|restore)\(\)/; - next if /^\ttest_simplesignal\(\)/; # non-default-loop - next if /^\ttest_immediatesignal\(\)/; # non-default-loop - next if /test_priorities\(\d\)/; - print; -' test/regress.c - -perl -ne ' - s/\bmin_heap.h\b//g; - s/\bsignal.c\b//g; - s/\bevport.c\b//g; - s/\bkqueue.c\b//g; - s/\bdevpoll.c\b//g; - s/\brtsig.c\b//g; - s/\bselect.c\b//g; - s/\bpoll.c\b//g; - s/\bepoll.c\b//g; - s/\bepoll_sub.c\b//g; - s/\bevent-internal.h\b//g; - s/\bevsignal.h\b//g; - s/^(man_MANS\s*=)/$1 ev.3 /; - s/^(EXTRA_DIST\s*=)/$1 libev.m4 ev.h ev_vars.h ev_wrap.h event_compat.h ev++.h ev_epoll.c ev_select.c ev_poll.c ev_kqueue.c ev_port.c ev_win32.c ev.3 ev.pod /; - s/^(include_HEADERS\s*=)/$1 ev.h event_compat.h ev++.h /; - s/^(CORE_SRC\s*=)/$1 ev.c /; - s/^(SYS_LIBS\s*=)/$1 -lm /; - #s/libevent/libev/g; - print; -' <$LE/Makefile.am >Makefile.am - -perl -ne ' - #s/-Wall/-Wall -Wno-comment -Wunused-function -Wno-unused-value/; - s/-Wall//g; - #s/libevent/libev/g; - #VERSION - s/AM_INIT_AUTOMAKE\s*\(.*,(.*)\)/AM_INIT_AUTOMAKE(libevent-$1+libev,3.1)/; - s/AC_LIBOBJ\(select\)/: ;/g; - s/AC_LIBOBJ\(poll\)/: ;/g; - s/AC_LIBOBJ\(kqueue\)/: ;/g; - s/AC_LIBOBJ\(epoll\)/: ;/g; - s/AC_LIBOBJ\(devpoll\)/: ;/g; - s/AC_LIBOBJ\(evport\)/: ;/g; - s/AC_LIBOBJ\(signal\)/: ;/g; - s/AC_LIBOBJ\(rtsig\)/: ;/g; - print "m4_include([libev.m4])\n" if /^AC_OUTPUT/; - print; -' <$LE/configure.in >configure.in - -aclocal-1.7 -automake-1.7 --add-missing -autoconf -autoheader -libtoolize -CC="ccache gcc" ./configure --prefix=/opt/libev --disable-shared "$@" - - diff --git a/submodules/lev/lev/vendor/libev.m4 b/submodules/lev/lev/vendor/libev.m4 deleted file mode 100644 index f859eff27..000000000 --- a/submodules/lev/lev/vendor/libev.m4 +++ /dev/null @@ -1,47 +0,0 @@ -dnl this file is part of libev, do not make local modifications -dnl http://software.schmorp.de/pkg/libev - -dnl libev support -AC_CHECK_HEADERS(sys/inotify.h sys/epoll.h sys/event.h port.h poll.h sys/timerfd.h) -AC_CHECK_HEADERS(sys/select.h sys/eventfd.h sys/signalfd.h linux/aio_abi.h linux/fs.h) - -AC_CHECK_FUNCS(inotify_init epoll_ctl kqueue port_create poll select eventfd signalfd) - -AC_CHECK_FUNCS(clock_gettime, [], [ - dnl on linux, try syscall wrapper first - if test $(uname) = Linux; then - AC_MSG_CHECKING(for clock_gettime syscall) - AC_LINK_IFELSE([AC_LANG_PROGRAM( - [#include - #include - #include ], - [struct timespec ts; int status = syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts)])], - [ac_have_clock_syscall=1 - AC_DEFINE(HAVE_CLOCK_SYSCALL, 1, Define to 1 to use the syscall interface for clock_gettime) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no)]) - fi - if test -z "$LIBEV_M4_AVOID_LIBRT" && test -z "$ac_have_clock_syscall"; then - AC_CHECK_LIB(rt, clock_gettime) - unset ac_cv_func_clock_gettime - AC_CHECK_FUNCS(clock_gettime) - fi -]) - -AC_CHECK_FUNCS(nanosleep, [], [ - if test -z "$LIBEV_M4_AVOID_LIBRT"; then - AC_CHECK_LIB(rt, nanosleep) - unset ac_cv_func_nanosleep - AC_CHECK_FUNCS(nanosleep) - fi -]) - -AC_CHECK_TYPE(__kernel_rwf_t, [ - AC_DEFINE(HAVE_KERNEL_RWF_T, 1, Define to 1 if linux/fs.h defined kernel_rwf_t) -], [], [#include ]) - -if test -z "$LIBEV_M4_AVOID_LIBM"; then - LIBM=m -fi -AC_SEARCH_LIBS(floor, $LIBM, [AC_DEFINE(HAVE_FLOOR, 1, Define to 1 if the floor function is available)]) - diff --git a/submodules/lev/lev/vendor/update_ev_c b/submodules/lev/lev/vendor/update_ev_c deleted file mode 100755 index a80bfae23..000000000 --- a/submodules/lev/lev/vendor/update_ev_c +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -e - -( - sed -ne '1,\%/\* ECB.H BEGIN \*/%p' ev.c - #perl -ne 'print unless /^#if ECB_CPP/ .. /^#endif/' <~/src/libecb/ecb.h - cat ~/src/libecb/ecb.h - sed -ne '\%/\* ECB.H END \*/%,$p' ev.c -) >ev.c~ && mv ev.c~ ev.c - diff --git a/submodules/lev/lev/vendor/update_ev_wrap b/submodules/lev/lev/vendor/update_ev_wrap deleted file mode 100755 index 995ea0cd2..000000000 --- a/submodules/lev/lev/vendor/update_ev_wrap +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -( - echo '#define VAR(name,decl) name' - echo '#define EV_GENWRAP 1' - cat ev_vars.h -) | cc -E -o - - | perl -ne ' - while (<>) { - push @syms, $1 if /(^\w+)/; - } - print "/* DO NOT EDIT, automatically generated by update_ev_wrap */\n", - "#ifndef EV_WRAP_H\n", - "#define EV_WRAP_H\n", - (map "#define $_ ((loop)->$_)\n", sort @syms), - "#else\n", - "#undef EV_WRAP_H\n", - (map "#undef $_\n", sort @syms), - "#endif\n"; -' >ev_wrap.h diff --git a/submodules/lev/lev/vendor/update_symbols b/submodules/lev/lev/vendor/update_symbols deleted file mode 100755 index a1a1cb3ad..000000000 --- a/submodules/lev/lev/vendor/update_symbols +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -make ev.o event.o || exit - -nm ev.o | perl -ne 'print "$1\n" if /\S+ [A-Z] (\S+)/' > Symbols.ev -nm event.o | perl -ne 'print "$1\n" if /\S+ [A-Z] (\S+)/' > Symbols.event - diff --git a/vendor/odoc-parser/LICENSE b/vendor/odoc-parser/LICENSE deleted file mode 100644 index 039fd7bf3..000000000 --- a/vendor/odoc-parser/LICENSE +++ /dev/null @@ -1,267 +0,0 @@ -Copyright (c) 2016 Thomas Refis -Copyright (c) 2014, 2015 Leo White -Copyright (c) 2015 David Sheets - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - -# Licenses for the support files used by the generated HTML - -## src/html_support_files/highlight.pack.js - -BSD 3-Clause License - -Copyright (c) 2006, Ivan Sagalaev. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -## src/html_support_files/katex.min.js, katex.min.css and fonts/KaTeX_* - -The MIT License (MIT) - -Copyright (c) 2013-2020 Khan Academy and other contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -## src/html_support_files/fonts/fira-mono-* and fonts/fira-sans-* - -Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. - -## src/html_support_files/fonts/noticia-* - -Copyright (c) 2011, JM Sole (http://jmsole.cl|info@jmsole.cl), -with Reserved Font Name "Noticia Text". - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/vendor/odoc-parser/src/ast.ml b/vendor/odoc-parser/src/ast.ml deleted file mode 100644 index 85c38931f..000000000 --- a/vendor/odoc-parser/src/ast.ml +++ /dev/null @@ -1,95 +0,0 @@ -(** Abstract syntax tree representing ocamldoc comments *) - -(** This is a syntactic representation of ocamldoc comments. See - {{:https://ocaml.org/releases/4.12/htmlman/ocamldoc.html}The manual} for a detailed - description of the syntax understood. Note that there is no attempt at semantic - analysis, and hence these types are capable of representing values that will - be rejected by further stages, for example, invalid references or headings that - are out of range. *) - -type 'a with_location = 'a Loc.with_location -type style = [ `Bold | `Italic | `Emphasis | `Superscript | `Subscript ] -type alignment = [ `Left | `Center | `Right ] - -type reference_kind = [ `Simple | `With_text ] -(** References in doc comments can be of two kinds: [{!simple}] or [{{!ref}With text}]. *) - -type inline_element = - [ `Space of string - | `Word of string - | `Code_span of string - | `Raw_markup of string option * string - | `Styled of style * inline_element with_location list - | `Reference of - reference_kind * string with_location * inline_element with_location list - | `Link of string * inline_element with_location list - | `Math_span of string (** @since 2.0.0 *) ] -(** Inline elements are equivalent to what would be found in a [span] in HTML. - Mostly these are straightforward. The [`Reference] constructor takes a triple - whose second element is the reference itself, and the third the replacement - text. Similarly the [`Link] constructor has the link itself as first parameter - and the second is the replacement text. *) - -type 'a cell = 'a with_location list * [ `Header | `Data ] -type 'a row = 'a cell list -type 'a grid = 'a row list -type 'a abstract_table = 'a grid * alignment option list option - -type code_block_meta = { - language : string with_location; - tags : string with_location option; -} - -type code_block = { - meta : code_block_meta option; - delimiter : string option; - content : string with_location; - output : nestable_block_element with_location list option; -} - -and nestable_block_element = - [ `Paragraph of inline_element with_location list - | `Code_block of code_block - | `Verbatim of string - | `Modules of string with_location list - | `List of - [ `Unordered | `Ordered ] - * [ `Light | `Heavy ] - * nestable_block_element with_location list list - | `Table of table - | `Math_block of string (** @since 2.0.0 *) ] -(** Some block elements may be nested within lists or tags, but not all. - The [`List] constructor has a parameter of type [\[`Light | `Heavy\]]. - This corresponds to the syntactic constructor used (see the - {{:https://ocaml.org/releases/4.12/htmlman/ocamldoc.html#sss:ocamldoc-list}manual}). - *) - -and table = nestable_block_element abstract_table * [ `Light | `Heavy ] - -type internal_tag = - [ `Canonical of string with_location | `Inline | `Open | `Closed | `Hidden ] -(** Internal tags are used to exercise fine control over the output of odoc. They - are never rendered in the output *) - -type ocamldoc_tag = - [ `Author of string - | `Deprecated of nestable_block_element with_location list - | `Param of string * nestable_block_element with_location list - | `Raise of string * nestable_block_element with_location list - | `Return of nestable_block_element with_location list - | `See of - [ `Url | `File | `Document ] - * string - * nestable_block_element with_location list - | `Since of string - | `Before of string * nestable_block_element with_location list - | `Version of string ] -(** ocamldoc tags are those that are specified in the {{:https://ocaml.org/releases/4.12/htmlman/ocamldoc.html#ss:ocamldoc-tags}manual}) *) - -type tag = [ ocamldoc_tag | internal_tag ] -type heading = int * string option * inline_element with_location list - -type block_element = - [ nestable_block_element | `Heading of heading | `Tag of tag ] - -type t = block_element with_location list diff --git a/vendor/odoc-parser/src/compat.ml b/vendor/odoc-parser/src/compat.ml deleted file mode 100644 index a7b535d18..000000000 --- a/vendor/odoc-parser/src/compat.ml +++ /dev/null @@ -1,32 +0,0 @@ -module Option = struct - type 'a t = 'a option = None | Some of 'a - - let is_some = function None -> false | Some _ -> true - let value ~default = function None -> default | Some x -> x - - let join_list l = - let rec loop acc = function - | [] -> Some (List.rev acc) - | Some a :: q -> loop (a :: acc) q - | None :: _ -> None - in - loop [] l -end - -module Char = struct - include Char - - let equal (x : char) y = x = y -end - -module String = struct - include String - - let for_all f str = - let rec aux i = - if i >= String.length str then true - else if f (String.get str i) then aux (i + 1) - else false - in - aux 0 -end diff --git a/vendor/odoc-parser/src/compat.mli b/vendor/odoc-parser/src/compat.mli deleted file mode 100644 index 0959145c2..000000000 --- a/vendor/odoc-parser/src/compat.mli +++ /dev/null @@ -1,26 +0,0 @@ -(** @since 4.08 *) -module Option : sig - type 'a t = 'a option = None | Some of 'a - - val is_some : 'a option -> bool - (** [is_some o] is [true] if and only if [o] is [Some o]. *) - - val value : default:'a -> 'a option -> 'a - val join_list : 'a option list -> 'a list option -end - -module Char : sig - include module type of Char - - val equal : t -> t -> bool - (** The equal function for chars. - @since 4.03.0 *) -end - -module String : sig - include module type of String - - val for_all : (char -> bool) -> string -> bool - (** [for_all p s] checks if all characters in [s] satisfy the preficate [p]. - @since 4.13.0 *) -end diff --git a/vendor/odoc-parser/src/dune b/vendor/odoc-parser/src/dune deleted file mode 100644 index b72423c26..000000000 --- a/vendor/odoc-parser/src/dune +++ /dev/null @@ -1,5 +0,0 @@ -(ocamllex lexer) - -(library - (name odoc_parser) - (libraries astring camlp-streams)) diff --git a/vendor/odoc-parser/src/lexer.mli b/vendor/odoc-parser/src/lexer.mli deleted file mode 100644 index ce053b495..000000000 --- a/vendor/odoc-parser/src/lexer.mli +++ /dev/null @@ -1,10 +0,0 @@ -(* Internal module, not exposed *) - -type input = { - file : string; - offset_to_location : int -> Loc.point; - warnings : Warning.t list ref; - lexbuf : Lexing.lexbuf; -} - -val token : input -> Lexing.lexbuf -> Token.t Loc.with_location diff --git a/vendor/odoc-parser/src/lexer.mll b/vendor/odoc-parser/src/lexer.mll deleted file mode 100644 index 0cde0b434..000000000 --- a/vendor/odoc-parser/src/lexer.mll +++ /dev/null @@ -1,762 +0,0 @@ -{ - -let unescape_word : string -> string = fun s -> - (* The common case is that there are no escape sequences. *) - match String.index s '\\' with - | exception Not_found -> s - | _ -> - let buffer = Buffer.create (String.length s) in - let rec scan_word index = - if index >= String.length s then - () - else - let c = s.[index] in - let c, increment = - match c with - | '\\' -> - if index + 1 < String.length s then - match s.[index + 1] with - | '{' | '}' | '[' | ']' | '@' as c -> c, 2 - | _ -> c, 1 - else c, 1 - | _ -> c, 1 - in - Buffer.add_char buffer c; - scan_word (index + increment) - in - scan_word 0; - Buffer.contents buffer - -type math_kind = - Inline | Block - -let math_constr kind x = - match kind with - | Inline -> `Math_span x - | Block -> `Math_block x - -(* This is used for code and verbatim blocks. It can be done with a regular - expression, but the regexp gets quite ugly, so a function is easier to - understand. *) -let trim_leading_blank_lines : string -> string = fun s -> - let rec scan_for_last_newline : int -> int -> int = - fun index trim_until -> - if index >= String.length s then - String.length s - else - match s.[index] with - | ' ' | '\t' | '\r' -> scan_for_last_newline (index + 1) trim_until - | '\n' -> scan_for_last_newline (index + 1) (index + 1) - | _ -> trim_until - in - let trim_until = scan_for_last_newline 0 0 in - String.sub s trim_until (String.length s - trim_until) - -let trim_trailing_blank_lines : string -> string = fun s -> - let rec scan_for_last_newline : int -> int option -> int option = - fun index trim_from -> - if index < 0 then - Some 0 - else - match s.[index] with - | ' ' | '\t' | '\r' -> scan_for_last_newline (index - 1) trim_from - | '\n' -> scan_for_last_newline (index - 1) (Some index) - | _ -> trim_from - in - let last = String.length s - 1 in - match scan_for_last_newline last None with - | None -> - s - | Some trim_from -> - let trim_from = - if trim_from > 0 && s.[trim_from - 1] = '\r' then - trim_from - 1 - else - trim_from - in - String.sub s 0 trim_from - -(** Returns [None] for an empty, [Some ident] for an indented line. *) -let trim_leading_whitespace : first_line_offset:int -> string -> string = - fun ~first_line_offset s -> - let count_leading_whitespace line = - let rec count_leading_whitespace' index len = - if index = len then None - else - match line.[index] with - | ' ' | '\t' -> count_leading_whitespace' (index + 1) len - | _ -> Some index - in - let len = String.length line in - (* '\r' may remain because we only split on '\n' below. This is important - for the first line, which would be considered not empty without this check. *) - let len = if len > 0 && line.[len - 1] = '\r' then len - 1 else len in - count_leading_whitespace' 0 len - in - - let lines = Astring.String.cuts ~sep:"\n" s in - - let least_amount_of_whitespace = - List.fold_left (fun least_so_far line -> - match (count_leading_whitespace line, least_so_far) with - | (Some _ as n', None) -> n' - | (Some n as n', Some least) when n < least -> n' - | _ -> least_so_far) - in - - let first_line_max_drop, least_amount_of_whitespace = - match lines with - | [] -> 0, None - | first_line :: tl -> - begin match count_leading_whitespace first_line with - | Some n -> - n, least_amount_of_whitespace (Some (first_line_offset + n)) tl - | None -> - 0, least_amount_of_whitespace None tl - end - in - - match least_amount_of_whitespace with - | None -> - s - | Some least_amount_of_whitespace -> - let drop n line = - (* Since blank lines were ignored when calculating - [least_amount_of_whitespace], their length might be less than the - amount. *) - if String.length line < n then line - else String.sub line n (String.length line - n) - in - let lines = - match lines with - | [] -> [] - | first_line :: tl -> - drop (min first_line_max_drop least_amount_of_whitespace) first_line - :: List.map (drop least_amount_of_whitespace) tl - in - String.concat "\n" lines - -type input = { - file : string; - offset_to_location : int -> Loc.point; - warnings : Warning.t list ref; - lexbuf : Lexing.lexbuf; -} - -let with_location_adjustments - k input ?start_offset ?adjust_start_by ?end_offset ?adjust_end_by value = - - let start = - match start_offset with - | None -> Lexing.lexeme_start input.lexbuf - | Some s -> s - in - let start = - match adjust_start_by with - | None -> start - | Some s -> start + String.length s - in - let end_ = - match end_offset with - | None -> Lexing.lexeme_end input.lexbuf - | Some e -> e - in - let end_ = - match adjust_end_by with - | None -> end_ - | Some s -> end_ - String.length s - in - let location = { - Loc.file = input.file; - start = input.offset_to_location start; - end_ = input.offset_to_location end_; - } - in - k input location value - -let emit = - with_location_adjustments (fun _ -> Loc.at) - -let warning = - with_location_adjustments (fun input location error -> - input.warnings := (error location) :: !(input.warnings)) - -let reference_token start target = - match start with - | "{!" -> `Simple_reference target - | "{{!" -> `Begin_reference_with_replacement_text target - | "{:" -> `Simple_link target - | "{{:" -> `Begin_link_with_replacement_text target - | _ -> assert false - -let trim_leading_space_or_accept_whitespace input start_offset text = - match text.[0] with - | ' ' -> String.sub text 1 (String.length text - 1) - | '\t' | '\r' | '\n' -> text - | exception Invalid_argument _ -> "" - | _ -> - warning - input - ~start_offset - ~end_offset:(start_offset + 2) - Parse_error.no_leading_whitespace_in_verbatim; - text - -let trim_trailing_space_or_accept_whitespace text = - match text.[String.length text - 1] with - | ' ' -> String.sub text 0 (String.length text - 1) - | '\t' | '\r' | '\n' -> text - | _ -> text - | exception Invalid_argument _ -> text - -let emit_verbatim input start_offset buffer = - let t = Buffer.contents buffer in - let t = trim_trailing_space_or_accept_whitespace t in - let t = trim_leading_space_or_accept_whitespace input start_offset t in - let t = trim_leading_blank_lines t in - let t = trim_trailing_blank_lines t in - emit input (`Verbatim t) ~start_offset - -(* The locations have to be treated carefully in this function. We need to ensure that - the []`Code_block] location matches the entirety of the block including the terminator, - and the content location is precicely the location of the text of the code itself. - Note that the location reflects the content _without_ stripping of whitespace, whereas - the value of the content in the tree has whitespace stripped from the beginning, - and trailing empty lines removed. *) -let emit_code_block ~start_offset content_offset input metadata delim terminator c has_results = - let c = Buffer.contents c |> trim_trailing_blank_lines in - let content_location = input.offset_to_location content_offset in - let c = - with_location_adjustments - (fun _ _location c -> - let first_line_offset = content_location.column in - trim_leading_whitespace ~first_line_offset c) - input c - in - let c = trim_leading_blank_lines c in - let c = with_location_adjustments ~adjust_end_by:terminator ~start_offset:content_offset (fun _ -> Loc.at) input c in - emit ~start_offset input (`Code_block (metadata, delim, c, has_results)) - -let heading_level input level = - if String.length level >= 2 && level.[0] = '0' then begin - warning - input ~start_offset:1 (Parse_error.leading_zero_in_heading_level level) - end; - int_of_string level - -let buffer_add_lexeme buffer lexbuf = - Buffer.add_string buffer (Lexing.lexeme lexbuf) - -} - -let markup_char = - ['{' '}' '[' ']' '@' '|'] -let space_char = - [' ' '\t' '\n' '\r'] -let bullet_char = - ['-' '+'] - -let word_char = - (_ # markup_char # space_char # bullet_char) | ('\\' markup_char) - -let horizontal_space = - [' ' '\t'] -let newline = - '\n' | "\r\n" - -let reference_start = - "{!" | "{{!" | "{:" | "{{:" - -let raw_markup = - ([^ '%'] | '%'+ [^ '%' '}'])* '%'* - -let raw_markup_target = - ([^ ':' '%'] | '%'+ [^ ':' '%' '}'])* '%'* - -let language_tag_char = - ['a'-'z' 'A'-'Z' '0'-'9' '_' '-' ] - -let delim_char = - ['a'-'z' 'A'-'Z' '0'-'9' '_' ] - -rule reference_paren_content input start ref_offset start_offset depth_paren - buffer = - parse - | '(' - { - buffer_add_lexeme buffer lexbuf ; - reference_paren_content input start ref_offset start_offset - (depth_paren + 1) buffer lexbuf } - | ')' - { - buffer_add_lexeme buffer lexbuf ; - if depth_paren = 0 then - reference_content input start ref_offset buffer lexbuf - else - reference_paren_content input start ref_offset start_offset - (depth_paren - 1) buffer lexbuf } - | eof - { warning - input - ~start_offset - (Parse_error.unclosed_bracket ~bracket:"(") ; - Buffer.contents buffer } - | _ - { - buffer_add_lexeme buffer lexbuf ; - reference_paren_content input start ref_offset start_offset depth_paren - buffer lexbuf } - -and reference_content input start start_offset buffer = parse - | '}' - { - Buffer.contents buffer - } - | '(' - { - buffer_add_lexeme buffer lexbuf ; - reference_paren_content input start start_offset - (Lexing.lexeme_start lexbuf) 0 buffer lexbuf - } - | '"' [^ '"']* '"' - { - buffer_add_lexeme buffer lexbuf ; - reference_content input start start_offset buffer lexbuf - } - | eof - { warning - input - ~start_offset - (Parse_error.unclosed_bracket ~bracket:start) ; - Buffer.contents buffer } - | _ - { - buffer_add_lexeme buffer lexbuf ; - reference_content input start start_offset buffer lexbuf } - -and token input = parse - | horizontal_space* eof - { emit input `End } - - | ((horizontal_space* newline as prefix) - horizontal_space* ((newline horizontal_space*)+ as suffix) as ws) - { emit input (`Blank_line ws) ~adjust_start_by:prefix ~adjust_end_by:suffix } - - | (horizontal_space* newline horizontal_space* as ws) - { emit input (`Single_newline ws) } - - | (horizontal_space+ as ws) - { emit input (`Space ws) } - - | (horizontal_space* (newline horizontal_space*)? as p) '}' - { emit input `Right_brace ~adjust_start_by:p } - - | '|' - { emit input `Bar } - - | word_char (word_char | bullet_char | '@')* - | bullet_char (word_char | bullet_char | '@')+ as w - { emit input (`Word (unescape_word w)) } - - | '[' - { code_span - (Buffer.create 1024) 0 (Lexing.lexeme_start lexbuf) input lexbuf } - - | '-' - { emit input `Minus } - - | '+' - { emit input `Plus } - - | "{b" - { emit input (`Begin_style `Bold) } - - | "{i" - { emit input (`Begin_style `Italic) } - - | "{e" - { emit input (`Begin_style `Emphasis) } - - | "{L" - { emit input (`Begin_paragraph_style `Left) } - - | "{C" - { emit input (`Begin_paragraph_style `Center) } - - | "{R" - { emit input (`Begin_paragraph_style `Right) } - - | "{^" - { emit input (`Begin_style `Superscript) } - - | "{_" - { emit input (`Begin_style `Subscript) } - - | "{math" space_char - { math Block (Buffer.create 1024) 0 (Lexing.lexeme_start lexbuf) input lexbuf } - - | "{m" horizontal_space - { math Inline (Buffer.create 1024) 0 (Lexing.lexeme_start lexbuf) input lexbuf } - - - | "{!modules:" ([^ '}']* as modules) '}' - { emit input (`Modules modules) } - - | (reference_start as start) - { - let start_offset = Lexing.lexeme_start lexbuf in - let target = - reference_content input start start_offset (Buffer.create 16) lexbuf - in - let token = (reference_token start target) in - emit ~start_offset input token } - - | "{[" - { code_block (Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf) None (Buffer.create 256) "" input lexbuf } - - | (("{" (delim_char* as delim) "@" horizontal_space*) as prefix) (language_tag_char+ as lang_tag_) - { - let start_offset = Lexing.lexeme_start lexbuf in - let lang_tag = - with_location_adjustments ~adjust_start_by:prefix (fun _ -> Loc.at) input lang_tag_ - in - let emit_truncated_code_block () = - let empty_content = with_location_adjustments (fun _ -> Loc.at) input "" in - emit ~start_offset input (`Code_block (Some (lang_tag, None), delim, empty_content, false)) - in - match code_block_metadata_tail input lexbuf with - | `Ok metadata -> code_block start_offset (Lexing.lexeme_end lexbuf) (Some (lang_tag, metadata)) (Buffer.create 256) delim input lexbuf - | `Eof -> - warning input ~start_offset Parse_error.truncated_code_block_meta; - emit_truncated_code_block () - | `Invalid_char c -> - warning input ~start_offset - (Parse_error.language_tag_invalid_char lang_tag_ c); - code_block start_offset (Lexing.lexeme_end lexbuf) (Some (lang_tag, None)) (Buffer.create 256) delim input lexbuf - } - - | "{@" horizontal_space* '[' - { - warning input Parse_error.no_language_tag_in_meta; - code_block (Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf) None (Buffer.create 256) "" input lexbuf - } - - | "{v" - { verbatim - (Buffer.create 1024) None (Lexing.lexeme_start lexbuf) input lexbuf } - - | "{%" ((raw_markup_target as target) ':')? (raw_markup as s) - ("%}" | eof as e) - { let token = `Raw_markup (target, s) in - if e <> "%}" then - warning - input - ~start_offset:(Lexing.lexeme_end lexbuf) - (Parse_error.not_allowed - ~what:(Token.describe `End) - ~in_what:(Token.describe token)); - emit input token } - - | "{ul" - { emit input (`Begin_list `Unordered) } - - | "{ol" - { emit input (`Begin_list `Ordered) } - - | "{li" - { emit input (`Begin_list_item `Li) } - - | "{-" - { emit input (`Begin_list_item `Dash) } - - | "{table" - { emit input (`Begin_table_heavy) } - - | "{t" - { emit input (`Begin_table_light) } - - | "{tr" - { emit input `Begin_table_row } - - | "{th" - { emit input (`Begin_table_cell `Header) } - - | "{td" - { emit input (`Begin_table_cell `Data) } - - | '{' (['0'-'9']+ as level) ':' (([^ '}'] # space_char)* as label) - { emit - input (`Begin_section_heading (heading_level input level, Some label)) } - - | '{' (['0'-'9']+ as level) - { emit input (`Begin_section_heading (heading_level input level, None)) } - - | "@author" ((horizontal_space+ [^ '\r' '\n']*)? as author) - { emit input (`Tag (`Author author)) } - - | "@deprecated" - { emit input (`Tag `Deprecated) } - - | "@param" horizontal_space+ ((_ # space_char)+ as name) - { emit input (`Tag (`Param name)) } - - | ("@raise" | "@raises") horizontal_space+ ((_ # space_char)+ as name) - { emit input (`Tag (`Raise name)) } - - | ("@return" | "@returns") - { emit input (`Tag `Return) } - - | "@see" horizontal_space* '<' ([^ '>']* as url) '>' - { emit input (`Tag (`See (`Url, url))) } - - | "@see" horizontal_space* '\'' ([^ '\'']* as filename) '\'' - { emit input (`Tag (`See (`File, filename))) } - - | "@see" horizontal_space* '"' ([^ '"']* as name) '"' - { emit input (`Tag (`See (`Document, name))) } - - | "@since" ((horizontal_space+ [^ '\r' '\n']*)? as version) - { emit input (`Tag (`Since version)) } - - | "@before" horizontal_space+ ((_ # space_char)+ as version) - { emit input (`Tag (`Before version)) } - - | "@version" ((horizontal_space+ [^ '\r' '\n']*)? as version) - { emit input (`Tag (`Version version)) } - - | "@canonical" ((horizontal_space+ [^ '\r' '\n']*)? as identifier) - { emit input (`Tag (`Canonical identifier)) } - - | "@inline" - { emit input (`Tag `Inline) } - - | "@open" - { emit input (`Tag `Open) } - - | "@closed" - { emit input (`Tag `Closed) } - - | "@hidden" - { emit input (`Tag `Hidden) } - - | "]}" - { emit input `Right_code_delimiter} - - | '{' - { try bad_markup_recovery (Lexing.lexeme_start lexbuf) input lexbuf - with Failure _ -> - warning - input - (Parse_error.bad_markup - "{" ~suggestion:"escape the brace with '\\{'."); - emit input (`Word "{") } - - | ']' - { warning input Parse_error.unpaired_right_bracket; - emit input (`Word "]") } - - | "@param" - { warning input Parse_error.truncated_param; - emit input (`Tag (`Param "")) } - - | ("@raise" | "@raises") as tag - { warning input (Parse_error.truncated_raise tag); - emit input (`Tag (`Raise "")) } - - | "@before" - { warning input Parse_error.truncated_before; - emit input (`Tag (`Before "")) } - - | "@see" - { warning input Parse_error.truncated_see; - emit input (`Word "@see") } - - | '@' ['a'-'z' 'A'-'Z']+ as tag - { warning input (Parse_error.unknown_tag tag); - emit input (`Word tag) } - - | '@' - { warning input Parse_error.stray_at; - emit input (`Word "@") } - - | '\r' - { warning input Parse_error.stray_cr; - token input lexbuf } - - | "{!modules:" ([^ '}']* as modules) eof - { warning - input - ~start_offset:(Lexing.lexeme_end lexbuf) - (Parse_error.not_allowed - ~what:(Token.describe `End) - ~in_what:(Token.describe (`Modules ""))); - emit input (`Modules modules) } - -and code_span buffer nesting_level start_offset input = parse - | ']' - { if nesting_level = 0 then - emit input (`Code_span (Buffer.contents buffer)) ~start_offset - else begin - Buffer.add_char buffer ']'; - code_span buffer (nesting_level - 1) start_offset input lexbuf - end } - - | '[' - { Buffer.add_char buffer '['; - code_span buffer (nesting_level + 1) start_offset input lexbuf } - - | '\\' ('[' | ']' as c) - { Buffer.add_char buffer c; - code_span buffer nesting_level start_offset input lexbuf } - - | newline newline - { warning - input - (Parse_error.not_allowed - ~what:(Token.describe (`Blank_line "\n\n")) - ~in_what:(Token.describe (`Code_span ""))); - Buffer.add_char buffer '\n'; - code_span buffer nesting_level start_offset input lexbuf } - - | eof - { warning - input - (Parse_error.not_allowed - ~what:(Token.describe `End) - ~in_what:(Token.describe (`Code_span ""))); - emit input (`Code_span (Buffer.contents buffer)) ~start_offset } - - | _ as c - { Buffer.add_char buffer c; - code_span buffer nesting_level start_offset input lexbuf } - -and math kind buffer nesting_level start_offset input = parse - | '}' - { if nesting_level == 0 then - emit input (math_constr kind (Buffer.contents buffer)) ~start_offset - else begin - Buffer.add_char buffer '}'; - math kind buffer (nesting_level - 1) start_offset input lexbuf - end - } - | '{' - { Buffer.add_char buffer '{'; - math kind buffer (nesting_level + 1) start_offset input lexbuf } - | ("\\{" | "\\}") as s - { Buffer.add_string buffer s; - math kind buffer nesting_level start_offset input lexbuf } - | (newline) as s - { - match kind with - | Inline -> - warning - input - (Parse_error.not_allowed - ~what:(Token.describe (`Blank_line "\n")) - ~in_what:(Token.describe (math_constr kind ""))); - Buffer.add_char buffer '\n'; - math kind buffer nesting_level start_offset input lexbuf - | Block -> - Buffer.add_string buffer s; - math kind buffer nesting_level start_offset input lexbuf - } - | eof - { warning - input - (Parse_error.not_allowed - ~what:(Token.describe `End) - ~in_what:(Token.describe (math_constr kind ""))); - emit input (math_constr kind (Buffer.contents buffer)) ~start_offset } - | _ as c - { Buffer.add_char buffer c; - math kind buffer nesting_level start_offset input lexbuf } - -and verbatim buffer last_false_terminator start_offset input = parse - | (space_char as c) "v}" - { Buffer.add_char buffer c; - emit_verbatim input start_offset buffer } - - | "v}" - { Buffer.add_string buffer "v}"; - verbatim - buffer (Some (Lexing.lexeme_start lexbuf)) start_offset input lexbuf } - - | eof - { begin match last_false_terminator with - | None -> - warning - input - (Parse_error.not_allowed - ~what:(Token.describe `End) - ~in_what:(Token.describe (`Verbatim ""))) - | Some location -> - warning - input - ~start_offset:location - ~end_offset:(location + 2) - Parse_error.no_trailing_whitespace_in_verbatim - end; - emit_verbatim input start_offset buffer } - - | _ as c - { Buffer.add_char buffer c; - verbatim buffer last_false_terminator start_offset input lexbuf } - - - -and bad_markup_recovery start_offset input = parse - | [^ '}']+ as text '}' as rest - { let suggestion = - Printf.sprintf "did you mean '{!%s}' or '[%s]'?" text text in - warning - input - ~start_offset - (Parse_error.bad_markup ("{" ^ rest) ~suggestion); - emit input (`Code_span text) ~start_offset} - -(* The second field of the metadata. - This rule keeps whitespaces and newlines in the 'metadata' field except the - ones just before the '['. *) -and code_block_metadata_tail input = parse - | (space_char+ as prefix) - ((space_char* (_ # space_char # ['['])+)+ as meta) - ((space_char* '[') as suffix) - { - let meta = - with_location_adjustments ~adjust_start_by:prefix ~adjust_end_by:suffix (fun _ -> Loc.at) input meta - in - `Ok (Some meta) - } - | (newline | horizontal_space)* '[' - { `Ok None } - | _ as c - { `Invalid_char c } - | eof - { `Eof } - -and code_block start_offset content_offset metadata prefix delim input = parse - | ("]" (delim_char* as delim') "[") as terminator - { if delim = delim' - then emit_code_block ~start_offset content_offset input metadata delim terminator prefix true - else - (Buffer.add_string prefix terminator; - code_block start_offset content_offset metadata prefix delim input lexbuf) } - | ("]" (delim_char* as delim') "}") as terminator - { - if delim = delim' - then emit_code_block ~start_offset content_offset input metadata delim terminator prefix false - else ( - Buffer.add_string prefix terminator; - code_block start_offset content_offset metadata prefix delim input lexbuf - ) - } - | eof - { - warning input ~start_offset Parse_error.truncated_code_block; - emit_code_block ~start_offset content_offset input metadata delim "" prefix false - } - | (_ as c) - { - Buffer.add_char prefix c; - code_block start_offset content_offset metadata prefix delim input lexbuf - } diff --git a/vendor/odoc-parser/src/loc.ml b/vendor/odoc-parser/src/loc.ml deleted file mode 100644 index 0316fa270..000000000 --- a/vendor/odoc-parser/src/loc.ml +++ /dev/null @@ -1,32 +0,0 @@ -type point = { line : int; column : int } -type span = { file : string; start : point; end_ : point } -type +'a with_location = { location : span; value : 'a } - -let at location value = { location; value } -let location { location; _ } = location -let value { value; _ } = value -let map f annotated = { annotated with value = f annotated.value } -let same annotated value = { annotated with value } - -let span spans = - match spans with - | [] -> - { - file = "_none_"; - start = { line = 1; column = 0 }; - end_ = { line = 1; column = 0 }; - } - | first :: spans -> - let last = List.fold_left (fun _ span -> span) first spans in - { file = first.file; start = first.start; end_ = last.end_ } - -let nudge_start offset span = - { span with start = { span.start with column = span.start.column + offset } } - -let spans_multiple_lines = function - | { - location = - { start = { line = start_line; _ }; end_ = { line = end_line; _ }; _ }; - _; - } -> - end_line > start_line diff --git a/vendor/odoc-parser/src/loc.mli b/vendor/odoc-parser/src/loc.mli deleted file mode 100644 index 135ba0358..000000000 --- a/vendor/odoc-parser/src/loc.mli +++ /dev/null @@ -1,45 +0,0 @@ -(** Locations in files. *) - -(** This module concerns locations in source files, both points indicating a specific - character and spans between two points. *) - -(** {2 Basic types} *) - -type point = { line : int; column : int } -(** A specific character *) - -type span = { file : string; start : point; end_ : point } -(** A range of characters between [start] and [end_] in a particular file *) - -val span : span list -> span -(** [span spans] takes a list of spans and returns a single {!type-span} starting - at the start of the first span and ending at the end of the final span *) - -val nudge_start : int -> span -> span -(** This adjusts only the column number, implicitly assuming that the offset does - not move the location across a newline character. *) - -(** {2 Located values} *) - -type +'a with_location = { location : span; value : 'a } -(** Describes values located at a particular span *) - -val at : span -> 'a -> 'a with_location -(** Constructor for {!with_location} *) - -val location : 'a with_location -> span -(** Returns the location of a located value *) - -val value : 'a with_location -> 'a -(** Returns the value of a located value *) - -val map : ('a -> 'b) -> 'a with_location -> 'b with_location -(** Map over a located value without changing its location *) - -val same : _ with_location -> 'b -> 'b with_location -(** [same x y] retuns the value y wrapped in a {!with_location} whose - location is that of [x] *) - -val spans_multiple_lines : _ with_location -> bool -(** [spans_multiple_lines x] checks to see whether [x] is located - on a single line or whether it covers more than one. *) diff --git a/vendor/odoc-parser/src/odoc_parser.ml b/vendor/odoc-parser/src/odoc_parser.ml deleted file mode 100644 index 2d9fdd5de..000000000 --- a/vendor/odoc-parser/src/odoc_parser.ml +++ /dev/null @@ -1,121 +0,0 @@ -module Ast = Ast -module Loc = Loc -module Warning = Warning - -type t = { - ast : Ast.t; - warnings : Warning.t list; - reversed_newlines : (int * int) list; - original_pos : Lexing.position; -} - -(* odoc uses an ocamllex lexer. The "engine" for such lexers is the standard - [Lexing] module. - - As the [Lexing] module reads the input, it keeps track of only the byte - offset into the input. It is normally the job of each particular lexer - implementation to decide which character sequences count as newlines, and - keep track of line/column locations. This is usually done by writing several - extra regular expressions, and calling [Lexing.new_line] at the right time. - - Keeping track of newlines like this makes the odoc lexer somewhat too - diffiult to read, however. To factor the aspect of keeping track of newlines - fully out of the odoc lexer, instead of having it keep track of newlines as - it's scanning the input, the input is pre-scanned before feeding it into the - lexer. A table of all the newlines is assembled, and used to convert offsets - into line/column pairs after the lexer emits tokens. - - [reversed_newlines ~input ~comment_location offset] returns a list of pairs - of (line number * offset), allowing the easy conversion from the byte - [offset], relative to the beginning of a comment, into a location, relative - to the beginning of the file containing the comment. This can then be used - to convert from byte offset to line number / column number - a Loc.point, - and additionally for converting back from a Loc.point to a Lexing.position. -*) - -let reversed_newlines : input:string -> (int * int) list = - fun ~input -> - let rec find_newlines line_number input_index newlines_accumulator = - if input_index >= String.length input then newlines_accumulator - else if - (* This is good enough to detect CR-LF also. *) - input.[input_index] = '\n' - then - find_newlines (line_number + 1) (input_index + 1) - ((line_number + 1, input_index + 1) :: newlines_accumulator) - else find_newlines line_number (input_index + 1) newlines_accumulator - in - find_newlines 1 0 [ (1, 0) ] - -(* [offset_to_location] converts from an offset within the comment text, where - [reversed_newlines] is the result of the above function and [comment_location] - is the location of the comment within its file. The function is meant to be - partially applied to its first two arguments, at which point it is passed to - the lexer, so it can apply the table to its emitted tokens. *) - -let offset_to_location : - reversed_newlines:(int * int) list -> - comment_location:Lexing.position -> - int -> - Loc.point = - fun ~reversed_newlines ~comment_location byte_offset -> - let rec scan_to_last_newline reversed_newlines_prefix = - match reversed_newlines_prefix with - | [] -> assert false - | (line_in_comment, line_start_offset) :: prefix -> - if line_start_offset > byte_offset then scan_to_last_newline prefix - else - let column_in_comment = byte_offset - line_start_offset in - let line_in_file = - line_in_comment + comment_location.Lexing.pos_lnum - 1 - in - let column_in_file = - if line_in_comment = 1 then - column_in_comment + comment_location.Lexing.pos_cnum - - comment_location.Lexing.pos_bol - else column_in_comment - in - { Loc.line = line_in_file; column = column_in_file } - in - scan_to_last_newline reversed_newlines - -(* Given a Loc.point and the result of [parse_comment], this function returns - a valid Lexing.position *) -let position_of_point : t -> Loc.point -> Lexing.position = - fun v point -> - let { reversed_newlines; original_pos; _ } = v in - let line_in_comment = point.Loc.line - original_pos.pos_lnum + 1 in - let rec find_pos_bol reversed_newlines_prefix = - match reversed_newlines_prefix with - | [] -> assert false - | [ _ ] -> original_pos.pos_bol - | (line_number, line_start_offset) :: prefix -> - if line_number > line_in_comment then find_pos_bol prefix - else line_start_offset + original_pos.pos_cnum - in - let pos_bol = find_pos_bol reversed_newlines in - let pos_lnum = point.Loc.line in - let pos_cnum = point.column + pos_bol in - let pos_fname = original_pos.pos_fname in - { Lexing.pos_bol; pos_lnum; pos_cnum; pos_fname } - -(* The main entry point for this module *) -let parse_comment ~location ~text = - let warnings = ref [] in - let reversed_newlines = reversed_newlines ~input:text in - let token_stream = - let lexbuf = Lexing.from_string text in - let offset_to_location = - offset_to_location ~reversed_newlines ~comment_location:location - in - let input : Lexer.input = - { file = location.Lexing.pos_fname; offset_to_location; warnings; lexbuf } - in - Stream.from (fun _token_index -> Some (Lexer.token input lexbuf)) - in - let ast, warnings = Syntax.parse warnings token_stream in - { ast; warnings; reversed_newlines; original_pos = location } - -(* Accessor functions, as [t] is opaque *) -let warnings t = t.warnings -let ast t = t.ast diff --git a/vendor/odoc-parser/src/odoc_parser.mli b/vendor/odoc-parser/src/odoc_parser.mli deleted file mode 100644 index 5dbd4a081..000000000 --- a/vendor/odoc-parser/src/odoc_parser.mli +++ /dev/null @@ -1,46 +0,0 @@ -(** Parser for ocamldoc formatted comments. *) - -type t -(** [type t] is the result of parsing. *) - -val parse_comment : location:Lexing.position -> text:string -> t -(** [parse_comment ~location ~text] parses [text] as an ocamldoc formatted - string. The parser will try to recover from any invalid syntax encountered, - and therefore this will always produce a result without raising exceptions - with zero or more warnings. The location passed in should represent the - start of the {i content} of the documentation comment - so for a line such - as - {[ - (** A comment starting in the first column (0) *) - ]} - the location should represent the space immediately before the [A], so the - in the 4th column (e.g. [{... pos_bol=0; pos_cnum=3 }]) *) - -module Ast = Ast -module Loc = Loc - -(** Warnings produced during parsing. *) -module Warning : sig - type t = Warning.t = { location : Loc.span; message : string } - (** Warnings are represented as record containing the human-readable text - of the warning alongside the location of the offending text in the source *) - - val pp : Format.formatter -> t -> unit - (** Pretty printer for {!t} *) - - val to_string : t -> string - (** [to_string] will format the location and warning as text to be - printed. *) -end - -val warnings : t -> Warning.t list -(** Extract any warnings from the parser result. *) - -val ast : t -> Ast.t -(** Extract the {!Ast.t} from the parser result. *) - -val position_of_point : t -> Loc.point -> Lexing.position -(** Helper function to turn the internal representation of positions back into - the usual representation in the Lexing module. Note that this relies on - the information passed in {!parse_comment}, and hence requires the result - of that call in addition to the {!Loc.point} being converted. *) diff --git a/vendor/odoc-parser/src/parse_error.ml b/vendor/odoc-parser/src/parse_error.ml deleted file mode 100644 index 4ee22c470..000000000 --- a/vendor/odoc-parser/src/parse_error.ml +++ /dev/null @@ -1,83 +0,0 @@ -let capitalize_ascii = Astring.String.Ascii.capitalize - -let bad_markup : ?suggestion:string -> string -> Loc.span -> Warning.t = - fun ?suggestion -> Warning.make ?suggestion "'%s': bad markup." - -let leading_zero_in_heading_level : string -> Loc.span -> Warning.t = - Warning.make "'%s': leading zero in heading level." - -let should_not_be_empty : what:string -> Loc.span -> Warning.t = - fun ~what -> Warning.make "%s should not be empty." (capitalize_ascii what) - -let markup_should_not_be_used : what:string -> Loc.span -> Warning.t = - fun ~what -> - Warning.make "%s should not be used because it has no effect." - (capitalize_ascii what) - -let should_begin_on_its_own_line : what:string -> Loc.span -> Warning.t = - fun ~what -> - Warning.make "%s should begin on its own line." (capitalize_ascii what) - -let should_be_followed_by_whitespace : what:string -> Loc.span -> Warning.t = - fun ~what -> - Warning.make "%s should be followed by space, a tab, or a new line." - (capitalize_ascii what) - -let not_allowed : - ?suggestion:string -> what:string -> in_what:string -> Loc.span -> Warning.t - = - fun ?suggestion ~what ~in_what -> - Warning.make ?suggestion "%s is not allowed in %s." (capitalize_ascii what) - in_what - -let unclosed_bracket : - ?suggestion:string -> bracket:string -> Loc.span -> Warning.t = - fun ?suggestion ~bracket -> - Warning.make ?suggestion "Open bracket '%s' is never closed." bracket - -let no_leading_whitespace_in_verbatim : Loc.span -> Warning.t = - Warning.make "'{v' should be followed by whitespace." - -let no_trailing_whitespace_in_verbatim : Loc.span -> Warning.t = - Warning.make "'v}' should be preceded by whitespace." - -let stray_at : Loc.span -> Warning.t = Warning.make "Stray '@'." - -let stray_cr : Loc.span -> Warning.t = - Warning.make "Stray '\\r' (carriage return character)." - -let truncated_before : Loc.span -> Warning.t = - Warning.make "'@before' expects version number on the same line." - -let truncated_param : Loc.span -> Warning.t = - Warning.make "'@param' expects parameter name on the same line." - -let truncated_raise : string -> Loc.span -> Warning.t = - Warning.make "'%s' expects exception constructor on the same line." - -let truncated_see : Loc.span -> Warning.t = - Warning.make - "'@see' should be followed by , 'file', or \"document title\"." - -let unknown_tag : string -> Loc.span -> Warning.t = - Warning.make "Unknown tag '%s'." - -let unpaired_right_brace : Loc.span -> Warning.t = - Warning.make ~suggestion:"try '\\}'." "Unpaired '}' (end of markup)." - -let unpaired_right_bracket : Loc.span -> Warning.t = - Warning.make ~suggestion:"try '\\]'." "Unpaired ']' (end of code)." - -let no_language_tag_in_meta : Loc.span -> Warning.t = - Warning.make ~suggestion:"try '{[ ... ]}' or '{@ocaml[ ... ]}'." - "'{@' should be followed by a language tag." - -let language_tag_invalid_char lang_tag : char -> Loc.span -> Warning.t = - let suggestion = "try '{@" ^ lang_tag ^ "[ ... ]}'." in - Warning.make ~suggestion "Invalid character '%c' in language tag." - -let truncated_code_block_meta : Loc.span -> Warning.t = - Warning.make ~suggestion:"try '{@ocaml[ ... ]}'." "Missing end of code block." - -let truncated_code_block : Loc.span -> Warning.t = - Warning.make ~suggestion:"add ']}'." "Missing end of code block." diff --git a/vendor/odoc-parser/src/syntax.ml b/vendor/odoc-parser/src/syntax.ml deleted file mode 100644 index d8ecb87b5..000000000 --- a/vendor/odoc-parser/src/syntax.ml +++ /dev/null @@ -1,1463 +0,0 @@ -(* This module is a recursive descent parser for the ocamldoc syntax. The parser - consumes a token stream of type [Token.t Stream.t], provided by the lexer, - and produces a comment AST of the type defined in [Parser_.Ast]. - - The AST has two main levels: inline elements, which can appear inside - paragraphs, and are spaced horizontally when presented, and block elements, - such as paragraphs and lists, which are spaced vertically when presented. - Block elements contain inline elements, but not vice versa. - - Corresponding to this, the parser has three "main" functions: - - - [delimited_inline_element_list] parses a run of inline elements that is - delimited by curly brace markup ([{...}]). - - [paragraph] parses a run of inline elements that make up a paragraph, and - is not explicitly delimited with curly braces. - - [block_element_list] parses a sequence of block elements. A comment is a - sequence of block elements, so [block_element_list] is the top-level - parser. It is also used for list item and tag content. *) - -open! Compat - -type 'a with_location = 'a Loc.with_location - -(* {2 Input} *) - -type input = { - tokens : Token.t Loc.with_location Stream.t; - warnings : Warning.t list ref; -} - -(* {2 Output} *) - -let add_warning input warning = input.warnings := warning :: !(input.warnings) -let junk input = Stream.junk input.tokens - -let peek input = - match Stream.peek input.tokens with - | Some token -> token - | None -> assert false - -module Table = struct - module Light_syntax = struct - let valid_align = function - | [ { Loc.value = `Word w; _ } ] -> ( - match String.length w with - | 0 -> `Valid None - | 1 -> ( - match w with - | "-" -> `Valid None - | ":" -> `Valid (Some `Center) - | _ -> `Invalid) - | len -> - if String.for_all (Char.equal '-') (String.sub w 1 (len - 2)) then - match (String.get w 0, String.get w (len - 1)) with - | ':', ':' -> `Valid (Some `Center) - | ':', '-' -> `Valid (Some `Left) - | '-', ':' -> `Valid (Some `Right) - | '-', '-' -> `Valid None - | _ -> `Invalid - else `Invalid) - | _ -> `Invalid - - let valid_align_row lx = - let rec loop acc = function - | [] -> Some (List.rev acc) - | x :: q -> ( - match valid_align x with - | `Invalid -> None - | `Valid alignment -> loop (alignment :: acc) q) - in - loop [] lx - - let create ~grid ~align : Ast.table = - let cell_to_block (x, k) = - let whole_loc = Loc.span (List.map (fun x -> x.Loc.location) x) in - match x with - | [] -> ([], k) - | _ -> ([ Loc.at whole_loc (`Paragraph x) ], k) - in - let row_to_block = List.map cell_to_block in - let grid_to_block = List.map row_to_block in - ((grid_to_block grid, align), `Light) - - let with_kind kind : 'a with_location list list -> 'a Ast.row = - List.map (fun c -> (c, kind)) - - let from_raw_data grid : Ast.table = - match grid with - | [] -> create ~grid:[] ~align:None - | row1 :: rows2_N -> ( - match valid_align_row row1 with - (* If the first line is the align row, everything else is data. *) - | Some _ as align -> - create ~grid:(List.map (with_kind `Data) rows2_N) ~align - | None -> ( - match rows2_N with - (* Only 1 line, if this is not the align row this is data. *) - | [] -> create ~grid:[ with_kind `Data row1 ] ~align:None - | row2 :: rows3_N -> ( - match valid_align_row row2 with - (* If the second line is the align row, the first one is the - header and the rest is data. *) - | Some _ as align -> - let header = with_kind `Header row1 in - let data = List.map (with_kind `Data) rows3_N in - create ~grid:(header :: data) ~align - (* No align row in the first 2 lines, everything is considered - data. *) - | None -> - create ~grid:(List.map (with_kind `Data) grid) ~align:None - ))) - end - - module Heavy_syntax = struct - let create ~grid : Ast.table = ((grid, None), `Heavy) - let from_grid grid : Ast.table = create ~grid - end -end - -module Reader = struct - let until_rbrace input acc = - let rec consume () = - let next_token = peek input in - match next_token.value with - | `Right_brace -> - junk input; - `End (acc, next_token.location) - | `Space _ | `Single_newline _ | `Blank_line _ -> - junk input; - consume () - | _ -> `Token next_token - in - consume () - - module Infix = struct - let ( >>> ) consume if_token = - match consume with - | `End (ret, loc) -> (ret, loc) - | `Token t -> if_token t - end -end - -open Reader.Infix - -(* The last token in the stream is always [`End], and it is never consumed by - the parser, so the [None] case is impossible. *) - -let npeek n input = Stream.npeek n input.tokens - -(* {2 Non-link inline elements} *) -type style = [ `Bold | `Italic | `Emphasis | `Superscript | `Subscript ] - -(* Convenient abbreviation for use in patterns. *) -type token_that_always_begins_an_inline_element = - [ `Word of string - | `Code_span of string - | `Raw_markup of string option * string - | `Begin_style of style - | `Simple_reference of string - | `Begin_reference_with_replacement_text of string - | `Simple_link of string - | `Begin_link_with_replacement_text of string - | `Math_span of string ] - -(* Check that the token constructors above actually are all in [Token.t]. *) -let _check_subset : token_that_always_begins_an_inline_element -> Token.t = - fun t -> (t :> Token.t) - -(* Consumes tokens that make up a single non-link inline element: - - - a horizontal space ([`Space], significant in inline elements), - - a word (see [word]), - - a code span ([...], [`Code_span _]), or - - styled text ({e ...}). - - The latter requires a recursive call to [delimited_inline_element_list], - defined below. - - This should be part of [delimited_inline_element_list]; however, it is also - called by function [paragraph]. As a result, it is factored out, and made - mutually-recursive with [delimited_inline_element_list]. - - This is called only when it is known that the first token in the list is the - beginning of an inline element. In the case of [`Minus] and [`Plus], that - means the caller has determined that they are not a list bullet (i.e., not - the first non-whitespace tokens on their line). - - This function consumes exactly the tokens that make up the element. *) -let rec inline_element : - input -> Loc.span -> _ -> Ast.inline_element with_location = - fun input location next_token -> - match next_token with - | `Space _ as token -> - junk input; - Loc.at location token - | `Word _ as token -> - junk input; - Loc.at location token - (* This is actually the same memory representation as the token, complete - with location, and is probably the most common case. Perhaps the token - can be reused somehow. The same is true of [`Space], [`Code_span]. *) - | `Minus -> - junk input; - Loc.at location (`Word "-") - | `Plus -> - junk input; - Loc.at location (`Word "+") - | `Bar -> - junk input; - Loc.at location (`Word "|") - | (`Code_span _ | `Math_span _ | `Raw_markup _) as token -> - junk input; - Loc.at location token - | `Begin_style s as parent_markup -> - junk input; - - let requires_leading_whitespace = - match s with - | `Bold | `Italic | `Emphasis -> true - | `Superscript | `Subscript -> false - in - let content, brace_location = - delimited_inline_element_list ~parent_markup - ~parent_markup_location:location ~requires_leading_whitespace input - in - - let location = Loc.span [ location; brace_location ] in - - if content = [] then - Parse_error.should_not_be_empty - ~what:(Token.describe parent_markup) - location - |> add_warning input; - - Loc.at location (`Styled (s, content)) - | `Simple_reference r -> - junk input; - - let r_location = Loc.nudge_start (String.length "{!") location in - let r = Loc.at r_location r in - - Loc.at location (`Reference (`Simple, r, [])) - | `Begin_reference_with_replacement_text r as parent_markup -> - junk input; - - let r_location = Loc.nudge_start (String.length "{{!") location in - let r = Loc.at r_location r in - - let content, brace_location = - delimited_inline_element_list ~parent_markup - ~parent_markup_location:location ~requires_leading_whitespace:false - input - in - - let location = Loc.span [ location; brace_location ] in - - if content = [] then - Parse_error.should_not_be_empty - ~what:(Token.describe parent_markup) - location - |> add_warning input; - - Loc.at location (`Reference (`With_text, r, content)) - | `Simple_link u -> - junk input; - - let u = String.trim u in - - if u = "" then - Parse_error.should_not_be_empty - ~what:(Token.describe next_token) - location - |> add_warning input; - - Loc.at location (`Link (u, [])) - | `Begin_link_with_replacement_text u as parent_markup -> - junk input; - - let u = String.trim u in - - if u = "" then - Parse_error.should_not_be_empty - ~what:(Token.describe parent_markup) - location - |> add_warning input; - - let content, brace_location = - delimited_inline_element_list ~parent_markup - ~parent_markup_location:location ~requires_leading_whitespace:false - input - in - - `Link (u, content) |> Loc.at (Loc.span [ location; brace_location ]) - -(* Consumes tokens that make up a sequence of inline elements that is ended by - a '}', a [`Right_brace] token. The brace token is also consumed. - - The sequences are also preceded by some markup like '{b'. Some of these - markup tokens require whitespace immediately after the token, and others not. - The caller indicates which way that is through the - [~requires_leading_whitespace] argument. - - Whitespace is significant in inline element lists. In particular, "foo [bar]" - is represented as [`Word "foo"; `Space; `Code_span "bar"], while "foo[bar]" - is [`Word "foo"; `Code_span "bar"]. It doesn't matter how much whitespace is - there, just whether it is present or not. Single newlines and horizontal - space in any amount are allowed. Blank lines are not, as these are separators - for {e block} elements. - - In correct input, the first and last elements emitted will not be [`Space], - i.e. [`Space] appears only between other non-link inline elements. In - incorrect input, there might be [`Space] followed immediately by something - like an @author tag. - - The [~parent_markup] and [~parent_markup_location] arguments are used for - generating error messages. *) -and delimited_inline_element_list : - parent_markup:[< Token.t ] -> - parent_markup_location:Loc.span -> - requires_leading_whitespace:bool -> - input -> - Ast.inline_element with_location list * Loc.span = - fun ~parent_markup ~parent_markup_location ~requires_leading_whitespace input -> - (* [~at_start_of_line] is used to interpret [`Minus] and [`Plus]. These are - word tokens if not the first non-whitespace tokens on their line. Then, - they are allowed in a non-link element list. *) - let rec consume_elements : - at_start_of_line:bool -> - Ast.inline_element with_location list -> - Ast.inline_element with_location list * Loc.span = - fun ~at_start_of_line acc -> - let next_token = peek input in - match next_token.value with - | `Right_brace -> - junk input; - (List.rev acc, next_token.location) - (* The [`Space] token is not space at the beginning or end of line, because - that is combined into [`Single_newline] or [`Blank_line] tokens. It is - also not at the beginning of markup (after e.g. '{b'), because that is - handled separately before calling - [consume_non_link_inline_elements], and not immediately before '}', - because that is combined into the [`Right_brace] token by the lexer. So, - it is an internal space, and we want to add it to the non-link inline - element list. *) - | (`Space _ | #token_that_always_begins_an_inline_element) as token -> - let acc = inline_element input next_token.location token :: acc in - consume_elements ~at_start_of_line:false acc - | `Single_newline ws -> - junk input; - let element = Loc.same next_token (`Space ws) in - consume_elements ~at_start_of_line:true (element :: acc) - | `Blank_line ws as blank -> - Parse_error.not_allowed ~what:(Token.describe blank) - ~in_what:(Token.describe parent_markup) - next_token.location - |> add_warning input; - - junk input; - let element = Loc.same next_token (`Space ws) in - consume_elements ~at_start_of_line:true (element :: acc) - | `Bar as token -> - let acc = inline_element input next_token.location token :: acc in - consume_elements ~at_start_of_line:false acc - | (`Minus | `Plus) as bullet -> - (if at_start_of_line then - let suggestion = - Printf.sprintf "move %s so it isn't the first thing on the line." - (Token.print bullet) - in - Parse_error.not_allowed ~what:(Token.describe bullet) - ~in_what:(Token.describe parent_markup) - ~suggestion next_token.location - |> add_warning input); - - let acc = inline_element input next_token.location bullet :: acc in - consume_elements ~at_start_of_line:false acc - | other_token -> - Parse_error.not_allowed - ~what:(Token.describe other_token) - ~in_what:(Token.describe parent_markup) - next_token.location - |> add_warning input; - - let last_location = - match acc with - | last_token :: _ -> last_token.location - | [] -> parent_markup_location - in - - (List.rev acc, last_location) - in - - let first_token = peek input in - match first_token.value with - | `Space _ -> - junk input; - consume_elements ~at_start_of_line:false [] - (* [~at_start_of_line] is [false] here because the preceding token was some - some markup like '{b', and we didn't move to the next line, so the next - token will not be the first non-whitespace token on its line. *) - | `Single_newline _ -> - junk input; - consume_elements ~at_start_of_line:true [] - | `Blank_line _ as blank -> - (* In case the markup is immediately followed by a blank line, the error - message printed by the catch-all case below can be confusing, as it will - suggest that the markup must be followed by a newline (which it is). It - just must not be followed by two newlines. To explain that clearly, - handle that case specifically. *) - Parse_error.not_allowed ~what:(Token.describe blank) - ~in_what:(Token.describe parent_markup) - first_token.location - |> add_warning input; - - junk input; - consume_elements ~at_start_of_line:true [] - | `Right_brace -> - junk input; - ([], first_token.location) - | _ -> - if requires_leading_whitespace then - Parse_error.should_be_followed_by_whitespace - ~what:(Token.print parent_markup) - parent_markup_location - |> add_warning input; - consume_elements ~at_start_of_line:false [] - -(* {2 Paragraphs} *) - -(* Consumes tokens that make up a paragraph. - - A paragraph is a sequence of inline elements that ends on a blank line, or - explicit block markup such as a verbatim block on a new line. - - Because of the significance of newlines, paragraphs are parsed line-by-line. - The function [paragraph] is called only when the current token is the first - non-whitespace token on its line, and begins an inline element. [paragraph] - then parses a line of inline elements. Afterwards, it looks ahead to the next - line. If that line also begins with an inline element, it parses that line, - and so on. *) -let paragraph : input -> Ast.nestable_block_element with_location = - fun input -> - (* Parses a single line of a paragraph, consisting of inline elements. The - only valid ways to end a paragraph line are with [`End], [`Single_newline], - [`Blank_line], and [`Right_brace]. Everything else either belongs in the - paragraph, or signifies an attempt to begin a block element inside a - paragraph line, which is an error. These errors are caught elsewhere; the - paragraph parser just stops. *) - let rec paragraph_line : - Ast.inline_element with_location list -> - Ast.inline_element with_location list = - fun acc -> - let next_token = peek input in - match next_token.value with - | ( `Space _ | `Minus | `Plus | `Bar - | #token_that_always_begins_an_inline_element ) as token -> - let element = inline_element input next_token.location token in - paragraph_line (element :: acc) - | _ -> acc - in - - (* After each line is parsed, decides whether to parse more lines. *) - let rec additional_lines : - Ast.inline_element with_location list -> - Ast.inline_element with_location list = - fun acc -> - match npeek 2 input with - | { value = `Single_newline ws; location } - :: { value = #token_that_always_begins_an_inline_element | `Bar; _ } - :: _ -> - junk input; - let acc = Loc.at location (`Space ws) :: acc in - let acc = paragraph_line acc in - additional_lines acc - | _ -> List.rev acc - in - - let elements = paragraph_line [] |> additional_lines in - `Paragraph elements |> Loc.at (Loc.span (List.map Loc.location elements)) - -(* {2 Block elements} *) - -(* {3 Helper types} *) - -(* The interpretation of tokens in the block parser depends on where on a line - each token appears. The six possible "locations" are: - - - [`At_start_of_line], when only whitespace has been read on the current - line. - - [`After_tag], when a valid tag token, such as [@deprecated], has been read, - and only whitespace has been read since. - - [`After_shorthand_bullet], when a valid shorthand list item bullet, such as - [-], has been read, and only whitespace has been read since. - - [`After_explicit_list_bullet], when a valid explicit bullet, such as [{li], - has been read, and only whitespace has been read since. - - [`After_table_cell], when a table cell opening markup ('{th' or '{td') has been read. - - [`After_text], when any other valid non-whitespace token has already been - read on the current line. - - Here are some examples of how this affects the interpretation of tokens: - - - A paragraph can start anywhere except [`After_text] (two paragraphs cannot - be on the same line, but paragraphs can be nested in just about anything). - - [`Minus] is interpreted as a list item bullet [`At_start_of_line], - [`After_tag], and [`After_explicit_list_bullet]. - - Tags are only allowed [`At_start_of_line]. - - To track the location accurately, the functions that make up the block parser - pass explicit [where_in_line] values around and return them. - - In a few cases, [where_in_line] can be inferred from what helper was called. - For example, the [paragraph] parser always stops on the same line as the last - significant token that is in the paragraph it consumed, so the location must - be [`After_text]. *) -type where_in_line = - [ `At_start_of_line - | `After_tag - | `After_shorthand_bullet - | `After_explicit_list_bullet - | `After_table_cell - | `After_text ] - -(* The block parsing loop, function [block_element_list], stops when it - encounters certain tokens. - - When it is called for the whole comment, or for in explicit list item - ([{li foo}]), it can only stop on end of input or a right brace. - - When it is called inside a shorthand list item ([- foo]), it stops on end of - input, right brace, a blank line (indicating end of shorthand list), plus or - minus (indicating the start of the next liste item), or a section heading or - tag, which cannot be nested in list markup. - - The block parser [block_element_list] explicitly returns the token that - stopped it, with a type more precise than [Token.t stream_head]: if it was - called for the whole comment or an explicit list item, the stop token will - have type [stops_at_delimiters stream_head], and if it was called for a - shorthand list item, the stop token will have type - [implicit_stop stream_head]. This allows the calling parsers to write precise - cases for exactly the tokens that might be at the front of the stream after - the block parser returns. *) -type stops_at_delimiters = [ `End | `Right_brace ] -type code_stop = [ `End | `Right_code_delimiter ] - -type stopped_implicitly = - [ `End - | `Blank_line of string - | `Right_brace - | `Minus - | `Plus - | Token.section_heading - | Token.tag ] - -(* Ensure that the above two types are really subsets of [Token.t]. *) -let _check_subset : stops_at_delimiters -> Token.t = fun t -> (t :> Token.t) -let _check_subset : stopped_implicitly -> Token.t = fun t -> (t :> Token.t) - -(* The different contexts in which the block parser [block_element_list] can be - called. The block parser's behavior depends somewhat on the context. For - example, while paragraphs are allowed anywhere, shorthand lists are not - allowed immediately inside other shorthand lists, while tags are not allowed - anywhere except at the comment top level. - - Besides telling the block parser how to behave, each context also carries two - types, which determine the return type of the block parser: - - - The type of blocks the parser returns. Note that [nestable_block_element] - is included in [block_element]. However, the extra block kinds in - [block_element] are only allowed at the comment top level. - - The type of token that the block parser stops at. See discussion above. *) -type ('block, 'stops_at_which_tokens) context = - | Top_level : (Ast.block_element, stops_at_delimiters) context - | In_shorthand_list : (Ast.nestable_block_element, stopped_implicitly) context - | In_explicit_list : (Ast.nestable_block_element, stops_at_delimiters) context - | In_table_cell : (Ast.nestable_block_element, stops_at_delimiters) context - | In_code_results : (Ast.nestable_block_element, code_stop) context - | In_tag : (Ast.nestable_block_element, Token.t) context - -(* This is a no-op. It is needed to prove to the type system that nestable block - elements are acceptable block elements in all contexts. *) -let accepted_in_all_contexts : - type block stops_at_which_tokens. - (block, stops_at_which_tokens) context -> - Ast.nestable_block_element -> - block = - fun context block -> - match context with - | Top_level -> (block :> Ast.block_element) - | In_shorthand_list -> block - | In_explicit_list -> block - | In_table_cell -> block - | In_code_results -> block - | In_tag -> block - -(* Converts a tag to a series of words. This is used in error recovery, when a - tag cannot be generated. *) -let tag_to_words = function - | `Author s -> [ `Word "@author"; `Space " "; `Word s ] - | `Before s -> [ `Word "@before"; `Space " "; `Word s ] - | `Canonical s -> [ `Word "@canonical"; `Space " "; `Word s ] - | `Deprecated -> [ `Word "@deprecated" ] - | `Inline -> [ `Word "@inline" ] - | `Open -> [ `Word "@open" ] - | `Closed -> [ `Word "@closed" ] - | `Hidden -> [ `Word "@hidden" ] - | `Param s -> [ `Word "@param"; `Space " "; `Word s ] - | `Raise s -> [ `Word "@raise"; `Space " "; `Word s ] - | `Return -> [ `Word "@return" ] - | `See (`Document, s) -> [ `Word "@see"; `Space " "; `Word ("\"" ^ s ^ "\"") ] - | `See (`File, s) -> [ `Word "@see"; `Space " "; `Word ("'" ^ s ^ "'") ] - | `See (`Url, s) -> [ `Word "@see"; `Space " "; `Word ("<" ^ s ^ ">") ] - | `Since s -> [ `Word "@since"; `Space " "; `Word s ] - | `Version s -> [ `Word "@version"; `Space " "; `Word s ] - -(* {3 Block element lists} *) - -(* Consumes tokens making up a sequence of block elements. These are: - - - paragraphs, - - code blocks, - - verbatim text blocks, - - tables, - - lists, and - - section headings. *) -let rec block_element_list : - type block stops_at_which_tokens. - (block, stops_at_which_tokens) context -> - parent_markup:[< Token.t | `Comment ] -> - input -> - block with_location list - * stops_at_which_tokens with_location - * where_in_line = - fun context ~parent_markup input -> - let rec consume_block_elements : - parsed_a_tag:bool -> - where_in_line -> - block with_location list -> - block with_location list - * stops_at_which_tokens with_location - * where_in_line = - fun ~parsed_a_tag where_in_line acc -> - let describe token = - match token with - | #token_that_always_begins_an_inline_element -> "paragraph" - | _ -> Token.describe token - in - - let warn_if_after_text { Loc.location; value = token } = - if where_in_line = `After_text then - Parse_error.should_begin_on_its_own_line ~what:(describe token) location - |> add_warning input - in - - let warn_if_after_tags { Loc.location; value = token } = - if parsed_a_tag then - let suggestion = - Printf.sprintf "move %s before any tags." (Token.describe token) - in - Parse_error.not_allowed ~what:(describe token) - ~in_what:"the tags section" ~suggestion location - |> add_warning input - in - - let warn_because_not_at_top_level { Loc.location; value = token } = - let suggestion = - Printf.sprintf "move %s outside of any other markup." - (Token.print token) - in - Parse_error.not_allowed ~what:(Token.describe token) - ~in_what:(Token.describe parent_markup) - ~suggestion location - |> add_warning input - in - - match peek input with - (* Terminators: the two tokens that terminate anything. *) - | { value = `End; _ } as next_token -> ( - match context with - | Top_level -> (List.rev acc, next_token, where_in_line) - | In_shorthand_list -> (List.rev acc, next_token, where_in_line) - | In_explicit_list -> (List.rev acc, next_token, where_in_line) - | In_tag -> (List.rev acc, next_token, where_in_line) - | In_table_cell -> (List.rev acc, next_token, where_in_line) - | In_code_results -> (List.rev acc, next_token, where_in_line)) - | { value = `Right_brace; _ } as next_token -> ( - (* This little absurdity is needed to satisfy the type system. Without it, - OCaml is unable to prove that [stream_head] has the right type for all - possible values of [context]. *) - match context with - | Top_level -> (List.rev acc, next_token, where_in_line) - | In_shorthand_list -> (List.rev acc, next_token, where_in_line) - | In_explicit_list -> (List.rev acc, next_token, where_in_line) - | In_table_cell -> (List.rev acc, next_token, where_in_line) - | In_tag -> (List.rev acc, next_token, where_in_line) - | In_code_results -> - junk input; - consume_block_elements ~parsed_a_tag where_in_line acc) - | { value = `Right_code_delimiter; _ } as next_token -> ( - match context with - | In_code_results -> (List.rev acc, next_token, where_in_line) - | _ -> - junk input; - consume_block_elements ~parsed_a_tag where_in_line acc) - (* Whitespace. This can terminate some kinds of block elements. It is also - necessary to track it to interpret [`Minus] and [`Plus] correctly, as - well as to ensure that all block elements begin on their own line. *) - | { value = `Space _; _ } -> - junk input; - consume_block_elements ~parsed_a_tag where_in_line acc - | { value = `Single_newline _; _ } -> - junk input; - consume_block_elements ~parsed_a_tag `At_start_of_line acc - | { value = `Blank_line _; _ } as next_token -> ( - match context with - (* Blank lines terminate shorthand lists ([- foo]). They also terminate - paragraphs, but the paragraph parser is aware of that internally. *) - | In_shorthand_list -> (List.rev acc, next_token, where_in_line) - (* Otherwise, blank lines are pretty much like single newlines. *) - | _ -> - junk input; - consume_block_elements ~parsed_a_tag `At_start_of_line acc) - (* Explicit list items ([{li ...}] and [{- ...}]) can never appear directly - in block content. They can only appear inside [{ul ...}] and [{ol ...}]. - So, catch those. *) - | { value = `Begin_list_item _ as token; location } -> - let suggestion = - Printf.sprintf "move %s into %s, or use %s." (Token.print token) - (Token.describe (`Begin_list `Unordered)) - (Token.describe `Minus) - in - Parse_error.not_allowed ~what:(Token.describe token) - ~in_what:(Token.describe parent_markup) - ~suggestion location - |> add_warning input; - - junk input; - consume_block_elements ~parsed_a_tag where_in_line acc - (* Table rows ([{tr ...}]) can never appear directly - in block content. They can only appear inside [{table ...}]. *) - | { value = `Begin_table_row as token; location } -> - let suggestion = - Printf.sprintf "move %s into %s." (Token.print token) - (Token.describe `Begin_table_heavy) - in - Parse_error.not_allowed ~what:(Token.describe token) - ~in_what:(Token.describe parent_markup) - ~suggestion location - |> add_warning input; - junk input; - consume_block_elements ~parsed_a_tag where_in_line acc - (* Table cells ([{th ...}] and [{td ...}]) can never appear directly - in block content. They can only appear inside [{tr ...}]. *) - | { value = `Begin_table_cell _ as token; location } -> - let suggestion = - Printf.sprintf "move %s into %s." (Token.print token) - (Token.describe `Begin_table_row) - in - Parse_error.not_allowed ~what:(Token.describe token) - ~in_what:(Token.describe parent_markup) - ~suggestion location - |> add_warning input; - junk input; - consume_block_elements ~parsed_a_tag where_in_line acc - (* Tags. These can appear at the top level only. Also, once one tag is seen, - the only top-level elements allowed are more tags. *) - | { value = `Tag tag as token; location } as next_token -> ( - let recover_when_not_at_top_level context = - warn_because_not_at_top_level next_token; - junk input; - let words = List.map (Loc.at location) (tag_to_words tag) in - let paragraph = - `Paragraph words - |> accepted_in_all_contexts context - |> Loc.at location - in - consume_block_elements ~parsed_a_tag `At_start_of_line - (paragraph :: acc) - in - - match context with - (* Tags cannot make sense in an explicit list ([{ul {li ...}}]). *) - | In_explicit_list -> recover_when_not_at_top_level context - (* If a tag starts at the beginning of a line, it terminates the preceding - tag and/or the current shorthand list. In this case, return to the - caller, and let the caller decide how to interpret the tag token. *) - | In_shorthand_list -> - if where_in_line = `At_start_of_line then - (List.rev acc, next_token, where_in_line) - else recover_when_not_at_top_level context - | In_table_cell -> recover_when_not_at_top_level context - | In_tag -> - if where_in_line = `At_start_of_line then - (List.rev acc, next_token, where_in_line) - else recover_when_not_at_top_level context - | In_code_results -> recover_when_not_at_top_level context - (* If this is the top-level call to [block_element_list], parse the - tag. *) - | Top_level -> ( - if where_in_line <> `At_start_of_line then - Parse_error.should_begin_on_its_own_line - ~what:(Token.describe token) location - |> add_warning input; - - junk input; - - match tag with - | (`Author s | `Since s | `Version s | `Canonical s) as tag -> - let s = String.trim s in - if s = "" then - Parse_error.should_not_be_empty ~what:(Token.describe token) - location - |> add_warning input; - let tag = - match tag with - | `Author _ -> `Author s - | `Since _ -> `Since s - | `Version _ -> `Version s - | `Canonical _ -> - (* TODO The location is only approximate, as we need lexer - cooperation to get the real location. *) - let r_location = - Loc.nudge_start (String.length "@canonical ") location - in - `Canonical (Loc.at r_location s) - in - - let tag = Loc.at location (`Tag tag) in - consume_block_elements ~parsed_a_tag:true `After_text - (tag :: acc) - | (`Deprecated | `Return) as tag -> - let content, _stream_head, where_in_line = - block_element_list In_tag ~parent_markup:token input - in - let tag = - match tag with - | `Deprecated -> `Deprecated content - | `Return -> `Return content - in - let location = - location :: List.map Loc.location content |> Loc.span - in - let tag = Loc.at location (`Tag tag) in - consume_block_elements ~parsed_a_tag:true where_in_line - (tag :: acc) - | (`Param _ | `Raise _ | `Before _) as tag -> - let content, _stream_head, where_in_line = - block_element_list In_tag ~parent_markup:token input - in - let tag = - match tag with - | `Param s -> `Param (s, content) - | `Raise s -> `Raise (s, content) - | `Before s -> `Before (s, content) - in - let location = - location :: List.map Loc.location content |> Loc.span - in - let tag = Loc.at location (`Tag tag) in - consume_block_elements ~parsed_a_tag:true where_in_line - (tag :: acc) - | `See (kind, target) -> - let content, _next_token, where_in_line = - block_element_list In_tag ~parent_markup:token input - in - let location = - location :: List.map Loc.location content |> Loc.span - in - let tag = `Tag (`See (kind, target, content)) in - let tag = Loc.at location tag in - consume_block_elements ~parsed_a_tag:true where_in_line - (tag :: acc) - | (`Inline | `Open | `Closed | `Hidden) as tag -> - let tag = Loc.at location (`Tag tag) in - consume_block_elements ~parsed_a_tag:true `After_text - (tag :: acc))) - | ( { value = #token_that_always_begins_an_inline_element; _ } - | { value = `Bar; _ } ) as next_token -> - warn_if_after_tags next_token; - warn_if_after_text next_token; - - let block = paragraph input in - let block = Loc.map (accepted_in_all_contexts context) block in - let acc = block :: acc in - consume_block_elements ~parsed_a_tag `After_text acc - | { value = `Verbatim s as token; location } as next_token -> - warn_if_after_tags next_token; - warn_if_after_text next_token; - if s = "" then - Parse_error.should_not_be_empty ~what:(Token.describe token) location - |> add_warning input; - - junk input; - let block = accepted_in_all_contexts context token in - let block = Loc.at location block in - let acc = block :: acc in - consume_block_elements ~parsed_a_tag `After_text acc - | { value = `Math_block s as token; location } as next_token -> - warn_if_after_tags next_token; - warn_if_after_text next_token; - if s = "" then - Parse_error.should_not_be_empty ~what:(Token.describe token) location - |> add_warning input; - - junk input; - let block = accepted_in_all_contexts context token in - let block = Loc.at location block in - let acc = block :: acc in - consume_block_elements ~parsed_a_tag `After_text acc - | { - value = - `Code_block (meta, delim, { value = s; location = v_loc }, has_outputs) - as token; - location; - } as next_token -> - warn_if_after_tags next_token; - warn_if_after_text next_token; - junk input; - let delimiter = if delim = "" then None else Some delim in - let output, location = - if not has_outputs then (None, location) - else - let content, next_token, _where_in_line = - block_element_list In_code_results ~parent_markup:token input - in - junk input; - let locations = - location :: List.map (fun content -> content.Loc.location) content - in - let location = Loc.span locations in - let location = { location with end_ = next_token.location.end_ } in - (Some content, location) - in - - if s = "" then - Parse_error.should_not_be_empty ~what:(Token.describe token) location - |> add_warning input; - - let meta = - match meta with - | None -> None - | Some (language, tags) -> Some { Ast.language; tags } - in - let block = - accepted_in_all_contexts context - (`Code_block - { - Ast.meta; - delimiter; - content = { value = s; location = v_loc }; - output; - }) - in - let block = Loc.at location block in - let acc = block :: acc in - consume_block_elements ~parsed_a_tag `After_text acc - | { value = `Modules s as token; location } as next_token -> - warn_if_after_tags next_token; - warn_if_after_text next_token; - - junk input; - - (* TODO Use some library for a splitting function, or move this out into a - Util module. *) - let split_string delimiters s = - let rec scan_delimiters acc index = - if index >= String.length s then List.rev acc - else if String.contains delimiters s.[index] then - scan_delimiters acc (index + 1) - else scan_word acc index (index + 1) - and scan_word acc start_index index = - if index >= String.length s then - let word = String.sub s start_index (index - start_index) in - List.rev (word :: acc) - else if String.contains delimiters s.[index] then - let word = String.sub s start_index (index - start_index) in - scan_delimiters (word :: acc) (index + 1) - else scan_word acc start_index (index + 1) - in - - scan_delimiters [] 0 - in - - (* TODO Correct locations await a full implementation of {!modules} - parsing. *) - let modules = - split_string " \t\r\n" s |> List.map (fun r -> Loc.at location r) - in - - if modules = [] then - Parse_error.should_not_be_empty ~what:(Token.describe token) location - |> add_warning input; - - let block = accepted_in_all_contexts context (`Modules modules) in - let block = Loc.at location block in - let acc = block :: acc in - consume_block_elements ~parsed_a_tag `After_text acc - | { value = `Begin_list kind as token; location } as next_token -> - warn_if_after_tags next_token; - warn_if_after_text next_token; - - junk input; - - let items, brace_location = - explicit_list_items ~parent_markup:token input - in - if items = [] then - Parse_error.should_not_be_empty ~what:(Token.describe token) location - |> add_warning input; - - let location = Loc.span [ location; brace_location ] in - let block = `List (kind, `Heavy, items) in - let block = accepted_in_all_contexts context block in - let block = Loc.at location block in - let acc = block :: acc in - consume_block_elements ~parsed_a_tag `After_text acc - | { value = (`Begin_table_light | `Begin_table_heavy) as token; location } - as next_token -> - warn_if_after_tags next_token; - warn_if_after_text next_token; - junk input; - let block, brace_location = - let parent_markup = token in - let parent_markup_location = location in - match token with - | `Begin_table_light -> - light_table input ~parent_markup ~parent_markup_location - | `Begin_table_heavy -> - heavy_table input ~parent_markup ~parent_markup_location - in - let location = Loc.span [ location; brace_location ] in - let block = accepted_in_all_contexts context (`Table block) in - let block = Loc.at location block in - let acc = block :: acc in - consume_block_elements ~parsed_a_tag `After_text acc - | { value = (`Minus | `Plus) as token; location } as next_token -> ( - (match where_in_line with - | `After_text | `After_shorthand_bullet -> - Parse_error.should_begin_on_its_own_line - ~what:(Token.describe token) location - |> add_warning input - | _ -> ()); - - warn_if_after_tags next_token; - - match context with - | In_shorthand_list -> (List.rev acc, next_token, where_in_line) - | _ -> - let items, where_in_line = - shorthand_list_items next_token where_in_line input - in - let kind = - match token with `Minus -> `Unordered | `Plus -> `Ordered - in - let location = - location :: List.map Loc.location (List.flatten items) |> Loc.span - in - let block = `List (kind, `Light, items) in - let block = accepted_in_all_contexts context block in - let block = Loc.at location block in - let acc = block :: acc in - consume_block_elements ~parsed_a_tag where_in_line acc) - | { value = `Begin_section_heading (level, label) as token; location } as - next_token -> ( - warn_if_after_tags next_token; - - let recover_when_not_at_top_level context = - warn_because_not_at_top_level next_token; - junk input; - let content, brace_location = - delimited_inline_element_list ~parent_markup:token - ~parent_markup_location:location ~requires_leading_whitespace:true - input - in - let location = Loc.span [ location; brace_location ] in - let paragraph = - `Paragraph content - |> accepted_in_all_contexts context - |> Loc.at location - in - consume_block_elements ~parsed_a_tag `At_start_of_line - (paragraph :: acc) - in - - match context with - | In_shorthand_list -> - if where_in_line = `At_start_of_line then - (List.rev acc, next_token, where_in_line) - else recover_when_not_at_top_level context - | In_explicit_list -> recover_when_not_at_top_level context - | In_table_cell -> recover_when_not_at_top_level context - | In_tag -> recover_when_not_at_top_level context - | In_code_results -> recover_when_not_at_top_level context - | Top_level -> - if where_in_line <> `At_start_of_line then - Parse_error.should_begin_on_its_own_line - ~what:(Token.describe token) location - |> add_warning input; - - let label = - match label with - | Some "" -> - Parse_error.should_not_be_empty ~what:"heading label" location - |> add_warning input; - None - | _ -> label - in - - junk input; - - let content, brace_location = - delimited_inline_element_list ~parent_markup:token - ~parent_markup_location:location - ~requires_leading_whitespace:true input - in - if content = [] then - Parse_error.should_not_be_empty ~what:(Token.describe token) - location - |> add_warning input; - - let location = Loc.span [ location; brace_location ] in - let heading = `Heading (level, label, content) in - let heading = Loc.at location heading in - let acc = heading :: acc in - consume_block_elements ~parsed_a_tag `After_text acc) - | { value = `Begin_paragraph_style _ as token; location } -> - junk input; - let content, brace_location = - delimited_inline_element_list ~parent_markup:token - ~parent_markup_location:location ~requires_leading_whitespace:true - input - in - let location = Loc.span [ location; brace_location ] in - - Parse_error.markup_should_not_be_used ~what:(Token.describe token) - location - |> add_warning input; - - let paragraph = - `Paragraph content - |> accepted_in_all_contexts context - |> Loc.at location - in - consume_block_elements ~parsed_a_tag `At_start_of_line (paragraph :: acc) - in - - let where_in_line = - match context with - | Top_level -> `At_start_of_line - | In_shorthand_list -> `After_shorthand_bullet - | In_explicit_list -> `After_explicit_list_bullet - | In_table_cell -> `After_table_cell - | In_code_results -> `After_tag - | In_tag -> `After_tag - in - - consume_block_elements ~parsed_a_tag:false where_in_line [] - -(* {3 Lists} *) - -(* Consumes a sequence of implicit list items. Each one consists of a [`Minus] - or [`Plus] token, followed by block elements until: - - - a blank line, or - - a list bullet of the opposite kind (e.g. [`Plus] for a [`Minus] list). - - This function is called when the next token is known to be [`Minus] or - [`Plus]. It consumes that token, and calls the block element parser (see - above). That parser returns to [implicit_list_items] only on [`Blank_line], - [`End], [`Minus] or [`Plus] at the start of a line, or [`Right_brace]. *) -and shorthand_list_items : - [ `Minus | `Plus ] with_location -> - where_in_line -> - input -> - Ast.nestable_block_element with_location list list * where_in_line = - fun first_token where_in_line input -> - let bullet_token = first_token.value in - - let rec consume_list_items : - [> ] with_location -> - where_in_line -> - Ast.nestable_block_element with_location list list -> - Ast.nestable_block_element with_location list list * where_in_line = - fun next_token where_in_line acc -> - match next_token.value with - | `End | `Right_brace | `Blank_line _ | `Tag _ | `Begin_section_heading _ -> - (List.rev acc, where_in_line) - | (`Minus | `Plus) as bullet -> - if bullet = bullet_token then ( - junk input; - - let content, stream_head, where_in_line = - block_element_list In_shorthand_list ~parent_markup:bullet input - in - if content = [] then - Parse_error.should_not_be_empty ~what:(Token.describe bullet) - next_token.location - |> add_warning input; - - let acc = content :: acc in - consume_list_items stream_head where_in_line acc) - else (List.rev acc, where_in_line) - in - - consume_list_items - (first_token :> stopped_implicitly with_location) - where_in_line [] - -(* Consumes a sequence of explicit list items (starting with '{li ...}' and - '{-...}', which are represented by [`Begin_list_item _] tokens). - - This function is called immediately after '{ul' or '{ol' ([`Begin_list _]) is - read. The only "valid" way to exit is by reading a [`Right_brace] token, - which is consumed. - - Whitespace inside the list, but outside list items, is not significant – this - parsing function consumes all of it. Otherwise, only list item start tokens - are accepted. Everything else is an error. *) -and explicit_list_items : - parent_markup:[< Token.t ] -> - input -> - Ast.nestable_block_element with_location list list * Loc.span = - fun ~parent_markup input -> - let rec consume_list_items : - Ast.nestable_block_element with_location list list -> - Ast.nestable_block_element with_location list list * Loc.span = - fun acc -> - let next_token = peek input in - match next_token.value with - | `End -> - Parse_error.not_allowed next_token.location ~what:(Token.describe `End) - ~in_what:(Token.describe parent_markup) - |> add_warning input; - (List.rev acc, next_token.location) - | `Right_brace -> - junk input; - (List.rev acc, next_token.location) - | `Space _ | `Single_newline _ | `Blank_line _ -> - junk input; - consume_list_items acc - | `Begin_list_item kind as token -> - junk input; - - (* '{li', represented by [`Begin_list_item `Li], must be followed by - whitespace. *) - (if kind = `Li then - match (peek input).value with - | `Space _ | `Single_newline _ | `Blank_line _ | `Right_brace -> - () - (* The presence of [`Right_brace] above requires some explanation: - - - It is better to be silent about missing whitespace if the next - token is [`Right_brace], because the error about an empty list - item will be generated below, and that error is more important to - the user. - - The [`Right_brace] token also happens to include all whitespace - before it, as a convenience for the rest of the parser. As a - result, not ignoring it could be wrong: there could in fact be - whitespace in the concrete syntax immediately after '{li', just - it is not represented as [`Space], [`Single_newline], or - [`Blank_line]. *) - | _ -> - Parse_error.should_be_followed_by_whitespace next_token.location - ~what:(Token.print token) - |> add_warning input); - - let content, token_after_list_item, _where_in_line = - block_element_list In_explicit_list ~parent_markup:token input - in - - if content = [] then - Parse_error.should_not_be_empty next_token.location - ~what:(Token.describe token) - |> add_warning input; - - (match token_after_list_item.value with - | `Right_brace -> junk input - | `End -> - Parse_error.not_allowed token_after_list_item.location - ~what:(Token.describe `End) ~in_what:(Token.describe token) - |> add_warning input); - - let acc = content :: acc in - consume_list_items acc - | token -> - let suggestion = - match token with - | `Begin_section_heading _ | `Tag _ -> - Printf.sprintf "move %s outside the list." (Token.describe token) - | _ -> - Printf.sprintf "move %s into a list item, %s or %s." - (Token.describe token) - (Token.print (`Begin_list_item `Li)) - (Token.print (`Begin_list_item `Dash)) - in - Parse_error.not_allowed next_token.location ~what:(Token.describe token) - ~in_what:(Token.describe parent_markup) - ~suggestion - |> add_warning input; - - junk input; - consume_list_items acc - in - - consume_list_items [] - -(* Consumes a sequence of table rows that might start with [`Bar]. - - This function is called immediately after '{t' ([`Begin_table `Light]) is - read. The only "valid" way to exit is by reading a [`Right_brace] token, - which is consumed. *) -and light_table ~parent_markup ~parent_markup_location input = - let rec consume_rows acc ~last_loc = - Reader.until_rbrace input acc >>> fun next_token -> - match next_token.Loc.value with - | `Bar | #token_that_always_begins_an_inline_element -> ( - let next, row, last_loc = - light_table_row ~parent_markup ~last_loc input - in - match next with - | `Continue -> consume_rows (row :: acc) ~last_loc - | `Stop -> (row :: acc, last_loc)) - | other_token -> - Parse_error.not_allowed next_token.location - ~what:(Token.describe other_token) - ~in_what:(Token.describe parent_markup) - |> add_warning input; - junk input; - consume_rows acc ~last_loc - in - let rows, brace_location = consume_rows [] ~last_loc:parent_markup_location in - let grid = List.rev rows in - (Table.Light_syntax.from_raw_data grid, brace_location) - -(* Consumes a table row that might start with [`Bar]. *) -and light_table_row ~parent_markup ~last_loc input = - let rec consume_row acc_row acc_cell acc_space ~new_line ~last_loc = - let push_cells row cell = - match cell with [] -> row | _ -> List.rev cell :: row - in - let return row cell = List.rev (push_cells row cell) in - let next_token = peek input in - match next_token.value with - | `Right_brace -> - junk input; - (`Stop, return acc_row acc_cell, next_token.location) - | `Space _ as token -> - junk input; - let i = Loc.at next_token.location token in - consume_row acc_row acc_cell (i :: acc_space) ~new_line ~last_loc - | `Single_newline _ | `Blank_line _ -> - junk input; - (`Continue, return acc_row acc_cell, last_loc) - | `Bar -> - junk input; - let acc_row = if new_line then [] else List.rev acc_cell :: acc_row in - consume_row acc_row [] [] ~new_line:false ~last_loc - | #token_that_always_begins_an_inline_element as token -> - let i = inline_element input next_token.location token in - if Loc.spans_multiple_lines i then - Parse_error.not_allowed - ~what:(Token.describe (`Single_newline "")) - ~in_what:(Token.describe `Begin_table_light) - i.location - |> add_warning input; - let acc_cell = - if acc_cell = [] then [ i ] else (i :: acc_space) @ acc_cell - in - consume_row acc_row acc_cell [] ~new_line:false - ~last_loc:next_token.location - | other_token -> - Parse_error.not_allowed next_token.location - ~what:(Token.describe other_token) - ~in_what:(Token.describe parent_markup) - |> add_warning input; - junk input; - consume_row acc_row acc_cell acc_space ~new_line ~last_loc - in - consume_row [] [] [] ~new_line:true ~last_loc - -(* Consumes a sequence of table rows (starting with '{tr ...}', which are - represented by [`Begin_table_row] tokens). - - This function is called immediately after '{table' ([`Begin_table `Heavy]) is - read. The only "valid" way to exit is by reading a [`Right_brace] token, - which is consumed. *) -and heavy_table ~parent_markup ~parent_markup_location input = - let rec consume_rows acc ~last_loc = - Reader.until_rbrace input acc >>> fun next_token -> - match next_token.Loc.value with - | `Begin_table_row as token -> - junk input; - let items, last_loc = heavy_table_row ~parent_markup:token input in - consume_rows (List.rev items :: acc) ~last_loc - | token -> - Parse_error.not_allowed next_token.location ~what:(Token.describe token) - ~in_what:(Token.describe parent_markup) - ~suggestion:"Move outside of {table ...}, or inside {tr ...}" - |> add_warning input; - junk input; - consume_rows acc ~last_loc - in - let rows, brace_location = consume_rows [] ~last_loc:parent_markup_location in - let grid = List.rev rows in - (Table.Heavy_syntax.from_grid grid, brace_location) - -(* Consumes a sequence of table cells (starting with '{th ...}' or '{td ... }', - which are represented by [`Begin_table_cell] tokens). - - This function is called immediately after '{tr' ([`Begin_table_row]) is - read. The only "valid" way to exit is by reading a [`Right_brace] token, - which is consumed. *) -and heavy_table_row ~parent_markup input = - let rec consume_cell_items acc = - Reader.until_rbrace input acc >>> fun next_token -> - match next_token.Loc.value with - | `Begin_table_cell kind as token -> - junk input; - let content, token_after_list_item, _where_in_line = - block_element_list In_table_cell ~parent_markup:token input - in - (match token_after_list_item.value with - | `Right_brace -> junk input - | `End -> - Parse_error.not_allowed token_after_list_item.location - ~what:(Token.describe `End) ~in_what:(Token.describe token) - |> add_warning input); - consume_cell_items ((content, kind) :: acc) - | token -> - Parse_error.not_allowed next_token.location ~what:(Token.describe token) - ~in_what:(Token.describe parent_markup) - ~suggestion: - "Move outside of {table ...}, or inside {td ...} or {th ...}" - |> add_warning input; - junk input; - consume_cell_items acc - in - consume_cell_items [] - -(* {2 Entry point} *) - -let parse warnings tokens = - let input : input = { tokens; warnings } in - - let rec parse_block_elements () = - let elements, last_token, _where_in_line = - block_element_list Top_level ~parent_markup:`Comment input - in - - match last_token.value with - | `End -> elements - | `Right_brace -> - Parse_error.unpaired_right_brace last_token.location - |> add_warning input; - - let block = - Loc.same last_token (`Paragraph [ Loc.same last_token (`Word "}") ]) - in - - junk input; - elements @ (block :: parse_block_elements ()) - in - let ast = parse_block_elements () in - (ast, List.rev !(input.warnings)) diff --git a/vendor/odoc-parser/src/syntax.mli b/vendor/odoc-parser/src/syntax.mli deleted file mode 100644 index a40b69841..000000000 --- a/vendor/odoc-parser/src/syntax.mli +++ /dev/null @@ -1,6 +0,0 @@ -(* Internal module, not exposed *) - -val parse : - Warning.t list ref -> - Token.t Loc.with_location Stream.t -> - Ast.t * Warning.t list diff --git a/vendor/odoc-parser/src/token.ml b/vendor/odoc-parser/src/token.ml deleted file mode 100644 index 83181fe45..000000000 --- a/vendor/odoc-parser/src/token.ml +++ /dev/null @@ -1,194 +0,0 @@ -(* This module contains the token type, emitted by the lexer, and consumed by - the comment syntax parser. It also contains two functions that format tokens - for error messages. *) - -type section_heading = [ `Begin_section_heading of int * string option ] -type style = [ `Bold | `Italic | `Emphasis | `Superscript | `Subscript ] -type paragraph_style = [ `Left | `Center | `Right ] - -type tag = - [ `Tag of - [ `Author of string - | `Deprecated - | `Param of string - | `Raise of string - | `Return - | `See of [ `Url | `File | `Document ] * string - | `Since of string - | `Before of string - | `Version of string - | `Canonical of string - | `Inline - | `Open - | `Closed - | `Hidden ] ] - -type t = - [ (* End of input. *) - `End - | (* Runs of whitespace. [Blank_line] is any run of whitespace that contains two - or more newline characters. [Single_newline] is any run of whitespace that - contains exactly one newline character. [Space] is any run of whitespace - that contains no newline characters. - - It is an important invariant in the parser that no adjacent whitespace - tokens are emitted by the lexer. Otherwise, there would be the need for - unbounded lookahead, a (co-?)ambiguity between - [Single_newline Single_newline] and [Blank_line], and other problems. *) - `Space of - string - | `Single_newline of string - | `Blank_line of string - | (* A right curly brace ([}]), i.e. end of markup. *) - `Right_brace - | `Right_code_delimiter - | (* Words are anything that is not whitespace or markup. Markup symbols can be - be part of words if escaped. - - Words can contain plus and minus symbols, but those are emitted as [Plus] - and [Minus] tokens. The parser combines plus and minus into words, except - when they appear first on a line, in which case the tokens are list item - bullets. *) - `Word of - string - | `Code_span of string - | `Raw_markup of string option * string - | `Math_span of string - | `Math_block of string - | `Begin_style of style - | `Begin_paragraph_style of paragraph_style - | (* Other inline element markup. *) - `Simple_reference of string - | `Begin_reference_with_replacement_text of string - | `Simple_link of string - | `Begin_link_with_replacement_text of string - | (* Leaf block element markup. *) - `Code_block of - (string Loc.with_location * string Loc.with_location option) option - * string - * string Loc.with_location - * bool - | `Verbatim of string - | `Modules of string - | (* List markup. *) - `Begin_list of [ `Unordered | `Ordered ] - | `Begin_list_item of [ `Li | `Dash ] - | (* Table markup. *) - `Begin_table_light - | `Begin_table_heavy - | `Begin_table_row - | `Begin_table_cell of [ `Header | `Data ] - | `Minus - | `Plus - | `Bar - | section_heading - | tag ] - -let print : [< t ] -> string = function - | `Begin_paragraph_style `Left -> "'{L'" - | `Begin_paragraph_style `Center -> "'{C'" - | `Begin_paragraph_style `Right -> "'{R'" - | `Begin_style `Bold -> "'{b'" - | `Begin_style `Italic -> "'{i'" - | `Begin_style `Emphasis -> "'{e'" - | `Begin_style `Superscript -> "'{^'" - | `Begin_style `Subscript -> "'{_'" - | `Begin_reference_with_replacement_text _ -> "'{{!'" - | `Begin_link_with_replacement_text _ -> "'{{:'" - | `Begin_list_item `Li -> "'{li ...}'" - | `Begin_list_item `Dash -> "'{- ...}'" - | `Begin_table_light -> "{t" - | `Begin_table_heavy -> "{table" - | `Begin_table_row -> "'{tr'" - | `Begin_table_cell `Header -> "'{th'" - | `Begin_table_cell `Data -> "'{td'" - | `Minus -> "'-'" - | `Plus -> "'+'" - | `Bar -> "'|'" - | `Begin_section_heading (level, label) -> - let label = match label with None -> "" | Some label -> ":" ^ label in - Printf.sprintf "'{%i%s'" level label - | `Tag (`Author _) -> "'@author'" - | `Tag `Deprecated -> "'@deprecated'" - | `Tag (`Param _) -> "'@param'" - | `Tag (`Raise _) -> "'@raise'" - | `Tag `Return -> "'@return'" - | `Tag (`See _) -> "'@see'" - | `Tag (`Since _) -> "'@since'" - | `Tag (`Before _) -> "'@before'" - | `Tag (`Version _) -> "'@version'" - | `Tag (`Canonical _) -> "'@canonical'" - | `Tag `Inline -> "'@inline'" - | `Tag `Open -> "'@open'" - | `Tag `Closed -> "'@closed'" - | `Tag `Hidden -> "'@hidden" - | `Raw_markup (None, _) -> "'{%...%}'" - | `Raw_markup (Some target, _) -> "'{%" ^ target ^ ":...%}'" - -(* [`Minus] and [`Plus] are interpreted as if they start list items. Therefore, - for error messages based on [Token.describe] to be accurate, formatted - [`Minus] and [`Plus] should always be plausibly list item bullets. *) -let describe : [< t | `Comment ] -> string = function - | `Word w -> Printf.sprintf "'%s'" w - | `Code_span _ -> "'[...]' (code)" - | `Raw_markup _ -> "'{%...%}' (raw markup)" - | `Begin_paragraph_style `Left -> "'{L ...}' (left alignment)" - | `Begin_paragraph_style `Center -> "'{C ...}' (center alignment)" - | `Begin_paragraph_style `Right -> "'{R ...}' (right alignment)" - | `Begin_style `Bold -> "'{b ...}' (boldface text)" - | `Begin_style `Italic -> "'{i ...}' (italic text)" - | `Begin_style `Emphasis -> "'{e ...}' (emphasized text)" - | `Begin_style `Superscript -> "'{^...}' (superscript)" - | `Begin_style `Subscript -> "'{_...}' (subscript)" - | `Math_span _ -> "'{m ...}' (math span)" - | `Math_block _ -> "'{math ...}' (math block)" - | `Simple_reference _ -> "'{!...}' (cross-reference)" - | `Begin_reference_with_replacement_text _ -> - "'{{!...} ...}' (cross-reference)" - | `Simple_link _ -> "'{:...} (external link)'" - | `Begin_link_with_replacement_text _ -> "'{{:...} ...}' (external link)" - | `End -> "end of text" - | `Space _ -> "whitespace" - | `Single_newline _ -> "line break" - | `Blank_line _ -> "blank line" - | `Right_brace -> "'}'" - | `Right_code_delimiter -> "']}'" - | `Code_block _ -> "'{[...]}' (code block)" - | `Verbatim _ -> "'{v ... v}' (verbatim text)" - | `Modules _ -> "'{!modules ...}'" - | `Begin_list `Unordered -> "'{ul ...}' (bulleted list)" - | `Begin_list `Ordered -> "'{ol ...}' (numbered list)" - | `Begin_list_item `Li -> "'{li ...}' (list item)" - | `Begin_list_item `Dash -> "'{- ...}' (list item)" - | `Begin_table_light -> "'{t ...}' (table)" - | `Begin_table_heavy -> "'{table ...}' (table)" - | `Begin_table_row -> "'{tr ...}' (table row)" - | `Begin_table_cell `Header -> "'{th ... }' (table header cell)" - | `Begin_table_cell `Data -> "'{td ... }' (table data cell)" - | `Minus -> "'-' (bulleted list item)" - | `Plus -> "'+' (numbered list item)" - | `Bar -> "'|'" - | `Begin_section_heading (level, _) -> - Printf.sprintf "'{%i ...}' (section heading)" level - | `Tag (`Author _) -> "'@author'" - | `Tag `Deprecated -> "'@deprecated'" - | `Tag (`Param _) -> "'@param'" - | `Tag (`Raise _) -> "'@raise'" - | `Tag `Return -> "'@return'" - | `Tag (`See _) -> "'@see'" - | `Tag (`Since _) -> "'@since'" - | `Tag (`Before _) -> "'@before'" - | `Tag (`Version _) -> "'@version'" - | `Tag (`Canonical _) -> "'@canonical'" - | `Tag `Inline -> "'@inline'" - | `Tag `Open -> "'@open'" - | `Tag `Closed -> "'@closed'" - | `Tag `Hidden -> "'@hidden" - | `Comment -> "top-level text" - -let describe_element = function - | `Reference (`Simple, _, _) -> describe (`Simple_reference "") - | `Reference (`With_text, _, _) -> - describe (`Begin_reference_with_replacement_text "") - | `Link _ -> describe (`Begin_link_with_replacement_text "") - | `Heading (level, _, _) -> describe (`Begin_section_heading (level, None)) diff --git a/vendor/odoc-parser/src/warning.ml b/vendor/odoc-parser/src/warning.ml deleted file mode 100644 index 61dd987f8..000000000 --- a/vendor/odoc-parser/src/warning.ml +++ /dev/null @@ -1,29 +0,0 @@ -type t = { location : Loc.span; message : string } - -let to_string e = - let { location; message } = e in - let location_string = - if location.start.line = location.end_.line then - Printf.sprintf "line %i, characters %i-%i" location.start.line - location.start.column location.end_.column - else - Printf.sprintf "line %i, character %i to line %i, character %i" - location.start.line location.start.column location.end_.line - location.end_.column - in - Printf.sprintf "File \"%s\", %s:\n%s" location.file location_string message - -let pp fmt v = Format.fprintf fmt "%s" (to_string v) - -let kasprintf k fmt = - Format.(kfprintf (fun _ -> k (flush_str_formatter ())) str_formatter fmt) - -let kmake k ?suggestion = - kasprintf (fun message -> - match suggestion with - | None -> k message - | Some suggestion -> k (message ^ "\nSuggestion: " ^ suggestion)) - -let make ?suggestion format = - let k message location = { location; message } in - kmake k ?suggestion format diff --git a/vendor/update-odoc-parser.sh b/vendor/update-odoc-parser.sh deleted file mode 100755 index 364dcfa61..000000000 --- a/vendor/update-odoc-parser.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -version=v2.3.0 - -set -e -o pipefail - -TMP="$(mktemp -d)" -trap "rm -rf $TMP" EXIT - -rm -rf odoc-parser -mkdir -p odoc-parser/src - -( - cd $TMP - git clone https://github.com/ocaml/odoc.git - cd odoc - git checkout $version -) - -SRC=$TMP/odoc - -cp -v $SRC/src/parser/*.{ml,mli,mll} odoc-parser/src -cp -v $SRC/LICENSE odoc-parser/ - -git checkout odoc-parser/src/dune -git add -A .