Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ast/estree): visit JSXOpeningFragment and JSXClosingFragment #9342

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
4 changes: 2 additions & 2 deletions crates/oxc_ast/src/ast/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub struct JSXFragment<'a> {
}

/// JSX Opening Fragment (`<>`)
#[ast]
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXOpeningFragment {
Expand All @@ -135,7 +135,7 @@ pub struct JSXOpeningFragment {
}

/// JSX Closing Fragment (`</>`)
#[ast]
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct JSXClosingFragment {
Expand Down
12 changes: 0 additions & 12 deletions crates/oxc_ast/src/ast_builder_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,4 @@ impl<'a> AstBuilder<'a> {
self.allocator,
)
}

/// Create an [`JSXOpeningElement`].
#[inline]
pub fn jsx_opening_fragment(self, span: Span) -> JSXOpeningFragment {
JSXOpeningFragment { span }
}

/// Create an [`JSXClosingElement`].
#[inline]
pub fn jsx_closing_fragment(self, span: Span) -> JSXClosingFragment {
JSXClosingFragment { span }
}
}
44 changes: 44 additions & 0 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7763,6 +7763,50 @@ impl<'a> AstBuilder<'a> {
)
}

/// Build a [`JSXOpeningFragment`].
///
/// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_opening_fragment`] instead.
///
/// ## Parameters
/// * `span`: Node location in source code
#[inline]
pub fn jsx_opening_fragment(self, span: Span) -> JSXOpeningFragment {
JSXOpeningFragment { span }
}

/// Build a [`JSXOpeningFragment`], and store it in the memory arena.
///
/// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_opening_fragment`] instead.
///
/// ## Parameters
/// * `span`: Node location in source code
#[inline]
pub fn alloc_jsx_opening_fragment(self, span: Span) -> Box<'a, JSXOpeningFragment> {
Box::new_in(self.jsx_opening_fragment(span), self.allocator)
}

/// Build a [`JSXClosingFragment`].
///
/// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_closing_fragment`] instead.
///
/// ## Parameters
/// * `span`: Node location in source code
#[inline]
pub fn jsx_closing_fragment(self, span: Span) -> JSXClosingFragment {
JSXClosingFragment { span }
}

/// Build a [`JSXClosingFragment`], and store it in the memory arena.
///
/// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_closing_fragment`] instead.
///
/// ## Parameters
/// * `span`: Node location in source code
#[inline]
pub fn alloc_jsx_closing_fragment(self, span: Span) -> Box<'a, JSXClosingFragment> {
Box::new_in(self.jsx_closing_fragment(span), self.allocator)
}

/// Build a [`JSXElementName::Identifier`].
///
/// This node contains a [`JSXIdentifier`] that will be stored in the memory arena.
Expand Down
24 changes: 24 additions & 0 deletions crates/oxc_ast/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,16 @@ pub trait Visit<'a>: Sized {
walk_jsx_fragment(self, it);
}

#[inline]
fn visit_jsx_opening_fragment(&mut self, it: &JSXOpeningFragment) {
walk_jsx_opening_fragment(self, it);
}

#[inline]
fn visit_jsx_closing_fragment(&mut self, it: &JSXClosingFragment) {
walk_jsx_closing_fragment(self, it);
}

#[inline]
fn visit_jsx_element_name(&mut self, it: &JSXElementName<'a>) {
walk_jsx_element_name(self, it);
Expand Down Expand Up @@ -2953,10 +2963,24 @@ pub mod walk {
let kind = AstKind::JSXFragment(visitor.alloc(it));
visitor.enter_node(kind);
visitor.visit_span(&it.span);
visitor.visit_jsx_opening_fragment(&it.opening_fragment);
visitor.visit_jsx_closing_fragment(&it.closing_fragment);
visitor.visit_jsx_children(&it.children);
visitor.leave_node(kind);
}

#[inline]
pub fn walk_jsx_opening_fragment<'a, V: Visit<'a>>(visitor: &mut V, it: &JSXOpeningFragment) {
// No `AstKind` for this type
visitor.visit_span(&it.span);
}

#[inline]
pub fn walk_jsx_closing_fragment<'a, V: Visit<'a>>(visitor: &mut V, it: &JSXClosingFragment) {
// No `AstKind` for this type
visitor.visit_span(&it.span);
}

#[inline]
pub fn walk_jsx_element_name<'a, V: Visit<'a>>(visitor: &mut V, it: &JSXElementName<'a>) {
let kind = AstKind::JSXElementName(visitor.alloc(it));
Expand Down
30 changes: 30 additions & 0 deletions crates/oxc_ast/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,16 @@ pub trait VisitMut<'a>: Sized {
walk_jsx_fragment(self, it);
}

#[inline]
fn visit_jsx_opening_fragment(&mut self, it: &mut JSXOpeningFragment) {
walk_jsx_opening_fragment(self, it);
}

#[inline]
fn visit_jsx_closing_fragment(&mut self, it: &mut JSXClosingFragment) {
walk_jsx_closing_fragment(self, it);
}

#[inline]
fn visit_jsx_element_name(&mut self, it: &mut JSXElementName<'a>) {
walk_jsx_element_name(self, it);
Expand Down Expand Up @@ -3075,10 +3085,30 @@ pub mod walk_mut {
let kind = AstType::JSXFragment;
visitor.enter_node(kind);
visitor.visit_span(&mut it.span);
visitor.visit_jsx_opening_fragment(&mut it.opening_fragment);
visitor.visit_jsx_closing_fragment(&mut it.closing_fragment);
visitor.visit_jsx_children(&mut it.children);
visitor.leave_node(kind);
}

#[inline]
pub fn walk_jsx_opening_fragment<'a, V: VisitMut<'a>>(
visitor: &mut V,
it: &mut JSXOpeningFragment,
) {
// No `AstType` for this type
visitor.visit_span(&mut it.span);
}

#[inline]
pub fn walk_jsx_closing_fragment<'a, V: VisitMut<'a>>(
visitor: &mut V,
it: &mut JSXClosingFragment,
) {
// No `AstType` for this type
visitor.visit_span(&mut it.span);
}

#[inline]
pub fn walk_jsx_element_name<'a, V: VisitMut<'a>>(
visitor: &mut V,
Expand Down
Loading
Loading