Skip to content

Commit be6d142

Browse files
Revert edge on master
To avoid conflicts in the future. For eng/shared/automatic-merges#222
1 parent 4c50e83 commit be6d142

8 files changed

+133
-167
lines changed

source/ada/lsp-ada_contexts.adb

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2024, AdaCore --
4+
-- Copyright (C) 2018-2022, 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- --
@@ -78,10 +78,10 @@ package body LSP.Ada_Contexts is
7878
-- Return the charset with which the context was initialized
7979

8080
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
8585
(Base_Id : Libadalang.Analysis.Base_Id;
8686
Kind : Libadalang.Common.Ref_Result_Kind;
8787
Cancel : in out Boolean));
@@ -208,15 +208,15 @@ package body LSP.Ada_Contexts is
208208
------------------------
209209

210210
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)
214214
return Libadalang.Analysis.Basic_Decl_Array
215215
is
216216
Units : constant Libadalang.Analysis.Analysis_Unit_Array :=
217217
Self.Analysis_Units;
218218
begin
219-
Result_Kind := Libadalang.Common.Precise;
219+
Imprecise_Results := False;
220220

221221
if Decl.Is_Null then
222222
return (1 .. 0 => <>);
@@ -228,14 +228,13 @@ package body LSP.Ada_Contexts is
228228
return Decl.P_Find_All_Overrides (Units);
229229
exception
230230
when E : Libadalang.Common.Property_Error =>
231-
Result_Kind := Libadalang.Common.Imprecise;
231+
Imprecise_Results := True;
232232
Self.Tracer.Trace_Exception (E, "in Find_All_Overrides (precise)");
233233
return Decl.P_Find_All_Overrides
234234
(Units, Imprecise_Fallback => True);
235235
end;
236236
exception
237237
when E : Libadalang.Common.Property_Error =>
238-
Result_Kind := Libadalang.Common.Error;
239238
Self.Tracer.Trace_Exception (E, "in Find_All_Overrides (imprecise)");
240239
return (1 .. 0 => <>);
241240
end Find_All_Overrides;
@@ -245,9 +244,9 @@ package body LSP.Ada_Contexts is
245244
--------------------------------
246245

247246
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)
251250
return Libadalang.Analysis.Basic_Decl_Array
252251
is
253252
use Libadalang.Analysis;
@@ -260,7 +259,7 @@ package body LSP.Ada_Contexts is
260259
Langkit_Support.Slocs.Start_Sloc (Left.Sloc_Range) =
261260
Langkit_Support.Slocs.Start_Sloc (Right.Sloc_Range));
262261
begin
263-
Result_Kind := Libadalang.Common.Precise;
262+
Imprecise_Results := False;
264263

265264
if Decl.Is_Null then
266265
return (1 .. 0 => <>);
@@ -294,7 +293,7 @@ package body LSP.Ada_Contexts is
294293
exception
295294
when E : Libadalang.Common.Property_Error =>
296295
Self.Tracer.Trace_Exception (E, "in Find_All_Base_Declarations");
297-
Result_Kind := Libadalang.Common.Error;
296+
Imprecise_Results := True;
298297
return (1 .. 0 => <>);
299298
end Find_All_Base_Declarations;
300299

@@ -303,10 +302,10 @@ package body LSP.Ada_Contexts is
303302
--------------------------------------
304303

305304
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
310309
(Base_Id : Libadalang.Analysis.Base_Id;
311310
Kind : Libadalang.Common.Ref_Result_Kind;
312311
Cancel : in out Boolean))
@@ -324,44 +323,31 @@ package body LSP.Ada_Contexts is
324323
else
325324
Decl);
326325

327-
Overriding_Result_Kind : Libadalang.Common.Ref_Result_Kind;
328-
Bases_Result_Kind : Libadalang.Common.Ref_Result_Kind;
329-
330326
Overriding_Decls : constant Libadalang.Analysis.Basic_Decl_Array :=
331327
Self.Find_All_Overrides
332328
(Subp_Decl,
333-
Result_Kind => Overriding_Result_Kind);
329+
Imprecise_Results => Imprecise);
334330

