use ryo_analysis::SymbolKind;
use ryo_mutations::basic::RemoveModMutation;
use ryo_mutations::MutationResult;
use crate::engine::{ASTMutationContext, ASTRegApply, MutationEvent};
impl ASTRegApply for RemoveModMutation {
fn apply_to_registry(&self, ctx: &mut ASTMutationContext) -> MutationResult {
let target_id = self.module_id;
if ctx.symbol_registry.kind(target_id) != Some(SymbolKind::Mod) {
return MutationResult {
mutation_type: "RemoveMod".to_string(),
changes: 0,
description: format!("Symbol {} is not a module", target_id),
};
}
let path = ctx.symbol_registry.path(target_id).cloned();
ctx.symbol_registry.remove(target_id);
ctx.ast_registry.remove(target_id);
if let Some(path) = path {
ctx.emit(MutationEvent::SymbolRemoved { path });
}
MutationResult {
mutation_type: "RemoveMod".to_string(),
changes: 1,
description: format!("Removed mod {}", target_id),
}
}
}