diff --git a/CHANGES.md b/CHANGES.md index 81a1d3cf0..6de67cd66 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ - Support folding of `ifthenelse` expressions (#1031) -- Add `duneContexts` method and `--context` flag (#1238) +- Add `--context` flag (#1238) ## Fixes diff --git a/ocaml-lsp-server/docs/ocamllsp/duneContexts-spec.md b/ocaml-lsp-server/docs/ocamllsp/duneContexts-spec.md deleted file mode 100644 index 3ca5b0284..000000000 --- a/ocaml-lsp-server/docs/ocamllsp/duneContexts-spec.md +++ /dev/null @@ -1,26 +0,0 @@ -# Dune Contexts Request - -Dune Contexts Request is sent from the client to the server to get the list -of contexts available in the current Dune workspace. - -Warning: this custom request is meant to be consumed by `ocaml-vscode-platform` exclusively, -it can be removed any time and should not be relied on. - -## Client capability - -nothing that should be noted - -## Server capability - -property name: `handleDuneContexts` -property type: `boolean` - -## Request - -- method: `ocamllsp/duneContexts` -- params: none - -## Response - -- result: String[] -- error: code and message set in case an exception happens during the processing of the request. diff --git a/ocaml-lsp-server/src/custom_requests/req_dune_contexts.ml b/ocaml-lsp-server/src/custom_requests/req_dune_contexts.ml deleted file mode 100644 index c6f0588de..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_dune_contexts.ml +++ /dev/null @@ -1,49 +0,0 @@ -open Import - -let capability = ("handleDuneContexts", `Bool true) - -let meth = "ocamllsp/duneContexts" - -let on_request () = - match Bin.which "dune" with - | None -> - Jsonrpc.Response.Error.raise - (Jsonrpc.Response.Error.make - ~code:InternalError - ~message:"dune binary not found" - ()) - | Some dune -> ( - let describe = - "DUNE_CONFIG__GLOBAL_LOCK=disabled " ^ Fpath.to_string dune - ^ " describe contexts" - in - let temp_file = Filename.temp_file "req_dune_contexts" ".txt" in - let command = Printf.sprintf "%s > %s" describe temp_file in - let error ~data = - Jsonrpc.Response.Error.raise - (Jsonrpc.Response.Error.make - ~code:InternalError - ~message:"Execution of `dune describe contexts` failed" - ~data - ()) - in - - try - let exit_status = Sys.command command in - if exit_status = 0 then ( - let ic = open_in temp_file in - let rec read_lines acc = - try - let line = input_line ic in - read_lines (line :: acc) - with End_of_file -> List.rev acc - in - let lines = read_lines [] in - close_in ic; - Sys.remove temp_file; - Json.yojson_of_list (fun line -> `String line) lines) - else error ~data:(`Assoc [ ("exitStatus", `Int exit_status) ]) - with - | Sys_error msg -> error ~data:(`Assoc [ ("systemError", `String msg) ]) - | Failure msg -> error ~data:(`Assoc [ ("Failure", `String msg) ]) - | _ -> error ~data:(`String "Unknown error")) diff --git a/ocaml-lsp-server/src/custom_requests/req_dune_contexts.mli b/ocaml-lsp-server/src/custom_requests/req_dune_contexts.mli deleted file mode 100644 index b919a08bf..000000000 --- a/ocaml-lsp-server/src/custom_requests/req_dune_contexts.mli +++ /dev/null @@ -1,7 +0,0 @@ -open Import - -val capability : string * Json.t - -val meth : string - -val on_request : unit -> Json.t diff --git a/ocaml-lsp-server/src/ocaml_lsp_server.ml b/ocaml-lsp-server/src/ocaml_lsp_server.ml index e71d7f814..5ebe5a64b 100644 --- a/ocaml-lsp-server/src/ocaml_lsp_server.ml +++ b/ocaml-lsp-server/src/ocaml_lsp_server.ml @@ -98,7 +98,6 @@ let initialize_info (client_capabilities : ClientCapabilities.t) : ; Req_wrapping_ast_node.capability ; Dune.view_promotion_capability ; Req_hover_extended.capability - ; Req_dune_contexts.capability ] ) ] in @@ -511,10 +510,6 @@ let on_request : , Semantic_highlighting.Debug.on_request_full ) ; ( Req_hover_extended.meth , fun ~params _ -> Req_hover_extended.on_request ~params rpc ) - ; ( Req_dune_contexts.meth - , fun ~params:_ _ -> - Fiber.of_thunk (fun () -> - Fiber.return (Req_dune_contexts.on_request ())) ) ] |> List.assoc_opt meth with diff --git a/ocaml-lsp-server/test/e2e-new/start_stop.ml b/ocaml-lsp-server/test/e2e-new/start_stop.ml index 75efbb092..c9f822580 100644 --- a/ocaml-lsp-server/test/e2e-new/start_stop.ml +++ b/ocaml-lsp-server/test/e2e-new/start_stop.ml @@ -90,8 +90,7 @@ let%expect_test "start/stop" = "handleTypedHoles": true, "handleWrappingAstNode": true, "diagnostic_promotions": true, - "handleHoverExtended": true, - "handleDuneContexts": true + "handleHoverExtended": true } }, "foldingRangeProvider": true,