pub struct ContextDetector { /* private fields */ }Expand description
Detects the context or domain of functions based on naming patterns and file location.
The detector uses compiled regexes to identify common function naming conventions
(e.g., format_*, parse_*, handle_*) and file path patterns to classify
functions into domain-specific contexts.
§Performance
Creating a new ContextDetector compiles 17 regexes. For repeated use,
prefer the ContextDetector::global() singleton to avoid recompilation.
§Example
use debtmap::analysis::context_detection::ContextDetector;
use std::path::Path;
let detector = ContextDetector::global();
let analysis = detector.detect_context(&function, Path::new("src/parser.rs"));
println!("Context: {:?}, confidence: {}", analysis.context, analysis.confidence);Implementations§
Source§impl ContextDetector
impl ContextDetector
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new context detector with compiled regex patterns.
Compiles 17 regexes for pattern matching. For hot paths, prefer
ContextDetector::global() to reuse a singleton instance.
Sourcepub fn global() -> &'static Self
pub fn global() -> &'static Self
Get the global singleton instance.
This avoids repeated regex compilation when called from hot paths. The singleton is lazily initialized on first access.
Sourcepub fn detect_context(
&self,
function: &FunctionMetrics,
file_path: &Path,
) -> ContextAnalysis
pub fn detect_context( &self, function: &FunctionMetrics, file_path: &Path, ) -> ContextAnalysis
Detect the context of a function
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContextDetector
impl RefUnwindSafe for ContextDetector
impl Send for ContextDetector
impl Sync for ContextDetector
impl Unpin for ContextDetector
impl UnsafeUnpin for ContextDetector
impl UnwindSafe for ContextDetector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> EnsureExt<T> for T
impl<T> EnsureExt<T> for T
Source§fn ensure<P, E>(self, predicate: P, error: E) -> Validation<T, NonEmptyVec<E>>where
P: Predicate<T>,
fn ensure<P, E>(self, predicate: P, error: E) -> Validation<T, NonEmptyVec<E>>where
P: Predicate<T>,
Source§fn ensure_with<P, E, F>(
self,
predicate: P,
error_fn: F,
) -> Validation<T, NonEmptyVec<E>>
fn ensure_with<P, E, F>( self, predicate: P, error_fn: F, ) -> Validation<T, NonEmptyVec<E>>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more