Skip to content
Draft
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
36 changes: 34 additions & 2 deletions crates/swc_ecma_ast/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
Accessibility, TsExprWithTypeArgs, TsIndexSignature, TsTypeAnn, TsTypeParamDecl,
TsTypeParamInstantiation,
},
BigInt, ComputedPropName, EmptyStmt, Id, Ident, IdentName, Number,
BigInt, ComputedPropName, EmptyStmt, Id, Ident, IdentName, NodeId, Number,
};

#[ast_node]
Expand All @@ -21,6 +21,9 @@ use crate::{
pub struct Class {
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,

pub ctxt: SyntaxContext,

#[cfg_attr(feature = "serde-impl", serde(default))]
Expand Down Expand Up @@ -99,7 +102,10 @@ pub enum ClassMember {

impl Take for ClassMember {
fn dummy() -> Self {
ClassMember::Empty(EmptyStmt { span: DUMMY_SP })
ClassMember::Empty(EmptyStmt {
span: DUMMY_SP,
node_id: Default::default(),
})
}
}

Expand All @@ -111,6 +117,9 @@ pub struct ClassProp {
#[cfg_attr(feature = "serde-impl", serde(default))]
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,

pub key: PropName,

#[cfg_attr(feature = "serde-impl", serde(default))]
Expand Down Expand Up @@ -169,6 +178,9 @@ pub struct PrivateProp {
#[cfg_attr(feature = "serde-impl", serde(default))]
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub ctxt: SyntaxContext,

Expand Down Expand Up @@ -222,6 +234,9 @@ pub struct PrivateProp {
pub struct ClassMethod {
#[cfg_attr(feature = "serde-impl", serde(default))]
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,
pub key: PropName,
pub function: Box<Function>,
pub kind: MethodKind,
Expand Down Expand Up @@ -250,6 +265,9 @@ pub struct ClassMethod {
pub struct PrivateMethod {
#[cfg_attr(feature = "serde-impl", serde(default))]
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,
pub key: PrivateName,
pub function: Box<Function>,
pub kind: MethodKind,
Expand Down Expand Up @@ -278,6 +296,9 @@ pub struct PrivateMethod {
pub struct Constructor {
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,

pub ctxt: SyntaxContext,

pub key: PropName,
Expand Down Expand Up @@ -309,6 +330,9 @@ pub struct Constructor {
pub struct Decorator {
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,

#[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
pub expr: Box<Expr>,
}
Expand Down Expand Up @@ -344,13 +368,17 @@ pub enum MethodKind {
#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
pub struct StaticBlock {
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,
pub body: BlockStmt,
}

impl Take for StaticBlock {
fn dummy() -> Self {
StaticBlock {
span: DUMMY_SP,
node_id: Default::default(),
body: Take::dummy(),
}
}
Expand Down Expand Up @@ -399,6 +427,9 @@ pub struct AutoAccessor {
#[cfg_attr(feature = "serde-impl", serde(default))]
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,

pub key: Key,

#[cfg_attr(feature = "serde-impl", serde(default))]
Expand Down Expand Up @@ -443,6 +474,7 @@ impl Take for AutoAccessor {
fn dummy() -> AutoAccessor {
AutoAccessor {
span: Take::dummy(),
node_id: Default::default(),
key: Take::dummy(),
value: Take::dummy(),
type_ann: None,
Expand Down
20 changes: 20 additions & 0 deletions crates/swc_ecma_ast/src/decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
ident::Ident,
pat::Pat,
typescript::{TsEnumDecl, TsInterfaceDecl, TsModuleDecl, TsTypeAliasDecl},
NodeId,
};

#[ast_node]
Expand Down Expand Up @@ -99,6 +100,9 @@ impl Take for Decl {
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
pub struct FnDecl {
#[cfg_attr(feature = "serde-impl", serde(skip))]
pub node_id: NodeId,

#[cfg_attr(feature = "serde-impl", serde(rename = "identifier"))]
pub ident: Ident,

Expand All @@ -113,6 +117,7 @@ pub struct FnDecl {
impl Take for FnDecl {
fn dummy() -> Self {
FnDecl {
node_id: Default::default(),
ident: Take::dummy(),
declare: Default::default(),
function: Take::dummy(),
Expand All @@ -125,6 +130,9 @@ impl Take for FnDecl {
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
pub struct ClassDecl {
#[cfg_attr(feature = "serde-impl", serde(skip))]
pub node_id: NodeId,

#[cfg_attr(feature = "serde-impl", serde(rename = "identifier"))]
pub ident: Ident,

Expand All @@ -139,6 +147,7 @@ pub struct ClassDecl {
impl Take for ClassDecl {
fn dummy() -> Self {
ClassDecl {
node_id: Default::default(),
ident: Take::dummy(),
declare: Default::default(),
class: Take::dummy(),
Expand All @@ -153,6 +162,9 @@ impl Take for ClassDecl {
pub struct VarDecl {
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,

pub ctxt: SyntaxContext,

pub kind: VarDeclKind,
Expand Down Expand Up @@ -200,6 +212,9 @@ pub enum VarDeclKind {
#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
pub struct VarDeclarator {
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,
#[cfg_attr(feature = "serde-impl", serde(rename = "id"))]
pub name: Pat,

Expand All @@ -220,6 +235,7 @@ impl Take for VarDeclarator {
fn dummy() -> Self {
VarDeclarator {
span: DUMMY_SP,
node_id: Default::default(),
name: Take::dummy(),
init: Take::dummy(),
definite: Default::default(),
Expand All @@ -235,6 +251,9 @@ pub struct UsingDecl {
#[cfg_attr(feature = "serde-impl", serde(default))]
pub span: Span,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub node_id: NodeId,

#[cfg_attr(feature = "serde-impl", serde(default))]
pub is_await: bool,

Expand All @@ -246,6 +265,7 @@ impl Take for UsingDecl {
fn dummy() -> Self {
Self {
span: DUMMY_SP,
node_id: Default::default(),
is_await: Default::default(),
decls: Take::dummy(),
}
Expand Down
Loading
Loading