Skip to content

Commit dda4a58

Browse files
committed
refactor(ast): add AstKind for AssignmentTargetRest
1 parent 3f91f24 commit dda4a58

File tree

8 files changed

+187
-160
lines changed

8 files changed

+187
-160
lines changed

crates/oxc_ast/src/ast_kind_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ impl AstKind<'_> {
414414
Self::JSDocNullableType(_) => "JSDocNullableType".into(),
415415
Self::JSDocNonNullableType(_) => "JSDocNonNullableType".into(),
416416
Self::JSDocUnknownType(_) => "JSDocUnknownType".into(),
417+
Self::AssignmentTargetRest(_) => "AssignmentTargetRest".into(),
417418
}
418419
}
419420
}

crates/oxc_ast/src/generated/ast_kind.rs

Lines changed: 163 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -48,160 +48,161 @@ pub enum AstType {
4848
AssignmentTargetPattern = 31,
4949
ArrayAssignmentTarget = 32,
5050
ObjectAssignmentTarget = 33,
51-
AssignmentTargetWithDefault = 34,
52-
SequenceExpression = 35,
53-
Super = 36,
54-
AwaitExpression = 37,
55-
ChainExpression = 38,
56-
ParenthesizedExpression = 39,
57-
Directive = 40,
58-
Hashbang = 41,
59-
BlockStatement = 42,
60-
VariableDeclaration = 43,
61-
VariableDeclarator = 44,
62-
EmptyStatement = 45,
63-
ExpressionStatement = 46,
64-
IfStatement = 47,
65-
DoWhileStatement = 48,
66-
WhileStatement = 49,
67-
ForStatement = 50,
68-
ForInStatement = 51,
69-
ForOfStatement = 52,
70-
ContinueStatement = 53,
71-
BreakStatement = 54,
72-
ReturnStatement = 55,
73-
WithStatement = 56,
74-
SwitchStatement = 57,
75-
SwitchCase = 58,
76-
LabeledStatement = 59,
77-
ThrowStatement = 60,
78-
TryStatement = 61,
79-
CatchClause = 62,
80-
CatchParameter = 63,
81-
DebuggerStatement = 64,
82-
AssignmentPattern = 65,
83-
ObjectPattern = 66,
84-
BindingProperty = 67,
85-
ArrayPattern = 68,
86-
BindingRestElement = 69,
87-
Function = 70,
88-
FormalParameters = 71,
89-
FormalParameter = 72,
90-
FunctionBody = 73,
91-
ArrowFunctionExpression = 74,
92-
YieldExpression = 75,
93-
Class = 76,
94-
ClassBody = 77,
95-
MethodDefinition = 78,
96-
PropertyDefinition = 79,
97-
PrivateIdentifier = 80,
98-
StaticBlock = 81,
99-
ModuleDeclaration = 82,
100-
AccessorProperty = 83,
101-
ImportExpression = 84,
102-
ImportDeclaration = 85,
103-
ImportSpecifier = 86,
104-
ImportDefaultSpecifier = 87,
105-
ImportNamespaceSpecifier = 88,
106-
WithClause = 89,
107-
ImportAttribute = 90,
108-
ExportNamedDeclaration = 91,
109-
ExportDefaultDeclaration = 92,
110-
ExportAllDeclaration = 93,
111-
ExportSpecifier = 94,
112-
V8IntrinsicExpression = 95,
113-
BooleanLiteral = 96,
114-
NullLiteral = 97,
115-
NumericLiteral = 98,
116-
StringLiteral = 99,
117-
BigIntLiteral = 100,
118-
RegExpLiteral = 101,
119-
JSXElement = 102,
120-
JSXOpeningElement = 103,
121-
JSXClosingElement = 104,
122-
JSXFragment = 105,
123-
JSXOpeningFragment = 106,
124-
JSXClosingFragment = 107,
125-
JSXNamespacedName = 108,
126-
JSXMemberExpression = 109,
127-
JSXExpressionContainer = 110,
128-
JSXEmptyExpression = 111,
129-
JSXAttribute = 112,
130-
JSXSpreadAttribute = 113,
131-
JSXIdentifier = 114,
132-
JSXSpreadChild = 115,
133-
JSXText = 116,
134-
TSThisParameter = 117,
135-
TSEnumDeclaration = 118,
136-
TSEnumBody = 119,
137-
TSEnumMember = 120,
138-
TSTypeAnnotation = 121,
139-
TSLiteralType = 122,
140-
TSConditionalType = 123,
141-
TSUnionType = 124,
142-
TSIntersectionType = 125,
143-
TSParenthesizedType = 126,
144-
TSTypeOperator = 127,
145-
TSArrayType = 128,
146-
TSIndexedAccessType = 129,
147-
TSTupleType = 130,
148-
TSNamedTupleMember = 131,
149-
TSOptionalType = 132,
150-
TSRestType = 133,
151-
TSAnyKeyword = 134,
152-
TSStringKeyword = 135,
153-
TSBooleanKeyword = 136,
154-
TSNumberKeyword = 137,
155-
TSNeverKeyword = 138,
156-
TSIntrinsicKeyword = 139,
157-
TSUnknownKeyword = 140,
158-
TSNullKeyword = 141,
159-
TSUndefinedKeyword = 142,
160-
TSVoidKeyword = 143,
161-
TSSymbolKeyword = 144,
162-
TSThisType = 145,
163-
TSObjectKeyword = 146,
164-
TSBigIntKeyword = 147,
165-
TSTypeReference = 148,
166-
TSTypeName = 149,
167-
TSQualifiedName = 150,
168-
TSTypeParameterInstantiation = 151,
169-
TSTypeParameter = 152,
170-
TSTypeParameterDeclaration = 153,
171-
TSTypeAliasDeclaration = 154,
172-
TSClassImplements = 155,
173-
TSInterfaceDeclaration = 156,
174-
TSInterfaceBody = 157,
175-
TSPropertySignature = 158,
176-
TSIndexSignature = 159,
177-
TSCallSignatureDeclaration = 160,
178-
TSMethodSignature = 161,
179-
TSConstructSignatureDeclaration = 162,
180-
TSIndexSignatureName = 163,
181-
TSInterfaceHeritage = 164,
182-
TSTypePredicate = 165,
183-
TSModuleDeclaration = 166,
184-
TSModuleBlock = 167,
185-
TSTypeLiteral = 168,
186-
TSInferType = 169,
187-
TSTypeQuery = 170,
188-
TSImportType = 171,
189-
TSConstructorType = 172,
190-
TSMappedType = 173,
191-
TSTemplateLiteralType = 174,
192-
TSAsExpression = 175,
193-
TSSatisfiesExpression = 176,
194-
TSTypeAssertion = 177,
195-
TSImportEqualsDeclaration = 178,
196-
TSExternalModuleReference = 179,
197-
TSNonNullExpression = 180,
198-
Decorator = 181,
199-
TSExportAssignment = 182,
200-
TSNamespaceExportDeclaration = 183,
201-
TSInstantiationExpression = 184,
202-
JSDocNullableType = 185,
203-
JSDocNonNullableType = 186,
204-
JSDocUnknownType = 187,
51+
AssignmentTargetRest = 34,
52+
AssignmentTargetWithDefault = 35,
53+
SequenceExpression = 36,
54+
Super = 37,
55+
AwaitExpression = 38,
56+
ChainExpression = 39,
57+
ParenthesizedExpression = 40,
58+
Directive = 41,
59+
Hashbang = 42,
60+
BlockStatement = 43,
61+
VariableDeclaration = 44,
62+
VariableDeclarator = 45,
63+
EmptyStatement = 46,
64+
ExpressionStatement = 47,
65+
IfStatement = 48,
66+
DoWhileStatement = 49,
67+
WhileStatement = 50,
68+
ForStatement = 51,
69+
ForInStatement = 52,
70+
ForOfStatement = 53,
71+
ContinueStatement = 54,
72+
BreakStatement = 55,
73+
ReturnStatement = 56,
74+
WithStatement = 57,
75+
SwitchStatement = 58,
76+
SwitchCase = 59,
77+
LabeledStatement = 60,
78+
ThrowStatement = 61,
79+
TryStatement = 62,
80+
CatchClause = 63,
81+
CatchParameter = 64,
82+
DebuggerStatement = 65,
83+
AssignmentPattern = 66,
84+
ObjectPattern = 67,
85+
BindingProperty = 68,
86+
ArrayPattern = 69,
87+
BindingRestElement = 70,
88+
Function = 71,
89+
FormalParameters = 72,
90+
FormalParameter = 73,
91+
FunctionBody = 74,
92+
ArrowFunctionExpression = 75,
93+
YieldExpression = 76,
94+
Class = 77,
95+
ClassBody = 78,
96+
MethodDefinition = 79,
97+
PropertyDefinition = 80,
98+
PrivateIdentifier = 81,
99+
StaticBlock = 82,
100+
ModuleDeclaration = 83,
101+
AccessorProperty = 84,
102+
ImportExpression = 85,
103+
ImportDeclaration = 86,
104+
ImportSpecifier = 87,
105+
ImportDefaultSpecifier = 88,
106+
ImportNamespaceSpecifier = 89,
107+
WithClause = 90,
108+
ImportAttribute = 91,
109+
ExportNamedDeclaration = 92,
110+
ExportDefaultDeclaration = 93,
111+
ExportAllDeclaration = 94,
112+
ExportSpecifier = 95,
113+
V8IntrinsicExpression = 96,
114+
BooleanLiteral = 97,
115+
NullLiteral = 98,
116+
NumericLiteral = 99,
117+
StringLiteral = 100,
118+
BigIntLiteral = 101,
119+
RegExpLiteral = 102,
120+
JSXElement = 103,
121+
JSXOpeningElement = 104,
122+
JSXClosingElement = 105,
123+
JSXFragment = 106,
124+
JSXOpeningFragment = 107,
125+
JSXClosingFragment = 108,
126+
JSXNamespacedName = 109,
127+
JSXMemberExpression = 110,
128+
JSXExpressionContainer = 111,
129+
JSXEmptyExpression = 112,
130+
JSXAttribute = 113,
131+
JSXSpreadAttribute = 114,
132+
JSXIdentifier = 115,
133+
JSXSpreadChild = 116,
134+
JSXText = 117,
135+
TSThisParameter = 118,
136+
TSEnumDeclaration = 119,
137+
TSEnumBody = 120,
138+
TSEnumMember = 121,
139+
TSTypeAnnotation = 122,
140+
TSLiteralType = 123,
141+
TSConditionalType = 124,
142+
TSUnionType = 125,
143+
TSIntersectionType = 126,
144+
TSParenthesizedType = 127,
145+
TSTypeOperator = 128,
146+
TSArrayType = 129,
147+
TSIndexedAccessType = 130,
148+
TSTupleType = 131,
149+
TSNamedTupleMember = 132,
150+
TSOptionalType = 133,
151+
TSRestType = 134,
152+
TSAnyKeyword = 135,
153+
TSStringKeyword = 136,
154+
TSBooleanKeyword = 137,
155+
TSNumberKeyword = 138,
156+
TSNeverKeyword = 139,
157+
TSIntrinsicKeyword = 140,
158+
TSUnknownKeyword = 141,
159+
TSNullKeyword = 142,
160+
TSUndefinedKeyword = 143,
161+
TSVoidKeyword = 144,
162+
TSSymbolKeyword = 145,
163+
TSThisType = 146,
164+
TSObjectKeyword = 147,
165+
TSBigIntKeyword = 148,
166+
TSTypeReference = 149,
167+
TSTypeName = 150,
168+
TSQualifiedName = 151,
169+
TSTypeParameterInstantiation = 152,
170+
TSTypeParameter = 153,
171+
TSTypeParameterDeclaration = 154,
172+
TSTypeAliasDeclaration = 155,
173+
TSClassImplements = 156,
174+
TSInterfaceDeclaration = 157,
175+
TSInterfaceBody = 158,
176+
TSPropertySignature = 159,
177+
TSIndexSignature = 160,
178+
TSCallSignatureDeclaration = 161,
179+
TSMethodSignature = 162,
180+
TSConstructSignatureDeclaration = 163,
181+
TSIndexSignatureName = 164,
182+
TSInterfaceHeritage = 165,
183+
TSTypePredicate = 166,
184+
TSModuleDeclaration = 167,
185+
TSModuleBlock = 168,
186+
TSTypeLiteral = 169,
187+
TSInferType = 170,
188+
TSTypeQuery = 171,
189+
TSImportType = 172,
190+
TSConstructorType = 173,
191+
TSMappedType = 174,
192+
TSTemplateLiteralType = 175,
193+
TSAsExpression = 176,
194+
TSSatisfiesExpression = 177,
195+
TSTypeAssertion = 178,
196+
TSImportEqualsDeclaration = 179,
197+
TSExternalModuleReference = 180,
198+
TSNonNullExpression = 181,
199+
Decorator = 182,
200+
TSExportAssignment = 183,
201+
TSNamespaceExportDeclaration = 184,
202+
TSInstantiationExpression = 185,
203+
JSDocNullableType = 186,
204+
JSDocNonNullableType = 187,
205+
JSDocUnknownType = 188,
205206
}
206207

