big_code_analysis_ast/lang_helpers.rs
1//! Byte-level identity helpers shared by the classifiers and the metrics.
2//!
3//! Some questions a walk asks are not answerable from a node's kind: an
4//! Elixir `def` and a `quote` are both `Call` nodes told apart only by
5//! their target text, a Tcl `switch` is a plain `command` whose leading
6//! word names the builtin, and Python's aliased `block` / `lambda` kinds
7//! must be normalised at one site (grammar-dispatch §9 and §10). These
8//! helpers read the bytes once so `Checker`, `Getter`, and every metric
9//! agree on the answer.
10//!
11//! They live beside the classifiers rather than in a metric module
12//! because the classifiers consult them: a `Checker` impl that imported
13//! a helper *from* `metrics::cognitive` would make the parse layer depend
14//! on the metric layer, the inversion #1376 exists to remove.
15
16pub mod bash;
17// Crate-private: the doc-comment predicates are read by this crate's
18// `Checker` impls; only the run walk the LOC metric drives is
19// re-exported below.
20pub(crate) mod doc_comment;
21// Crate-private: Doxygen's attachment rule, read by the four C-family
22// `Checker` impls only (#1613).
23pub(crate) mod doxygen;
24pub mod elixir;
25// Crate-private: this dialect's only helper is a kind table the three
26// classifiers in this crate share, and nothing outside names it.
27pub(crate) mod irules;
28pub mod perl;
29pub mod python;
30pub mod tcl;
31// Crate-private for the same reason as `irules` above: the braced-word
32// slot rule is read by this crate's three classifiers and by nothing
33// outside it. The one exception is re-exported below rather than by
34// widening the module, which would publish the slot tables too.
35pub(crate) mod tcl_family;
36
37/// Re-exported because both dialects' metrics need it and the module
38/// holding it is crate-private: iRules' nexits and ABC walkers resolve a
39/// leading word themselves rather than through `tcl::tcl_command_name`,
40/// so they normalise the `::` qualifier at their own call sites.
41pub use tcl_family::strip_global_qualifier;
42
43/// Re-exported because the LOC metric bills documentation through them —
44/// Go, Ruby and Lua runs by position, and the doc comments a bound
45/// language's tool attaches — while the predicates beside them stay
46/// crate-private.
47pub use doc_comment::{
48 DocBinding, KeptDocs, bound_doc_run, documents_unbound, documents_where_it_sits,
49 leading_doc_run,
50};