@@ -44,27 +44,59 @@ package body LSP.GPR_Files.Symbols is
44
44
is
45
45
File : constant File_Access := Get_File (Provider, File_Name);
46
46
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
+
47
77
begin
48
- for Symbol of File.Document_Symbols.Document_Symbols loop
78
+ for Imported of File.Document_Symbols.Imported_Symbols loop
49
79
declare
50
80
Item : LSP.Structures.SymbolInformation;
51
81
Kind : constant LSP.Enumerations.SymbolKind :=
52
- To_Symbol_Kind (Symbol);
53
-
82
+ To_Symbol_Kind (Imported);
54
83
begin
55
84
Item :=
56
- (name => Symbol .Name,
85
+ (name => Imported .Name,
57
86
kind => Kind,
58
87
tags => LSP.Constants.Empty,
59
88
deprecated => <>,
60
89
location =>
61
90
(uri => Document_URI,
62
- a_range => To_Range (Symbol ),
91
+ a_range => To_Range (Imported ),
63
92
alsKind => LSP.Constants.Empty),
64
93
containerName => <>);
65
94
Result.Append (Item);
66
95
end ;
67
96
end loop ;
97
+
98
+ Walk (File.Document_Symbols.Project);
99
+
68
100
end Get_Symbols ;
69
101
70
102
-- -------------------------
@@ -81,56 +113,101 @@ package body LSP.GPR_Files.Symbols is
81
113
82
114
File : constant File_Access := Get_File (Provider, File_Name);
83
115
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 => <>);
95
136
begin
96
- for Symbol of Symbols loop
137
+ for Imported of File.Document_Symbols.Imported_Symbols loop
97
138
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 => <>);
110
151
111
152
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);
128
154
end ;
129
155
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 ;
131
205
132
206
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;
134
211
end Get_Symbols_Hierarchy ;
135
212
136
213
-- ------------
@@ -146,7 +223,6 @@ package body LSP.GPR_Files.Symbols is
146
223
an_end =>
147
224
(line => Symbol.End_Position.Line - 1 ,
148
225
character => Symbol.End_Position.Column - 1 ));
149
- -- XXX Incorrect conversion
150
226
151
227
-- ------------------
152
228
-- To_Symbol_Kind --
@@ -168,6 +244,10 @@ package body LSP.GPR_Files.Symbols is
168
244
return LSP.Enumerations.Property;
169
245
when K_Package =>
170
246
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;
171
251
end case ;
172
252
end To_Symbol_Kind ;
173
253
0 commit comments