Skip to content

Commit 452985f

Browse files
amiraliescristianoc
authored andcommitted
Add rename tests
1 parent caca939 commit 452985f

File tree

9 files changed

+206
-0
lines changed

9 files changed

+206
-0
lines changed

analysis/src/Commands.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ let test ~path =
283283
| "doc" ->
284284
print_endline ("DocumentSymbol " ^ path);
285285
documentSymbol ~path
286+
| "ren" ->
287+
let newName = String.sub rest 4 (len - mlen - 4) in
288+
let () =
289+
print_endline
290+
("Rename " ^ path ^ " " ^ string_of_int line ^ ":"
291+
^ string_of_int col ^ " " ^ newName)
292+
in
293+
294+
rename ~path ~line ~col ~newName
286295
| "com" ->
287296
print_endline
288297
("Complete " ^ path ^ " " ^ string_of_int line ^ ":"

analysis/tests/src/Cross.res

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ let crossRefWithInterface2 = ReferencesWithInterface.x
1717
module RefWithInterface = ReferencesWithInterface
1818

1919
let crossRefWithInterface3 = ReferencesWithInterface.x
20+
21+
22+
let _ = RenameWithInterface.x
23+
// ^ren RenameWithInterfacePrime
24+
25+
let _ = RenameWithInterface.x
26+
// ^ren xPrime

analysis/tests/src/Rename.res

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let x = 12
2+
// ^ren y
3+
4+
let a = x
5+
6+
let b = a
7+
8+
let c = x
9+
10+
let foo = (~xx) => xx + 1
11+
// ^ren yy
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let x = 2
2+
// ^ren y
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let x: int
2+
// ^ren y

analysis/tests/src/expected/Cross.res.txt

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,67 @@ References tests/src/Cross.res 11:31
1717
{"uri": "ReferencesWithInterface.resi", "range": {"start": {"line": 0, "character": 0}, "end": {"line": 0, "character": 0}}}
1818
]
1919

