@@ -205,20 +205,49 @@ let sendCompilationFinishedMessage = () => {
205
205
send ( notification ) ;
206
206
} ;
207
207
208
+ let debug = false ;
209
+
210
+ let syncProjectConfigCache = ( rootPath : string ) => {
211
+ try {
212
+ if ( debug ) console . log ( "syncing project config cache for " + rootPath ) ;
213
+ utils . runAnalysisAfterSanityCheck ( rootPath , [ "cache-project" , rootPath ] ) ;
214
+ if ( debug ) console . log ( "OK - synced project config cache for " + rootPath ) ;
215
+ } catch ( e ) {
216
+ if ( debug ) console . error ( e ) ;
217
+ }
218
+ } ;
219
+
220
+ let deleteProjectConfigCache = ( rootPath : string ) => {
221
+ try {
222
+ if ( debug ) console . log ( "deleting project config cache for " + rootPath ) ;
223
+ utils . runAnalysisAfterSanityCheck ( rootPath , [ "cache-delete" , rootPath ] ) ;
224
+ if ( debug ) console . log ( "OK - deleted project config cache for " + rootPath ) ;
225
+ } catch ( e ) {
226
+ if ( debug ) console . error ( e ) ;
227
+ }
228
+ } ;
229
+
208
230
let compilerLogsWatcher = chokidar
209
231
. watch ( [ ] , {
210
232
awaitWriteFinish : {
211
233
stabilityThreshold : 1 ,
212
234
} ,
213
235
} )
214
- . on ( "all" , ( _e , _changedPath ) => {
215
- sendUpdatedDiagnostics ( ) ;
216
- sendCompilationFinishedMessage ( ) ;
217
- if ( config . extensionConfiguration . inlayHints ?. enable === true ) {
218
- sendInlayHintsRefresh ( ) ;
219
- }
220
- if ( config . extensionConfiguration . codeLens === true ) {
221
- sendCodeLensRefresh ( ) ;
236
+ . on ( "all" , ( _e , changedPath ) => {
237
+ if ( changedPath . includes ( "build.ninja" ) ) {
238
+ let projectRoot = utils . findProjectRootOfFile ( changedPath ) ;
239
+ if ( projectRoot != null ) {
240
+ syncProjectConfigCache ( projectRoot ) ;
241
+ }
242
+ } else {
243
+ sendUpdatedDiagnostics ( ) ;
244
+ sendCompilationFinishedMessage ( ) ;
245
+ if ( config . extensionConfiguration . inlayHints ?. enable === true ) {
246
+ sendInlayHintsRefresh ( ) ;
247
+ }
248
+ if ( config . extensionConfiguration . codeLens === true ) {
249
+ sendCodeLensRefresh ( ) ;
250
+ }
222
251
}
223
252
} ) ;
224
253
let stopWatchingCompilerLog = ( ) => {
@@ -257,6 +286,14 @@ let openedFile = (fileUri: string, fileContent: string) => {
257
286
compilerLogsWatcher . add (
258
287
path . join ( projectRootPath , c . compilerLogPartialPath )
259
288
) ;
289
+ if (
290
+ config . extensionConfiguration . cache ?. projectConfig ?. enabled === true
291
+ ) {
292
+ compilerLogsWatcher . add (
293
+ path . join ( projectRootPath , c . buildNinjaPartialPath )
294
+ ) ;
295
+ syncProjectConfigCache ( projectRootPath ) ;
296
+ }
260
297
}
261
298
let root = projectsFiles . get ( projectRootPath ) ! ;
262
299
root . openFiles . add ( filePath ) ;
@@ -335,6 +372,10 @@ let closedFile = (fileUri: string) => {
335
372
compilerLogsWatcher . unwatch (
336
373
path . join ( projectRootPath , c . compilerLogPartialPath )
337
374
) ;
375
+ compilerLogsWatcher . unwatch (
376
+ path . join ( projectRootPath , c . buildNinjaPartialPath )
377
+ ) ;
378
+ deleteProjectConfigCache ( projectRootPath ) ;
338
379
deleteProjectDiagnostics ( projectRootPath ) ;
339
380
if ( root . bsbWatcherByEditor !== null ) {
340
381
root . bsbWatcherByEditor . kill ( ) ;
0 commit comments