@@ -44,27 +44,59 @@ package body LSP.GPR_Files.Symbols is
4444 is
4545 File : constant File_Access := Get_File (Provider, File_Name);
4646
47+ procedure Walk (Symbol : LSP.GPR_Files.Symbol);
48+
49+ -- --------
50+ -- Walk --
51+ -- --------
52+
53+ procedure Walk
54+ (Symbol : LSP.GPR_Files.Symbol) is
55+ Item : constant LSP.Structures.SymbolInformation :=
56+ (name => Symbol.Name,
57+ kind => To_Symbol_Kind (Symbol),
58+ tags => LSP.Constants.Empty,
59+ deprecated => <>,
60+ location =>
61+ (uri => Document_URI,
62+ a_range => To_Range (Symbol),
63+ alsKind => LSP.Constants.Empty),
64+ containerName => <>);
65+ C : constant LSP.GPR_Files.Symbol_List_Maps.Cursor :=
66+ File.Document_Symbols.Children_Map.Find
67+ (Symbol.Id);
68+ begin
69+ Result.Append (Item);
70+ if Symbol_List_Maps.Has_Element (C) then
71+ for Symbol of Symbol_List_Maps.Element (C) loop
72+ Walk (Symbol);
73+ end loop ;
74+ end if ;
75+ end Walk ;
76+
4777 begin
48- for Symbol of File.Document_Symbols.Document_Symbols loop
78+ for Imported of File.Document_Symbols.Imported_Symbols loop
4979 declare
5080 Item : LSP.Structures.SymbolInformation;
5181 Kind : constant LSP.Enumerations.SymbolKind :=
52- To_Symbol_Kind (Symbol);
53-
82+ To_Symbol_Kind (Imported);
5483 begin
5584 Item :=
56- (name => Symbol .Name,
85+ (name => Imported .Name,
5786 kind => Kind,
5887 tags => LSP.Constants.Empty,
5988 deprecated => <>,
6089 location =>
6190 (uri => Document_URI,
62- a_range => To_Range (Symbol ),
91+ a_range => To_Range (Imported ),
6392 alsKind => LSP.Constants.Empty),
6493 containerName => <>);
6594 Result.Append (Item);
6695 end ;
6796 end loop ;
97+
98+ Walk (File.Document_Symbols.Project);
99+
68100 end Get_Symbols ;
69101
70102 -- -------------------------
@@ -81,56 +113,101 @@ package body LSP.GPR_Files.Symbols is
81113
82114 File : constant File_Access := Get_File (Provider, File_Name);
83115
84- procedure Walk
85- (Symbols : LSP.GPR_Files.Symbol_List;
86- Result : in out LSP.Structures.DocumentSymbol_Vector);
87-
88- -- --------
89- -- Walk --
90- -- --------
91-
92- procedure Walk
93- (Symbols : LSP.GPR_Files.Symbol_List;
94- Result : in out LSP.Structures.DocumentSymbol_Vector) is
116+ procedure Append_Project ;
117+ procedure Append_With_Clauses ;
118+
119+ -- -----------------------
120+ -- Append_With_Clauses --
121+ -- -----------------------
122+
123+ procedure Append_With_Clauses is
124+ Item : LSP.Structures.DocumentSymbol :=
125+ (name => " with clauses" ,
126+ detail => <>,
127+ kind => LSP.Enumerations.Namespace,
128+ tags => LSP.Constants.Empty,
129+ deprecated => <>,
130+ a_range => ((0 , 0 ), (0 , 0 )),
131+ selectionRange => ((0 , 0 ), (0 , 0 )),
132+ alsIsDeclaration => (Is_Set => False),
133+ alsIsAdaProcedure => <>,
134+ alsVisibility => <>,
135+ children => <>);
95136 begin
96- for Symbol of Symbols loop
137+ for Imported of File.Document_Symbols.Imported_Symbols loop
97138 declare
98- Item : LSP.Structures.DocumentSymbol :=
99- (name => Symbol .Name,
100- detail => <>,
101- kind => To_Symbol_Kind (Symbol ),
102- tags => LSP.Constants.Empty,
103- deprecated => <>,
104- a_range => To_Range (Symbol ),
105- selectionRange => To_Range (Symbol ),
106- alsIsDeclaration => (Is_Set => False),
107- alsIsAdaProcedure => <>,
108- alsVisibility => <>,
109- children => <>);
139+ S : constant LSP.Structures.DocumentSymbol :=
140+ (name => Imported .Name,
141+ detail => <>,
142+ kind => To_Symbol_Kind (Imported ),
143+ tags => LSP.Constants.Empty,
144+ deprecated => <>,
145+ a_range => To_Range (Imported ),
146+ selectionRange => To_Range (Imported ),
147+ alsIsDeclaration => (Is_Set => False),
148+ alsIsAdaProcedure => <>,
149+ alsVisibility => <>,
150+ children => <>);
110151
111152 begin
112- if Symbol.Children /= Gpr_Parser.Common.No_Token then
113- declare
114- C : constant LSP.GPR_Files.Symbols_Maps.Cursor :=
115- File.Document_Symbols.Children.Find
116- (Symbol.Children);
117-
118- begin
119- if LSP.GPR_Files.Symbols_Maps.Has_Element (C) then
120- Walk
121- (LSP.GPR_Files.Symbols_Maps.Element (C),
122- Item.children);
123- end if ;
124- end ;
125- end if ;
126-
127- Result.Append (Item);
153+ Item.children.Append (S);
128154 end ;
129155 end loop ;
130- end Walk ;
156+
157+ Result.Append (Item);
158+ end Append_With_Clauses ;
159+
160+ -- ------------------
161+ -- Append_Project --
162+ -- ------------------
163+
164+ procedure Append_Project is
165+
166+ procedure Walk
167+ (Symbol : LSP.GPR_Files.Symbol;
168+ Result : in out LSP.Structures.DocumentSymbol_Vector);
169+
170+ -- --------
171+ -- Walk --
172+ -- --------
173+
174+ procedure Walk
175+ (Symbol : LSP.GPR_Files.Symbol;
176+ Result : in out LSP.Structures.DocumentSymbol_Vector) is
177+ Item : LSP.Structures.DocumentSymbol :=
178+ (name => Symbol.Name,
179+ detail => <>,
180+ kind => To_Symbol_Kind (Symbol),
181+ tags => LSP.Constants.Empty,
182+ deprecated => <>,
183+ a_range => To_Range (Symbol),
184+ selectionRange => To_Range (Symbol),
185+ alsIsDeclaration => (Is_Set => False),
186+ alsIsAdaProcedure => <>,
187+ alsVisibility => <>,
188+ children => <>);
189+
190+ C : constant LSP.GPR_Files.Symbol_List_Maps.Cursor :=
191+ File.Document_Symbols.Children_Map.Find
192+ (Symbol.Id);
193+ begin
194+ if LSP.GPR_Files.Symbol_List_Maps.Has_Element (C) then
195+ for S of LSP.GPR_Files.Symbol_List_Maps.Element (C) loop
196+ Walk (S, Item.children);
197+ end loop ;
198+ end if ;
199+ Result.Append (Item);
200+ end Walk ;
201+
202+ begin
203+ Walk (File.Document_Symbols.Project, Result);
204+ end Append_Project ;
131205
132206 begin
133- Walk (File.Document_Symbols.Document_Symbols, Result);
207+ if not File.Document_Symbols.Imported_Symbols.Is_Empty then
208+ Append_With_Clauses;
209+ end if ;
210+ Append_Project;
134211 end Get_Symbols_Hierarchy ;
135212
136213 -- ------------
@@ -146,7 +223,6 @@ package body LSP.GPR_Files.Symbols is
146223 an_end =>
147224 (line => Symbol.End_Position.Line - 1 ,
148225 character => Symbol.End_Position.Column - 1 ));
149- -- XXX Incorrect conversion
150226
151227 -- ------------------
152228 -- To_Symbol_Kind --
@@ -168,6 +244,10 @@ package body LSP.GPR_Files.Symbols is
168244 return LSP.Enumerations.Property;
169245 when K_Package =>
170246 return LSP.Enumerations.A_Package;
247+ when K_Case =>
248+ return LSP.Enumerations.A_Package;
249+ when K_When =>
250+ return LSP.Enumerations.A_Package;
171251 end case ;
172252 end To_Symbol_Kind ;
173253
0 commit comments