Skip to content

Commit 34b956f

Browse files
BoulangerBoulanger
authored andcommitted
Fix tests failures related to subprogram called on a null entity
Closes eng/ide/ada_language_server#1493
1 parent 68556e0 commit 34b956f

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

liblsp_3_17/source/lsp-server_messages.ads

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ package LSP.Server_Messages is
1212
type Server_Message is abstract tagged limited null record;
1313
-- Base class of messages send by a client to a server
1414

15-
function Assigned (Self : access Server_Message'Class) return Boolean
16-
is (Self /= null);
17-
-- Check if the argument is not null
18-
1915
type Server_Message_Access is access all Server_Message'Class;
2016

2117
procedure Visit_Server_Message_Visitor

source/server/lsp-job_schedulers.adb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ package body LSP.Job_Schedulers is
3737
procedure Complete_Last_Fence_Job
3838
(Self : in out Job_Scheduler'Class;
3939
Next : LSP.Server_Messages.Server_Message_Access;
40-
Waste : out LSP.Server_Messages.Server_Message_Access) is
40+
Waste : out LSP.Server_Messages.Server_Message_Access)
41+
is
42+
use type LSP.Server_Jobs.Server_Job_Access;
4143
begin
42-
if Self.Done.Assigned then
44+
if Self.Done /= null then
4345
Self.Done.Complete (Next);
4446
Waste := Self.Done.Message;
4547
Free (Self.Done);
@@ -55,6 +57,7 @@ package body LSP.Job_Schedulers is
5557
Message : in out LSP.Server_Messages.Server_Message_Access;
5658
Waste : out LSP.Server_Messages.Server_Message_Access)
5759
is
60+
use type LSP.Server_Jobs.Server_Job_Access;
5861
Cursor : constant Handler_Maps.Cursor :=
5962
Self.Handlers.Find (Message'Tag);
6063

@@ -65,7 +68,7 @@ package body LSP.Job_Schedulers is
6568
Self.Complete_Last_Fence_Job (Message, Waste);
6669
Job := Handler_Maps.Element (Cursor).Create_Job (Message);
6770

68-
if Job.Assigned then
71+
if Job /= null then
6972
Message := null;
7073
Self.Enqueue (Job);
7174
end if;
@@ -91,9 +94,11 @@ package body LSP.Job_Schedulers is
9194
-- Has_Jobs --
9295
--------------
9396

94-
function Has_Jobs (Self : Job_Scheduler'Class) return Boolean is
97+
function Has_Jobs (Self : Job_Scheduler'Class) return Boolean
98+
is
99+
use type LSP.Server_Jobs.Server_Job_Access;
95100
begin
96-
return Self.Blocker.Assigned or else
101+
return Self.Blocker /= null or else
97102
(for some List of Self.Jobs => not List.Is_Empty);
98103
end Has_Jobs;
99104

@@ -121,13 +126,15 @@ package body LSP.Job_Schedulers is
121126
is
122127
use all type LSP.Server_Jobs.Job_Priority;
123128
use all type LSP.Server_Jobs.Execution_Status;
129+
use type LSP.Server_Jobs.Server_Job_Access;
130+
use type LSP.Server_Messages.Server_Message_Access;
124131

125132
Job : LSP.Server_Jobs.Server_Job_Access renames Self.Blocker;
126133
Status : LSP.Server_Jobs.Execution_Status := Continue;
127134
begin
128135
Waste := null;
129136

130-
if not Job.Assigned then
137+
if Job = null then
131138
return;
132139
end if;
133140

@@ -138,7 +145,7 @@ package body LSP.Job_Schedulers is
138145
loop
139146
Self.Process_Job (Client, Waste, From => Low);
140147

141-
if Waste.Assigned then
148+
if Waste /= null then
142149
return;
143150
end if;
144151
end loop;
@@ -168,11 +175,12 @@ package body LSP.Job_Schedulers is
168175
Waste : out LSP.Server_Messages.Server_Message_Access;
169176
From : LSP.Server_Jobs.Job_Priority := LSP.Server_Jobs.Lowest)
170177
is
178+
use type LSP.Server_Messages.Server_Message_Access;
171179
Status : LSP.Server_Jobs.Execution_Status;
172180
begin
173181
Self.Complete_Last_Fence_Job (null, Waste);
174182

175-
if not Waste.Assigned then
183+
if Waste = null then
176184
for List of reverse Self.Jobs (From .. LSP.Server_Jobs.High)
177185
when not List.Is_Empty
178186
loop

source/server/lsp-server_jobs.ads

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ package LSP.Server_Jobs is
7676
return LSP.Server_Messages.Server_Message_Access is abstract;
7777
-- Message to be destroyed when the job is done
7878

79-
function Assigned (Self : access Server_Job'Class) return Boolean is
80-
(Self /= null);
81-
8279
type Server_Job_Access is access all Server_Job'Class;
8380

8481
end LSP.Server_Jobs;

source/server/lsp-servers.adb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ package body LSP.Servers is
817817

818818
task body Processing_Task_Type is
819819

820+
use type LSP.Server_Messages.Server_Message_Access;
820821
Input_Queue : Input_Message_Queues.Queue renames Server.Input_Queue;
821822

822823
procedure Process_Message (Message : in out Server_Message_Access);
@@ -846,7 +847,7 @@ package body LSP.Servers is
846847
-- job if any.
847848
Server.Scheduler.Process_Job (Server.all, Waste);
848849

849-
if Waste.Assigned then
850+
if Waste /= null then
850851
Server.Destroy_Queue.Enqueue (Waste);
851852
end if;
852853

@@ -869,19 +870,19 @@ package body LSP.Servers is
869870
begin
870871
Server.Scheduler.Create_Job (Message, Waste);
871872

872-
if Waste.Assigned then
873+
if Waste /= null then
873874
Server.Destroy_Queue.Enqueue (Waste);
874875
end if;
875876

876-
if Message.Assigned then
877+
if Message /= null then
877878
-- Scheduler wasn't able to process message, destroy it
878879
Server.Destroy_Queue.Enqueue (Message);
879880
end if;
880881

881882
loop
882883
Server.Scheduler.Process_High_Priority_Job (Server.all, Waste);
883884

884-
exit when not Waste.Assigned;
885+
exit when Waste = null;
885886

886887
Server.Destroy_Queue.Enqueue (Waste);
887888
end loop;
@@ -919,7 +920,7 @@ package body LSP.Servers is
919920
Continue := False;
920921
end select;
921922

922-
if Request.Assigned then
923+
if Request /= null then
923924
Process_Message (Request);
924925
end if;
925926
end loop;
@@ -930,7 +931,7 @@ package body LSP.Servers is
930931

931932
Execute_Jobs (Server.Look_Ahead);
932933

933-
if not Server.Look_Ahead.Assigned then
934+
if Server.Look_Ahead = null then
934935
-- there is no jobs any more, just wait for input messages
935936

936937
select
@@ -961,7 +962,7 @@ package body LSP.Servers is
961962
end;
962963
end loop;
963964

964-
if Server.Look_Ahead.Assigned then
965+
if Server.Look_Ahead /= null then
965966
Free (Server.Look_Ahead);
966967
end if;
967968

0 commit comments

Comments
 (0)