Skip to content

Commit de2dc6f

Browse files
authored
Merge pull request #1940 from voodoos/414-4.19-backports
414 4.19 backports
2 parents 2b9cd21 + 45cc7b6 commit de2dc6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1943
-485
lines changed

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# git config blame.ignoreRevsFile .git-blame-ignore-revs
22
beb4b4c5ed38984534effc3cc8733db57820bc7b
3+
013987e10b9ed17a8e06e9e4e859070482254ab2

.github/workflows/main.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ name: CI
66
# events but only for the master branch
77
on:
88
push:
9-
branches: [ '414' ]
9+
branches: ["414"]
1010
paths-ignore:
11-
- '**.md'
12-
- '**.txt'
13-
- '.git*'
14-
- 'doc/**'
15-
- 'emacs/**'
16-
- 'vim/**'
17-
- '**/emacs-lint.yml'
11+
- "**.md"
12+
- "**.txt"
13+
- ".git*"
14+
- "doc/**"
15+
- "emacs/**"
16+
- "vim/**"
17+
- "**/emacs-lint.yml"
1818
pull_request:
19-
branches: [ '414' ]
19+
branches: ["414"]
2020
paths-ignore:
21-
- '**.md'
22-
- '**.txt'
23-
- '.git*'
24-
- 'doc/**'
25-
- 'emacs/**'
26-
- 'vim/**'
27-
- '**/emacs-lint.yml'
21+
- "**.md"
22+
- "**.txt"
23+
- ".git*"
24+
- "doc/**"
25+
- "emacs/**"
26+
- "vim/**"
27+
- "**/emacs-lint.yml"
2828
schedule:
29-
- cron: '0 12 */6 * *'
29+
- cron: "0 12 */6 * *"
3030

3131
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
3232
jobs:
@@ -53,7 +53,7 @@ jobs:
5353
- uses: actions/checkout@v3
5454

5555
- name: Set up OCaml ${{ matrix.ocaml-compiler }}
56-
uses: ocaml/setup-ocaml@v2
56+
uses: ocaml/setup-ocaml@v3
5757
with:
5858
# Version of the OCaml compiler to initialise
5959
ocaml-compiler: ${{ matrix.ocaml-compiler }}
@@ -82,9 +82,8 @@ jobs:
8282
opam exec -- dune build
8383
git diff --exit-code
8484
85-
8685
- name: Check that the changes are correctly formatted
8786
if: matrix.os == 'ubuntu-latest'
8887
run: |
89-
opam install ocamlformat.0.26.2
88+
opam install ocamlformat.0.27.0
9089
opam exec -- dune build @fmt

.github/workflows/ocaml-lsp-compat.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ name: Check ocaml-lsp compat
44
# events but only for the master branch
55
on:
66
push:
7-
branches: [ master ]
7+
branches: [master]
88
paths-ignore:
9-
- '**.md'
10-
- '**.txt'
11-
- '.git*'
12-
- 'doc/**'
13-
- 'emacs/**'
14-
- 'vim/**'
15-
- '**/emacs-lint.yml'
9+
- "**.md"
10+
- "**.txt"
11+
- ".git*"
12+
- "doc/**"
13+
- "emacs/**"
14+
- "vim/**"
15+
- "**/emacs-lint.yml"
1616
pull_request:
17-
branches: [ master ]
17+
branches: [master]
1818
paths-ignore:
19-
- '**.md'
20-
- '**.txt'
21-
- '.git*'
22-
- 'doc/**'
23-
- 'emacs/**'
24-
- 'vim/**'
25-
- '**/emacs-lint.yml'
19+
- "**.md"
20+
- "**.txt"
21+
- ".git*"
22+
- "doc/**"
23+
- "emacs/**"
24+
- "vim/**"
25+
- "**/emacs-lint.yml"
2626

2727
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2828
jobs:
@@ -55,4 +55,3 @@ jobs:
5555
opam --cli=2.1 pin --with-version=dev --no-action https://github.com/ocaml/ocaml-lsp.git
5656
opam --cli=2.1 pin --with-version=dev --no-action .
5757
opam install ocaml-lsp-server --with-test --ignore-constraints-on=merlin-lib
58-

.ocamlformat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=0.26.2
1+
version=0.27.0
22
disable=false
33

