From 062f94ea2f7ff67f0b982ccca753bb752212dbb5 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Thu, 24 Oct 2024 14:01:41 +0200 Subject: [PATCH 1/2] WIP --- server/src/server.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/src/server.ts b/server/src/server.ts index c7e0cf2c0..a9b45f037 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -217,15 +217,19 @@ let compilerLogsWatcher = chokidar }, }) .on("all", (_e, changedPath) => { + console.log("changes in path: ", changedPath); if (changedPath.includes("build.ninja")) { if (config.extensionConfiguration.cache?.projectConfig?.enable === true) { + console.log("Changed path includes build ninja"); let projectRoot = utils.findProjectRootOfFile(changedPath); if (projectRoot != null) { + console.log("Sync project config cache"); syncProjectConfigCache(projectRoot); } } } else { try { + console.log("Send updated diagnostics"); sendUpdatedDiagnostics(); sendCompilationFinishedMessage(); if (config.extensionConfiguration.inlayHints?.enable === true) { @@ -234,12 +238,13 @@ let compilerLogsWatcher = chokidar if (config.extensionConfiguration.codeLens === true) { sendCodeLensRefresh(); } - } catch { - console.log("Error while sending updated diagnostics"); + } catch (error) { + console.log("Error while sending updated diagnostics", error); } } }); let stopWatchingCompilerLog = () => { + console.log("Stop watching compiler log"); // TODO: cleanup of compilerLogs? compilerLogsWatcher.close(); }; From 8b584b3a75598ea8b57e7045399a6ce02cb62e47 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Thu, 24 Oct 2024 14:36:27 +0200 Subject: [PATCH 2/2] More logging --- server/src/server.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/server/src/server.ts b/server/src/server.ts index a9b45f037..12e1c1948 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -216,8 +216,8 @@ let compilerLogsWatcher = chokidar stabilityThreshold: 1, }, }) - .on("all", (_e, changedPath) => { - console.log("changes in path: ", changedPath); + .on("all", (eventName, changedPath, stats) => { + console.log(eventName, changedPath, stats); if (changedPath.includes("build.ninja")) { if (config.extensionConfiguration.cache?.projectConfig?.enable === true) { console.log("Changed path includes build ninja"); @@ -227,10 +227,32 @@ let compilerLogsWatcher = chokidar syncProjectConfigCache(projectRoot); } } + } else if ( + eventName === "unlink" && + changedPath.includes(".compiler.log") + ) { + console.log(compilerLogsWatcher.getWatched()); + console.log(".compiler.log has been deleted"); + + let projectRoot = utils.findProjectRootOfFile(changedPath); + if (projectRoot != null) { + compilerLogsWatcher.add( + path.join(projectRoot, c.compilerLogPartialPath) + ); + if ( + config.extensionConfiguration.cache?.projectConfig?.enable === true + ) { + compilerLogsWatcher.add( + path.join(projectRoot, c.buildNinjaPartialPath) + ); + syncProjectConfigCache(projectRoot); + } + } } else { try { console.log("Send updated diagnostics"); sendUpdatedDiagnostics(); + console.log("Send compilation finished message"); sendCompilationFinishedMessage(); if (config.extensionConfiguration.inlayHints?.enable === true) { sendInlayHintsRefresh();