Skip to content

Commit d5d4bc7

Browse files
Merge branch 'topic/als.1404.completion_aggregate_string' into 'master'
Aggregate completion only works on record types Closes #1404 See merge request eng/ide/ada_language_server!1659
2 parents 7a3e670 + 719a36c commit d5d4bc7

File tree

5 files changed

+245
-1
lines changed

5 files changed

+245
-1
lines changed

source/ada/lsp-ada_completions-parameters.adb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,10 @@ package body LSP.Ada_Completions.Parameters is
528528
return Res;
529529
end if;
530530

531-
if Aggr_Type.Kind in Ada_Type_Decl then
531+
if Aggr_Type.Kind in Ada_Type_Decl
532+
and then Aggr_Type.P_Is_Record_Type
533+
-- P_Shapes can only be called on record types
534+
then
532535
declare
533536
Base_Type : constant Base_Type_Decl :=
534537
Aggr_Type.P_Base_Type (Origin => A);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
with Ada.Text_IO;
2+
3+
procedure Main is
4+
A : constant String := (1 .. 0 => 'a');
5+
begin
6+
if A'Last in A'Range then
7+
Ada.Text_IO.Put_Line ("Hello");
8+
end if;
9+
end Main;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
project Test is
2+
for Main use ("main.adb");
3+
end Test;
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
[
2+
{
3+
"comment": [
4+
"Test the completion provider inside a string aggregate.",
5+
"No exception should happen."
6+
]
7+
}, {
8+
"start": {
9+
"cmd": [
10+
"${ALS}"
11+
]
12+
}
13+
},
14+
{
15+
"send": {
16+
"request": {
17+
"params": {
18+
"processId": 31570,
19+
"capabilities": {
20+
"textDocument": {
21+
"completion": {
22+
"completionItem": {
23+
"documentationFormat": [
24+
"plaintext",
25+
"markdown"
26+
],
27+
"snippetSupport": true
28+
},
29+
"dynamicRegistration": true
30+
},
31+
"definition": {},
32+
"hover": {},
33+
"formatting": {
34+
"dynamicRegistration": true
35+
},
36+
"implementation": {},
37+
"codeLens": {},
38+
"typeDefinition": {},
39+
"selectionRange": {},
40+
"documentHighlight": {},
41+
"documentSymbol": {
42+
"hierarchicalDocumentSymbolSupport": true
43+
},
44+
"synchronization": {},
45+
"references": {},
46+
"rangeFormatting": {},
47+
"onTypeFormatting": {},
48+
"declaration": {},
49+
"foldingRange": {
50+
"lineFoldingOnly": true
51+
},
52+
"colorProvider": {}
53+
},
54+
"workspace": {
55+
"applyEdit": true,
56+
"executeCommand": {},
57+
"didChangeWatchedFiles": {},
58+
"workspaceEdit": {},
59+
"didChangeConfiguration": {}
60+
}
61+
},
62+
"rootUri": "$URI{.}"
63+
},
64+
"jsonrpc": "2.0",
65+
"id": 1,
66+
"method": "initialize"
67+
},
68+
"wait": [
69+
{
70+
"jsonrpc": "2.0",
71+
"id": 1,
72+
"result": {
73+
"capabilities": {
74+
"textDocumentSync": 2,
75+
"completionProvider": {
76+
"triggerCharacters": [
77+
".",
78+
",",
79+
"'",
80+
"("
81+
],
82+
"resolveProvider": true
83+
}
84+
}
85+
}
86+
}
87+
]
88+
}
89+
},
90+
{
91+
"send": {
92+
"request": {
93+
"jsonrpc": "2.0",
94+
"method": "initialized"
95+
},
96+
"wait": []
97+
}
98+
},
99+
{
100+
"send": {
101+
"request": {
102+
"params": {
103+
"settings": {
104+
"ada": {
105+
"scenarioVariables": {},
106+
"enableDiagnostics": false,
107+
"defaultCharset": "ISO-8859-1"
108+
}
109+
}
110+
},
111+
"jsonrpc": "2.0",
112+
"method": "workspace/didChangeConfiguration"
113+
},
114+
"wait": []
115+
}
116+
},
117+
{
118+
"send": {
119+
"request": {
120+
"jsonrpc": "2.0",
121+
"method": "textDocument/didOpen",
122+
"params": {
123+
"textDocument": {
124+
"uri": "$URI{main.adb}",
125+
"languageId": "Ada",
126+
"version": 0,
127+
"text": "with Ada.Text_IO;\n\nprocedure Main is\n A : constant String := (1 .. 0 => 'a');\nbegin\n if A'Last in A'Range then\n Ada.Text_IO.Put_Line (\"Hello\");\n end if;\nend Main;\n"
128+
}
129+
}
130+
},
131+
"wait": []
132+
}
133+
},
134+
{
135+
"send": {
136+
"request": {
137+
"jsonrpc": "2.0",
138+
"id": 7,
139+
"method": "textDocument/completion",
140+
"params": {
141+
"textDocument": {
142+
"uri": "$URI{main.adb}"
143+
},
144+
"position": {
145+
"line": 3,
146+
"character": 33
147+
},
148+
"context": {
149+
"triggerKind": 1
150+
}
151+
}
152+
},
153+
"wait": [
154+
{
155+
"id": 7,
156+
"result": {
157+
"isIncomplete": false,
158+
"items": []
159+
}
160+
}
161+
]
162+
}
163+
},
164+
{
165+
"send": {
166+
"request": {
167+
"jsonrpc": "2.0",
168+
"id": 8,
169+
"method": "textDocument/completion",
170+
"params": {
171+
"textDocument": {
172+
"uri": "$URI{main.adb}"
173+
},
174+
"position": {
175+
"line": 3,
176+
"character": 33
177+
},
178+
"context": {
179+
"triggerKind": 1
180+
}
181+
}
182+
},
183+
"wait": [
184+
{
185+
"id": 8,
186+
"result": {
187+
"isIncomplete": false,
188+
"items": []
189+
}
190+
}
191+
]
192+
}
193+
},
194+
{
195+
"send": {
196+
"request": {
197+
"jsonrpc": "2.0",
198+
"method": "textDocument/didClose",
199+
"params": {
200+
"textDocument": {
201+
"uri": "$URI{src/main.adb"
202+
}
203+
}
204+
},
205+
"wait": []
206+
}
207+
},
208+
{
209+
"send": {
210+
"request": {
211+
"jsonrpc": "2.0",
212+
"id": 9,
213+
"method": "shutdown"
214+
},
215+
"wait": [
216+
{
217+
"id": 9,
218+
"result": null
219+
}
220+
]
221+
}
222+
},
223+
{
224+
"stop": {
225+
"exit_code": 0
226+
}
227+
}
228+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'completion.aggregates.string'

0 commit comments

Comments
 (0)