1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
use super::*;

impl Debug for AnnotationNode {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        if self.is_empty() {
            f.debug_struct("Empty").finish()
        }
        else {
            let mut w = f.debug_struct("Annotation");
            if !self.documents.is_empty() {
                w.field("documents", &self.documents);
            }
            if !self.attributes.is_empty() {
                w.field("attributes", &self.attributes);
            }
            if !self.modifiers.is_empty() {
                w.field("modifiers", &WrapDisplay::new(&self.modifiers));
            }
            w.finish()
        }
    }
}

impl Display for AttributeKind {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(feature = "pretty-print")]
impl PrettyPrint for AttributeKind {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        theme.annotation(self.as_str())
    }
}
#[cfg(feature = "pretty-print")]
impl PrettyPrint for AttributeTerm {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        let mut terms = PrettySequence::new(2);
        terms += self.kind.pretty(theme);
        terms += self.term.pretty(theme);
        terms.into()
    }
}

impl Debug for AttributeList {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.debug_list().entries(self.terms.iter()).finish()
    }
}

#[cfg(feature = "pretty-print")]
impl PrettyPrint for AttributeList {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        let mut terms = PrettySequence::new(self.terms.len());
        terms += self.kind.pretty(theme);
        terms += theme.annotation("[");
        for term in &self.terms {
            terms += term.pretty(theme);
        }
        terms += theme.annotation("]");
        terms.into()
    }
}
#[cfg(feature = "pretty-print")]
impl PrettyPrint for AttributeTerm {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        let mut terms = PrettySequence::new(3);
        terms += self.path.pretty(theme);
        terms += self.arguments.pretty(theme);
        terms += self.domain.pretty(theme);
        terms.into()
    }
}
#[cfg(feature = "pretty-print")]
impl PrettyPrint for AttributeName {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        theme.annotation(self.to_string())
    }
}

impl Debug for ModifierList {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.debug_list().entries(self.terms.iter()).finish()
    }
}

impl Display for ModifierList {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.debug_list().entries(self.terms.iter().map(|v| WrapDisplay::new(&v.name))).finish()
    }
}

#[cfg(feature = "lispify")]
impl Lispify for ModifierList {
    type Output = Lisp;

    fn lispify(&self) -> Self::Output {
        let mut lisp = Lisp::new(4);
        lisp += Lisp::keyword("modifiers");
        for modifier in &self.terms {
            lisp += modifier.lispify();
        }
        lisp
    }
}