From 53bdfe60f01534e0efc4e9709648736a4db01f60 Mon Sep 17 00:00:00 2001 From: Freddie Ridell Date: Wed, 11 Mar 2026 23:38:33 +0000 Subject: [PATCH] Rename span to subst_span and add mutation scoring --- crates/bough-core/src/mutant.rs | 16 +++++------ crates/bough-core/src/mutation_score.rs | 36 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/crates/bough-core/src/mutant.rs b/crates/bough-core/src/mutant.rs index ade20df7..76631f07 100644 --- a/crates/bough-core/src/mutant.rs +++ b/crates/bough-core/src/mutant.rs @@ -33,7 +33,7 @@ pub struct Mutant { lang: LanguageId, twig: Twig, kind: MutantKind, - span: Span, + subst_span: Span, } impl Mutant { @@ -42,7 +42,7 @@ impl Mutant { lang, twig, kind, - span, + subst_span: span, } } @@ -59,7 +59,7 @@ impl Mutant { } pub fn span(&self) -> &Span { - &self.span + &self.subst_span } pub fn get_contextual_fragment( @@ -81,11 +81,11 @@ impl Mutant { let root = tree.root_node(); let target = root - .descendant_for_byte_range(self.span.start().byte(), self.span.end().byte()) + .descendant_for_byte_range(self.subst_span.start().byte(), self.subst_span.end().byte()) .unwrap_or(root); - let mutant_start_line = self.span.start().line(); - let mutant_end_line = self.span.end().line(); + let mutant_start_line = self.subst_span.start().line(); + let mutant_end_line = self.subst_span.end().line(); let mut candidate = target; let mut current = target; @@ -175,7 +175,7 @@ impl<'a> BasedMutant<'a> { } pub fn span(&self) -> &Span { - &self.mutant.span + &self.mutant.subst_span } } @@ -192,7 +192,7 @@ impl HashInto for Mutant { .as_os_str() .as_encoded_bytes() .hash_into(state)?; - self.span.hash_into(state)?; + self.subst_span.hash_into(state)?; self.kind.hash_into(state)?; Ok(()) } diff --git a/crates/bough-core/src/mutation_score.rs b/crates/bough-core/src/mutation_score.rs index 99ad8b52..173001de 100644 --- a/crates/bough-core/src/mutation_score.rs +++ b/crates/bough-core/src/mutation_score.rs @@ -1,5 +1,9 @@ +use std::sync::Arc; + use facet::Facet; +use crate::{Mutation, base::Base}; + #[derive(Facet, Debug, Clone, Copy, PartialEq, Eq)] #[repr(u8)] pub enum Factor { @@ -20,3 +24,35 @@ pub enum Factor { /// How recently was this line touched VcsLineBlameRecency, } + +struct OpaqueScore(u64); + +pub struct MutationScorer { + factor: Factor, + base: Arc, +} + +pub struct MutationScoreViewer { + min: u64, + max: u64, +} + +impl MutationScorer { + pub fn new(base: Arc, factor: Factor) -> Self { + Self { base, factor } + } + + pub fn score(&mut self, mutation: Mutation) -> OpaqueScore { + todo!() + } + + pub fn view(self) -> MutationScoreViewer { + todo!() + } +} + +impl MutationScoreViewer { + fn view(&self, os: OpaqueScore) -> f64 { + todo!() + } +} -- knotmirror 0.0.1