-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
open Test.Import | ||
|
||
let%expect_test "uri" = | ||
let notif_received = Fiber.Ivar.create () in | ||
let handler = | ||
let on_notification _ (notification : Lsp.Server_notification.t) = | ||
(match notification with | ||
| PublishDiagnostics d -> | ||
print_endline "client: received publish diagnostics notification"; | ||
Printf.printf "uri received from the server: %s\n" (d.uri |> DocumentUri.to_string) | ||
| ShowMessage _ | ||
| LogMessage _ | ||
| TelemetryNotification _ | ||
| CancelRequest _ | ||
| WorkDoneProgress _ | ||
| UnknownNotification _ -> ()); | ||
let* () = Fiber.Ivar.fill notif_received () in | ||
Fiber.return () | ||
in | ||
Client.Handler.make ~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 uri = DocumentUri.of_path "src/néw/Mödel + Other Thîngß/test.ml" in | ||
Printf.printf "uri sent to the server: %s\n" (DocumentUri.to_string uri); | ||
let textDocument = | ||
TextDocumentItem.create ~uri ~languageId:"ocaml" ~text:"" ~version:0 | ||
in | ||
let params = DidOpenTextDocumentParams.create ~textDocument in | ||
let* () = Client.notification client (TextDocumentDidOpen params) in | ||
Fiber.Ivar.read notif_received | ||
in | ||
Fiber.fork_and_join_unit run_client (fun () -> run >>> Client.stop client) | ||
); | ||
[%expect | ||
{| | ||
uri sent to the server: file:///src/néw/Mödel + Other Thîngß/test.ml | ||
client: received publish diagnostics notification | ||
uri received from the server: file:///src/néw/Mödel + Other Thîngß/test.ml |}] |