ryo_executor/engine/impls/
mod_decl.rs1use ryo_analysis::SymbolKind;
6use ryo_mutations::basic::RemoveModMutation;
7use ryo_mutations::MutationResult;
8
9use crate::engine::{ASTMutationContext, ASTRegApply, MutationEvent};
10
11impl ASTRegApply for RemoveModMutation {
12 fn apply_to_registry(&self, ctx: &mut ASTMutationContext) -> MutationResult {
13 let target_id = self.module_id;
15
16 if ctx.symbol_registry.kind(target_id) != Some(SymbolKind::Mod) {
18 return MutationResult {
19 mutation_type: "RemoveMod".to_string(),
20 changes: 0,
21 description: format!("Symbol {} is not a module", target_id),
22 };
23 }
24
25 let path = ctx.symbol_registry.path(target_id).cloned();
27
28 ctx.symbol_registry.remove(target_id);
30 ctx.ast_registry.remove(target_id);
31
32 if let Some(path) = path {
34 ctx.emit(MutationEvent::SymbolRemoved { path });
35 }
36
37 MutationResult {
38 mutation_type: "RemoveMod".to_string(),
39 changes: 1,
40 description: format!("Removed mod {}", target_id),
41 }
42 }
43}