Skip to main content

normalize_languages/
sparql.rs

1//! SPARQL query language support.
2
3use crate::{Language, LanguageSymbols};
4
5/// SPARQL language support.
6pub struct Sparql;
7
8impl Language for Sparql {
9    fn name(&self) -> &'static str {
10        "SPARQL"
11    }
12    fn extensions(&self) -> &'static [&'static str] {
13        &["sparql", "rq"]
14    }
15    fn grammar_name(&self) -> &'static str {
16        "sparql"
17    }
18
19    fn as_symbols(&self) -> Option<&dyn LanguageSymbols> {
20        Some(self)
21    }
22}
23
24impl LanguageSymbols for Sparql {}
25
26#[cfg(test)]
27mod tests {
28    use super::*;
29    use crate::validate_unused_kinds_audit;
30
31    #[test]
32    fn unused_node_kinds_audit() {
33        #[rustfmt::skip]
34        let documented_unused: &[&str] = &[
35            // Query parts
36            "select_clause", "where_clause", "construct_query", "construct_template",
37            "construct_triples", "triples_block",
38            // Modifiers
39            "solution_modifier", "order_clause", "limit_clause", "offset_clause",
40            "limit_offset_clauses", "group_clause", "having_clause", "values_clause",
41            // Dataset
42            "dataset_clause", "default_graph_clause", "named_graph_clause",
43            // Update
44            "modify", "insert_clause", "delete_clause", "using_clause", "data_block",
45            // Declarations
46            "base_declaration", "prefix_declaration",
47            // Expressions
48            "expression_list", "binary_expression", "unary_expression",
49            "bracketted_expression", "function_call", "build_in_function",
50            "regex_expression", "substring_expression", "string_replace_expression",
51        ];
52        validate_unused_kinds_audit(&Sparql, documented_unused)
53            .expect("SPARQL unused node kinds audit failed");
54    }
55}