Skip to content

Commit b2340ad

Browse files
committed
Merge branch 'topic/error_no_callbacks' into 'master'
Update code to new Spawn API. See merge request eng/ide/ada_language_server!1174
2 parents 8367488 + 7de953f commit b2340ad

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

source/client/lsp-raw_clients.adb

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,16 @@ package body LSP.Raw_Clients is
194194
begin
195195
loop
196196
declare
197-
Raw : Ada.Streams.Stream_Element_Array (1 .. 1024);
198-
Last : Ada.Streams.Stream_Element_Count;
199-
Text : String (1 .. 1024) with Import, Address => Raw'Address;
197+
Raw : Ada.Streams.Stream_Element_Array (1 .. 1024);
198+
Last : Ada.Streams.Stream_Element_Count;
199+
Text : String (1 .. 1024) with Import, Address => Raw'Address;
200+
Success : Boolean := True;
201+
200202
begin
201-
Self.Client.Server.Read_Standard_Error (Raw, Last);
202-
exit when Last in 0;
203+
Self.Client.Server.Read_Standard_Error (Raw, Last, Success);
204+
205+
exit when Last < Raw'First or not Success;
206+
203207
Self.Client.On_Standard_Error_Message (Text (1 .. Natural (Last)));
204208
end;
205209
end loop;
@@ -220,18 +224,21 @@ package body LSP.Raw_Clients is
220224
begin
221225
while Rest_Length > 0 loop
222226
declare
223-
Size : constant Positive := Positive'Min (Rest_Length, 1024);
227+
Size : constant Positive := Positive'Min (Rest_Length, 1024);
224228
-- Restrict output to reasonable size to avoid stack overflow
225-
Slice : constant String := Ada.Strings.Unbounded.Slice
229+
Slice : constant String := Ada.Strings.Unbounded.Slice
226230
(Client.To_Write, Client.Written + 1, Client.Written + Size);
227-
Raw : constant Ada.Streams.Stream_Element_Array
231+
Raw : constant Ada.Streams.Stream_Element_Array
228232
(1 .. Ada.Streams.Stream_Element_Count (Size))
229233
with Import, Address => Slice'Address;
230-
Last : Natural;
234+
Last : Natural;
235+
Success : Boolean := True;
231236

232237
begin
233238
Client.Server.Write_Standard_Input
234-
(Raw, Ada.Streams.Stream_Element_Count (Last));
239+
(Raw, Ada.Streams.Stream_Element_Count (Last), Success);
240+
241+
-- ??? IO failure is not handled, should it?
235242

236243
Client.Written := Client.Written + Last;
237244
Rest_Length := Rest_Length - Last;
@@ -319,15 +326,17 @@ package body LSP.Raw_Clients is
319326
begin
320327
loop
321328
declare
322-
Raw : Ada.Streams.Stream_Element_Array (1 .. 1024);
323-
Last : Ada.Streams.Stream_Element_Count;
324-
Text : String (1 .. Raw'Length)
329+
Raw : Ada.Streams.Stream_Element_Array (1 .. 1024);
330+
Last : Ada.Streams.Stream_Element_Count;
331+
Text : String (1 .. Raw'Length)
325332
with Import, Address => Raw'Address;
326-
Start : Natural;
333+
Success : Boolean := True;
334+
Start : Natural;
335+
327336
begin
328-
Client.Server.Read_Standard_Output (Raw, Last);
337+
Client.Server.Read_Standard_Output (Raw, Last, Success);
329338

330-
exit when Last in 0;
339+
exit when Last < Raw'First or not Success;
331340

332341
Append (Client.Buffer, Text (1 .. Positive (Last)));
333342

source/tester/tester-tests.adb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,13 +1042,16 @@ package body Tester.Tests is
10421042
(Self : in out Process_Listener)
10431043
is
10441044
use type Ada.Streams.Stream_Element_Count;
1045-
Data : Ada.Streams.Stream_Element_Array (1 .. 128);
1046-
Last : Ada.Streams.Stream_Element_Count;
1047-
Ignore : Interfaces.C_Streams.size_t;
1045+
Data : Ada.Streams.Stream_Element_Array (1 .. 128);
1046+
Last : Ada.Streams.Stream_Element_Count;
1047+
Success : Boolean := True;
1048+
Ignore : Interfaces.C_Streams.size_t;
1049+
10481050
begin
10491051
loop
1050-
Self.Process.Read_Standard_Error (Data, Last);
1051-
exit when Last = 0;
1052+
Self.Process.Read_Standard_Error (Data, Last, Success);
1053+
1054+
exit when Last = 0 or not Success;
10521055

10531056
Ignore := Interfaces.C_Streams.fwrite
10541057
(Data'Address,
@@ -1066,14 +1069,16 @@ package body Tester.Tests is
10661069
(Self : in out Process_Listener)
10671070
is
10681071
use type Ada.Streams.Stream_Element_Count;
1069-
Data : Ada.Streams.Stream_Element_Array (1 .. 128);
1070-
Last : Ada.Streams.Stream_Element_Count;
1071-
Ignore : Interfaces.C_Streams.size_t;
1072+
Data : Ada.Streams.Stream_Element_Array (1 .. 128);
1073+
Last : Ada.Streams.Stream_Element_Count;
1074+
Success : Boolean := True;
1075+
Ignore : Interfaces.C_Streams.size_t;
1076+
10721077
begin
10731078
loop
1074-
Self.Process.Read_Standard_Output (Data, Last);
1079+
Self.Process.Read_Standard_Output (Data, Last, Success);
10751080

1076-
exit when Last = 0;
1081+
exit when Last = 0 or not Success;
10771082

10781083
Ignore := Interfaces.C_Streams.fwrite
10791084
(Data'Address,

0 commit comments

Comments
 (0)