Skip to main content

Module signatures

Module signatures 

Source
Expand description

Signature extraction — regex fallback layer.

IMPORTANT for readers skimming the repo: this file is the fallback, not the primary engine. The default build extracts signatures with tree-sitter via declarative per-language queries in crate::signatures_ts (real ASTs, real multi-line spans, ~27 languages). extract_signatures_with_backend tries that path first and only drops to the line-oriented regex extractors here when the tree-sitter feature is off or a parse yields nothing usable for a file.

The regex extractors are intentionally conservative: single-line declarations, declaration-line spans only (end_line == start_line). Use extract_signatures_with_backend when you need to know — and surface — which backend actually produced a result (gitlab #981).

Structs§

Signature

Enums§

SigBackend
Which extractor produced a signature set: the primary tree-sitter AST path (crate::signatures_ts) or the line-oriented regex fallback in this module. Surfaced so navigation output (ctx_outline) can label its backend honestly and verifiably instead of merely claiming “via tree-sitter” (gitlab #981).

Functions§

exports_not_in_signatures
Exports not already named by key_sigs. Map-mode renderers list the API with full signatures + line ranges; repeating those same names in an exports: line is pure redundancy. Callers surface only the exports the API does not already cover (e.g. re-exports or const/type aliases that aren’t captured as signatures), keeping map lossless while dropping duplicates (#361). Shared by the MCP, CLI, and benchmark map renderers.
extract_signatures_counted
Extract signatures and count the producing backend in the process-lifetime signature_backend_stats. Returns the backend as well, so the engine’s extract_signatures can add its persistent per-extension telemetry.
extract_signatures_with_backend
Like extract_signatures_counted but does not touch the global backend counters, so callers that only want the label (e.g. per-file JSON outline) don’t distort signature_backend_stats; the counted path stays extract_signatures_counted.
signature_backend_stats
Returns (tree_sitter_hits, regex_fallback_hits) since process start.
tdd_legend
One-line legend for TDD symbol notation (GL #580): outputs must be self-describing for vanilla agents without injected rules. Only the symbols actually present in sigs are explained, keeping the line well under the 15-token budget for typical files. Empty when nothing applies.