forked from ocaml/ocaml-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use correct file permissions for preprocessing (ocaml#1153)
from jboillot/bugfix/ocamllsp-pp-output-file-creation
- Loading branch information
Showing
6 changed files
with
106 additions
and
5 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
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
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
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 @@ | ||
type world |
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,2 @@ | ||
#!/bin/sh | ||
sed 's/world/universe/g' $1 |
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,71 @@ | ||
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 } | ||
} | ||
}|}] |