1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Drift guard for the generated per-language token enums.
//!
//! This module lives at the crate root rather than under `src/languages/`
//! because that directory is wholly owned by the `enums/` codegen — the
//! `enums-codegen-drift` gate flags any hand-written file there as stale.
//!
//! Each `language_<lang>.rs` exposes two generated conversion tables —
//! `From<u16>` (node-kind id → enum variant) and `From<Enum> for
//! &'static str` (variant → kind name). They are pure lookup tables, so
//! nothing exercises most of their arms unless a fixture happens to
//! contain a node of that exact kind; on a typical run they sit at a few
//! percent line coverage and a silent disagreement with the live grammar
//! (e.g. after a grammar bump renumbers node kinds) goes unnoticed.
//!
//! For every supported language we walk all `0..node_kind_count` ids the
//! grammar defines, round-trip each through both tables, and assert the
//! enum's name string agrees with the grammar for every *visible* kind.
//! This both pins the mapping against drift (the same fear behind the
//! `grammar_version` guard in `src/langs.rs`) and drives the generated
//! tables to near-full coverage.
use crateLANG;
use crate*;
/// Round-trips every node-kind id the grammar behind `lang` defines
/// through the generated `From<u16>` and `From<Enum> for &'static str`
/// tables, asserting the enum name matches the grammar for each visible
/// kind. Languages whose grammar feature is disabled in the current
/// build are skipped (the enum surface is always compiled, but
/// `tree_sitter_language` hands back `Err(LanguageDisabled)`).
// One arm per `mk_langs!` entry in `src/langs.rs`. Keep in sync: a new
// language must gain a round-trip test here too.
roundtrip_tests!;