Skip to content

Commit c0b38a0

Browse files
author
mergerepo
committed
Merge remote branch 'origin/master' into edge
(no-precommit-check no-tn-check)
2 parents 75063ee + 0cde301 commit c0b38a0

12 files changed

+325
-17
lines changed

source/ada/lsp-ada_handlers.adb

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3879,6 +3879,7 @@ package body LSP.Ada_Handlers is
38793879
is
38803880
use type LSP.Messages.Search_Kind;
38813881
use type VSS.Strings.Character_Count;
3882+
use type Ada.Containers.Count_Type;
38823883

38833884
procedure On_Inaccessible_Name
38843885
(File : GNATCOLL.VFS.Virtual_File;
@@ -3931,6 +3932,31 @@ package body LSP.Ada_Handlers is
39313932
Response : LSP.Messages.Server_Responses.Symbol_Response
39323933
(Is_Error => False);
39333934

3935+
Partial_Response_Sended : Boolean := False;
3936+
3937+
-- Send_Partial_Response --
3938+
3939+
procedure Send_Partial_Response;
3940+
procedure Send_Partial_Response
3941+
is
3942+
P : LSP.Messages.Progress_SymbolInformation_Vector;
3943+
V : LSP.Messages.Symbol_Vector;
3944+
begin
3945+
if Canceled.Has_Been_Canceled then
3946+
return;
3947+
end if;
3948+
3949+
Write_Symbols (Names, V);
3950+
Names.Clear;
3951+
3952+
P.token := Request.params.partialResultToken.Value;
3953+
P.value := V.Vector;
3954+
3955+
Self.Server.On_Progress_SymbolInformation_Vector (P);
3956+
3957+
Partial_Response_Sended := True;
3958+
end Send_Partial_Response;
3959+
39343960
begin
39353961
if Pattern.Get_Kind /= LSP.Messages.Start_Word_Text
39363962
and then Pattern.Get_Canonical_Pattern.Character_Length < 2
@@ -3950,6 +3976,11 @@ package body LSP.Ada_Handlers is
39503976

39513977
if Canceled.Has_Been_Canceled then
39523978
return Response;
3979+
3980+
elsif Request.params.partialResultToken.Is_Set
3981+
and then Names.Length > 100
3982+
then
3983+
Send_Partial_Response;
39533984
end if;
39543985
end loop;
39553986

@@ -3969,10 +4000,19 @@ package body LSP.Ada_Handlers is
39694000

39704001
if Canceled.Has_Been_Canceled then
39714002
return Response;
4003+
4004+
elsif Request.params.partialResultToken.Is_Set
4005+
and then Names.Length > 100
4006+
then
4007+
Send_Partial_Response;
39724008
end if;
39734009
end loop;
39744010

3975-
Write_Symbols (Names, Response.result);
4011+
if Partial_Response_Sended then
4012+
Send_Partial_Response;
4013+
else
4014+
Write_Symbols (Names, Response.result);
4015+
end if;
39764016

39774017
return Response;
39784018
end On_Workspace_Symbols_Request;

source/client/lsp-clients.adb

Lines changed: 89 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,26 @@ package body LSP.Clients is
142142
procedure Show_Message
143143
(Stream : access Ada.Streams.Root_Stream_Type'Class;
144144
Handler : access LSP.Client_Notification_Receivers
145-
.Client_Notification_Receiver'Class);
145+
.Client_Notification_Receiver'Class;
146+
Token : LSP.Types.LSP_Number_Or_String);
146147

147148
procedure Log_Message
148149
(Stream : access Ada.Streams.Root_Stream_Type'Class;
149150
Handler : access LSP.Client_Notification_Receivers
150-
.Client_Notification_Receiver'Class);
151+
.Client_Notification_Receiver'Class;
152+
Token : LSP.Types.LSP_Number_Or_String);
151153

152154
procedure Publish_Diagnostics
153155
(Stream : access Ada.Streams.Root_Stream_Type'Class;
154156
Handler : access LSP.Client_Notification_Receivers
155-
.Client_Notification_Receiver'Class);
157+
.Client_Notification_Receiver'Class;
158+
Token : LSP.Types.LSP_Number_Or_String);
156159

157160
procedure Progress
158161
(Stream : access Ada.Streams.Root_Stream_Type'Class;
159162
Handler : access LSP.Client_Notification_Receivers
160-
.Client_Notification_Receiver'Class);
163+
.Client_Notification_Receiver'Class;
164+
Token : LSP.Types.LSP_Number_Or_String);
161165

162166
end Decoders;
163167

@@ -461,8 +465,10 @@ package body LSP.Clients is
461465
procedure Log_Message
462466
(Stream : access Ada.Streams.Root_Stream_Type'Class;
463467
Handler : access LSP.Client_Notification_Receivers
464-
.Client_Notification_Receiver'Class)
468+
.Client_Notification_Receiver'Class;
469+
Token : LSP.Types.LSP_Number_Or_String)
465470
is
471+
pragma Unreferenced (Token);
466472
Message : LogMessage_Notification;
467473
begin
468474
LogMessage_Notification'Read (Stream, Message);
@@ -476,8 +482,10 @@ package body LSP.Clients is
476482
procedure Publish_Diagnostics
477483
(Stream : access Ada.Streams.Root_Stream_Type'Class;
478484
Handler : access LSP.Client_Notification_Receivers
479-
.Client_Notification_Receiver'Class)
485+
.Client_Notification_Receiver'Class;
486+
Token : LSP.Types.LSP_Number_Or_String)
480487
is
488+
pragma Unreferenced (Token);
481489
Message : PublishDiagnostics_Notification;
482490
begin
483491
PublishDiagnostics_Notification'Read (Stream, Message);
@@ -491,8 +499,10 @@ package body LSP.Clients is
491499
procedure Show_Message
492500
(Stream : access Ada.Streams.Root_Stream_Type'Class;
493501
Handler : access LSP.Client_Notification_Receivers
494-
.Client_Notification_Receiver'Class)
502+
.Client_Notification_Receiver'Class;
503+
Token : LSP.Types.LSP_Number_Or_String)
495504
is
505+
pragma Unreferenced (Token);
496506
Message : ShowMessage_Notification;
497507
begin
498508
ShowMessage_Notification'Read (Stream, Message);
@@ -506,12 +516,28 @@ package body LSP.Clients is
506516
procedure Progress
507517
(Stream : access Ada.Streams.Root_Stream_Type'Class;
508518
Handler : access LSP.Client_Notification_Receivers
509-
.Client_Notification_Receiver'Class)
510-
is
511-
Message : Progress_Notification;
519+
.Client_Notification_Receiver'Class;
520+
Token : LSP.Types.LSP_Number_Or_String) is
512521
begin
513-
Progress_Notification'Read (Stream, Message);
514-
Handler.On_Progress (Message.params);
522+
case Handler.Get_Progress_Type (Token) is
523+
when LSP.Client_Notification_Receivers.ProgressParams =>
524+
declare
525+
Message : Progress_Notification;
526+
begin
527+
Progress_Notification'Read (Stream, Message);
528+
Handler.On_Progress (Message.params);
529+
end;
530+
531+
when LSP.Client_Notification_Receivers.SymbolInformation =>
532+
declare
533+
Message : SymbolInformation_Vectors_Notification;
534+
begin
535+
SymbolInformation_Vectors_Notification'Read
536+
(Stream, Message);
537+
Handler.On_Progress_SymbolInformation_Vector
538+
(Message.params);
539+
end;
540+
end case;
515541
end Progress;
516542

517543
end Decoders;
@@ -588,6 +614,7 @@ package body LSP.Clients is
588614
procedure Look_Ahead
589615
(Id : out LSP.Types.LSP_Number_Or_String;
590616
Method : out LSP.Types.Optional_String;
617+
Token : out LSP.Types.LSP_Number_Or_String;
591618
Is_Error : in out Boolean);
592619

593620
Memory : aliased
@@ -600,6 +627,7 @@ package body LSP.Clients is
600627
procedure Look_Ahead
601628
(Id : out LSP.Types.LSP_Number_Or_String;
602629
Method : out LSP.Types.Optional_String;
630+
Token : out LSP.Types.LSP_Number_Or_String;
603631
Is_Error : in out Boolean)
604632
is
605633
use all type VSS.JSON.Pull_Readers.JSON_Event_Kind;
@@ -628,24 +656,69 @@ package body LSP.Clients is
628656
Id :=
629657
(Is_Number => False,
630658
String => R.String_Value);
659+
631660
when Number_Value =>
632661
Id :=
633662
(Is_Number => True,
634663
Number => LSP.Types.LSP_Number
635664
(R.Number_Value.Integer_Value));
665+
636666
when others =>
637667
raise Constraint_Error;
638668
end case;
639669
R.Read_Next;
670+
640671
elsif Key = "method" then
641672
pragma Assert (R.Is_String_Value);
642673
Method := (Is_Set => True,
643674
Value =>
644675
LSP.Types.To_LSP_String (R.String_Value));
645676
R.Read_Next;
677+
646678
elsif Key = "error" then
647679
Is_Error := True;
648680
JS.Skip_Value;
681+
682+
elsif Key = "params" then
683+
-- parse 'params' object to get 'token' value
684+
-- from a notification if any
685+
686+
pragma Assert (R.Is_Start_Object);
687+
R.Read_Next;
688+
689+
while not R.Is_End_Object loop
690+
pragma Assert (R.Is_Key_Name);
691+
declare
692+
Key : constant String :=
693+
VSS.Strings.Conversions.To_UTF_8_String (R.Key_Name);
694+
begin
695+
R.Read_Next;
696+
697+
if Key = "token" then
698+
case R.Event_Kind is
699+
when String_Value =>
700+
Token :=
701+
(Is_Number => False,
702+
String => R.String_Value);
703+
704+
when Number_Value =>
705+
Token :=
706+
(Is_Number => True,
707+
Number => LSP.Types.LSP_Number
708+
(R.Number_Value.Integer_Value));
709+
710+
when others =>
711+
raise Constraint_Error;
712+
end case;
713+
R.Read_Next;
714+
715+
else
716+
JS.Skip_Value;
717+
end if;
718+
end;
719+
end loop;
720+
R.Read_Next;
721+
649722
else
650723
JS.Skip_Value;
651724
end if;
@@ -660,6 +733,8 @@ package body LSP.Clients is
660733
(Is_Server_Side => False, R => Reader'Unchecked_Access);
661734
Id : LSP.Types.LSP_Number_Or_String;
662735
Method : LSP.Types.Optional_String;
736+
Token : LSP.Types.LSP_Number_Or_String :=
737+
(Is_Number => False, String => VSS.Strings.Empty_Virtual_String);
663738

664739
Is_Error : Boolean := False;
665740

@@ -671,7 +746,7 @@ package body LSP.Clients is
671746
(VSS.Stream_Element_Vectors.Conversions.Unchecked_From_Unbounded_String
672747
(Data));
673748

674-
Look_Ahead (Id, Method, Is_Error);
749+
Look_Ahead (Id, Method, Token, Is_Error);
675750
Reader.Set_Stream (Memory'Unchecked_Access);
676751
Stream.R.Read_Next;
677752
pragma Assert (Stream.R.Is_Start_Document);
@@ -803,7 +878,7 @@ package body LSP.Clients is
803878
begin
804879
if Notification_Maps.Has_Element (Position) then
805880
Notification_Maps.Element (Position).all
806-
(Stream'Access, Self.Notification);
881+
(Stream'Access, Self.Notification, Token);
807882
end if;
808883
end;
809884
end if;

source/client/lsp-clients.ads

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ private
202202
type Notification_Decoder is access procedure
203203
(Stream : access Ada.Streams.Root_Stream_Type'Class;
204204
Handler : access LSP.Client_Notification_Receivers
205-
.Client_Notification_Receiver'Class);
205+
.Client_Notification_Receiver'Class;
206+
Token : LSP.Types.LSP_Number_Or_String);
206207

207208
package Notification_Maps is new Ada.Containers.Hashed_Maps
208209
(Key_Type => Ada.Strings.Unbounded.Unbounded_String,

source/protocol/lsp-client_notification_receivers.ads

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
--
1818
-- Interface to process notifications sent to the client.
1919

20+
with LSP.Types;
2021
with LSP.Messages;
2122

2223
package LSP.Client_Notification_Receivers is
2324

25+
type Progress_Value_Kind is (ProgressParams, SymbolInformation);
26+
2427
type Client_Notification_Receiver is limited interface;
2528
-- Receiver of notification on LSP client side
2629

@@ -39,9 +42,19 @@ package LSP.Client_Notification_Receivers is
3942
Params : LSP.Messages.PublishDiagnosticsParams) is abstract;
4043
-- Process textDocument/publishDiagnostics notification
4144

45+
function Get_Progress_Type
46+
(Self : access Client_Notification_Receiver;
47+
Token : LSP.Types.LSP_Number_Or_String)
48+
return Progress_Value_Kind is abstract;
49+
4250
procedure On_Progress
4351
(Self : access Client_Notification_Receiver;
4452
Params : LSP.Messages.Progress_Params) is abstract;
4553
-- Process a $/progress notification
4654

55+
procedure On_Progress_SymbolInformation_Vector
56+
(Self : access Client_Notification_Receiver;
57+
Params : LSP.Messages.Progress_SymbolInformation_Vector) is abstract;
58+
-- Process a $/progress notification that contains SymbolInformation_Vector
59+
4760
end LSP.Client_Notification_Receivers;

source/protocol/lsp-messages-client_notifications.adb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,15 @@ package body LSP.Messages.Client_Notifications is
6565
Receiver.On_Progress (Self.params);
6666
end Visit;
6767

68+
-----------
69+
-- Visit --
70+
-----------
71+
72+
overriding procedure Visit
73+
(Self : SymbolInformation_Vectors_Notification;
74+
Receiver : access Client_Notification_Receiver'Class) is
75+
begin
76+
Receiver.On_Progress_SymbolInformation_Vector (Self.params);
77+
end Visit;
78+
6879
end LSP.Messages.Client_Notifications;

source/protocol/lsp-messages-client_notifications.ads

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,16 @@ package LSP.Messages.Client_Notifications is
7777
(Self : Progress_Notification;
7878
Receiver : access Client_Notification_Receiver'Class);
7979

80+
package SymbolInformation_Vectors is new LSP.Generic_Notifications
81+
(Client_Notification,
82+
LSP.Messages.Progress_SymbolInformation_Vector,
83+
Client_Notification_Receiver'Class);
84+
85+
type SymbolInformation_Vectors_Notification is
86+
new SymbolInformation_Vectors.Notification with null record;
87+
88+
overriding procedure Visit
89+
(Self : SymbolInformation_Vectors_Notification;
90+
Receiver : access Client_Notification_Receiver'Class);
91+
8092
end LSP.Messages.Client_Notifications;

0 commit comments

Comments
 (0)