335331
Base_Decls : constant Libadalang.Analysis.Basic_Decl_Array :=
336332
Self.Find_All_Base_Declarations
337333
(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;
339338
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);
345350
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;
365351
end Find_All_References_In_Hierarchy;
366352

367353
--------------------
@@ -383,7 +369,7 @@ package body LSP.Ada_Contexts is
383369
procedure Get_References_For_Renaming
384370
(Self : Context;
385371
Definition : Libadalang.Analysis.Defining_Name;
386-
Imprecise_Results : out Libadalang.Common.Ref_Result_Kind;
372+
Imprecise_Results : out Boolean;
387373
Callback : not null access procedure
388374
(Base_Id : Libadalang.Analysis.Base_Id;
389375
Kind : Libadalang.Common.Ref_Result_Kind;
@@ -395,7 +381,7 @@ package body LSP.Ada_Contexts is
395381

396382
begin
397383
-- Make sure to initialize the "out" variable Imprecise_Results
398-
Imprecise_Results := Libadalang.Common.Precise;
384+
Imprecise_Results := False;
399385

400386
if Decl.Is_Null then
401387
return;

source/ada/lsp-ada_contexts.ads

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2014, AdaCore --
4+
-- Copyright (C) 2018-2019, 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- --
@@ -98,26 +98,26 @@ package LSP.Ada_Contexts is
9898
-- context.
9999

100100
function Find_All_Overrides
101-
(Self : Context;
102-
Decl : Libadalang.Analysis.Basic_Decl;
103-
Result_Kind : out Libadalang.Common.Ref_Result_Kind)
101+
(Self : Context;
102+
Decl : Libadalang.Analysis.Basic_Decl;
103+
Imprecise_Results : out Boolean)
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
107107
-- when textDocument/definition requests happen on dispatching calls.
108-
-- Result_Kind indicates if LAL encountered an Error or if the result are
109-
-- Imprecise.
108+
-- Imprecise_Results is set to True if we don't know whether the results
109+
-- are precise.
110110
-- Returns an empty array if Decl is null.
111111

112112
function Find_All_Base_Declarations
113-
(Self : Context;
114-
Decl : Libadalang.Analysis.Basic_Decl;
115-
Result_Kind : out Libadalang.Common.Ref_Result_Kind)
113+
(Self : Context;
114+
Decl : Libadalang.Analysis.Basic_Decl;
115+
Imprecise_Results : out Boolean)
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.
119-
-- Result_Kind indicates if LAL encountered an Error or if the result are
120-
-- Imprecise.
119+
-- Imprecise_Results is set to True if we don't know whether the results
120+
-- are precise.
121121
-- Returns an empty array if Decl is null.
122122

123123
procedure Find_All_Calls
@@ -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 Libadalang.Common.Ref_Result_Kind;
148+
Imprecise_Results : out Boolean;
149149
Callback : not null access procedure
150150
(Base_Id : Libadalang.Analysis.Base_Id;
151151
Kind : Libadalang.Common.Ref_Result_Kind;

source/ada/lsp-ada_declaration.adb

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ package body LSP.Ada_Declaration is
139139
On_Defining_Name : Boolean := False;
140140
-- Set to True if we are on a denfining name node
141141

142-
Imprecise_Ignore : Boolean;
143-
Result_Kind : Libadalang.Common.Ref_Result_Kind;
142+
Ignore : Boolean;
143+
Dummy : Libadalang.Common.Ref_Result_Kind;
144144
begin
145145
if Self.Contexts.Is_Empty then
146146
-- No more contexts to process, sort and return collected results
@@ -173,13 +173,12 @@ package body LSP.Ada_Declaration is
173173

174174
if Definition.Is_Null then
175175
-- If we aren't on a defining_name already then try to resolve
176-
Definition := Laltools.Common.Resolve_Name
177-
(Name_Node, Trace, Result_Kind);
176+
Definition := Laltools.Common.Resolve_Name (Name_Node, Trace, Dummy);
178177
else
179178
On_Defining_Name := True;
180179
end if;
181180

182-
if Result_Kind in Libadalang.Common.Error or else Definition.Is_Null then
181+
if Definition.Is_Null then
183182
return; -- Name resolution fails, nothing to do.
184183
end if;
185184

@@ -230,25 +229,16 @@ package body LSP.Ada_Declaration is
230229

231230
if not Decl_For_Find_Overrides.Is_Null then
232231
declare
233-
Overriding_Result_Kind : Libadalang.Common.Ref_Result_Kind;
234-
Bases_Result_Kind : Libadalang.Common.Ref_Result_Kind;
235232
Overridings : constant Libadalang.Analysis.Basic_Decl_Array :=
236233
Context.Find_All_Overrides
237234
(Decl_For_Find_Overrides,
238-
Result_Kind => Overriding_Result_Kind);
235+
Imprecise_Results => Ignore);
239236

240237
Bases : constant Libadalang.Analysis.Basic_Decl_Array :=
241238
Context.Find_All_Base_Declarations
242239
(Decl_For_Find_Overrides,
243-
Result_Kind => Bases_Result_Kind);
240+
Imprecise_Results => Ignore);
244241
begin
245-
if Overriding_Result_Kind in Libadalang.Common.Error
246-
or else Bases_Result_Kind in Libadalang.Common.Error
247-
then
248-
-- Abort
249-
return;
250-
end if;
251-
252242
for Subp of Bases loop
253243
Self.Parent.Context.Append_Location
254244
(Self.Response,

source/ada/lsp-ada_definition.adb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ package body LSP.Ada_Definition is
123123
Definition_Node : Libadalang.Analysis.Basic_Decl;
124124
Decl_For_Find_Overrides : Libadalang.Analysis.Basic_Decl;
125125
Entry_Decl_Node : Libadalang.Analysis.Entry_Decl;
126+
127+
Ignore : Boolean;
126128
begin
127129
if Self.Contexts.Is_Empty then
128130
-- No more contexts to process, sort and return collected results
@@ -236,25 +238,16 @@ package body LSP.Ada_Definition is
236238

237239
if not Decl_For_Find_Overrides.Is_Null then
238240
declare
239-
Overriding_Result_Kind : Libadalang.Common.Ref_Result_Kind;
240-
Bases_Result_Kind : Libadalang.Common.Ref_Result_Kind;
241241
Overridings : constant Libadalang.Analysis.Basic_Decl_Array :=
242242
Context.Find_All_Overrides
243243
(Decl_For_Find_Overrides,
244-
Result_Kind => Overriding_Result_Kind);
244+
Imprecise_Results => Ignore);
245245

246246
Bases : constant Libadalang.Analysis.Basic_Decl_Array :=
247247
Context.Find_All_Base_Declarations
248248
(Decl_For_Find_Overrides,
249-
Result_Kind => Bases_Result_Kind);
249+
Imprecise_Results => Ignore);
250250
begin
251-
if Overriding_Result_Kind in Libadalang.Common.Error
252-
or else Bases_Result_Kind in Libadalang.Common.Error
253-
then
254-
-- Abort
255-
return;
256-
end if;
257-
258251
for Subp of Bases loop
259252
Self.Parent.Context.Append_Location
260253
(Self.Response,

source/ada/lsp-ada_handlers-call_hierarchy.adb

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-2024, AdaCore --
4+
-- Copyright (C) 2018-2023, 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,16 +313,16 @@ package body LSP.Ada_Handlers.Call_Hierarchy is
313313
end if;
314314
end Callback;
315315

316-
Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind :=
316+
Cursor : Laltools.Common.References_By_Subprogram.Cursor;
317+
Ignore : Libadalang.Common.Ref_Result_Kind :=
317318
Libadalang.Common.No_Ref;
318-
Cursor : Laltools.Common.References_By_Subprogram.Cursor;
319319

320320
begin
321321
Laltools.Call_Hierarchy.Find_Outgoing_Calls
322322
(Definition => Definition,
323323
Callback => Callback'Access,
324324
Trace => Trace,
325-
Imprecise => Imprecise_Ignore);
325+
Imprecise => Ignore);
326326

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

0 commit comments

Comments
 (0)