Skip to content

Commit

Permalink
feat(ast): add ContentEq trait. (#5427)
Browse files Browse the repository at this point in the history
Part of #5283
  • Loading branch information
rzvxa committed Sep 4, 2024
1 parent c782916 commit 23285f4
Show file tree
Hide file tree
Showing 23 changed files with 4,796 additions and 304 deletions.
3 changes: 3 additions & 0 deletions .github/.generated_ast_watch_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ src:
- 'crates/oxc_syntax/src/generated/derive_clone_in.rs'
- 'crates/oxc_ast/src/generated/derive_get_span.rs'
- 'crates/oxc_ast/src/generated/derive_get_span_mut.rs'
- 'crates/oxc_ast/src/generated/derive_content_eq.rs'
- 'crates/oxc_regular_expression/src/generated/derive_content_eq.rs'
- 'crates/oxc_syntax/src/generated/derive_content_eq.rs'
- 'tasks/ast_codegen/src/**'
254 changes: 127 additions & 127 deletions crates/oxc_ast/src/ast/js.rs

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions crates/oxc_ast/src/ast/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use oxc_allocator::{Box, CloneIn, Vec};
use oxc_ast_macros::ast;
use oxc_span::{Atom, GetSpan, GetSpanMut, Span};
use oxc_span::{cmp::ContentEq, Atom, GetSpan, GetSpanMut, Span};
#[cfg(feature = "serialize")]
use serde::Serialize;
#[cfg(feature = "serialize")]
Expand Down Expand Up @@ -38,7 +38,7 @@ use super::{inherit_variants, js::*, literal::*, ts::*};
/// See: [JSX Syntax](https://facebook.github.io/jsx/)
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type", rename_all = "camelCase")]
pub struct JSXElement<'a> {
Expand Down Expand Up @@ -69,7 +69,7 @@ pub struct JSXElement<'a> {
/// ```
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type", rename_all = "camelCase")]
pub struct JSXOpeningElement<'a> {
Expand Down Expand Up @@ -103,7 +103,7 @@ pub struct JSXOpeningElement<'a> {
/// ```
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXClosingElement<'a> {
Expand All @@ -122,7 +122,7 @@ pub struct JSXClosingElement<'a> {
/// See: [`React.Fragment`](https://react.dev/reference/react/Fragment)
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type", rename_all = "camelCase")]
pub struct JSXFragment<'a> {
Expand All @@ -139,7 +139,7 @@ pub struct JSXFragment<'a> {
/// JSX Opening Fragment (`<>`)
#[ast]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXOpeningFragment {
Expand All @@ -150,7 +150,7 @@ pub struct JSXOpeningFragment {
/// JSX Closing Fragment (`</>`)
#[ast]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXClosingFragment {
Expand All @@ -161,7 +161,7 @@ pub struct JSXClosingFragment {
/// JSX Element Name
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(untagged)]
pub enum JSXElementName<'a> {
Expand All @@ -184,7 +184,7 @@ pub enum JSXElementName<'a> {
/// ```
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXNamespacedName<'a> {
Expand Down Expand Up @@ -213,7 +213,7 @@ pub struct JSXNamespacedName<'a> {
/// [`member expression`]: JSXMemberExpressionObject::MemberExpression
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXMemberExpression<'a> {
Expand All @@ -227,7 +227,7 @@ pub struct JSXMemberExpression<'a> {

#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(untagged)]
pub enum JSXMemberExpressionObject<'a> {
Expand All @@ -250,7 +250,7 @@ pub enum JSXMemberExpressionObject<'a> {
/// ```
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXExpressionContainer<'a> {
Expand All @@ -269,7 +269,7 @@ inherit_variants! {
/// [`ast` module docs]: `super`
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(untagged)]
pub enum JSXExpression<'a> {
Expand All @@ -282,7 +282,7 @@ pub enum JSXExpression<'a> {
/// An empty JSX expression (`{}`)
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXEmptyExpression {
Expand All @@ -303,7 +303,7 @@ pub struct JSXEmptyExpression {
/// ```
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(untagged)]
pub enum JSXAttributeItem<'a> {
Expand All @@ -326,7 +326,7 @@ pub enum JSXAttributeItem<'a> {
/// // name ^^^ ^^^^ value
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXAttribute<'a> {
Expand All @@ -349,7 +349,7 @@ pub struct JSXAttribute<'a> {
/// ```
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXSpreadAttribute<'a> {
Expand All @@ -375,7 +375,7 @@ pub struct JSXSpreadAttribute<'a> {
/// ```
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(untagged)]
pub enum JSXAttributeName<'a> {
Expand Down Expand Up @@ -405,7 +405,7 @@ pub enum JSXAttributeName<'a> {
/// ```
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(untagged)]
pub enum JSXAttributeValue<'a> {
Expand All @@ -422,7 +422,7 @@ pub enum JSXAttributeValue<'a> {
/// [`IdentifierName`]: super::IdentifierName
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXIdentifier<'a> {
Expand All @@ -439,7 +439,7 @@ pub struct JSXIdentifier<'a> {
/// Part of a [`JSXElement`].
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(untagged)]
pub enum JSXChild<'a> {
Expand All @@ -460,7 +460,7 @@ pub enum JSXChild<'a> {
/// Variant of [`JSXChild`] that represents an object spread (`{...expression}`).
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXSpreadChild<'a> {
Expand All @@ -482,7 +482,7 @@ pub struct JSXSpreadChild<'a> {
/// ```
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct JSXText<'a> {
Expand Down
20 changes: 10 additions & 10 deletions crates/oxc_ast/src/ast/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bitflags::bitflags;
use oxc_allocator::{Box, CloneIn};
use oxc_ast_macros::ast;
use oxc_regular_expression::ast::Pattern;
use oxc_span::{Atom, GetSpan, GetSpanMut, Span};
use oxc_span::{cmp::ContentEq, Atom, GetSpan, GetSpanMut, Span};
use oxc_syntax::number::{BigintBase, NumberBase};
#[cfg(feature = "serialize")]
use serde::Serialize;
Expand All @@ -25,7 +25,7 @@ use tsify::Tsify;
/// <https://tc39.es/ecma262/#prod-BooleanLiteral>
#[ast(visit)]
#[derive(Debug, Clone, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct BooleanLiteral {
Expand All @@ -39,7 +39,7 @@ pub struct BooleanLiteral {
/// <https://tc39.es/ecma262/#sec-null-literals>
#[ast(visit)]
#[derive(Debug, Clone)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct NullLiteral {
Expand All @@ -52,7 +52,7 @@ pub struct NullLiteral {
/// <https://tc39.es/ecma262/#sec-literals-numeric-literals>
#[ast(visit)]
#[derive(Debug, Clone)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct NumericLiteral<'a> {
Expand All @@ -70,7 +70,7 @@ pub struct NumericLiteral<'a> {
/// BigInt literal
#[ast(visit)]
#[derive(Debug, Clone, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct BigIntLiteral<'a> {
Expand All @@ -88,7 +88,7 @@ pub struct BigIntLiteral<'a> {
/// <https://tc39.es/ecma262/#sec-literals-regular-expression-literals>
#[ast(visit)]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct RegExpLiteral<'a> {
Expand All @@ -105,7 +105,7 @@ pub struct RegExpLiteral<'a> {
/// <https://tc39.es/ecma262/multipage/text-processing.html#sec-regexp-regular-expression-objects>
#[ast]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn)]
#[generate_derive(CloneIn, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
pub struct RegExp<'a> {
/// The regex pattern between the slashes
Expand All @@ -119,7 +119,7 @@ pub struct RegExp<'a> {
/// This pattern may or may not be parsed.
#[ast]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn)]
#[generate_derive(CloneIn, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
pub enum RegExpPattern<'a> {
/// Unparsed pattern, Contains a string slice of the pattern.
Expand All @@ -132,7 +132,7 @@ pub enum RegExpPattern<'a> {

#[ast]
#[derive(Debug, Clone, Hash)]
#[generate_derive(CloneIn)]
#[generate_derive(CloneIn, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
pub struct EmptyObject;

Expand All @@ -141,7 +141,7 @@ pub struct EmptyObject;
/// <https://tc39.es/ecma262/#sec-literals-string-literals>
#[ast(visit)]
#[derive(Debug, Clone, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type")]
pub struct StringLiteral<'a> {
Expand Down
Loading

0 comments on commit 23285f4

Please sign in to comment.