Skip to content

Commit ce6337d

Browse files
Create a parent node for with-clauses in documentSymbols request
For eng/ide/ada_language_server#1198
1 parent a688e0e commit ce6337d

File tree

6 files changed

+919
-908
lines changed

6 files changed

+919
-908
lines changed

source/ada/lsp-ada_handlers-symbols.adb

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,47 @@ package body LSP.Ada_Handlers.Symbols is
302302

303303
for Child of Node.Children loop
304304
if not Child.Is_Null then
305-
Walk (Child, Next_Level, Children);
305+
Walk
306+
(Node => Child,
307+
Nested_Level => Next_Level,
308+
Vector => Children);
306309
exit when Self.Is_Canceled.all;
307310
end if;
308311
end loop;
309312

310313
case Node.Kind is
314+
when Libadalang.Common.Ada_Ada_Node_List_Range =>
315+
316+
-- Check if we are dealing with a list of with-clauses nodes
317+
-- ('namespace' symbol kind). If yes, create a 'fake' parent
318+
-- item called 'With clauses' and put every with-clause within it.
319+
if Children.Length > 0 then
320+
declare
321+
First_Item : constant LSP.Structures.DocumentSymbol :=
322+
LSP.Structures.Get_DocumentSymbol_Constant_Reference
323+
(Children, 1);
324+
Package_Deps_Item : LSP.Structures.DocumentSymbol;
325+
begin
326+
if First_Item.kind = Namespace then
327+
Package_Deps_Item :=
328+
(name => VSS.Strings.To_Virtual_String
329+
("With clauses"),
330+
detail => VSS.Strings.Empty_Virtual_String,
331+
kind => Namespace,
332+
deprecated => (Is_Set => False),
333+
tags => LSP.Constants.Empty,
334+
a_range => First_Item.a_range,
335+
selectionRange => First_Item.a_range,
336+
children => Children,
337+
others => <>);
338+
Vector.Append (Package_Deps_Item);
339+
else
340+
for J in 1 .. Children.Length loop
341+
Vector.Append (Children (J));
342+
end loop;
343+
end if;
344+
end;
345+
end if;
311346
when Libadalang.Common.Ada_Basic_Decl =>
312347
declare
313348
Decl : constant Libadalang.Analysis.Basic_Decl :=

0 commit comments

Comments
 (0)