dev: handle compilation notifications for multiple projects (#1229)

* dev: handle multiple-project notifications

* dev: remove todo
This commit is contained in:
Myriad-Dreamin 2025-01-30 00:25:59 +08:00 committed by GitHub
parent eac275c28d
commit 0451a1089d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 5 deletions

View file

@ -210,6 +210,8 @@ pub trait CompileHandler<F: CompilerFeat, Ext>: Send + Sync + 'static {
// todo: notify project specific compile
/// Called when a compilation is done.
fn notify_compile(&self, res: &CompiledArtifact<F>, rep: CompileReport);
/// Called when a project is removed.
fn notify_removed(&self, _id: &ProjectInsId) {}
/// Called when the compilation status is changed.
fn status(&self, revision: usize, id: &ProjectInsId, rep: CompileReport);
}
@ -487,6 +489,9 @@ impl<F: CompilerFeat + Send + Sync + 'static, Ext: Default + 'static> ProjectCom
fn remove_dedicates(&mut self, id: &ProjectInsId) {
let proj = self.dedicates.iter().position(|e| e.id == *id);
if let Some(idx) = proj {
// Resets the handle state, e.g. notified revision
self.handler.notify_removed(id);
let _proj = self.dedicates.remove(idx);
// todo: kill compilations
} else {