Skip to content

Commit 78eb8d7

Browse files
update
1 parent c0a3e5d commit 78eb8d7

19 files changed

+187
-55
lines changed

dune-project

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(lang dune 3.0)
22
(using cinaps 1.0)
33
(name lsp)
4-
(version "1.19.0+jst")
4+
(version "1.19.0+ox")
55

66
(implicit_transitive_deps false)
77

@@ -71,8 +71,8 @@ possible and does not make any assumptions about IO.
7171
(csexp (>= 1.5))
7272
(ocamlformat-rpc-lib (>= 0.21.0))
7373
(odoc :with-doc)
74-
(odoc-parser (= 2.0.0))
75-
(merlin-lib (= "5.2.1-502+jst"))
74+
(odoc-parser (= "3.1.0+ox"))
75+
(merlin-lib (= "5.2.1-502+ox"))
7676
ppx_yojson_conv
7777
core_unix
7878
async

jsonrpc.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is generated by dune, edit dune-project instead
22
opam-version: "2.0"
3-
version: "1.19.0+jst"
3+
version: "1.19.0+ox"
44
synopsis: "Jsonrpc protocol implemenation"
55
description: "See https://www.jsonrpc.org/specification"
66
maintainer: ["Rudi Grinberg <[email protected]>"]

lsp.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is generated by dune, edit dune-project instead
22
opam-version: "2.0"
3-
version: "1.19.0+jst"
3+
version: "1.19.0+ox"
44
synopsis: "LSP protocol implementation in OCaml"
55
description: """
66

ocaml-lsp-server.opam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is generated by dune, edit dune-project instead
22
opam-version: "2.0"
3-
version: "1.19.0+jst"
3+
version: "1.19.0+ox"
44
synopsis: "LSP Server for OCaml"
55
description: "An LSP server for OCaml."
66
maintainer: ["Rudi Grinberg <[email protected]>"]
@@ -46,8 +46,8 @@ depends: [
4646
"csexp" {>= "1.5"}
4747
"ocamlformat-rpc-lib" {>= "0.21.0"}
4848
"odoc" {with-doc}
49-
"odoc-parser" {= "2.0.0"}
50-
"merlin-lib" {= "5.2.1-502+jst"}
49+
"odoc-parser" {= "3.1.0+ox"}
50+
"merlin-lib" {= "5.2.1-502+ox"}
5151
"ppx_yojson_conv"
5252
"core_unix"
5353
"async"

ocaml-lsp-server/src/action_add_rec.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let action_title = "Add missing `rec` keyword"
66
let let_bound_vars bindings =
77
List.filter_map bindings ~f:(fun vb ->
88
match vb.Typedtree.vb_pat.pat_desc with
9-
| Typedtree.Tpat_var (id, loc, _, _) -> Some (id, loc)
9+
| Typedtree.Tpat_var (id, loc, _, _, _) -> Some (id, loc)
1010
| _ -> None)
1111
;;
1212

ocaml-lsp-server/src/action_inline.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ let find_inline_task typedtree pos =
6666
match expr.exp_desc with
6767
| Texp_let
6868
( Nonrecursive
69-
, [ { vb_pat = { pat_desc = Tpat_var (inlined_var, { loc; _ }, _, _); _ }
69+
, [ { vb_pat = { pat_desc = Tpat_var (inlined_var, { loc; _ }, _, _, _); _ }
7070
; vb_expr = inlined_expr
7171
; _
7272
}
@@ -81,7 +81,7 @@ let find_inline_task typedtree pos =
8181
match item.str_desc with
8282
| Tstr_value
8383
( Nonrecursive
84-
, [ { vb_pat = { pat_desc = Tpat_var (inlined_var, { loc; _ }, _, _); _ }
84+
, [ { vb_pat = { pat_desc = Tpat_var (inlined_var, { loc; _ }, _, _, _); _ }
8585
; vb_expr = inlined_expr
8686
; _
8787
}
@@ -158,8 +158,8 @@ end = struct
158158
in
159159
let pat_iter (type k) (iter : I.iterator) (pat : k Typedtree.general_pattern) =
160160
match pat.pat_desc with
161-
| Tpat_var (id, { loc; _ }, _, _) -> paths := Loc.Map.set !paths loc (Pident id)
162-
| Tpat_alias (pat, id, { loc; _ }, _, _, _) ->
161+
| Tpat_var (id, { loc; _ }, _, _, _) -> paths := Loc.Map.set !paths loc (Pident id)
162+
| Tpat_alias (pat, id, { loc; _ }, _, _, _, _) ->
163163
paths := Loc.Map.set !paths loc (Pident id);
164164
I.default_iterator.pat iter pat
165165
| _ -> I.default_iterator.pat iter pat
@@ -209,7 +209,7 @@ let same_path paths (id : _ H.with_loc) (id' : _ H.with_loc) =
209209

210210
let beta_reduce (paths : Paths.t) (app : Parsetree.expression) =
211211
let rec beta_reduce_arg body (pat : Parsetree.pattern) arg =
212-
let with_let () = H.Exp.let_ Nonrecursive [ H.Vb.mk pat arg ] body in
212+
let with_let () = H.Exp.let_ Immutable Nonrecursive [ H.Vb.mk pat arg ] body in
213213
let with_subst param = subst (same_path paths) arg param body in
214214
match pat.ppat_desc with
215215
| Ppat_any | Ppat_construct ({ txt = Lident "()"; _ }, _) ->

ocaml-lsp-server/src/action_mark_remove_unused.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ let rec mark_value_unused_edit name contexts =
7575
(function
7676
| ( { loc = field_loc; _ }
7777
, _
78-
, { pat_desc = Tpat_var (ident, _, _, _); pat_loc; _ } )
78+
, { pat_desc = Tpat_var (ident, _, _, _, _); pat_loc; _ } )
7979
when Ident.name ident = name ->
8080
(* Special case for record shorthand *)
8181
if field_loc.loc_start = pat_loc.loc_start
@@ -97,7 +97,7 @@ let rec mark_value_unused_edit name contexts =
9797
(match m_field_edit with
9898
| Some e -> Some e
9999
| None -> mark_value_unused_edit name cs)
100-
| Pattern { pat_desc = Tpat_var (ident, _, _, _); pat_loc = loc; _ } :: _ ->
100+
| Pattern { pat_desc = Tpat_var (ident, _, _, _, _); pat_loc = loc; _ } :: _ ->
101101
if Ident.name ident = name
102102
then
103103
let+ start = Position.of_lexical_position loc.loc_start in
@@ -132,7 +132,7 @@ let enclosing_value_binding_range name =
132132
{ exp_desc =
133133
Texp_let
134134
( _
135-
, [ { vb_pat = { pat_desc = Tpat_var (_, { txt = name'; _ }, _, _); _ }; _ }
135+
, [ { vb_pat = { pat_desc = Tpat_var (_, { txt = name'; _ }, _, _, _); _ }; _ }
136136
]
137137
, { exp_loc = { loc_start = let_end; _ }; _ } )
138138
; exp_loc = { loc_start = let_start; _ }

ocaml-lsp-server/src/call_hierarchy.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ let handle_incoming ~log_info (server : State.t Server.t) params =
207207
let { CallHierarchyIncomingCallsParams.item; _ } = params in
208208
let { CallHierarchyItem.uri; range; _ } = item in
209209
let%bind.Fiber_option merlin_doc = get_merlin_doc state uri in
210-
let* locs, _synced =
210+
let* occurrences, _synced =
211211
Document.Merlin.dispatch_exn
212212
~log_info
213213
merlin_doc
214214
(Occurrences (`Ident_at (Position.logical range.end_), `Project))
215215
in
216-
List.map locs ~f:(fun (loc : Loc.t) -> loc.loc_start.pos_fname, loc)
216+
List.map occurrences ~f:(fun { loc; is_stale = _ } -> loc.loc_start.pos_fname, loc)
217217
|> Base.List.Assoc.sort_and_group ~compare:Base.String.compare
218218
|> batched_parallel ~batch_size:40 ~f:(fun (fn_name, locs) ->
219219
(* Using Map to only open one doc and create one parsetree per file name. *)

ocaml-lsp-server/src/compl.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ module Complete_by_prefix = struct
151151
; desc = typ
152152
; info = ""
153153
; deprecated = false (* TODO this is wrong *)
154+
; ppx_template_generated = false
154155
})
155156
in
156157
(* we need to json-ify completion params to put them in completion item's

ocaml-lsp-server/src/doc_to_md.ml

Lines changed: 126 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,41 @@ let rec nestable_block_element_to_block
106106
in
107107
let meta = loc_to_meta location in
108108
Block.Paragraph (paragraph, meta)
109+
| { value = `Table ((grid, alignment), _); location } ->
110+
let meta = loc_to_meta location in
111+
let cell
112+
((c, _) : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.cell) =
113+
let c = nestable_block_element_list_to_inlines c in
114+
(c, (" ", " ") (* Initial and trailing blanks *))
115+
in
116+
let header_row
117+
(row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row) =
118+
let row = List.map ~f:cell row in
119+
((`Header row, Meta.none), "")
120+
in
121+
let data_row
122+
(row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row) =
123+
let row = List.map ~f:cell row in
124+
((`Data row, Meta.none), "")
125+
in
126+
let alignment_row =
127+
match alignment with
128+
| None -> []
129+
| Some alignment ->
130+
let alignment =
131+
List.map
132+
~f:(fun x -> ((x, 1 (* nb of separator *)), Meta.none))
133+
alignment
134+
in
135+
[ ((`Sep alignment, Meta.none), "") ]
136+
in
137+
let rows =
138+
match grid with
139+
| [] -> assert false
140+
| h :: t -> (header_row h :: alignment_row) @ List.map ~f:data_row t
141+
in
142+
let tbl = Block.Table.make rows in
143+
Block.Ext_table (tbl, meta)
109144
| { value = `List (kind, style, xs); location } ->
110145
let l =
111146
let list_items =
@@ -148,22 +183,27 @@ let rec nestable_block_element_to_block
148183
in
149184
let meta = loc_to_meta location in
150185
Block.List (l, meta)
151-
| { value = `Code_block (metadata, { value = code; location = code_loc }); location } ->
186+
| { value = `Code_block { meta = metadata; delimiter = _; content = { value = code; location = code_loc }; output }; location } ->
152187
let meta = loc_to_meta location in
153188
let main_block =
154189
let code_block =
155190
let info_string =
156191
match metadata with
157192
| None -> Some ("ocaml", loc_to_meta code_loc)
158-
| Some ({ value = lang; location = lang_log }, _env) ->
193+
| Some { language = { value = lang; location = lang_log }; tags = _ } ->
159194
Some (lang, loc_to_meta lang_log)
160195
in
161196
let block_line = Block_line.list_of_string code in
162197
Block.Code_block.make ?info_string block_line
163198
in
164199
Block.Code_block (code_block, meta)
165200
in
166-
Block.Blocks ([ main_block ], meta)
201+
let output_block =
202+
match output with
203+
| None -> []
204+
| Some output -> [nestable_block_element_list_to_block output]
205+
in
206+
Block.Blocks ( main_block :: output_block , meta)
167207
| { value = `Verbatim code; location } ->
168208
let code_block =
169209
let info_string = Some ("verb", Meta.none) in
@@ -179,6 +219,75 @@ let rec nestable_block_element_to_block
179219
in
180220
let meta = loc_to_meta location in
181221
Block.Ext_math_block (code_block, meta)
222+
| { value = `Media _; location } ->
223+
let meta = loc_to_meta location in
224+
let p = Block.Paragraph.make (Inline.Text ("(media)", meta)) in
225+
Block.Paragraph (p, meta)
226+
227+
and nestable_block_element_to_inlines
228+
(nestable :
229+
Odoc_parser.Ast.nestable_block_element Odoc_parser.Loc.with_location) =
230+
match nestable with
231+
| { value = `Paragraph text; location = _ } ->
232+
inline_element_list_to_inlines text
233+
| { value = `Table ((grid, _), _); location } ->
234+
let meta = loc_to_meta location in
235+
let cell
236+
((c, _) : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.cell) =
237+
nestable_block_element_list_to_inlines c
238+
in
239+
let row (row : Odoc_parser.Ast.nestable_block_element Odoc_parser.Ast.row) =
240+
let sep = Inline.Text (" | ", Meta.none) in
241+
sep :: List.concat_map ~f:(fun c -> [ cell c; sep ]) row
242+
in
243+
let rows = List.concat_map ~f:row grid in
244+
Inline.Inlines (rows, meta)
245+
| { value = `List (_, _, xs); location } ->
246+
let meta = loc_to_meta location in
247+
let item i = nestable_block_element_list_to_inlines i in
248+
let items =
249+
let sep = Inline.Text (" - ", Meta.none) in
250+
List.concat_map ~f:(fun i -> [ sep; item i ]) xs
251+
in
252+
Inline.Inlines (items, meta)
253+
| { value = `Modules modules; location } ->
254+
let meta = loc_to_meta location in
255+
let s = List.map ~f:(fun x -> x.Odoc_parser.Loc.value) modules in
256+
Inline.Text ("modules: " ^ String.concat ~sep:" " s, meta)
257+
| { value =
258+
`Code_block
259+
{ meta = _
260+
; delimiter = _
261+
; content = { value = code; location = code_loc }
262+
; output = _
263+
}
264+
; location
265+
} ->
266+
let meta = loc_to_meta location in
267+
let meta_code = loc_to_meta code_loc in
268+
let code_span =
269+
Inline.Code_span.make ~backtick_count:1 [ ("", (code, meta_code)) ]
270+
in
271+
Inline.Code_span (code_span, meta)
272+
| { value = `Verbatim code; location } ->
273+
let meta = loc_to_meta location in
274+
let code_span =
275+
Inline.Code_span.make ~backtick_count:1 [ ("", (code, Meta.none)) ]
276+
in
277+
Inline.Code_span (code_span, meta)
278+
| { value = `Math_block code; location } ->
279+
let meta = loc_to_meta location in
280+
let code_span =
281+
Inline.Math_span.make ~display:true [ ("", (code, Meta.none)) ]
282+
in
283+
Inline.Ext_math_span (code_span, meta)
284+
| { value = `Media _; location } ->
285+
let meta = loc_to_meta location in
286+
Inline.Text ("(media)", meta)
287+
288+
and nestable_block_element_list_to_inlines l =
289+
let inlines = List.map ~f:nestable_block_element_to_inlines l in
290+
Inline.Inlines (inlines, Meta.none)
182291

183292
and nestable_block_element_list_to_block nestables =
184293
let blocks = List.map ~f:nestable_block_element_to_block nestables in
@@ -276,6 +385,19 @@ let tag_to_block ~meta (tag : Odoc_parser.Ast.tag) =
276385
| `Inline -> format_tag_empty "@inline"
277386
| `Open -> format_tag_empty "@open"
278387
| `Closed -> format_tag_empty "@closed"
388+
| `Hidden -> format_tag_empty "@hidden"
389+
| `Order_category oc ->
390+
let block = nestable_block_element_list_to_block oc in
391+
format_tag_block "@order_category" block
392+
| `Short_title oc ->
393+
let block = nestable_block_element_list_to_block oc in
394+
format_tag_block "@short_title" block
395+
| `Toc_status oc ->
396+
let block = nestable_block_element_list_to_block oc in
397+
format_tag_block "@toc_status" block
398+
| `Children_order oc ->
399+
let block = nestable_block_element_list_to_block oc in
400+
format_tag_block "@children_order" block
279401
;;
280402

281403
let rec block_element_to_block
@@ -293,7 +415,7 @@ let rec block_element_to_block
293415
let meta = loc_to_meta location in
294416
tag_to_block ~meta t
295417
| { value =
296-
`Paragraph _ | `List _ | `Modules _ | `Code_block _ | `Verbatim _ | `Math_block _
418+
`Paragraph _ | `List _ | `Modules _ | `Code_block _ | `Verbatim _ | `Table _ | `Math_block _ | `Media _
297419
; location = _
298420
} as nestable -> nestable_block_element_to_block nestable
299421

0 commit comments

Comments
 (0)