20+
Rename tests/src/Cross.res 21:13 RenameWithInterfacePrime
21+
[
22+
{
23+
"kind": "rename",
24+
"oldUri": "RenameWithInterface.res",
25+
"newUri": "RenameWithInterfacePrime.res"
26+
},
27+
{
28+
"kind": "rename",
29+
"oldUri": "RenameWithInterface.resi",
30+
"newUri": "RenameWithInterfacePrime.resi"
31+
},
32+
{
33+
"textDocument": {
34+
"version": null,
35+
"uri": "Cross.res"
36+
},
37+
"edits": [{
38+
"range": {"start": {"line": 24, "character": 8}, "end": {"line": 24, "character": 27}},
39+
"newText": "RenameWithInterfacePrime"
40+
}, {
41+
"range": {"start": {"line": 21, "character": 8}, "end": {"line": 21, "character": 27}},
42+
"newText": "RenameWithInterfacePrime"
43+
}]
44+
}
45+
]
46+
47+
Rename tests/src/Cross.res 24:28 xPrime
48+
[
49+
{
50+
"textDocument": {
51+
"version": null,
52+
"uri": "RenameWithInterface.resi"
53+
},
54+
"edits": [{
55+
"range": {"start": {"line": 0, "character": 4}, "end": {"line": 0, "character": 5}},
56+
"newText": "xPrime"
57+
}]
58+
},
59+
{
60+
"textDocument": {
61+
"version": null,
62+
"uri": "RenameWithInterface.res"
63+
},
64+
"edits": [{
65+
"range": {"start": {"line": 0, "character": 4}, "end": {"line": 0, "character": 5}},
66+
"newText": "xPrime"
67+
}]
68+
},
69+
{
70+
"textDocument": {
71+
"version": null,
72+
"uri": "Cross.res"
73+
},
74+
"edits": [{
75+
"range": {"start": {"line": 21, "character": 28}, "end": {"line": 21, "character": 29}},
76+
"newText": "xPrime"
77+
}, {
78+
"range": {"start": {"line": 24, "character": 28}, "end": {"line": 24, "character": 29}},
79+
"newText": "xPrime"
80+
}]
81+
}
82+
]
83+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Rename tests/src/Rename.res 0:4 y
2+
[
3+
{
4+
"textDocument": {
5+
"version": null,
6+
"uri": "Rename.res"
7+
},
8+
"edits": [{
9+
"range": {"start": {"line": 0, "character": 4}, "end": {"line": 0, "character": 5}},
10+
"newText": "y"
11+
}, {
12+
"range": {"start": {"line": 3, "character": 8}, "end": {"line": 3, "character": 9}},
13+
"newText": "y"
14+
}, {
15+
"range": {"start": {"line": 7, "character": 8}, "end": {"line": 7, "character": 9}},
16+
"newText": "y"
17+
}]
18+
}
19+
]
20+
21+
Rename tests/src/Rename.res 9:19 yy
22+
[
23+
{
24+
"textDocument": {
25+
"version": null,
26+
"uri": "Rename.res"
27+
},
28+
"edits": [{
29+
"range": {"start": {"line": 9, "character": 12}, "end": {"line": 9, "character": 14}},
30+
"newText": "yy"
31+
}, {
32+
"range": {"start": {"line": 9, "character": 19}, "end": {"line": 9, "character": 21}},
33+
"newText": "yy"
34+
}]
35+
}
36+
]
37+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Rename tests/src/RenameWithInterface.res 0:4 y
2+
[
3+
{
4+
"textDocument": {
5+
"version": null,
6+
"uri": "RenameWithInterface.resi"
7+
},
8+
"edits": [{
9+
"range": {"start": {"line": 0, "character": 4}, "end": {"line": 0, "character": 5}},
10+
"newText": "y"
11+
}]
12+
},
13+
{
14+
"textDocument": {
15+
"version": null,
16+
"uri": "RenameWithInterface.res"
17+
},
18+
"edits": [{
19+
"range": {"start": {"line": 0, "character": 4}, "end": {"line": 0, "character": 5}},
20+
"newText": "y"
21+
}]
22+
},
23+
{
24+
"textDocument": {
25+
"version": null,
26+
"uri": "Cross.res"
27+
},
28+
"edits": [{
29+
"range": {"start": {"line": 21, "character": 28}, "end": {"line": 21, "character": 29}},
30+
"newText": "y"
31+
}, {
32+
"range": {"start": {"line": 24, "character": 28}, "end": {"line": 24, "character": 29}},
33+
"newText": "y"
34+
}]
35+
}
36+
]
37+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Rename tests/src/RenameWithInterface.resi 0:4 y
2+
[
3+
{
4+
"textDocument": {
5+
"version": null,
6+
"uri": "RenameWithInterface.resi"
7+
},
8+
"edits": [{
9+
"range": {"start": {"line": 0, "character": 4}, "end": {"line": 0, "character": 5}},
10+
"newText": "y"
11+
}]
12+
},
13+
{
14+
"textDocument": {
15+
"version": null,
16+
"uri": "RenameWithInterface.res"
17+
},
18+
"edits": [{
19+
"range": {"start": {"line": 0, "character": 4}, "end": {"line": 0, "character": 5}},
20+
"newText": "y"
21+
}]
22+
},
23+
{
24+
"textDocument": {
25+
"version": null,
26+
"uri": "Cross.res"
27+
},
28+
"edits": [{
29+
"range": {"start": {"line": 21, "character": 28}, "end": {"line": 21, "character": 29}},
30+
"newText": "y"
31+
}, {
32+
"range": {"start": {"line": 24, "character": 28}, "end": {"line": 24, "character": 29}},
33+
"newText": "y"
34+
}]
35+
}
36+
]
37+

0 commit comments

Comments
 (0)