Skip to main content

normalize_languages/
ron.rs

1//! RON (Rusty Object Notation) support.
2
3use crate::{ContainerBody, Language, LanguageSymbols};
4use tree_sitter::Node;
5
6/// RON language support.
7pub struct Ron;
8
9impl Language for Ron {
10    fn name(&self) -> &'static str {
11        "RON"
12    }
13    fn extensions(&self) -> &'static [&'static str] {
14        &["ron"]
15    }
16    fn grammar_name(&self) -> &'static str {
17        "ron"
18    }
19
20    fn as_symbols(&self) -> Option<&dyn LanguageSymbols> {
21        Some(self)
22    }
23
24    fn container_body<'a>(&self, node: &'a Node<'a>) -> Option<Node<'a>> {
25        // RON struct uses ( ... ), map uses { ... }; use node itself for body analysis
26        Some(*node)
27    }
28
29    fn analyze_container_body(
30        &self,
31        body_node: &Node,
32        content: &str,
33        inner_indent: &str,
34    ) -> Option<ContainerBody> {
35        match body_node.kind() {
36            "struct" => crate::body::analyze_paren_body(body_node, content, inner_indent),
37            "map" => crate::body::analyze_brace_body(body_node, content, inner_indent),
38            _ => None,
39        }
40    }
41}
42
43impl LanguageSymbols for Ron {}
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48    use crate::validate_unused_kinds_audit;
49
50    #[test]
51    fn unused_node_kinds_audit() {
52        #[rustfmt::skip]
53        let documented_unused: &[&str] = &[
54            "identifier", "struct_name", "unit_struct", "enum_variant",
55            "map_entry", "block_comment",
56            // structural node, not extracted as symbols
57            "struct",
58            "struct_entry",
59        ];
60        validate_unused_kinds_audit(&Ron, documented_unused)
61            .expect("RON unused node kinds audit failed");
62    }
63}