Skip to content

Commit

Permalink
_
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed May 17, 2024
1 parent f4f5130 commit e6d68e1
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 10 deletions.
5 changes: 4 additions & 1 deletion ocaml-lsp-server/src/custom_requests/req_typed_holes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ let on_request ~(params : Jsonrpc.Structured.t option) (state : State.t) =
()
| Some doc ->
let+ holes =
Document.Merlin.dispatch_exn ~name:"typed-holes" (Document.merlin_exn doc) Holes
Document.Merlin.dispatch_exn
~name:"typed-holes"
(Document.merlin_exn doc)
Holes
in
Json.yojson_of_list
(fun (loc, _type) -> loc |> Range.of_loc |> Range.yojson_of_t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ 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
~name:"wrapping-ast-node"
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 *) =
Expand Down
6 changes: 3 additions & 3 deletions ocaml-lsp-server/src/definition_query.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ let run kind (state : State.t) uri position =
let command, name =
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), "definition")
| `Declaration -> (Query_protocol.Locate (None, `MLI, pos), "declaration")
| `Type_definition -> (Query_protocol.Locate_type pos, "type definition")
in
let* result = Document.Merlin.dispatch_exn ~name doc command in
match location_of_merlin_loc uri result with
Expand Down
3 changes: 2 additions & 1 deletion ocaml-lsp-server/src/document.ml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ module Merlin = struct
| Error exn -> Exn_with_backtrace.reraise exn

let dispatch ?name t command =
with_pipeline ?name t (fun pipeline -> Query_commands.dispatch pipeline command)
with_pipeline ?name t (fun pipeline ->
Query_commands.dispatch pipeline command)

let dispatch_exn ?name t command =
with_pipeline_exn ?name t (fun pipeline ->
Expand Down
3 changes: 2 additions & 1 deletion ocaml-lsp-server/src/document.mli
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ module Merlin : sig
?name:string
-> t
-> Msource.position
-> (* doc string *) string option Fiber.t
-> (* doc string *)
string option Fiber.t

val syntax_doc :
Mpipeline.t -> Msource.position -> Query_protocol.syntax_doc_result option
Expand Down
5 changes: 4 additions & 1 deletion ocaml-lsp-server/src/inference.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ let infer_intf_for_impl doc =
"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
~name:"infer-interface"
doc
(fun pipeline ->
let typer = Mpipeline.typer_result pipeline in
let sig_ : Types.signature =
let typedtree = Mtyper.get_typedtree typer in
Expand Down
5 changes: 4 additions & 1 deletion ocaml-lsp-server/src/ocaml_lsp_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ let selection_range (state : State.t)
let+ ranges =
Fiber.sequential_map positions ~f:(fun x ->
let+ shapes =
Document.Merlin.dispatch_exn ~name:"shape" merlin (Shape (Position.logical x))
Document.Merlin.dispatch_exn
~name:"shape"
merlin
(Shape (Position.logical x))
in
selection_range_of_shapes x shapes)
in
Expand Down
5 changes: 4 additions & 1 deletion ocaml-lsp-server/src/signature_help.ml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ let run (state : State.t)
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
~name:"signature-help"
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
Expand Down

0 comments on commit e6d68e1

Please sign in to comment.