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
6 changes: 3 additions & 3 deletions crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2311,7 +2311,7 @@ pub struct ImportDeclaration<'a> {
pub specifiers: Option<Vec<'a, ImportDeclarationSpecifier<'a>>>,
pub source: StringLiteral<'a>,
/// Some(vec![]) for empty assertion
pub with_clause: Option<WithClause<'a>>,
pub with_clause: Option<Box<'a, WithClause<'a>>>,
/// `import type { foo } from 'bar'`
pub import_kind: ImportOrExportKind,
}
Expand Down Expand Up @@ -2452,7 +2452,7 @@ pub struct ExportNamedDeclaration<'a> {
/// `export type { foo }`
pub export_kind: ImportOrExportKind,
/// Some(vec![]) for empty assertion
pub with_clause: Option<WithClause<'a>>,
pub with_clause: Option<Box<'a, WithClause<'a>>>,
}

/// Export Default Declaration
Expand Down Expand Up @@ -2497,7 +2497,7 @@ pub struct ExportAllDeclaration<'a> {
pub exported: Option<ModuleExportName<'a>>,
pub source: StringLiteral<'a>,
/// Will be `Some(vec![])` for empty assertion
pub with_clause: Option<WithClause<'a>>, // Some(vec![]) for empty assertion
pub with_clause: Option<Box<'a, WithClause<'a>>>, // Some(vec![]) for empty assertion
pub export_kind: ImportOrExportKind, // `export type *`
}

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_ast/src/ast_builder_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl<'a> AstBuilder<'a> {
self.vec(),
None,
ImportOrExportKind::Value,
None,
None::<WithClause>,
))
}

Expand All @@ -191,7 +191,7 @@ impl<'a> AstBuilder<'a> {
specifiers,
source,
ImportOrExportKind::Value,
None,
None::<WithClause>,
))
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ impl<'a> ModuleDeclaration<'a> {
}
}

