1use oak_core::{ElementType, TokenType, UniversalElementRole, UniversalTokenRole};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub enum TypeScriptSyntaxKind {
6 Root,
8 SourceFile,
9 Module,
10
11 VariableDeclaration,
13 FunctionDeclaration,
14 ClassDeclaration,
15 InterfaceDeclaration,
16 TypeAliasDeclaration,
17 EnumDeclaration,
18 NamespaceDeclaration,
19 ImportDeclaration,
20 ExportDeclaration,
21
22 BinaryExpression,
24 UnaryExpression,
25 ConditionalExpression,
26 CallExpression,
27 NewExpression,
28 MemberExpression,
29 ArrayExpression,
30 ObjectExpression,
31 FunctionExpression,
32 ArrowFunction,
33 TemplateExpression,
34 TaggedTemplateExpression,
35 AsExpression,
36 TypeAssertionExpression,
37 NonNullExpression,
38
39 ExpressionStatement,
41 BlockStatement,
42 IfStatement,
43 WhileStatement,
44 ForStatement,
45 ForInStatement,
46 ForOfStatement,
47 DoWhileStatement,
48 SwitchStatement,
49 CaseClause,
50 DefaultClause,
51 TryStatement,
52 CatchClause,
53 FinallyClause,
54 ThrowStatement,
55 ReturnStatement,
56 BreakStatement,
57 ContinueStatement,
58 DebuggerStatement,
59 WithStatement,
60
61 BindingPattern,
63 ArrayBindingPattern,
64 ObjectBindingPattern,
65 BindingElement,
66
67 TypeReference,
69 TypeLiteral,
70 FunctionType,
71 ConstructorType,
72 ArrayType,
73 TupleType,
74 UnionType,
75 IntersectionType,
76 ConditionalType,
77 MappedType,
78 IndexedAccessType,
79 TypeQuery,
80 TypePredicate,
81
82 Error,
84
85 Abstract,
87 Any,
88 As,
89 Asserts,
90 Async,
91 Await,
92 Boolean,
93 Break,
94 Case,
95 Catch,
96 Class,
97 Const,
98 Constructor,
99 Continue,
100 Debugger,
101 Declare,
102 Default,
103 Delete,
104 Do,
105 Else,
106 Enum,
107 Export,
108 Extends,
109 False,
110 Finally,
111 For,
112 From,
113 Function,
114 Get,
115 Global,
116 If,
117 Implements,
118 Import,
119 In,
120 Infer,
121 Instanceof,
122 Interface,
123 Is,
124 Keyof,
125 Let,
126 Namespace,
127 Never,
128 New,
129 Null,
130 Number,
131 Object,
132 Of,
133 Package,
134 Private,
135 Protected,
136 Public,
137 Readonly,
138 Require,
139 Return,
140 Set,
141 Static,
142 String,
143 Super,
144 Switch,
145 Symbol,
146 This,
147 Throw,
148 True,
149 Try,
150 Type,
151 Typeof,
152 Undefined,
153 Unique,
154 Unknown,
155 Var,
156 Void,
157 While,
158 With,
159 Yield,
160
161 Plus,
163 Minus,
164 Star,
165 Slash,
166 Percent,
167 StarStar,
168
169 Less,
171 Greater,
172 LessEqual,
173 GreaterEqual,
174 EqualEqual,
175 NotEqual,
176 EqualEqualEqual,
177 NotEqualEqual,
178
179 AmpersandAmpersand,
181 PipePipe,
182 Exclamation,
183
184 Ampersand,
186 Pipe,
187 Caret,
188 Tilde,
189 LeftShift,
190 RightShift,
191 UnsignedRightShift,
192
193 Equal,
195 PlusEqual,
196 MinusEqual,
197 StarEqual,
198 SlashEqual,
199 PercentEqual,
200 StarStarEqual,
201 LeftShiftEqual,
202 RightShiftEqual,
203 UnsignedRightShiftEqual,
204 AmpersandEqual,
205 PipeEqual,
206 CaretEqual,
207 AmpersandAmpersandEqual,
208 PipePipeEqual,
209 QuestionQuestionEqual,
210
211 PlusPlus,
213 MinusMinus,
214
215 Question,
217 QuestionQuestion,
218 QuestionDot,
219 Arrow,
220
221 LeftParen,
223 RightParen,
224 LeftBrace,
225 RightBrace,
226 LeftBracket,
227 RightBracket,
228 Semicolon,
229 Comma,
230 Dot,
231 DotDotDot,
232 Colon,
233
234 StringLiteral,
236 NumericLiteral,
237 BigIntLiteral,
238 TemplateString,
239 RegexLiteral,
240
241 IdentifierName,
243
244 LineComment,
246 BlockComment,
247 Whitespace,
248 Newline,
249
250 Eof,
252}
253
254impl TokenType for TypeScriptSyntaxKind {
255 const END_OF_STREAM: Self = Self::Eof;
256 type Role = UniversalTokenRole;
257
258 fn role(&self) -> Self::Role {
259 match self {
260 TypeScriptSyntaxKind::Whitespace | TypeScriptSyntaxKind::Newline => UniversalTokenRole::Whitespace,
261 TypeScriptSyntaxKind::LineComment | TypeScriptSyntaxKind::BlockComment => UniversalTokenRole::Comment,
262 Self::Eof => UniversalTokenRole::Eof,
263 _ => UniversalTokenRole::None,
264 }
265 }
266}
267
268impl ElementType for TypeScriptSyntaxKind {
269 type Role = UniversalElementRole;
270
271 fn role(&self) -> Self::Role {
272 match self {
273 Self::Error => UniversalElementRole::Error,
274 _ => UniversalElementRole::None,
275 }
276 }
277}