Skip to content

Commit baf0cfa

Browse files
committed
Merge branch 'laltools_issue_163' into 'edge'
Replace Boolean imprecise by Ref_Result_Kind See merge request eng/ide/ada_language_server!1528
2 parents 98c4407 + fae9c29 commit baf0cfa

7 files changed

+58
-48
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ test-vscode-extension:
142142

143143
# Run VSCode extension tests
144144
- echo -e "\e[0Ksection_start:`date +%s`:test_vscode[collapsed=true]\r\e[0Kanod test vscode-extension"
145-
- anod test vscode-extension --qualifier=$ACI_TRACK_QUALIFIER --minimal
145+
- anod test vscode-extension $ACI_TRACK_QUALIFIER --minimal
146146

147147
- VSCODE_BUILD_SPACE=$(anod info test vscode-extension $ACI_TRACK_QUALIFIER --show working_dir)
148148
- echo -e "\e[0Ksection_end:`date +%s`:test_vscode\r\e[0K"

source/ada/lsp-ada_contexts.adb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2022, AdaCore --
4+
-- Copyright (C) 2018-2024, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -80,7 +80,7 @@ package body LSP.Ada_Contexts is
8080
procedure Find_All_References_In_Hierarchy
8181
(Self : Context;
8282
Decl : Libadalang.Analysis.Basic_Decl;
83-
Imprecise : in out Boolean;
83+
Imprecise : in out Libadalang.Common.Ref_Result_Kind;
8484
Callback : not null access procedure
8585
(Base_Id : Libadalang.Analysis.Base_Id;
8686
Kind : Libadalang.Common.Ref_Result_Kind;
@@ -210,13 +210,13 @@ package body LSP.Ada_Contexts is
210210
function Find_All_Overrides
211211
(Self : Context;
212212
Decl : Libadalang.Analysis.Basic_Decl;
213-
Imprecise_Results : out Boolean)
213+
Imprecise_Results : out Libadalang.Common.Ref_Result_Kind)
214214
return Libadalang.Analysis.Basic_Decl_Array
215215
is
216216
Units : constant Libadalang.Analysis.Analysis_Unit_Array :=
217217
Self.Analysis_Units;
218218
begin
219-
Imprecise_Results := False;
219+
Imprecise_Results := Libadalang.Common.Precise;
220220

221221
if Decl.Is_Null then
222222
return (1 .. 0 => <>);
@@ -228,7 +228,7 @@ package body LSP.Ada_Contexts is
228228
return Decl.P_Find_All_Overrides (Units);
229229
exception
230230
when E : Libadalang.Common.Property_Error =>
231-
Imprecise_Results := True;
231+
Imprecise_Results := Libadalang.Common.Imprecise;
232232
Self.Tracer.Trace_Exception (E, "in Find_All_Overrides (precise)");
233233
return Decl.P_Find_All_Overrides
234234
(Units, Imprecise_Fallback => True);
@@ -246,7 +246,7 @@ package body LSP.Ada_Contexts is
246246
function Find_All_Base_Declarations
247247
(Self : Context;
248248
Decl : Libadalang.Analysis.Basic_Decl;
249-
Imprecise_Results : out Boolean)
249+
Imprecise_Results : out Libadalang.Common.Ref_Result_Kind)
250250
return Libadalang.Analysis.Basic_Decl_Array
251251
is
252252
use Libadalang.Analysis;
@@ -259,7 +259,7 @@ package body LSP.Ada_Contexts is
259259
Langkit_Support.Slocs.Start_Sloc (Left.Sloc_Range) =
260260
Langkit_Support.Slocs.Start_Sloc (Right.Sloc_Range));
261261
begin
262-
Imprecise_Results := False;
262+
Imprecise_Results := Libadalang.Common.Precise;
263263

264264
if Decl.Is_Null then
265265
return (1 .. 0 => <>);
@@ -293,7 +293,7 @@ package body LSP.Ada_Contexts is
293293
exception
294294
when E : Libadalang.Common.Property_Error =>
295295
Self.Tracer.Trace_Exception (E, "in Find_All_Base_Declarations");
296-
Imprecise_Results := True;
296+
Imprecise_Results := Libadalang.Common.Imprecise;
297297
return (1 .. 0 => <>);
298298
end Find_All_Base_Declarations;
299299