44
break-cases=fit-or-vertical
@@ -8,4 +8,4 @@ dock-collection-brackets=false
88
# Preserve begin/end
99
exp-grouping=preserve
1010
module-item-spacing=preserve
11-
parse-docstrings=false
11+
parse-docstrings=false

CHANGES.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
merlin 4.19
2+
===========
3+
Mon Jun 23 10:10:42 CEST 2024
4+
5+
+ merlin library
6+
- Expose utilities to manipulate typed-holes in `Merlin_analysis.Typed_hole`
7+
(#1888)
8+
- `inlay-hints` fix inlay hints on function parameters (#1923)
9+
- Handle class type in outline (#1932)
10+
- Handle locally defined value in outline (#1936)
11+
+ vim plugin
12+
- Added support for search-by-type (#1846)
13+
This is exposed through the existing `:MerlinSearch` command, that
14+
switches between search-by-type and polarity search depending on the
15+
first character of the query.
16+
117
merlin 4.18
218
===========
319
Tue Nov 26 17:30:42 CET 2024

merlin-lib.opam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ homepage: "https://github.com/ocaml/merlin"
55
bug-reports: "https://github.com/ocaml/merlin/issues"
66
dev-repo: "git+https://github.com/ocaml/merlin.git"
77
license: "MIT"
8+
x-maintenance-intent: ["(latest)"]
89
build: [
910
["dune" "subst"] {dev}
1011
["dune" "build" "-p" name "-j" jobs]

merlin.opam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ homepage: "https://github.com/ocaml/merlin"
55
bug-reports: "https://github.com/ocaml/merlin/issues"
66
dev-repo: "git+https://github.com/ocaml/merlin.git"
77
license: "MIT"
8+
x-maintenance-intent: ["(latest)"]
89
build: [
910
["dune" "subst"] {dev}
1011
["dune" "build" "-p" name "-j" jobs]

src/analysis/completion.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,10 @@ let complete_methods ~env ~prefix obj =
507507
in
508508
let methods = List.filter ~f:has_prefix (methods_of_type env t) in
509509
List.map methods ~f:(fun (name, ty) ->
510-
let info = `None (* TODO: get documentation. *) in
510+
let info =
511+
`None
512+
(* TODO: get documentation. *)
513+
in
511514
{ name;
512515
kind = `MethodCall;
513516
desc = `Type_scheme ty;

src/analysis/destruct.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ let rec needs_parentheses = function
196196
binding. *)
197197
| Texp_function { cases = [ _ ]; _ }
198198
(* The assumption here is that we're not in a [function ... | ...]
199-
situation but either in [fun param] or [let name param]. *) ->
200-
needs_parentheses ts
199+
situation but either in [fun param] or [let name param]. *)
200+
-> needs_parentheses ts
201201
| _ -> true
202202
end
203203
| _ -> needs_parentheses ts)

src/analysis/inlay_hints.ml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let pattern_has_constraint (type a) (pattern : a Typedtree.general_pattern) =
1717
pattern.pat_extra
1818

1919
let structure_iterator hint_let_binding hint_pattern_binding
20-
avoid_ghost_location typedtree range callback =
20+
_hint_function_params avoid_ghost_location typedtree range callback =
2121
let case_iterator hint_lhs (iterator : Iterator.iterator) case =
2222
let () = log ~title:"case" "on case" in
2323
let () = if hint_lhs then iterator.pat iterator case.Typedtree.c_lhs in
@@ -136,21 +136,24 @@ let create_hint env typ loc =
136136
let position = loc.Location.loc_end in
137137
(position, label)
138138

139-
let of_structure ~hint_let_binding ~hint_pattern_binding ~avoid_ghost_location
140-
~start ~stop structure =
139+
let of_structure ~hint_let_binding ~hint_pattern_binding ~hint_function_params
140+
~avoid_ghost_location ~start ~stop structure =
141141
let () =
142142
log ~title:"start" "%a" Logger.fmt (fun fmt ->
143143
Format.fprintf fmt
144-
"Start on %s to %s with : let: %b, pat: %b, ghost: %b"
144+
"Start on %s to %s with : let: %b, pat: %b, function_param: %b, \
145+
ghost: %b"
145146
(Lexing.print_position () start)
146147
(Lexing.print_position () stop)
147-
hint_let_binding hint_pattern_binding avoid_ghost_location)
148+
hint_let_binding hint_pattern_binding hint_function_params
149+
avoid_ghost_location)
148150
in
149151
let range = (start, stop) in
150152
let hints = ref [] in
151153
let () =
152154
structure_iterator hint_let_binding hint_pattern_binding
153-
avoid_ghost_location structure range (fun env typ loc ->
155+
hint_function_params avoid_ghost_location structure range
156+
(fun env typ loc ->
154157
let () =
155158
log ~title:"hint" "Find hint %a" Logger.fmt (fun fmt ->
156159
Format.fprintf fmt "%s - %a"

src/analysis/inlay_hints.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type hint = Lexing.position * string
55
val of_structure :
66
hint_let_binding:bool ->
77
hint_pattern_binding:bool ->
8+
hint_function_params:bool ->
89
avoid_ghost_location:bool ->
910
start:Lexing.position ->
1011
stop:Lexing.position ->

src/analysis/locate.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -888,15 +888,15 @@ let find_doc_attributes_in_typedtree ~config ~comp_unit uid =
888888
| Interface s ->
889889
Some
890890
(`Interface
891-
{ s with
892-
sig_final_env = Envaux.env_of_only_summary s.sig_final_env
893-
})
891+
{ s with
892+
sig_final_env = Envaux.env_of_only_summary s.sig_final_env
893+
})
894894
| Implementation str ->
895895
Some
896896
(`Implementation
897-
{ str with
898-
str_final_env = Envaux.env_of_only_summary str.str_final_env
899-
})
897+
{ str with
898+
str_final_env = Envaux.env_of_only_summary str.str_final_env
899+
})
900900
| _ -> None
901901
end
902902
| Error _ -> None
@@ -946,7 +946,8 @@ let doc_from_uid ~config ~loc uid =
946946
when Env.get_unit_name () <> comp_unit -> (
947947
log ~title:"get_doc"
948948
"the doc (%a) you're looking for is in another\n\
949-
\ compilation unit (%s)" Logger.fmt
949+
\ compilation unit (%s)"
950+
Logger.fmt
950951
(fun fmt -> Shape.Uid.print fmt uid)
951952
comp_unit;
952953
match find_doc_attributes_in_typedtree ~config ~comp_unit uid with

src/analysis/outline.ml

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ let mk ?(children = []) ~location ~deprecated outline_kind outline_type id =
4848
deprecated
4949
}
5050

51-
let get_class_field_desc_infos = function
52-
| Typedtree.Tcf_val (str_loc, _, _, _, _) -> Some (str_loc, `Value)
53-
| Typedtree.Tcf_method (str_loc, _, _) -> Some (str_loc, `Method)
51+
let get_class_signature_field_desc_infos = function
52+
| Typedtree.Tctf_val (outline_name, _, _, _) -> Some (outline_name, `Value)
53+
| Typedtree.Tctf_method (outline_name, _, _, _) -> Some (outline_name, `Method)
5454
| _ -> None
5555

5656
let outline_type ~env typ =
@@ -64,13 +64,16 @@ let rec summarize node =
6464
let location = node.t_loc in
6565
match node.t_node with
6666
| Value_binding vb ->
67+
let children =
68+
List.concat_map (Lazy.force node.t_children) ~f:get_val_elements
69+
in
6770
let deprecated = Type_utils.is_deprecated vb.vb_attributes in
6871
begin
6972
match id_of_patt vb.vb_pat with
7073
| None -> None
7174
| Some ident ->
7275
let typ = outline_type ~env:node.t_env vb.vb_pat.pat_type in
73-
Some (mk ~location ~deprecated `Value typ ident)
76+
Some (mk ~children ~location ~deprecated `Value typ ident)
7477
end
7578
| Value_description vd ->
7679
let deprecated = Type_utils.is_deprecated vd.val_attributes in
@@ -141,32 +144,65 @@ let rec summarize node =
141144
in
142145
let deprecated = Type_utils.is_deprecated cd.ci_attributes in
143146
Some (mk ~children ~location `Class None cd.ci_id_class_type ~deprecated)
147+
| Class_type_declaration ctd ->
148+
let children =
149+
List.concat_map (Lazy.force node.t_children) ~f:get_class_elements
150+
in
151+
let deprecated = Type_utils.is_deprecated ctd.ci_attributes in
152+
Some
153+
(mk ~children ~location `ClassType None ctd.ci_id_class_type ~deprecated)
144154
| _ -> None
145155

156+
and get_val_elements node =
157+
match node.t_node with
158+
| Expression _ ->
159+
List.concat_map (Lazy.force node.t_children) ~f:get_val_elements
160+
| Class_expr _ | Class_structure _ -> get_class_elements node
161+
| _ -> Option.to_list (summarize node)
162+
146163
and get_class_elements node =
147164
match node.t_node with
148165
| Class_expr _ ->
149166
List.concat_map (Lazy.force node.t_children) ~f:get_class_elements
167+
| Class_field cf ->
168+
let children =
169+
List.concat_map (Lazy.force node.t_children) ~f:get_class_elements
170+
in
171+
cf.cf_desc |> get_class_field_desc_infos
172+
|> Option.map ~f:(fun (str_loc, outline_kind) ->
173+
let deprecated = Type_utils.is_deprecated cf.cf_attributes in
174+
{ Query_protocol.outline_name = str_loc.Location.txt;
175+
outline_kind;
176+
outline_type = None;
177+
location = str_loc.Location.loc;
178+
children;
179+
deprecated
180+
})
181+
|> Option.to_list
182+
| Class_field_kind _ ->
183+
List.concat_map (Lazy.force node.t_children) ~f:get_val_elements
150184
| Class_structure _ ->
151-
List.filter_map (Lazy.force node.t_children) ~f:(fun child ->
152-
match child.t_node with
153-
| Class_field cf -> begin
154-
match get_class_field_desc_infos cf.cf_desc with
155-
| Some (str_loc, outline_kind) ->
156-
let deprecated = Type_utils.is_deprecated cf.cf_attributes in
157-
Some
158-
{ Query_protocol.outline_name = str_loc.Location.txt;
159-
outline_kind;
160-
outline_type = None;
161-
location = str_loc.Location.loc;
162-
children = [];
163-
deprecated
164-
}
165-
| None -> None
166-
end
167-
| _ -> None)
185+
List.concat_map (Lazy.force node.t_children) ~f:get_class_elements
186+
| Class_type { cltyp_desc = Tcty_signature { csig_fields; _ }; _ } ->
187+
List.filter_map csig_fields ~f:(fun field ->
188+
get_class_signature_field_desc_infos field.ctf_desc
189+
|> Option.map ~f:(fun (name, outline_kind) ->
190+
let deprecated = Type_utils.is_deprecated field.ctf_attributes in
191+
{ Query_protocol.outline_name = name;
192+
outline_kind;
193+
outline_type = None;
194+
location = field.ctf_loc;
195+
(* TODO: could we have more precised location information? *)
196+
children = [];
197+
deprecated
198+
}))
168199
| _ -> []
169200

201+
and get_class_field_desc_infos = function
202+
| Typedtree.Tcf_val (str_loc, _, _, _field_kind, _) -> Some (str_loc, `Value)
203+
| Typedtree.Tcf_method (str_loc, _, _field_kind) -> Some (str_loc, `Method)
204+
| _ -> None
205+
170206
and get_mod_children node =
171207
List.concat_map (Lazy.force node.t_children) ~f:remove_mod_indir
172208

src/analysis/syntax_doc.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let get_syntax_doc cursor_loc node : syntax_info =
3939
:: ( _,
4040
Module_type_constraint
4141
(Tmodtype_explicit
42-
{ mty_desc = Tmty_with (_, [ (_, _, Twith_modtype _) ]); _ }) )
42+
{ mty_desc = Tmty_with (_, [ (_, _, Twith_modtype _) ]); _ }) )
4343
:: _ ->
4444
Some
4545
{ name = "Module substitution";

src/analysis/tail_analysis.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ let expr_tail_positions = function
7575
| Texp_unreachable
7676
| Texp_extension_constructor _
7777
| Texp_letop _
78-
| Texp_hole -> []
78+
| Texp_typed_hole -> []
7979
| Texp_match (_, cs, _) -> List.map cs ~f:(fun c -> Case c)
8080
| Texp_try (_, cs) -> List.map cs ~f:(fun c -> Case c)
8181
| Texp_letmodule (_, _, _, _, e)

0 commit comments

Comments
 (0)