Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- Support for `class`, `class type`, `method` and `property` for `DocumentSymbol` query (#1487 fixes #1449)
- Fix `inlay-hint` for function parameters (#1515)
- More precise diagnostics in the event of a failed identifier search (`Definition_query`) (#1518)

# 1.22.0

Expand Down
14 changes: 7 additions & 7 deletions ocaml-lsp-server/src/definition_query.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ open Import
open Fiber.O

let location_of_merlin_loc uri : _ -> (_, string) result = function
| `At_origin -> Ok None
| `Builtin _ -> Ok None
| `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)
| `File_not_found s -> Error (sprintf "File_not_found: %s" s)
| `Invalid_context -> Ok None
| `Invalid_context -> Error "Not a valid identifier"
| `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
Expand Down Expand Up @@ -56,7 +57,6 @@ 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' query to merlin returned error: %s" err_msg))
~data:(`String (sprintf "Locate: %s" err_msg))
()))
;;