Skip to main content

normalize_languages/
postscript.rs

1//! PostScript support.
2
3use crate::{ContainerBody, Language, LanguageSymbols};
4use tree_sitter::Node;
5
6/// PostScript language support.
7pub struct PostScript;
8
9impl Language for PostScript {
10    fn name(&self) -> &'static str {
11        "PostScript"
12    }
13    fn extensions(&self) -> &'static [&'static str] {
14        &["ps", "eps"]
15    }
16    fn grammar_name(&self) -> &'static str {
17        "postscript"
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        // PostScript procedure is itself "{ ... }"; no named body field
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        // procedure node spans "{ ... }" directly
36        crate::body::analyze_brace_body(body_node, content, inner_indent)
37    }
38}
39
40impl LanguageSymbols for PostScript {}
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45    use crate::validate_unused_kinds_audit;
46
47    #[test]
48    fn unused_node_kinds_audit() {
49        #[rustfmt::skip]
50        let documented_unused: &[&str] = &[
51            "operator", "document_structure_comment",
52        ];
53        validate_unused_kinds_audit(&PostScript, documented_unused)
54            .expect("PostScript unused node kinds audit failed");
55    }
56}