Skip to content

Commit

Permalink
refactor(ast): rename the visited_node marker to ast. (#4289)
Browse files Browse the repository at this point in the history
closes #4282
I went with `#[ast(visit)]` but we can change it to 2 separate markers as suggested by @overlookmotel in the issue.
  • Loading branch information
rzvxa committed Jul 20, 2024
1 parent 7a75e0f commit 5f1c7ec
Show file tree
Hide file tree
Showing 13 changed files with 317 additions and 265 deletions.
236 changes: 118 additions & 118 deletions crates/oxc_ast/src/ast/js.rs

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions crates/oxc_ast/src/ast/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#![allow(non_snake_case)]

use oxc_allocator::{Box, Vec};
use oxc_ast_macros::visited_node;
use oxc_ast_macros::ast;
use oxc_span::{Atom, Span};
#[cfg(feature = "serialize")]
use serde::Serialize;
Expand All @@ -20,7 +20,7 @@ use super::{inherit_variants, js::*, literal::*, ts::*};
// 1.2 JSX Elements

/// JSX Element
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
Expand All @@ -33,7 +33,7 @@ pub struct JSXElement<'a> {
}

/// JSX Opening Element
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
Expand All @@ -47,7 +47,7 @@ pub struct JSXOpeningElement<'a> {
}

/// JSX Closing Element
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -58,7 +58,7 @@ pub struct JSXClosingElement<'a> {
}

/// JSX Fragment
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
Expand Down Expand Up @@ -87,7 +87,7 @@ pub struct JSXClosingFragment {
}

/// JSX Element Name
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(untagged))]
Expand All @@ -101,7 +101,7 @@ pub enum JSXElementName<'a> {
}

/// JSX Namespaced Name
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -113,7 +113,7 @@ pub struct JSXNamespacedName<'a> {
}

/// JSX Member Expression
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -124,7 +124,7 @@ pub struct JSXMemberExpression<'a> {
pub property: JSXIdentifier<'a>,
}

#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(untagged))]
Expand All @@ -133,7 +133,7 @@ pub enum JSXMemberExpressionObject<'a> {
MemberExpression(Box<'a, JSXMemberExpression<'a>>),
}

#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -149,7 +149,7 @@ inherit_variants! {
/// Inherits variants from [`Expression`]. See [`ast` module docs] for explanation of inheritance.
///
/// [`ast` module docs]: `super`
#[visited_node]
#[ast(visit)]
#[repr(C, u8)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
Expand All @@ -161,7 +161,7 @@ pub enum JSXExpression<'a> {
}
}

#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -173,7 +173,7 @@ pub struct JSXEmptyExpression {
// 1.3 JSX Attributes

/// JSX Attributes
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(untagged))]
Expand All @@ -183,7 +183,7 @@ pub enum JSXAttributeItem<'a> {
}

/// JSX Attribute
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -195,7 +195,7 @@ pub struct JSXAttribute<'a> {
}

/// JSX Spread Attribute
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -206,7 +206,7 @@ pub struct JSXSpreadAttribute<'a> {
}

/// JSX Attribute Name
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(untagged))]
Expand All @@ -216,7 +216,7 @@ pub enum JSXAttributeName<'a> {
}

/// JSX Attribute Value
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(untagged))]
Expand All @@ -227,7 +227,7 @@ pub enum JSXAttributeValue<'a> {
Fragment(Box<'a, JSXFragment<'a>>),
}

#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -240,7 +240,7 @@ pub struct JSXIdentifier<'a> {
// 1.4 JSX Children

/// JSX Child
#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(untagged))]
Expand All @@ -252,7 +252,7 @@ pub enum JSXChild<'a> {
Spread(Box<'a, JSXSpreadChild<'a>>),
}

#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -262,7 +262,7 @@ pub struct JSXSpreadChild<'a> {
pub expression: Expression<'a>,
}

#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand Down
14 changes: 7 additions & 7 deletions crates/oxc_ast/src/ast/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
use std::hash::Hash;

use bitflags::bitflags;
use oxc_ast_macros::visited_node;
use oxc_ast_macros::ast;
use oxc_span::{Atom, Span};
use oxc_syntax::number::{BigintBase, NumberBase};
#[cfg(feature = "serialize")]
use serde::Serialize;
#[cfg(feature = "serialize")]
use tsify::Tsify;

#[visited_node]
#[ast(visit)]
#[derive(Debug, Clone, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -28,7 +28,7 @@ pub struct BooleanLiteral {
pub value: bool,
}

#[visited_node]
#[ast(visit)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -37,7 +37,7 @@ pub struct NullLiteral {
pub span: Span,
}

#[visited_node]
#[ast(visit)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -50,7 +50,7 @@ pub struct NumericLiteral<'a> {
pub base: NumberBase,
}

#[visited_node]
#[ast(visit)]
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -62,7 +62,7 @@ pub struct BigIntLiteral<'a> {
pub base: BigintBase,
}

#[visited_node]
#[ast(visit)]
#[derive(Debug, Clone, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand All @@ -86,7 +86,7 @@ pub struct RegExp<'a> {
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
pub struct EmptyObject;

#[visited_node]
#[ast(visit)]
#[derive(Debug, Clone, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
Expand Down
Loading

0 comments on commit 5f1c7ec

Please sign in to comment.