Skip to content

Commit 219adcc

Browse files
authored
refactor(ast): don't generate AstKind for ArrayExpressionElement (#11684)
Part of #11490
1 parent 0b4261b commit 219adcc

File tree

13 files changed

+185
-213
lines changed

13 files changed

+185
-213
lines changed

crates/oxc_ast/src/ast_kind_impl.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ impl AstKind<'_> {
244244
}
245245
Self::PropertyKey(p) => format!("PropertyKey({})", p.name().unwrap_or(COMPUTED)).into(),
246246
Self::Argument(_) => "Argument".into(),
247-
Self::ArrayExpressionElement(_) => "ArrayExpressionElement".into(),
248247
Self::AssignmentTarget(_) => "AssignmentTarget".into(),
249248
Self::SimpleAssignmentTarget(a) => {
250249
format!("SimpleAssignmentTarget({})", a.get_identifier_name().unwrap_or(&UNKNOWN))

crates/oxc_ast/src/generated/ast_kind.rs

Lines changed: 163 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -20,170 +20,169 @@ pub enum AstType {
2020
LabelIdentifier = 4,
2121
ThisExpression = 5,
2222
ArrayExpression = 6,
23-
ArrayExpressionElement = 7,
24-
Elision = 8,
25-
ObjectExpression = 9,
26-
ObjectProperty = 10,
27-
PropertyKey = 11,
28-
TemplateLiteral = 12,
29-
TaggedTemplateExpression = 13,
30-
MemberExpression = 14,
31-
CallExpression = 15,
32-
NewExpression = 16,
33-
MetaProperty = 17,
34-
SpreadElement = 18,
35-
Argument = 19,
36-
UpdateExpression = 20,
37-
UnaryExpression = 21,
38-
BinaryExpression = 22,
39-
PrivateInExpression = 23,
40-
LogicalExpression = 24,
41-
ConditionalExpression = 25,
42-
AssignmentExpression = 26,
43-
AssignmentTarget = 27,
44-
SimpleAssignmentTarget = 28,
45-
AssignmentTargetPattern = 29,
46-
ArrayAssignmentTarget = 30,
47-
ObjectAssignmentTarget = 31,
48-
AssignmentTargetWithDefault = 32,
49-
SequenceExpression = 33,
50-
Super = 34,
51-
AwaitExpression = 35,
52-
ChainExpression = 36,
53-
ParenthesizedExpression = 37,
54-
Directive = 38,
55-
Hashbang = 39,
56-
BlockStatement = 40,
57-
VariableDeclaration = 41,
58-
VariableDeclarator = 42,
59-
EmptyStatement = 43,
60-
ExpressionStatement = 44,
61-
IfStatement = 45,
62-
DoWhileStatement = 46,
63-
WhileStatement = 47,
64-
ForStatement = 48,
65-
ForInStatement = 49,
66-
ForOfStatement = 50,
67-
ContinueStatement = 51,
68-
BreakStatement = 52,
69-
ReturnStatement = 53,
70-
WithStatement = 54,
71-
SwitchStatement = 55,
72-
SwitchCase = 56,
73-
LabeledStatement = 57,
74-
ThrowStatement = 58,
75-
TryStatement = 59,
76-
CatchClause = 60,
77-
CatchParameter = 61,
78-
DebuggerStatement = 62,
79-
AssignmentPattern = 63,
80-
ObjectPattern = 64,
81-
ArrayPattern = 65,
82-
BindingRestElement = 66,
83-
Function = 67,
84-
FormalParameters = 68,
85-
FormalParameter = 69,
86-
FunctionBody = 70,
87-
ArrowFunctionExpression = 71,
88-
YieldExpression = 72,
89-
Class = 73,
90-
ClassBody = 74,
91-
MethodDefinition = 75,
92-
PropertyDefinition = 76,
93-
PrivateIdentifier = 77,
94-
StaticBlock = 78,
95-
ModuleDeclaration = 79,
96-
ImportExpression = 80,
97-
ImportDeclaration = 81,
98-
ImportSpecifier = 82,
99-
ImportDefaultSpecifier = 83,
100-
ImportNamespaceSpecifier = 84,
101-
ExportNamedDeclaration = 85,
102-
ExportDefaultDeclaration = 86,
103-
ExportAllDeclaration = 87,
104-
ExportSpecifier = 88,
105-
V8IntrinsicExpression = 89,
106-
BooleanLiteral = 90,
107-
NullLiteral = 91,
108-
NumericLiteral = 92,
109-
StringLiteral = 93,
110-
BigIntLiteral = 94,
111-
RegExpLiteral = 95,
112-
JSXElement = 96,
113-
JSXOpeningElement = 97,
114-
JSXClosingElement = 98,
115-
JSXFragment = 99,
116-
JSXOpeningFragment = 100,
117-
JSXClosingFragment = 101,
118-
JSXNamespacedName = 102,
119-
JSXMemberExpression = 103,
120-
JSXExpressionContainer = 104,
121-
JSXEmptyExpression = 105,
122-
JSXAttribute = 106,
123-
JSXSpreadAttribute = 107,
124-
JSXIdentifier = 108,
125-
JSXSpreadChild = 109,
126-
JSXText = 110,
127-
TSThisParameter = 111,
128-
TSEnumDeclaration = 112,
129-
TSEnumBody = 113,
130-
TSEnumMember = 114,
131-
TSTypeAnnotation = 115,
132-
TSLiteralType = 116,
133-
TSConditionalType = 117,
134-
TSUnionType = 118,
135-
TSIntersectionType = 119,
136-
TSParenthesizedType = 120,
137-
TSIndexedAccessType = 121,
138-
TSNamedTupleMember = 122,
139-
TSAnyKeyword = 123,
140-
TSStringKeyword = 124,
141-
TSBooleanKeyword = 125,
142-
TSNumberKeyword = 126,
143-
TSNeverKeyword = 127,
144-
TSIntrinsicKeyword = 128,
145-
TSUnknownKeyword = 129,
146-
TSNullKeyword = 130,
147-
TSUndefinedKeyword = 131,
148-
TSVoidKeyword = 132,
149-
TSSymbolKeyword = 133,
150-
TSThisType = 134,
151-
TSObjectKeyword = 135,
152-
TSBigIntKeyword = 136,
153-
TSTypeReference = 137,
154-
TSTypeName = 138,
155-
TSQualifiedName = 139,
156-
TSTypeParameterInstantiation = 140,
157-
TSTypeParameter = 141,
158-
TSTypeParameterDeclaration = 142,
159-
TSTypeAliasDeclaration = 143,
160-
TSClassImplements = 144,
161-
TSInterfaceDeclaration = 145,
162-
TSPropertySignature = 146,
163-
TSMethodSignature = 147,
164-
TSConstructSignatureDeclaration = 148,
165-
TSInterfaceHeritage = 149,
166-
TSModuleDeclaration = 150,
167-
TSModuleBlock = 151,
168-
TSTypeLiteral = 152,
169-
TSInferType = 153,
170-
TSTypeQuery = 154,
171-
TSImportType = 155,
172-
TSMappedType = 156,
173-
TSTemplateLiteralType = 157,
174-
TSAsExpression = 158,
175-
TSSatisfiesExpression = 159,
176-
TSTypeAssertion = 160,
177-
TSImportEqualsDeclaration = 161,
178-
TSModuleReference = 162,
179-
TSExternalModuleReference = 163,
180-
TSNonNullExpression = 164,
181-
Decorator = 165,
182-
TSExportAssignment = 166,
183-
TSInstantiationExpression = 167,
184-
JSDocNullableType = 168,
185-
JSDocNonNullableType = 169,
186-
JSDocUnknownType = 170,
23+
Elision = 7,
24+
ObjectExpression = 8,
25+
ObjectProperty = 9,
26+
PropertyKey = 10,
27+
TemplateLiteral = 11,
28+
TaggedTemplateExpression = 12,
29+
MemberExpression = 13,
30+
CallExpression = 14,
31+
NewExpression = 15,
32+
MetaProperty = 16,
33+
SpreadElement = 17,
34+
Argument = 18,
35+
UpdateExpression = 19,
36+
UnaryExpression = 20,
37+
BinaryExpression = 21,
38+
PrivateInExpression = 22,
39+
LogicalExpression = 23,
40+
ConditionalExpression = 24,
41+
AssignmentExpression = 25,
42+
AssignmentTarget = 26,
43+
SimpleAssignmentTarget = 27,
44+
AssignmentTargetPattern = 28,
45+
ArrayAssignmentTarget = 29,
46+
ObjectAssignmentTarget = 30,
47+
AssignmentTargetWithDefault = 31,
48+
SequenceExpression = 32,
49+
Super = 33,
50+
AwaitExpression = 34,
51+
ChainExpression = 35,
52+
ParenthesizedExpression = 36,
53+
Directive = 37,
54+
Hashbang = 38,
55+
BlockStatement = 39,
56+
VariableDeclaration = 40,
57+
VariableDeclarator = 41,
58+
EmptyStatement = 42,
59+
ExpressionStatement = 43,
60+
IfStatement = 44,
61+
DoWhileStatement = 45,
62+
WhileStatement = 46,
63+
ForStatement = 47,
64+
ForInStatement = 48,
65+
ForOfStatement = 49,
66+
ContinueStatement = 50,
67+
BreakStatement = 51,
68+
ReturnStatement = 52,
69+
WithStatement = 53,
70+
SwitchStatement = 54,
71+
SwitchCase = 55,
72+
LabeledStatement = 56,
73+
ThrowStatement = 57,
74+
TryStatement = 58,
75+
CatchClause = 59,
76+
CatchParameter = 60,
77+
DebuggerStatement = 61,
78+
AssignmentPattern = 62,
79+
ObjectPattern = 63,
80+
ArrayPattern = 64,
81+
BindingRestElement = 65,
82+
Function = 66,
83+
FormalParameters = 67,
84+
FormalParameter = 68,
85+
FunctionBody = 69,
86+
ArrowFunctionExpression = 70,
87+
YieldExpression = 71,
88+
Class = 72,
89+
ClassBody = 73,
90+
MethodDefinition = 74,
91+
PropertyDefinition = 75,
92+
PrivateIdentifier = 76,
93+
StaticBlock = 77,
94+
ModuleDeclaration = 78,
95+
ImportExpression = 79,
96+
ImportDeclaration = 80,
97+
ImportSpecifier = 81,
98+
ImportDefaultSpecifier = 82,
99+
ImportNamespaceSpecifier = 83,
100+
ExportNamedDeclaration = 84,
101+
ExportDefaultDeclaration = 85,
102+
ExportAllDeclaration = 86,
103+
ExportSpecifier = 87,
104+
V8IntrinsicExpression = 88,
105+
BooleanLiteral = 89,
106+
NullLiteral = 90,
107+
NumericLiteral = 91,
108+
StringLiteral = 92,
109+
BigIntLiteral = 93,
110+
RegExpLiteral = 94,
111+
JSXElement = 95,
112+
JSXOpeningElement = 96,
113+
JSXClosingElement = 97,
114+
JSXFragment = 98,
115+
JSXOpeningFragment = 99,
116+
JSXClosingFragment = 100,
117+
JSXNamespacedName = 101,
118+
JSXMemberExpression = 102,
119+
JSXExpressionContainer = 103,
120+
JSXEmptyExpression = 104,
121+
JSXAttribute = 105,
122+
JSXSpreadAttribute = 106,
123+
JSXIdentifier = 107,
124+
JSXSpreadChild = 108,
125+
JSXText = 109,
126+
TSThisParameter = 110,
127+
TSEnumDeclaration = 111,
128+
TSEnumBody = 112,
129+
TSEnumMember = 113,
130+
TSTypeAnnotation = 114,
131+
TSLiteralType = 115,
132+
TSConditionalType = 116,
133+
TSUnionType = 117,
134+
TSIntersectionType = 118,
135+
TSParenthesizedType = 119,
136+
TSIndexedAccessType = 120,
137+
TSNamedTupleMember = 121,
138+
TSAnyKeyword = 122,
139+
TSStringKeyword = 123,
140+
TSBooleanKeyword = 124,
141+
TSNumberKeyword = 125,
142+
TSNeverKeyword = 126,
143+
TSIntrinsicKeyword = 127,
144+
TSUnknownKeyword = 128,
145+
TSNullKeyword = 129,
146+
TSUndefinedKeyword = 130,
147+
TSVoidKeyword = 131,
148+
TSSymbolKeyword = 132,
149+
TSThisType = 133,
150+
TSObjectKeyword = 134,
151+
TSBigIntKeyword = 135,
152+
TSTypeReference = 136,
153+
TSTypeName = 137,
154+
TSQualifiedName = 138,
155+
TSTypeParameterInstantiation = 139,
156+
TSTypeParameter = 140,
157+
TSTypeParameterDeclaration = 141,
158+
TSTypeAliasDeclaration = 142,
159+
TSClassImplements = 143,
160+
TSInterfaceDeclaration = 144,
161+
TSPropertySignature = 145,
162+
TSMethodSignature = 146,
163+
TSConstructSignatureDeclaration = 147,
164+
TSInterfaceHeritage = 148,
165+
TSModuleDeclaration = 149,
166+
TSModuleBlock = 150,
167+
TSTypeLiteral = 151,
168+
TSInferType = 152,
169+
TSTypeQuery = 153,
170+
TSImportType = 154,
171+
TSMappedType = 155,
172+
TSTemplateLiteralType = 156,
173+
TSAsExpression = 157,
174+
TSSatisfiesExpression = 158,
175+
TSTypeAssertion = 159,
176+
TSImportEqualsDeclaration = 160,
177+
TSModuleReference = 161,
178+
TSExternalModuleReference = 162,
179+
TSNonNullExpression = 163,
180+
Decorator = 164,
181+
TSExportAssignment = 165,
182+
TSInstantiationExpression = 166,
183+
JSDocNullableType = 167,
184+
JSDocNonNullableType = 168,
185+
JSDocUnknownType = 169,
187186
}
188187

189188
/// Untyped AST Node Kind
@@ -197,7 +196,6 @@ pub enum AstKind<'a> {
197196
LabelIdentifier(&'a LabelIdentifier<'a>) = AstType::LabelIdentifier as u8,
198197
ThisExpression(&'a ThisExpression) = AstType::ThisExpression as u8,
199198
ArrayExpression(&'a ArrayExpression<'a>) = AstType::ArrayExpression as u8,
200-
ArrayExpressionElement(&'a ArrayExpressionElement<'a>) = AstType::ArrayExpressionElement as u8,
201199
Elision(&'a Elision) = AstType::Elision as u8,
202200
ObjectExpression(&'a ObjectExpression<'a>) = AstType::ObjectExpression as u8,
203201
ObjectProperty(&'a ObjectProperty<'a>) = AstType::ObjectProperty as u8,
@@ -398,7 +396,6 @@ impl GetSpan for AstKind<'_> {
398396
Self::LabelIdentifier(it) => it.span(),
399397
Self::ThisExpression(it) => it.span(),
400398
Self::ArrayExpression(it) => it.span(),
401-
Self::ArrayExpressionElement(it) => it.span(),
402399
Self::Elision(it) => it.span(),
403400
Self::ObjectExpression(it) => it.span(),
404401
Self::ObjectProperty(it) => it.span(),
@@ -602,11 +599,6 @@ impl<'a> AstKind<'a> {
602599
if let Self::ArrayExpression(v) = self { Some(v) } else { None }
603600
}
604601

605-
#[inline]
606-
pub fn as_array_expression_element(self) -> Option<&'a ArrayExpressionElement<'a>> {
607-
if let Self::ArrayExpressionElement(v) = self { Some(v) } else { None }
608-
}
609-
610602
#[inline]
611603
pub fn as_elision(self) -> Option<&'a Elision> {
612604
if let Self::Elision(v) = self { Some(v) } else { None }

crates/oxc_ast_visit/src/generated/visit.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,16 +1473,14 @@ pub mod walk {
14731473
visitor: &mut V,
14741474
it: &ArrayExpressionElement<'a>,
14751475
) {
1476-
let kind = AstKind::ArrayExpressionElement(visitor.alloc(it));
1477-
visitor.enter_node(kind);
1476+
// No `AstKind` for this type
14781477
match it {
14791478
ArrayExpressionElement::SpreadElement(it) => visitor.visit_spread_element(it),
14801479
ArrayExpressionElement::Elision(it) => visitor.visit_elision(it),
14811480
match_expression!(ArrayExpressionElement) => {
14821481
visitor.visit_expression(it.to_expression())
14831482
}
14841483
}
1485-
visitor.leave_node(kind);
14861484
}
14871485

14881486
#[inline]

0 commit comments

Comments
 (0)