1use oak_core::SyntaxKind;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
6pub enum JavaScriptSyntaxKind {
7    Root,
9    Program,
10    Statement,
11    Expression,
12    Declaration,
13    FunctionDeclaration,
14    VariableDeclaration,
15    ClassDeclaration,
16    ImportDeclaration,
17    ExportDeclaration,
18    IfStatement,
19    WhileStatement,
20    ForStatement,
21    BlockStatement,
22    ExpressionStatement,
23    ReturnStatement,
24    BreakStatement,
25    ContinueStatement,
26    ThrowStatement,
27    TryStatement,
28    CatchClause,
29    FinallyClause,
30    SwitchStatement,
31    CaseClause,
32    DefaultClause,
33
34    BinaryExpression,
36    UnaryExpression,
37    AssignmentExpression,
38    CallExpression,
39    MemberExpression,
40    ConditionalExpression,
41    ArrayExpression,
42    ObjectExpression,
43    FunctionExpression,
44    ArrowFunctionExpression,
45    NewExpression,
46    UpdateExpression,
47    LogicalExpression,
48    SequenceExpression,
49    ThisExpression,
50    Identifier,
51    Literal,
52    TemplateLiteral,
53    TaggedTemplateExpression,
54
55    ObjectPattern,
57    ArrayPattern,
58    RestElement,
59    AssignmentPattern,
60    Property,
61
62    ErrorNode,
64
65    Abstract,
67    As,
68    Async,
69    Await,
70    Break,
71    Case,
72    Catch,
73    Class,
74    Const,
75    Continue,
76    Debugger,
77    Default,
78    Delete,
79    Do,
80    Else,
81    Enum,
82    Export,
83    Extends,
84    False,
85    Finally,
86    For,
87    Function,
88    If,
89    Implements,
90    Import,
91    In,
92    Instanceof,
93    Interface,
94    Let,
95    New,
96    Null,
97    Package,
98    Private,
99    Protected,
100    Public,
101    Return,
102    Static,
103    Super,
104    Switch,
105    This,
106    Throw,
107    True,
108    Try,
109    Typeof,
110    Undefined,
111    Var,
112    Void,
113    While,
114    With,
115    Yield,
116
117    Plus,               Minus,              Star,               Slash,              Percent,            StarStar,           PlusPlus,           MinusMinus,         LeftShift,          RightShift,         UnsignedRightShift, Less,               Greater,            LessEqual,          GreaterEqual,       EqualEqual,         NotEqual,           EqualEqualEqual,    NotEqualEqual,      Ampersand,          Pipe,               Caret,              Exclamation,        Tilde,              AmpersandAmpersand, PipePipe,           Question,           QuestionQuestion,   QuestionDot,        Equal,                   PlusEqual,               MinusEqual,              StarEqual,               SlashEqual,              PercentEqual,            StarStarEqual,           LeftShiftEqual,          RightShiftEqual,         UnsignedRightShiftEqual, AmpersandEqual,          PipeEqual,               CaretEqual,              AmpersandAmpersandEqual, PipePipeEqual,           QuestionQuestionEqual,   LeftParen,    RightParen,   LeftBrace,    RightBrace,   LeftBracket,  RightBracket, Semicolon,    Comma,        Dot,          DotDotDot,    Colon,        Arrow,        StringLiteral,
182    NumericLiteral,
183    BigIntLiteral,
184    RegexLiteral,
185    TemplateString,
186    TemplateHead,
187    TemplateMiddle,
188    TemplateTail,
189
190    IdentifierName,
192
193    LineComment,
195    BlockComment,
196    Whitespace,
197    Newline,
198
199    Eof,
201    Error,
202}
203
204impl SyntaxKind for JavaScriptSyntaxKind {
205    fn is_trivia(&self) -> bool {
206        matches!(self, Self::LineComment | Self::BlockComment | Self::Whitespace | Self::Newline)
207    }
208
209    fn is_comment(&self) -> bool {
210        matches!(self, Self::LineComment | Self::BlockComment)
211    }
212
213    fn is_whitespace(&self) -> bool {
214        matches!(self, Self::Whitespace | Self::Newline)
215    }
216
217    fn is_token_type(&self) -> bool {
218        !matches!(
219            self,
220            Self::Root
221                | Self::Program
222                | Self::Statement
223                | Self::Expression
224                | Self::Declaration
225                | Self::FunctionDeclaration
226                | Self::VariableDeclaration
227                | Self::ClassDeclaration
228                | Self::ImportDeclaration
229                | Self::ExportDeclaration
230                | Self::IfStatement
231                | Self::WhileStatement
232                | Self::ForStatement
233                | Self::BlockStatement
234                | Self::ExpressionStatement
235                | Self::ReturnStatement
236                | Self::BreakStatement
237                | Self::ContinueStatement
238                | Self::ThrowStatement
239                | Self::TryStatement
240                | Self::CatchClause
241                | Self::FinallyClause
242                | Self::SwitchStatement
243                | Self::CaseClause
244                | Self::DefaultClause
245                | Self::BinaryExpression
246                | Self::UnaryExpression
247                | Self::AssignmentExpression
248                | Self::CallExpression
249                | Self::MemberExpression
250                | Self::ConditionalExpression
251                | Self::ArrayExpression
252                | Self::ObjectExpression
253                | Self::FunctionExpression
254                | Self::ArrowFunctionExpression
255                | Self::NewExpression
256                | Self::UpdateExpression
257                | Self::LogicalExpression
258                | Self::SequenceExpression
259                | Self::ThisExpression
260                | Self::Identifier
261                | Self::Literal
262                | Self::TemplateLiteral
263                | Self::TaggedTemplateExpression
264                | Self::ObjectPattern
265                | Self::ArrayPattern
266                | Self::RestElement
267                | Self::AssignmentPattern
268                | Self::Property
269                | Self::ErrorNode
270        )
271    }
272
273    fn is_element_type(&self) -> bool {
274        matches!(
275            self,
276            Self::Root
277                | Self::Program
278                | Self::Statement
279                | Self::Expression
280                | Self::Declaration
281                | Self::FunctionDeclaration
282                | Self::VariableDeclaration
283                | Self::ClassDeclaration
284                | Self::ImportDeclaration
285                | Self::ExportDeclaration
286                | Self::IfStatement
287                | Self::WhileStatement
288                | Self::ForStatement
289                | Self::BlockStatement
290                | Self::ExpressionStatement
291                | Self::ReturnStatement
292                | Self::BreakStatement
293                | Self::ContinueStatement
294                | Self::ThrowStatement
295                | Self::TryStatement
296                | Self::CatchClause
297                | Self::FinallyClause
298                | Self::SwitchStatement
299                | Self::CaseClause
300                | Self::DefaultClause
301                | Self::BinaryExpression
302                | Self::UnaryExpression
303                | Self::AssignmentExpression
304                | Self::CallExpression
305                | Self::MemberExpression
306                | Self::ConditionalExpression
307                | Self::ArrayExpression
308                | Self::ObjectExpression
309                | Self::FunctionExpression
310                | Self::ArrowFunctionExpression
311                | Self::NewExpression
312                | Self::UpdateExpression
313                | Self::LogicalExpression
314                | Self::SequenceExpression
315                | Self::ThisExpression
316                | Self::Identifier
317                | Self::Literal
318                | Self::TemplateLiteral
319                | Self::TaggedTemplateExpression
320                | Self::ObjectPattern
321                | Self::ArrayPattern
322                | Self::RestElement
323                | Self::AssignmentPattern
324                | Self::Property
325                | Self::ErrorNode
326        )
327    }
328}