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 elixir;
17// Crate-private: this dialect's only helper is a kind table the three
18// classifiers in this crate share, and nothing outside names it.
19pub(crate) mod irules;
20pub mod python;
21pub mod tcl;
22// Crate-private for the same reason as `irules` above: the braced-word
23// slot rule is read by this crate's three classifiers and by nothing
24// outside it. The one exception is re-exported below rather than by
25// widening the module, which would publish the slot tables too.
26pub(crate) mod tcl_family;
27
28/// Re-exported because both dialects' metrics need it and the module
29/// holding it is crate-private: iRules' nexits and ABC walkers resolve a
30/// leading word themselves rather than through `tcl::tcl_command_name`,
31/// so they normalise the `::` qualifier at their own call sites.
32pub use tcl_family::strip_global_qualifier;