Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #1048

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

WIP #1048

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,30 +216,57 @@ let compilerLogsWatcher = chokidar
stabilityThreshold: 1,
},
})
.on("all", (_e, 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");
let projectRoot = utils.findProjectRootOfFile(changedPath);
if (projectRoot != null) {
console.log("Sync project config cache");
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();
}
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();
};
Expand Down