Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/oxc_ast/src/ast_kind_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ impl AstKind<'_> {

Self::AccessorProperty(_) => "AccessorProperty".into(),

Self::BindingProperty(_) => "BindingProperty".into(),

Self::ArrayExpression(_) => "ArrayExpression".into(),
Self::ArrowFunctionExpression(_) => "ArrowFunctionExpression".into(),
Self::AssignmentExpression(_) => "AssignmentExpression".into(),
Expand Down
249 changes: 129 additions & 120 deletions crates/oxc_ast/src/generated/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,126 +81,127 @@ pub enum AstType {
DebuggerStatement = 64,
AssignmentPattern = 65,
ObjectPattern = 66,
ArrayPattern = 67,
BindingRestElement = 68,
Function = 69,
FormalParameters = 70,
FormalParameter = 71,
FunctionBody = 72,
ArrowFunctionExpression = 73,
YieldExpression = 74,
Class = 75,
ClassBody = 76,
MethodDefinition = 77,
PropertyDefinition = 78,
PrivateIdentifier = 79,
StaticBlock = 80,
ModuleDeclaration = 81,
AccessorProperty = 82,
ImportExpression = 83,
ImportDeclaration = 84,
ImportSpecifier = 85,
ImportDefaultSpecifier = 86,
ImportNamespaceSpecifier = 87,
WithClause = 88,
ImportAttribute = 89,
ExportNamedDeclaration = 90,
ExportDefaultDeclaration = 91,
ExportAllDeclaration = 92,
ExportSpecifier = 93,
V8IntrinsicExpression = 94,
BooleanLiteral = 95,
NullLiteral = 96,
NumericLiteral = 97,
StringLiteral = 98,
BigIntLiteral = 99,
RegExpLiteral = 100,
JSXElement = 101,
JSXOpeningElement = 102,
JSXClosingElement = 103,
JSXFragment = 104,
JSXOpeningFragment = 105,
JSXClosingFragment = 106,
JSXNamespacedName = 107,
JSXMemberExpression = 108,
JSXExpressionContainer = 109,
JSXEmptyExpression = 110,
JSXAttribute = 111,
JSXSpreadAttribute = 112,
JSXIdentifier = 113,
JSXSpreadChild = 114,
JSXText = 115,
TSThisParameter = 116,
TSEnumDeclaration = 117,
TSEnumBody = 118,
TSEnumMember = 119,
TSTypeAnnotation = 120,
TSLiteralType = 121,
TSConditionalType = 122,
TSUnionType = 123,
TSIntersectionType = 124,
TSParenthesizedType = 125,
TSTypeOperator = 126,
TSArrayType = 127,
TSIndexedAccessType = 128,
TSTupleType = 129,
TSNamedTupleMember = 130,
TSOptionalType = 131,
TSRestType = 132,
TSAnyKeyword = 133,
TSStringKeyword = 134,
TSBooleanKeyword = 135,
TSNumberKeyword = 136,
TSNeverKeyword = 137,
TSIntrinsicKeyword = 138,
TSUnknownKeyword = 139,
TSNullKeyword = 140,
TSUndefinedKeyword = 141,
TSVoidKeyword = 142,
TSSymbolKeyword = 143,
TSThisType = 144,
TSObjectKeyword = 145,
TSBigIntKeyword = 146,
TSTypeReference = 147,
TSTypeName = 148,
TSQualifiedName = 149,
TSTypeParameterInstantiation = 150,
TSTypeParameter = 151,
TSTypeParameterDeclaration = 152,
TSTypeAliasDeclaration = 153,
TSClassImplements = 154,
TSInterfaceDeclaration = 155,
TSInterfaceBody = 156,
TSPropertySignature = 157,
TSIndexSignature = 158,
TSCallSignatureDeclaration = 159,
TSMethodSignature = 160,
TSConstructSignatureDeclaration = 161,
TSIndexSignatureName = 162,
TSInterfaceHeritage = 163,
TSTypePredicate = 164,
TSModuleDeclaration = 165,
TSModuleBlock = 166,
TSTypeLiteral = 167,
TSInferType = 168,
TSTypeQuery = 169,
TSImportType = 170,
TSConstructorType = 171,
TSMappedType = 172,
TSTemplateLiteralType = 173,
TSAsExpression = 174,
TSSatisfiesExpression = 175,
TSTypeAssertion = 176,
TSImportEqualsDeclaration = 177,
TSExternalModuleReference = 178,
TSNonNullExpression = 179,
Decorator = 180,
TSExportAssignment = 181,
TSNamespaceExportDeclaration = 182,
TSInstantiationExpression = 183,
JSDocNullableType = 184,
JSDocNonNullableType = 185,
JSDocUnknownType = 186,
BindingProperty = 67,
ArrayPattern = 68,
BindingRestElement = 69,
Function = 70,
FormalParameters = 71,
FormalParameter = 72,
FunctionBody = 73,
ArrowFunctionExpression = 74,
YieldExpression = 75,
Class = 76,
ClassBody = 77,
MethodDefinition = 78,
PropertyDefinition = 79,
PrivateIdentifier = 80,
StaticBlock = 81,
ModuleDeclaration = 82,
AccessorProperty = 83,
ImportExpression = 84,
ImportDeclaration = 85,
ImportSpecifier = 86,
ImportDefaultSpecifier = 87,
ImportNamespaceSpecifier = 88,
WithClause = 89,
ImportAttribute = 90,
ExportNamedDeclaration = 91,
ExportDefaultDeclaration = 92,
ExportAllDeclaration = 93,
ExportSpecifier = 94,
V8IntrinsicExpression = 95,
BooleanLiteral = 96,
NullLiteral = 97,
NumericLiteral = 98,
StringLiteral = 99,
BigIntLiteral = 100,
RegExpLiteral = 101,
JSXElement = 102,
JSXOpeningElement = 103,
JSXClosingElement = 104,
JSXFragment = 105,
JSXOpeningFragment = 106,
JSXClosingFragment = 107,
JSXNamespacedName = 108,
JSXMemberExpression = 109,
JSXExpressionContainer = 110,
JSXEmptyExpression = 111,
JSXAttribute = 112,
JSXSpreadAttribute = 113,
JSXIdentifier = 114,
JSXSpreadChild = 115,
JSXText = 116,
TSThisParameter = 117,
TSEnumDeclaration = 118,
TSEnumBody = 119,
TSEnumMember = 120,
TSTypeAnnotation = 121,
TSLiteralType = 122,
TSConditionalType = 123,
TSUnionType = 124,
TSIntersectionType = 125,
TSParenthesizedType = 126,
TSTypeOperator = 127,
TSArrayType = 128,
TSIndexedAccessType = 129,
TSTupleType = 130,
TSNamedTupleMember = 131,
TSOptionalType = 132,
TSRestType = 133,
TSAnyKeyword = 134,
TSStringKeyword = 135,
TSBooleanKeyword = 136,
TSNumberKeyword = 137,
TSNeverKeyword = 138,
TSIntrinsicKeyword = 139,
TSUnknownKeyword = 140,
TSNullKeyword = 141,
TSUndefinedKeyword = 142,
TSVoidKeyword = 143,
TSSymbolKeyword = 144,
TSThisType = 145,
TSObjectKeyword = 146,
TSBigIntKeyword = 147,
TSTypeReference = 148,
TSTypeName = 149,
TSQualifiedName = 150,
TSTypeParameterInstantiation = 151,
TSTypeParameter = 152,
TSTypeParameterDeclaration = 153,
TSTypeAliasDeclaration = 154,
TSClassImplements = 155,
TSInterfaceDeclaration = 156,
TSInterfaceBody = 157,
TSPropertySignature = 158,
TSIndexSignature = 159,
TSCallSignatureDeclaration = 160,
TSMethodSignature = 161,
TSConstructSignatureDeclaration = 162,
TSIndexSignatureName = 163,
TSInterfaceHeritage = 164,
TSTypePredicate = 165,
TSModuleDeclaration = 166,
TSModuleBlock = 167,
TSTypeLiteral = 168,
TSInferType = 169,
TSTypeQuery = 170,
TSImportType = 171,
TSConstructorType = 172,
TSMappedType = 173,
TSTemplateLiteralType = 174,
TSAsExpression = 175,
TSSatisfiesExpression = 176,
TSTypeAssertion = 177,
TSImportEqualsDeclaration = 178,
TSExternalModuleReference = 179,
TSNonNullExpression = 180,
Decorator = 181,
TSExportAssignment = 182,
TSNamespaceExportDeclaration = 183,
TSInstantiationExpression = 184,
JSDocNullableType = 185,
JSDocNonNullableType = 186,
JSDocUnknownType = 187,
}

