Skip to content

Commit

Permalink
feat(ast_tools): Add #[estree(always_flatten)] to Span (oxc-project#6935
Browse files Browse the repository at this point in the history
)

Part of oxc-project#6347

Other changes:
- added #[estree(skip)] to thisSpan in TSThisParameter
- Flattened the span in BoundaryAssertion (regex)
  • Loading branch information
ottomated authored and Orenbek committed Oct 28, 2024
1 parent 5230c71 commit 75592ef
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 238 deletions.
93 changes: 1 addition & 92 deletions crates/oxc_ast/src/ast/js.rs

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions crates/oxc_ast/src/ast/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use super::{inherit_variants, js::*, literal::*, ts::*};
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXElement<'a> {
#[estree(flatten)]
/// Node location in source code
pub span: Span,
/// Opening tag of the element.
Expand Down Expand Up @@ -65,7 +64,6 @@ pub struct JSXElement<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXOpeningElement<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// Is this tag self-closing?
///
Expand Down Expand Up @@ -99,7 +97,6 @@ pub struct JSXOpeningElement<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXClosingElement<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The tag name, e.g. `Foo` in `</Foo>`.
pub name: JSXElementName<'a>,
Expand All @@ -118,7 +115,6 @@ pub struct JSXClosingElement<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXFragment<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// `<>`
pub opening_fragment: JSXOpeningFragment,
Expand All @@ -134,7 +130,6 @@ pub struct JSXFragment<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXOpeningFragment {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
}

Expand All @@ -144,7 +139,6 @@ pub struct JSXOpeningFragment {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXClosingFragment {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
}

Expand Down Expand Up @@ -177,7 +171,6 @@ pub enum JSXElementName<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXNamespacedName<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// Namespace portion of the name, e.g. `Apple` in `<Apple:Orange />`
pub namespace: JSXIdentifier<'a>,
Expand Down Expand Up @@ -205,7 +198,6 @@ pub struct JSXNamespacedName<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXMemberExpression<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The object being accessed. This is everything before the last `.`.
pub object: JSXMemberExpressionObject<'a>,
Expand Down Expand Up @@ -259,7 +251,6 @@ pub enum JSXMemberExpressionObject<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXExpressionContainer<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The expression inside the container.
pub expression: JSXExpression<'a>,
Expand Down Expand Up @@ -295,7 +286,6 @@ pub enum JSXExpression<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXEmptyExpression {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
}

Expand Down Expand Up @@ -336,7 +326,6 @@ pub enum JSXAttributeItem<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXAttribute<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The name of the attribute. This is a prop in React-like applications.
pub name: JSXAttributeName<'a>,
Expand All @@ -358,7 +347,6 @@ pub struct JSXAttribute<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXSpreadAttribute<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The expression being spread.
pub argument: Expression<'a>,
Expand Down Expand Up @@ -431,7 +419,6 @@ pub enum JSXAttributeValue<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXIdentifier<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The name of the identifier.
pub name: Atom<'a>,
Expand Down Expand Up @@ -466,7 +453,6 @@ pub enum JSXChild<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXSpreadChild<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The expression being spread.
pub expression: Expression<'a>,
Expand All @@ -487,7 +473,6 @@ pub struct JSXSpreadChild<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct JSXText<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The text content.
pub value: Atom<'a>,
Expand Down
6 changes: 0 additions & 6 deletions crates/oxc_ast/src/ast/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use oxc_syntax::number::{BigintBase, NumberBase};
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct BooleanLiteral {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The boolean value itself
pub value: bool,
Expand All @@ -36,7 +35,6 @@ pub struct BooleanLiteral {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct NullLiteral {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
}

Expand All @@ -48,7 +46,6 @@ pub struct NullLiteral {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct NumericLiteral<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The value of the number, converted into base 10
pub value: f64,
Expand All @@ -65,7 +62,6 @@ pub struct NumericLiteral<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct BigIntLiteral<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The bigint as it appears in source code
pub raw: Atom<'a>,
Expand All @@ -82,7 +78,6 @@ pub struct BigIntLiteral<'a> {
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct RegExpLiteral<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// Placeholder for printing.
///
Expand Down Expand Up @@ -142,7 +137,6 @@ pub struct EmptyObject;
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)]
pub struct StringLiteral<'a> {
/// Node location in source code
#[estree(flatten)]
pub span: Span,
/// The string as it appears in source code
pub value: Atom<'a>,
Expand Down
Loading

0 comments on commit 75592ef

Please sign in to comment.