Skip to content

Commit 6e2a4b8

Browse files
Merge branch 'topic/#1737' into 'master'
Do not report progress for small indexing jobs See merge request eng/ide/ada_language_server!2151
2 parents f848091 + 0ba14e4 commit 6e2a4b8

File tree

4 files changed

+74
-56
lines changed

4 files changed

+74
-56
lines changed

source/ada/lsp-ada_handlers-project_loading.adb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -804,12 +804,13 @@ package body LSP.Ada_Handlers.Project_Loading is
804804

805805
-- Schedule the indexing job
806806
LSP.Ada_Indexing.Schedule_Indexing
807-
(Server => Self.Server,
808-
Handler => Self'Unchecked_Access,
809-
Configuration => Self.Configuration,
810-
Project_Stamp => Self.Project_Stamp,
811-
Files => Files,
812-
Index_Runtime => True);
807+
(Server => Self.Server,
808+
Handler => Self'Unchecked_Access,
809+
Configuration => Self.Configuration,
810+
Project_Stamp => Self.Project_Stamp,
811+
Files => Files,
812+
Index_Runtime => True,
813+
Report_Progress => True);
813814
end Enqueue_Indexing_Job;
814815

815816
---------------------------------------

source/ada/lsp-ada_handlers.adb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,13 @@ package body LSP.Ada_Handlers is
370370
begin
371371
Files.Include (File);
372372
LSP.Ada_Indexing.Schedule_Indexing
373-
(Server => Self.Server,
374-
Handler => Self'Unchecked_Access,
375-
Configuration => Self.Configuration,
376-
Project_Stamp => Self.Project_Stamp,
377-
Files => Files,
378-
Index_Runtime => False);
373+
(Server => Self.Server,
374+
Handler => Self'Unchecked_Access,
375+
Configuration => Self.Configuration,
376+
Project_Stamp => Self.Project_Stamp,
377+
Files => Files,
378+
Index_Runtime => False,
379+
Report_Progress => False);
379380
end Enqueue_Indexing;
380381

381382
----------

source/ada/lsp-ada_indexing.adb

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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

source/ada/lsp-ada_indexing.ads

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ package LSP.Ada_Indexing is
3737
"=" => GNATCOLL.VFS."=");
3838

3939
procedure Schedule_Indexing
40-
(Server : not null access LSP.Servers.Server'Class;
41-
Handler : not null access LSP.Ada_Handlers.Message_Handler'Class;
42-
Configuration : LSP.Ada_Configurations.Configuration'Class;
43-
Project_Stamp : LSP.Ada_Handlers.Project_Stamp;
44-
Files : File_Sets.Set;
45-
Index_Runtime : Boolean);
40+
(Server : not null access LSP.Servers.Server'Class;
41+
Handler : not null access LSP.Ada_Handlers.Message_Handler'Class;
42+
Configuration : LSP.Ada_Configurations.Configuration'Class;
43+
Project_Stamp : LSP.Ada_Handlers.Project_Stamp;
44+
Files : File_Sets.Set;
45+
Index_Runtime : Boolean;
46+
Report_Progress : Boolean);
4647

47-
type Indexing_Job (<>) is new LSP.Server_Jobs.Server_Job
48-
with private;
48+
type Indexing_Job (<>) is new LSP.Server_Jobs.Server_Job with private;
49+
type Indexing_Job_Access is access all Indexing_Job'Class;
4950

5051
private
5152

@@ -64,28 +65,35 @@ private
6465
-- schedule new indexing job
6566

6667
type Indexing_Job
67-
(Handler : not null access LSP.Ada_Handlers.Message_Handler'Class) is
68-
new LSP.Server_Jobs.Server_Job with
69-
record
70-
Files_To_Index : File_Sets.Set;
68+
(Handler : not null access LSP.Ada_Handlers.Message_Handler'Class;
69+
Report_Progress : Boolean)
70+
is new LSP.Server_Jobs.Server_Job with record
71+
Files_To_Index : File_Sets.Set;
7172
-- Contains any files that need indexing.
7273

73-
Indexing_Token : LSP.Structures.ProgressToken;
74-
-- The token of the current indexing progress sequence
75-
7674
Total_Files_Indexed : Natural := 0;
7775
Total_Files_To_Index : Positive := 1;
7876
-- These two fields are used to produce a progress bar for the indexing
7977
-- operations. Total_Files_To_Index starts at 1 so that the progress
8078
-- bar starts at 0%.
8179

82-
Progress_Report_Sent : Ada.Calendar.Time;
83-
-- Time of send of last progress notification.
84-
85-
Project_Stamp : LSP.Ada_Handlers.Project_Stamp;
80+
Project_Stamp : LSP.Ada_Handlers.Project_Stamp;
8681

87-
Index_Runtime : Boolean := False;
82+
Index_Runtime : Boolean := False;
8883
-- True if the runtime should be indexed
84+
85+
case Report_Progress is
86+
-- True if we should report progress while indexing.
87+
88+
when True =>
89+
Indexing_Token : LSP.Structures.ProgressToken;
90+
-- The token of the current indexing progress sequence
91+
Progress_Report_Sent : Ada.Calendar.Time;
92+
-- Time of send of last progress notification.
93+
94+
when False =>
95+
null;
96+
end case;
8997
end record;
9098

9199
overriding function Priority

0 commit comments

Comments
 (0)