Skip to content

Commit c7c9b80

Browse files
V804-025: Param completion for non_basic_decl
Add a test.
1 parent 65aa931 commit c7c9b80

File tree

5 files changed

+282
-1
lines changed

5 files changed

+282
-1
lines changed

source/ada/lsp-ada_completions-parameters.adb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ package body LSP.Ada_Completions.Parameters is
8383

8484
begin
8585
for N of reverse Context.Find_All_Env_Elements (Name_Node) loop
86-
if N.Kind in Ada_Basic_Subp_Decl then
86+
if N.Kind in Ada_Basic_Subp_Decl
87+
| Ada_Null_Subp_Decl_Range
88+
| Ada_Expr_Function_Range
89+
then
8790
declare
8891
Assoc : LSP.Ada_Completions.Generic_Assoc_Utils.Assoc_Data;
8992
Spec : constant Libadalang.Analysis.Base_Subp_Spec
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project Default is
2+
end Default;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
procedure Foo is
2+
function Bar
3+
(I, J, K : Integer; L : Float := 1.0) return Float is (L);
4+
procedure Bar (A, B : Integer) is null;
5+
procedure Bar (C : String);
6+
X : Float;
7+
begin
8+
X := Bar (
9+
end Foo;
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
[
2+
{
3+
"comment": [
4+
"Test param completion for: expression function, null procedure and",
5+
"procedure without a body"
6+
]
7+
},
8+
{
9+
"start": {
10+
"cmd": [
11+
"${ALS}"
12+
]
13+
}
14+
},
15+
{
16+
"send": {
17+
"request": {
18+
"jsonrpc": "2.0",
19+
"id": 1,
20+
"method": "initialize",
21+
"params": {
22+
"processId": 199714,
23+
"rootUri": "$URI{.}",
24+
"capabilities": {
25+
"workspace": {
26+
"applyEdit": true
27+
},
28+
"textDocument": {
29+
"completion": {
30+
"completionItem": {
31+
"snippetSupport": true,
32+
"documentationFormat": [
33+
"markdown",
34+
"plaintext"
35+
]
36+
}
37+
}
38+
},
39+
"window": {
40+
"workDoneProgress": true
41+
}
42+
}
43+
}
44+
},
45+
"wait": [
46+
{
47+
"jsonrpc": "2.0",
48+
"id": 1,
49+
"result": {
50+
"capabilities": {
51+
"textDocumentSync": 2,
52+
"completionProvider": {
53+
"triggerCharacters": [
54+
".",
55+
",",
56+
"'",
57+
"("
58+
],
59+
"resolveProvider": true
60+
}
61+
}
62+
}
63+
}
64+
]
65+
}
66+
},
67+
{
68+
"send": {
69+
"request": {
70+
"jsonrpc": "2.0",
71+
"method": "initialized"
72+
},
73+
"wait": []
74+
}
75+
},
76+
{
77+
"send": {
78+
"request": {
79+
"jsonrpc": "2.0",
80+
"method": "workspace/didChangeConfiguration",
81+
"params": {
82+
"settings": {
83+
"ada": {
84+
"projectFile":"$URI{default.gpr}"
85+
}
86+
}
87+
}
88+
},
89+
"wait": [
90+
{
91+
"jsonrpc": "2.0",
92+
"method": "$/progress",
93+
"params": {
94+
"token": "<ANY>",
95+
"value": {
96+
"kind": "end"
97+
}
98+
}
99+
}
100+
]
101+
}
102+
},
103+
{
104+
"send": {
105+
"request": {
106+
"jsonrpc": "2.0",
107+
"method": "textDocument/didOpen",
108+
"params": {
109+
"textDocument": {
110+
"uri": "$URI{foo.adb}",
111+
"languageId": "Ada",
112+
"version": 0,
113+
"text": "procedure Foo is\n function Bar\n (I, J, K : Integer; L : Float := 1.0) return Float is (L);\n procedure Bar (A, B : Integer) is null;\n procedure Bar (C : String);\n X : Float;\nbegin\n X := Bar (\nend Foo;\n"
114+
}
115+
}
116+
},
117+
"wait": []
118+
}
119+
},
120+
{
121+
"send": {
122+
"request": {
123+
"jsonrpc": "2.0",
124+
"id": 5,
125+
"method": "textDocument/completion",
126+
"params": {
127+
"textDocument": {
128+
"uri": "$URI{foo.adb}"
129+
},
130+
"position": {
131+
"line": 7,
132+
"character": 13
133+
},
134+
"context": {
135+
"triggerKind": 2
136+
}
137+
}
138+
},
139+
"wait": [
140+
{
141+
"id": 5,
142+
"result": {
143+
"isIncomplete": false,
144+
"items": [
145+
{
146+
"label": "Params of Bar",
147+
"kind": 15,
148+
"detail": "procedure Bar (C : String)",
149+
"documentation": "at foo.adb (5:4)",
150+
"sortText": "+00",
151+
"insertText": "C => ${1:String})$0",
152+
"insertTextFormat": 2,
153+
"additionalTextEdits": []
154+
},
155+
{
156+
"label": "C",
157+
"kind": 5,
158+
"sortText": "+01",
159+
"insertText": "C => ",
160+
"insertTextFormat": 1,
161+
"additionalTextEdits": []
162+
},
163+
{
164+
"label": "Params of Bar",
165+
"kind": 15,
166+
"detail": "procedure Bar (A, B : Integer) is null",
167+
"documentation": "at foo.adb (4:4)",
168+
"sortText": "+02",
169+
"insertText": "${1:A : Integer}, ${2:B : Integer})$0",
170+
"insertTextFormat": 2,
171+
"additionalTextEdits": []
172+
},
173+
{
174+
"label": "A",
175+
"kind": 5,
176+
"sortText": "+03",
177+
"insertText": "A => ",
178+
"insertTextFormat": 1,
179+
"additionalTextEdits": []
180+
},
181+
{
182+
"label": "B",
183+
"kind": 5,
184+
"sortText": "+04",
185+
"insertText": "B => ",
186+
"insertTextFormat": 1,
187+
"additionalTextEdits": []
188+
},
189+
{
190+
"label": "Params of Bar",
191+
"kind": 15,
192+
"detail": "function Bar\n (I, J, K : Integer; L : Float := 1.0) return Float",
193+
"documentation": "at foo.adb (2:4)",
194+
"sortText": "+05",
195+
"insertText": "I => ${1:Integer}, J => ${2:Integer}, K => ${3:Integer}, L => ${4:Float})$0",
196+
"insertTextFormat": 2,
197+
"additionalTextEdits": []
198+
},
199+
{
200+
"label": "I",
201+
"kind": 5,
202+
"sortText": "+06",
203+
"insertText": "I => ",
204+
"insertTextFormat": 1,
205+
"additionalTextEdits": []
206+
},
207+
{
208+
"label": "J",
209+
"kind": 5,
210+
"sortText": "+07",
211+
"insertText": "J => ",
212+
"insertTextFormat": 1,
213+
"additionalTextEdits": []
214+
},
215+
{
216+
"label": "K",
217+
"kind": 5,
218+
"sortText": "+08",
219+
"insertText": "K => ",
220+
"insertTextFormat": 1,
221+
"additionalTextEdits": []
222+
},
223+
{
224+
"label": "L",
225+
"kind": 5,
226+
"sortText": "+09",
227+
"insertText": "L => ",
228+
"insertTextFormat": 1,
229+
"additionalTextEdits": []
230+
}
231+
]
232+
}
233+
}
234+
]
235+
}
236+
},
237+
{
238+
"send": {
239+
"request": {
240+
"jsonrpc": "2.0",
241+
"method": "textDocument/didClose",
242+
"params": {
243+
"textDocument": {
244+
"uri": "$URI{foo.adb}"
245+
}
246+
}
247+
},
248+
"wait": []
249+
}
250+
},
251+
{
252+
"send": {
253+
"request": {
254+
"jsonrpc": "2.0",
255+
"id": 12,
256+
"method": "shutdown"
257+
},
258+
"wait": []
259+
}
260+
},
261+
{
262+
"stop": {
263+
"exit_code": 0
264+
}
265+
}
266+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'testsuite/ada_lsp/completion.param.non_basic_calls'

0 commit comments

Comments
 (0)