@@ -71,7 +71,7 @@ package body LSP.Ada_Indexing is
7171 end Emit_Progress_Report ;
7272
7373 begin
74- if Self.Total_Files_Indexed = 0 then
74+ if Self.Report_Progress and then Self. Total_Files_Indexed = 0 then
7575 Client.On_ProgressBegin_Work_Done
7676 (Self.Indexing_Token,
7777 (title => " Indexing" , percentage => (True, 0 ), others => <>));
@@ -102,8 +102,10 @@ package body LSP.Ada_Indexing is
102102 Context.Index_File (File, Reparse => False);
103103 end loop ;
104104
105- Emit_Progress_Report
106- (Self.Total_Files_Indexed, Self.Total_Files_To_Index);
105+ if Self.Report_Progress then
106+ Emit_Progress_Report
107+ (Self.Total_Files_Indexed, Self.Total_Files_To_Index);
108+ end if ;
107109
108110 exit ;
109111 end if ;
@@ -114,8 +116,10 @@ package body LSP.Ada_Indexing is
114116 if Self.Files_To_Index.Is_Empty then
115117 -- Indexing done.
116118
117- Client.On_ProgressEnd_Work_Done
118- (Self.Indexing_Token, (message => <>));
119+ if Self.Report_Progress then
120+ Client.On_ProgressEnd_Work_Done
121+ (Self.Indexing_Token, (message => <>));
122+ end if ;
119123
120124 if not Self.Handler.Is_Shutdown
121125 and then Self.Index_Runtime
@@ -161,12 +165,13 @@ package body LSP.Ada_Indexing is
161165 -- ---------------------
162166
163167 procedure Schedule_Indexing
164- (Server : not null access LSP.Servers.Server'Class;
165- Handler : not null access LSP.Ada_Handlers.Message_Handler'Class;
166- Configuration : LSP.Ada_Configurations.Configuration'Class;
167- Project_Stamp : LSP.Ada_Handlers.Project_Stamp;
168- Files : File_Sets.Set;
169- Index_Runtime : Boolean) is
168+ (Server : not null access LSP.Servers.Server'Class;
169+ Handler : not null access LSP.Ada_Handlers.Message_Handler'Class;
170+ Configuration : LSP.Ada_Configurations.Configuration'Class;
171+ Project_Stamp : LSP.Ada_Handlers.Project_Stamp;
172+ Files : File_Sets.Set;
173+ Index_Runtime : Boolean;
174+ Report_Progress : Boolean) is
170175 begin
171176 if Files.Is_Empty
172177 or not Configuration.Indexing_Enabled
@@ -180,26 +185,29 @@ package body LSP.Ada_Indexing is
180185 Server.Allocate_Request_Id;
181186 Token : constant LSP.Structures.ProgressToken :=
182187 Handler.Allocate_Progress_Token (" indexing" );
183- Job : LSP.Server_Jobs.Server_Job_Access :=
184- new Indexing_Job'
185- (Handler => Handler,
186- Files_To_Index => Files,
187- Indexing_Token => Token,
188- Total_Files_Indexed => 0 ,
189- Total_Files_To_Index => Natural (Files.Length),
190- Progress_Report_Sent => Ada.Calendar.Clock,
191- Project_Stamp => Project_Stamp,
192- Index_Runtime => Index_Runtime);
193-
188+ Job : Indexing_Job_Access :=
189+ new Indexing_Job
190+ (Handler => Handler, Report_Progress => Report_Progress);
194191 begin
195- Server.On_Progress_Create_Request (Id, (token => Token));
192+ Job.Files_To_Index := Files;
193+ Job.Total_Files_Indexed := 0 ;
194+ Job.Total_Files_To_Index := Natural (Files.Length);
195+ Job.Project_Stamp := Project_Stamp;
196+ Job.Index_Runtime := Index_Runtime;
197+
196198 -- FIXME: wait response before sending progress notifications.
197199 -- Currenctly, we just send a `window/workDoneProgress/create`
198200 -- request and immediately after this start sending notifications.
199201 -- We could do better, send request, wait for client response and
200202 -- start progress-report sending only after response.
203+ if Report_Progress then
204+ Job.Indexing_Token := Token;
205+ Job.Progress_Report_Sent := Ada.Calendar.Clock;
206+
207+ Server.On_Progress_Create_Request (Id, (token => Token));
208+ end if ;
201209
202- Server.Enqueue (Job);
210+ Server.Enqueue (LSP.Server_Jobs.Server_Job_Access ( Job) );
203211 end ;
204212 end Schedule_Indexing ;
205213
0 commit comments