Skip to content

Commit

Permalink
review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
PizieDust committed Nov 6, 2024
1 parent 6100599 commit fd7e6fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
6 changes: 5 additions & 1 deletion ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface TypeSearchParams extends TexDocumentPositionParams
query: string;
limit: int;
with_doc: bool;
doc_format: string;
}
```
- method: `ocamllsp/typeSearch`
Expand All @@ -36,7 +37,10 @@ export interface TypeSearchParams extends TexDocumentPositionParams
"name": string,
"typ": string,
"loc": Range,
"doc": string,
"doc": {
"value": string,
"kind": string
},
"cost": int,
"constructible" : string
]
Expand Down
17 changes: 9 additions & 8 deletions ocaml-lsp-server/src/custom_requests/req_type_search.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ module TypeSearchParams = struct
| None -> []
in
`Assoc
((("textDocument", TextDocumentIdentifier.yojson_of_t text_document)
:: ("position", Position.yojson_of_t position)
:: ("limit", `Int limit)
:: ("with_doc", `Bool with_doc)
:: [ "query", `String query ])
@ doc_format)
(("textDocument", TextDocumentIdentifier.yojson_of_t text_document)
:: ("position", Position.yojson_of_t position)
:: ("limit", `Int limit)
:: ("with_doc", `Bool with_doc)
:: ("query", `String query)
:: doc_format)
;;
end

module TypeSearch = struct
type t = string Query_protocol.type_search_result list

let create ~kind ~value =
let doc_to_markupContent ~kind ~value =
let v =
match kind with
| MarkupKind.Markdown ->
Expand All @@ -74,7 +74,8 @@ module TypeSearch = struct
; "loc", Range.yojson_of_t (Range.of_loc res.loc)
; ( "doc"
, match res.doc with
| Some value -> create ~kind:format ~value |> MarkupContent.yojson_of_t
| Some value ->
doc_to_markupContent ~kind:format ~value |> MarkupContent.yojson_of_t
| None -> `Null )
; "cost", `Int res.cost
; "constructible", `String res.constructible
Expand Down
8 changes: 1 addition & 7 deletions ocaml-lsp-server/test/e2e-new/type_search.ml
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,7 @@ let%expect_test "Type Search for a simple query that takes an int and returns a
let source = "" in
let line = 1 in
let character = 0 in
Util.test
~line
~character
~query:"int -> string"
source
~with_doc:false
();
Util.test ~line ~character ~query:"int -> string" source ~with_doc:false ();
[%expect
{|
[
Expand Down

0 comments on commit fd7e6fa

Please sign in to comment.