@@ -304,7 +304,7 @@ package body LSP.Ada_Contexts is
304304
procedure Find_All_References_In_Hierarchy
305305
(Self : Context;
306306
Decl : Libadalang.Analysis.Basic_Decl;
307-
Imprecise : in out Boolean;
307+
Imprecise : in out Libadalang.Common.Ref_Result_Kind;
308308
Callback : not null access procedure
309309
(Base_Id : Libadalang.Analysis.Base_Id;
310310
Kind : Libadalang.Common.Ref_Result_Kind;
@@ -369,7 +369,7 @@ package body LSP.Ada_Contexts is
369369
procedure Get_References_For_Renaming
370370
(Self : Context;
371371
Definition : Libadalang.Analysis.Defining_Name;
372-
Imprecise_Results : out Boolean;
372+
Imprecise_Results : out Libadalang.Common.Ref_Result_Kind;
373373
Callback : not null access procedure
374374
(Base_Id : Libadalang.Analysis.Base_Id;
375375
Kind : Libadalang.Common.Ref_Result_Kind;
@@ -381,7 +381,7 @@ package body LSP.Ada_Contexts is
381381

382382
begin
383383
-- Make sure to initialize the "out" variable Imprecise_Results
384-
Imprecise_Results := False;
384+
Imprecise_Results := Libadalang.Common.Precise;
385385

386386
if Decl.Is_Null then
387387
return;

source/ada/lsp-ada_contexts.ads

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2019, AdaCore --
4+
-- Copyright (C) 2018-2014, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -100,7 +100,7 @@ package LSP.Ada_Contexts is
100100
function Find_All_Overrides
101101
(Self : Context;
102102
Decl : Libadalang.Analysis.Basic_Decl;
103-
Imprecise_Results : out Boolean)
103+
Imprecise_Results : out Libadalang.Common.Ref_Result_Kind)
104104
return Libadalang.Analysis.Basic_Decl_Array;
105105
-- Finds all overriding subprograms of the given basic declaration.
106106
-- This is used to propose all the implementations of a given subprogram
@@ -112,7 +112,7 @@ package LSP.Ada_Contexts is
112112
function Find_All_Base_Declarations
113113
(Self : Context;
114114
Decl : Libadalang.Analysis.Basic_Decl;
115-
Imprecise_Results : out Boolean)
115+
Imprecise_Results : out Libadalang.Common.Ref_Result_Kind)
116116
return Libadalang.Analysis.Basic_Decl_Array;
117117
-- Given a subprogram declaration in Decl, find all the base subprograms
118118
-- that it inherits, not including self.
@@ -145,7 +145,7 @@ package LSP.Ada_Contexts is
145145
procedure Get_References_For_Renaming
146146
(Self : Context;
147147
Definition : Libadalang.Analysis.Defining_Name;
148-
Imprecise_Results : out Boolean;
148+
Imprecise_Results : out Libadalang.Common.Ref_Result_Kind;
149149
Callback : not null access procedure
150150
(Base_Id : Libadalang.Analysis.Base_Id;
151151
Kind : Libadalang.Common.Ref_Result_Kind;

source/ada/lsp-ada_definition.adb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ package body LSP.Ada_Definition is
124124
Decl_For_Find_Overrides : Libadalang.Analysis.Basic_Decl;
125125
Entry_Decl_Node : Libadalang.Analysis.Entry_Decl;
126126

127-
Ignore : Boolean;
127+
Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind;
128+
128129
begin
129130
if Self.Contexts.Is_Empty then
130131
-- No more contexts to process, sort and return collected results
@@ -241,12 +242,12 @@ package body LSP.Ada_Definition is
241242
Overridings : constant Libadalang.Analysis.Basic_Decl_Array :=
242243
Context.Find_All_Overrides
243244
(Decl_For_Find_Overrides,
244-
Imprecise_Results => Ignore);
245+
Imprecise_Results => Imprecise_Ignore);
245246

246247
Bases : constant Libadalang.Analysis.Basic_Decl_Array :=
247248
Context.Find_All_Base_Declarations
248249
(Decl_For_Find_Overrides,
249-
Imprecise_Results => Ignore);
250+
Imprecise_Results => Imprecise_Ignore);
250251
begin
251252
for Subp of Bases loop
252253
Self.Parent.Context.Append_Location

source/ada/lsp-ada_handlers-call_hierarchy.adb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2023, AdaCore --
4+
-- Copyright (C) 2018-2024, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -313,15 +313,16 @@ package body LSP.Ada_Handlers.Call_Hierarchy is
313313
end if;
314314
end Callback;
315315

316-
Imprecise : Boolean := False;
316+
Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind :=
317+
Libadalang.Common.No_Ref;
317318
Cursor : Laltools.Common.References_By_Subprogram.Cursor;
318319

319320
begin
320321
Laltools.Call_Hierarchy.Find_Outgoing_Calls
321322
(Definition => Definition,
322323
Callback => Callback'Access,
323324
Trace => Trace,
324-
Imprecise => Imprecise);
325+
Imprecise => Imprecise_Ignore);
325326

326327
Cursor := Result.First;
327328
-- Iterate through all the results, converting them to protocol

source/ada/lsp-ada_handlers.adb

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2023, AdaCore --
4+
-- Copyright (C) 2018-2024, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -140,7 +140,7 @@ package body LSP.Ada_Handlers is
140140
Id : LSP.Structures.Integer_Or_Virtual_String;
141141
Context : LSP.Ada_Contexts.Context;
142142
Name_Node : Libadalang.Analysis.Name;
143-
Imprecise : out Boolean)
143+
Imprecise : out Libadalang.Common.Ref_Result_Kind)
144144
return Libadalang.Analysis.Defining_Name;
145145
-- Toplayer Resolve_Name based on Laltools.Common.Resolve_Name.
146146
-- This function is handling Imprecise and Error results during Nameres by
@@ -1737,7 +1737,8 @@ package body LSP.Ada_Handlers is
17371737
On_Defining_Name : Boolean := False;
17381738
-- Set to True if we are on a denfining name node
17391739

