Skip to content

Commit 93183d3

Browse files
committed
Fix Read_Location_Or_Link_Vector procedure in 3.16
to be able to read single object response. The new 3.17 encoder sends definition/declaration/etc response as an object instead of a single element array. Old decoder wasn't be able to read it properly.
1 parent 33f8f34 commit 93183d3

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

source/protocol/lsp-messages.adb

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,13 +2833,14 @@ package body LSP.Messages is
28332833
Nested : aliased LSP.JSON_Streams.JSON_Stream
28342834
(JS.Is_Server_Side, Look_Ahead'Unchecked_Access);
28352835
begin
2836-
pragma Assert (Look_Ahead.Is_Start_Array);
2837-
Look_Ahead.Read_Next;
2838-
2839-
if Look_Ahead.Is_End_Array then
2836+
if Look_Ahead.Is_Start_Array then
28402837
Look_Ahead.Read_Next;
2841-
V := (Kind => Empty_Vector_Kind);
2842-
return;
2838+
2839+
if Look_Ahead.Is_End_Array then
2840+
Look_Ahead.Read_Next;
2841+
V := (Kind => Empty_Vector_Kind);
2842+
return;
2843+
end if;
28432844
end if;
28442845

28452846
pragma Assert (Look_Ahead.Is_Start_Object);
@@ -2857,16 +2858,38 @@ package body LSP.Messages is
28572858
then
28582859
V := (Kind => LocationLink_Vector_Kind, LocationLinks => <>);
28592860
Look_Ahead.Rewind; -- Rewind to Start_Array and read
2860-
LocationLink_Vector'Read
2861-
(Nested'Unchecked_Access, V.LocationLinks);
2861+
2862+
if Look_Ahead.Is_Start_Array then
2863+
LocationLink_Vector'Read
2864+
(Nested'Unchecked_Access, V.LocationLinks);
2865+
else
2866+
declare
2867+
Item : LocationLink;
2868+
begin
2869+
LocationLink'Read (Nested'Unchecked_Access, Item);
2870+
V.LocationLinks.Append (Item);
2871+
end;
2872+
end if;
28622873

28632874
return;
2875+
28642876
elsif Key in "uri" | "range" then
28652877
V := (Kind => Location_Vector_Kind, Locations => <>);
28662878
Look_Ahead.Rewind; -- Rewind to Start_Array and read
2867-
Location_Vector'Read (Nested'Unchecked_Access, V.Locations);
2879+
2880+
if Look_Ahead.Is_Start_Array then
2881+
Location_Vector'Read (Nested'Unchecked_Access, V.Locations);
2882+
else
2883+
declare
2884+
Item : Location;
2885+
begin
2886+
Location'Read (Nested'Unchecked_Access, Item);
2887+
V.Locations.Append (Item);
2888+
end;
2889+
end if;
28682890

28692891
return;
2892+
28702893
else
28712894
-- Go to next field and try again
28722895
Nested.Skip_Value;

0 commit comments

Comments
 (0)