Skip to content

Commit 3b0ab17

Browse files
U415-017: Fix callHierrachy requests for abstract subprograms
An automatic test has been added.
1 parent ac36146 commit 3b0ab17

File tree

7 files changed

+351
-9
lines changed

7 files changed

+351
-9
lines changed

source/ada/lsp-ada_handlers.adb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4053,7 +4053,7 @@ package body LSP.Ada_Handlers is
40534053
(C.Get_Node_At
40544054
(Get_Open_Document (Self, Value.textDocument.uri), Value));
40554055

4056-
Name : Libadalang.Analysis.Defining_Name :=
4056+
Name : constant Libadalang.Analysis.Defining_Name :=
40574057
Laltools.Common.Resolve_Name
40584058
(Node,
40594059
Self.Trace,
@@ -4064,14 +4064,6 @@ package body LSP.Ada_Handlers is
40644064
return Response;
40654065
end if;
40664066

4067-
-- Go to the corresponding body, because only body could have calls
4068-
declare
4069-
Bodies : constant Laltools.Common.Bodies_List.List :=
4070-
Laltools.Common.List_Bodies_Of (Name, Self.Trace, Imprecise);
4071-
begin
4072-
Name := Bodies.Last_Element;
4073-
end;
4074-
40754067
Response.result.Append (To_Call_Hierarchy_Item (Name));
40764068

40774069
if Imprecise then
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
with P; use P;
2+
with Q; use Q;
3+
4+
procedure Main is
5+
C : Root'Class;
6+
begin
7+
Foo (C);
8+
end;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package P is
2+
type Root is abstract tagged null record;
3+
4+
procedure Foo (R : Root) is abstract;
5+
end P;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project P is
2+
end P;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
with P; use P;
2+
package Q is
3+
type Child is new Root with null record;
4+
overriding procedure Foo (R : Child) is null;
5+
end Q;
Lines changed: 329 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,329 @@
1+
[
2+
{
3+
"comment": [
4+
"Test that callHierarchy/incomingCalls works on abstract subps."
5+
]
6+
},
7+
{
8+
"start": {
9+
"cmd": [
10+
"${ALS}"
11+
]
12+
}
13+
},
14+
{
15+
"send": {
16+
"request": {
17+
"jsonrpc": "2.0",
18+
"id": "ada-1",
19+
"method": "initialize",
20+
"params": {
21+
"processId": 253542,
22+
"rootUri": "$URI{.}",
23+
"capabilities": {
24+
"workspace": {
25+
"applyEdit": true,
26+
"workspaceEdit": {},
27+
"didChangeConfiguration": {},
28+
"didChangeWatchedFiles": {},
29+
"executeCommand": {}
30+
},
31+
"textDocument": {
32+
"synchronization": {},
33+
"completion": {
34+
"dynamicRegistration": true,
35+
"completionItem": {
36+
"snippetSupport": true,
37+
"documentationFormat": [
38+
"plaintext",
39+
"markdown"
40+
]
41+
}
42+
},
43+
"hover": {},
44+
"signatureHelp": {},
45+
"declaration": {},
46+
"definition": {},
47+
"typeDefinition": {},
48+
"implementation": {},
49+
"references": {},
50+
"documentHighlight": {},
51+
"documentSymbol": {
52+
"hierarchicalDocumentSymbolSupport": true
53+
},
54+
"codeLens": {},
55+
"colorProvider": {},
56+
"formatting": {
57+
"dynamicRegistration": false
58+
},
59+
"rangeFormatting": {
60+
"dynamicRegistration": false
61+
},
62+
"onTypeFormatting": {
63+
"dynamicRegistration": false
64+
},
65+
"foldingRange": {
66+
"lineFoldingOnly": true
67+
},
68+
"selectionRange": {},
69+
"linkedEditingRange": {},
70+
"callHierarchy": {},
71+
"moniker": {}
72+
}
73+
}
74+
}
75+
},
76+
"wait": [
77+
{
78+
"id": "ada-1",
79+
"result": {
80+
"capabilities": {
81+
"textDocumentSync": 2,
82+
"completionProvider": {
83+
"triggerCharacters": [
84+
".",
85+
"("
86+
],
87+
"resolveProvider": false
88+
},
89+
"hoverProvider": true,
90+
"declarationProvider": true,
91+
"definitionProvider": true,
92+
"typeDefinitionProvider": true,
93+
"implementationProvider": true,
94+
"referencesProvider": true,
95+
"documentHighlightProvider": true,
96+
"documentSymbolProvider": {},
97+
"codeActionProvider": {},
98+
"documentFormattingProvider": true,
99+
"renameProvider": {},
100+
"foldingRangeProvider": true,
101+
"executeCommandProvider": {
102+
"commands": [
103+
"als-named-parameters",
104+
"als-refactor-imports",
105+
"als-refactor-remove-parameters",
106+
"als-refactor-move-parameter",
107+
"als-refactor-change-parameter-mode"
108+
]
109+
},
110+
"workspaceSymbolProvider": true,
111+
"callHierarchyProvider": {},
112+
"alsCalledByProvider": true,
113+
"alsCallsProvider": true,
114+
"alsShowDepsProvider": true,
115+
"alsReferenceKinds": [
116+
"reference",
117+
"access",
118+
"write",
119+
"call",
120+
"dispatching call",
121+
"parent",
122+
"child"
123+
]
124+
}
125+
}
126+
}
127+
]
128+
}
129+
},
130+
{
131+
"send": {
132+
"request": {
133+
"jsonrpc": "2.0",
134+
"method": "initialized"
135+
},
136+
"wait": []
137+
}
138+
},
139+
{
140+
"send": {
141+
"request": {
142+
"jsonrpc": "2.0",
143+
"method": "workspace/didChangeConfiguration",
144+
"params": {
145+
"settings": {
146+
"ada": {
147+
"scenarioVariables": {},
148+
"defaultCharset": "ISO-8859-1",
149+
"enableDiagnostics": false,
150+
"followSymlinks": false
151+
}
152+
}
153+
}
154+
},
155+
"wait": []
156+
}
157+
},
158+
{
159+
"send": {
160+
"request": {
161+
"jsonrpc": "2.0",
162+
"method": "textDocument/didOpen",
163+
"params": {
164+
"textDocument": {
165+
"uri": "$URI{p.ads}",
166+
"languageId": "Ada",
167+
"version": 0,
168+
"text": "package P is\n type Root is abstract tagged null record;\n\n procedure Foo (R : Root) is abstract;\nend P;\n"
169+
}
170+
}
171+
},
172+
"wait": []
173+
}
174+
},
175+
{
176+
"send": {
177+
"request": {
178+
"jsonrpc": "2.0",
179+
"id": "ada-6",
180+
"method": "textDocument/prepareCallHierarchy",
181+
"params": {
182+
"textDocument": {
183+
"uri": "$URI{p.ads}"
184+
},
185+
"position": {
186+
"line": 3,
187+
"character": 13
188+
}
189+
}
190+
},
191+
"wait": [
192+
{
193+
"id": "ada-6",
194+
"result": [
195+
{
196+
"name": "Foo",
197+
"kind": 12,
198+
"detail": "at p.ads (4:14)",
199+
"uri": "$URI{p.ads}",
200+
"range": {
201+
"start": {
202+
"line": 3,
203+
"character": 3
204+
},
205+
"end": {
206+
"line": 3,
207+
"character": 40
208+
}
209+
},
210+
"selectionRange": {
211+
"start": {
212+
"line": 3,
213+
"character": 13
214+
},
215+
"end": {
216+
"line": 3,
217+
"character": 16
218+
}
219+
}
220+
}
221+
]
222+
}
223+
]
224+
}
225+
},
226+
{
227+
"send": {
228+
"request": {
229+
"jsonrpc": "2.0",
230+
"id": "ada-7",
231+
"method": "callHierarchy/incomingCalls",
232+
"params": {
233+
"item": {
234+
"name": "",
235+
"kind": 12,
236+
"uri": "$URI{p.ads}",
237+
"range": {
238+
"start": {
239+
"line": 3,
240+
"character": 13
241+
},
242+
"end": {
243+
"line": 3,
244+
"character": 13
245+
}
246+
},
247+
"selectionRange": {
248+
"start": {
249+
"line": 3,
250+
"character": 13
251+
},
252+
"end": {
253+
"line": 3,
254+
"character": 13
255+
}
256+
}
257+
}
258+
}
259+
},
260+
"wait": [
261+
{
262+
"id": "ada-7",
263+
"result": [
264+
{
265+
"from": {
266+
"name": "Main",
267+
"kind": 12,
268+
"detail": "at main.adb (4:11)",
269+
"uri": "$URI{main.adb}",
270+
"range": {
271+
"start": {
272+
"line": 3,
273+
"character": 0
274+
},
275+
"end": {
276+
"line": 7,
277+
"character": 4
278+
}
279+
},
280+
"selectionRange": {
281+
"start": {
282+
"line": 3,
283+
"character": 10
284+
},
285+
"end": {
286+
"line": 3,
287+
"character": 14
288+
}
289+
}
290+
},
291+
"fromRanges": [
292+
{
293+
"start": {
294+
"line": 6,
295+
"character": 3
296+
},
297+
"end": {
298+
"line": 6,
299+
"character": 6
300+
}
301+
}
302+
]
303+
}
304+
]
305+
}
306+
]
307+
}
308+
},
309+
{
310+
"send": {
311+
"request": {
312+
"jsonrpc": "2.0",
313+
"id": "ada-8",
314+
"method": "shutdown"
315+
},
316+
"wait": [
317+
{
318+
"id": "ada-8",
319+
"result": null
320+
}
321+
]
322+
}
323+
},
324+
{
325+
"stop": {
326+
"exit_code": 0
327+
}
328+
}
329+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'callHierarchy.abstract_subps'

0 commit comments

Comments
 (0)