Skip to content

Commit b7197c8

Browse files
committed
Repair jump code action test
The code action need explicit enabling
1 parent dd0e317 commit b7197c8

File tree

4 files changed

+58
-13
lines changed

4 files changed

+58
-13
lines changed

ocaml-lsp-server/test/e2e-new/code_actions.ml

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,14 @@ module M : sig type t = I of int | B of bool end
12721272
|}]
12731273
;;
12741274
1275+
let activate_jump client =
1276+
let config =
1277+
DidChangeConfigurationParams.create
1278+
~settings:(`Assoc [ "merlinJumpCodeActions", `Assoc [ "enable", `Bool true ] ])
1279+
in
1280+
change_config ~client config
1281+
;;
1282+
12751283
let%expect_test "can jump to match target" =
12761284
let source =
12771285
{ocaml|
@@ -1288,7 +1296,11 @@ let f (x : t) (d : bool) =
12881296
let end_ = Position.create ~line:5 ~character:5 in
12891297
Range.create ~start ~end_
12901298
in
1291-
print_code_actions source range ~filter:(find_action "merlin-jump-match");
1299+
print_code_actions
1300+
~prep:activate_jump
1301+
source
1302+
range
1303+
~filter:(find_action "merlin-jump-match");
12921304
[%expect
12931305
{|
12941306
Code actions:
@@ -1327,7 +1339,11 @@ let f (x : t) (d : bool) =
13271339
let end_ = Position.create ~line:5 ~character:5 in
13281340
Range.create ~start ~end_
13291341
in
1330-
print_code_actions source range ~filter:(find_action "merlin-jump-next-case");
1342+
print_code_actions
1343+
~prep:activate_jump
1344+
source
1345+
range
1346+
~filter:(find_action "merlin-jump-next-case");
13311347
[%expect
13321348
{|
13331349
Code actions:
@@ -1364,7 +1380,11 @@ let f (x : t) (d : bool) =
13641380
let end_ = Position.create ~line:5 ~character:5 in
13651381
Range.create ~start ~end_
13661382
in
1367-
print_code_actions source range ~filter:(find_action "merlin-jump-prev-case");
1383+
print_code_actions
1384+
~prep:activate_jump
1385+
source
1386+
range
1387+
~filter:(find_action "merlin-jump-prev-case");
13681388
[%expect
13691389
{|
13701390
Code actions:
@@ -1401,7 +1421,11 @@ let f (x : t) (d : bool) =
14011421
let end_ = Position.create ~line:5 ~character:5 in
14021422
Range.create ~start ~end_
14031423
in
1404-
print_code_actions source range ~filter:(find_action "merlin-jump-let");
1424+
print_code_actions
1425+
~prep:activate_jump
1426+
source
1427+
range
1428+
~filter:(find_action "merlin-jump-let");
14051429
[%expect
14061430
{|
14071431
Code actions:
@@ -1438,7 +1462,11 @@ let f (x : t) (d : bool) =
14381462
let end_ = Position.create ~line:5 ~character:5 in
14391463
Range.create ~start ~end_
14401464
in
1441-
print_code_actions source range ~filter:(find_action "merlin-jump-fun");
1465+
print_code_actions
1466+
~prep:activate_jump
1467+
source
1468+
range
1469+
~filter:(find_action "merlin-jump-fun");
14421470
[%expect
14431471
{|
14441472
Code actions:
@@ -1476,7 +1504,11 @@ let f (x : t) (d : bool) =
14761504
let end_ = Position.create ~line:2 ~character:5 in
14771505
Range.create ~start ~end_
14781506
in
1479-
print_code_actions source range ~filter:(find_action "merlin-jump-module");
1507+
print_code_actions
1508+
~prep:activate_jump
1509+
source
1510+
range
1511+
~filter:(find_action "merlin-jump-module");
14801512
[%expect
14811513
{|
14821514
Code actions:
@@ -1517,7 +1549,11 @@ let%expect_test "can jump to module-type target" =
15171549
let end_ = Position.create ~line:4 ~character:5 in
15181550
Range.create ~start ~end_
15191551
in
1520-
print_code_actions source range ~filter:(find_action "merlin-jump-module-type");
1552+
print_code_actions
1553+
~prep:activate_jump
1554+
source
1555+
range
1556+
~filter:(find_action "merlin-jump-module-type");
15211557
[%expect
15221558
{|
15231559
Code actions:
@@ -1553,7 +1589,11 @@ let%expect_test "shouldn't find the jump target on the same line" =
15531589
let end_ = Position.create ~line:0 ~character:5 in
15541590
Range.create ~start ~end_
15551591
in
1556-
print_code_actions source range ~filter:(find_action "merlin-jump-fun");
1592+
print_code_actions
1593+
~prep:activate_jump
1594+
source
1595+
range
1596+
~filter:(find_action "merlin-jump-fun");
15571597
[%expect {|
15581598
No code actions |}]
15591599
;;

ocaml-lsp-server/test/e2e-new/lsp_helpers.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
open Test.Import
22

3+
let change_config ~client params = Client.notification client (ChangeConfiguration params)
4+
35
let open_document ~client ~uri ~source =
46
let textDocument =
57
TextDocumentItem.create ~uri ~languageId:"ocaml" ~version:0 ~text:source

ocaml-lsp-server/test/e2e-new/lsp_helpers.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
open Test.Import
22

3+
(** Send the given configuration to the language server *)
4+
val change_config : client:'a Client.t -> DidChangeConfigurationParams.t -> unit Fiber.t
5+
36
(** Opens a document with the language server. This must be done before trying
47
to access it *)
58
val open_document

ocaml-lsp-server/test/e2e-new/syntax_doc_tests.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
open! Test.Import
2+
open Lsp_helpers
23

3-
let change_config client params = Client.notification client (ChangeConfiguration params)
44
let uri = DocumentUri.of_path "test.ml"
55
let create_postion line character = Position.create ~line ~character
66

@@ -67,7 +67,7 @@ type color = Red|Blue
6767
|ocaml} in
6868
let position = create_postion 1 9 in
6969
let req client =
70-
let* () = change_config client activate_syntax_doc in
70+
let* () = change_config ~client activate_syntax_doc in
7171
let* resp = hover_req client position in
7272
let () = print_hover resp in
7373
Fiber.return ()
@@ -94,7 +94,7 @@ type color = Red|Blue
9494
|ocaml} in
9595
let position = create_postion 1 9 in
9696
let req client =
97-
let* () = change_config client deactivate_syntax_doc in
97+
let* () = change_config ~client deactivate_syntax_doc in
9898
let* resp = hover_req client position in
9999
let () = print_hover resp in
100100
Fiber.return ()
@@ -117,7 +117,7 @@ type t = ..
117117
|ocaml} in
118118
let position = create_postion 1 5 in
119119
let req client =
120-
let* () = change_config client activate_syntax_doc in
120+
let* () = change_config ~client activate_syntax_doc in
121121
let* resp = hover_req client position in
122122
let () = print_hover resp in
123123
Fiber.return ()
@@ -143,7 +143,7 @@ let%expect_test "should receive no hover response" =
143143
|ocaml} in
144144
let position = create_postion 1 5 in
145145
let req client =
146-
let* () = change_config client activate_syntax_doc in
146+
let* () = change_config ~client activate_syntax_doc in
147147
let* resp = hover_req client position in
148148
let () = print_hover resp in
149149
Fiber.return ()

0 commit comments

Comments
 (0)