1740-
Imprecise : Boolean;
1740+
Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind;
1741+
17411742
begin
17421743
if Name_Node.Is_Null then
17431744
return;
@@ -1754,7 +1755,7 @@ package body LSP.Ada_Handlers is
17541755
Id => Id,
17551756
Context => C.all,
17561757
Name_Node => Name_Node,
1757-
Imprecise => Imprecise);
1758+
Imprecise => Imprecise_Ignore);
17581759
else
17591760
On_Defining_Name := True;
17601761
end if;
@@ -1806,16 +1807,15 @@ package body LSP.Ada_Handlers is
18061807

18071808
if not Decl_For_Find_Overrides.Is_Null then
18081809
declare
1809-
Is_Imprecise : Boolean;
18101810
Overridings : constant Libadalang.Analysis.Basic_Decl_Array :=
18111811
C.Find_All_Overrides
18121812
(Decl_For_Find_Overrides,
1813-
Imprecise_Results => Is_Imprecise);
1813+
Imprecise_Results => Imprecise_Ignore);
18141814

18151815
Bases : constant Libadalang.Analysis.Basic_Decl_Array :=
18161816
C.Find_All_Base_Declarations
18171817
(Decl_For_Find_Overrides,
1818-
Imprecise_Results => Is_Imprecise);
1818+
Imprecise_Results => Imprecise_Ignore);
18191819
begin
18201820
for Subp of Bases loop
18211821
Self.Append_Location
@@ -2742,9 +2742,11 @@ package body LSP.Ada_Handlers is
27422742
end Update_Response;
27432743

27442744
Definition : Libadalang.Analysis.Defining_Name;
2745-
Imprecise : Boolean := False;
27462745
Decl : Libadalang.Analysis.Basic_Decl;
27472746

2747+
Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind :=
2748+
Libadalang.Common.No_Ref;
2749+
27482750
begin
27492751
if Name_Node.Is_Null then
27502752
return;
@@ -2755,7 +2757,7 @@ package body LSP.Ada_Handlers is
27552757
Id => Id,
27562758
Context => C.all,
27572759
Name_Node => Name_Node,
2758-
Imprecise => Imprecise);
2760+
Imprecise => Imprecise_Ignore);
27592761

27602762
-- If we didn't find a definition, give up for this context
27612763
if Definition.Is_Null then
@@ -2764,7 +2766,8 @@ package body LSP.Ada_Handlers is
27642766