pub fn with_clause(&self) -> Option<&WithClause<'a>> {
pub fn with_clause(&self) -> Option<&Box<'a, WithClause<'a>>> {
match self {
Self::ImportDeclaration(decl) => decl.with_clause.as_ref(),
Self::ExportAllDeclaration(decl) => decl.with_clause.as_ref(),
Expand Down
20 changes: 10 additions & 10 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,13 +706,13 @@ const _: () = {
assert!(offset_of!(ImportExpression, source) == 8usize);
assert!(offset_of!(ImportExpression, arguments) == 24usize);

assert!(size_of::<ImportDeclaration>() == 136usize);
assert!(size_of::<ImportDeclaration>() == 80usize);
assert!(align_of::<ImportDeclaration>() == 8usize);
assert!(offset_of!(ImportDeclaration, span) == 0usize);
assert!(offset_of!(ImportDeclaration, specifiers) == 8usize);
assert!(offset_of!(ImportDeclaration, source) == 40usize);
assert!(offset_of!(ImportDeclaration, with_clause) == 64usize);
assert!(offset_of!(ImportDeclaration, import_kind) == 128usize);
assert!(offset_of!(ImportDeclaration, import_kind) == 72usize);

assert!(size_of::<ImportDeclarationSpecifier>() == 16usize);
assert!(align_of::<ImportDeclarationSpecifier>() == 8usize);
Expand Down Expand Up @@ -749,7 +749,7 @@ const _: () = {
assert!(size_of::<ImportAttributeKey>() == 32usize);
assert!(align_of::<ImportAttributeKey>() == 8usize);

assert!(size_of::<ExportNamedDeclaration>() == 152usize);
assert!(size_of::<ExportNamedDeclaration>() == 96usize);
assert!(align_of::<ExportNamedDeclaration>() == 8usize);
assert!(offset_of!(ExportNamedDeclaration, span) == 0usize);
assert!(offset_of!(ExportNamedDeclaration, declaration) == 8usize);
Expand All @@ -764,13 +764,13 @@ const _: () = {
assert!(offset_of!(ExportDefaultDeclaration, declaration) == 8usize);
assert!(offset_of!(ExportDefaultDeclaration, exported) == 24usize);

assert!(size_of::<ExportAllDeclaration>() == 144usize);
assert!(size_of::<ExportAllDeclaration>() == 88usize);
assert!(align_of::<ExportAllDeclaration>() == 8usize);
assert!(offset_of!(ExportAllDeclaration, span) == 0usize);
assert!(offset_of!(ExportAllDeclaration, exported) == 8usize);
assert!(offset_of!(ExportAllDeclaration, source) == 48usize);
assert!(offset_of!(ExportAllDeclaration, with_clause) == 72usize);
assert!(offset_of!(ExportAllDeclaration, export_kind) == 136usize);
assert!(offset_of!(ExportAllDeclaration, export_kind) == 80usize);

assert!(size_of::<ExportSpecifier>() == 96usize);
assert!(align_of::<ExportSpecifier>() == 8usize);
Expand Down Expand Up @@ -2261,13 +2261,13 @@ const _: () = {
assert!(offset_of!(ImportExpression, source) == 8usize);
assert!(offset_of!(ImportExpression, arguments) == 16usize);

assert!(size_of::<ImportDeclaration>() == 84usize);
assert!(size_of::<ImportDeclaration>() == 48usize);
assert!(align_of::<ImportDeclaration>() == 4usize);
assert!(offset_of!(ImportDeclaration, span) == 0usize);
assert!(offset_of!(ImportDeclaration, specifiers) == 8usize);
assert!(offset_of!(ImportDeclaration, source) == 24usize);
assert!(offset_of!(ImportDeclaration, with_clause) == 40usize);
assert!(offset_of!(ImportDeclaration, import_kind) == 80usize);
assert!(offset_of!(ImportDeclaration, import_kind) == 44usize);

assert!(size_of::<ImportDeclarationSpecifier>() == 8usize);
assert!(align_of::<ImportDeclarationSpecifier>() == 4usize);
Expand Down Expand Up @@ -2304,7 +2304,7 @@ const _: () = {
assert!(size_of::<ImportAttributeKey>() == 20usize);
assert!(align_of::<ImportAttributeKey>() == 4usize);

assert!(size_of::<ExportNamedDeclaration>() == 92usize);
assert!(size_of::<ExportNamedDeclaration>() == 56usize);
assert!(align_of::<ExportNamedDeclaration>() == 4usize);
assert!(offset_of!(ExportNamedDeclaration, span) == 0usize);
assert!(offset_of!(ExportNamedDeclaration, declaration) == 8usize);
Expand All @@ -2319,13 +2319,13 @@ const _: () = {
assert!(offset_of!(ExportDefaultDeclaration, declaration) == 8usize);
assert!(offset_of!(ExportDefaultDeclaration, exported) == 16usize);

assert!(size_of::<ExportAllDeclaration>() == 92usize);
assert!(size_of::<ExportAllDeclaration>() == 56usize);
assert!(align_of::<ExportAllDeclaration>() == 4usize);
assert!(offset_of!(ExportAllDeclaration, span) == 0usize);
assert!(offset_of!(ExportAllDeclaration, exported) == 8usize);
assert!(offset_of!(ExportAllDeclaration, source) == 32usize);
assert!(offset_of!(ExportAllDeclaration, with_clause) == 48usize);
assert!(offset_of!(ExportAllDeclaration, export_kind) == 88usize);
assert!(offset_of!(ExportAllDeclaration, export_kind) == 52usize);

assert!(size_of::<ExportSpecifier>() == 60usize);
assert!(align_of::<ExportSpecifier>() == 4usize);
Expand Down
106 changes: 76 additions & 30 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6740,14 +6740,17 @@ impl<'a> AstBuilder<'a> {
/// - with_clause: Some(vec![]) for empty assertion
/// - import_kind: `import type { foo } from 'bar'`
#[inline]
pub fn module_declaration_import_declaration(
pub fn module_declaration_import_declaration<T1>(
self,
span: Span,
specifiers: Option<Vec<'a, ImportDeclarationSpecifier<'a>>>,
source: StringLiteral<'a>,
with_clause: Option<WithClause<'a>>,
with_clause: T1,
import_kind: ImportOrExportKind,
) -> ModuleDeclaration<'a> {
) -> ModuleDeclaration<'a>
where
T1: IntoIn<'a, Option<Box<'a, WithClause<'a>>>>,
{
ModuleDeclaration::ImportDeclaration(self.alloc(self.import_declaration(
span,
specifiers,
Expand Down Expand Up @@ -6777,14 +6780,17 @@ impl<'a> AstBuilder<'a> {
/// - with_clause: Will be `Some(vec![])` for empty assertion
/// - export_kind
#[inline]
pub fn module_declaration_export_all_declaration(
pub fn module_declaration_export_all_declaration<T1>(
self,
span: Span,
exported: Option<ModuleExportName<'a>>,
source: StringLiteral<'a>,
with_clause: Option<WithClause<'a>>,
with_clause: T1,
export_kind: ImportOrExportKind,
) -> ModuleDeclaration<'a> {
) -> ModuleDeclaration<'a>
where
T1: IntoIn<'a, Option<Box<'a, WithClause<'a>>>>,
{
ModuleDeclaration::ExportAllDeclaration(self.alloc(self.export_all_declaration(
span,
exported,
Expand Down Expand Up @@ -6852,15 +6858,18 @@ impl<'a> AstBuilder<'a> {
/// - export_kind: `export type { foo }`
/// - with_clause: Some(vec![]) for empty assertion
#[inline]
pub fn module_declaration_export_named_declaration(
pub fn module_declaration_export_named_declaration<T1>(
self,
span: Span,
declaration: Option<Declaration<'a>>,
specifiers: Vec<'a, ExportSpecifier<'a>>,
source: Option<StringLiteral<'a>>,
export_kind: ImportOrExportKind,
with_clause: Option<WithClause<'a>>,
) -> ModuleDeclaration<'a> {
with_clause: T1,
) -> ModuleDeclaration<'a>
where
T1: IntoIn<'a, Option<Box<'a, WithClause<'a>>>>,
{
ModuleDeclaration::ExportNamedDeclaration(self.alloc(self.export_named_declaration(
span,
declaration,
Expand Down Expand Up @@ -7082,15 +7091,24 @@ impl<'a> AstBuilder<'a> {
/// - with_clause: Some(vec![]) for empty assertion
/// - import_kind: `import type { foo } from 'bar'`
#[inline]
pub fn import_declaration(
pub fn import_declaration<T1>(
self,
span: Span,
specifiers: Option<Vec<'a, ImportDeclarationSpecifier<'a>>>,
source: StringLiteral<'a>,
with_clause: Option<WithClause<'a>>,
with_clause: T1,
import_kind: ImportOrExportKind,
) -> ImportDeclaration<'a> {
ImportDeclaration { span, specifiers, source, with_clause, import_kind }
) -> ImportDeclaration<'a>
where
T1: IntoIn<'a, Option<Box<'a, WithClause<'a>>>>,
{
ImportDeclaration {
span,
specifiers,
source,
with_clause: with_clause.into_in(self.allocator),
import_kind,
}
}

/// Builds a [`ImportDeclaration`] and stores it in the memory arena.
Expand All @@ -7104,14 +7122,17 @@ impl<'a> AstBuilder<'a> {
/// - with_clause: Some(vec![]) for empty assertion
/// - import_kind: `import type { foo } from 'bar'`
#[inline]
pub fn alloc_import_declaration(
pub fn alloc_import_declaration<T1>(
self,
span: Span,
specifiers: Option<Vec<'a, ImportDeclarationSpecifier<'a>>>,
source: StringLiteral<'a>,
with_clause: Option<WithClause<'a>>,
with_clause: T1,
import_kind: ImportOrExportKind,
) -> Box<'a, ImportDeclaration<'a>> {
) -> Box<'a, ImportDeclaration<'a>>
where
T1: IntoIn<'a, Option<Box<'a, WithClause<'a>>>>,
{
Box::new_in(
self.import_declaration(span, specifiers, source, with_clause, import_kind),
self.allocator,
Expand Down Expand Up @@ -7455,16 +7476,26 @@ impl<'a> AstBuilder<'a> {
/// - export_kind: `export type { foo }`
/// - with_clause: Some(vec![]) for empty assertion
#[inline]
pub fn export_named_declaration(
pub fn export_named_declaration<T1>(
self,
span: Span,
declaration: Option<Declaration<'a>>,
specifiers: Vec<'a, ExportSpecifier<'a>>,
source: Option<StringLiteral<'a>>,
export_kind: ImportOrExportKind,
with_clause: Option<WithClause<'a>>,
) -> ExportNamedDeclaration<'a> {
ExportNamedDeclaration { span, declaration, specifiers, source, export_kind, with_clause }
with_clause: T1,
) -> ExportNamedDeclaration<'a>
where
T1: IntoIn<'a, Option<Box<'a, WithClause<'a>>>>,
{
ExportNamedDeclaration {
span,
declaration,
specifiers,
source,
export_kind,
with_clause: with_clause.into_in(self.allocator),
}
}

/// Builds a [`ExportNamedDeclaration`] and stores it in the memory arena.
Expand All @@ -7479,15 +7510,18 @@ impl<'a> AstBuilder<'a> {
/// - export_kind: `export type { foo }`
/// - with_clause: Some(vec![]) for empty assertion
#[inline]
pub fn alloc_export_named_declaration(
pub fn alloc_export_named_declaration<T1>(
self,
span: Span,
declaration: Option<Declaration<'a>>,
specifiers: Vec<'a, ExportSpecifier<'a>>,
source: Option<StringLiteral<'a>>,
export_kind: ImportOrExportKind,
with_clause: Option<WithClause<'a>>,
) -> Box<'a, ExportNamedDeclaration<'a>> {
with_clause: T1,
) -> Box<'a, ExportNamedDeclaration<'a>>
where
T1: IntoIn<'a, Option<Box<'a, WithClause<'a>>>>,
{
Box::new_in(
self.export_named_declaration(
span,
Expand Down Expand Up @@ -7548,15 +7582,24 @@ impl<'a> AstBuilder<'a> {
/// - with_clause: Will be `Some(vec![])` for empty assertion
/// - export_kind
#[inline]
pub fn export_all_declaration(
pub fn export_all_declaration<T1>(
self,
span: Span,
exported: Option<ModuleExportName<'a>>,
source: StringLiteral<'a>,
with_clause: Option<WithClause<'a>>,
with_clause: T1,
export_kind: ImportOrExportKind,
) -> ExportAllDeclaration<'a> {
ExportAllDeclaration { span, exported, source, with_clause, export_kind }
) -> ExportAllDeclaration<'a>
where
T1: IntoIn<'a, Option<Box<'a, WithClause<'a>>>>,
{
ExportAllDeclaration {
span,
exported,
source,
with_clause: with_clause.into_in(self.allocator),
export_kind,
}
}

/// Builds a [`ExportAllDeclaration`] and stores it in the memory arena.
Expand All @@ -7570,14 +7613,17 @@ impl<'a> AstBuilder<'a> {
/// - with_clause: Will be `Some(vec![])` for empty assertion
/// - export_kind
#[inline]
pub fn alloc_export_all_declaration(
pub fn alloc_export_all_declaration<T1>(
self,
span: Span,
exported: Option<ModuleExportName<'a>>,
source: StringLiteral<'a>,
with_clause: Option<WithClause<'a>>,
with_clause: T1,
export_kind: ImportOrExportKind,
) -> Box<'a, ExportAllDeclaration<'a>> {
) -> Box<'a, ExportAllDeclaration<'a>>
where
T1: IntoIn<'a, Option<Box<'a, WithClause<'a>>>>,
{
Box::new_in(
self.export_all_declaration(span, exported, source, with_clause, export_kind),
self.allocator,
Expand Down
Loading