repotoire 0.7.0

Graph-powered code analysis CLI. 110 detectors for security, architecture, bus factor, and code quality.
Documentation
//! Read-only context for `collect_*` recursive AST visitors.
//!
//! Bundles the language tag and the source bytes so visitors don't have
//! to thread the same triple through every recursion. Resolves a
//! DataClumpsDetector finding on the `(lang, node, source, out)` cluster
//! that appeared across 9 `collect_*_sites` / `collect_functions*`
//! visitors in `ast_fingerprint` and 6 security detectors.
//!
//! `node` and `out: &mut Vec<...>` deliberately stay as separate
//! arguments because they change per call: each recursion descends into
//! a different child node, and the accumulator's element type varies
//! per detector (`Vec<EvalSite>`, `Vec<CommandSite>`, ...).
//!
//! Two flavours are provided because `ast_fingerprint` walks operate on
//! `&str` source (so it can call `node_text(node, &str) -> &str`), while
//! security detectors operate on `&[u8]` (so `tree_sitter::Node`'s byte
//! offsets are usable directly without a UTF-8 round-trip).

use crate::parsers::lightweight::Language;

/// Walker context for `&[u8]`-source visitors (security detectors).
#[derive(Clone, Copy)]
pub(crate) struct AstWalkCtx<'a> {
    pub lang: Language,
    pub source: &'a [u8],
}

/// Walker context for `&str`-source visitors (ast_fingerprint).
#[derive(Clone, Copy)]
pub(crate) struct AstWalkStrCtx<'a> {
    pub lang: Language,
    pub source: &'a str,
}