27652767
-- First list the bodies of this definition
27662768
Update_Response
2767-
(Laltools.Common.List_Bodies_Of (Definition, Trace, Imprecise),
2769+
(Laltools.Common.List_Bodies_Of
2770+
(Definition, Trace, Imprecise_Ignore),
27682771
LSP.Constants.Empty);
27692772

27702773
-- Then list the bodies of the parent implementations
@@ -2777,19 +2780,19 @@ package body LSP.Ada_Handlers is
27772780
(Display_Method_Policy = Usage_And_Abstract_Only
27782781
and then Decl.Kind in Ada_Abstract_Subp_Decl_Range)
27792782
then
2780-
for Subp of C.Find_All_Base_Declarations (Decl, Imprecise)
2783+
for Subp of C.Find_All_Base_Declarations (Decl, Imprecise_Ignore)
27812784
loop
27822785
Update_Response
27832786
(Laltools.Common.List_Bodies_Of
2784-
(Subp.P_Defining_Name, Trace, Imprecise),
2787+
(Subp.P_Defining_Name, Trace, Imprecise_Ignore),
27852788
Is_Parent);
27862789
end loop;
27872790

27882791
-- And finally the bodies of child implementations
2789-
for Subp of C.Find_All_Overrides (Decl, Imprecise) loop
2792+
for Subp of C.Find_All_Overrides (Decl, Imprecise_Ignore) loop
27902793
Update_Response
27912794
(Laltools.Common.List_Bodies_Of
2792-
(Subp.P_Defining_Name, Trace, Imprecise),
2795+
(Subp.P_Defining_Name, Trace, Imprecise_Ignore),
27932796
Is_Child);
27942797
end loop;
27952798
end if;
@@ -3310,7 +3313,11 @@ package body LSP.Ada_Handlers is
33103313

33113314
Defining_Name : Libadalang.Analysis.Defining_Name;
33123315

3313-
Imprecise : Boolean := False;
3316+
Imprecise : Libadalang.Common.Ref_Result_Kind :=
3317+
Libadalang.Common.No_Ref;
3318+
3319+
use type Libadalang.Common.Ref_Result_Kind;
3320+
33143321
begin
33153322
if not Name_Node.Is_Null then
33163323
Defining_Name := Resolve_Name
@@ -3323,7 +3330,7 @@ package body LSP.Ada_Handlers is
33233330

33243331
if not Name_Node.Is_Null
33253332
and then not Defining_Name.Is_Null
3326-
and then not Imprecise
3333+
and then Imprecise in Libadalang.Common.Precise
33273334
then
33283335
-- Success only if the node is a name and can be resolved precisely
33293336
Response :=
@@ -3923,7 +3930,9 @@ package body LSP.Ada_Handlers is
39233930
Response : LSP.Structures.Definition_Result (LSP.Structures.Variant_1);
39243931
Vector : LSP.Structures.Location_Vector renames Response.Variant_1;
39253932
Filter : LSP.Locations.File_Span_Sets.Set;
3926-
Imprecise : Boolean := False;
3933+
3934+
Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind :=
3935+
Libadalang.Common.No_Ref;
39273936

39283937
procedure Resolve_In_Context (C : LSP.Ada_Context_Sets.Context_Access);
39293938
-- Utility function to gather results on one context
@@ -3960,7 +3969,7 @@ package body LSP.Ada_Handlers is
39603969
Id => Id,
39613970
Context => C.all,
39623971
Name_Node => Type_Expr.P_Type_Name,
3963-
Imprecise => Imprecise);
3972+
Imprecise => Imprecise_Ignore);
39643973
end if;
39653974
end;
39663975
else
@@ -4064,19 +4073,18 @@ package body LSP.Ada_Handlers is
40644073
Id : LSP.Structures.Integer_Or_Virtual_String;
40654074
Context : LSP.Ada_Contexts.Context;
40664075
Name_Node : Libadalang.Analysis.Name;
4067-
Imprecise : out Boolean)
4076+
Imprecise : out Libadalang.Common.Ref_Result_Kind)
40684077
return Libadalang.Analysis.Defining_Name
40694078
is
40704079
Definition : Libadalang.Analysis.Defining_Name;
4071-
Result_Kind : Libadalang.Common.Ref_Result_Kind;
40724080
Trace : constant GNATCOLL.Traces.Trace_Handle :=
40734081
LSP.GNATCOLL_Tracers.Handle (Self.Tracer.all);
40744082
Id_Image : constant String :=
40754083
(if Id.Is_Integer
40764084
then Id.Integer'Image
40774085
else VSS.Strings.Conversions.To_UTF_8_String (Id.Virtual_String));
40784086
begin
4079-
Imprecise := False;
4087+
Imprecise := Libadalang.Common.No_Ref;
40804088

40814089
if Name_Node.Is_Null then
40824090
-- Internal tracing of resolve on null node
@@ -4086,9 +4094,9 @@ package body LSP.Ada_Handlers is
40864094

40874095
-- Find the definition
40884096
Definition := Laltools.Common.Resolve_Name
4089-
(Name_Node, Trace, Result_Kind);
4097+
(Name_Node, Trace, Imprecise);
40904098

4091-
if Result_Kind in Libadalang.Common.Error then
4099+
if Imprecise in Libadalang.Common.Error then
40924100
declare
40934101
Err_Msg : constant String :=
40944102
"Failed to resolve " & Name_Node.Image;
@@ -4138,7 +4146,7 @@ package body LSP.Ada_Handlers is
41384146
return Libadalang.Analysis.No_Defining_Name;
41394147
end;
41404148

4141-
elsif Result_Kind in Libadalang.Common.Imprecise then
4149+
elsif Imprecise in Libadalang.Common.Imprecise then
41424150
-- Internal tracing of imprecise resolving
41434151
Self.Tracer.Trace
41444152
("Imprecise result when resolving "
@@ -4147,7 +4155,6 @@ package body LSP.Ada_Handlers is
41474155
& VSS.Strings.Conversions.To_UTF_8_String (Context.Id)
41484156
& " for request "
41494157
& Id_Image);
4150-
Imprecise := True;
41514158
end if;
41524159

41534160
return Definition;

0 commit comments

Comments
 (0)