/// Untyped AST Node Kind
Expand Down Expand Up @@ -279,6 +280,7 @@ pub enum AstKind<'a> {
DebuggerStatement(&'a DebuggerStatement) = AstType::DebuggerStatement as u8,
AssignmentPattern(&'a AssignmentPattern<'a>) = AstType::AssignmentPattern as u8,
ObjectPattern(&'a ObjectPattern<'a>) = AstType::ObjectPattern as u8,
BindingProperty(&'a BindingProperty<'a>) = AstType::BindingProperty as u8,
ArrayPattern(&'a ArrayPattern<'a>) = AstType::ArrayPattern as u8,
BindingRestElement(&'a BindingRestElement<'a>) = AstType::BindingRestElement as u8,
Function(&'a Function<'a>) = AstType::Function as u8,
Expand Down Expand Up @@ -494,6 +496,7 @@ impl GetSpan for AstKind<'_> {
Self::DebuggerStatement(it) => it.span(),
Self::AssignmentPattern(it) => it.span(),
Self::ObjectPattern(it) => it.span(),
Self::BindingProperty(it) => it.span(),
Self::ArrayPattern(it) => it.span(),
Self::BindingRestElement(it) => it.span(),
Self::Function(it) => it.span(),
Expand Down Expand Up @@ -688,6 +691,7 @@ impl GetAddress for AstKind<'_> {
Self::DebuggerStatement(it) => Address::from_ptr(it),
Self::AssignmentPattern(it) => Address::from_ptr(it),
Self::ObjectPattern(it) => Address::from_ptr(it),
Self::BindingProperty(it) => Address::from_ptr(it),
Self::ArrayPattern(it) => Address::from_ptr(it),
Self::BindingRestElement(it) => Address::from_ptr(it),
Self::Function(it) => Address::from_ptr(it),
Expand Down Expand Up @@ -1148,6 +1152,11 @@ impl<'a> AstKind<'a> {
if let Self::ObjectPattern(v) = self { Some(v) } else { None }
}

#[inline]
pub fn as_binding_property(self) -> Option<&'a BindingProperty<'a>> {
if let Self::BindingProperty(v) = self { Some(v) } else { None }
}

#[inline]
pub fn as_array_pattern(self) -> Option<&'a ArrayPattern<'a>> {
if let Self::ArrayPattern(v) = self { Some(v) } else { None }
Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_ast_visit/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2388,10 +2388,12 @@ pub mod walk {

#[inline]
pub fn walk_binding_property<'a, V: Visit<'a>>(visitor: &mut V, it: &BindingProperty<'a>) {
// No `AstKind` for this type
let kind = AstKind::BindingProperty(visitor.alloc(it));
visitor.enter_node(kind);
visitor.visit_span(&it.span);
visitor.visit_property_key(&it.key);
visitor.visit_binding_pattern(&it.value);
visitor.leave_node(kind);
}

#[inline]
Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_ast_visit/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2461,10 +2461,12 @@ pub mod walk_mut {
visitor: &mut V,
it: &mut BindingProperty<'a>,
) {
// No `AstType` for this type
let kind = AstType::BindingProperty;
visitor.enter_node(kind);
visitor.visit_span(&mut it.span);
visitor.visit_property_key(&mut it.key);
visitor.visit_binding_pattern(&mut it.value);
visitor.leave_node(kind);
}

#[inline]
Expand Down
9 changes: 7 additions & 2 deletions crates/oxc_formatter/src/generated/ast_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub enum AstNodes<'a> {
DebuggerStatement(&'a AstNode<'a, DebuggerStatement>),
AssignmentPattern(&'a AstNode<'a, AssignmentPattern<'a>>),
ObjectPattern(&'a AstNode<'a, ObjectPattern<'a>>),
BindingProperty(&'a AstNode<'a, BindingProperty<'a>>),
ArrayPattern(&'a AstNode<'a, ArrayPattern<'a>>),
BindingRestElement(&'a AstNode<'a, BindingRestElement<'a>>),
Function(&'a AstNode<'a, Function<'a>>),
Expand Down Expand Up @@ -2381,6 +2382,7 @@ impl<'a> AstNodes<'a> {
Self::DebuggerStatement(n) => n.span(),
Self::AssignmentPattern(n) => n.span(),
Self::ObjectPattern(n) => n.span(),
Self::BindingProperty(n) => n.span(),
Self::ArrayPattern(n) => n.span(),
Self::BindingRestElement(n) => n.span(),
Self::Function(n) => n.span(),
Expand Down Expand Up @@ -2574,6 +2576,7 @@ impl<'a> AstNodes<'a> {
Self::DebuggerStatement(n) => n.parent,
Self::AssignmentPattern(n) => n.parent,
Self::ObjectPattern(n) => n.parent,
Self::BindingProperty(n) => n.parent,
Self::ArrayPattern(n) => n.parent,
Self::BindingRestElement(n) => n.parent,
Self::Function(n) => n.parent,
Expand Down Expand Up @@ -2767,6 +2770,7 @@ impl<'a> AstNodes<'a> {
Self::DebuggerStatement(n) => SiblingNode::from(n.inner),
Self::AssignmentPattern(n) => SiblingNode::from(n.inner),
Self::ObjectPattern(n) => SiblingNode::from(n.inner),
Self::BindingProperty(n) => SiblingNode::from(n.inner),
Self::ArrayPattern(n) => SiblingNode::from(n.inner),
Self::BindingRestElement(n) => SiblingNode::from(n.inner),
Self::Function(n) => SiblingNode::from(n.inner),
Expand Down Expand Up @@ -2960,6 +2964,7 @@ impl<'a> AstNodes<'a> {
Self::DebuggerStatement(_) => "DebuggerStatement",
Self::AssignmentPattern(_) => "AssignmentPattern",
Self::ObjectPattern(_) => "ObjectPattern",
Self::BindingProperty(_) => "BindingProperty",
Self::ArrayPattern(_) => "ArrayPattern",
Self::BindingRestElement(_) => "BindingRestElement",
Self::Function(_) => "Function",
Expand Down Expand Up @@ -6177,7 +6182,7 @@ impl<'a> AstNode<'a, BindingProperty<'a>> {
self.allocator.alloc(AstNode {
inner: &self.inner.key,
allocator: self.allocator,
parent: self.parent,
parent: self.allocator.alloc(AstNodes::BindingProperty(transmute_self(self))),
following_node,
})
}
Expand All @@ -6188,7 +6193,7 @@ impl<'a> AstNode<'a, BindingProperty<'a>> {
self.allocator.alloc(AstNode {
inner: &self.inner.value,
allocator: self.allocator,
parent: self.parent,
parent: self.allocator.alloc(AstNodes::BindingProperty(transmute_self(self))),
following_node,
})
}
Expand Down
10 changes: 9 additions & 1 deletion crates/oxc_formatter/src/generated/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,15 @@ impl<'a> Format<'a> for AstNode<'a, ObjectPattern<'a>> {

impl<'a> Format<'a> for AstNode<'a, BindingProperty<'a>> {
fn fmt(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> {
self.write(f)
format_leading_comments(self.span).fmt(f)?;
let result = self.write(f);
format_trailing_comments(
&self.parent.as_sibling_node(),
&SiblingNode::from(self.inner),
self.following_node.as_ref(),
)
.fmt(f)?;
result
}
}

Expand Down
Loading
Loading