Skip to main content

normalize_languages/
uiua.rs

1//! Uiua array programming language support.
2
3use crate::{Language, LanguageSymbols};
4
5/// Uiua language support.
6pub struct Uiua;
7
8impl Language for Uiua {
9    fn name(&self) -> &'static str {
10        "Uiua"
11    }
12    fn extensions(&self) -> &'static [&'static str] {
13        &["ua"]
14    }
15    fn grammar_name(&self) -> &'static str {
16        "uiua"
17    }
18
19    fn as_symbols(&self) -> Option<&dyn LanguageSymbols> {
20        Some(self)
21    }
22
23    fn is_test_symbol(&self, symbol: &crate::Symbol) -> bool {
24        let name = symbol.name.as_str();
25        match symbol.kind {
26            crate::SymbolKind::Function | crate::SymbolKind::Method => name.starts_with("test_"),
27            crate::SymbolKind::Module => name == "tests" || name == "test",
28            _ => false,
29        }
30    }
31}
32
33impl LanguageSymbols for Uiua {}
34
35#[cfg(test)]
36mod tests {
37    use super::*;
38    use crate::validate_unused_kinds_audit;
39
40    #[test]
41    fn unused_node_kinds_audit() {
42        #[rustfmt::skip]
43        let documented_unused: &[&str] = &[
44            // Functions and modifiers
45            "function", "inlineFunction", "switchFunctions",
46            "modifier1", "modifier2",
47            // Other
48            "module", "identifier", "identifierDeprecated", "formatter",
49        ];
50        validate_unused_kinds_audit(&Uiua, documented_unused)
51            .expect("Uiua unused node kinds audit failed");
52    }
53}