From 1abea6c49de9deabdcad863d1ab67927fbdfa790 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Sat, 8 Jul 2023 23:00:00 +0900 Subject: [PATCH] [rust] allow complex types in estree codegen Uses the `syn` crate, which can parse various Rust syntax forms, to parse the `type` field from json schema description. This allows us to describe complex types like `"type": "Vec>"` directly, rather than requiring flags like nullable, plural, and nullable_item. The main flag that i'm keeping is "optional", which is used to indicate when the field itself (not the value) is optional. --- .../crates/estree-codegen/src/codegen.rs | 86 ++++--- .../crates/estree-codegen/src/ecmascript.json | 97 +++----- .../forget/crates/estree/src/generated.rs | 209 +++++++++--------- ...e__tests__fixtures@for-statement.json.snap | 9 - .../estree__tests__fixtures@import.json.snap | 1 - .../estree__tests__fixtures@simple.json.snap | 4 - 6 files changed, 174 insertions(+), 232 deletions(-) diff --git a/compiler/forget/crates/estree-codegen/src/codegen.rs b/compiler/forget/crates/estree-codegen/src/codegen.rs index fdf835670e..e45f003b64 100644 --- a/compiler/forget/crates/estree-codegen/src/codegen.rs +++ b/compiler/forget/crates/estree-codegen/src/codegen.rs @@ -3,6 +3,7 @@ use std::collections::HashSet; use indexmap::IndexMap; use quote::{__private::TokenStream, format_ident, quote}; use serde::{Deserialize, Serialize}; +use syn::Type; /// Returns prettyplease-formatted Rust source for estree pub fn estree() -> String { @@ -15,6 +16,7 @@ pub fn estree() -> String { } #[derive(Serialize, Deserialize, Debug)] +#[serde(deny_unknown_fields)] pub struct Grammar { pub objects: IndexMap, pub nodes: IndexMap, @@ -70,6 +72,7 @@ impl Grammar { } #[derive(Serialize, Deserialize, Debug)] +#[serde(deny_unknown_fields)] pub struct Object { #[serde(default)] pub fields: IndexMap, @@ -94,6 +97,7 @@ impl Object { } #[derive(Serialize, Deserialize, Debug)] +#[serde(deny_unknown_fields)] pub struct Node { #[serde(default)] pub fields: IndexMap, @@ -124,89 +128,65 @@ impl Node { } #[derive(Serialize, Deserialize, Debug)] +#[serde(deny_unknown_fields)] pub struct Field { #[serde(rename = "type")] pub type_: String, - #[serde(default)] - pub nullable: bool, - #[serde(default)] pub optional: bool, - #[serde(default)] - pub plural: bool, - - #[serde(default)] - pub nullable_item: bool, - #[serde(default)] pub flatten: bool, #[serde(default)] pub rename: Option, + + #[serde(default)] + pub skip: bool, } impl Field { pub fn codegen(&self, name: &str) -> TokenStream { let name = format_ident!("{}", name); - let type_name = format_ident!("{}", &self.type_); - let mut type_ = quote!(#type_name); - if self.plural { - if self.nullable_item { - type_ = quote!(Option<#type_>); - } - type_ = quote! { Vec<#type_> }; - } else { - assert_eq!( - self.nullable_item, false, - "Can only set nullable_item if plural" - ) - } - if self.nullable { - type_ = quote!(Option<#type_>); - } - let mut field = quote!(#name: #type_); + let type_name: Type = syn::parse_str(&self.type_) + .unwrap_or_else(|_| panic!("Expected a type name, got `{}`", &self.type_)); + + let type_ = quote!(#type_name); + let mut field = quote!(pub #name: #type_); if self.optional { field = quote! { #[serde(default)] #field } } + if self.flatten { + field = quote! { + #[serde(flatten)] + #field + } + } + if self.skip { + field = quote! { + #[serde(skip)] + #field + } + } if let Some(rename) = &self.rename { field = quote! { #[serde(rename = #rename)] #field } } - if self.flatten { - field = quote! { - #[serde(flatten)] - #field - } - } field } pub fn codegen_node(&self, name: &str) -> TokenStream { let name = format_ident!("{}", name); - let type_name = format_ident!("{}", &self.type_); - let mut type_ = quote!(#type_name); - if self.plural { - if self.nullable_item { - type_ = quote!(Option<#type_>); - } - type_ = quote! { Vec<#type_> }; - } else { - assert_eq!( - self.nullable_item, false, - "Can only set nullable_item if plural" - ) - } - if self.nullable { - type_ = quote!(Option<#type_>); - } - let mut field = quote!(#name: #type_); + let type_name: Type = syn::parse_str(&self.type_) + .unwrap_or_else(|_| panic!("Expected a type name, got `{}`", &self.type_)); + let type_ = quote!(#type_name); + let mut field = quote!(pub #name: #type_); if self.optional { field = quote! { #[serde(default)] @@ -219,6 +199,12 @@ impl Field { #field } } + if self.skip { + field = quote! { + #[serde(skip)] + #field + } + } if let Some(rename) = &self.rename { field = quote! { #[serde(rename = #rename)] @@ -231,6 +217,7 @@ impl Field { #[derive(Serialize, Deserialize, Debug)] #[serde(transparent)] +#[serde(deny_unknown_fields)] pub struct Enum { pub variants: Vec, } @@ -280,6 +267,7 @@ impl Enum { #[derive(Serialize, Deserialize, Debug)] #[serde(transparent)] +#[serde(deny_unknown_fields)] pub struct Operator { pub variants: IndexMap, } diff --git a/compiler/forget/crates/estree-codegen/src/ecmascript.json b/compiler/forget/crates/estree-codegen/src/ecmascript.json index 6249c13ce3..ea8d5284e2 100644 --- a/compiler/forget/crates/estree-codegen/src/ecmascript.json +++ b/compiler/forget/crates/estree-codegen/src/ecmascript.json @@ -3,8 +3,7 @@ "SourceLocation": { "fields": { "source": { - "type": "String", - "nullable": true + "type": "Option" }, "start": { "type": "Position" @@ -27,16 +26,13 @@ "Function": { "fields": { "id": { - "type": "Identifier", - "nullable": true + "type": "Option" }, "params": { - "type": "Pattern", - "plural": true + "type": "Vec" }, "body": { - "type": "FunctionBody", - "nullable": true + "type": "Option" }, "is_generator": { "type": "bool", @@ -68,8 +64,7 @@ "type": "String" }, "binding": { - "type": "Binding", - "nullable": true, + "type": "Option", "optional": true, "skip": true } @@ -81,13 +76,11 @@ "type": "JsValue" }, "raw": { - "type": "String", - "nullable": true, + "type": "Option", "optional": true }, "regex": { - "type": "RegExpValue", - "nullable": true, + "type": "Option", "optional": true } } @@ -95,12 +88,10 @@ "Program": { "fields": { "body": { - "type": "ModuleItem", - "plural": true + "type": "Vec" }, "source_type": { - "type": "SourceType", - "nullable": true, + "type": "Option", "rename": "sourceType" } } @@ -111,8 +102,7 @@ "type": "Expression" }, "directive": { - "type": "String", - "nullable": true, + "type": "Option", "optional": true } } @@ -120,8 +110,7 @@ "BlockStatement": { "fields": { "body": { - "type": "Statement", - "plural": true + "type": "Vec" } } }, @@ -140,8 +129,7 @@ "ReturnStatement": { "fields": { "argument": { - "type": "Expression", - "nullable": true + "type": "Option" } } }, @@ -158,16 +146,14 @@ "BreakStatement": { "fields": { "label": { - "type": "Identifier", - "nullable": true + "type": "Option" } } }, "ContinueStatement": { "fields": { "label": { - "type": "Identifier", - "nullable": true + "type": "Option" } } }, @@ -180,8 +166,7 @@ "type": "Statement" }, "alternate": { - "type": "Statement", - "nullable": true + "type": "Option" } } }, @@ -191,20 +176,17 @@ "type": "Expression" }, "cases": { - "type": "SwitchCase", - "plural": true + "type": "Vec" } } }, "SwitchCase": { "fields": { "test": { - "type": "Expression", - "nullable": true + "type": "Option" }, "consequent": { - "type": "Statement", - "plural": true + "type": "Vec" } } }, @@ -221,12 +203,10 @@ "type": "BlockStatement" }, "handler": { - "type": "CatchClause", - "nullable": true + "type": "Option" }, "finalizer": { - "type": "BlockStatement", - "nullable": true + "type": "Option" } } }, @@ -263,16 +243,13 @@ "ForStatement": { "fields": { "init": { - "type": "ForInit", - "nullable": true + "type": "Option" }, "test": { - "type": "Expression", - "nullable": true + "type": "Option" }, "update": { - "type": "Expression", - "nullable": true + "type": "Option" }, "body": { "type": "Statement" @@ -319,8 +296,7 @@ "type": "VariableDeclarationKind" }, "declarations": { - "type": "VariableDeclarator", - "plural": true + "type": "Vec" } } }, @@ -330,8 +306,7 @@ "type": "Pattern" }, "init": { - "type": "Expression", - "nullable": true + "type": "Option" } } }, @@ -339,17 +314,14 @@ "ArrayExpression": { "fields": { "elements": { - "type": "ExpressionOrSpread", - "plural": true, - "nullable_item": true + "type": "Vec>" } } }, "ObjectExpression": { "fields": { "properties": { - "type": "Property", - "plural": true + "type": "Vec" } } }, @@ -483,8 +455,7 @@ "type": "ExpressionOrSuper" }, "arguments": { - "type": "ExpressionOrSpread", - "plural": true + "type": "Vec" } } }, @@ -494,16 +465,14 @@ "type": "Expression" }, "arguments": { - "type": "ExpressionOrSpread", - "plural": true + "type": "Vec" } } }, "SequenceExpression": { "fields": { "expressions": { - "type": "Expression", - "plural": true + "type": "Vec" } } }, @@ -518,8 +487,7 @@ "YieldExpression": { "fields": { "argument": { - "type": "Expression", - "nullable": true, + "type": "Option", "optional": true }, "is_delegate": { @@ -531,8 +499,7 @@ "ImportDeclaration": { "fields": { "specifiers": { - "type": "ImportDeclarationSpecifier", - "plural": true + "type": "Vec" }, "source": { "type": "Literal" diff --git a/compiler/forget/crates/estree/src/generated.rs b/compiler/forget/crates/estree/src/generated.rs index b86ba0dc88..41abb8efe2 100644 --- a/compiler/forget/crates/estree/src/generated.rs +++ b/compiler/forget/crates/estree/src/generated.rs @@ -3,37 +3,38 @@ use serde::{Serialize, Deserialize}; use crate::{JsValue, Binding, SourceRange}; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct SourceLocation { - source: Option, - start: Position, - end: Position, + pub source: Option, + pub start: Position, + pub end: Position, } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Position { - line: NonZeroU32, - column: u32, + pub line: NonZeroU32, + pub column: u32, } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Function { - id: Option, - params: Vec, - body: Option, + pub id: Option, + pub params: Vec, + pub body: Option, #[serde(rename = "generator")] #[serde(default)] - is_generator: bool, + pub is_generator: bool, #[serde(rename = "async")] #[serde(default)] - is_async: bool, + pub is_async: bool, } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct RegExpValue { - pattern: String, - flags: String, + pub pattern: String, + pub flags: String, } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Identifier { - name: String, + pub name: String, + #[serde(skip)] #[serde(default)] - binding: Option, + pub binding: Option, #[serde(default)] pub loc: Option, #[serde(default)] @@ -41,11 +42,11 @@ pub struct Identifier { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Literal { - value: JsValue, + pub value: JsValue, #[serde(default)] - raw: Option, + pub raw: Option, #[serde(default)] - regex: Option, + pub regex: Option, #[serde(default)] pub loc: Option, #[serde(default)] @@ -53,9 +54,9 @@ pub struct Literal { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Program { - body: Vec, + pub body: Vec, #[serde(rename = "sourceType")] - source_type: Option, + pub source_type: Option, #[serde(default)] pub loc: Option, #[serde(default)] @@ -63,9 +64,9 @@ pub struct Program { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ExpressionStatement { - expression: Expression, + pub expression: Expression, #[serde(default)] - directive: Option, + pub directive: Option, #[serde(default)] pub loc: Option, #[serde(default)] @@ -73,7 +74,7 @@ pub struct ExpressionStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct BlockStatement { - body: Vec, + pub body: Vec, #[serde(default)] pub loc: Option, #[serde(default)] @@ -95,8 +96,8 @@ pub struct DebuggerStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct WithStatement { - object: Expression, - body: Statement, + pub object: Expression, + pub body: Statement, #[serde(default)] pub loc: Option, #[serde(default)] @@ -104,7 +105,7 @@ pub struct WithStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ReturnStatement { - argument: Option, + pub argument: Option, #[serde(default)] pub loc: Option, #[serde(default)] @@ -112,8 +113,8 @@ pub struct ReturnStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct LabeledStatement { - label: Identifier, - body: Statement, + pub label: Identifier, + pub body: Statement, #[serde(default)] pub loc: Option, #[serde(default)] @@ -121,7 +122,7 @@ pub struct LabeledStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct BreakStatement { - label: Option, + pub label: Option, #[serde(default)] pub loc: Option, #[serde(default)] @@ -129,7 +130,7 @@ pub struct BreakStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ContinueStatement { - label: Option, + pub label: Option, #[serde(default)] pub loc: Option, #[serde(default)] @@ -137,9 +138,9 @@ pub struct ContinueStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct IfStatement { - test: Expression, - consequent: Statement, - alternate: Option, + pub test: Expression, + pub consequent: Statement, + pub alternate: Option, #[serde(default)] pub loc: Option, #[serde(default)] @@ -147,8 +148,8 @@ pub struct IfStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct SwitchStatement { - discriminant: Expression, - cases: Vec, + pub discriminant: Expression, + pub cases: Vec, #[serde(default)] pub loc: Option, #[serde(default)] @@ -156,8 +157,8 @@ pub struct SwitchStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct SwitchCase { - test: Option, - consequent: Vec, + pub test: Option, + pub consequent: Vec, #[serde(default)] pub loc: Option, #[serde(default)] @@ -165,7 +166,7 @@ pub struct SwitchCase { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ThrowStatement { - argument: Expression, + pub argument: Expression, #[serde(default)] pub loc: Option, #[serde(default)] @@ -173,9 +174,9 @@ pub struct ThrowStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct TryStatement { - block: BlockStatement, - handler: Option, - finalizer: Option, + pub block: BlockStatement, + pub handler: Option, + pub finalizer: Option, #[serde(default)] pub loc: Option, #[serde(default)] @@ -183,8 +184,8 @@ pub struct TryStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct CatchClause { - param: Pattern, - body: BlockStatement, + pub param: Pattern, + pub body: BlockStatement, #[serde(default)] pub loc: Option, #[serde(default)] @@ -192,8 +193,8 @@ pub struct CatchClause { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct WhileStatement { - test: Expression, - body: Statement, + pub test: Expression, + pub body: Statement, #[serde(default)] pub loc: Option, #[serde(default)] @@ -201,8 +202,8 @@ pub struct WhileStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct DoWhileStatement { - body: Statement, - test: Expression, + pub body: Statement, + pub test: Expression, #[serde(default)] pub loc: Option, #[serde(default)] @@ -210,10 +211,10 @@ pub struct DoWhileStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ForStatement { - init: Option, - test: Option, - update: Option, - body: Statement, + pub init: Option, + pub test: Option, + pub update: Option, + pub body: Statement, #[serde(default)] pub loc: Option, #[serde(default)] @@ -221,9 +222,9 @@ pub struct ForStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ForInStatement { - left: ForInInit, - right: Expression, - body: Statement, + pub left: ForInInit, + pub right: Expression, + pub body: Statement, #[serde(default)] pub loc: Option, #[serde(default)] @@ -231,9 +232,9 @@ pub struct ForInStatement { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ForOfStatement { - left: ForInInit, - right: Expression, - body: Statement, + pub left: ForInInit, + pub right: Expression, + pub body: Statement, #[serde(default)] pub loc: Option, #[serde(default)] @@ -242,7 +243,7 @@ pub struct ForOfStatement { #[derive(Serialize, Deserialize, Clone, Debug)] pub struct FunctionDeclaration { #[serde(flatten)] - function: Function, + pub function: Function, #[serde(default)] pub loc: Option, #[serde(default)] @@ -250,8 +251,8 @@ pub struct FunctionDeclaration { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct VariableDeclaration { - kind: VariableDeclarationKind, - declarations: Vec, + pub kind: VariableDeclarationKind, + pub declarations: Vec, #[serde(default)] pub loc: Option, #[serde(default)] @@ -259,8 +260,8 @@ pub struct VariableDeclaration { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct VariableDeclarator { - id: Pattern, - init: Option, + pub id: Pattern, + pub init: Option, #[serde(default)] pub loc: Option, #[serde(default)] @@ -275,7 +276,7 @@ pub struct ThisExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ArrayExpression { - elements: Vec>, + pub elements: Vec>, #[serde(default)] pub loc: Option, #[serde(default)] @@ -283,7 +284,7 @@ pub struct ArrayExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ObjectExpression { - properties: Vec, + pub properties: Vec, #[serde(default)] pub loc: Option, #[serde(default)] @@ -291,9 +292,9 @@ pub struct ObjectExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Property { - key: PropertyKey, - value: Expression, - kind: PropertyKind, + pub key: PropertyKey, + pub value: Expression, + pub kind: PropertyKind, #[serde(default)] pub loc: Option, #[serde(default)] @@ -302,7 +303,7 @@ pub struct Property { #[derive(Serialize, Deserialize, Clone, Debug)] pub struct FunctionExpression { #[serde(flatten)] - function: Function, + pub function: Function, #[serde(default)] pub loc: Option, #[serde(default)] @@ -311,9 +312,9 @@ pub struct FunctionExpression { #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ArrowFunctionExpression { #[serde(flatten)] - function: Function, + pub function: Function, #[serde(rename = "expression")] - is_expression: bool, + pub is_expression: bool, #[serde(default)] pub loc: Option, #[serde(default)] @@ -321,9 +322,9 @@ pub struct ArrowFunctionExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct UnaryExpression { - operator: UnaryOperator, - prefix: bool, - argument: Expression, + pub operator: UnaryOperator, + pub prefix: bool, + pub argument: Expression, #[serde(default)] pub loc: Option, #[serde(default)] @@ -331,9 +332,9 @@ pub struct UnaryExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct UpdateExpression { - operator: UpdateOperator, - argument: Expression, - prefix: bool, + pub operator: UpdateOperator, + pub argument: Expression, + pub prefix: bool, #[serde(default)] pub loc: Option, #[serde(default)] @@ -341,9 +342,9 @@ pub struct UpdateExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct BinaryExpression { - left: Expression, - operator: BinaryOperator, - right: Expression, + pub left: Expression, + pub operator: BinaryOperator, + pub right: Expression, #[serde(default)] pub loc: Option, #[serde(default)] @@ -351,9 +352,9 @@ pub struct BinaryExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct AssignmentExpression { - operator: AssignmentOperator, - left: AssignmentTarget, - right: Expression, + pub operator: AssignmentOperator, + pub left: AssignmentTarget, + pub right: Expression, #[serde(default)] pub loc: Option, #[serde(default)] @@ -361,9 +362,9 @@ pub struct AssignmentExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct LogicalExpression { - operator: LogicalOperator, - left: Expression, - right: Expression, + pub operator: LogicalOperator, + pub left: Expression, + pub right: Expression, #[serde(default)] pub loc: Option, #[serde(default)] @@ -371,9 +372,9 @@ pub struct LogicalExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct MemberExpression { - object: ExpressionOrSuper, - property: Expression, - computed: bool, + pub object: ExpressionOrSuper, + pub property: Expression, + pub computed: bool, #[serde(default)] pub loc: Option, #[serde(default)] @@ -381,9 +382,9 @@ pub struct MemberExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ConditionalExpression { - test: Expression, - alternate: Expression, - consequent: Expression, + pub test: Expression, + pub alternate: Expression, + pub consequent: Expression, #[serde(default)] pub loc: Option, #[serde(default)] @@ -391,8 +392,8 @@ pub struct ConditionalExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct CallExpression { - callee: ExpressionOrSuper, - arguments: Vec, + pub callee: ExpressionOrSuper, + pub arguments: Vec, #[serde(default)] pub loc: Option, #[serde(default)] @@ -400,8 +401,8 @@ pub struct CallExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct NewExpression { - callee: Expression, - arguments: Vec, + pub callee: Expression, + pub arguments: Vec, #[serde(default)] pub loc: Option, #[serde(default)] @@ -409,7 +410,7 @@ pub struct NewExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct SequenceExpression { - expressions: Vec, + pub expressions: Vec, #[serde(default)] pub loc: Option, #[serde(default)] @@ -424,7 +425,7 @@ pub struct Super { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct SpreadElement { - argument: Expression, + pub argument: Expression, #[serde(default)] pub loc: Option, #[serde(default)] @@ -433,9 +434,9 @@ pub struct SpreadElement { #[derive(Serialize, Deserialize, Clone, Debug)] pub struct YieldExpression { #[serde(default)] - argument: Option, + pub argument: Option, #[serde(rename = "delegate")] - is_delegate: bool, + pub is_delegate: bool, #[serde(default)] pub loc: Option, #[serde(default)] @@ -443,8 +444,8 @@ pub struct YieldExpression { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ImportDeclaration { - specifiers: Vec, - source: Literal, + pub specifiers: Vec, + pub source: Literal, #[serde(default)] pub loc: Option, #[serde(default)] @@ -452,8 +453,8 @@ pub struct ImportDeclaration { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ImportSpecifier { - imported: Identifier, - local: Identifier, + pub imported: Identifier, + pub local: Identifier, #[serde(default)] pub loc: Option, #[serde(default)] @@ -461,7 +462,7 @@ pub struct ImportSpecifier { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ImportDefaultSpecifier { - local: Identifier, + pub local: Identifier, #[serde(default)] pub loc: Option, #[serde(default)] @@ -469,7 +470,7 @@ pub struct ImportDefaultSpecifier { } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ImportNamespaceSpecifier { - local: Identifier, + pub local: Identifier, #[serde(default)] pub loc: Option, #[serde(default)] diff --git a/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@for-statement.json.snap b/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@for-statement.json.snap index fa6efd4016..b403a9bb68 100644 --- a/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@for-statement.json.snap +++ b/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@for-statement.json.snap @@ -540,7 +540,6 @@ Output: "type": "FunctionDeclaration", "id": { "name": "Component", - "binding": null, "loc": { "source": null, "start": { @@ -561,7 +560,6 @@ Output: { "type": "Identifier", "name": "props", - "binding": null, "loc": { "source": null, "start": { @@ -589,7 +587,6 @@ Output: "id": { "type": "Identifier", "name": "x", - "binding": null, "loc": { "source": null, "start": { @@ -671,7 +668,6 @@ Output: "id": { "type": "Identifier", "name": "i", - "binding": null, "loc": { "source": null, "start": { @@ -749,7 +745,6 @@ Output: "left": { "type": "Identifier", "name": "i", - "binding": null, "loc": { "source": null, "start": { @@ -812,7 +807,6 @@ Output: "argument": { "type": "Identifier", "name": "i", - "binding": null, "loc": { "source": null, "start": { @@ -857,7 +851,6 @@ Output: "left": { "type": "Identifier", "name": "x", - "binding": null, "loc": { "source": null, "start": { @@ -877,7 +870,6 @@ Output: "right": { "type": "Identifier", "name": "i", - "binding": null, "loc": { "source": null, "start": { @@ -965,7 +957,6 @@ Output: "argument": { "type": "Identifier", "name": "x", - "binding": null, "loc": { "source": null, "start": { diff --git a/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@import.json.snap b/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@import.json.snap index ca13c3bb80..8e895be675 100644 --- a/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@import.json.snap +++ b/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@import.json.snap @@ -119,7 +119,6 @@ Output: "type": "ImportDefaultSpecifier", "local": { "name": "React", - "binding": null, "loc": { "source": null, "start": { diff --git a/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@simple.json.snap b/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@simple.json.snap index d00101d707..85cb9a74bb 100644 --- a/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@simple.json.snap +++ b/compiler/forget/crates/estree/src/snapshots/estree__tests__fixtures@simple.json.snap @@ -201,7 +201,6 @@ Output: "type": "FunctionDeclaration", "id": { "name": "Component", - "binding": null, "loc": { "source": null, "start": { @@ -222,7 +221,6 @@ Output: { "type": "Identifier", "name": "props", - "binding": null, "loc": { "source": null, "start": { @@ -249,7 +247,6 @@ Output: "object": { "type": "Identifier", "name": "props", - "binding": null, "loc": { "source": null, "start": { @@ -269,7 +266,6 @@ Output: "property": { "type": "Identifier", "name": "value", - "binding": null, "loc": { "source": null, "start": {