Skip to main content

EntryPointDetector

Trait EntryPointDetector 

Source
pub trait EntryPointDetector {
    // Required method
    fn detect(&self, source: &str, file_path: &Path) -> Vec<EntryPoint>;
}
Expand description

Per-language entry-point detector.

Designed for consumption by RepoGraph::compute_dead_code in 4.1.0-X2. Until X2 lands, the only consumers are the integration tests under crates/ripvec-core/tests/entry_points.rs — see the module-level docstring for the Type B (Wired-Stub) self-audit note.

Implementations parse the source once per call. The parsing cost is trivial (tree-sitter is O(n) and the source is already in memory at detection time), and stateless parsers compose more cleanly than a shared parser cache across the three (and eventually eleven) language detectors. X2’s RepoGraph::compute_dead_code already iterates per-file, so the per-file parse adds no additional walk cost.

Required Methods§

Source

fn detect(&self, source: &str, file_path: &Path) -> Vec<EntryPoint>

Return every entry point declared in this source file.

source is the full UTF-8 contents of file_path. The path is passed alongside source so detectors that consider filename patterns (e.g. Python’s test_*.py and *_test.py, Rust’s build.rs) can use both signals.

If parsing fails, returns an empty vector — entry-point detection is best-effort and should never abort the dead-code walk.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§