mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(ast): reorder fields to reflect their visit order. (#3994)
This commit is contained in:
parent
bdee156c5d
commit
0fe22a8225
5 changed files with 453 additions and 449 deletions
|
|
@ -453,10 +453,10 @@ pub struct PrivateFieldExpression<'a> {
|
|||
pub struct CallExpression<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
pub span: Span,
|
||||
pub callee: Expression<'a>,
|
||||
pub arguments: Vec<'a, Argument<'a>>,
|
||||
pub optional: bool, // for optional chaining
|
||||
pub callee: Expression<'a>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
|
||||
pub optional: bool, // for optional chaining
|
||||
}
|
||||
|
||||
/// New Expression
|
||||
|
|
@ -1659,6 +1659,7 @@ pub struct PropertyDefinition<'a> {
|
|||
pub r#type: PropertyDefinitionType,
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
pub span: Span,
|
||||
pub decorators: Vec<'a, Decorator<'a>>,
|
||||
pub key: PropertyKey<'a>,
|
||||
pub value: Option<Expression<'a>>,
|
||||
pub computed: bool,
|
||||
|
|
@ -1670,7 +1671,6 @@ pub struct PropertyDefinition<'a> {
|
|||
pub readonly: bool,
|
||||
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
||||
pub accessibility: Option<TSAccessibility>,
|
||||
pub decorators: Vec<'a, Decorator<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
|
|||
|
|
@ -612,8 +612,8 @@ pub struct TSTypeAliasDeclaration<'a> {
|
|||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
pub span: Span,
|
||||
pub id: BindingIdentifier<'a>,
|
||||
pub type_annotation: TSType<'a>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
|
||||
pub type_annotation: TSType<'a>,
|
||||
pub declare: bool,
|
||||
}
|
||||
|
||||
|
|
@ -648,9 +648,9 @@ pub struct TSInterfaceDeclaration<'a> {
|
|||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
pub span: Span,
|
||||
pub id: BindingIdentifier<'a>,
|
||||
pub body: Box<'a, TSInterfaceBody<'a>>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
|
||||
pub extends: Option<Vec<'a, TSInterfaceHeritage<'a>>>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
|
||||
pub body: Box<'a, TSInterfaceBody<'a>>,
|
||||
pub declare: bool,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -608,10 +608,10 @@ impl<'a> AstBuilder<'a> {
|
|||
) -> Expression<'a> {
|
||||
Expression::CallExpression(self.alloc(CallExpression {
|
||||
span,
|
||||
callee,
|
||||
arguments,
|
||||
optional,
|
||||
callee,
|
||||
type_parameters,
|
||||
optional,
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
@ -1067,6 +1067,7 @@ impl<'a> AstBuilder<'a> {
|
|||
ClassElement::PropertyDefinition(self.alloc(PropertyDefinition {
|
||||
r#type,
|
||||
span,
|
||||
decorators,
|
||||
key,
|
||||
value,
|
||||
computed,
|
||||
|
|
@ -1078,7 +1079,6 @@ impl<'a> AstBuilder<'a> {
|
|||
readonly,
|
||||
type_annotation,
|
||||
accessibility,
|
||||
decorators,
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
@ -1860,9 +1860,9 @@ impl<'a> AstBuilder<'a> {
|
|||
Declaration::TSInterfaceDeclaration(self.alloc(TSInterfaceDeclaration {
|
||||
span,
|
||||
id,
|
||||
body,
|
||||
type_parameters,
|
||||
extends,
|
||||
type_parameters,
|
||||
body,
|
||||
declare,
|
||||
}))
|
||||
}
|
||||
|
|
@ -1879,8 +1879,8 @@ impl<'a> AstBuilder<'a> {
|
|||
Declaration::TSTypeAliasDeclaration(self.alloc(TSTypeAliasDeclaration {
|
||||
span,
|
||||
id,
|
||||
type_annotation,
|
||||
type_parameters,
|
||||
type_annotation,
|
||||
declare,
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -608,19 +608,21 @@ pub(crate) unsafe fn walk_call_expression<'a, Tr: Traverse<'a>>(
|
|||
ctx: &mut TraverseCtx<'a>,
|
||||
) {
|
||||
traverser.enter_call_expression(&mut *node, ctx);
|
||||
ctx.push_stack(Ancestor::CallExpressionCallee(ancestor::CallExpressionWithoutCallee(node)));
|
||||
walk_expression(
|
||||
traverser,
|
||||
(node as *mut u8).add(ancestor::OFFSET_CALL_EXPRESSION_CALLEE) as *mut Expression,
|
||||
ctx,
|
||||
);
|
||||
ctx.retag_stack(AncestorType::CallExpressionArguments);
|
||||
ctx.push_stack(Ancestor::CallExpressionArguments(ancestor::CallExpressionWithoutArguments(
|
||||
node,
|
||||
)));
|
||||
for item in (*((node as *mut u8).add(ancestor::OFFSET_CALL_EXPRESSION_ARGUMENTS)
|
||||
as *mut Vec<Argument>))
|
||||
.iter_mut()
|
||||
{
|
||||
walk_argument(traverser, item as *mut _, ctx);
|
||||
}
|
||||
ctx.retag_stack(AncestorType::CallExpressionCallee);
|
||||
walk_expression(
|
||||
traverser,
|
||||
(node as *mut u8).add(ancestor::OFFSET_CALL_EXPRESSION_CALLEE) as *mut Expression,
|
||||
ctx,
|
||||
);
|
||||
if let Some(field) = &mut *((node as *mut u8)
|
||||
.add(ancestor::OFFSET_CALL_EXPRESSION_TYPE_PARAMETERS)
|
||||
as *mut Option<Box<TSTypeParameterInstantiation>>)
|
||||
|
|
@ -2590,7 +2592,16 @@ pub(crate) unsafe fn walk_property_definition<'a, Tr: Traverse<'a>>(
|
|||
ctx: &mut TraverseCtx<'a>,
|
||||
) {
|
||||
traverser.enter_property_definition(&mut *node, ctx);
|
||||
ctx.push_stack(Ancestor::PropertyDefinitionKey(ancestor::PropertyDefinitionWithoutKey(node)));
|
||||
ctx.push_stack(Ancestor::PropertyDefinitionDecorators(
|
||||
ancestor::PropertyDefinitionWithoutDecorators(node),
|
||||
));
|
||||
for item in (*((node as *mut u8).add(ancestor::OFFSET_PROPERTY_DEFINITION_DECORATORS)
|
||||
as *mut Vec<Decorator>))
|
||||
.iter_mut()
|
||||
{
|
||||
walk_decorator(traverser, item as *mut _, ctx);
|
||||
}
|
||||
ctx.retag_stack(AncestorType::PropertyDefinitionKey);
|
||||
walk_property_key(
|
||||
traverser,
|
||||
(node as *mut u8).add(ancestor::OFFSET_PROPERTY_DEFINITION_KEY) as *mut PropertyKey,
|
||||
|
|
@ -2609,13 +2620,6 @@ pub(crate) unsafe fn walk_property_definition<'a, Tr: Traverse<'a>>(
|
|||
ctx.retag_stack(AncestorType::PropertyDefinitionTypeAnnotation);
|
||||
walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx);
|
||||
}
|
||||
ctx.retag_stack(AncestorType::PropertyDefinitionDecorators);
|
||||
for item in (*((node as *mut u8).add(ancestor::OFFSET_PROPERTY_DEFINITION_DECORATORS)
|
||||
as *mut Vec<Decorator>))
|
||||
.iter_mut()
|
||||
{
|
||||
walk_decorator(traverser, item as *mut _, ctx);
|
||||
}
|
||||
ctx.pop_stack();
|
||||
traverser.exit_property_definition(&mut *node, ctx);
|
||||
}
|
||||
|
|
@ -4477,13 +4481,6 @@ pub(crate) unsafe fn walk_ts_type_alias_declaration<'a, Tr: Traverse<'a>>(
|
|||
as *mut BindingIdentifier,
|
||||
ctx,
|
||||
);
|
||||
ctx.retag_stack(AncestorType::TSTypeAliasDeclarationTypeAnnotation);
|
||||
walk_ts_type(
|
||||
traverser,
|
||||
(node as *mut u8).add(ancestor::OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_ANNOTATION)
|
||||
as *mut TSType,
|
||||
ctx,
|
||||
);
|
||||
if let Some(field) = &mut *((node as *mut u8)
|
||||
.add(ancestor::OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_PARAMETERS)
|
||||
as *mut Option<Box<TSTypeParameterDeclaration>>)
|
||||
|
|
@ -4491,6 +4488,13 @@ pub(crate) unsafe fn walk_ts_type_alias_declaration<'a, Tr: Traverse<'a>>(
|
|||
ctx.retag_stack(AncestorType::TSTypeAliasDeclarationTypeParameters);
|
||||
walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx);
|
||||
}
|
||||
ctx.retag_stack(AncestorType::TSTypeAliasDeclarationTypeAnnotation);
|
||||
walk_ts_type(
|
||||
traverser,
|
||||
(node as *mut u8).add(ancestor::OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_ANNOTATION)
|
||||
as *mut TSType,
|
||||
ctx,
|
||||
);
|
||||
ctx.pop_stack();
|
||||
traverser.exit_ts_type_alias_declaration(&mut *node, ctx);
|
||||
}
|
||||
|
|
@ -4535,20 +4539,6 @@ pub(crate) unsafe fn walk_ts_interface_declaration<'a, Tr: Traverse<'a>>(
|
|||
as *mut BindingIdentifier,
|
||||
ctx,
|
||||
);
|
||||
ctx.retag_stack(AncestorType::TSInterfaceDeclarationBody);
|
||||
walk_ts_interface_body(
|
||||
traverser,
|
||||
(&mut **((node as *mut u8).add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_BODY)
|
||||
as *mut Box<TSInterfaceBody>)) as *mut _,
|
||||
ctx,
|
||||
);
|
||||
if let Some(field) = &mut *((node as *mut u8)
|
||||
.add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_TYPE_PARAMETERS)
|
||||
as *mut Option<Box<TSTypeParameterDeclaration>>)
|
||||
{
|
||||
ctx.retag_stack(AncestorType::TSInterfaceDeclarationTypeParameters);
|
||||
walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx);
|
||||
}
|
||||
if let Some(field) = &mut *((node as *mut u8)
|
||||
.add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_EXTENDS)
|
||||
as *mut Option<Vec<TSInterfaceHeritage>>)
|
||||
|
|
@ -4558,6 +4548,20 @@ pub(crate) unsafe fn walk_ts_interface_declaration<'a, Tr: Traverse<'a>>(
|
|||
walk_ts_interface_heritage(traverser, item as *mut _, ctx);
|
||||
}
|
||||
}
|
||||
if let Some(field) = &mut *((node as *mut u8)
|
||||
.add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_TYPE_PARAMETERS)
|
||||
as *mut Option<Box<TSTypeParameterDeclaration>>)
|
||||
{
|
||||
ctx.retag_stack(AncestorType::TSInterfaceDeclarationTypeParameters);
|
||||
walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx);
|
||||
}
|
||||
ctx.retag_stack(AncestorType::TSInterfaceDeclarationBody);
|
||||
walk_ts_interface_body(
|
||||
traverser,
|
||||
(&mut **((node as *mut u8).add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_BODY)
|
||||
as *mut Box<TSInterfaceBody>)) as *mut _,
|
||||
ctx,
|
||||
);
|
||||
ctx.pop_stack();
|
||||
traverser.exit_ts_interface_declaration(&mut *node, ctx);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue