Skip to content

Commit bd069ad

Browse files
Merge branch 'cherry-pick-ebdf0de1' into '25.0'
Merge branch 'topic/eng/ide/ada_language_server#1453' into 'master' See merge request eng/ide/ada_language_server!1718
2 parents 921660f + 33ed056 commit bd069ad

File tree

5 files changed

+199
-3
lines changed

5 files changed

+199
-3
lines changed

source/ada/lsp-predefined_completion.adb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,12 @@ package body LSP.Predefined_Completion is
321321
return;
322322
end case;
323323

324-
Item := Filtered_Items.First_Element;
324+
if not Filtered_Items.Is_Empty then
325+
Item := Filtered_Items.First_Element;
325326

326-
Declaration_Text := Item.detail;
327-
Documentation_Text := Item.documentation.Value.Virtual_String;
327+
Declaration_Text := Item.detail;
328+
Documentation_Text := Item.documentation.Value.Virtual_String;
329+
end if;
328330
end Get_Tooltip_Text;
329331

330332
end LSP.Predefined_Completion;
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
with Ada.Text_IO; use Ada.Text_IO;
2+
3+
procedure Main
4+
with Unknown => Off
5+
is
6+
Foo : Integer := 30;
7+
pragma Unknown (C, Foo);
8+
begin
9+
Put_Line (Foo'Unknown);
10+
end Main;
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
[
2+
{
3+
"comment": [
4+
"This test checks that the textDocument/hover request does not ",
5+
"fail when hovering on unknown predefined entities."
6+
]
7+
},
8+
{
9+
"start": {
10+
"cmd": ["${ALS}"]
11+
}
12+
},
13+
{
14+
"send": {
15+
"request": {
16+
"jsonrpc": "2.0",
17+
"id": 1,
18+
"method": "initialize",
19+
"params": {
20+
"rootUri": "$URI{.}",
21+
"capabilities": {
22+
"textDocument": {
23+
"rangeFormatting": {
24+
"dynamicRegistration": true
25+
}
26+
}
27+
}
28+
}
29+
},
30+
"wait": [
31+
{
32+
"id": 1,
33+
"result": {
34+
"capabilities": {
35+
"hoverProvider": true
36+
}
37+
}
38+
}
39+
]
40+
}
41+
},
42+
{
43+
"send": {
44+
"request": {
45+
"jsonrpc": "2.0",
46+
"method": "initialized"
47+
},
48+
"wait": []
49+
}
50+
},
51+
{
52+
"send": {
53+
"request": {
54+
"jsonrpc": "2.0",
55+
"method": "workspace/didChangeConfiguration",
56+
"params": {
57+
"settings": {
58+
"ada": {
59+
"scenarioVariables": {},
60+
"defaultCharset": "ISO-8859-1",
61+
"enableDiagnostics": false,
62+
"followSymlinks": false,
63+
"documentationStyle": "gnat",
64+
"namedNotationThreshold": 3,
65+
"foldComments": false
66+
}
67+
}
68+
}
69+
},
70+
"wait": []
71+
}
72+
},
73+
{
74+
"send": {
75+
"request": {
76+
"jsonrpc": "2.0",
77+
"method": "textDocument/didOpen",
78+
"params": {
79+
"textDocument": {
80+
"uri": "$URI{main.adb}",
81+
"languageId": "Ada",
82+
"version": 0,
83+
"text": "with Ada.Text_IO; use Ada.Text_IO;\n\nprocedure Main \n with Unknown => Off\nis\n Foo : Integer := 30;\n pragma Unknown (C, Foo);\nbegin\n Put_Line (Foo'Unknown);\nend Main;\n"
84+
}
85+
}
86+
},
87+
"wait": []
88+
}
89+
},
90+
{
91+
"send": {
92+
"request": {
93+
"jsonrpc": "2.0",
94+
"id": 4,
95+
"method": "textDocument/hover",
96+
"params": {
97+
"textDocument": {
98+
"uri": "$URI{main.adb}"
99+
},
100+
"position": {
101+
"line": 3,
102+
"character": 7
103+
}
104+
}
105+
},
106+
"wait": [{ "result": null }]
107+
}
108+
},
109+
{
110+
"send": {
111+
"request": {
112+
"jsonrpc": "2.0",
113+
"id": 5,
114+
"method": "textDocument/hover",
115+
"params": {
116+
"textDocument": {
117+
"uri": "$URI{main.adb}"
118+
},
119+
"position": {
120+
"line": 6,
121+
"character": 10
122+
}
123+
}
124+
},
125+
"wait": [{ "result": null }]
126+
}
127+
},
128+
{
129+
"send": {
130+
"request": {
131+
"jsonrpc": "2.0",
132+
"id": 6,
133+
"method": "textDocument/hover",
134+
"params": {
135+
"textDocument": {
136+
"uri": "$URI{main.adb}"
137+
},
138+
"position": {
139+
"line": 8,
140+
"character": 17
141+
}
142+
}
143+
},
144+
"wait": [{ "result": null }]
145+
}
146+
},
147+
{
148+
"send": {
149+
"request": {
150+
"jsonrpc": "2.0",
151+
"method": "textDocument/didClose",
152+
"params": {
153+
"textDocument": {
154+
"uri": "$URI{main.adb}"
155+
}
156+
}
157+
},
158+
"wait": []
159+
}
160+
},
161+
{
162+
"send": {
163+
"request": {
164+
"jsonrpc": "2.0",
165+
"id": 7,
166+
"method": "shutdown"
167+
},
168+
"wait": [
169+
{
170+
"id": 7,
171+
"result": null
172+
}
173+
]
174+
}
175+
},
176+
{
177+
"stop": {
178+
"exit_code": 0
179+
}
180+
}
181+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'hover.predefined_entities.unknown'

0 commit comments

Comments
 (0)