1
1
-- ----------------------------------------------------------------------------
2
2
-- Language Server Protocol --
3
3
-- --
4
- -- Copyright (C) 2018-2024 , AdaCore --
4
+ -- Copyright (C) 2018-2022 , AdaCore --
5
5
-- --
6
6
-- This is free software; you can redistribute it and/or modify it under --
7
7
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -78,10 +78,10 @@ package body LSP.Ada_Contexts is
78
78
-- Return the charset with which the context was initialized
79
79
80
80
procedure Find_All_References_In_Hierarchy
81
- (Self : Context;
82
- Decl : Libadalang.Analysis.Basic_Decl;
83
- Result_Kind : in out Libadalang.Common.Ref_Result_Kind ;
84
- Callback : not null access procedure
81
+ (Self : Context;
82
+ Decl : Libadalang.Analysis.Basic_Decl;
83
+ Imprecise : in out Boolean ;
84
+ Callback : not null access procedure
85
85
(Base_Id : Libadalang.Analysis.Base_Id;
86
86
Kind : Libadalang.Common.Ref_Result_Kind;
87
87
Cancel : in out Boolean));
@@ -208,15 +208,15 @@ package body LSP.Ada_Contexts is
208
208
-- ----------------------
209
209
210
210
function Find_All_Overrides
211
- (Self : Context;
212
- Decl : Libadalang.Analysis.Basic_Decl;
213
- Result_Kind : out Libadalang.Common.Ref_Result_Kind )
211
+ (Self : Context;
212
+ Decl : Libadalang.Analysis.Basic_Decl;
213
+ Imprecise_Results : out Boolean )
214
214
return Libadalang.Analysis.Basic_Decl_Array
215
215
is
216
216
Units : constant Libadalang.Analysis.Analysis_Unit_Array :=
217
217
Self.Analysis_Units;
218
218
begin
219
- Result_Kind := Libadalang.Common.Precise ;
219
+ Imprecise_Results := False ;
220
220
221
221
if Decl.Is_Null then
222
222
return (1 .. 0 => <>);
@@ -228,14 +228,13 @@ package body LSP.Ada_Contexts is
228
228
return Decl.P_Find_All_Overrides (Units);
229
229
exception
230
230
when E : Libadalang.Common.Property_Error =>
231
- Result_Kind := Libadalang.Common.Imprecise ;
231
+ Imprecise_Results := True ;
232
232
Self.Tracer.Trace_Exception (E, " in Find_All_Overrides (precise)" );
233
233
return Decl.P_Find_All_Overrides
234
234
(Units, Imprecise_Fallback => True);
235
235
end ;
236
236
exception
237
237
when E : Libadalang.Common.Property_Error =>
238
- Result_Kind := Libadalang.Common.Error;
239
238
Self.Tracer.Trace_Exception (E, " in Find_All_Overrides (imprecise)" );
240
239
return (1 .. 0 => <>);
241
240
end Find_All_Overrides ;
@@ -245,9 +244,9 @@ package body LSP.Ada_Contexts is
245
244
-- ------------------------------
246
245
247
246
function Find_All_Base_Declarations
248
- (Self : Context;
249
- Decl : Libadalang.Analysis.Basic_Decl;
250
- Result_Kind : out Libadalang.Common.Ref_Result_Kind )
247
+ (Self : Context;
248
+ Decl : Libadalang.Analysis.Basic_Decl;
249
+ Imprecise_Results : out Boolean )
251
250
return Libadalang.Analysis.Basic_Decl_Array
252
251
is
253
252
use Libadalang.Analysis;
@@ -260,7 +259,7 @@ package body LSP.Ada_Contexts is
260
259
Langkit_Support.Slocs.Start_Sloc (Left.Sloc_Range) =
261
260
Langkit_Support.Slocs.Start_Sloc (Right.Sloc_Range));
262
261
begin
263
- Result_Kind := Libadalang.Common.Precise ;
262
+ Imprecise_Results := False ;
264
263
265
264
if Decl.Is_Null then
266
265
return (1 .. 0 => <>);
@@ -294,7 +293,7 @@ package body LSP.Ada_Contexts is
294
293
exception
295
294
when E : Libadalang.Common.Property_Error =>
296
295
Self.Tracer.Trace_Exception (E, " in Find_All_Base_Declarations" );
297
- Result_Kind := Libadalang.Common.Error ;
296
+ Imprecise_Results := True ;
298
297
return (1 .. 0 => <>);
299
298
end Find_All_Base_Declarations ;
300
299
@@ -303,10 +302,10 @@ package body LSP.Ada_Contexts is
303
302
-- ------------------------------------
304
303
305
304
procedure Find_All_References_In_Hierarchy
306
- (Self : Context;
307
- Decl : Libadalang.Analysis.Basic_Decl;
308
- Result_Kind : in out Libadalang.Common.Ref_Result_Kind ;
309
- Callback : not null access procedure
305
+ (Self : Context;
306
+ Decl : Libadalang.Analysis.Basic_Decl;
307
+ Imprecise : in out Boolean ;
308
+ Callback : not null access procedure
310
309
(Base_Id : Libadalang.Analysis.Base_Id;
311
310
Kind : Libadalang.Common.Ref_Result_Kind;
312
311
Cancel : in out Boolean))
@@ -324,44 +323,31 @@ package body LSP.Ada_Contexts is
324
323
else
325
324
Decl);
326
325
327
- Overriding_Result_Kind : Libadalang.Common.Ref_Result_Kind;
328
- Bases_Result_Kind : Libadalang.Common.Ref_Result_Kind;
329
-
330
326
Overriding_Decls : constant Libadalang.Analysis.Basic_Decl_Array :=
331
327
Self.Find_All_Overrides
332
328
(Subp_Decl,
333
- Result_Kind => Overriding_Result_Kind );
329
+ Imprecise_Results => Imprecise );
334
330
335
331
Base_Decls : constant Libadalang.Analysis.Basic_Decl_Array :=
336
332
Self.Find_All_Base_Declarations
337
333
(Subp_Decl,
338
- Result_Kind => Bases_Result_Kind);
334
+ Imprecise_Results => Imprecise);
335
+
336
+ Hierarchy : constant Libadalang.Analysis.Basic_Decl_Array :=
337
+ Overriding_Decls & Base_Decls;
339
338
begin
340
- if Overriding_Result_Kind in Libadalang.Common.Error
341
- or else Bases_Result_Kind in Libadalang.Common.Error
342
- then
343
- Result_Kind := Libadalang.Common.Error;
344
- return ;
339
+ if Is_Param then
340
+ LSP.Ada_Id_Iterators.Find_All_Param_References_In_Hierarchy
341
+ (Param => Decl.As_Param_Spec,
342
+ Hierarchy => Hierarchy,
343
+ Units => Self.Analysis_Units,
344
+ Callback => Callback);
345
+ else
346
+ LSP.Ada_Id_Iterators.Find_All_Subp_References_In_Hierarchy
347
+ (Hierarchy => Hierarchy,
348
+ Tracer => Self.Tracer.all ,
349
+ Callback => Callback);
345
350
end if ;
346
-
347
- declare
348
- Hierarchy : constant Libadalang.Analysis.Basic_Decl_Array :=
349
- Overriding_Decls & Base_Decls;
350
- begin
351
-
352
- if Is_Param then
353
- LSP.Ada_Id_Iterators.Find_All_Param_References_In_Hierarchy
354
- (Param => Decl.As_Param_Spec,
355
- Hierarchy => Hierarchy,
356
- Units => Self.Analysis_Units,
357
- Callback => Callback);
358
- else
359
- LSP.Ada_Id_Iterators.Find_All_Subp_References_In_Hierarchy
360
- (Hierarchy => Hierarchy,
361
- Tracer => Self.Tracer.all ,
362
- Callback => Callback);
363
- end if ;
364
- end ;
365
351
end Find_All_References_In_Hierarchy ;
366
352
367
353
-- ------------------
@@ -383,7 +369,7 @@ package body LSP.Ada_Contexts is
383
369
procedure Get_References_For_Renaming
384
370
(Self : Context;
385
371
Definition : Libadalang.Analysis.Defining_Name;
386
- Imprecise_Results : out Libadalang.Common.Ref_Result_Kind ;
372
+ Imprecise_Results : out Boolean ;
387
373
Callback : not null access procedure
388
374
(Base_Id : Libadalang.Analysis.Base_Id;
389
375
Kind : Libadalang.Common.Ref_Result_Kind;
@@ -395,7 +381,7 @@ package body LSP.Ada_Contexts is
395
381
396
382
begin
397
383
-- Make sure to initialize the "out" variable Imprecise_Results
398
- Imprecise_Results := Libadalang.Common.Precise ;
384
+ Imprecise_Results := False ;
399
385
400
386
if Decl.Is_Null then
401
387
return ;
0 commit comments