From a2be3bd227d71dd266be9e29cacc8fc9776344b4 Mon Sep 17 00:00:00 2001 From: Boshen Date: Fri, 5 May 2023 21:55:44 +0800 Subject: [PATCH] refactor(ast): remove unnecessary `ModuleDeclarationKind` --- crates/oxc_ast/src/ast/js.rs | 22 +++-- crates/oxc_ast/src/ast_builder.rs | 16 ++-- crates/oxc_ast/src/ast_kind.rs | 2 +- crates/oxc_ast/src/lib.rs | 2 +- crates/oxc_ast/src/span.rs | 15 +++- .../oxc_ast/src/syntax_directed_operations.rs | 2 +- crates/oxc_ast/src/visit.rs | 14 ++-- crates/oxc_ast/src/visit_mut.rs | 14 ++-- crates/oxc_parser/src/js/module.rs | 83 ++++++++++++------- crates/oxc_printer/src/gen.rs | 6 -- crates/oxc_semantic/src/builder.rs | 2 +- crates/oxc_semantic/src/checker/javascript.rs | 18 ++-- .../oxc_semantic/src/module_record/builder.rs | 14 ++-- 13 files changed, 119 insertions(+), 91 deletions(-) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index e899fe468..d15604214 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1604,19 +1604,9 @@ pub struct StaticBlock<'a> { pub body: Vec<'a, Statement<'a>>, } -/// Imports -#[derive(Debug, PartialEq, Hash)] -#[cfg_attr(feature = "serde", derive(Serialize))] -pub struct ModuleDeclaration<'a> { - #[cfg_attr(feature = "serde", serde(flatten))] - pub span: Span, - #[cfg_attr(feature = "serde", serde(flatten))] - pub kind: ModuleDeclarationKind<'a>, -} - #[derive(Debug, PartialEq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(untagged))] -pub enum ModuleDeclarationKind<'a> { +pub enum ModuleDeclaration<'a> { ImportDeclaration(Box<'a, ImportDeclaration<'a>>), ExportAllDeclaration(Box<'a, ExportAllDeclaration<'a>>), ExportDefaultDeclaration(Box<'a, ExportDefaultDeclaration<'a>>), @@ -1626,7 +1616,7 @@ pub enum ModuleDeclarationKind<'a> { TSNamespaceExportDeclaration(Box<'a, TSNamespaceExportDeclaration>), } -impl<'a> ModuleDeclarationKind<'a> { +impl<'a> ModuleDeclaration<'a> { #[must_use] pub fn is_export(&self) -> bool { matches!( @@ -1663,6 +1653,8 @@ pub struct ImportExpression<'a> { #[derive(Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))] pub struct ImportDeclaration<'a> { + #[cfg_attr(feature = "serde", serde(flatten))] + pub span: Span, pub specifiers: Vec<'a, ImportDeclarationSpecifier>, pub source: StringLiteral, pub assertions: Option>, // Some(vec![]) for empty assertion @@ -1735,6 +1727,8 @@ impl ImportAttributeKey { #[derive(Debug, PartialEq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))] pub struct ExportNamedDeclaration<'a> { + #[cfg_attr(feature = "serde", serde(flatten))] + pub span: Span, pub declaration: Option>, pub specifiers: Vec<'a, ExportSpecifier>, pub source: Option, @@ -1752,6 +1746,8 @@ impl<'a> ExportNamedDeclaration<'a> { #[derive(Debug, PartialEq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))] pub struct ExportDefaultDeclaration<'a> { + #[cfg_attr(feature = "serde", serde(flatten))] + pub span: Span, pub declaration: ExportDefaultDeclarationKind<'a>, pub exported: ModuleExportName, // `default` } @@ -1759,6 +1755,8 @@ pub struct ExportDefaultDeclaration<'a> { #[derive(Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))] pub struct ExportAllDeclaration<'a> { + #[cfg_attr(feature = "serde", serde(flatten))] + pub span: Span, pub exported: Option, pub source: StringLiteral, pub assertions: Option>, // Some(vec![]) for empty assertion diff --git a/crates/oxc_ast/src/ast_builder.rs b/crates/oxc_ast/src/ast_builder.rs index dd7d60e16..85a3deb97 100644 --- a/crates/oxc_ast/src/ast_builder.rs +++ b/crates/oxc_ast/src/ast_builder.rs @@ -783,46 +783,50 @@ impl<'a> AstBuilder<'a> { /* ---------- Modules ---------- */ - pub fn module_declaration(&self, span: Span, kind: ModuleDeclarationKind<'a>) -> Statement<'a> { - Statement::ModuleDeclaration(self.alloc(ModuleDeclaration { span, kind })) + pub fn module_declaration(&self, decl: ModuleDeclaration<'a>) -> Statement<'a> { + Statement::ModuleDeclaration(self.alloc(decl)) } pub fn import_declaration( &self, + span: Span, specifiers: Vec<'a, ImportDeclarationSpecifier>, source: StringLiteral, assertions: Option>, import_kind: Option, ) -> Box<'a, ImportDeclaration<'a>> { - self.alloc(ImportDeclaration { specifiers, source, assertions, import_kind }) + self.alloc(ImportDeclaration { span, specifiers, source, assertions, import_kind }) } pub fn export_all_declaration( &self, + span: Span, exported: Option, source: StringLiteral, assertions: Option>, // Some(vec![]) for empty assertion export_kind: Option, ) -> Box<'a, ExportAllDeclaration<'a>> { - self.alloc(ExportAllDeclaration { exported, source, assertions, export_kind }) + self.alloc(ExportAllDeclaration { span, exported, source, assertions, export_kind }) } pub fn export_default_declaration( &self, + span: Span, declaration: ExportDefaultDeclarationKind<'a>, exported: ModuleExportName, ) -> Box<'a, ExportDefaultDeclaration<'a>> { - self.alloc(ExportDefaultDeclaration { declaration, exported }) + self.alloc(ExportDefaultDeclaration { span, declaration, exported }) } pub fn export_named_declaration( &self, + span: Span, declaration: Option>, specifiers: Vec<'a, ExportSpecifier>, source: Option, export_kind: Option, // `export type { foo }` ) -> Box<'a, ExportNamedDeclaration<'a>> { - self.alloc(ExportNamedDeclaration { declaration, specifiers, source, export_kind }) + self.alloc(ExportNamedDeclaration { span, declaration, specifiers, source, export_kind }) } /* ---------- JSX ----------------- */ diff --git a/crates/oxc_ast/src/ast_kind.rs b/crates/oxc_ast/src/ast_kind.rs index 487143564..8bae37d57 100644 --- a/crates/oxc_ast/src/ast_kind.rs +++ b/crates/oxc_ast/src/ast_kind.rs @@ -336,7 +336,7 @@ impl<'a> GetSpan for AstKind<'a> { Self::Decorator(x) => x.span, - Self::ModuleDeclaration(x) => x.span, + Self::ModuleDeclaration(x) => x.span(), Self::JSXOpeningElement(x) => x.span, Self::JSXElementName(x) => x.span(), diff --git a/crates/oxc_ast/src/lib.rs b/crates/oxc_ast/src/lib.rs index 8f01b4167..afb375121 100644 --- a/crates/oxc_ast/src/lib.rs +++ b/crates/oxc_ast/src/lib.rs @@ -65,7 +65,7 @@ fn no_bloat_enum_sizes() { assert_eq!(size_of::(), 16); assert_eq!(size_of::(), 16); assert_eq!(size_of::(), 16); - assert_eq!(size_of::(), 16); + assert_eq!(size_of::(), 16); assert_eq!(size_of::(), 16); assert_eq!(size_of::(), 16); assert_eq!(size_of::(), 16); diff --git a/crates/oxc_ast/src/span.rs b/crates/oxc_ast/src/span.rs index b4fcc0a2a..5918cca91 100644 --- a/crates/oxc_ast/src/span.rs +++ b/crates/oxc_ast/src/span.rs @@ -24,7 +24,7 @@ impl<'a> GetSpan for Statement<'a> { Self::TryStatement(stmt) => stmt.span, Self::WhileStatement(stmt) => stmt.span, Self::WithStatement(stmt) => stmt.span, - Self::ModuleDeclaration(decl) => decl.span, + Self::ModuleDeclaration(decl) => decl.span(), Self::Declaration(decl) => decl.span(), } } @@ -153,6 +153,19 @@ impl GetSpan for ModuleExportName { } } +impl<'a> GetSpan for ModuleDeclaration<'a> { + fn span(&self) -> Span { + match self { + Self::ImportDeclaration(decl) => decl.span, + Self::ExportAllDeclaration(decl) => decl.span, + Self::ExportDefaultDeclaration(decl) => decl.span, + Self::ExportNamedDeclaration(decl) => decl.span, + Self::TSExportAssignment(decl) => decl.span, + Self::TSNamespaceExportDeclaration(decl) => decl.span, + } + } +} + impl<'a> GetSpan for Declaration<'a> { fn span(&self) -> Span { match self { diff --git a/crates/oxc_ast/src/syntax_directed_operations.rs b/crates/oxc_ast/src/syntax_directed_operations.rs index 5e08a9d81..4c9e49f58 100644 --- a/crates/oxc_ast/src/syntax_directed_operations.rs +++ b/crates/oxc_ast/src/syntax_directed_operations.rs @@ -130,7 +130,7 @@ impl<'a> BoundNames for FormalParameter<'a> { impl<'a> BoundNames for ModuleDeclaration<'a> { fn bound_names(&self, f: &mut F) { - if let ModuleDeclarationKind::ImportDeclaration(decl) = &self.kind { + if let ModuleDeclaration::ImportDeclaration(decl) = &self { decl.bound_names(f); } } diff --git a/crates/oxc_ast/src/visit.rs b/crates/oxc_ast/src/visit.rs index 115800708..05972f68a 100644 --- a/crates/oxc_ast/src/visit.rs +++ b/crates/oxc_ast/src/visit.rs @@ -1147,23 +1147,23 @@ pub trait Visit<'a>: Sized { fn visit_module_declaration(&mut self, decl: &'a ModuleDeclaration<'a>) { let kind = AstKind::ModuleDeclaration(decl); self.enter_node(kind); - match &decl.kind { - ModuleDeclarationKind::ImportDeclaration(decl) => { + match decl { + ModuleDeclaration::ImportDeclaration(decl) => { self.visit_import_declaration(decl); } - ModuleDeclarationKind::ExportAllDeclaration(decl) => { + ModuleDeclaration::ExportAllDeclaration(decl) => { self.visit_export_all_declaration(decl); } - ModuleDeclarationKind::ExportDefaultDeclaration(decl) => { + ModuleDeclaration::ExportDefaultDeclaration(decl) => { self.visit_export_default_declaration(decl); } - ModuleDeclarationKind::ExportNamedDeclaration(decl) => { + ModuleDeclaration::ExportNamedDeclaration(decl) => { self.visit_export_named_declaration(decl); } - ModuleDeclarationKind::TSExportAssignment(decl) => { + ModuleDeclaration::TSExportAssignment(decl) => { self.visit_expression(&decl.expression); } - ModuleDeclarationKind::TSNamespaceExportDeclaration(_) => {} + ModuleDeclaration::TSNamespaceExportDeclaration(_) => {} } self.leave_node(kind); } diff --git a/crates/oxc_ast/src/visit_mut.rs b/crates/oxc_ast/src/visit_mut.rs index 3a700c040..af86bf504 100644 --- a/crates/oxc_ast/src/visit_mut.rs +++ b/crates/oxc_ast/src/visit_mut.rs @@ -865,23 +865,23 @@ pub trait VisitMut<'a, 'b>: Sized { /* ---------- Module ---------- */ fn visit_module_declaration(&mut self, decl: &'b mut ModuleDeclaration<'a>) { - match &mut decl.kind { - ModuleDeclarationKind::ImportDeclaration(decl) => { + match decl { + ModuleDeclaration::ImportDeclaration(decl) => { self.visit_import_declaration(decl); } - ModuleDeclarationKind::ExportAllDeclaration(decl) => { + ModuleDeclaration::ExportAllDeclaration(decl) => { self.visit_export_all_declaration(decl); } - ModuleDeclarationKind::ExportDefaultDeclaration(decl) => { + ModuleDeclaration::ExportDefaultDeclaration(decl) => { self.visit_export_default_declaration(decl); } - ModuleDeclarationKind::ExportNamedDeclaration(decl) => { + ModuleDeclaration::ExportNamedDeclaration(decl) => { self.visit_export_named_declaration(decl); } - ModuleDeclarationKind::TSExportAssignment(decl) => { + ModuleDeclaration::TSExportAssignment(decl) => { self.visit_expression(&mut decl.expression); } - ModuleDeclarationKind::TSNamespaceExportDeclaration(_) => {} + ModuleDeclaration::TSNamespaceExportDeclaration(_) => {} } } diff --git a/crates/oxc_parser/src/js/module.rs b/crates/oxc_parser/src/js/module.rs index 3c4bbcc3d..6e90f0feb 100644 --- a/crates/oxc_parser/src/js/module.rs +++ b/crates/oxc_parser/src/js/module.rs @@ -58,16 +58,15 @@ impl<'a> Parser<'a> { let source = self.parse_literal_string()?; let assertions = self.parse_import_attributes()?; self.asi()?; - let span = self.end_span(span); - let kind = ModuleDeclarationKind::ImportDeclaration(self.ast.import_declaration( + let decl = ModuleDeclaration::ImportDeclaration(self.ast.import_declaration( + span, specifiers, source, assertions, import_kind, )); - - Ok(self.ast.module_declaration(span, kind)) + Ok(self.ast.module_declaration(decl)) } // Full Syntax: @@ -176,36 +175,36 @@ impl<'a> Parser<'a> { /// [Exports](https://tc39.es/ecma262/#sec-exports) pub(crate) fn parse_export_declaration(&mut self) -> Result> { - let start_span = self.start_span(); + let span = self.start_span(); self.bump_any(); // advance `export` - let kind = match self.cur_kind() { + let decl = match self.cur_kind() { Kind::Eq if self.ts_enabled() => self .parse_ts_export_assignment_declaration() - .map(ModuleDeclarationKind::TSExportAssignment), + .map(ModuleDeclaration::TSExportAssignment), Kind::As if self.peek_at(Kind::Namespace) && self.ts_enabled() => self .parse_ts_export_namespace() - .map(ModuleDeclarationKind::TSNamespaceExportDeclaration), + .map(ModuleDeclaration::TSNamespaceExportDeclaration), Kind::Default => self - .parse_export_default_declaration() - .map(ModuleDeclarationKind::ExportDefaultDeclaration), + .parse_export_default_declaration(span) + .map(ModuleDeclaration::ExportDefaultDeclaration), Kind::Star => { - self.parse_export_all_declaration().map(ModuleDeclarationKind::ExportAllDeclaration) + self.parse_export_all_declaration(span).map(ModuleDeclaration::ExportAllDeclaration) } Kind::LCurly => self - .parse_export_named_specifiers() - .map(ModuleDeclarationKind::ExportNamedDeclaration), + .parse_export_named_specifiers(span) + .map(ModuleDeclaration::ExportNamedDeclaration), Kind::Type if self.peek_at(Kind::LCurly) && self.ts_enabled() => self - .parse_export_named_specifiers() - .map(ModuleDeclarationKind::ExportNamedDeclaration), + .parse_export_named_specifiers(span) + .map(ModuleDeclaration::ExportNamedDeclaration), Kind::Type if self.peek_at(Kind::Star) => { - self.parse_export_all_declaration().map(ModuleDeclarationKind::ExportAllDeclaration) + self.parse_export_all_declaration(span).map(ModuleDeclaration::ExportAllDeclaration) } _ => self - .parse_export_named_declaration() - .map(ModuleDeclarationKind::ExportNamedDeclaration), + .parse_export_named_declaration(span) + .map(ModuleDeclaration::ExportNamedDeclaration), }?; - Ok(self.ast.module_declaration(self.end_span(start_span), kind)) + Ok(self.ast.module_declaration(decl)) } // export NamedExports ; @@ -219,7 +218,10 @@ impl<'a> Parser<'a> { // ExportSpecifier : // ModuleExportName // ModuleExportName as ModuleExportName - fn parse_export_named_specifiers(&mut self) -> Result>> { + fn parse_export_named_specifiers( + &mut self, + span: Span, + ) -> Result>> { let export_kind = self.parse_import_or_export_kind(); let ctx = self.ctx; @@ -249,12 +251,16 @@ impl<'a> Parser<'a> { } self.asi()?; - Ok(self.ast.export_named_declaration(None, specifiers, source, export_kind)) + let span = self.end_span(span); + Ok(self.ast.export_named_declaration(span, None, specifiers, source, export_kind)) } // export Declaration - fn parse_export_named_declaration(&mut self) -> Result>> { - let start_span = self.start_span(); + fn parse_export_named_declaration( + &mut self, + span: Span, + ) -> Result>> { + let decl_span = self.start_span(); // For tc39/proposal-decorators // For more information, please refer to self.eat_decorators()?; @@ -264,8 +270,15 @@ impl<'a> Parser<'a> { Modifiers::empty() }; - let declaration = self.parse_declaration(start_span, modifiers)?; - Ok(self.ast.export_named_declaration(Some(declaration), self.ast.new_vec(), None, None)) + let declaration = self.parse_declaration(decl_span, modifiers)?; + let span = self.end_span(span); + Ok(self.ast.export_named_declaration( + span, + Some(declaration), + self.ast.new_vec(), + None, + None, + )) } // export default HoistableDeclaration[~Yield, +Await, +Default] @@ -273,27 +286,28 @@ impl<'a> Parser<'a> { // export default AssignmentExpression[+In, ~Yield, +Await] ; fn parse_export_default_declaration( &mut self, + span: Span, ) -> Result>> { let exported = self.parse_keyword_identifier(Kind::Default); - let start_span = self.start_span(); + let decl_span = self.start_span(); // For tc39/proposal-decorators // For more information, please refer to self.eat_decorators()?; let declaration = match self.cur_kind() { Kind::Class => self - .parse_class_declaration(start_span, /* modifiers */ Modifiers::empty()) + .parse_class_declaration(decl_span, /* modifiers */ Modifiers::empty()) .map(ExportDefaultDeclarationKind::ClassDeclaration)?, _ if self.at(Kind::Abstract) && self.peek_at(Kind::Class) && self.ts_enabled() => { // eat the abstract modifier let (_, modifiers) = self.eat_modifiers_before_declaration(); - self.parse_class_declaration(start_span, modifiers) + self.parse_class_declaration(decl_span, modifiers) .map(ExportDefaultDeclarationKind::ClassDeclaration)? } _ if self.at(Kind::Interface) && !self.peek_token().is_on_new_line && self.ts_enabled() => { - self.parse_ts_interface_declaration(start_span, Modifiers::empty()).map(|decl| { + self.parse_ts_interface_declaration(decl_span, Modifiers::empty()).map(|decl| { match decl { Declaration::TSInterfaceDeclaration(decl) => { ExportDefaultDeclarationKind::TSInterfaceDeclaration(decl) @@ -314,7 +328,8 @@ impl<'a> Parser<'a> { } }; let exported = ModuleExportName::Identifier(exported); - Ok(self.ast.export_default_declaration(declaration, exported)) + let span = self.end_span(span); + Ok(self.ast.export_default_declaration(span, declaration, exported)) } // export ExportFromClause FromClause ; @@ -322,7 +337,10 @@ impl<'a> Parser<'a> { // * // * as ModuleExportName // NamedExports - fn parse_export_all_declaration(&mut self) -> Result>> { + fn parse_export_all_declaration( + &mut self, + span: Span, + ) -> Result>> { let export_kind = self.parse_import_or_export_kind(); self.bump_any(); // bump `star` let exported = self.eat(Kind::As).then(|| self.parse_module_export_name()).transpose()?; @@ -330,7 +348,8 @@ impl<'a> Parser<'a> { let source = self.parse_literal_string()?; let assertions = self.parse_import_attributes()?; self.asi()?; - Ok(self.ast.export_all_declaration(exported, source, assertions, export_kind)) + let span = self.end_span(span); + Ok(self.ast.export_all_declaration(span, exported, source, assertions, export_kind)) } // ImportSpecifier : diff --git a/crates/oxc_printer/src/gen.rs b/crates/oxc_printer/src/gen.rs index 13d57a54b..e8492b323 100644 --- a/crates/oxc_printer/src/gen.rs +++ b/crates/oxc_printer/src/gen.rs @@ -420,12 +420,6 @@ impl Gen for DebuggerStatement { } impl<'a> Gen for ModuleDeclaration<'a> { - fn gen(&self, p: &mut Printer) { - self.kind.gen(p); - } -} - -impl<'a> Gen for ModuleDeclarationKind<'a> { fn gen(&self, p: &mut Printer) { match self { Self::ImportDeclaration(decl) => decl.gen(p), diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index f13d2270c..5c033d8a4 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -392,7 +392,7 @@ impl<'a> SemanticBuilder<'a> { } fn symbol_flag_from_module_declaration(module: &ModuleDeclaration) -> SymbolFlags { - if matches!(&module.kind, ModuleDeclarationKind::ImportDeclaration(_)) { + if matches!(module, ModuleDeclaration::ImportDeclaration(_)) { SymbolFlags::Import } else { SymbolFlags::Export diff --git a/crates/oxc_semantic/src/checker/javascript.rs b/crates/oxc_semantic/src/checker/javascript.rs index f5cca2d79..7894eb6cb 100644 --- a/crates/oxc_semantic/src/checker/javascript.rs +++ b/crates/oxc_semantic/src/checker/javascript.rs @@ -41,7 +41,7 @@ impl EarlyErrorJavaScript { AstKind::Directive(dir) => check_directive(dir, node, ctx), AstKind::ModuleDeclaration(decl) => { check_module_declaration(decl, node, ctx); - if let ModuleDeclarationKind::ImportDeclaration(import_decl) = &decl.kind { + if let ModuleDeclaration::ImportDeclaration(import_decl) = decl { check_import_declaration(import_decl, ctx); } } @@ -452,15 +452,15 @@ fn check_module_declaration<'a>( return; } - let text = match decl.kind { - ModuleDeclarationKind::ImportDeclaration(_) => "import statement", - ModuleDeclarationKind::ExportAllDeclaration(_) - | ModuleDeclarationKind::ExportDefaultDeclaration(_) - | ModuleDeclarationKind::ExportNamedDeclaration(_) - | ModuleDeclarationKind::TSExportAssignment(_) - | ModuleDeclarationKind::TSNamespaceExportDeclaration(_) => "export statement", + let text = match decl { + ModuleDeclaration::ImportDeclaration(_) => "import statement", + ModuleDeclaration::ExportAllDeclaration(_) + | ModuleDeclaration::ExportDefaultDeclaration(_) + | ModuleDeclaration::ExportNamedDeclaration(_) + | ModuleDeclaration::TSExportAssignment(_) + | ModuleDeclaration::TSNamespaceExportDeclaration(_) => "export statement", }; - let span = Span::new(decl.span.start, decl.span.start + 6); + let span = Span::new(decl.span().start, decl.span().start + 6); match ctx.source_type.module_kind() { ModuleKind::Script => { ctx.error(ModuleCode(text, span)); diff --git a/crates/oxc_semantic/src/module_record/builder.rs b/crates/oxc_semantic/src/module_record/builder.rs index abdae472f..c53dba043 100644 --- a/crates/oxc_semantic/src/module_record/builder.rs +++ b/crates/oxc_semantic/src/module_record/builder.rs @@ -141,21 +141,21 @@ impl ModuleRecordBuilder { } pub fn visit_module_declaration(&mut self, module_decl: &ModuleDeclaration) { - match &module_decl.kind { - ModuleDeclarationKind::ImportDeclaration(import_decl) => { + match module_decl { + ModuleDeclaration::ImportDeclaration(import_decl) => { self.visit_import_declaration(import_decl); } - ModuleDeclarationKind::ExportAllDeclaration(export_all_decl) => { + ModuleDeclaration::ExportAllDeclaration(export_all_decl) => { self.visit_export_all_declaration(export_all_decl); } - ModuleDeclarationKind::ExportDefaultDeclaration(export_default_decl) => { + ModuleDeclaration::ExportDefaultDeclaration(export_default_decl) => { self.visit_export_default_declaration(export_default_decl); } - ModuleDeclarationKind::ExportNamedDeclaration(export_named_decl) => { + ModuleDeclaration::ExportNamedDeclaration(export_named_decl) => { self.visit_export_named_declaration(export_named_decl); } - ModuleDeclarationKind::TSExportAssignment(_) - | ModuleDeclarationKind::TSNamespaceExportDeclaration(_) => { /* noop */ } + ModuleDeclaration::TSExportAssignment(_) + | ModuleDeclaration::TSNamespaceExportDeclaration(_) => { /* noop */ } } }