Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ target/
/editors/vscode/out/
/editors/vscode/*.vsix

# JetBrains
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oxc/.gitignore

Lines 42 to 46 in 29edb51

# NOTE: For non-project files such as `.vscode` or `.idea`, please add them to your `.gitignore_global`.
# In `.gitconfig`, add `[core] excludesfile = ~/.gitignore_global`
# See also
# * https://stackoverflow.com/a/7335487
# * https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that I don't want to ignore it on my repos
But I will use a local gitignore

/.idea/

# Cloned conformance repos
tasks/coverage/babel/
tasks/coverage/test262/
Expand Down
32 changes: 2 additions & 30 deletions crates/oxc_ast/src/ast/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,40 +1280,12 @@ pub struct TSImportType<'a> {
pub span: Span,
/// `true` for `typeof import("foo")`
pub is_type_of: bool,
pub parameter: TSType<'a>,
pub argument: TSType<'a>,
pub qualifier: Option<TSTypeName<'a>>,
pub attributes: Option<Box<'a, TSImportAttributes<'a>>>,
pub options: Option<ObjectExpression<'a>>,
pub type_parameters: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
}

#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct TSImportAttributes<'a> {
pub span: Span,
pub attributes_keyword: IdentifierName<'a>, // `with` or `assert`
pub elements: Vec<'a, TSImportAttribute<'a>>,
}

#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
// Pluralize as `TSImportAttributeList` to avoid naming clash with `TSImportAttributes`.
#[plural(TSImportAttributeList)]
pub struct TSImportAttribute<'a> {
pub span: Span,
pub name: TSImportAttributeName<'a>,
pub value: Expression<'a>,
}

#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub enum TSImportAttributeName<'a> {
Identifier(IdentifierName<'a>) = 0,
StringLiteral(StringLiteral<'a>) = 1,
}

/// TypeScript Function Type
///
/// ## Examples
Expand Down
46 changes: 8 additions & 38 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,29 +1253,14 @@ const _: () = {
assert!(size_of::<TSTypeQueryExprName>() == 16);
assert!(align_of::<TSTypeQueryExprName>() == 8);

assert!(size_of::<TSImportType>() == 64);
assert!(size_of::<TSImportType>() == 112);
assert!(align_of::<TSImportType>() == 8);
assert!(offset_of!(TSImportType, span) == 0);
assert!(offset_of!(TSImportType, is_type_of) == 8);
assert!(offset_of!(TSImportType, parameter) == 16);
assert!(offset_of!(TSImportType, argument) == 16);
assert!(offset_of!(TSImportType, qualifier) == 32);
assert!(offset_of!(TSImportType, attributes) == 48);
assert!(offset_of!(TSImportType, type_parameters) == 56);

assert!(size_of::<TSImportAttributes>() == 64);
assert!(align_of::<TSImportAttributes>() == 8);
assert!(offset_of!(TSImportAttributes, span) == 0);
assert!(offset_of!(TSImportAttributes, attributes_keyword) == 8);
assert!(offset_of!(TSImportAttributes, elements) == 32);

assert!(size_of::<TSImportAttribute>() == 72);
assert!(align_of::<TSImportAttribute>() == 8);
assert!(offset_of!(TSImportAttribute, span) == 0);
assert!(offset_of!(TSImportAttribute, name) == 8);
assert!(offset_of!(TSImportAttribute, value) == 56);

assert!(size_of::<TSImportAttributeName>() == 48);
assert!(align_of::<TSImportAttributeName>() == 8);
assert!(offset_of!(TSImportType, options) == 48);
assert!(offset_of!(TSImportType, type_parameters) == 104);

assert!(size_of::<TSFunctionType>() == 48);
assert!(align_of::<TSFunctionType>() == 8);
Expand Down Expand Up @@ -2657,29 +2642,14 @@ const _: () = {
assert!(size_of::<TSTypeQueryExprName>() == 8);
assert!(align_of::<TSTypeQueryExprName>() == 4);

assert!(size_of::<TSImportType>() == 36);
assert!(size_of::<TSImportType>() == 68);
assert!(align_of::<TSImportType>() == 4);
assert!(offset_of!(TSImportType, span) == 0);
assert!(offset_of!(TSImportType, is_type_of) == 8);
assert!(offset_of!(TSImportType, parameter) == 12);
assert!(offset_of!(TSImportType, argument) == 12);
assert!(offset_of!(TSImportType, qualifier) == 20);
assert!(offset_of!(TSImportType, attributes) == 28);
assert!(offset_of!(TSImportType, type_parameters) == 32);

assert!(size_of::<TSImportAttributes>() == 40);
assert!(align_of::<TSImportAttributes>() == 4);
assert!(offset_of!(TSImportAttributes, span) == 0);
assert!(offset_of!(TSImportAttributes, attributes_keyword) == 8);
assert!(offset_of!(TSImportAttributes, elements) == 24);

assert!(size_of::<TSImportAttribute>() == 44);
assert!(align_of::<TSImportAttribute>() == 4);
assert!(offset_of!(TSImportAttribute, span) == 0);
assert!(offset_of!(TSImportAttribute, name) == 8);
assert!(offset_of!(TSImportAttribute, value) == 36);

assert!(size_of::<TSImportAttributeName>() == 28);
assert!(align_of::<TSImportAttributeName>() == 4);
assert!(offset_of!(TSImportType, options) == 28);
assert!(offset_of!(TSImportType, type_parameters) == 64);

assert!(size_of::<TSFunctionType>() == 28);
assert!(align_of::<TSFunctionType>() == 4);
Expand Down
189 changes: 35 additions & 154 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10307,30 +10307,29 @@ impl<'a> AstBuilder<'a> {
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `is_type_of`: `true` for `typeof import("foo")`
/// * `parameter`
/// * `argument`
/// * `qualifier`
/// * `attributes`
/// * `options`
/// * `type_parameters`
#[inline]
pub fn ts_type_import_type<T1, T2>(
pub fn ts_type_import_type<T1>(
self,
span: Span,
is_type_of: bool,
parameter: TSType<'a>,
argument: TSType<'a>,
qualifier: Option<TSTypeName<'a>>,
attributes: T1,
type_parameters: T2,
options: Option<ObjectExpression<'a>>,
type_parameters: T1,
) -> TSType<'a>
where
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
{
TSType::TSImportType(self.alloc_ts_import_type(
span,
is_type_of,
parameter,
argument,
qualifier,
attributes,
options,
type_parameters,
))
}
Expand Down Expand Up @@ -13423,30 +13422,29 @@ impl<'a> AstBuilder<'a> {
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `is_type_of`: `true` for `typeof import("foo")`
/// * `parameter`
/// * `argument`
/// * `qualifier`
/// * `attributes`
/// * `options`
/// * `type_parameters`
#[inline]
pub fn ts_type_query_expr_name_import_type<T1, T2>(
pub fn ts_type_query_expr_name_import_type<T1>(
self,
span: Span,
is_type_of: bool,
parameter: TSType<'a>,
argument: TSType<'a>,
qualifier: Option<TSTypeName<'a>>,
attributes: T1,
type_parameters: T2,
options: Option<ObjectExpression<'a>>,
type_parameters: T1,
) -> TSTypeQueryExprName<'a>
where
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
{
TSTypeQueryExprName::TSImportType(self.alloc_ts_import_type(
span,
is_type_of,
parameter,
argument,
qualifier,
attributes,
options,
type_parameters,
))
}
Expand All @@ -13458,30 +13456,29 @@ impl<'a> AstBuilder<'a> {
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `is_type_of`: `true` for `typeof import("foo")`
/// * `parameter`
/// * `argument`
/// * `qualifier`
/// * `attributes`
/// * `options`
/// * `type_parameters`
#[inline]
pub fn ts_import_type<T1, T2>(
pub fn ts_import_type<T1>(
self,
span: Span,
is_type_of: bool,
parameter: TSType<'a>,
argument: TSType<'a>,
qualifier: Option<TSTypeName<'a>>,
attributes: T1,
type_parameters: T2,
options: Option<ObjectExpression<'a>>,
type_parameters: T1,
) -> TSImportType<'a>
where
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
{
TSImportType {
span,
is_type_of,
parameter,
argument,
qualifier,
attributes: attributes.into_in(self.allocator),
options,
type_parameters: type_parameters.into_in(self.allocator),
}
}
Expand All @@ -13493,145 +13490,29 @@ impl<'a> AstBuilder<'a> {
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `is_type_of`: `true` for `typeof import("foo")`
/// * `parameter`
/// * `argument`
/// * `qualifier`
/// * `attributes`
/// * `options`
/// * `type_parameters`
#[inline]
pub fn alloc_ts_import_type<T1, T2>(
pub fn alloc_ts_import_type<T1>(
self,
span: Span,
is_type_of: bool,
parameter: TSType<'a>,
argument: TSType<'a>,
qualifier: Option<TSTypeName<'a>>,
attributes: T1,
type_parameters: T2,
options: Option<ObjectExpression<'a>>,
type_parameters: T1,
) -> Box<'a, TSImportType<'a>>
where
T1: IntoIn<'a, Option<Box<'a, TSImportAttributes<'a>>>>,
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
{
Box::new_in(
self.ts_import_type(
span,
is_type_of,
parameter,
qualifier,
attributes,
type_parameters,
),
self.ts_import_type(span, is_type_of, argument, qualifier, options, type_parameters),
self.allocator,
)
}

/// Build a [`TSImportAttributes`].
///
/// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_import_attributes`] instead.
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `attributes_keyword`
/// * `elements`
#[inline]
pub fn ts_import_attributes(
self,
span: Span,
attributes_keyword: IdentifierName<'a>,
elements: Vec<'a, TSImportAttribute<'a>>,
) -> TSImportAttributes<'a> {
TSImportAttributes { span, attributes_keyword, elements }
}

/// Build a [`TSImportAttributes`], and store it in the memory arena.
///
/// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_import_attributes`] instead.
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `attributes_keyword`
/// * `elements`
#[inline]
pub fn alloc_ts_import_attributes(
self,
span: Span,
attributes_keyword: IdentifierName<'a>,
elements: Vec<'a, TSImportAttribute<'a>>,
) -> Box<'a, TSImportAttributes<'a>> {
Box::new_in(self.ts_import_attributes(span, attributes_keyword, elements), self.allocator)
}

/// Build a [`TSImportAttribute`].
///
/// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_import_attribute`] instead.
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `name`
/// * `value`
#[inline]
pub fn ts_import_attribute(
self,
span: Span,
name: TSImportAttributeName<'a>,
value: Expression<'a>,
) -> TSImportAttribute<'a> {
TSImportAttribute { span, name, value }
}

/// Build a [`TSImportAttribute`], and store it in the memory arena.
///
/// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_import_attribute`] instead.
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `name`
/// * `value`
#[inline]
pub fn alloc_ts_import_attribute(
self,
span: Span,
name: TSImportAttributeName<'a>,
value: Expression<'a>,
) -> Box<'a, TSImportAttribute<'a>> {
Box::new_in(self.ts_import_attribute(span, name, value), self.allocator)
}

/// Build a [`TSImportAttributeName::Identifier`].
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `name`
#[inline]
pub fn ts_import_attribute_name_identifier<A>(
self,
span: Span,
name: A,
) -> TSImportAttributeName<'a>
where
A: IntoIn<'a, Atom<'a>>,
{
TSImportAttributeName::Identifier(self.identifier_name(span, name))
}

/// Build a [`TSImportAttributeName::StringLiteral`].
///
/// ## Parameters
/// * `span`: Node location in source code
/// * `value`: The value of the string.
/// * `raw`: The raw string as it appears in source code.
#[inline]
pub fn ts_import_attribute_name_string_literal<A>(
self,
span: Span,
value: A,
raw: Option<Atom<'a>>,
) -> TSImportAttributeName<'a>
where
A: IntoIn<'a, Atom<'a>>,
{
TSImportAttributeName::StringLiteral(self.string_literal(span, value, raw))
}

/// Build a [`TSFunctionType`].
///
/// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_function_type`] instead.
Expand Down
Loading
Loading