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: 1 addition & 1 deletion crates/oxc_ast/src/ast/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface TSIndexSignatureName extends Span {
pub struct TSThisParameter<'a> {
#[serde(flatten)]
pub span: Span,
pub this: IdentifierName<'a>,
pub this_span: Span,
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
}

Expand Down
28 changes: 14 additions & 14 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,11 @@ const _: () = {
assert!(size_of::<ModuleExportName>() == 40usize);
assert!(align_of::<ModuleExportName>() == 8usize);

assert!(size_of::<TSThisParameter>() == 40usize);
assert!(size_of::<TSThisParameter>() == 24usize);
assert!(align_of::<TSThisParameter>() == 8usize);
assert!(offset_of!(TSThisParameter, span) == 0usize);
assert!(offset_of!(TSThisParameter, this) == 8usize);
assert!(offset_of!(TSThisParameter, type_annotation) == 32usize);
assert!(offset_of!(TSThisParameter, this_span) == 8usize);
assert!(offset_of!(TSThisParameter, type_annotation) == 16usize);

assert!(size_of::<TSEnumDeclaration>() == 80usize);
assert!(align_of::<TSEnumDeclaration>() == 8usize);
Expand Down Expand Up @@ -1037,13 +1037,13 @@ const _: () = {
assert!(offset_of!(TSIndexSignature, type_annotation) == 40usize);
assert!(offset_of!(TSIndexSignature, readonly) == 48usize);

assert!(size_of::<TSCallSignatureDeclaration>() == 72usize);
assert!(size_of::<TSCallSignatureDeclaration>() == 64usize);
assert!(align_of::<TSCallSignatureDeclaration>() == 8usize);
assert!(offset_of!(TSCallSignatureDeclaration, span) == 0usize);
assert!(offset_of!(TSCallSignatureDeclaration, this_param) == 8usize);
assert!(offset_of!(TSCallSignatureDeclaration, params) == 48usize);
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 56usize);
assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 64usize);
assert!(offset_of!(TSCallSignatureDeclaration, params) == 40usize);
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 48usize);
assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 56usize);

assert!(size_of::<TSMethodSignatureKind>() == 1usize);
assert!(align_of::<TSMethodSignatureKind>() == 1usize);
Expand Down Expand Up @@ -2339,11 +2339,11 @@ const _: () = {
assert!(size_of::<ModuleExportName>() == 24usize);
assert!(align_of::<ModuleExportName>() == 4usize);

assert!(size_of::<TSThisParameter>() == 28usize);
assert!(size_of::<TSThisParameter>() == 20usize);
assert!(align_of::<TSThisParameter>() == 4usize);
assert!(offset_of!(TSThisParameter, span) == 0usize);
assert!(offset_of!(TSThisParameter, this) == 8usize);
assert!(offset_of!(TSThisParameter, type_annotation) == 24usize);
assert!(offset_of!(TSThisParameter, this_span) == 8usize);
assert!(offset_of!(TSThisParameter, type_annotation) == 16usize);

assert!(size_of::<TSEnumDeclaration>() == 52usize);
assert!(align_of::<TSEnumDeclaration>() == 4usize);
Expand Down Expand Up @@ -2591,13 +2591,13 @@ const _: () = {
assert!(offset_of!(TSIndexSignature, type_annotation) == 24usize);
assert!(offset_of!(TSIndexSignature, readonly) == 28usize);

assert!(size_of::<TSCallSignatureDeclaration>() == 48usize);
assert!(size_of::<TSCallSignatureDeclaration>() == 44usize);
assert!(align_of::<TSCallSignatureDeclaration>() == 4usize);
assert!(offset_of!(TSCallSignatureDeclaration, span) == 0usize);
assert!(offset_of!(TSCallSignatureDeclaration, this_param) == 8usize);
assert!(offset_of!(TSCallSignatureDeclaration, params) == 36usize);
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 40usize);
assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 44usize);
assert!(offset_of!(TSCallSignatureDeclaration, params) == 32usize);
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 36usize);
assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 40usize);

