fix(ast): do not include scope_id fields in JSON AST (#4858)

Exclude `scope_id` fields from JSON AST (as produced by `oxc-parser` NPM
package). I neglected to flag them `#[serde(skip)]` when I added these
fields.
This commit is contained in:
overlookmotel 2024-08-13 03:23:32 +01:00 committed by GitHub
parent c4354daab5
commit c0b26f4df4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -44,6 +44,7 @@ pub struct Program<'a> {
pub hashbang: Option<Hashbang<'a>>,
pub directives: Vec<'a, Directive<'a>>,
pub body: Vec<'a, Statement<'a>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1187,6 +1188,7 @@ pub struct BlockStatement<'a> {
#[serde(flatten)]
pub span: Span,
pub body: Vec<'a, Statement<'a>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1362,6 +1364,7 @@ pub struct ForStatement<'a> {
pub test: Option<Expression<'a>>,
pub update: Option<Expression<'a>>,
pub body: Statement<'a>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1398,6 +1401,7 @@ pub struct ForInStatement<'a> {
pub left: ForStatementLeft<'a>,
pub right: Expression<'a>,
pub body: Statement<'a>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1434,6 +1438,7 @@ pub struct ForOfStatement<'a> {
pub left: ForStatementLeft<'a>,
pub right: Expression<'a>,
pub body: Statement<'a>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1500,6 +1505,7 @@ pub struct SwitchStatement<'a> {
pub discriminant: Expression<'a>,
#[scope(enter_before)]
pub cases: Vec<'a, SwitchCase<'a>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1567,6 +1573,7 @@ pub struct CatchClause<'a> {
pub span: Span,
pub param: Option<CatchParameter<'a>>,
pub body: Box<'a, BlockStatement<'a>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1735,6 +1742,7 @@ pub struct Function<'a> {
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub body: Option<Box<'a, FunctionBody<'a>>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1832,6 +1840,7 @@ pub struct ArrowFunctionExpression<'a> {
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
/// See `expression` for whether this arrow expression returns an expression.
pub body: Box<'a, FunctionBody<'a>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1919,6 +1928,7 @@ pub struct Class<'a> {
pub declare: bool,
/// Id of the scope created by the [`Class`], including type parameters and
/// statements within the [`ClassBody`].
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -2176,6 +2186,7 @@ pub struct StaticBlock<'a> {
#[serde(flatten)]
pub span: Span,
pub body: Vec<'a, Statement<'a>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}

View file

@ -76,6 +76,7 @@ pub struct TSEnumDeclaration<'a> {
pub members: Vec<'a, TSEnumMember<'a>>,
pub r#const: bool,
pub declare: bool,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -314,6 +315,7 @@ pub struct TSConditionalType<'a> {
pub extends_type: TSType<'a>,
pub true_type: TSType<'a>,
pub false_type: TSType<'a>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -759,6 +761,7 @@ pub struct TSTypeAliasDeclaration<'a> {
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
pub type_annotation: TSType<'a>,
pub declare: bool,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -805,6 +808,7 @@ pub struct TSInterfaceDeclaration<'a> {
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
pub body: Box<'a, TSInterfaceBody<'a>>,
pub declare: bool,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -914,6 +918,7 @@ pub struct TSMethodSignature<'a> {
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -930,6 +935,7 @@ pub struct TSConstructSignatureDeclaration<'a> {
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1007,6 +1013,7 @@ pub struct TSModuleDeclaration<'a> {
/// ```
pub kind: TSModuleDeclarationKind,
pub declare: bool,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}
@ -1205,6 +1212,7 @@ pub struct TSMappedType<'a> {
pub type_annotation: Option<TSType<'a>>,
pub optional: TSMappedTypeModifierOperator,
pub readonly: TSMappedTypeModifierOperator,
#[serde(skip)]
#[clone_in(default)]
pub scope_id: Cell<Option<ScopeId>>,
}