207208
/// Untyped AST Node Kind
@@ -245,6 +246,7 @@ pub enum AstKind<'a> {
245246
AstType::AssignmentTargetPattern as u8,
246247
ArrayAssignmentTarget(&'a ArrayAssignmentTarget<'a>) = AstType::ArrayAssignmentTarget as u8,
247248
ObjectAssignmentTarget(&'a ObjectAssignmentTarget<'a>) = AstType::ObjectAssignmentTarget as u8,
249+
AssignmentTargetRest(&'a AssignmentTargetRest<'a>) = AstType::AssignmentTargetRest as u8,
248250
AssignmentTargetWithDefault(&'a AssignmentTargetWithDefault<'a>) =
249251
AstType::AssignmentTargetWithDefault as u8,
250252
SequenceExpression(&'a SequenceExpression<'a>) = AstType::SequenceExpression as u8,
@@ -463,6 +465,7 @@ impl GetSpan for AstKind<'_> {
463465
Self::AssignmentTargetPattern(it) => it.span(),
464466
Self::ArrayAssignmentTarget(it) => it.span(),
465467
Self::ObjectAssignmentTarget(it) => it.span(),
468+
Self::AssignmentTargetRest(it) => it.span(),
466469
Self::AssignmentTargetWithDefault(it) => it.span(),
467470
Self::SequenceExpression(it) => it.span(),
468471
Self::Super(it) => it.span(),
@@ -658,6 +661,7 @@ impl GetAddress for AstKind<'_> {
658661
Self::AssignmentTargetPattern(it) => it.address(),
659662
Self::ArrayAssignmentTarget(it) => Address::from_ptr(it),
660663
Self::ObjectAssignmentTarget(it) => Address::from_ptr(it),
664+
Self::AssignmentTargetRest(it) => Address::from_ptr(it),
661665
Self::AssignmentTargetWithDefault(it) => Address::from_ptr(it),
662666
Self::SequenceExpression(it) => Address::from_ptr(it),
663667
Self::Super(it) => Address::from_ptr(it),
@@ -987,6 +991,11 @@ impl<'a> AstKind<'a> {
987991
if let Self::ObjectAssignmentTarget(v) = self { Some(v) } else { None }
988992
}
989993

