@@ -22,11 +22,11 @@ use span;
22
22
use Span ;
23
23
24
24
use actions:: post_build:: { BuildResults , PostBuildHandler , DiagnosticsNotifier } ;
25
- use actions:: notifications:: { BeginBuild , DiagnosticsBegin , DiagnosticsEnd , PublishDiagnostics , Progress } ;
25
+ use actions:: notifications:: { PublishDiagnostics , Progress } ;
26
26
use build:: * ;
27
27
use lsp_data;
28
28
use lsp_data:: * ;
29
- use server:: { Output , Notification , NoParams } ;
29
+ use server:: { Output , Notification } ;
30
30
31
31
use std:: collections:: HashMap ;
32
32
use std:: path:: { Path , PathBuf } ;
@@ -198,22 +198,48 @@ impl InitActionContext {
198
198
199
199
fn build < O : Output > ( & self , project_path : & Path , priority : BuildPriority , out : O ) {
200
200
201
+ lazy_static ! {
202
+ static ref PROGRESS_ID_COUNTER : AtomicUsize = {
203
+ AtomicUsize :: new( 0 )
204
+ } ;
205
+ }
206
+
207
+ fn new_progress_params ( id : String , title : & str ) -> ProgressParams {
208
+ ProgressParams {
209
+ id,
210
+ title : Some ( title. into ( ) ) ,
211
+ message : None ,
212
+ percentage : None ,
213
+ done : None ,
214
+ }
215
+ }
216
+
201
217
// notifier of diagnostics after the build
202
218
struct BuildDiagnosticsNotifier < O : Output > {
203
219
out : O ,
204
220
active_build_count : Arc < AtomicUsize > ,
221
+ progress_params : ProgressParams ,
205
222
}
206
223
224
+ // base progress parameters for notification of the analysis.
225
+ let diganostics_progress_params = {
226
+ let id = format ! ( "diagnostics_{}" , PROGRESS_ID_COUNTER . fetch_add( 1 , Ordering :: SeqCst ) ) ;
227
+ new_progress_params ( id, "Diagnostics" )
228
+ } ;
229
+
207
230
impl < O : Output > DiagnosticsNotifier for BuildDiagnosticsNotifier < O > {
208
231
fn notify_begin_diagnostics ( & self ) {
209
- self . out . notify ( Notification :: < DiagnosticsBegin > :: new ( NoParams { } ) ) ;
232
+ let params = self . progress_params . clone ( ) ;
233
+ self . out . notify ( Notification :: < Progress > :: new ( params) ) ;
210
234
}
211
235
fn notify_publish_diagnostics ( & self , params : PublishDiagnosticsParams ) {
212
236
self . out . notify ( Notification :: < PublishDiagnostics > :: new ( params) ) ;
213
237
}
214
238
fn notify_end_diagnostics ( & self ) {
215
239
self . active_build_count . fetch_sub ( 1 , Ordering :: SeqCst ) ;
216
- self . out . notify ( Notification :: < DiagnosticsEnd > :: new ( NoParams { } ) ) ;
240
+ let mut params = self . progress_params . clone ( ) ;
241
+ params. done = Some ( true ) ;
242
+ self . out . notify ( Notification :: < Progress > :: new ( params) ) ;
217
243
}
218
244
}
219
245
@@ -225,19 +251,8 @@ impl InitActionContext {
225
251
226
252
// base progress parameters for notification of this build.
227
253
let progress_params = {
228
- lazy_static ! {
229
- static ref ID_COUNTER : AtomicUsize = {
230
- AtomicUsize :: new( 0 )
231
- } ;
232
- }
233
-
234
- ProgressParams {
235
- id : format ! ( "progress_{}" , ID_COUNTER . fetch_add( 1 , Ordering :: SeqCst ) ) ,
236
- title : None ,
237
- message : None ,
238
- percentage : None ,
239
- done : None ,
240
- }
254
+ let id = format ! ( "progress_{}" , PROGRESS_ID_COUNTER . fetch_add( 1 , Ordering :: SeqCst ) ) ;
255
+ new_progress_params ( id, "Build" )
241
256
} ;
242
257
243
258
impl < O : Output > ProgressNotifier for BuildProgressNotifier < O > {
@@ -255,7 +270,6 @@ impl InitActionContext {
255
270
}
256
271
fn notify_end_progress ( & self ) {
257
272
let mut params = self . progress_params . clone ( ) ;
258
- params. percentage = Some ( 1.0 ) ;
259
273
params. done = Some ( true ) ;
260
274
self . out . notify ( Notification :: < Progress > :: new ( params) ) ;
261
275
}
@@ -272,6 +286,7 @@ impl InitActionContext {
272
286
notifier : Box :: new ( BuildDiagnosticsNotifier {
273
287
out : out. clone ( ) ,
274
288
active_build_count : self . active_build_count . clone ( ) ,
289
+ progress_params : diganostics_progress_params,
275
290
} ) ,
276
291
blocked_threads : vec ! [ ] ,
277
292
}
@@ -282,7 +297,6 @@ impl InitActionContext {
282
297
progress_params,
283
298
} ) ;
284
299
285
- out. notify ( Notification :: < BeginBuild > :: new ( NoParams { } ) ) ;
286
300
self . active_build_count . fetch_add ( 1 , Ordering :: SeqCst ) ;
287
301
self . build_queue
288
302
. request_build ( project_path, priority, notifier, pbh) ;
0 commit comments