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/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub struct JSXNamespacedName<'a> {
/// Namespace portion of the name, e.g. `Apple` in `<Apple:Orange />`
pub namespace: JSXIdentifier<'a>,
/// Name portion of the name, e.g. `Orange` in `<Apple:Orange />`
pub property: JSXIdentifier<'a>,
pub name: JSXIdentifier<'a>,
}

/// JSX Member Expression
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_ast/src/ast_impl/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl fmt::Display for JSXIdentifier<'_> {

impl fmt::Display for JSXNamespacedName<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}:{}", self.namespace.name, self.property.name)
write!(f, "{}:{}", self.namespace.name, self.name.name)
}
}

Expand Down Expand Up @@ -173,7 +173,7 @@ impl<'a> JSXAttributeName<'a> {
pub fn get_identifier(&self) -> &JSXIdentifier<'a> {
match self {
Self::Identifier(ident) => ident.as_ref(),
Self::NamespacedName(namespaced) => &namespaced.property,
Self::NamespacedName(namespaced) => &namespaced.name,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ const _: () = {
assert!(align_of::<JSXNamespacedName>() == 8);
assert!(offset_of!(JSXNamespacedName, span) == 0);
assert!(offset_of!(JSXNamespacedName, namespace) == 8);
assert!(offset_of!(JSXNamespacedName, property) == 32);
assert!(offset_of!(JSXNamespacedName, name) == 32);

assert!(size_of::<JSXMemberExpression>() == 48);
assert!(align_of::<JSXMemberExpression>() == 8);
Expand Down Expand Up @@ -2246,7 +2246,7 @@ const _: () = {
assert!(align_of::<JSXNamespacedName>() == 4);
assert!(offset_of!(JSXNamespacedName, span) == 0);
assert!(offset_of!(JSXNamespacedName, namespace) == 8);
assert!(offset_of!(JSXNamespacedName, property) == 24);
assert!(offset_of!(JSXNamespacedName, name) == 24);

assert!(size_of::<JSXMemberExpression>() == 32);
assert!(align_of::<JSXMemberExpression>() == 4);
Expand Down
24 changes: 12 additions & 12 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8933,15 +8933,15 @@ impl<'a> AstBuilder<'a> {
/// ## Parameters
/// * `span`: Node location in source code
/// * `namespace`: Namespace portion of the name, e.g. `Apple` in `<Apple:Orange />`
/// * `property`: Name portion of the name, e.g. `Orange` in `<Apple:Orange />`
/// * `name`: Name portion of the name, e.g. `Orange` in `<Apple:Orange />`
#[inline]
pub fn jsx_element_name_namespaced_name(
self,
span: Span,
namespace: JSXIdentifier<'a>,
property: JSXIdentifier<'a>,
name: JSXIdentifier<'a>,
) -> JSXElementName<'a> {
JSXElementName::NamespacedName(self.alloc_jsx_namespaced_name(span, namespace, property))
JSXElementName::NamespacedName(self.alloc_jsx_namespaced_name(span, namespace, name))
}

/// Build a [`JSXElementName::MemberExpression`].
Expand Down Expand Up @@ -8980,15 +8980,15 @@ impl<'a> AstBuilder<'a> {
/// ## Parameters
/// * `span`: Node location in source code
/// * `namespace`: Namespace portion of the name, e.g. `Apple` in `<Apple:Orange />`
/// * `property`: Name portion of the name, e.g. `Orange` in `<Apple:Orange />`
/// * `name`: Name portion of the name, e.g. `Orange` in `<Apple:Orange />`
#[inline]
pub fn jsx_namespaced_name(
self,
span: Span,
namespace: JSXIdentifier<'a>,
property: JSXIdentifier<'a>,
name: JSXIdentifier<'a>,
) -> JSXNamespacedName<'a> {
JSXNamespacedName { span, namespace, property }
JSXNamespacedName { span, namespace, name }
}

/// Build a [`JSXNamespacedName`], and store it in the memory arena.
Expand All @@ -8998,15 +8998,15 @@ impl<'a> AstBuilder<'a> {
/// ## Parameters
/// * `span`: Node location in source code
/// * `namespace`: Namespace portion of the name, e.g. `Apple` in `<Apple:Orange />`
/// * `property`: Name portion of the name, e.g. `Orange` in `<Apple:Orange />`
/// * `name`: Name portion of the name, e.g. `Orange` in `<Apple:Orange />`
#[inline]
pub fn alloc_jsx_namespaced_name(
self,
span: Span,
namespace: JSXIdentifier<'a>,
property: JSXIdentifier<'a>,
name: JSXIdentifier<'a>,
) -> Box<'a, JSXNamespacedName<'a>> {
Box::new_in(self.jsx_namespaced_name(span, namespace, property), self.allocator)
Box::new_in(self.jsx_namespaced_name(span, namespace, name), self.allocator)
}

/// Build a [`JSXMemberExpression`].
Expand Down Expand Up @@ -9308,15 +9308,15 @@ impl<'a> AstBuilder<'a> {
/// ## Parameters
/// * `span`: Node location in source code
/// * `namespace`: Namespace portion of the name, e.g. `Apple` in `<Apple:Orange />`
/// * `property`: Name portion of the name, e.g. `Orange` in `<Apple:Orange />`
/// * `name`: Name portion of the name, e.g. `Orange` in `<Apple:Orange />`
#[inline]
pub fn jsx_attribute_name_namespaced_name(
self,
span: Span,
namespace: JSXIdentifier<'a>,
property: JSXIdentifier<'a>,
name: JSXIdentifier<'a>,
) -> JSXAttributeName<'a> {
JSXAttributeName::NamespacedName(self.alloc_jsx_namespaced_name(span, namespace, property))
JSXAttributeName::NamespacedName(self.alloc_jsx_namespaced_name(span, namespace, name))
}

/// Build a [`JSXAttributeValue::StringLiteral`].
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 @@ -2670,7 +2670,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for JSXNamespacedName<'_> {
JSXNamespacedName {
span: CloneIn::clone_in(&self.span, allocator),
namespace: CloneIn::clone_in(&self.namespace, allocator),
property: CloneIn::clone_in(&self.property, allocator),
name: CloneIn::clone_in(&self.name, 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 @@ -1552,7 +1552,7 @@ impl ContentEq for JSXElementName<'_> {
impl ContentEq for JSXNamespacedName<'_> {
fn content_eq(&self, other: &Self) -> bool {
ContentEq::content_eq(&self.namespace, &other.namespace)
&& ContentEq::content_eq(&self.property, &other.property)
&& ContentEq::content_eq(&self.name, &other.name)
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/generated/derive_estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2061,7 +2061,7 @@ impl ESTree for JSXNamespacedName<'_> {
state.serialize_field("start", &self.span.start);
state.serialize_field("end", &self.span.end);
state.serialize_field("namespace", &self.namespace);
state.serialize_field("property", &self.property);
state.serialize_field("name", &self.name);
state.end();
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast_visit/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3022,7 +3022,7 @@ pub mod walk {
visitor.enter_node(kind);
visitor.visit_span(&it.span);
visitor.visit_jsx_identifier(&it.namespace);
visitor.visit_jsx_identifier(&it.property);
visitor.visit_jsx_identifier(&it.name);
visitor.leave_node(kind);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast_visit/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3156,7 +3156,7 @@ pub mod walk_mut {
visitor.enter_node(kind);
visitor.visit_span(&mut it.span);
visitor.visit_jsx_identifier(&mut it.namespace);
visitor.visit_jsx_identifier(&mut it.property);
visitor.visit_jsx_identifier(&mut it.name);
visitor.leave_node(kind);
}

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 @@ -2431,7 +2431,7 @@ impl Gen for JSXNamespacedName<'_> {
fn r#gen(&self, p: &mut Codegen, ctx: Context) {
self.namespace.print(p, ctx);
p.print_colon();
self.property.print(p, ctx);
self.name.print(p, ctx);
}
}

Expand Down
6 changes: 2 additions & 4 deletions crates/oxc_linter/src/rules/react/no_namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ impl Rule for NoNamespace {
match node.kind() {
AstKind::JSXOpeningElement(element) => {
if let JSXElementName::NamespacedName(namespaced_name) = &element.name {
let component_name_with_ns = format!(
"{}:{}",
namespaced_name.namespace.name, namespaced_name.property.name
);
let component_name_with_ns =
format!("{}:{}", namespaced_name.namespace.name, namespaced_name.name.name);

ctx.diagnostic(no_namespace_diagnostic(
namespaced_name.span,
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/utils/react.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn get_prop_value<'a, 'b>(item: &'b JSXAttributeItem<'a>) -> Option<&'b JSXA
pub fn get_jsx_attribute_name<'a>(attr: &JSXAttributeName<'a>) -> Cow<'a, str> {
match attr {
JSXAttributeName::NamespacedName(name) => {
Cow::Owned(format!("{}:{}", name.namespace.name, name.property.name))
Cow::Owned(format!("{}:{}", name.namespace.name, name.name.name))
}
JSXAttributeName::Identifier(ident) => Cow::Borrowed(ident.name.as_str()),
}
Expand Down Expand Up @@ -228,7 +228,7 @@ pub fn get_element_type<'c, 'a>(
JSXElementName::Identifier(id) => Cow::Borrowed(id.as_ref().name.as_str()),
JSXElementName::IdentifierReference(id) => Cow::Borrowed(id.as_ref().name.as_str()),
JSXElementName::NamespacedName(namespaced) => {
Cow::Owned(format!("{}:{}", namespaced.namespace.name, namespaced.property.name))
Cow::Owned(format!("{}:{}", namespaced.namespace.name, namespaced.name.name))
}
JSXElementName::MemberExpression(jsx_mem_expr) => get_jsx_mem_expr_name(jsx_mem_expr),
JSXElementName::ThisExpression(_) => Cow::Borrowed("this"),
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/jsx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl<'a> ParserImpl<'a> {
JSXElementName::IdentifierReference(rhs),
) => lhs.name == rhs.name,
(JSXElementName::NamespacedName(lhs), JSXElementName::NamespacedName(rhs)) => {
lhs.namespace.name == rhs.namespace.name && lhs.property.name == rhs.property.name
lhs.namespace.name == rhs.namespace.name && lhs.name.name == rhs.name.name
}
(JSXElementName::MemberExpression(lhs), JSXElementName::MemberExpression(rhs)) => {
Self::jsx_member_expression_eq(lhs, rhs)
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_prettier/src/format/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ impl<'a> Format<'a> for JSXElementName<'a> {
impl<'a> Format<'a> for JSXNamespacedName<'a> {
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
let namespace_doc = self.namespace.format(p);
let property_doc = self.property.format(p);
array!(p, [namespace_doc, text!(":"), property_doc])
let name_doc = self.name.format(p);
array!(p, [namespace_doc, text!(":"), name_doc])
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ impl<'a> GatherNodeParts<'a> for JSXElementName<'a> {
impl<'a> GatherNodeParts<'a> for JSXNamespacedName<'a> {
fn gather<F: FnMut(&str)>(&self, f: &mut F) {
self.namespace.gather(f);
self.property.gather(f);
self.name.gather(f);
}
}

Expand Down
23 changes: 11 additions & 12 deletions crates/oxc_traverse/src/generated/ancestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub(crate) enum AncestorType {
JSXFragmentClosingFragment = 179,
JSXFragmentChildren = 180,
JSXNamespacedNameNamespace = 181,
JSXNamespacedNameProperty = 182,
JSXNamespacedNameName = 182,
JSXMemberExpressionObject = 183,
JSXMemberExpressionProperty = 184,
JSXExpressionContainerExpression = 185,
Expand Down Expand Up @@ -665,8 +665,8 @@ pub enum Ancestor<'a, 't> {
AncestorType::JSXFragmentChildren as u16,
JSXNamespacedNameNamespace(JSXNamespacedNameWithoutNamespace<'a, 't>) =
AncestorType::JSXNamespacedNameNamespace as u16,
JSXNamespacedNameProperty(JSXNamespacedNameWithoutProperty<'a, 't>) =
AncestorType::JSXNamespacedNameProperty as u16,
JSXNamespacedNameName(JSXNamespacedNameWithoutName<'a, 't>) =
AncestorType::JSXNamespacedNameName as u16,
JSXMemberExpressionObject(JSXMemberExpressionWithoutObject<'a, 't>) =
AncestorType::JSXMemberExpressionObject as u16,
JSXMemberExpressionProperty(JSXMemberExpressionWithoutProperty<'a, 't>) =
Expand Down Expand Up @@ -1472,7 +1472,7 @@ impl<'a, 't> Ancestor<'a, 't> {

#[inline]
pub fn is_jsx_namespaced_name(self) -> bool {
matches!(self, Self::JSXNamespacedNameNamespace(_) | Self::JSXNamespacedNameProperty(_))
matches!(self, Self::JSXNamespacedNameNamespace(_) | Self::JSXNamespacedNameName(_))
}

#[inline]
Expand Down Expand Up @@ -2403,7 +2403,7 @@ impl<'a, 't> GetAddress for Ancestor<'a, 't> {
Self::JSXFragmentClosingFragment(a) => a.address(),
Self::JSXFragmentChildren(a) => a.address(),
Self::JSXNamespacedNameNamespace(a) => a.address(),
Self::JSXNamespacedNameProperty(a) => a.address(),
Self::JSXNamespacedNameName(a) => a.address(),
Self::JSXMemberExpressionObject(a) => a.address(),
Self::JSXMemberExpressionProperty(a) => a.address(),
Self::JSXExpressionContainerExpression(a) => a.address(),
Expand Down Expand Up @@ -10881,8 +10881,7 @@ impl<'a, 't> GetAddress for JSXFragmentWithoutChildren<'a, 't> {
pub(crate) const OFFSET_JSX_NAMESPACED_NAME_SPAN: usize = offset_of!(JSXNamespacedName, span);
pub(crate) const OFFSET_JSX_NAMESPACED_NAME_NAMESPACE: usize =
offset_of!(JSXNamespacedName, namespace);
pub(crate) const OFFSET_JSX_NAMESPACED_NAME_PROPERTY: usize =
offset_of!(JSXNamespacedName, property);
pub(crate) const OFFSET_JSX_NAMESPACED_NAME_NAME: usize = offset_of!(JSXNamespacedName, name);

#[repr(transparent)]
#[derive(Clone, Copy, Debug)]
Expand All @@ -10898,9 +10897,9 @@ impl<'a, 't> JSXNamespacedNameWithoutNamespace<'a, 't> {
}

#[inline]
pub fn property(self) -> &'t JSXIdentifier<'a> {
pub fn name(self) -> &'t JSXIdentifier<'a> {
unsafe {
&*((self.0 as *const u8).add(OFFSET_JSX_NAMESPACED_NAME_PROPERTY)
&*((self.0 as *const u8).add(OFFSET_JSX_NAMESPACED_NAME_NAME)
as *const JSXIdentifier<'a>)
}
}
Expand All @@ -10915,12 +10914,12 @@ impl<'a, 't> GetAddress for JSXNamespacedNameWithoutNamespace<'a, 't> {

#[repr(transparent)]
#[derive(Clone, Copy, Debug)]
pub struct JSXNamespacedNameWithoutProperty<'a, 't>(
pub struct JSXNamespacedNameWithoutName<'a, 't>(
pub(crate) *const JSXNamespacedName<'a>,
pub(crate) PhantomData<&'t ()>,
);

impl<'a, 't> JSXNamespacedNameWithoutProperty<'a, 't> {
impl<'a, 't> JSXNamespacedNameWithoutName<'a, 't> {
#[inline]
pub fn span(self) -> &'t Span {
unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_NAMESPACED_NAME_SPAN) as *const Span) }
Expand All @@ -10935,7 +10934,7 @@ impl<'a, 't> JSXNamespacedNameWithoutProperty<'a, 't> {
}
}

impl<'a, 't> GetAddress for JSXNamespacedNameWithoutProperty<'a, 't> {
impl<'a, 't> GetAddress for JSXNamespacedNameWithoutName<'a, 't> {
#[inline]
fn address(&self) -> Address {
Address::from_ptr(self.0)
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_traverse/src/generated/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3350,10 +3350,10 @@ unsafe fn walk_jsx_namespaced_name<'a, Tr: Traverse<'a>>(
(node as *mut u8).add(ancestor::OFFSET_JSX_NAMESPACED_NAME_NAMESPACE) as *mut JSXIdentifier,
ctx,
);
ctx.retag_stack(AncestorType::JSXNamespacedNameProperty);
ctx.retag_stack(AncestorType::JSXNamespacedNameName);
walk_jsx_identifier(
traverser,
(node as *mut u8).add(ancestor::OFFSET_JSX_NAMESPACED_NAME_PROPERTY) as *mut JSXIdentifier,
(node as *mut u8).add(ancestor::OFFSET_JSX_NAMESPACED_NAME_NAME) as *mut JSXIdentifier,
ctx,
);
ctx.pop_stack(pop_token);
Expand Down
2 changes: 1 addition & 1 deletion napi/parser/deserialize-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ function deserializeJSXNamespacedName(pos) {
start: deserializeU32(pos),
end: deserializeU32(pos + 4),
namespace: deserializeJSXIdentifier(pos + 8),
property: deserializeJSXIdentifier(pos + 32),
name: deserializeJSXIdentifier(pos + 32),
};
}

Expand Down
2 changes: 1 addition & 1 deletion napi/parser/deserialize-ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ function deserializeJSXNamespacedName(pos) {
start: deserializeU32(pos),
end: deserializeU32(pos + 4),
namespace: deserializeJSXIdentifier(pos + 8),
property: deserializeJSXIdentifier(pos + 32),
name: deserializeJSXIdentifier(pos + 32),
};
}

Expand Down
2 changes: 1 addition & 1 deletion npm/oxc-types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ export type JSXElementName = JSXIdentifier | JSXNamespacedName | JSXMemberExpres
export interface JSXNamespacedName extends Span {
type: 'JSXNamespacedName';
namespace: JSXIdentifier;
property: JSXIdentifier;
name: JSXIdentifier;
}

export interface JSXMemberExpression extends Span {
Expand Down
Loading