assert!(size_of::<TSMethodSignatureKind>() == 1usize);
assert!(align_of::<TSMethodSignatureKind>() == 1usize);
Expand Down
16 changes: 10 additions & 6 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7878,19 +7878,23 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// - span: The [`Span`] covering this node
/// - this
/// - this_span
/// - type_annotation
#[inline]
pub fn ts_this_parameter<T1>(
self,
span: Span,
this: IdentifierName<'a>,
this_span: Span,
type_annotation: T1,
) -> TSThisParameter<'a>
where
T1: IntoIn<'a, Option<Box<'a, TSTypeAnnotation<'a>>>>,
{
TSThisParameter { span, this, type_annotation: type_annotation.into_in(self.allocator) }
TSThisParameter {
span,
this_span,
type_annotation: type_annotation.into_in(self.allocator),
}
}

/// Builds a [`TSThisParameter`] and stores it in the memory arena.
Expand All @@ -7899,19 +7903,19 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// - span: The [`Span`] covering this node
/// - this
/// - this_span
/// - type_annotation
#[inline]
pub fn alloc_ts_this_parameter<T1>(
self,
span: Span,
this: IdentifierName<'a>,
this_span: Span,
type_annotation: T1,
) -> Box<'a, TSThisParameter<'a>>
where
T1: IntoIn<'a, Option<Box<'a, TSTypeAnnotation<'a>>>>,
{
Box::new_in(self.ts_this_parameter(span, this, type_annotation), self.allocator)
Box::new_in(self.ts_this_parameter(span, this_span, type_annotation), self.allocator)
}

/// Builds a [`TSEnumDeclaration`]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/generated/derive_clone_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,7 @@ impl<'old_alloc, 'new_alloc> CloneIn<'new_alloc> for TSThisParameter<'old_alloc>
fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned {
TSThisParameter {
span: self.span.clone_in(allocator),
this: self.this.clone_in(allocator),
this_span: self.this_span.clone_in(allocator),
type_annotation: self.type_annotation.clone_in(allocator),
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/generated/derive_content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,7 @@ impl<'a> ContentEq for ModuleExportName<'a> {

impl<'a> ContentEq for TSThisParameter<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.this.content_eq(&other.this) && self.type_annotation.content_eq(&other.type_annotation)
self.type_annotation.content_eq(&other.type_annotation)
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,6 @@ pub mod walk {
pub fn walk_ts_this_parameter<'a, V: Visit<'a>>(visitor: &mut V, it: &TSThisParameter<'a>) {
let kind = AstKind::TSThisParameter(visitor.alloc(it));
visitor.enter_node(kind);
visitor.visit_identifier_name(&it.this);
if let Some(type_annotation) = &it.type_annotation {
visitor.visit_ts_type_annotation(type_annotation);
}
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,6 @@ pub mod walk_mut {
) {
let kind = AstType::TSThisParameter;
visitor.enter_node(kind);
visitor.visit_identifier_name(&mut it.this);
if let Some(type_annotation) = &mut it.type_annotation {
visitor.visit_ts_type_annotation(type_annotation);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3161,7 +3161,7 @@ impl<'a> Gen for TSFunctionType<'a> {

impl<'a> Gen for TSThisParameter<'a> {
fn gen(&self, p: &mut Codegen, ctx: Context) {
self.this.gen(p, ctx);
p.print_str("this");
if let Some(type_annotation) = &self.type_annotation {
p.print_str(": ");
type_annotation.gen(p, ctx);
Expand Down
9 changes: 5 additions & 4 deletions crates/oxc_parser/src/ts/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,11 @@ impl<'a> ParserImpl<'a> {
let span = self.start_span();
self.parse_class_element_modifiers(true);
self.eat_decorators()?;
let this = {
let (span, name) = self.parse_identifier_kind(Kind::This);
self.ast.identifier_name(span, name)
};

let this_span = self.start_span();
self.bump_any();
let this = self.end_span(this_span);

let type_annotation = self.parse_ts_type_annotation()?;
Ok(self.ast.ts_this_parameter(self.end_span(span), this, type_annotation))
}
Expand Down
Loading