Skip to content

Commit 06ec4e4

Browse files
Add test for didChangeWatchedFiles notification
Add a test to cover the case where we are receiving a didChangeWatchedFiles notification after receiving a didCreate notification. For eng/ide/ada_language_server#1550
1 parent a8bc861 commit 06ec4e4

File tree

7 files changed

+334
-2
lines changed

7 files changed

+334
-2
lines changed

source/ada/lsp-ada_handlers.adb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,9 +1791,9 @@ package body LSP.Ada_Handlers is
17911791
-- Contexts wont be empty, and all we need to do is check if
17921792
-- there's an open document. If there is, it takes precedence over
17931793
-- the filesystem.
1794-
-- If Contexts is empty, then we need to check if is a new source
1794+
-- If Contexts is empty, then we need to check if it's a new source
17951795
-- that needs to be added. For instance, a source that was moved
1796-
-- to the the project source directories.
1796+
-- to the project source directories.
17971797

17981798
if Contexts.Is_Empty then
17991799
for Context of Self.Contexts.Each_Context
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
with Foo;
2+
procedure Main is
3+
begin
4+
Foo.Bar;
5+
end Main;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Foo is
2+
3+
procedure Bar;
4+
5+
end Foo;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package body Foo is
2+
3+
procedure Bar is
4+
begin
5+
null;
6+
end Bar;
7+
8+
end Foo;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
project Test is
2+
3+
for Source_Dirs use (".", "src1", "src2");
4+
5+
package Naming is
6+
for Spec_Suffix ("Ada") use ".1.ada";
7+
end Naming;
8+
9+
end Test;
Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
[
2+
{
3+
"comment": [
4+
"Test didChangeWatchedFiles notification after receiving a didCreate notification."
5+
]
6+
},
7+
{
8+
"start": {
9+
"cmd": ["${ALS}"]
10+
}
11+
},
12+
{
13+
"send": {
14+
"request": {
15+
"jsonrpc": "2.0",
16+
"id": 0,
17+
"method": "initialize",
18+
"params": {
19+
"rootUri": "$URI{.}",
20+
"capabilities": {
21+
"workspace": {
22+
"fileOperations": {
23+
"didCreate": true
24+
}
25+
}
26+
}
27+
}
28+
},
29+
"wait": [
30+
{
31+
"id": 0,
32+
"result": {
33+
"capabilities": {
34+
"textDocumentSync": 2,
35+
"documentSymbolProvider": true,
36+
"definitionProvider": true,
37+
"workspace": {
38+
"fileOperations": {
39+
"didCreate": {
40+
"filters": [
41+
{
42+
"scheme": "file",
43+
"pattern": {
44+
"glob": "**/*.ad{a,s,b,c}",
45+
"matches": "file",
46+
"options": {
47+
"ignoreCase": true
48+
}
49+
}
50+
}
51+
]
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}
58+
]
59+
}
60+
},
61+
{
62+
"send": {
63+
"request": {
64+
"jsonrpc": "2.0",
65+
"method": "initialized",
66+
"params": {}
67+
},
68+
"wait": []
69+
}
70+
},
71+
{
72+
"send": {
73+
"request": {
74+
"jsonrpc": "2.0",
75+
"method": "workspace/didChangeConfiguration",
76+
"params": {
77+
"settings": {
78+
"ada": {
79+
"defaultCharset": "ISO-8859-1",
80+
"projectFile": "$URI{test.gpr}",
81+
"scenarioVariables": {}
82+
}
83+
}
84+
}
85+
},
86+
"wait": []
87+
}
88+
},
89+
{
90+
"send": {
91+
"request": {
92+
"jsonrpc": "2.0",
93+
"method": "textDocument/didOpen",
94+
"params": {
95+
"textDocument": {
96+
"uri": "$URI{main.adb}",
97+
"languageId": "ada",
98+
"version": 1,
99+
"text": "with Foo;\nprocedure Main is\nbegin\n Foo.Bar;\nend Main;\n"
100+
}
101+
}
102+
},
103+
"wait": []
104+
}
105+
},
106+
{
107+
"send": {
108+
"request": {
109+
"jsonrpc": "2.0",
110+
"id": 2,
111+
"method": "textDocument/definition",
112+
"params": {
113+
"textDocument": {
114+
"uri": "$URI{main.adb}"
115+
},
116+
"position": {
117+
"line": 3,
118+
"character": 8
119+
}
120+
}
121+
},
122+
"wait": [
123+
{
124+
"id": 2,
125+
"result": []
126+
}
127+
]
128+
}
129+
},
130+
{
131+
"shell": [
132+
"mv",
133+
"${DIR}${DIR_SEP}src1${DIR_SEP}foo.ads",
134+
"${DIR}${DIR_SEP}src1${DIR_SEP}foo.1.ada"
135+
]
136+
},
137+
{
138+
"shell": [
139+
"mv",
140+
"${DIR}${DIR_SEP}src2${DIR_SEP}foo.2.ada",
141+
"${DIR}${DIR_SEP}src2${DIR_SEP}foo.adb"
142+
]
143+
},
144+
{
145+
"send": {
146+
"request": {
147+
"jsonrpc": "2.0",
148+
"method": "workspace/didCreateFiles",
149+
"params": {
150+
"files": [
151+
{
152+
"uri": "$URI{src2/foo.adb}"
153+
},
154+
{
155+
"uri": "$URI{src1/foo.1.ada}"
156+
}
157+
]
158+
}
159+
},
160+
"wait": []
161+
}
162+
},
163+
{
164+
"send": {
165+
"request": {
166+
"jsonrpc": "2.0",
167+
"method": "workspace/didChangeWatchedFiles",
168+
"params": {
169+
"changes": [
170+
{
171+
"uri": "$URI{src2/foo.adb}",
172+
"type": 1
173+
},
174+
{
175+
"uri": "$URI{src2/foo.1.ada}",
176+
"type": 1
177+
}
178+
]
179+
}
180+
},
181+
"wait": []
182+
}
183+
},
184+
{
185+
"send": {
186+
"request": {
187+
"jsonrpc": "2.0",
188+
"id": 3,
189+
"method": "workspace/executeCommand",
190+
"params": {
191+
"command": "als-other-file",
192+
"arguments": [
193+
{
194+
"uri": "$URI{src1/foo.1.ada}"
195+
}
196+
]
197+
}
198+
},
199+
"wait": [
200+
{
201+
"jsonrpc": "2.0",
202+
"method": "window/showDocument",
203+
"params": {
204+
"uri": "$URI{src2/foo.adb}",
205+
"takeFocus": true
206+
}
207+
},
208+
{
209+
"jsonrpc": "2.0",
210+
"id": 3,
211+
"result": null
212+
}
213+
]
214+
}
215+
},
216+
{
217+
"send": {
218+
"request": {
219+
"jsonrpc": "2.0",
220+
"id": 4,
221+
"method": "workspace/executeCommand",
222+
"params": {
223+
"command": "als-other-file",
224+
"arguments": [
225+
{
226+
"uri": "$URI{src1/foo.1.ada}"
227+
}
228+
]
229+
}
230+
},
231+
"wait": [
232+
{
233+
"jsonrpc": "2.0",
234+
"method": "window/showDocument",
235+
"params": {
236+
"uri": "$URI{src2/foo.adb}",
237+
"takeFocus": true
238+
}
239+
},
240+
{
241+
"jsonrpc": "2.0",
242+
"id": 4,
243+
"result": null
244+
}
245+
]
246+
}
247+
},
248+
{
249+
"send": {
250+
"request": {
251+
"jsonrpc": "2.0",
252+
"id": 5,
253+
"method": "textDocument/definition",
254+
"params": {
255+
"textDocument": {
256+
"uri": "$URI{main.adb}"
257+
},
258+
"position": {
259+
"line": 3,
260+
"character": 8
261+
}
262+
}
263+
},
264+
"wait": [
265+
{
266+
"id": 5,
267+
"result": {
268+
"uri": "$URI{src1/foo.1.ada}",
269+
"range": {
270+
"start": {
271+
"line": 2,
272+
"character": 13
273+
},
274+
"end": {
275+
"line": 2,
276+
"character": 16
277+
}
278+
}
279+
}
280+
}
281+
]
282+
}
283+
},
284+
{
285+
"send": {
286+
"request": {
287+
"jsonrpc": "2.0",
288+
"id": 6,
289+
"method": "shutdown"
290+
},
291+
"wait": [
292+
{
293+
"id": 6,
294+
"result": null
295+
}
296+
]
297+
}
298+
},
299+
{
300+
"stop": {
301+
"exit_code": 0
302+
}
303+
}
304+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'did_change_watched_files.after_did_create'

0 commit comments

Comments
 (0)