Skip to content

Commit 2a66172

Browse files
UA05-024: Add special case in completion for end names
The existing automatic test has been adapted.
1 parent 9060f06 commit 2a66172

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

source/ada/lsp-ada_completions-names.adb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ package body LSP.Ada_Completions.Names is
123123
-- . When we are providing an actual parameter to a subprogram call
124124

125125
Use_Snippets := False;
126+
127+
-- If we are dealing with an end label, just return the corresponding
128+
-- declaration's name: it's the only valid result in this case.
129+
if Parent.Kind in Ada_End_Name and then not Parent.Is_Null then
130+
Names.Include
131+
(Parent.As_End_Name.P_Basic_Decl.P_Defining_Name,
132+
(Is_Dot_Call => False,
133+
Is_Visible => True,
134+
Use_Snippets => Use_Snippets,
135+
Pos => 1));
136+
return;
137+
end if;
126138
end if;
127139

128140
declare

testsuite/ada_lsp/completion.end_labels/test.json

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -242,27 +242,12 @@
242242
"result": {
243243
"isIncomplete": false,
244244
"items": [
245-
{
246-
"label": "A",
247-
"kind": 6,
248-
"detail": "A, B : Integer",
249-
"documentation": "at main.adb (3:18)",
250-
"additionalTextEdits": [
251-
]
252-
},
253-
{
254-
"label": "ASCII",
255-
"kind": 9,
256-
"detail": "package ASCII ",
257-
"documentation": "<ANY>",
258-
"additionalTextEdits": [
259-
]
260-
},
261245
{
262246
"label": "Add",
263247
"kind": 3,
264248
"detail": "function Add (A, B : Integer) return Integer",
265249
"documentation": "at main.adb (3:4)",
250+
"sortText": "1Add",
266251
"additionalTextEdits": [
267252
]
268253
}

0 commit comments

Comments
 (0)