994+
#[inline]
995+
pub fn as_assignment_target_rest(self) -> Option<&'a AssignmentTargetRest<'a>> {
996+
if let Self::AssignmentTargetRest(v) = self { Some(v) } else { None }
997+
}
998+
990999
#[inline]
9911000
pub fn as_assignment_target_with_default(self) -> Option<&'a AssignmentTargetWithDefault<'a>> {
9921001
if let Self::AssignmentTargetWithDefault(v) = self { Some(v) } else { None }

crates/oxc_ast_visit/src/generated/visit.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1852,9 +1852,11 @@ pub mod walk {
18521852
visitor: &mut V,
18531853
it: &AssignmentTargetRest<'a>,
18541854
) {
1855-
// No `AstKind` for this type
1855+
let kind = AstKind::AssignmentTargetRest(visitor.alloc(it));
1856+
visitor.enter_node(kind);
18561857
visitor.visit_span(&it.span);
18571858
visitor.visit_assignment_target(&it.target);
1859+
visitor.leave_node(kind);
18581860
}
18591861

18601862
#[inline]

crates/oxc_ast_visit/src/generated/visit_mut.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,9 +1883,11 @@ pub mod walk_mut {
18831883
visitor: &mut V,
18841884
it: &mut AssignmentTargetRest<'a>,
18851885
) {
1886-
// No `AstType` for this type
1886+
let kind = AstType::AssignmentTargetRest;
1887+
visitor.enter_node(kind);
18871888
visitor.visit_span(&mut it.span);
18881889
visitor.visit_assignment_target(&mut it.target);
1890+
visitor.leave_node(kind);
18891891
}
18901892

18911893
#[inline]

0 commit comments

Comments
 (0)