feat(visit): Derive serde for AstParentKind (#9744)
Some checks are pending
CI / Cargo fmt (push) Waiting to run
CI / Cargo clippy (push) Waiting to run
CI / Check license of dependencies (push) Waiting to run
CI / Check (macos-latest) (push) Waiting to run
CI / Check (ubuntu-latest) (push) Waiting to run
CI / Check (windows-latest) (push) Waiting to run
CI / Test wasm (binding_core_wasm) (push) Waiting to run
CI / Test wasm (binding_minifier_wasm) (push) Waiting to run
CI / Test wasm (binding_typescript_wasm) (push) Waiting to run
CI / List crates (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (push) Blocked by required conditions
CI / Test node bindings - ${{ matrix.os }} (macos-latest) (push) Waiting to run
CI / Test node bindings - ${{ matrix.os }} (windows-latest) (push) Waiting to run
CI / Test with @swc/cli (push) Waiting to run
CI / Miri (better_scoped_tls) (push) Waiting to run
CI / Miri (string_enum) (push) Waiting to run
CI / Miri (swc) (push) Waiting to run
CI / Miri (swc_bundler) (push) Waiting to run
CI / Done (push) Blocked by required conditions
Benchmark / Bench everything (push) Waiting to run
Publish crates (auto) / Publish cargo crates (push) Waiting to run

**Description:**

This is for turbopack.
This commit is contained in:
Donny/강동윤 2024-11-21 20:42:30 +09:00 committed by GitHub
parent 14a5c1ebd2
commit e0fdd68183
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 467 additions and 13 deletions

View File

@ -0,0 +1,8 @@
---
swc_css_visit: patch
swc_html_visit: patch
swc_ecma_visit: patch
swc_xml_visit: patch
---
feat(visit): Derive serde for `AstParentKind`

View File

@ -16,11 +16,12 @@ version = "4.0.0"
bench = false
[features]
default = ["serde"]
path = []
default = ["serde"]
path = []
serde-impl = ["serde"]
[dependencies]
serde = { workspace = true, optional = true }
serde = { workspace = true, optional = true, features = ["derive"] }
swc_atoms = { version = "2.0.0", path = "../swc_atoms" }
swc_common = { version = "4.0.1", path = "../swc_common" }

File diff suppressed because it is too large Load Diff

View File

@ -16,14 +16,15 @@ version = "4.0.0"
bench = false
[features]
debug = []
default = []
path = []
debug = []
default = []
path = []
serde-impl = ["serde"]
[dependencies]
new_debug_unreachable = { workspace = true }
num-bigint = { workspace = true, features = ["serde"] }
serde = { workspace = true, optional = true }
serde = { workspace = true, optional = true, features = ["derive"] }
tracing = { workspace = true }
swc_atoms = { version = "2.0.0", path = "../swc_atoms" }

File diff suppressed because it is too large Load Diff

View File

@ -19,11 +19,12 @@ version = "4.0.0"
bench = false
[features]
default = ["serde"]
path = []
default = ["serde"]
path = []
serde-impl = ["serde"]
[dependencies]
serde = { workspace = true, optional = true }
serde = { workspace = true, optional = true, features = ["derive"] }
swc_atoms = { version = "2.0.0", path = "../swc_atoms" }
swc_common = { version = "4.0.1", path = "../swc_common" }

View File

@ -10833,6 +10833,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum AttributeField {
#[doc = "Represents [`Attribute::span`]"]
Span,
@ -10857,6 +10858,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum AttributeTokenField {
#[doc = "Represents [`AttributeToken::span`]"]
Span,
@ -10876,6 +10878,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum ChildField {
#[doc = "Represents [`Child::DocumentType`]"]
DocumentType,
@ -10894,6 +10897,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum CommentField {
#[doc = "Represents [`Comment::span`]"]
Span,
@ -10914,6 +10918,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum DocumentField {
#[doc = "Represents [`Document::span`]"]
Span,
@ -10934,6 +10939,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum DocumentFragmentField {
#[doc = "Represents [`DocumentFragment::span`]"]
Span,
@ -10947,6 +10953,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum DocumentModeField {
#[doc = "Represents [`DocumentMode::NoQuirks`]"]
NoQuirks,
@ -10963,6 +10970,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum DocumentTypeField {
#[doc = "Represents [`DocumentType::span`]"]
Span,
@ -10991,6 +10999,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum ElementField {
#[doc = "Represents [`Element::span`]"]
Span,
@ -11014,6 +11023,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum NamespaceField {
#[doc = "Represents [`Namespace::HTML`]"]
Html,
@ -11035,6 +11045,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum RawField {
#[doc = "Represents [`Raw::Same`]"]
Same,
@ -11049,6 +11060,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum TextField {
#[doc = "Represents [`Text::span`]"]
Span,
@ -11064,6 +11076,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum TokenField {
#[doc = "Represents [`Token::Doctype`]"]
Doctype,
@ -11086,6 +11099,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum TokenAndSpanField {
#[doc = "Represents [`TokenAndSpan::span`]"]
Span,
@ -11093,6 +11107,7 @@ pub mod fields {
Token,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum AstParentKind {
Attribute(AttributeField),
AttributeToken(AttributeTokenField),

View File

@ -19,11 +19,12 @@ version = "4.0.0"
bench = false
[features]
default = ["serde"]
path = []
default = ["serde"]
path = []
serde-impl = ["serde"]
[dependencies]
serde = { workspace = true, optional = true }
serde = { workspace = true, optional = true, features = ["derive"] }
swc_atoms = { version = "2.0.0", path = "../swc_atoms" }
swc_common = { version = "4.0.1", path = "../swc_common" }

View File

@ -10398,6 +10398,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum AttributeField {
#[doc = "Represents [`Attribute::span`]"]
Span,
@ -10422,6 +10423,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum AttributeTokenField {
#[doc = "Represents [`AttributeToken::span`]"]
Span,
@ -10442,6 +10444,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum CdataSectionField {
#[doc = "Represents [`CdataSection::span`]"]
Span,
@ -10457,6 +10460,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum ChildField {
#[doc = "Represents [`Child::DocumentType`]"]
DocumentType,
@ -10479,6 +10483,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum CommentField {
#[doc = "Represents [`Comment::span`]"]
Span,
@ -10499,6 +10504,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum DocumentField {
#[doc = "Represents [`Document::span`]"]
Span,
@ -10512,6 +10518,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum DocumentModeField {
#[doc = "Represents [`DocumentMode::NoQuirks`]"]
NoQuirks,
@ -10528,6 +10535,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum DocumentTypeField {
#[doc = "Represents [`DocumentType::span`]"]
Span,
@ -10556,6 +10564,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum ElementField {
#[doc = "Represents [`Element::span`]"]
Span,
@ -10573,6 +10582,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum NamespaceField {
#[doc = "Represents [`Namespace::HTML`]"]
Html,
@ -10595,6 +10605,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum ProcessingInstructionField {
#[doc = "Represents [`ProcessingInstruction::span`]"]
Span,
@ -10611,6 +10622,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum TextField {
#[doc = "Represents [`Text::span`]"]
Span,
@ -10626,6 +10638,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum TokenField {
#[doc = "Represents [`Token::Doctype`]"]
Doctype,
@ -10654,6 +10667,7 @@ pub mod fields {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum TokenAndSpanField {
#[doc = "Represents [`TokenAndSpan::span`]"]
Span,
@ -10661,6 +10675,7 @@ pub mod fields {
Token,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum AstParentKind {
Attribute(AttributeField),
AttributeToken(AttributeTokenField),

View File

@ -1530,6 +1530,7 @@ fn define_fields(crate_name: &Ident, node_types: &[&Item]) -> Vec<Item> {
defs.push(parse_quote!(
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum #fields_enum_name {
#(#variants),*
}
@ -1539,6 +1540,7 @@ fn define_fields(crate_name: &Ident, node_types: &[&Item]) -> Vec<Item> {
{
defs.push(parse_quote!(
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum AstParentKind {
#(#kind_enum_members),*
}