normalize_languages/
awk.rs1use crate::{Language, LanguageSymbols};
4
5pub struct Awk;
7
8impl Language for Awk {
9 fn name(&self) -> &'static str {
10 "AWK"
11 }
12 fn extensions(&self) -> &'static [&'static str] {
13 &["awk", "gawk"]
14 }
15 fn grammar_name(&self) -> &'static str {
16 "awk"
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 Awk {}
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 "break_statement", "continue_statement", "delete_statement", "do_while_statement",
45 "else_clause", "exit_statement", "identifier", "next_statement", "nextfile_statement",
46 "ns_qualified_name", "piped_io_statement", "print_statement", "printf_statement",
47 "redirected_io_statement", "return_statement", "switch_body", "switch_case",
48 "switch_statement",
49 "if_statement",
51 "for_in_statement",
52 "for_statement",
53 "while_statement",
54 "block",
55 ];
56 validate_unused_kinds_audit(&Awk, documented_unused)
57 .expect("AWK unused node kinds audit failed");
58 }
59}