From 1f6b3215ef5fc94e84153365585b1792e3ea4e90 Mon Sep 17 00:00:00 2001 From: Dunqing Date: Sat, 27 Jul 2024 12:23:20 +0800 Subject: [PATCH] feat(ast): add AstKind::TSExprotAssignment --- crates/oxc_ast/src/ast_kind_impl.rs | 1 + crates/oxc_ast/src/generated/ast_kind.rs | 3 +++ crates/oxc_ast/src/generated/visit.rs | 4 +++- crates/oxc_ast/src/generated/visit_mut.rs | 4 +++- .../tests/fixtures/typescript-eslint/export/equals1.snap | 2 +- .../tests/fixtures/typescript-eslint/export/equals4-type.snap | 2 +- tasks/ast_codegen/src/generators/ast_kind.rs | 3 +-- 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/oxc_ast/src/ast_kind_impl.rs b/crates/oxc_ast/src/ast_kind_impl.rs index 7e86afa0f1e0d..53387a051259e 100644 --- a/crates/oxc_ast/src/ast_kind_impl.rs +++ b/crates/oxc_ast/src/ast_kind_impl.rs @@ -381,6 +381,7 @@ impl<'a> AstKind<'a> { Self::TSMappedType(_) => "TSMappedType".into(), Self::TSConstructSignatureDeclaration(_) => "TSConstructSignatureDeclaration".into(), Self::TSModuleReference(_) => "TSModuleReference".into(), + Self::TSExportAssignment(_) => "TSExportAssignment".into(), } } } diff --git a/crates/oxc_ast/src/generated/ast_kind.rs b/crates/oxc_ast/src/generated/ast_kind.rs index c1f2493413200..b3b3d8302c7ea 100644 --- a/crates/oxc_ast/src/generated/ast_kind.rs +++ b/crates/oxc_ast/src/generated/ast_kind.rs @@ -159,6 +159,7 @@ pub enum AstType { TSExternalModuleReference, TSNonNullExpression, Decorator, + TSExportAssignment, TSInstantiationExpression, JSXElement, JSXOpeningElement, @@ -332,6 +333,7 @@ pub enum AstKind<'a> { TSExternalModuleReference(&'a TSExternalModuleReference<'a>), TSNonNullExpression(&'a TSNonNullExpression<'a>), Decorator(&'a Decorator<'a>), + TSExportAssignment(&'a TSExportAssignment<'a>), TSInstantiationExpression(&'a TSInstantiationExpression<'a>), JSXElement(&'a JSXElement<'a>), JSXOpeningElement(&'a JSXOpeningElement<'a>), @@ -506,6 +508,7 @@ impl<'a> GetSpan for AstKind<'a> { Self::TSExternalModuleReference(it) => it.span(), Self::TSNonNullExpression(it) => it.span(), Self::Decorator(it) => it.span(), + Self::TSExportAssignment(it) => it.span(), Self::TSInstantiationExpression(it) => it.span(), Self::JSXElement(it) => it.span(), Self::JSXOpeningElement(it) => it.span(), diff --git a/crates/oxc_ast/src/generated/visit.rs b/crates/oxc_ast/src/generated/visit.rs index 884a98822e7e3..26a5c83a28f2e 100644 --- a/crates/oxc_ast/src/generated/visit.rs +++ b/crates/oxc_ast/src/generated/visit.rs @@ -4207,8 +4207,10 @@ pub mod walk { visitor: &mut V, it: &TSExportAssignment<'a>, ) { - // NOTE: AstKind doesn't exists! + let kind = AstKind::TSExportAssignment(visitor.alloc(it)); + visitor.enter_node(kind); visitor.visit_expression(&it.expression); + visitor.leave_node(kind); } #[inline] diff --git a/crates/oxc_ast/src/generated/visit_mut.rs b/crates/oxc_ast/src/generated/visit_mut.rs index c835e4cb91331..45b7039580421 100644 --- a/crates/oxc_ast/src/generated/visit_mut.rs +++ b/crates/oxc_ast/src/generated/visit_mut.rs @@ -4452,8 +4452,10 @@ pub mod walk_mut { visitor: &mut V, it: &mut TSExportAssignment<'a>, ) { - // NOTE: AstType doesn't exists! + let kind = AstType::TSExportAssignment; + visitor.enter_node(kind); visitor.visit_expression(&mut it.expression); + visitor.leave_node(kind); } #[inline] diff --git a/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals1.snap b/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals1.snap index 89cd91475c47e..0d9e98e4ad634 100644 --- a/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals1.snap +++ b/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals1.snap @@ -19,7 +19,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals1. "flag": "ReferenceFlag(Read)", "id": 0, "name": "x", - "node_id": 6 + "node_id": 7 } ] } diff --git a/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals4-type.snap b/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals4-type.snap index 6b6547d369eb9..58899d4ba4f8b 100644 --- a/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals4-type.snap +++ b/crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals4-type.snap @@ -27,7 +27,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/export/equals4- "flag": "ReferenceFlag(Type)", "id": 0, "name": "T", - "node_id": 10 + "node_id": 11 } ] } diff --git a/tasks/ast_codegen/src/generators/ast_kind.rs b/tasks/ast_codegen/src/generators/ast_kind.rs index 2a014ce944b75..e112853e0aa9c 100644 --- a/tasks/ast_codegen/src/generators/ast_kind.rs +++ b/tasks/ast_codegen/src/generators/ast_kind.rs @@ -11,7 +11,7 @@ use super::generated_header; pub struct AstKindGenerator; -pub const BLACK_LIST: [&str; 62] = [ +pub const BLACK_LIST: [&str; 61] = [ "Expression", "ObjectPropertyKind", "TemplateElement", @@ -62,7 +62,6 @@ pub const BLACK_LIST: [&str; 62] = [ "TSImportAttributeName", "TSFunctionType", "TSConstructorType", - "TSExportAssignment", "TSNamespaceExportDeclaration", "JSDocNullableType", "JSDocNonNullableType",