oak_css/kind/
mod.rs

1#![allow(non_camel_case_types)]
2
3use oak_core::SyntaxKind;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6#[repr(u16)]
7pub enum CssSyntaxKind {
8    // Trivia
9    Whitespace = 0,
10    Newline,
11    Comment,
12
13    // Literals
14    StringLiteral,
15    NumberLiteral,
16    ColorLiteral,
17    UrlLiteral,
18
19    // Identifiers and keywords
20    Identifier,
21    ClassName,
22    IdSelector,
23    TagName,
24    PseudoClass,
25    PseudoElement,
26    AttributeName,
27    PropertyName,
28    FunctionName,
29
30    // CSS Keywords
31    Important,
32    Inherit,
33    Initial,
34    Unset,
35    Auto,
36    None,
37    Normal,
38
39    // Units
40    Px,
41    Em,
42    Rem,
43    Percent,
44    Vh,
45    Vw,
46    Pt,
47    Cm,
48    Mm,
49    In,
50    Pc,
51    Ex,
52    Ch,
53    Vmin,
54    Vmax,
55
56    // Operators and punctuation
57    Colon,       // :
58    Semicolon,   // ;
59    Comma,       // ,
60    Dot,         // .
61    Hash,        // #
62    Plus,        // +
63    Minus,       // -
64    Star,        // *
65    Slash,       // /
66    Equals,      // =
67    Tilde,       // ~
68    Pipe,        // |
69    Caret,       // ^
70    Dollar,      // $
71    GreaterThan, // >
72
73    // Delimiters
74    LeftParen,    // (
75    RightParen,   // )
76    LeftBrace,    // {
77    RightBrace,   // }
78    LeftBracket,  // [
79    RightBracket, // ]
80
81    // At-rules
82    AtRule,
83    AtImport,
84    AtMedia,
85    AtKeyframes,
86    AtFontFace,
87    AtCharset,
88    AtNamespace,
89    AtSupports,
90    AtPage,
91    AtDocument,
92
93    // Special tokens
94    MediaQuery,
95    Selector,
96    Declaration,
97    Value,
98    Function,
99    Url,
100    CalcExpression,
101
102    // Compound nodes
103    SourceFile,
104    Error,
105    Eof,
106}
107
108impl SyntaxKind for CssSyntaxKind {
109    fn is_trivia(&self) -> bool {
110        matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
111    }
112
113    fn is_comment(&self) -> bool {
114        matches!(self, Self::Comment)
115    }
116
117    fn is_whitespace(&self) -> bool {
118        matches!(self, Self::Whitespace | Self::Newline)
119    }
120
121    fn is_token_type(&self) -> bool {
122        !matches!(
123            self,
124            Self::SourceFile
125                | Self::MediaQuery
126                | Self::Selector
127                | Self::Declaration
128                | Self::Value
129                | Self::Function
130                | Self::Url
131                | Self::CalcExpression
132        )
133    }
134
135    fn is_element_type(&self) -> bool {
136        matches!(
137            self,
138            Self::SourceFile
139                | Self::MediaQuery
140                | Self::Selector
141                | Self::Declaration
142                | Self::Value
143                | Self::Function
144                | Self::Url
145                | Self::CalcExpression
146        )
147    }
148}