11-- ----------------------------------------------------------------------------
22-- Language Server Protocol --
33-- --
4- -- Copyright (C) 2023, AdaCore --
4+ -- Copyright (C) 2023-2024 , 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- --
@@ -22,12 +22,15 @@ with VSS.Strings.Templates;
2222
2323package body LSP.Ada_Indexing is
2424
25- -- ---------------
26- -- Index_Files --
27- -- ---------------
28-
29- procedure Index_Files (Self : in out Indexing_Job'Class) is
25+ -- -----------
26+ -- Execute --
27+ -- -----------
3028
29+ overriding procedure Execute
30+ (Self : in out Indexing_Job;
31+ Client :
32+ in out LSP.Client_Message_Receivers.Client_Message_Receiver'Class)
33+ is
3134 use type LSP.Ada_Handlers.Project_Stamp;
3235
3336 procedure Emit_Progress_Report (Files_Indexed, Total_Files : Natural);
@@ -51,7 +54,7 @@ package body LSP.Ada_Indexing is
5154
5255 Self.Progress_Report_Sent := Current;
5356
54- Self.Server .On_ProgressReport_Work_Done
57+ Client .On_ProgressReport_Work_Done
5558 (Self.Indexing_Token,
5659 (percentage => (True, (Files_Indexed * 100 ) / Total_Files),
5760 message =>
@@ -63,7 +66,7 @@ package body LSP.Ada_Indexing is
6366
6467 begin
6568 if Self.Total_Files_Indexed = 0 then
66- Self.Server .On_ProgressBegin_Work_Done
69+ Client .On_ProgressBegin_Work_Done
6770 (Self.Indexing_Token,
6871 (title => " Indexing" , percentage => (True, 0 ), others => <>));
6972 end if ;
@@ -109,28 +112,10 @@ package body LSP.Ada_Indexing is
109112 if Self.Files_To_Index.Is_Empty then
110113 -- Indexing done.
111114
112- Self.Server .On_ProgressEnd_Work_Done
115+ Client .On_ProgressEnd_Work_Done
113116 (Self.Indexing_Token, (message => <>));
114-
115- return ;
116117 end if ;
117-
118- declare
119- Job : LSP.Server_Jobs.Server_Jobs_Access :=
120- new Indexing_Job'
121- (Server => Self.Server.all 'Unchecked_Access,
122- Handler => Self.Handler.all 'Unchecked_Access,
123- Files_To_Index => Self.Files_To_Index,
124- Indexing_Token => Self.Indexing_Token,
125- Total_Files_Indexed => Self.Total_Files_Indexed,
126- Total_Files_To_Index => Self.Total_Files_To_Index,
127- Progress_Report_Sent => Self.Progress_Report_Sent,
128- Project_Stamp => Self.Project_Stamp);
129-
130- begin
131- Self.Server.Enqueue (Job);
132- end ;
133- end Index_Files ;
118+ end Execute ;
134119
135120 -- ---------------------
136121 -- Schedule_Indexing --
@@ -155,7 +140,7 @@ package body LSP.Ada_Indexing is
155140 Server.Allocate_Request_Id;
156141 Token : constant LSP.Structures.ProgressToken :=
157142 Handler.Allocate_Progress_Token (" indexing" );
158- Job : LSP.Server_Jobs.Server_Jobs_Access :=
143+ Job : LSP.Server_Jobs.Server_Job_Access :=
159144 new Indexing_Job'
160145 (Server => Server,
161146 Handler => Handler,
@@ -167,7 +152,7 @@ package body LSP.Ada_Indexing is
167152 Project_Stamp => Project_Stamp);
168153
169154 begin
170- Job. Server.On_Progress_Create_Request (Id, (token => Token));
155+ Server.On_Progress_Create_Request (Id, (token => Token));
171156 -- FIXME: wait response before sending progress notifications.
172157 -- Currenctly, we just send a `window/workDoneProgress/create`
173158 -- request and immediately after this start sending notifications.
@@ -178,16 +163,4 @@ package body LSP.Ada_Indexing is
178163 end ;
179164 end Schedule_Indexing ;
180165
181- -- --------------------------------
182- -- Visit_Server_Message_Visitor --
183- -- --------------------------------
184-
185- overriding procedure Visit_Server_Message_Visitor
186- (Self : Indexing_Job;
187- Value : in out
188- LSP.Server_Message_Visitors.Server_Message_Visitor'Class) is
189- begin
190- Self'Unrestricted_Access.Index_Files;
191- end Visit_Server_Message_Visitor ;
192-
193166end LSP.Ada_Indexing ;
0 commit comments