Skip to content

Commit ffbd88d

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents d16dc8b + 2b9a25f commit ffbd88d

File tree

11 files changed

+484
-20
lines changed

11 files changed

+484
-20
lines changed

source/ada/lsp-ada_handlers-refactor-auto_import.adb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ package body LSP.Ada_Handlers.Refactor.Auto_Import is
135135
use Ada.Strings.Wide_Wide_Unbounded;
136136

137137
Title : constant Langkit_Support.Text.Unbounded_Text_Type :=
138-
"Qualify with " & Suggestion.Qualifier;
138+
(if Suggestion.Qualifier = Null_Unbounded_Wide_Wide_String then
139+
"Import from " & Suggestion.Import
140+
else
141+
"Qualify with " & Suggestion.Qualifier);
139142
begin
140143
return
141144
VSS.Strings.To_Virtual_String

testsuite/ada_lsp/refactoring_imports_commands/U511-009.refactoring.import_with_use/test.json

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
[
22
{
3-
"comment": ["Test codeaction import refactor"]
3+
"comment": [
4+
"Test codeaction import refactor"
5+
]
46
},
57
{
68
"start": {
7-
"cmd": ["${ALS}"]
9+
"cmd": [
10+
"${ALS}"
11+
]
812
}
913
},
1014
{
@@ -32,12 +36,22 @@
3236
"referencesProvider": true,
3337
"textDocumentSync": 2,
3438
"completionProvider": {
35-
"triggerCharacters": [".", ",", "'", "("],
39+
"triggerCharacters": [
40+
".",
41+
",",
42+
"'",
43+
"("
44+
],
3645
"resolveProvider": true
3746
},
3847
"signatureHelpProvider": {
39-
"triggerCharacters": [",", "("],
40-
"retriggerCharacters": ["\b"]
48+
"triggerCharacters": [
49+
",",
50+
"("
51+
],
52+
"retriggerCharacters": [
53+
"\b"
54+
]
4155
},
4256
"definitionProvider": true
4357
}
@@ -491,19 +505,6 @@
491505
}
492506
},
493507
"newText": "with Foo;\n"
494-
},
495-
{
496-
"range": {
497-
"start": {
498-
"line": 9,
499-
"character": 20
500-
},
501-
"end": {
502-
"line": 9,
503-
"character": 20
504-
}
505-
},
506-
"newText": ""
507508
}
508509
]
509510
}
@@ -617,4 +618,4 @@
617618
"exit_code": 0
618619
}
619620
}
620-
]
621+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package body A is
2+
3+
procedure Subprogram is
4+
begin
5+
null;
6+
end Subprogram;
7+
8+
end A;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package A is
2+
3+
procedure Subprogram;
4+
5+
end A;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
project Default is
2+
for Main use ("main.adb");
3+
for Runtime ("Ada") use "./rts-empty";
4+
end Default;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
with A;
2+
3+
package E renames A;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
procedure Main is
2+
begin
3+
A.Subprogram;
4+
end Main;
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
[
2+
{
3+
"comment": [
4+
"This test checks if imports (with clause + prefix) are being suggested to unresolved names."
5+
]
6+
},
7+
{
8+
"start": {
9+
"cmd": ["${ALS}"]
10+
}
11+
},
12+
{
13+
"send": {
14+
"request": {
15+
"params": {
16+
"processId": 13950,
17+
"capabilities": {
18+
"workspace": {
19+
"workspaceEdit": {
20+
"documentChanges": true
21+
},
22+
"applyEdit": false
23+
}
24+
},
25+
"rootUri": "$URI{.}"
26+
},
27+
"jsonrpc": "2.0",
28+
"id": 1,
29+
"method": "initialize"
30+
},
31+
"wait": [
32+
{
33+
"id": 1,
34+
"result": {
35+
"capabilities": {
36+
"textDocumentSync": 2,
37+
"executeCommandProvider": {
38+
"commands": ["<HAS>", "als-auto-import"]
39+
}
40+
}
41+
}
42+
}
43+
]
44+
}
45+
},
46+
{
47+
"send": {
48+
"request": {
49+
"jsonrpc": "2.0",
50+
"method": "initialized"
51+
},
52+
"wait": []
53+
}
54+
},
55+
{
56+
"send": {
57+
"request": {
58+
"params": {
59+
"settings": {
60+
"ada": {
61+
"projectFile": "default.gpr",
62+
"scenarioVariables": {},
63+
"defaultCharset": "ISO-8859-1"
64+
}
65+
}
66+
},
67+
"jsonrpc": "2.0",
68+
"method": "workspace/didChangeConfiguration"
69+
},
70+
"wait": [
71+
{
72+
"jsonrpc": "2.0",
73+
"id": 1,
74+
"method": "window/workDoneProgress/create",
75+
"params": {
76+
"token": "<ANY>"
77+
}
78+
},
79+
{
80+
"jsonrpc": "2.0",
81+
"method": "$/progress",
82+
"params": {
83+
"token": "<ANY>",
84+
"value": {
85+
"kind": "end"
86+
}
87+
}
88+
}
89+
]
90+
}
91+
},
92+
{
93+
"send": {
94+
"request": {
95+
"params": {
96+
"textDocument": {
97+
"text": "procedure Main is\nbegin\n A.Subprogram;\nend Main;",
98+
"version": 0,
99+
"uri": "$URI{main.adb}",
100+
"languageId": "Ada"
101+
}
102+
},
103+
"jsonrpc": "2.0",
104+
"method": "textDocument/didOpen"
105+
},
106+
"wait": []
107+
}
108+
},
109+
{
110+
"send": {
111+
"request": {
112+
"jsonrpc": "2.0",
113+
"id": 2,
114+
"method": "textDocument/codeAction",
115+
"params": {
116+
"textDocument": {
117+
"uri": "$URI{main.adb}"
118+
},
119+
"range": {
120+
"start": {
121+
"line": 2,
122+
"character": 3
123+
},
124+
"end": {
125+
"line": 2,
126+
"character": 3
127+
}
128+
},
129+
"context": {
130+
"diagnostics": []
131+
}
132+
}
133+
},
134+
"wait": [
135+
{
136+
"jsonrpc": "2.0",
137+
"id": 2,
138+
"result": [
139+
{
140+
"title": "Import from A",
141+
"kind": "quickfix",
142+
"command": {
143+
"title": "",
144+
"command": "als-auto-import",
145+
"arguments": [
146+
{
147+
"context": "Default",
148+
"where": {
149+
"textDocument": {
150+
"uri": "$URI{main.adb}"
151+
},
152+
"position": {
153+
"line": 2,
154+
"character": 5
155+
}
156+
},
157+
"import": "A",
158+
"qualifier": ""
159+
}
160+
]
161+
}
162+
},
163+
{
164+
"title": "Qualify with E",
165+
"kind": "quickfix",
166+
"command": {
167+
"title": "",
168+
"command": "als-auto-import",
169+
"arguments": [
170+
{
171+
"context": "Default",
172+
"where": {
173+
"textDocument": {
174+
"uri": "$URI{main.adb}"
175+
},
176+
"position": {
177+
"line": 2,
178+
"character": 5
179+
}
180+
},
181+
"import": "E",
182+
"qualifier": "E"
183+
}
184+
]
185+
}
186+
}
187+
]
188+
}
189+
]
190+
}
191+
},
192+
{
193+
"send": {
194+
"request": {
195+
"jsonrpc": "2.0",
196+
"id": 3,
197+
"method": "workspace/executeCommand",
198+
"params": {
199+
"command": "als-auto-import",
200+
"arguments": [
201+
{
202+
"context": "Default",
203+
"where": {
204+
"textDocument": {
205+
"uri": "$URI{main.adb}"
206+
},
207+
"position": {
208+
"line": 2,
209+
"character": 3
210+
}
211+
},
212+
"import": "A",
213+
"qualifier": ""
214+
}
215+
]
216+
}
217+
},
218+
"wait": [
219+
{
220+
"jsonrpc": "2.0",
221+
"id": 2,
222+
"method": "workspace/applyEdit",
223+
"params": {
224+
"edit": {
225+
"documentChanges": [
226+
{
227+
"textDocument": {
228+
"uri": "$URI{main.adb}",
229+
"version": 1
230+
},
231+
"edits": [
232+
{
233+
"range": {
234+
"start": {
235+
"line": 0,
236+
"character": 0
237+
},
238+
"end": {
239+
"line": 0,
240+
"character": 0
241+
}
242+
},
243+
"newText": "with A;\n"
244+
}
245+
]
246+
}
247+
]
248+
}
249+
}
250+
}
251+
]
252+
}
253+
},
254+
{
255+
"stop": {
256+
"exit_code": 0
257+
}
258+
}
259+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
------------------------------------------------------------------------------
2+
-- --
3+
-- GNAT RUN-TIME COMPONENTS --
4+
-- --
5+
-- A D A --
6+
-- --
7+
-- S p e c --
8+
-- --
9+
-- This specification is derived from the Ada Reference Manual for use with --
10+
-- GNAT. In accordance with the copyright of that document, you can freely --
11+
-- copy and modify this specification, provided that if you redistribute a --
12+
-- modified version, any changes that you have made are clearly indicated. --
13+
-- --
14+
------------------------------------------------------------------------------
15+
16+
package Ada is
17+
pragma No_Elaboration_Code_All;
18+
pragma Pure;
19+
20+
end Ada;

0 commit comments

Comments
 (0)