normalize_languages/
sql.rs1use crate::{Language, LanguageSymbols};
4use tree_sitter::Node;
5
6pub struct Sql;
8
9impl Language for Sql {
10 fn name(&self) -> &'static str {
11 "SQL"
12 }
13 fn extensions(&self) -> &'static [&'static str] {
14 &["sql"]
15 }
16 fn grammar_name(&self) -> &'static str {
17 "sql"
18 }
19
20 fn as_symbols(&self) -> Option<&dyn LanguageSymbols> {
21 Some(self)
22 }
23
24 fn build_signature(&self, node: &Node, content: &str) -> String {
25 let text = &content[node.byte_range()];
27 text.lines().next().unwrap_or(text).trim().to_string()
28 }
29
30 fn node_name<'a>(&self, _node: &Node, _content: &'a str) -> Option<&'a str> {
31 None
32 }
33}
34
35impl LanguageSymbols for Sql {}
36
37#[cfg(test)]
38mod tests {
39 use super::*;
40 use crate::validate_unused_kinds_audit;
41
42 #[test]
43 fn unused_node_kinds_audit() {
44 #[rustfmt::skip]
45 let documented_unused: &[&str] = &[
46 "alter_type", "array_size_definition", "between_expression", "binary_expression",
47 "block", "column_definition", "column_definitions", "comment_statement",
48 "drop_function", "drop_type", "enum", "enum_elements", "filter_expression",
49 "frame_definition", "function_argument", "function_arguments",
50 "function_body", "function_cost", "function_declaration", "function_language",
51 "function_leakproof", "function_rows", "function_safety", "function_security",
52 "function_strictness", "function_support", "function_volatility",
53 "keyword_before", "keyword_case", "keyword_else", "keyword_enum",
54 "keyword_except", "keyword_for", "keyword_force", "keyword_force_not_null",
55 "keyword_force_null", "keyword_force_quote", "keyword_foreign",
56 "keyword_format", "keyword_function", "keyword_geometry", "keyword_if",
57 "keyword_match", "keyword_matched", "keyword_modify", "keyword_regclass",
58 "keyword_regtype", "keyword_return", "keyword_returning", "keyword_returns",
59 "keyword_statement", "keyword_type", "keyword_while", "keyword_with",
60 "keyword_without", "modify_column", "parenthesized_expression",
61 "reset_statement", "returning", "row_format", "select_expression",
62 "set_statement", "statement", "unary_expression", "var_declaration",
63 "var_declarations", "when_clause", "while_statement", "window_clause",
64 "window_function", "window_specification",
65 "case",
67 ];
68 validate_unused_kinds_audit(&Sql, documented_unused)
69 .expect("SQL unused node kinds audit failed");
70 }
71}