From 36e63142d522dcacda0127ddb6ab037c8be26fa3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 04:45:54 +0800 Subject: [PATCH 01/11] chore(deps): update dependency tar to v6.2.1 (#2798) --- tasks/benchmark/codspeed/pnpm-lock.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/benchmark/codspeed/pnpm-lock.yaml b/tasks/benchmark/codspeed/pnpm-lock.yaml index 4b3cd163f7d15..d8ce2f79b25e3 100644 --- a/tasks/benchmark/codspeed/pnpm-lock.yaml +++ b/tasks/benchmark/codspeed/pnpm-lock.yaml @@ -13,7 +13,7 @@ devDependencies: version: 4.18.3 tar: specifier: ^6.2.0 - version: 6.2.0 + version: 6.2.1 packages: @@ -535,8 +535,8 @@ packages: engines: {node: '>= 0.8'} dev: true - /tar@6.2.0: - resolution: {integrity: sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==} + /tar@6.2.1: + resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} dependencies: chownr: 2.0.0 From 7b6a4d0690ed06d9751296ae616e8f1a426e6be6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 04:47:59 +0800 Subject: [PATCH 02/11] chore(deps): update vscode npm packages (#2799) --- editors/vscode/pnpm-lock.yaml | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/editors/vscode/pnpm-lock.yaml b/editors/vscode/pnpm-lock.yaml index eba97cac567a7..6cc3a28b53742 100644 --- a/editors/vscode/pnpm-lock.yaml +++ b/editors/vscode/pnpm-lock.yaml @@ -12,7 +12,7 @@ dependencies: devDependencies: '@types/node': specifier: ^20.11.5 - version: 20.11.28 + version: 20.11.30 '@types/vscode': specifier: 1.80.0 version: 1.80.0 @@ -27,13 +27,13 @@ devDependencies: version: 0.20.2 ovsx: specifier: ^0.8.3 - version: 0.8.3 + version: 0.8.4 prettier: specifier: ^3.2.4 version: 3.2.5 typescript: specifier: ^5.3.3 - version: 5.4.2 + version: 5.4.3 packages: @@ -244,8 +244,8 @@ packages: dev: true optional: true - /@types/node@20.11.28: - resolution: {integrity: sha512-M/GPWVS2wLkSkNHVeLkrF2fD5Lx5UC4PxA0uZcKc6QqbIQUJyW1jVjueJYi1z8n0I5PxYrtpnPnWglE+y9A0KA==} + /@types/node@20.11.30: + resolution: {integrity: sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==} dependencies: undici-types: 5.26.5 dev: true @@ -592,8 +592,8 @@ packages: pend: 1.2.0 dev: true - /follow-redirects@1.15.5: - resolution: {integrity: sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==} + /follow-redirects@1.15.6: + resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} engines: {node: '>=4.0'} peerDependencies: debug: '*' @@ -852,18 +852,18 @@ packages: wrappy: 1.0.2 dev: true - /ovsx@0.8.3: - resolution: {integrity: sha512-LG7wTzy4eYV/KolFeO4AwWPzQSARvCONzd5oHQlNvYOlji2r/zjbdK8pyObZN84uZlk6rQBWrJrAdJfh/SX0Hg==} + /ovsx@0.8.4: + resolution: {integrity: sha512-RMtGSVNM4NWSF9uVWCUqaYiA7ID8Vqm/rSk2W37eYVrDLOI/3do2IRY7rQYkvJqb6sS6LAnALODBkD50tIM1kw==} engines: {node: '>= 14'} hasBin: true dependencies: '@vscode/vsce': 2.24.0 commander: 6.2.1 - follow-redirects: 1.15.5 + follow-redirects: 1.15.6 is-ci: 2.0.0 leven: 3.1.0 - semver: 7.5.4 - tmp: 0.2.1 + semver: 7.6.0 + tmp: 0.2.3 transitivePeerDependencies: - debug dev: true @@ -1002,6 +1002,7 @@ packages: hasBin: true dependencies: lru-cache: 6.0.0 + dev: false /semver@7.6.0: resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} @@ -1114,6 +1115,11 @@ packages: rimraf: 3.0.2 dev: true + /tmp@0.2.3: + resolution: {integrity: sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==} + engines: {node: '>=14.14'} + dev: true + /tunnel-agent@0.6.0: resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} requiresBuild: true @@ -1135,8 +1141,8 @@ packages: underscore: 1.13.6 dev: true - /typescript@5.4.2: - resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==} + /typescript@5.4.3: + resolution: {integrity: sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==} engines: {node: '>=14.17'} hasBin: true dev: true From b6e493bd78a2f5b49e70ec763ad4734727d50f7c Mon Sep 17 00:00:00 2001 From: Dunqing Date: Mon, 25 Mar 2024 04:50:04 +0800 Subject: [PATCH 03/11] fix(semantic): ModuleRecord's indirect_export_entires missing reexported imports (#2792) local_name has `name` and `span`. We can't directly compare ExportEntry's local_name and ImportEntry's local_name. because the span is never equal. --- crates/oxc_semantic/src/builder.rs | 16 ++++++----- .../oxc_semantic/src/module_record/builder.rs | 14 +++++----- crates/oxc_semantic/src/module_record/mod.rs | 27 +++++++++++++++++++ 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 2ad8525523919..e433498096927 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -7,7 +7,7 @@ use oxc_ast::{ast::*, AstKind, Trivias, Visit}; use oxc_diagnostics::Error; use oxc_span::{CompactStr, SourceType, Span}; use oxc_syntax::{ - module_record::{ExportLocalName, ModuleRecord}, + module_record::{ExportImportName, ExportLocalName, ModuleRecord}, operator::AssignmentOperator, }; @@ -324,18 +324,20 @@ impl<'a> SemanticBuilder<'a> { } fn add_export_flag_for_export_identifier(&mut self) { - self.module_record.local_export_entries.iter().for_each(|entry| match &entry.local_name { - ExportLocalName::Name(name_span) => { - if let Some(symbol_id) = self.scope.get_root_binding(name_span.name()) { + self.module_record.indirect_export_entries.iter().for_each(|entry| { + if let ExportImportName::Name(name) = &entry.import_name { + if let Some(symbol_id) = self.symbols.get_symbol_id_from_name(name.name()) { self.symbols.union_flag(symbol_id, SymbolFlags::Export); } } - ExportLocalName::Default(span) => { - if let Some(symbol_id) = self.symbols.get_symbol_id_from_span(span) { + }); + + self.module_record.local_export_entries.iter().for_each(|entry| { + if let ExportLocalName::Name(name_span) = &entry.local_name { + if let Some(symbol_id) = self.scope.get_root_binding(name_span.name()) { self.symbols.union_flag(symbol_id, SymbolFlags::Export); } } - ExportLocalName::Null => {} }); } } diff --git a/crates/oxc_semantic/src/module_record/builder.rs b/crates/oxc_semantic/src/module_record/builder.rs index 9ea66936a697a..f7cf028b873c8 100644 --- a/crates/oxc_semantic/src/module_record/builder.rs +++ b/crates/oxc_semantic/src/module_record/builder.rs @@ -85,15 +85,14 @@ impl ModuleRecordBuilder { for ee in export_entries { // a. If ee.[[ModuleRequest]] is null, then if ee.module_request.is_none() { - let local_name = match &ee.local_name { - ExportLocalName::Name(name) => Some(name), + let found_import_entry = match &ee.local_name { + ExportLocalName::Name(name) => self + .module_record + .import_entries + .iter() + .find(|entry| entry.local_name.name() == name.name()), _ => None, }; - let found_import_entry = self - .module_record - .import_entries - .iter() - .find(|import_entry| Some(&import_entry.local_name) == local_name); match found_import_entry { // i. If ee.[[LocalName]] is not an element of importedBoundNames, then None => { @@ -130,6 +129,7 @@ impl ModuleRecordBuilder { ImportImportName::NamespaceObject => unreachable!(), }, export_name: ee.export_name.clone(), + span: ee.span, ..ExportEntry::default() }; self.append_indirect_export_entry(export_entry); diff --git a/crates/oxc_semantic/src/module_record/mod.rs b/crates/oxc_semantic/src/module_record/mod.rs index c9439f31fc47e..719317d09c8e2 100644 --- a/crates/oxc_semantic/src/module_record/mod.rs +++ b/crates/oxc_semantic/src/module_record/mod.rs @@ -248,4 +248,31 @@ mod module_record_tests { assert_eq!(module_record.local_export_entries.len(), 1); assert_eq!(module_record.local_export_entries[0], export_entry); } + + #[test] + fn indirect_export_entries() { + let module_record = + build("import { x } from 'mod';export { x };export * as ns from 'mod';"); + assert_eq!(module_record.indirect_export_entries.len(), 2); + assert_eq!( + module_record.indirect_export_entries[0], + ExportEntry { + module_request: Some(NameSpan::new("mod".into(), Span::new(18, 23))), + span: Span::new(33, 34), + import_name: ExportImportName::Name(NameSpan::new("x".into(), Span::new(9, 10))), + export_name: ExportExportName::Name(NameSpan::new("x".into(), Span::new(33, 34))), + local_name: ExportLocalName::Null, + } + ); + assert_eq!( + module_record.indirect_export_entries[1], + ExportEntry { + module_request: Some(NameSpan::new("mod".into(), Span::new(57, 62))), + span: Span::new(0, 0), + import_name: ExportImportName::All, + export_name: ExportExportName::Name(NameSpan::new("ns".into(), Span::new(49, 51))), + local_name: ExportLocalName::Null, + } + ); + } } From 398a0346b3362f91f61eb258844f1b9141dfb3f2 Mon Sep 17 00:00:00 2001 From: Dunqing Date: Mon, 25 Mar 2024 04:51:23 +0800 Subject: [PATCH 04/11] feat(transformer/typescript): remove `verbatim_module_syntax` option (#2796) Remove `verbatim_module_syntax` option, Because Babel's [onlyRemoveTypeImports](https://babeljs.io/docs/babel-plugin-transform-typescript#onlyremovetypeimports) option same behavior with `verbatim_module_syntax` , You can see https://github.com/babel/babel/issues/15493#issuecomment-1466453493 --- crates/oxc_transformer/src/lib.rs | 3 +-- crates/oxc_transformer/src/typescript/mod.rs | 17 +++-------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/crates/oxc_transformer/src/lib.rs b/crates/oxc_transformer/src/lib.rs index 82e3d204fba42..81f4064081acd 100644 --- a/crates/oxc_transformer/src/lib.rs +++ b/crates/oxc_transformer/src/lib.rs @@ -104,8 +104,7 @@ impl<'a> Transformer<'a> { Self { ctx: ctx.clone(), decorators: Decorators::new(Rc::clone(&ast), ctx.clone(), &options), - // TODO: pass verbatim_module_syntax from user config - typescript: source_type.is_typescript().then(|| TypeScript::new(Rc::clone(&ast), ctx.clone(), false, &options)), + typescript: source_type.is_typescript().then(|| TypeScript::new(Rc::clone(&ast), ctx.clone(), &options)), regexp_flags: RegexpFlags::new(Rc::clone(&ast), &options), // es2022 es2022_class_static_block: es2022::ClassStaticBlock::new(Rc::clone(&ast), &options), diff --git a/crates/oxc_transformer/src/typescript/mod.rs b/crates/oxc_transformer/src/typescript/mod.rs index cf37fb3ee40ca..18962cbbdf5fb 100644 --- a/crates/oxc_transformer/src/typescript/mod.rs +++ b/crates/oxc_transformer/src/typescript/mod.rs @@ -23,7 +23,6 @@ use crate::{context::TransformerCtx, utils::is_valid_identifier, TransformOption pub struct TypeScript<'a> { ast: Rc>, ctx: TransformerCtx<'a>, - verbatim_module_syntax: bool, export_name_set: FxHashSet>, options: TypescriptOptions, namespace_arg_names: FxHashMap, usize>, @@ -33,13 +32,11 @@ impl<'a> TypeScript<'a> { pub fn new( ast: Rc>, ctx: TransformerCtx<'a>, - verbatim_module_syntax: bool, options: &TransformOptions, ) -> Self { Self { ast, ctx, - verbatim_module_syntax, export_name_set: FxHashSet::default(), options: options.typescript.clone().unwrap_or_default(), namespace_arg_names: FxHashMap::default(), @@ -140,7 +137,6 @@ impl<'a> TypeScript<'a> { }); if decl.export_kind.is_type() - || self.verbatim_module_syntax || ((decl.declaration.is_none() || decl.declaration.as_ref().is_some_and(|d| { d.modifiers().is_some_and(|modifiers| { @@ -170,9 +166,7 @@ impl<'a> TypeScript<'a> { return false; } - if self.verbatim_module_syntax - || self.options.only_remove_type_imports - { + if self.options.only_remove_type_imports { return true; } @@ -182,9 +176,7 @@ impl<'a> TypeScript<'a> { self.has_value_references(&s.local.name) } - ImportDeclarationSpecifier::ImportDefaultSpecifier(s) - if !self.verbatim_module_syntax => - { + ImportDeclarationSpecifier::ImportDefaultSpecifier(s) => { if is_type { import_type_names.insert(s.local.name.clone()); return false; @@ -195,9 +187,7 @@ impl<'a> TypeScript<'a> { } self.has_value_references(&s.local.name) } - ImportDeclarationSpecifier::ImportNamespaceSpecifier(s) - if !self.verbatim_module_syntax => - { + ImportDeclarationSpecifier::ImportNamespaceSpecifier(s) => { if is_type { import_type_names.insert(s.local.name.clone()); } @@ -208,7 +198,6 @@ impl<'a> TypeScript<'a> { self.has_value_references(&s.local.name) } - _ => true, }); } From 890144f464c943348f5b88aad2652ecdec51ee35 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 24 Mar 2024 20:51:37 +0000 Subject: [PATCH 05/11] chore(deps): update dependency express to v4.19.1 (#2800) --- tasks/benchmark/codspeed/pnpm-lock.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tasks/benchmark/codspeed/pnpm-lock.yaml b/tasks/benchmark/codspeed/pnpm-lock.yaml index d8ce2f79b25e3..1155e2ab27a32 100644 --- a/tasks/benchmark/codspeed/pnpm-lock.yaml +++ b/tasks/benchmark/codspeed/pnpm-lock.yaml @@ -10,7 +10,7 @@ devDependencies: version: 1.6.8 express: specifier: ^4.18.3 - version: 4.18.3 + version: 4.19.1 tar: specifier: ^6.2.0 version: 6.2.1 @@ -107,8 +107,8 @@ packages: resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==} dev: true - /cookie@0.5.0: - resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} + /cookie@0.6.0: + resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} engines: {node: '>= 0.6'} dev: true @@ -177,8 +177,8 @@ packages: engines: {node: '>= 0.6'} dev: true - /express@4.18.3: - resolution: {integrity: sha512-6VyCijWQ+9O7WuVMTRBTl+cjNNIzD5cY5mQ1WM8r/LEkI2u8EYpOotESNwzNlyCn3g+dmjKYI6BmNneSr/FSRw==} + /express@4.19.1: + resolution: {integrity: sha512-K4w1/Bp7y8iSiVObmCrtq8Cs79XjJc/RU2YYkZQ7wpUu5ZyZ7MtPHkqoMz4pf+mgXfNvo2qft8D9OnrH2ABk9w==} engines: {node: '>= 0.10.0'} dependencies: accepts: 1.3.8 @@ -186,7 +186,7 @@ packages: body-parser: 1.20.2 content-disposition: 0.5.4 content-type: 1.0.5 - cookie: 0.5.0 + cookie: 0.6.0 cookie-signature: 1.0.6 debug: 2.6.9 depd: 2.0.0 From 2500947114d480294d6e29c1c572b5804b54df13 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 04:52:45 +0800 Subject: [PATCH 06/11] chore(deps): update dependency vite to v5.2.6 (#2801) --- website/pnpm-lock.yaml | 162 ++++++++++++++++++++--------------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/website/pnpm-lock.yaml b/website/pnpm-lock.yaml index 247ec8663128c..220e2b479c393 100644 --- a/website/pnpm-lock.yaml +++ b/website/pnpm-lock.yaml @@ -63,7 +63,7 @@ devDependencies: version: 8.2.2 vite: specifier: ^5.0.12 - version: 5.1.6 + version: 5.2.6 wasm-pack: specifier: ^0.12.1 version: 0.12.1 @@ -182,8 +182,8 @@ packages: '@lezer/highlight': 1.2.0 dev: false - /@esbuild/aix-ppc64@0.19.12: - resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==} + /@esbuild/aix-ppc64@0.20.2: + resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==} engines: {node: '>=12'} cpu: [ppc64] os: [aix] @@ -191,8 +191,8 @@ packages: dev: true optional: true - /@esbuild/android-arm64@0.19.12: - resolution: {integrity: sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==} + /@esbuild/android-arm64@0.20.2: + resolution: {integrity: sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==} engines: {node: '>=12'} cpu: [arm64] os: [android] @@ -200,8 +200,8 @@ packages: dev: true optional: true - /@esbuild/android-arm@0.19.12: - resolution: {integrity: sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==} + /@esbuild/android-arm@0.20.2: + resolution: {integrity: sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==} engines: {node: '>=12'} cpu: [arm] os: [android] @@ -209,8 +209,8 @@ packages: dev: true optional: true - /@esbuild/android-x64@0.19.12: - resolution: {integrity: sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==} + /@esbuild/android-x64@0.20.2: + resolution: {integrity: sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==} engines: {node: '>=12'} cpu: [x64] os: [android] @@ -218,8 +218,8 @@ packages: dev: true optional: true - /@esbuild/darwin-arm64@0.19.12: - resolution: {integrity: sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==} + /@esbuild/darwin-arm64@0.20.2: + resolution: {integrity: sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] @@ -227,8 +227,8 @@ packages: dev: true optional: true - /@esbuild/darwin-x64@0.19.12: - resolution: {integrity: sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==} + /@esbuild/darwin-x64@0.20.2: + resolution: {integrity: sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==} engines: {node: '>=12'} cpu: [x64] os: [darwin] @@ -236,8 +236,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-arm64@0.19.12: - resolution: {integrity: sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==} + /@esbuild/freebsd-arm64@0.20.2: + resolution: {integrity: sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] @@ -245,8 +245,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-x64@0.19.12: - resolution: {integrity: sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==} + /@esbuild/freebsd-x64@0.20.2: + resolution: {integrity: sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] @@ -254,8 +254,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm64@0.19.12: - resolution: {integrity: sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==} + /@esbuild/linux-arm64@0.20.2: + resolution: {integrity: sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==} engines: {node: '>=12'} cpu: [arm64] os: [linux] @@ -263,8 +263,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm@0.19.12: - resolution: {integrity: sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==} + /@esbuild/linux-arm@0.20.2: + resolution: {integrity: sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==} engines: {node: '>=12'} cpu: [arm] os: [linux] @@ -272,8 +272,8 @@ packages: dev: true optional: true - /@esbuild/linux-ia32@0.19.12: - resolution: {integrity: sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==} + /@esbuild/linux-ia32@0.20.2: + resolution: {integrity: sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==} engines: {node: '>=12'} cpu: [ia32] os: [linux] @@ -281,8 +281,8 @@ packages: dev: true optional: true - /@esbuild/linux-loong64@0.19.12: - resolution: {integrity: sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==} + /@esbuild/linux-loong64@0.20.2: + resolution: {integrity: sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==} engines: {node: '>=12'} cpu: [loong64] os: [linux] @@ -290,8 +290,8 @@ packages: dev: true optional: true - /@esbuild/linux-mips64el@0.19.12: - resolution: {integrity: sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==} + /@esbuild/linux-mips64el@0.20.2: + resolution: {integrity: sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] @@ -299,8 +299,8 @@ packages: dev: true optional: true - /@esbuild/linux-ppc64@0.19.12: - resolution: {integrity: sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==} + /@esbuild/linux-ppc64@0.20.2: + resolution: {integrity: sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] @@ -308,8 +308,8 @@ packages: dev: true optional: true - /@esbuild/linux-riscv64@0.19.12: - resolution: {integrity: sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==} + /@esbuild/linux-riscv64@0.20.2: + resolution: {integrity: sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] @@ -317,8 +317,8 @@ packages: dev: true optional: true - /@esbuild/linux-s390x@0.19.12: - resolution: {integrity: sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==} + /@esbuild/linux-s390x@0.20.2: + resolution: {integrity: sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==} engines: {node: '>=12'} cpu: [s390x] os: [linux] @@ -326,8 +326,8 @@ packages: dev: true optional: true - /@esbuild/linux-x64@0.19.12: - resolution: {integrity: sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==} + /@esbuild/linux-x64@0.20.2: + resolution: {integrity: sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==} engines: {node: '>=12'} cpu: [x64] os: [linux] @@ -335,8 +335,8 @@ packages: dev: true optional: true - /@esbuild/netbsd-x64@0.19.12: - resolution: {integrity: sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==} + /@esbuild/netbsd-x64@0.20.2: + resolution: {integrity: sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] @@ -344,8 +344,8 @@ packages: dev: true optional: true - /@esbuild/openbsd-x64@0.19.12: - resolution: {integrity: sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==} + /@esbuild/openbsd-x64@0.20.2: + resolution: {integrity: sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] @@ -353,8 +353,8 @@ packages: dev: true optional: true - /@esbuild/sunos-x64@0.19.12: - resolution: {integrity: sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==} + /@esbuild/sunos-x64@0.20.2: + resolution: {integrity: sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==} engines: {node: '>=12'} cpu: [x64] os: [sunos] @@ -362,8 +362,8 @@ packages: dev: true optional: true - /@esbuild/win32-arm64@0.19.12: - resolution: {integrity: sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==} + /@esbuild/win32-arm64@0.20.2: + resolution: {integrity: sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==} engines: {node: '>=12'} cpu: [arm64] os: [win32] @@ -371,8 +371,8 @@ packages: dev: true optional: true - /@esbuild/win32-ia32@0.19.12: - resolution: {integrity: sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==} + /@esbuild/win32-ia32@0.20.2: + resolution: {integrity: sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==} engines: {node: '>=12'} cpu: [ia32] os: [win32] @@ -380,8 +380,8 @@ packages: dev: true optional: true - /@esbuild/win32-x64@0.19.12: - resolution: {integrity: sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==} + /@esbuild/win32-x64@0.20.2: + resolution: {integrity: sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==} engines: {node: '>=12'} cpu: [x64] os: [win32] @@ -680,35 +680,35 @@ packages: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true - /esbuild@0.19.12: - resolution: {integrity: sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==} + /esbuild@0.20.2: + resolution: {integrity: sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/aix-ppc64': 0.19.12 - '@esbuild/android-arm': 0.19.12 - '@esbuild/android-arm64': 0.19.12 - '@esbuild/android-x64': 0.19.12 - '@esbuild/darwin-arm64': 0.19.12 - '@esbuild/darwin-x64': 0.19.12 - '@esbuild/freebsd-arm64': 0.19.12 - '@esbuild/freebsd-x64': 0.19.12 - '@esbuild/linux-arm': 0.19.12 - '@esbuild/linux-arm64': 0.19.12 - '@esbuild/linux-ia32': 0.19.12 - '@esbuild/linux-loong64': 0.19.12 - '@esbuild/linux-mips64el': 0.19.12 - '@esbuild/linux-ppc64': 0.19.12 - '@esbuild/linux-riscv64': 0.19.12 - '@esbuild/linux-s390x': 0.19.12 - '@esbuild/linux-x64': 0.19.12 - '@esbuild/netbsd-x64': 0.19.12 - '@esbuild/openbsd-x64': 0.19.12 - '@esbuild/sunos-x64': 0.19.12 - '@esbuild/win32-arm64': 0.19.12 - '@esbuild/win32-ia32': 0.19.12 - '@esbuild/win32-x64': 0.19.12 + '@esbuild/aix-ppc64': 0.20.2 + '@esbuild/android-arm': 0.20.2 + '@esbuild/android-arm64': 0.20.2 + '@esbuild/android-x64': 0.20.2 + '@esbuild/darwin-arm64': 0.20.2 + '@esbuild/darwin-x64': 0.20.2 + '@esbuild/freebsd-arm64': 0.20.2 + '@esbuild/freebsd-x64': 0.20.2 + '@esbuild/linux-arm': 0.20.2 + '@esbuild/linux-arm64': 0.20.2 + '@esbuild/linux-ia32': 0.20.2 + '@esbuild/linux-loong64': 0.20.2 + '@esbuild/linux-mips64el': 0.20.2 + '@esbuild/linux-ppc64': 0.20.2 + '@esbuild/linux-riscv64': 0.20.2 + '@esbuild/linux-s390x': 0.20.2 + '@esbuild/linux-x64': 0.20.2 + '@esbuild/netbsd-x64': 0.20.2 + '@esbuild/openbsd-x64': 0.20.2 + '@esbuild/sunos-x64': 0.20.2 + '@esbuild/win32-arm64': 0.20.2 + '@esbuild/win32-ia32': 0.20.2 + '@esbuild/win32-x64': 0.20.2 dev: true /escalade@3.1.1: @@ -848,13 +848,13 @@ packages: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} dev: true - /postcss@8.4.36: - resolution: {integrity: sha512-/n7eumA6ZjFHAsbX30yhHup/IMkOmlmvtEi7P+6RMYf+bGJSUHc3geH4a0NSZxAz/RJfiS9tooCTs9LAVYUZKw==} + /postcss@8.4.38: + resolution: {integrity: sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==} engines: {node: ^10 || ^12 || >=14} dependencies: nanoid: 3.3.7 picocolors: 1.0.0 - source-map-js: 1.1.0 + source-map-js: 1.2.0 dev: true /regenerator-runtime@0.14.1: @@ -906,8 +906,8 @@ packages: resolution: {integrity: sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==} dev: true - /source-map-js@1.1.0: - resolution: {integrity: sha512-9vC2SfsJzlej6MAaMPLu8HiBSHGdRAJ9hVFYN1ibZoNkeanmDmLUcIrj6G9DGL7XMJ54AKg/G75akXl1/izTOw==} + /source-map-js@1.2.0: + resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} dev: true @@ -974,8 +974,8 @@ packages: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} dev: true - /vite@5.1.6: - resolution: {integrity: sha512-yYIAZs9nVfRJ/AiOLCA91zzhjsHUgMjB+EigzFb6W2XTLO8JixBCKCjvhKZaye+NKYHCrkv3Oh50dH9EdLU2RA==} + /vite@5.2.6: + resolution: {integrity: sha512-FPtnxFlSIKYjZ2eosBQamz4CbyrTizbZ3hnGJlh/wMtCrlp1Hah6AzBLjGI5I2urTfNnpovpHdrL6YRuBOPnCA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -1002,8 +1002,8 @@ packages: terser: optional: true dependencies: - esbuild: 0.19.12 - postcss: 8.4.36 + esbuild: 0.20.2 + postcss: 8.4.38 rollup: 4.13.0 optionalDependencies: fsevents: 2.3.3 From 525031b7a2e9678b9d3097f8b407187b1d8409e6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 09:47:26 +0800 Subject: [PATCH 07/11] chore(deps): update rust crates (#2802) --- Cargo.lock | 48 ++++++++++++++++++------------------ Cargo.toml | 12 ++++----- crates/oxc_linter/Cargo.toml | 2 +- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 530f4c5c5dbe3..ea31de63e52de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,9 +122,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" dependencies = [ "serde", ] @@ -152,9 +152,9 @@ dependencies = [ [[package]] name = "bpaf" -version = "0.9.9" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc932b40b31d9bea0196f54c5b1b721b9aff3882fc08d9fe4082970c7e94d3d" +checksum = "567fc5f0a754100df11b167b2a247b2366fc1ac18e9b776a07659be00878f681" dependencies = [ "bpaf_derive", "owo-colors", @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "bpaf_derive" -version = "0.5.7" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efeab2975f8102de445dcf898856a638332403c50216144653a89aec22fd79e0" +checksum = "9a8d5b11f7fa1068e5bbac8ab6c8c2c6940047f69185987446b60c995d4bf89c" dependencies = [ "proc-macro2", "quote", @@ -773,9 +773,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "5.1.0" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab283476b99e66691dee3f1640fea91487a8d81f50fb5ecc75538f8f8879a1e4" +checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" dependencies = [ "log", "pest", @@ -867,9 +867,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", @@ -1144,7 +1144,7 @@ version = "2.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54a63d0570e4c3e0daf7a8d380563610e159f538e20448d6c911337246f40e84" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "ctor", "napi-derive", "napi-sys", @@ -1376,7 +1376,7 @@ dependencies = [ name = "oxc_ast" version = "0.10.0" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "num-bigint", "oxc_allocator", "oxc_index", @@ -1434,7 +1434,7 @@ name = "oxc_codegen" version = "0.10.0" dependencies = [ "base64 0.22.0", - "bitflags 2.4.2", + "bitflags 2.5.0", "oxc_allocator", "oxc_ast", "oxc_parser", @@ -1623,7 +1623,7 @@ name = "oxc_parser" version = "0.10.0" dependencies = [ "assert-unchecked", - "bitflags 2.4.2", + "bitflags 2.5.0", "memchr", "miette", "num-bigint", @@ -1673,7 +1673,7 @@ dependencies = [ name = "oxc_prettier" version = "0.0.0" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "oxc_allocator", "oxc_ast", "oxc_parser", @@ -1698,9 +1698,9 @@ dependencies = [ [[package]] name = "oxc_resolver" -version = "1.6.1" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6351564310d149357fcd2fe75baeee075eb338fd068de781991e017c8895093" +checksum = "e25e001325ea3e526424f01c6bdd5fda061eec2cc4cb21b6e64e660c0d8a14a1" dependencies = [ "dashmap", "dunce", @@ -1752,7 +1752,7 @@ dependencies = [ name = "oxc_syntax" version = "0.10.0" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "dashmap", "indexmap", "oxc_index", @@ -1802,7 +1802,7 @@ dependencies = [ name = "oxc_transformer" version = "0.10.0" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "oxc_allocator", "oxc_ast", "oxc_codegen", @@ -2063,9 +2063,9 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "rayon" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -2092,9 +2092,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -2212,7 +2212,7 @@ version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", diff --git a/Cargo.toml b/Cargo.toml index 9d32ea52e4828..730daf60c7b00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,8 +89,8 @@ napi = { version = "2" } napi-derive = { version = "2" } assert-unchecked = { version = "0.1.2" } -bpaf = { version = "0.9.9" } -bitflags = { version = "2.4.2" } +bpaf = { version = "0.9.11" } +bitflags = { version = "2.5.0" } bumpalo = { version = "3.15.4" } convert_case = { version = "0.6.0" } dashmap = { version = "5.5.3" } @@ -110,8 +110,8 @@ pico-args = { version = "0.5.0" } proc-macro2 = { version = "1.0.79" } project-root = { version = "0.2.2" } quote = { version = "1.0.35" } -rayon = { version = "1.9.0" } -regex = { version = "1.10.3" } +rayon = { version = "1.10.0" } +regex = { version = "1.10.4" } rustc-hash = { version = "1.1.0", default-features = false, features = ["std"] } ryu-js = { version = "1.0.1" } ropey = { version = "1.6.1" } @@ -127,7 +127,7 @@ unicode-id-start = { version = "1.1.2" } ureq = { version = "2.9.6", default-features = false, features = ["tls", "json"] } url = { version = "2.5.0" } walkdir = { version = "2.5.0" } -indexmap = { version = "2.2.5" } +indexmap = { version = "2.2.6" } index_vec = { version = "0.1.3" } static_assertions = { version = "1.1.0" } tracing-subscriber = { version = "0.3" } @@ -137,7 +137,7 @@ language-tags = { version = "0.3.2" } tsify = { version = "0.4.5" } wasm-bindgen = { version = "0.2" } serde-wasm-bindgen = { version = "0.6.5" } -handlebars = { version = "5.1.0" } +handlebars = { version = "5.1.2" } [profile.release.package.oxc_wasm] opt-level = 'z' diff --git a/crates/oxc_linter/Cargo.toml b/crates/oxc_linter/Cargo.toml index b9d2218a5c9f0..c8443189000fa 100644 --- a/crates/oxc_linter/Cargo.toml +++ b/crates/oxc_linter/Cargo.toml @@ -29,7 +29,7 @@ oxc_semantic = { workspace = true } oxc_syntax = { workspace = true } oxc_codegen = { workspace = true } oxc_index = { workspace = true } -oxc_resolver = { version = "1.6.1" } +oxc_resolver = { version = "1.6.2" } rayon = { workspace = true } lazy_static = { workspace = true } # used in oxc_macros From b28b61774b707c45d1220570bd6cd6cffba14381 Mon Sep 17 00:00:00 2001 From: Dunqing Date: Mon, 25 Mar 2024 10:32:02 +0800 Subject: [PATCH 08/11] fix(semantic): incorrect ExportEntry span for ExportAllDeclaration in ModuleRecord (#2793) Now the span is ExportAllDeclaration's span --- crates/oxc_semantic/src/module_record/builder.rs | 1 + crates/oxc_semantic/src/module_record/mod.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/oxc_semantic/src/module_record/builder.rs b/crates/oxc_semantic/src/module_record/builder.rs index f7cf028b873c8..5939bfa37066a 100644 --- a/crates/oxc_semantic/src/module_record/builder.rs +++ b/crates/oxc_semantic/src/module_record/builder.rs @@ -219,6 +219,7 @@ impl ModuleRecordBuilder { exported_name.span(), )) }), + span: decl.span, ..ExportEntry::default() }; self.add_export_entry(export_entry); diff --git a/crates/oxc_semantic/src/module_record/mod.rs b/crates/oxc_semantic/src/module_record/mod.rs index 719317d09c8e2..f1b2abd7a02d4 100644 --- a/crates/oxc_semantic/src/module_record/mod.rs +++ b/crates/oxc_semantic/src/module_record/mod.rs @@ -97,6 +97,7 @@ mod module_record_tests { let export_entry = ExportEntry { module_request: Some(NameSpan::new("mod".into(), Span::new(14, 19))), import_name: ExportImportName::AllButDefault, + span: Span::new(0, 19), ..ExportEntry::default() }; assert_eq!(module_record.star_export_entries.len(), 1); @@ -112,6 +113,7 @@ mod module_record_tests { module_request: Some(NameSpan::new("mod".into(), Span::new(20, 25))), import_name: ExportImportName::All, export_name: ExportExportName::Name(NameSpan::new("ns".into(), Span::new(12, 14))), + span: Span::new(0, 25), ..ExportEntry::default() }; assert_eq!(module_record.indirect_export_entries.len(), 1); @@ -268,7 +270,7 @@ mod module_record_tests { module_record.indirect_export_entries[1], ExportEntry { module_request: Some(NameSpan::new("mod".into(), Span::new(57, 62))), - span: Span::new(0, 0), + span: Span::new(37, 63), import_name: ExportImportName::All, export_name: ExportExportName::Name(NameSpan::new("ns".into(), Span::new(49, 51))), local_name: ExportLocalName::Null, From 198eea0bced2722fffbd6504953ad226356f21bd Mon Sep 17 00:00:00 2001 From: Ali Rezvani <3788964+rzvxa@users.noreply.github.com> Date: Mon, 25 Mar 2024 06:14:29 +0330 Subject: [PATCH 09/11] refactor(ast): add walk functions to Visit trait. (#2791) closes #2442 --- crates/oxc_ast/src/lib.rs | 2 +- crates/oxc_ast/src/visit.rs | 3191 ++++++++++++++++--------- crates/oxc_module_lexer/src/lib.rs | 311 +-- crates/oxc_parser/examples/visitor.rs | 25 +- 4 files changed, 2278 insertions(+), 1251 deletions(-) diff --git a/crates/oxc_ast/src/lib.rs b/crates/oxc_ast/src/lib.rs index 332ebd83ef8bd..2276ebba38d18 100644 --- a/crates/oxc_ast/src/lib.rs +++ b/crates/oxc_ast/src/lib.rs @@ -28,7 +28,7 @@ pub use crate::{ ast_builder::AstBuilder, ast_kind::{AstKind, AstType}, trivia::{Comment, CommentKind, Trivias, TriviasMap}, - visit::Visit, + visit::{walk, Visit}, visit_mut::VisitMut, }; diff --git a/crates/oxc_ast/src/visit.rs b/crates/oxc_ast/src/visit.rs index eeb60e390f948..7f1d7b39db537 100644 --- a/crates/oxc_ast/src/visit.rs +++ b/crates/oxc_ast/src/visit.rs @@ -10,496 +10,1306 @@ use oxc_syntax::scope::ScopeFlags; use crate::{ast::*, ast_kind::AstKind}; +use walk::*; + /// Syntax tree traversal pub trait Visit<'a>: Sized { fn enter_node(&mut self, _kind: AstKind<'a>) {} fn leave_node(&mut self, _kind: AstKind<'a>) {} - fn enter_scope(&mut self, _flags: ScopeFlags) {} - fn leave_scope(&mut self) {} + fn enter_scope(&mut self, _flags: ScopeFlags) {} + fn leave_scope(&mut self) {} + + fn alloc(&self, t: &T) -> &'a T { + // SAFETY: + // This should be safe as long as `src` is an reference from the allocator. + // But honestly, I'm not really sure if this is safe. + unsafe { std::mem::transmute(t) } + } + + fn visit_program(&mut self, program: &Program<'a>) { + walk_program(self, program); + } + + /* ---------- Statement ---------- */ + + fn visit_statements(&mut self, stmts: &Vec<'a, Statement<'a>>) { + walk_statements(self, stmts); + } + + fn visit_statement(&mut self, stmt: &Statement<'a>) { + walk_statement(self, stmt); + } + + fn visit_block_statement(&mut self, stmt: &BlockStatement<'a>) { + walk_block_statement(self, stmt); + } + + fn visit_break_statement(&mut self, stmt: &BreakStatement<'a>) { + walk_break_statement(self, stmt); + } + + fn visit_continue_statement(&mut self, stmt: &ContinueStatement<'a>) { + walk_continue_statement(self, stmt); + } + + fn visit_debugger_statement(&mut self, stmt: &DebuggerStatement) { + walk_debugger_statement(self, stmt); + } + + fn visit_do_while_statement(&mut self, stmt: &DoWhileStatement<'a>) { + walk_do_while_statement(self, stmt); + } + + fn visit_empty_statement(&mut self, stmt: &EmptyStatement) { + walk_empty_statement(self, stmt); + } + + fn visit_expression_statement(&mut self, stmt: &ExpressionStatement<'a>) { + walk_expression_statement(self, stmt); + } + + fn visit_for_statement(&mut self, stmt: &ForStatement<'a>) { + walk_for_statement(self, stmt); + } + + fn visit_for_statement_init(&mut self, init: &ForStatementInit<'a>) { + walk_for_statement_init(self, init); + } + + fn visit_for_in_statement(&mut self, stmt: &ForInStatement<'a>) { + walk_for_in_statement(self, stmt); + } + + fn visit_for_of_statement(&mut self, stmt: &ForOfStatement<'a>) { + walk_for_of_statement(self, stmt); + } + + fn visit_for_statement_left(&mut self, left: &ForStatementLeft<'a>) { + walk_for_statement_left(self, left); + } + + fn visit_if_statement(&mut self, stmt: &IfStatement<'a>) { + walk_if_statement(self, stmt); + } + + fn visit_labeled_statement(&mut self, stmt: &LabeledStatement<'a>) { + walk_labeled_statement(self, stmt); + } + + fn visit_return_statement(&mut self, stmt: &ReturnStatement<'a>) { + walk_return_statement(self, stmt); + } + + fn visit_switch_statement(&mut self, stmt: &SwitchStatement<'a>) { + walk_switch_statement(self, stmt); + } + + fn visit_switch_case(&mut self, case: &SwitchCase<'a>) { + walk_switch_case(self, case); + } + + fn visit_throw_statement(&mut self, stmt: &ThrowStatement<'a>) { + walk_throw_statement(self, stmt); + } + + fn visit_try_statement(&mut self, stmt: &TryStatement<'a>) { + walk_try_statement(self, stmt); + } + + fn visit_catch_clause(&mut self, clause: &CatchClause<'a>) { + walk_catch_clause(self, clause); + } + + fn visit_finally_clause(&mut self, clause: &BlockStatement<'a>) { + walk_finally_clause(self, clause); + } + + fn visit_while_statement(&mut self, stmt: &WhileStatement<'a>) { + walk_while_statement(self, stmt); + } + + fn visit_with_statement(&mut self, stmt: &WithStatement<'a>) { + walk_with_statement(self, stmt); + } + + fn visit_directive(&mut self, directive: &Directive<'a>) { + walk_directive(self, directive); + } + + /* ---------- Declaration ---------- */ + + fn visit_variable_declaration(&mut self, decl: &VariableDeclaration<'a>) { + walk_variable_declaration(self, decl); + } + + fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) { + walk_variable_declarator(self, declarator); + } + + /* ---------- Function ---------- */ + + fn visit_function(&mut self, func: &Function<'a>, flags: Option) { + walk_function(self, func, flags); + } + + fn visit_function_body(&mut self, body: &FunctionBody<'a>) { + walk_function_body(self, body); + } + + fn visit_formal_parameters(&mut self, params: &FormalParameters<'a>) { + walk_formal_parameters(self, params); + } + + fn visit_formal_parameter(&mut self, param: &FormalParameter<'a>) { + walk_formal_parameter(self, param); + } + + /* ---------- Class ---------- */ + + fn visit_decorator(&mut self, decorator: &Decorator<'a>) { + walk_decorator(self, decorator); + } + + fn visit_class(&mut self, class: &Class<'a>) { + walk_class(self, class); + } + + fn visit_class_heritage(&mut self, expr: &Expression<'a>) { + walk_class_heritage(self, expr); + } + + fn visit_class_body(&mut self, body: &ClassBody<'a>) { + walk_class_body(self, body); + } + + fn visit_class_element(&mut self, elem: &ClassElement<'a>) { + walk_class_element(self, elem); + } + + fn visit_static_block(&mut self, block: &StaticBlock<'a>) { + walk_static_block(self, block); + } + + fn visit_method_definition(&mut self, def: &MethodDefinition<'a>) { + walk_method_definition(self, def); + } + + fn visit_property_definition(&mut self, def: &PropertyDefinition<'a>) { + walk_property_definition(self, def); + } + + fn visit_using_declaration(&mut self, decl: &UsingDeclaration<'a>) { + walk_using_declaration(self, decl); + } + + /* ---------- Expression ---------- */ + + fn visit_expression(&mut self, expr: &Expression<'a>) { + walk_expression(self, expr); + } + + fn visit_meta_property(&mut self, meta: &MetaProperty<'a>) { + walk_meta_property(self, meta); + } + + fn visit_array_expression(&mut self, expr: &ArrayExpression<'a>) { + walk_array_expression(self, expr); + } + + fn visit_array_expression_element(&mut self, arg: &ArrayExpressionElement<'a>) { + walk_array_expression_element(self, arg); + } + + fn visit_argument(&mut self, arg: &Argument<'a>) { + walk_argument(self, arg); + } + + fn visit_spread_element(&mut self, elem: &SpreadElement<'a>) { + walk_spread_element(self, elem); + } + + fn visit_expression_array_element(&mut self, expr: &Expression<'a>) { + walk_expression_array_element(self, expr); + } + + fn visit_elision(&mut self, span: Span) { + walk_elision(self, span); + } + + fn visit_assignment_expression(&mut self, expr: &AssignmentExpression<'a>) { + walk_assignment_expression(self, expr); + } + + fn visit_arrow_expression(&mut self, expr: &ArrowFunctionExpression<'a>) { + walk_arrow_expression(self, expr); + } + + fn visit_await_expression(&mut self, expr: &AwaitExpression<'a>) { + walk_await_expression(self, expr); + } + + fn visit_binary_expression(&mut self, expr: &BinaryExpression<'a>) { + walk_binary_expression(self, expr); + } + + fn visit_call_expression(&mut self, expr: &CallExpression<'a>) { + walk_call_expression(self, expr); + } + + fn visit_chain_expression(&mut self, expr: &ChainExpression<'a>) { + walk_chain_expression(self, expr); + } + + fn visit_chain_element(&mut self, elem: &ChainElement<'a>) { + walk_chain_element(self, elem); + } + + fn visit_conditional_expression(&mut self, expr: &ConditionalExpression<'a>) { + walk_conditional_expression(self, expr); + } + + fn visit_import_expression(&mut self, expr: &ImportExpression<'a>) { + walk_import_expression(self, expr); + } + + fn visit_logical_expression(&mut self, expr: &LogicalExpression<'a>) { + walk_logical_expression(self, expr); + } + + fn visit_member_expression(&mut self, expr: &MemberExpression<'a>) { + walk_member_expression(self, expr); + } + + fn visit_computed_member_expression(&mut self, expr: &ComputedMemberExpression<'a>) { + walk_computed_member_expression(self, expr); + } + + fn visit_static_member_expression(&mut self, expr: &StaticMemberExpression<'a>) { + walk_static_member_expression(self, expr); + } + + fn visit_private_field_expression(&mut self, expr: &PrivateFieldExpression<'a>) { + walk_private_field_expression(self, expr); + } + + fn visit_new_expression(&mut self, expr: &NewExpression<'a>) { + walk_new_expression(self, expr); + } + + fn visit_object_expression(&mut self, expr: &ObjectExpression<'a>) { + walk_object_expression(self, expr); + } + + fn visit_object_property_kind(&mut self, prop: &ObjectPropertyKind<'a>) { + walk_object_property_kind(self, prop); + } + + fn visit_object_property(&mut self, prop: &ObjectProperty<'a>) { + walk_object_property(self, prop); + } + + fn visit_property_key(&mut self, key: &PropertyKey<'a>) { + walk_property_key(self, key); + } + + fn visit_parenthesized_expression(&mut self, expr: &ParenthesizedExpression<'a>) { + walk_parenthesized_expression(self, expr); + } + + fn visit_private_in_expression(&mut self, expr: &PrivateInExpression<'a>) { + walk_private_in_expression(self, expr); + } + + fn visit_sequence_expression(&mut self, expr: &SequenceExpression<'a>) { + walk_sequence_expression(self, expr); + } + + fn visit_tagged_template_expression(&mut self, expr: &TaggedTemplateExpression<'a>) { + walk_tagged_template_expression(self, expr); + } + + fn visit_this_expression(&mut self, expr: &ThisExpression) { + walk_this_expression(self, expr); + } + + fn visit_unary_expression(&mut self, expr: &UnaryExpression<'a>) { + walk_unary_expression(self, expr); + } + + fn visit_update_expression(&mut self, expr: &UpdateExpression<'a>) { + walk_update_expression(self, expr); + } + + fn visit_yield_expression(&mut self, expr: &YieldExpression<'a>) { + walk_yield_expression(self, expr); + } + + fn visit_super(&mut self, expr: &Super) { + walk_super(self, expr); + } + + fn visit_assignment_target(&mut self, target: &AssignmentTarget<'a>) { + walk_assignment_target(self, target); + } + + fn visit_simple_assignment_target(&mut self, target: &SimpleAssignmentTarget<'a>) { + walk_simple_assignment_target(self, target); + } + + fn visit_assignment_target_pattern(&mut self, pat: &AssignmentTargetPattern<'a>) { + walk_assignment_target_pattern(self, pat); + } + + fn visit_array_assignment_target(&mut self, target: &ArrayAssignmentTarget<'a>) { + walk_array_assignment_target(self, target); + } + + fn visit_assignment_target_maybe_default(&mut self, target: &AssignmentTargetMaybeDefault<'a>) { + walk_assignment_target_maybe_default(self, target); + } + + fn visit_assignment_target_with_default(&mut self, target: &AssignmentTargetWithDefault<'a>) { + walk_assignment_target_with_default(self, target); + } + + fn visit_object_assignment_target(&mut self, target: &ObjectAssignmentTarget<'a>) { + walk_object_assignment_target(self, target); + } + + fn visit_assignment_target_property(&mut self, property: &AssignmentTargetProperty<'a>) { + walk_assignment_target_property(self, property); + } + + fn visit_assignment_target_property_identifier( + &mut self, + ident: &AssignmentTargetPropertyIdentifier<'a>, + ) { + walk_assignment_target_property_identifier(self, ident); + } + + fn visit_assignment_target_property_property( + &mut self, + property: &AssignmentTargetPropertyProperty<'a>, + ) { + walk_assignment_target_property_property(self, property); + } + + fn visit_assignment_target_rest(&mut self, rest: &AssignmentTargetRest<'a>) { + walk_assignment_target_rest(self, rest); + } + + /* ---------- Expression ---------- */ + + fn visit_jsx_element(&mut self, elem: &JSXElement<'a>) { + walk_jsx_element(self, elem); + } + + fn visit_jsx_opening_element(&mut self, elem: &JSXOpeningElement<'a>) { + walk_jsx_opening_element(self, elem); + } + + fn visit_jsx_closing_element(&mut self, elem: &JSXClosingElement<'a>) { + walk_jsx_closing_element(self, elem); + } + + fn visit_jsx_element_name(&mut self, name: &JSXElementName<'a>) { + walk_jsx_element_name(self, name); + } + + fn visit_jsx_identifier(&mut self, ident: &JSXIdentifier<'a>) { + walk_jsx_identifier(self, ident); + } + + fn visit_jsx_member_expression(&mut self, expr: &JSXMemberExpression<'a>) { + walk_jsx_member_expression(self, expr); + } + + fn visit_jsx_member_expression_object(&mut self, expr: &JSXMemberExpressionObject<'a>) { + walk_jsx_member_expression_object(self, expr); + } + + fn visit_jsx_namespaced_name(&mut self, name: &JSXNamespacedName<'a>) { + walk_jsx_namespaced_name(self, name); + } + + fn visit_jsx_attribute_item(&mut self, item: &JSXAttributeItem<'a>) { + walk_jsx_attribute_item(self, item); + } + + fn visit_jsx_attribute(&mut self, attribute: &JSXAttribute<'a>) { + walk_jsx_attribute(self, attribute); + } + + fn visit_jsx_spread_attribute(&mut self, attribute: &JSXSpreadAttribute<'a>) { + walk_jsx_spread_attribute(self, attribute); + } + + fn visit_jsx_attribute_value(&mut self, value: &JSXAttributeValue<'a>) { + walk_jsx_attribute_value(self, value); + } + + fn visit_jsx_expression_container(&mut self, expr: &JSXExpressionContainer<'a>) { + walk_jsx_expression_container(self, expr); + } + + fn visit_jsx_expression(&mut self, expr: &JSXExpression<'a>) { + walk_jsx_expression(self, expr); + } + + fn visit_jsx_fragment(&mut self, elem: &JSXFragment<'a>) { + walk_jsx_fragment(self, elem); + } + + fn visit_jsx_child(&mut self, child: &JSXChild<'a>) { + walk_jsx_child(self, child); + } + + fn visit_jsx_spread_child(&mut self, child: &JSXSpreadChild<'a>) { + walk_jsx_spread_child(self, child); + } + + fn visit_jsx_text(&mut self, child: &JSXText<'a>) { + walk_jsx_text(self, child); + } + + /* ---------- Pattern ---------- */ + + fn visit_binding_pattern(&mut self, pat: &BindingPattern<'a>) { + walk_binding_pattern(self, pat); + } + + fn visit_binding_identifier(&mut self, ident: &BindingIdentifier<'a>) { + walk_binding_identifier(self, ident); + } + + fn visit_object_pattern(&mut self, pat: &ObjectPattern<'a>) { + walk_object_pattern(self, pat); + } + + fn visit_binding_property(&mut self, prop: &BindingProperty<'a>) { + walk_binding_property(self, prop); + } + + fn visit_array_pattern(&mut self, pat: &ArrayPattern<'a>) { + walk_array_pattern(self, pat); + } + + fn visit_rest_element(&mut self, pat: &BindingRestElement<'a>) { + walk_rest_element(self, pat); + } + + fn visit_assignment_pattern(&mut self, pat: &AssignmentPattern<'a>) { + walk_assignment_pattern(self, pat); + } + + /* ---------- Identifier ---------- */ + + fn visit_identifier_reference(&mut self, ident: &IdentifierReference<'a>) { + walk_identifier_reference(self, ident); + } + + fn visit_private_identifier(&mut self, ident: &PrivateIdentifier<'a>) { + walk_private_identifier(self, ident); + } + + fn visit_label_identifier(&mut self, ident: &LabelIdentifier<'a>) { + walk_label_identifier(self, ident); + } - fn alloc(&self, t: &T) -> &'a T { - // SAFETY: - // This should be safe as long as `src` is an reference from the allocator. - // But honestly, I'm not really sure if this is safe. - unsafe { std::mem::transmute(t) } + fn visit_identifier_name(&mut self, ident: &IdentifierName<'a>) { + walk_identifier_name(self, ident); } - fn visit_program(&mut self, program: &Program<'a>) { - let kind = AstKind::Program(self.alloc(program)); - self.enter_scope({ + /* ---------- Literal ---------- */ + + fn visit_number_literal(&mut self, lit: &NumericLiteral<'a>) { + walk_number_literal(self, lit); + } + + fn visit_boolean_literal(&mut self, lit: &BooleanLiteral) { + walk_boolean_literal(self, lit); + } + + fn visit_null_literal(&mut self, lit: &NullLiteral) { + walk_null_literal(self, lit); + } + + fn visit_bigint_literal(&mut self, lit: &BigIntLiteral<'a>) { + walk_bigint_literal(self, lit); + } + + fn visit_string_literal(&mut self, lit: &StringLiteral<'a>) { + walk_string_literal(self, lit); + } + + fn visit_template_literal(&mut self, lit: &TemplateLiteral<'a>) { + walk_template_literal(self, lit); + } + + fn visit_reg_expr_literal(&mut self, lit: &RegExpLiteral<'a>) { + walk_reg_expr_literal(self, lit); + } + + fn visit_template_element(&mut self, elem: &TemplateElement) { + walk_template_element(self, elem); + } + + /* ---------- Module ---------- */ + + fn visit_module_declaration(&mut self, decl: &ModuleDeclaration<'a>) { + walk_module_declaration(self, decl); + } + + fn visit_import_declaration(&mut self, decl: &ImportDeclaration<'a>) { + walk_import_declaration(self, decl); + } + + fn visit_with_clause(&mut self, with_clause: &WithClause<'a>) { + walk_with_clause(self, with_clause); + } + + fn visit_import_attribute(&mut self, attribute: &ImportAttribute<'a>) { + walk_import_attribute(self, attribute); + } + + fn visit_import_attribute_key(&mut self, key: &ImportAttributeKey<'a>) { + walk_import_attribute_key(self, key); + } + + fn visit_import_declaration_specifier(&mut self, specifier: &ImportDeclarationSpecifier<'a>) { + walk_import_declaration_specifier(self, specifier); + } + + fn visit_import_specifier(&mut self, specifier: &ImportSpecifier<'a>) { + walk_import_specifier(self, specifier); + } + + fn visit_import_default_specifier(&mut self, specifier: &ImportDefaultSpecifier<'a>) { + walk_import_default_specifier(self, specifier); + } + + fn visit_import_name_specifier(&mut self, specifier: &ImportNamespaceSpecifier<'a>) { + walk_import_name_specifier(self, specifier); + } + + fn visit_export_all_declaration(&mut self, decl: &ExportAllDeclaration<'a>) { + walk_export_all_declaration(self, decl); + } + + fn visit_export_default_declaration(&mut self, decl: &ExportDefaultDeclaration<'a>) { + walk_export_default_declaration(self, decl); + } + + fn visit_export_named_declaration(&mut self, decl: &ExportNamedDeclaration<'a>) { + walk_export_named_declaration(self, decl); + } + + fn visit_enum_member(&mut self, member: &TSEnumMember<'a>) { + walk_enum_member(self, member); + } + + fn visit_enum(&mut self, decl: &TSEnumDeclaration<'a>) { + walk_enum(self, decl); + } + + fn visit_declaration(&mut self, decl: &Declaration<'a>) { + walk_declaration(self, decl); + } + + fn visit_ts_import_equals_declaration(&mut self, decl: &TSImportEqualsDeclaration<'a>) { + walk_ts_import_equals_declaration(self, decl); + } + + fn visit_ts_module_reference(&mut self, reference: &TSModuleReference<'a>) { + walk_ts_module_reference(self, reference); + } + + fn visit_ts_type_name(&mut self, name: &TSTypeName<'a>) { + walk_ts_type_name(self, name); + } + + fn visit_ts_external_module_reference(&mut self, reference: &TSExternalModuleReference<'a>) { + walk_ts_external_module_reference(self, reference); + } + + fn visit_ts_qualified_name(&mut self, name: &TSQualifiedName<'a>) { + walk_ts_qualified_name(self, name); + } + + fn visit_ts_module_declaration(&mut self, decl: &TSModuleDeclaration<'a>) { + walk_ts_module_declaration(self, decl); + } + + fn visit_ts_module_block(&mut self, block: &TSModuleBlock<'a>) { + walk_ts_module_block(self, block); + } + + fn visit_ts_type_alias_declaration(&mut self, decl: &TSTypeAliasDeclaration<'a>) { + walk_ts_type_alias_declaration(self, decl); + } + + fn visit_ts_interface_declaration(&mut self, decl: &TSInterfaceDeclaration<'a>) { + walk_ts_interface_declaration(self, decl); + } + + fn visit_ts_as_expression(&mut self, expr: &TSAsExpression<'a>) { + walk_ts_as_expression(self, expr); + } + + fn visit_ts_satisfies_expression(&mut self, expr: &TSSatisfiesExpression<'a>) { + walk_ts_satisfies_expression(self, expr); + } + + fn visit_ts_non_null_expression(&mut self, expr: &TSNonNullExpression<'a>) { + walk_ts_non_null_expression(self, expr); + } + + fn visit_ts_type_assertion(&mut self, expr: &TSTypeAssertion<'a>) { + walk_ts_type_assertion(self, expr); + } + + fn visit_ts_instantiation_expression(&mut self, expr: &TSInstantiationExpression<'a>) { + walk_ts_instantiation_expression(self, expr); + } + + fn visit_ts_type_annotation(&mut self, annotation: &TSTypeAnnotation<'a>) { + walk_ts_type_annotation(self, annotation); + } + + fn visit_ts_type(&mut self, ty: &TSType<'a>) { + walk_ts_type(self, ty); + } + + fn visit_ts_type_literal(&mut self, ty: &TSTypeLiteral<'a>) { + walk_ts_type_literal(self, ty); + } + + fn visit_ts_indexed_access_type(&mut self, ty: &TSIndexedAccessType<'a>) { + walk_ts_indexed_access_type(self, ty); + } + + fn visit_ts_type_predicate(&mut self, ty: &TSTypePredicate<'a>) { + walk_ts_type_predicate(self, ty); + } + + fn visit_ts_type_operator_type(&mut self, ty: &TSTypeOperator<'a>) { + walk_ts_type_operator_type(self, ty); + } + + fn visit_ts_tuple_type(&mut self, ty: &TSTupleType<'a>) { + walk_ts_tuple_type(self, ty); + } + + fn visit_ts_tuple_element(&mut self, ty: &TSTupleElement<'a>) { + walk_ts_tuple_element(self, ty); + } + + fn visit_ts_mapped_type(&mut self, ty: &TSMappedType<'a>) { + walk_ts_mapped_type(self, ty); + } + + fn visit_ts_function_type(&mut self, ty: &TSFunctionType<'a>) { + walk_ts_function_type(self, ty); + } + + fn visit_ts_type_parameter(&mut self, ty: &TSTypeParameter<'a>) { + walk_ts_type_parameter(self, ty); + } + + fn visit_ts_type_parameter_instantiation(&mut self, ty: &TSTypeParameterInstantiation<'a>) { + walk_ts_type_parameter_instantiation(self, ty); + } + + fn visit_ts_type_parameter_declaration(&mut self, ty: &TSTypeParameterDeclaration<'a>) { + walk_ts_type_parameter_declaration(self, ty); + } + + fn visit_ts_constructor_type(&mut self, ty: &TSConstructorType<'a>) { + walk_ts_constructor_type(self, ty); + } + + fn visit_ts_conditional_type(&mut self, ty: &TSConditionalType<'a>) { + walk_ts_conditional_type(self, ty); + } + + fn visit_ts_array_type(&mut self, ty: &TSArrayType<'a>) { + walk_ts_array_type(self, ty); + } + + fn visit_ts_null_keyword(&mut self, ty: &TSNullKeyword) { + walk_ts_null_keyword(self, ty); + } + + fn visit_ts_any_keyword(&mut self, ty: &TSAnyKeyword) { + walk_ts_any_keyword(self, ty); + } + + fn visit_ts_void_keyword(&mut self, ty: &TSVoidKeyword) { + walk_ts_void_keyword(self, ty); + } + + fn visit_ts_intersection_type(&mut self, ty: &TSIntersectionType<'a>) { + walk_ts_intersection_type(self, ty); + } + + fn visit_ts_type_reference(&mut self, ty: &TSTypeReference<'a>) { + walk_ts_type_reference(self, ty); + } + + fn visit_ts_union_type(&mut self, ty: &TSUnionType<'a>) { + walk_ts_union_type(self, ty); + } + + fn visit_ts_literal_type(&mut self, ty: &TSLiteralType<'a>) { + walk_ts_literal_type(self, ty); + } + + fn visit_ts_signature(&mut self, signature: &TSSignature<'a>) { + walk_ts_signature(self, signature); + } + + fn visit_ts_construct_signature_declaration( + &mut self, + signature: &TSConstructSignatureDeclaration<'a>, + ) { + walk_ts_construct_signature_declaration(self, signature); + } + + fn visit_ts_method_signature(&mut self, signature: &TSMethodSignature<'a>) { + walk_ts_method_signature(self, signature); + } + + fn visit_ts_index_signature_name(&mut self, name: &TSIndexSignatureName<'a>) { + walk_ts_index_signature_name(self, name); + } + + fn visit_ts_index_signature(&mut self, signature: &TSIndexSignature<'a>) { + walk_ts_index_signature(self, signature); + } + + fn visit_ts_property_signature(&mut self, signature: &TSPropertySignature<'a>) { + walk_ts_property_signature(self, signature); + } + + fn visit_ts_call_signature_declaration(&mut self, signature: &TSCallSignatureDeclaration<'a>) { + walk_ts_call_signature_declaration(self, signature); + } + + fn visit_ts_type_query(&mut self, ty: &TSTypeQuery<'a>) { + walk_ts_type_query(self, ty); + } + + fn visit_ts_import_type(&mut self, ty: &TSImportType<'a>) { + walk_ts_import_type(self, ty); + } + + fn visit_ts_import_attributes(&mut self, attributes: &TSImportAttributes<'a>) { + walk_ts_import_attributes(self, attributes); + } + + fn visit_ts_import_attribute(&mut self, attribute: &TSImportAttribute<'a>) { + walk_ts_import_attribute(self, attribute); + } + + fn visit_ts_import_attribute_name(&mut self, name: &TSImportAttributeName<'a>) { + walk_ts_import_attribute_name(self, name); + } +} + +pub mod walk { + use super::*; + + pub fn walk_program<'a, V: Visit<'a>>(visitor: &mut V, program: &Program<'a>) { + let kind = AstKind::Program(visitor.alloc(program)); + visitor.enter_scope({ let mut flags = ScopeFlags::Top; if program.is_strict() { flags |= ScopeFlags::StrictMode; } flags }); - self.enter_node(kind); + visitor.enter_node(kind); for directive in &program.directives { - self.visit_directive(directive); + visitor.visit_directive(directive); } - self.visit_statements(&program.body); - self.leave_node(kind); - self.leave_scope(); + visitor.visit_statements(&program.body); + visitor.leave_node(kind); + visitor.leave_scope(); } /* ---------- Statement ---------- */ - fn visit_statements(&mut self, stmts: &Vec<'a, Statement<'a>>) { + pub fn walk_statements<'a, V: Visit<'a>>(visitor: &mut V, stmts: &Vec<'a, Statement<'a>>) { for stmt in stmts { - self.visit_statement(stmt); + visitor.visit_statement(stmt); } } - fn visit_statement(&mut self, stmt: &Statement<'a>) { - self.visit_statement_match(stmt); - } - - fn visit_statement_match(&mut self, stmt: &Statement<'a>) { + pub fn walk_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &Statement<'a>) { match stmt { - Statement::BlockStatement(stmt) => self.visit_block_statement(stmt), - Statement::BreakStatement(stmt) => self.visit_break_statement(stmt), - Statement::ContinueStatement(stmt) => self.visit_continue_statement(stmt), - Statement::DebuggerStatement(stmt) => self.visit_debugger_statement(stmt), - Statement::DoWhileStatement(stmt) => self.visit_do_while_statement(stmt), - Statement::EmptyStatement(stmt) => self.visit_empty_statement(stmt), - Statement::ExpressionStatement(stmt) => self.visit_expression_statement(stmt), - Statement::ForInStatement(stmt) => self.visit_for_in_statement(stmt), - Statement::ForOfStatement(stmt) => self.visit_for_of_statement(stmt), - Statement::ForStatement(stmt) => self.visit_for_statement(stmt), - Statement::IfStatement(stmt) => self.visit_if_statement(stmt), - Statement::LabeledStatement(stmt) => self.visit_labeled_statement(stmt), - Statement::ReturnStatement(stmt) => self.visit_return_statement(stmt), - Statement::SwitchStatement(stmt) => self.visit_switch_statement(stmt), - Statement::ThrowStatement(stmt) => self.visit_throw_statement(stmt), - Statement::TryStatement(stmt) => self.visit_try_statement(stmt), - Statement::WhileStatement(stmt) => self.visit_while_statement(stmt), - Statement::WithStatement(stmt) => self.visit_with_statement(stmt), - - Statement::ModuleDeclaration(decl) => self.visit_module_declaration(decl), - Statement::Declaration(decl) => self.visit_declaration(decl), - } - } - - fn visit_block_statement(&mut self, stmt: &BlockStatement<'a>) { - let kind = AstKind::BlockStatement(self.alloc(stmt)); - self.enter_scope(ScopeFlags::empty()); - self.enter_node(kind); - self.visit_statements(&stmt.body); - self.leave_node(kind); - self.leave_scope(); - } - - fn visit_break_statement(&mut self, stmt: &BreakStatement<'a>) { - let kind = AstKind::BreakStatement(self.alloc(stmt)); - self.enter_node(kind); + Statement::BlockStatement(stmt) => visitor.visit_block_statement(stmt), + Statement::BreakStatement(stmt) => visitor.visit_break_statement(stmt), + Statement::ContinueStatement(stmt) => visitor.visit_continue_statement(stmt), + Statement::DebuggerStatement(stmt) => visitor.visit_debugger_statement(stmt), + Statement::DoWhileStatement(stmt) => visitor.visit_do_while_statement(stmt), + Statement::EmptyStatement(stmt) => visitor.visit_empty_statement(stmt), + Statement::ExpressionStatement(stmt) => visitor.visit_expression_statement(stmt), + Statement::ForInStatement(stmt) => visitor.visit_for_in_statement(stmt), + Statement::ForOfStatement(stmt) => visitor.visit_for_of_statement(stmt), + Statement::ForStatement(stmt) => visitor.visit_for_statement(stmt), + Statement::IfStatement(stmt) => visitor.visit_if_statement(stmt), + Statement::LabeledStatement(stmt) => visitor.visit_labeled_statement(stmt), + Statement::ReturnStatement(stmt) => visitor.visit_return_statement(stmt), + Statement::SwitchStatement(stmt) => visitor.visit_switch_statement(stmt), + Statement::ThrowStatement(stmt) => visitor.visit_throw_statement(stmt), + Statement::TryStatement(stmt) => visitor.visit_try_statement(stmt), + Statement::WhileStatement(stmt) => visitor.visit_while_statement(stmt), + Statement::WithStatement(stmt) => visitor.visit_with_statement(stmt), + + Statement::ModuleDeclaration(decl) => visitor.visit_module_declaration(decl), + Statement::Declaration(decl) => visitor.visit_declaration(decl), + } + } + + pub fn walk_block_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &BlockStatement<'a>) { + let kind = AstKind::BlockStatement(visitor.alloc(stmt)); + visitor.enter_scope(ScopeFlags::empty()); + visitor.enter_node(kind); + visitor.visit_statements(&stmt.body); + visitor.leave_node(kind); + visitor.leave_scope(); + } + + pub fn walk_break_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &BreakStatement<'a>) { + let kind = AstKind::BreakStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); if let Some(break_target) = &stmt.label { - self.visit_label_identifier(break_target); + visitor.visit_label_identifier(break_target); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_continue_statement(&mut self, stmt: &ContinueStatement<'a>) { - let kind = AstKind::ContinueStatement(self.alloc(stmt)); - self.enter_node(kind); + pub fn walk_continue_statement<'a, V: Visit<'a>>( + visitor: &mut V, + stmt: &ContinueStatement<'a>, + ) { + let kind = AstKind::ContinueStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); if let Some(continue_target) = &stmt.label { - self.visit_label_identifier(continue_target); + visitor.visit_label_identifier(continue_target); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_debugger_statement(&mut self, stmt: &DebuggerStatement) { - let kind = AstKind::DebuggerStatement(self.alloc(stmt)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_debugger_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &DebuggerStatement) { + let kind = AstKind::DebuggerStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_do_while_statement(&mut self, stmt: &DoWhileStatement<'a>) { - let kind = AstKind::DoWhileStatement(self.alloc(stmt)); - self.enter_node(kind); - self.visit_statement(&stmt.body); - self.visit_expression(&stmt.test); - self.leave_node(kind); + pub fn walk_do_while_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &DoWhileStatement<'a>) { + let kind = AstKind::DoWhileStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.visit_statement(&stmt.body); + visitor.visit_expression(&stmt.test); + visitor.leave_node(kind); } - fn visit_empty_statement(&mut self, stmt: &EmptyStatement) { - let kind = AstKind::EmptyStatement(self.alloc(stmt)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_empty_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &EmptyStatement) { + let kind = AstKind::EmptyStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_expression_statement(&mut self, stmt: &ExpressionStatement<'a>) { - let kind = AstKind::ExpressionStatement(self.alloc(stmt)); - self.enter_node(kind); - self.visit_expression(&stmt.expression); - self.leave_node(kind); + pub fn walk_expression_statement<'a, V: Visit<'a>>( + visitor: &mut V, + stmt: &ExpressionStatement<'a>, + ) { + let kind = AstKind::ExpressionStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.visit_expression(&stmt.expression); + visitor.leave_node(kind); } - fn visit_for_statement(&mut self, stmt: &ForStatement<'a>) { - let kind = AstKind::ForStatement(self.alloc(stmt)); + pub fn walk_for_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &ForStatement<'a>) { + let kind = AstKind::ForStatement(visitor.alloc(stmt)); let is_lexical_declaration = stmt.init.as_ref().is_some_and(ForStatementInit::is_lexical_declaration); if is_lexical_declaration { - self.enter_scope(ScopeFlags::empty()); + visitor.enter_scope(ScopeFlags::empty()); } - self.enter_node(kind); + visitor.enter_node(kind); if let Some(init) = &stmt.init { - self.visit_for_statement_init(init); + visitor.visit_for_statement_init(init); } if let Some(test) = &stmt.test { - self.visit_expression(test); + visitor.visit_expression(test); } if let Some(update) = &stmt.update { - self.visit_expression(update); + visitor.visit_expression(update); } - self.visit_statement(&stmt.body); - self.leave_node(kind); + visitor.visit_statement(&stmt.body); + visitor.leave_node(kind); if is_lexical_declaration { - self.leave_scope(); + visitor.leave_scope(); } } - fn visit_for_statement_init(&mut self, init: &ForStatementInit<'a>) { - let kind = AstKind::ForStatementInit(self.alloc(init)); - self.enter_node(kind); + pub fn walk_for_statement_init<'a, V: Visit<'a>>(visitor: &mut V, init: &ForStatementInit<'a>) { + let kind = AstKind::ForStatementInit(visitor.alloc(init)); + visitor.enter_node(kind); match init { ForStatementInit::UsingDeclaration(decl) => { - self.visit_using_declaration(decl); + visitor.visit_using_declaration(decl); } ForStatementInit::VariableDeclaration(decl) => { - self.visit_variable_declaration(decl); + visitor.visit_variable_declaration(decl); } - ForStatementInit::Expression(expr) => self.visit_expression(expr), + ForStatementInit::Expression(expr) => visitor.visit_expression(expr), } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_for_in_statement(&mut self, stmt: &ForInStatement<'a>) { - let kind = AstKind::ForInStatement(self.alloc(stmt)); + pub fn walk_for_in_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &ForInStatement<'a>) { + let kind = AstKind::ForInStatement(visitor.alloc(stmt)); let is_lexical_declaration = stmt.left.is_lexical_declaration(); if is_lexical_declaration { - self.enter_scope(ScopeFlags::empty()); + visitor.enter_scope(ScopeFlags::empty()); } - self.enter_node(kind); - self.visit_for_statement_left(&stmt.left); - self.visit_expression(&stmt.right); - self.visit_statement(&stmt.body); - self.leave_node(kind); + visitor.enter_node(kind); + visitor.visit_for_statement_left(&stmt.left); + visitor.visit_expression(&stmt.right); + visitor.visit_statement(&stmt.body); + visitor.leave_node(kind); if is_lexical_declaration { - self.leave_scope(); + visitor.leave_scope(); } } - fn visit_for_of_statement(&mut self, stmt: &ForOfStatement<'a>) { - let kind = AstKind::ForOfStatement(self.alloc(stmt)); + pub fn walk_for_of_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &ForOfStatement<'a>) { + let kind = AstKind::ForOfStatement(visitor.alloc(stmt)); let is_lexical_declaration = stmt.left.is_lexical_declaration(); if is_lexical_declaration { - self.enter_scope(ScopeFlags::empty()); + visitor.enter_scope(ScopeFlags::empty()); } - self.enter_node(kind); - self.visit_for_statement_left(&stmt.left); - self.visit_expression(&stmt.right); - self.visit_statement(&stmt.body); - self.leave_node(kind); + visitor.enter_node(kind); + visitor.visit_for_statement_left(&stmt.left); + visitor.visit_expression(&stmt.right); + visitor.visit_statement(&stmt.body); + visitor.leave_node(kind); if is_lexical_declaration { - self.leave_scope(); + visitor.leave_scope(); } } - fn visit_for_statement_left(&mut self, left: &ForStatementLeft<'a>) { + pub fn walk_for_statement_left<'a, V: Visit<'a>>(visitor: &mut V, left: &ForStatementLeft<'a>) { match left { ForStatementLeft::VariableDeclaration(decl) => { - self.visit_variable_declaration(decl); + visitor.visit_variable_declaration(decl); } - ForStatementLeft::AssignmentTarget(target) => self.visit_assignment_target(target), + ForStatementLeft::AssignmentTarget(target) => visitor.visit_assignment_target(target), ForStatementLeft::UsingDeclaration(decl) => { - self.visit_using_declaration(decl); + visitor.visit_using_declaration(decl); } } } - fn visit_if_statement(&mut self, stmt: &IfStatement<'a>) { - let kind = AstKind::IfStatement(self.alloc(stmt)); - self.enter_node(kind); - self.visit_expression(&stmt.test); - self.visit_statement(&stmt.consequent); + pub fn walk_if_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &IfStatement<'a>) { + let kind = AstKind::IfStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.visit_expression(&stmt.test); + visitor.visit_statement(&stmt.consequent); if let Some(alternate) = &stmt.alternate { - self.visit_statement(alternate); + visitor.visit_statement(alternate); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_labeled_statement(&mut self, stmt: &LabeledStatement<'a>) { - let kind = AstKind::LabeledStatement(self.alloc(stmt)); - self.enter_node(kind); - self.visit_label_identifier(&stmt.label); - self.visit_statement(&stmt.body); - self.leave_node(kind); + pub fn walk_labeled_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &LabeledStatement<'a>) { + let kind = AstKind::LabeledStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.visit_label_identifier(&stmt.label); + visitor.visit_statement(&stmt.body); + visitor.leave_node(kind); } - fn visit_return_statement(&mut self, stmt: &ReturnStatement<'a>) { - let kind = AstKind::ReturnStatement(self.alloc(stmt)); - self.enter_node(kind); + pub fn walk_return_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &ReturnStatement<'a>) { + let kind = AstKind::ReturnStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); if let Some(arg) = &stmt.argument { - self.visit_expression(arg); + visitor.visit_expression(arg); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_switch_statement(&mut self, stmt: &SwitchStatement<'a>) { - let kind = AstKind::SwitchStatement(self.alloc(stmt)); - self.enter_node(kind); - self.visit_expression(&stmt.discriminant); - self.enter_scope(ScopeFlags::empty()); + pub fn walk_switch_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &SwitchStatement<'a>) { + let kind = AstKind::SwitchStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.visit_expression(&stmt.discriminant); + visitor.enter_scope(ScopeFlags::empty()); for case in &stmt.cases { - self.visit_switch_case(case); + visitor.visit_switch_case(case); } - self.leave_scope(); - self.leave_node(kind); + visitor.leave_scope(); + visitor.leave_node(kind); } - fn visit_switch_case(&mut self, case: &SwitchCase<'a>) { - let kind = AstKind::SwitchCase(self.alloc(case)); - self.enter_node(kind); + pub fn walk_switch_case<'a, V: Visit<'a>>(visitor: &mut V, case: &SwitchCase<'a>) { + let kind = AstKind::SwitchCase(visitor.alloc(case)); + visitor.enter_node(kind); if let Some(expr) = &case.test { - self.visit_expression(expr); + visitor.visit_expression(expr); } - self.visit_statements(&case.consequent); - self.leave_node(kind); + visitor.visit_statements(&case.consequent); + visitor.leave_node(kind); } - fn visit_throw_statement(&mut self, stmt: &ThrowStatement<'a>) { - let kind = AstKind::ThrowStatement(self.alloc(stmt)); - self.enter_node(kind); - self.visit_expression(&stmt.argument); - self.leave_node(kind); + pub fn walk_throw_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &ThrowStatement<'a>) { + let kind = AstKind::ThrowStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.visit_expression(&stmt.argument); + visitor.leave_node(kind); } - fn visit_try_statement(&mut self, stmt: &TryStatement<'a>) { - let kind = AstKind::TryStatement(self.alloc(stmt)); - self.enter_node(kind); - self.visit_block_statement(&stmt.block); + pub fn walk_try_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &TryStatement<'a>) { + let kind = AstKind::TryStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.visit_block_statement(&stmt.block); if let Some(handler) = &stmt.handler { - self.visit_catch_clause(handler); + visitor.visit_catch_clause(handler); } if let Some(finalizer) = &stmt.finalizer { - self.visit_finally_clause(finalizer); + visitor.visit_finally_clause(finalizer); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_catch_clause(&mut self, clause: &CatchClause<'a>) { - let kind = AstKind::CatchClause(self.alloc(clause)); - self.enter_scope(ScopeFlags::empty()); - self.enter_node(kind); + pub fn walk_catch_clause<'a, V: Visit<'a>>(visitor: &mut V, clause: &CatchClause<'a>) { + let kind = AstKind::CatchClause(visitor.alloc(clause)); + visitor.enter_scope(ScopeFlags::empty()); + visitor.enter_node(kind); if let Some(param) = &clause.param { - self.visit_binding_pattern(param); + visitor.visit_binding_pattern(param); } - self.visit_statements(&clause.body.body); - self.leave_node(kind); - self.leave_scope(); + visitor.visit_statements(&clause.body.body); + visitor.leave_node(kind); + visitor.leave_scope(); } - fn visit_finally_clause(&mut self, clause: &BlockStatement<'a>) { - let kind = AstKind::FinallyClause(self.alloc(clause)); - self.enter_node(kind); - self.visit_block_statement(clause); - self.leave_node(kind); + pub fn walk_finally_clause<'a, V: Visit<'a>>(visitor: &mut V, clause: &BlockStatement<'a>) { + let kind = AstKind::FinallyClause(visitor.alloc(clause)); + visitor.enter_node(kind); + visitor.visit_block_statement(clause); + visitor.leave_node(kind); } - fn visit_while_statement(&mut self, stmt: &WhileStatement<'a>) { - let kind = AstKind::WhileStatement(self.alloc(stmt)); - self.enter_node(kind); - self.visit_expression(&stmt.test); - self.visit_statement(&stmt.body); - self.leave_node(kind); + pub fn walk_while_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &WhileStatement<'a>) { + let kind = AstKind::WhileStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.visit_expression(&stmt.test); + visitor.visit_statement(&stmt.body); + visitor.leave_node(kind); } - fn visit_with_statement(&mut self, stmt: &WithStatement<'a>) { - let kind = AstKind::WithStatement(self.alloc(stmt)); - self.enter_node(kind); - self.visit_expression(&stmt.object); - self.visit_statement(&stmt.body); - self.leave_node(kind); + pub fn walk_with_statement<'a, V: Visit<'a>>(visitor: &mut V, stmt: &WithStatement<'a>) { + let kind = AstKind::WithStatement(visitor.alloc(stmt)); + visitor.enter_node(kind); + visitor.visit_expression(&stmt.object); + visitor.visit_statement(&stmt.body); + visitor.leave_node(kind); } - fn visit_directive(&mut self, directive: &Directive<'a>) { - let kind = AstKind::Directive(self.alloc(directive)); - self.enter_node(kind); - self.visit_string_literal(&directive.expression); - self.leave_node(kind); + pub fn walk_directive<'a, V: Visit<'a>>(visitor: &mut V, directive: &Directive<'a>) { + let kind = AstKind::Directive(visitor.alloc(directive)); + visitor.enter_node(kind); + visitor.visit_string_literal(&directive.expression); + visitor.leave_node(kind); } /* ---------- Declaration ---------- */ - fn visit_variable_declaration(&mut self, decl: &VariableDeclaration<'a>) { - let kind = AstKind::VariableDeclaration(self.alloc(decl)); - self.enter_node(kind); + pub fn walk_variable_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + decl: &VariableDeclaration<'a>, + ) { + let kind = AstKind::VariableDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); for declarator in &decl.declarations { - self.visit_variable_declarator(declarator); + visitor.visit_variable_declarator(declarator); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) { - let kind = AstKind::VariableDeclarator(self.alloc(declarator)); - self.enter_node(kind); - self.visit_binding_pattern(&declarator.id); + pub fn walk_variable_declarator<'a, V: Visit<'a>>( + visitor: &mut V, + declarator: &VariableDeclarator<'a>, + ) { + let kind = AstKind::VariableDeclarator(visitor.alloc(declarator)); + visitor.enter_node(kind); + visitor.visit_binding_pattern(&declarator.id); if let Some(init) = &declarator.init { - self.visit_expression(init); + visitor.visit_expression(init); } - self.leave_node(kind); + visitor.leave_node(kind); } /* ---------- Function ---------- */ - fn visit_function(&mut self, func: &Function<'a>, flags: Option) { - let kind = AstKind::Function(self.alloc(func)); - self.enter_scope({ + pub fn walk_function<'a, V: Visit<'a>>( + visitor: &mut V, + func: &Function<'a>, + flags: Option, + ) { + let kind = AstKind::Function(visitor.alloc(func)); + visitor.enter_scope({ let mut flags = flags.unwrap_or(ScopeFlags::empty()) | ScopeFlags::Function; if func.is_strict() { flags |= ScopeFlags::StrictMode; } flags }); - self.enter_node(kind); + visitor.enter_node(kind); if let Some(ident) = &func.id { - self.visit_binding_identifier(ident); + visitor.visit_binding_identifier(ident); } - self.visit_formal_parameters(&func.params); + visitor.visit_formal_parameters(&func.params); if let Some(body) = &func.body { - self.visit_function_body(body); + visitor.visit_function_body(body); } if let Some(parameters) = &func.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); + visitor.visit_ts_type_parameter_declaration(parameters); } if let Some(annotation) = &func.return_type { - self.visit_ts_type_annotation(annotation); + visitor.visit_ts_type_annotation(annotation); } - self.leave_node(kind); - self.leave_scope(); + visitor.leave_node(kind); + visitor.leave_scope(); } - fn visit_function_body(&mut self, body: &FunctionBody<'a>) { - let kind = AstKind::FunctionBody(self.alloc(body)); - self.enter_node(kind); + pub fn walk_function_body<'a, V: Visit<'a>>(visitor: &mut V, body: &FunctionBody<'a>) { + let kind = AstKind::FunctionBody(visitor.alloc(body)); + visitor.enter_node(kind); for directive in &body.directives { - self.visit_directive(directive); + visitor.visit_directive(directive); } - self.visit_statements(&body.statements); - self.leave_node(kind); + visitor.visit_statements(&body.statements); + visitor.leave_node(kind); } - fn visit_formal_parameters(&mut self, params: &FormalParameters<'a>) { - let kind = AstKind::FormalParameters(self.alloc(params)); - self.enter_node(kind); + pub fn walk_formal_parameters<'a, V: Visit<'a>>( + visitor: &mut V, + params: &FormalParameters<'a>, + ) { + let kind = AstKind::FormalParameters(visitor.alloc(params)); + visitor.enter_node(kind); for param in ¶ms.items { - self.visit_formal_parameter(param); + visitor.visit_formal_parameter(param); } if let Some(rest) = ¶ms.rest { - self.visit_rest_element(rest); + visitor.visit_rest_element(rest); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_formal_parameter(&mut self, param: &FormalParameter<'a>) { - let kind = AstKind::FormalParameter(self.alloc(param)); - self.enter_node(kind); + pub fn walk_formal_parameter<'a, V: Visit<'a>>(visitor: &mut V, param: &FormalParameter<'a>) { + let kind = AstKind::FormalParameter(visitor.alloc(param)); + visitor.enter_node(kind); for decorator in ¶m.decorators { - self.visit_decorator(decorator); + visitor.visit_decorator(decorator); } - self.visit_binding_pattern(¶m.pattern); - self.leave_node(kind); + visitor.visit_binding_pattern(¶m.pattern); + visitor.leave_node(kind); } /* ---------- Class ---------- */ - fn visit_decorator(&mut self, decorator: &Decorator<'a>) { - let kind = AstKind::Decorator(self.alloc(decorator)); - self.enter_node(kind); - self.visit_expression(&decorator.expression); - self.leave_node(kind); + pub fn walk_decorator<'a, V: Visit<'a>>(visitor: &mut V, decorator: &Decorator<'a>) { + let kind = AstKind::Decorator(visitor.alloc(decorator)); + visitor.enter_node(kind); + visitor.visit_expression(&decorator.expression); + visitor.leave_node(kind); } - fn visit_class(&mut self, class: &Class<'a>) { + pub fn walk_class<'a, V: Visit<'a>>(visitor: &mut V, class: &Class<'a>) { // Class level decorators are transpiled as functions outside of the class taking the class - // itself as argument. They should be visited before class is entered. E.g., they inherit + // itvisitor as argument. They should be visited before class is entered. E.g., they inherit // strict mode from the enclosing scope rather than from class. for decorator in &class.decorators { - self.visit_decorator(decorator); + visitor.visit_decorator(decorator); } - let kind = AstKind::Class(self.alloc(class)); + let kind = AstKind::Class(visitor.alloc(class)); // FIXME(don): Should we enter a scope when visiting class declarations? let is_class_expr = class.r#type == ClassType::ClassExpression; if is_class_expr { // Class expressions create a temporary scope with the class name as its only variable // E.g., `let c = class A { foo() { console.log(A) } }` - self.enter_scope(ScopeFlags::empty()); + visitor.enter_scope(ScopeFlags::empty()); } - self.enter_node(kind); + visitor.enter_node(kind); if let Some(id) = &class.id { - self.visit_binding_identifier(id); + visitor.visit_binding_identifier(id); } if let Some(parameters) = &class.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); + visitor.visit_ts_type_parameter_declaration(parameters); } if let Some(super_class) = &class.super_class { - self.visit_class_heritage(super_class); + visitor.visit_class_heritage(super_class); } if let Some(super_parameters) = &class.super_type_parameters { - self.visit_ts_type_parameter_instantiation(super_parameters); + visitor.visit_ts_type_parameter_instantiation(super_parameters); } - self.visit_class_body(&class.body); - self.leave_node(kind); + visitor.visit_class_body(&class.body); + visitor.leave_node(kind); if is_class_expr { - self.leave_scope(); + visitor.leave_scope(); } } - fn visit_class_heritage(&mut self, expr: &Expression<'a>) { - let kind = AstKind::ClassHeritage(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(expr); - self.leave_node(kind); + pub fn walk_class_heritage<'a, V: Visit<'a>>(visitor: &mut V, expr: &Expression<'a>) { + let kind = AstKind::ClassHeritage(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(expr); + visitor.leave_node(kind); } - fn visit_class_body(&mut self, body: &ClassBody<'a>) { - let kind = AstKind::ClassBody(self.alloc(body)); - self.enter_node(kind); + pub fn walk_class_body<'a, V: Visit<'a>>(visitor: &mut V, body: &ClassBody<'a>) { + let kind = AstKind::ClassBody(visitor.alloc(body)); + visitor.enter_node(kind); for elem in &body.body { - self.visit_class_element(elem); + visitor.visit_class_element(elem); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_class_element(&mut self, elem: &ClassElement<'a>) { + pub fn walk_class_element<'a, V: Visit<'a>>(visitor: &mut V, elem: &ClassElement<'a>) { match elem { - ClassElement::StaticBlock(block) => self.visit_static_block(block), - ClassElement::MethodDefinition(def) => self.visit_method_definition(def), - ClassElement::PropertyDefinition(def) => self.visit_property_definition(def), + ClassElement::StaticBlock(block) => visitor.visit_static_block(block), + ClassElement::MethodDefinition(def) => visitor.visit_method_definition(def), + ClassElement::PropertyDefinition(def) => visitor.visit_property_definition(def), ClassElement::AccessorProperty(_def) => { /* TODO */ } - ClassElement::TSIndexSignature(sig) => self.visit_ts_index_signature(sig), + ClassElement::TSIndexSignature(sig) => visitor.visit_ts_index_signature(sig), } } - fn visit_static_block(&mut self, block: &StaticBlock<'a>) { - let kind = AstKind::StaticBlock(self.alloc(block)); - self.enter_scope(ScopeFlags::ClassStaticBlock); - self.enter_node(kind); - self.visit_statements(&block.body); - self.leave_node(kind); - self.leave_scope(); + pub fn walk_static_block<'a, V: Visit<'a>>(visitor: &mut V, block: &StaticBlock<'a>) { + let kind = AstKind::StaticBlock(visitor.alloc(block)); + visitor.enter_scope(ScopeFlags::ClassStaticBlock); + visitor.enter_node(kind); + visitor.visit_statements(&block.body); + visitor.leave_node(kind); + visitor.leave_scope(); } - fn visit_method_definition(&mut self, def: &MethodDefinition<'a>) { - let kind = AstKind::MethodDefinition(self.alloc(def)); - self.enter_node(kind); + pub fn walk_method_definition<'a, V: Visit<'a>>(visitor: &mut V, def: &MethodDefinition<'a>) { + let kind = AstKind::MethodDefinition(visitor.alloc(def)); + visitor.enter_node(kind); for decorator in &def.decorators { - self.visit_decorator(decorator); + visitor.visit_decorator(decorator); } let flags = match def.kind { MethodDefinitionKind::Get => ScopeFlags::GetAccessor, @@ -507,1434 +1317,1635 @@ pub trait Visit<'a>: Sized { MethodDefinitionKind::Constructor => ScopeFlags::Constructor, MethodDefinitionKind::Method => ScopeFlags::empty(), }; - self.visit_property_key(&def.key); - self.visit_function(&def.value, Some(flags)); - self.leave_node(kind); + visitor.visit_property_key(&def.key); + visitor.visit_function(&def.value, Some(flags)); + visitor.leave_node(kind); } - fn visit_property_definition(&mut self, def: &PropertyDefinition<'a>) { - let kind = AstKind::PropertyDefinition(self.alloc(def)); - self.enter_node(kind); + pub fn walk_property_definition<'a, V: Visit<'a>>( + visitor: &mut V, + def: &PropertyDefinition<'a>, + ) { + let kind = AstKind::PropertyDefinition(visitor.alloc(def)); + visitor.enter_node(kind); for decorator in &def.decorators { - self.visit_decorator(decorator); + visitor.visit_decorator(decorator); } - self.visit_property_key(&def.key); + visitor.visit_property_key(&def.key); if let Some(value) = &def.value { - self.visit_expression(value); + visitor.visit_expression(value); } if let Some(annotation) = &def.type_annotation { - self.visit_ts_type_annotation(annotation); + visitor.visit_ts_type_annotation(annotation); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_using_declaration(&mut self, decl: &UsingDeclaration<'a>) { - let kind = AstKind::UsingDeclaration(self.alloc(decl)); - self.enter_node(kind); + pub fn walk_using_declaration<'a, V: Visit<'a>>(visitor: &mut V, decl: &UsingDeclaration<'a>) { + let kind = AstKind::UsingDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); for decl in &decl.declarations { - self.visit_variable_declarator(decl); + visitor.visit_variable_declarator(decl); } - self.leave_node(kind); + visitor.leave_node(kind); } /* ---------- Expression ---------- */ - fn visit_expression(&mut self, expr: &Expression<'a>) { - self.visit_expression_match(expr); - } - - fn visit_expression_match(&mut self, expr: &Expression<'a>) { + pub fn walk_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &Expression<'a>) { match expr { - Expression::BigintLiteral(lit) => self.visit_bigint_literal(lit), - Expression::BooleanLiteral(lit) => self.visit_boolean_literal(lit), - Expression::NullLiteral(lit) => self.visit_null_literal(lit), - Expression::NumericLiteral(lit) => self.visit_number_literal(lit), - Expression::RegExpLiteral(lit) => self.visit_reg_expr_literal(lit), - Expression::StringLiteral(lit) => self.visit_string_literal(lit), - Expression::TemplateLiteral(lit) => self.visit_template_literal(lit), - Expression::Identifier(ident) => self.visit_identifier_reference(ident), - Expression::MetaProperty(meta) => self.visit_meta_property(meta), - - Expression::ArrayExpression(expr) => self.visit_array_expression(expr), - Expression::ArrowFunctionExpression(expr) => self.visit_arrow_expression(expr), - Expression::AssignmentExpression(expr) => self.visit_assignment_expression(expr), - Expression::AwaitExpression(expr) => self.visit_await_expression(expr), - Expression::BinaryExpression(expr) => self.visit_binary_expression(expr), - Expression::CallExpression(expr) => self.visit_call_expression(expr), - Expression::ChainExpression(expr) => self.visit_chain_expression(expr), + Expression::BigintLiteral(lit) => visitor.visit_bigint_literal(lit), + Expression::BooleanLiteral(lit) => visitor.visit_boolean_literal(lit), + Expression::NullLiteral(lit) => visitor.visit_null_literal(lit), + Expression::NumericLiteral(lit) => visitor.visit_number_literal(lit), + Expression::RegExpLiteral(lit) => visitor.visit_reg_expr_literal(lit), + Expression::StringLiteral(lit) => visitor.visit_string_literal(lit), + Expression::TemplateLiteral(lit) => visitor.visit_template_literal(lit), + Expression::Identifier(ident) => visitor.visit_identifier_reference(ident), + Expression::MetaProperty(meta) => visitor.visit_meta_property(meta), + + Expression::ArrayExpression(expr) => visitor.visit_array_expression(expr), + Expression::ArrowFunctionExpression(expr) => visitor.visit_arrow_expression(expr), + Expression::AssignmentExpression(expr) => visitor.visit_assignment_expression(expr), + Expression::AwaitExpression(expr) => visitor.visit_await_expression(expr), + Expression::BinaryExpression(expr) => visitor.visit_binary_expression(expr), + Expression::CallExpression(expr) => visitor.visit_call_expression(expr), + Expression::ChainExpression(expr) => visitor.visit_chain_expression(expr), Expression::ClassExpression(expr) => { debug_assert_eq!(expr.r#type, ClassType::ClassExpression); - self.visit_class(expr); + visitor.visit_class(expr); } - Expression::ConditionalExpression(expr) => self.visit_conditional_expression(expr), - Expression::FunctionExpression(expr) => self.visit_function(expr, None), - Expression::ImportExpression(expr) => self.visit_import_expression(expr), - Expression::LogicalExpression(expr) => self.visit_logical_expression(expr), - Expression::MemberExpression(expr) => self.visit_member_expression(expr), - Expression::NewExpression(expr) => self.visit_new_expression(expr), - Expression::ObjectExpression(expr) => self.visit_object_expression(expr), + Expression::ConditionalExpression(expr) => visitor.visit_conditional_expression(expr), + Expression::FunctionExpression(expr) => visitor.visit_function(expr, None), + Expression::ImportExpression(expr) => visitor.visit_import_expression(expr), + Expression::LogicalExpression(expr) => visitor.visit_logical_expression(expr), + Expression::MemberExpression(expr) => visitor.visit_member_expression(expr), + Expression::NewExpression(expr) => visitor.visit_new_expression(expr), + Expression::ObjectExpression(expr) => visitor.visit_object_expression(expr), Expression::ParenthesizedExpression(expr) => { - self.visit_parenthesized_expression(expr); + visitor.visit_parenthesized_expression(expr); } - Expression::PrivateInExpression(expr) => self.visit_private_in_expression(expr), - Expression::SequenceExpression(expr) => self.visit_sequence_expression(expr), + Expression::PrivateInExpression(expr) => visitor.visit_private_in_expression(expr), + Expression::SequenceExpression(expr) => visitor.visit_sequence_expression(expr), Expression::TaggedTemplateExpression(expr) => { - self.visit_tagged_template_expression(expr); + visitor.visit_tagged_template_expression(expr); } - Expression::ThisExpression(expr) => self.visit_this_expression(expr), - Expression::UnaryExpression(expr) => self.visit_unary_expression(expr), - Expression::UpdateExpression(expr) => self.visit_update_expression(expr), - Expression::YieldExpression(expr) => self.visit_yield_expression(expr), - Expression::Super(expr) => self.visit_super(expr), - Expression::JSXElement(elem) => self.visit_jsx_element(elem), - Expression::JSXFragment(elem) => self.visit_jsx_fragment(elem), - - Expression::TSAsExpression(expr) => self.visit_ts_as_expression(expr), - Expression::TSSatisfiesExpression(expr) => self.visit_ts_satisfies_expression(expr), - Expression::TSNonNullExpression(expr) => self.visit_ts_non_null_expression(expr), - Expression::TSTypeAssertion(expr) => self.visit_ts_type_assertion(expr), + Expression::ThisExpression(expr) => visitor.visit_this_expression(expr), + Expression::UnaryExpression(expr) => visitor.visit_unary_expression(expr), + Expression::UpdateExpression(expr) => visitor.visit_update_expression(expr), + Expression::YieldExpression(expr) => visitor.visit_yield_expression(expr), + Expression::Super(expr) => visitor.visit_super(expr), + Expression::JSXElement(elem) => visitor.visit_jsx_element(elem), + Expression::JSXFragment(elem) => visitor.visit_jsx_fragment(elem), + + Expression::TSAsExpression(expr) => visitor.visit_ts_as_expression(expr), + Expression::TSSatisfiesExpression(expr) => visitor.visit_ts_satisfies_expression(expr), + Expression::TSNonNullExpression(expr) => visitor.visit_ts_non_null_expression(expr), + Expression::TSTypeAssertion(expr) => visitor.visit_ts_type_assertion(expr), Expression::TSInstantiationExpression(expr) => { - self.visit_ts_instantiation_expression(expr); + visitor.visit_ts_instantiation_expression(expr); } } } - fn visit_meta_property(&mut self, meta: &MetaProperty<'a>) { - let kind = AstKind::MetaProperty(self.alloc(meta)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_meta_property<'a, V: Visit<'a>>(visitor: &mut V, meta: &MetaProperty<'a>) { + let kind = AstKind::MetaProperty(visitor.alloc(meta)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_array_expression(&mut self, expr: &ArrayExpression<'a>) { - let kind = AstKind::ArrayExpression(self.alloc(expr)); - self.enter_node(kind); + pub fn walk_array_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &ArrayExpression<'a>) { + let kind = AstKind::ArrayExpression(visitor.alloc(expr)); + visitor.enter_node(kind); for elem in &expr.elements { - self.visit_array_expression_element(elem); + visitor.visit_array_expression_element(elem); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_array_expression_element(&mut self, arg: &ArrayExpressionElement<'a>) { - let kind = AstKind::ArrayExpressionElement(self.alloc(arg)); - self.enter_node(kind); + pub fn walk_array_expression_element<'a, V: Visit<'a>>( + visitor: &mut V, + arg: &ArrayExpressionElement<'a>, + ) { + let kind = AstKind::ArrayExpressionElement(visitor.alloc(arg)); + visitor.enter_node(kind); match arg { - ArrayExpressionElement::SpreadElement(spread) => self.visit_spread_element(spread), - ArrayExpressionElement::Expression(expr) => self.visit_expression_array_element(expr), - ArrayExpressionElement::Elision(span) => self.visit_elision(*span), + ArrayExpressionElement::SpreadElement(spread) => visitor.visit_spread_element(spread), + ArrayExpressionElement::Expression(expr) => { + visitor.visit_expression_array_element(expr); + } + ArrayExpressionElement::Elision(span) => visitor.visit_elision(*span), } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_argument(&mut self, arg: &Argument<'a>) { - let kind = AstKind::Argument(self.alloc(arg)); - self.enter_node(kind); + pub fn walk_argument<'a, V: Visit<'a>>(visitor: &mut V, arg: &Argument<'a>) { + let kind = AstKind::Argument(visitor.alloc(arg)); + visitor.enter_node(kind); match arg { - Argument::SpreadElement(spread) => self.visit_spread_element(spread), - Argument::Expression(expr) => self.visit_expression(expr), + Argument::SpreadElement(spread) => visitor.visit_spread_element(spread), + Argument::Expression(expr) => visitor.visit_expression(expr), } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_spread_element(&mut self, elem: &SpreadElement<'a>) { - let kind = AstKind::SpreadElement(self.alloc(elem)); - self.enter_node(kind); - self.visit_expression(&elem.argument); - self.leave_node(kind); + pub fn walk_spread_element<'a, V: Visit<'a>>(visitor: &mut V, elem: &SpreadElement<'a>) { + let kind = AstKind::SpreadElement(visitor.alloc(elem)); + visitor.enter_node(kind); + visitor.visit_expression(&elem.argument); + visitor.leave_node(kind); } - fn visit_expression_array_element(&mut self, expr: &Expression<'a>) { - let kind = AstKind::ExpressionArrayElement(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(expr); - self.leave_node(kind); + pub fn walk_expression_array_element<'a, V: Visit<'a>>(visitor: &mut V, expr: &Expression<'a>) { + let kind = AstKind::ExpressionArrayElement(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(expr); + visitor.leave_node(kind); } - fn visit_elision(&mut self, span: Span) { + pub fn walk_elision<'a, V: Visit<'a>>(visitor: &mut V, span: Span) { let kind = AstKind::Elision(span); - self.enter_node(kind); - self.leave_node(kind); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_assignment_expression(&mut self, expr: &AssignmentExpression<'a>) { - let kind = AstKind::AssignmentExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_assignment_target(&expr.left); - self.visit_expression(&expr.right); - self.leave_node(kind); + pub fn walk_assignment_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &AssignmentExpression<'a>, + ) { + let kind = AstKind::AssignmentExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_assignment_target(&expr.left); + visitor.visit_expression(&expr.right); + visitor.leave_node(kind); } - fn visit_arrow_expression(&mut self, expr: &ArrowFunctionExpression<'a>) { - let kind = AstKind::ArrowFunctionExpression(self.alloc(expr)); - self.enter_scope(ScopeFlags::Function | ScopeFlags::Arrow); - self.enter_node(kind); - self.visit_formal_parameters(&expr.params); - self.visit_function_body(&expr.body); + pub fn walk_arrow_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &ArrowFunctionExpression<'a>, + ) { + let kind = AstKind::ArrowFunctionExpression(visitor.alloc(expr)); + visitor.enter_scope(ScopeFlags::Function | ScopeFlags::Arrow); + visitor.enter_node(kind); + visitor.visit_formal_parameters(&expr.params); + visitor.visit_function_body(&expr.body); if let Some(parameters) = &expr.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); + visitor.visit_ts_type_parameter_declaration(parameters); } - self.leave_node(kind); - self.leave_scope(); + visitor.leave_node(kind); + visitor.leave_scope(); } - fn visit_await_expression(&mut self, expr: &AwaitExpression<'a>) { - let kind = AstKind::AwaitExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.argument); - self.leave_node(kind); + pub fn walk_await_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &AwaitExpression<'a>) { + let kind = AstKind::AwaitExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.argument); + visitor.leave_node(kind); } - fn visit_binary_expression(&mut self, expr: &BinaryExpression<'a>) { - let kind = AstKind::BinaryExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.left); - self.visit_expression(&expr.right); - self.leave_node(kind); + pub fn walk_binary_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &BinaryExpression<'a>) { + let kind = AstKind::BinaryExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.left); + visitor.visit_expression(&expr.right); + visitor.leave_node(kind); } - fn visit_call_expression(&mut self, expr: &CallExpression<'a>) { - let kind = AstKind::CallExpression(self.alloc(expr)); - self.enter_node(kind); + pub fn walk_call_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &CallExpression<'a>) { + let kind = AstKind::CallExpression(visitor.alloc(expr)); + visitor.enter_node(kind); for arg in &expr.arguments { - self.visit_argument(arg); + visitor.visit_argument(arg); } - self.visit_expression(&expr.callee); + visitor.visit_expression(&expr.callee); if let Some(parameters) = &expr.type_parameters { - self.visit_ts_type_parameter_instantiation(parameters); + visitor.visit_ts_type_parameter_instantiation(parameters); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_chain_expression(&mut self, expr: &ChainExpression<'a>) { - let kind = AstKind::ChainExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_chain_element(&expr.expression); - self.leave_node(kind); + pub fn walk_chain_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &ChainExpression<'a>) { + let kind = AstKind::ChainExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_chain_element(&expr.expression); + visitor.leave_node(kind); } - fn visit_chain_element(&mut self, elem: &ChainElement<'a>) { + pub fn walk_chain_element<'a, V: Visit<'a>>(visitor: &mut V, elem: &ChainElement<'a>) { match elem { - ChainElement::CallExpression(expr) => self.visit_call_expression(expr), - ChainElement::MemberExpression(expr) => self.visit_member_expression(expr), + ChainElement::CallExpression(expr) => visitor.visit_call_expression(expr), + ChainElement::MemberExpression(expr) => visitor.visit_member_expression(expr), } } - fn visit_conditional_expression(&mut self, expr: &ConditionalExpression<'a>) { - let kind = AstKind::ConditionalExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.test); - self.visit_expression(&expr.consequent); - self.visit_expression(&expr.alternate); - self.leave_node(kind); - } - - fn visit_import_expression(&mut self, expr: &ImportExpression<'a>) { - let kind = AstKind::ImportExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.source); + pub fn walk_conditional_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &ConditionalExpression<'a>, + ) { + let kind = AstKind::ConditionalExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.test); + visitor.visit_expression(&expr.consequent); + visitor.visit_expression(&expr.alternate); + visitor.leave_node(kind); + } + + pub fn walk_import_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &ImportExpression<'a>) { + let kind = AstKind::ImportExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.source); for arg in &expr.arguments { - self.visit_expression(arg); + visitor.visit_expression(arg); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_logical_expression(&mut self, expr: &LogicalExpression<'a>) { - let kind = AstKind::LogicalExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.left); - self.visit_expression(&expr.right); - self.leave_node(kind); + pub fn walk_logical_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &LogicalExpression<'a>, + ) { + let kind = AstKind::LogicalExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.left); + visitor.visit_expression(&expr.right); + visitor.leave_node(kind); } - fn visit_member_expression(&mut self, expr: &MemberExpression<'a>) { - let kind = AstKind::MemberExpression(self.alloc(expr)); - self.enter_node(kind); + pub fn walk_member_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &MemberExpression<'a>) { + let kind = AstKind::MemberExpression(visitor.alloc(expr)); + visitor.enter_node(kind); match expr { MemberExpression::ComputedMemberExpression(expr) => { - self.visit_computed_member_expression(expr); + visitor.visit_computed_member_expression(expr); } MemberExpression::StaticMemberExpression(expr) => { - self.visit_static_member_expression(expr); + visitor.visit_static_member_expression(expr); } MemberExpression::PrivateFieldExpression(expr) => { - self.visit_private_field_expression(expr); + visitor.visit_private_field_expression(expr); } } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_computed_member_expression(&mut self, expr: &ComputedMemberExpression<'a>) { - self.visit_expression(&expr.object); - self.visit_expression(&expr.expression); + pub fn walk_computed_member_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &ComputedMemberExpression<'a>, + ) { + visitor.visit_expression(&expr.object); + visitor.visit_expression(&expr.expression); } - fn visit_static_member_expression(&mut self, expr: &StaticMemberExpression<'a>) { - self.visit_expression(&expr.object); - self.visit_identifier_name(&expr.property); + pub fn walk_static_member_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &StaticMemberExpression<'a>, + ) { + visitor.visit_expression(&expr.object); + visitor.visit_identifier_name(&expr.property); } - fn visit_private_field_expression(&mut self, expr: &PrivateFieldExpression<'a>) { - self.visit_expression(&expr.object); - self.visit_private_identifier(&expr.field); + pub fn walk_private_field_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &PrivateFieldExpression<'a>, + ) { + visitor.visit_expression(&expr.object); + visitor.visit_private_identifier(&expr.field); } - fn visit_new_expression(&mut self, expr: &NewExpression<'a>) { - let kind = AstKind::NewExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.callee); + pub fn walk_new_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &NewExpression<'a>) { + let kind = AstKind::NewExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.callee); if let Some(parameters) = &expr.type_parameters { - self.visit_ts_type_parameter_instantiation(parameters); + visitor.visit_ts_type_parameter_instantiation(parameters); } for arg in &expr.arguments { - self.visit_argument(arg); + visitor.visit_argument(arg); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_object_expression(&mut self, expr: &ObjectExpression<'a>) { - let kind = AstKind::ObjectExpression(self.alloc(expr)); - self.enter_node(kind); + pub fn walk_object_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &ObjectExpression<'a>) { + let kind = AstKind::ObjectExpression(visitor.alloc(expr)); + visitor.enter_node(kind); for prop in &expr.properties { - self.visit_object_property_kind(prop); + visitor.visit_object_property_kind(prop); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_object_property_kind(&mut self, prop: &ObjectPropertyKind<'a>) { + pub fn walk_object_property_kind<'a, V: Visit<'a>>( + visitor: &mut V, + prop: &ObjectPropertyKind<'a>, + ) { match prop { - ObjectPropertyKind::ObjectProperty(prop) => self.visit_object_property(prop), - ObjectPropertyKind::SpreadProperty(elem) => self.visit_spread_element(elem), + ObjectPropertyKind::ObjectProperty(prop) => visitor.visit_object_property(prop), + ObjectPropertyKind::SpreadProperty(elem) => visitor.visit_spread_element(elem), } } - fn visit_object_property(&mut self, prop: &ObjectProperty<'a>) { - let kind = AstKind::ObjectProperty(self.alloc(prop)); - self.enter_node(kind); - self.visit_property_key(&prop.key); - self.visit_expression(&prop.value); - self.leave_node(kind); + pub fn walk_object_property<'a, V: Visit<'a>>(visitor: &mut V, prop: &ObjectProperty<'a>) { + let kind = AstKind::ObjectProperty(visitor.alloc(prop)); + visitor.enter_node(kind); + visitor.visit_property_key(&prop.key); + visitor.visit_expression(&prop.value); + visitor.leave_node(kind); } - fn visit_property_key(&mut self, key: &PropertyKey<'a>) { - let kind = AstKind::PropertyKey(self.alloc(key)); - self.enter_node(kind); + pub fn walk_property_key<'a, V: Visit<'a>>(visitor: &mut V, key: &PropertyKey<'a>) { + let kind = AstKind::PropertyKey(visitor.alloc(key)); + visitor.enter_node(kind); match key { - PropertyKey::Identifier(ident) => self.visit_identifier_name(ident), - PropertyKey::PrivateIdentifier(ident) => self.visit_private_identifier(ident), - PropertyKey::Expression(expr) => self.visit_expression(expr), + PropertyKey::Identifier(ident) => visitor.visit_identifier_name(ident), + PropertyKey::PrivateIdentifier(ident) => visitor.visit_private_identifier(ident), + PropertyKey::Expression(expr) => visitor.visit_expression(expr), } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_parenthesized_expression(&mut self, expr: &ParenthesizedExpression<'a>) { - let kind = AstKind::ParenthesizedExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.expression); - self.leave_node(kind); + pub fn walk_parenthesized_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &ParenthesizedExpression<'a>, + ) { + let kind = AstKind::ParenthesizedExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.expression); + visitor.leave_node(kind); } - fn visit_private_in_expression(&mut self, expr: &PrivateInExpression<'a>) { - let kind = AstKind::PrivateInExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_private_identifier(&expr.left); - self.visit_expression(&expr.right); - self.leave_node(kind); + pub fn walk_private_in_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &PrivateInExpression<'a>, + ) { + let kind = AstKind::PrivateInExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_private_identifier(&expr.left); + visitor.visit_expression(&expr.right); + visitor.leave_node(kind); } - fn visit_sequence_expression(&mut self, expr: &SequenceExpression<'a>) { - let kind = AstKind::SequenceExpression(self.alloc(expr)); - self.enter_node(kind); + pub fn walk_sequence_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &SequenceExpression<'a>, + ) { + let kind = AstKind::SequenceExpression(visitor.alloc(expr)); + visitor.enter_node(kind); for expr in &expr.expressions { - self.visit_expression(expr); + visitor.visit_expression(expr); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_tagged_template_expression(&mut self, expr: &TaggedTemplateExpression<'a>) { - let kind = AstKind::TaggedTemplateExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.tag); - self.visit_template_literal(&expr.quasi); - self.leave_node(kind); + pub fn walk_tagged_template_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &TaggedTemplateExpression<'a>, + ) { + let kind = AstKind::TaggedTemplateExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.tag); + visitor.visit_template_literal(&expr.quasi); + visitor.leave_node(kind); } - fn visit_this_expression(&mut self, expr: &ThisExpression) { - let kind = AstKind::ThisExpression(self.alloc(expr)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_this_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &ThisExpression) { + let kind = AstKind::ThisExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_unary_expression(&mut self, expr: &UnaryExpression<'a>) { - let kind = AstKind::UnaryExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.argument); - self.leave_node(kind); + pub fn walk_unary_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &UnaryExpression<'a>) { + let kind = AstKind::UnaryExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.argument); + visitor.leave_node(kind); } - fn visit_update_expression(&mut self, expr: &UpdateExpression<'a>) { - let kind = AstKind::UpdateExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_simple_assignment_target(&expr.argument); - self.leave_node(kind); + pub fn walk_update_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &UpdateExpression<'a>) { + let kind = AstKind::UpdateExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_simple_assignment_target(&expr.argument); + visitor.leave_node(kind); } - fn visit_yield_expression(&mut self, expr: &YieldExpression<'a>) { - let kind = AstKind::YieldExpression(self.alloc(expr)); - self.enter_node(kind); + pub fn walk_yield_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &YieldExpression<'a>) { + let kind = AstKind::YieldExpression(visitor.alloc(expr)); + visitor.enter_node(kind); if let Some(argument) = &expr.argument { - self.visit_expression(argument); + visitor.visit_expression(argument); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_super(&mut self, expr: &Super) { - let kind = AstKind::Super(self.alloc(expr)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_super<'a, V: Visit<'a>>(visitor: &mut V, expr: &Super) { + let kind = AstKind::Super(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_assignment_target(&mut self, target: &AssignmentTarget<'a>) { - let kind = AstKind::AssignmentTarget(self.alloc(target)); - self.enter_node(kind); + pub fn walk_assignment_target<'a, V: Visit<'a>>( + visitor: &mut V, + target: &AssignmentTarget<'a>, + ) { + let kind = AstKind::AssignmentTarget(visitor.alloc(target)); + visitor.enter_node(kind); match target { AssignmentTarget::SimpleAssignmentTarget(target) => { - self.visit_simple_assignment_target(target); + visitor.visit_simple_assignment_target(target); } AssignmentTarget::AssignmentTargetPattern(pat) => { - self.visit_assignment_target_pattern(pat); + visitor.visit_assignment_target_pattern(pat); } } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_simple_assignment_target(&mut self, target: &SimpleAssignmentTarget<'a>) { - let kind = AstKind::SimpleAssignmentTarget(self.alloc(target)); - self.enter_node(kind); + pub fn walk_simple_assignment_target<'a, V: Visit<'a>>( + visitor: &mut V, + target: &SimpleAssignmentTarget<'a>, + ) { + let kind = AstKind::SimpleAssignmentTarget(visitor.alloc(target)); + visitor.enter_node(kind); match target { SimpleAssignmentTarget::AssignmentTargetIdentifier(ident) => { - self.visit_identifier_reference(ident); + visitor.visit_identifier_reference(ident); } SimpleAssignmentTarget::MemberAssignmentTarget(expr) => { - self.visit_member_expression(expr); + visitor.visit_member_expression(expr); } SimpleAssignmentTarget::TSAsExpression(expr) => { - self.visit_expression(&expr.expression); + visitor.visit_expression(&expr.expression); } SimpleAssignmentTarget::TSSatisfiesExpression(expr) => { - self.visit_expression(&expr.expression); + visitor.visit_expression(&expr.expression); } SimpleAssignmentTarget::TSNonNullExpression(expr) => { - self.visit_expression(&expr.expression); + visitor.visit_expression(&expr.expression); } SimpleAssignmentTarget::TSTypeAssertion(expr) => { - self.visit_expression(&expr.expression); + visitor.visit_expression(&expr.expression); } } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_assignment_target_pattern(&mut self, pat: &AssignmentTargetPattern<'a>) { + pub fn walk_assignment_target_pattern<'a, V: Visit<'a>>( + visitor: &mut V, + pat: &AssignmentTargetPattern<'a>, + ) { match pat { AssignmentTargetPattern::ArrayAssignmentTarget(target) => { - self.visit_array_assignment_target(target); + visitor.visit_array_assignment_target(target); } AssignmentTargetPattern::ObjectAssignmentTarget(target) => { - self.visit_object_assignment_target(target); + visitor.visit_object_assignment_target(target); } } } - fn visit_array_assignment_target(&mut self, target: &ArrayAssignmentTarget<'a>) { + pub fn walk_array_assignment_target<'a, V: Visit<'a>>( + visitor: &mut V, + target: &ArrayAssignmentTarget<'a>, + ) { for element in target.elements.iter().flatten() { - self.visit_assignment_target_maybe_default(element); + visitor.visit_assignment_target_maybe_default(element); } if let Some(target) = &target.rest { - self.visit_assignment_target_rest(target); + visitor.visit_assignment_target_rest(target); } } - fn visit_assignment_target_maybe_default(&mut self, target: &AssignmentTargetMaybeDefault<'a>) { + pub fn walk_assignment_target_maybe_default<'a, V: Visit<'a>>( + visitor: &mut V, + target: &AssignmentTargetMaybeDefault<'a>, + ) { match target { AssignmentTargetMaybeDefault::AssignmentTarget(target) => { - self.visit_assignment_target(target); + visitor.visit_assignment_target(target); } AssignmentTargetMaybeDefault::AssignmentTargetWithDefault(target) => { - self.visit_assignment_target_with_default(target); + visitor.visit_assignment_target_with_default(target); } } } - fn visit_assignment_target_with_default(&mut self, target: &AssignmentTargetWithDefault<'a>) { - let kind = AstKind::AssignmentTargetWithDefault(self.alloc(target)); - self.enter_node(kind); - self.visit_assignment_target(&target.binding); - self.visit_expression(&target.init); - self.leave_node(kind); + pub fn walk_assignment_target_with_default<'a, V: Visit<'a>>( + visitor: &mut V, + target: &AssignmentTargetWithDefault<'a>, + ) { + let kind = AstKind::AssignmentTargetWithDefault(visitor.alloc(target)); + visitor.enter_node(kind); + visitor.visit_assignment_target(&target.binding); + visitor.visit_expression(&target.init); + visitor.leave_node(kind); } - fn visit_object_assignment_target(&mut self, target: &ObjectAssignmentTarget<'a>) { + pub fn walk_object_assignment_target<'a, V: Visit<'a>>( + visitor: &mut V, + target: &ObjectAssignmentTarget<'a>, + ) { for property in &target.properties { - self.visit_assignment_target_property(property); + visitor.visit_assignment_target_property(property); } if let Some(target) = &target.rest { - self.visit_assignment_target_rest(target); + visitor.visit_assignment_target_rest(target); } } - fn visit_assignment_target_property(&mut self, property: &AssignmentTargetProperty<'a>) { + pub fn walk_assignment_target_property<'a, V: Visit<'a>>( + visitor: &mut V, + property: &AssignmentTargetProperty<'a>, + ) { match property { AssignmentTargetProperty::AssignmentTargetPropertyIdentifier(ident) => { - self.visit_assignment_target_property_identifier(ident); + visitor.visit_assignment_target_property_identifier(ident); } AssignmentTargetProperty::AssignmentTargetPropertyProperty(prop) => { - self.visit_assignment_target_property_property(prop); + visitor.visit_assignment_target_property_property(prop); } } } - fn visit_assignment_target_property_identifier( - &mut self, + pub fn walk_assignment_target_property_identifier<'a, V: Visit<'a>>( + visitor: &mut V, ident: &AssignmentTargetPropertyIdentifier<'a>, ) { - self.visit_identifier_reference(&ident.binding); + visitor.visit_identifier_reference(&ident.binding); if let Some(expr) = &ident.init { - self.visit_expression(expr); + visitor.visit_expression(expr); } } - fn visit_assignment_target_property_property( - &mut self, + pub fn walk_assignment_target_property_property<'a, V: Visit<'a>>( + visitor: &mut V, property: &AssignmentTargetPropertyProperty<'a>, ) { - self.visit_property_key(&property.name); - self.visit_assignment_target_maybe_default(&property.binding); + visitor.visit_property_key(&property.name); + visitor.visit_assignment_target_maybe_default(&property.binding); } - fn visit_assignment_target_rest(&mut self, rest: &AssignmentTargetRest<'a>) { - self.visit_assignment_target(&rest.target); + pub fn walk_assignment_target_rest<'a, V: Visit<'a>>( + visitor: &mut V, + rest: &AssignmentTargetRest<'a>, + ) { + visitor.visit_assignment_target(&rest.target); } /* ---------- Expression ---------- */ - fn visit_jsx_element(&mut self, elem: &JSXElement<'a>) { - let kind = AstKind::JSXElement(self.alloc(elem)); - self.enter_node(kind); - self.visit_jsx_opening_element(&elem.opening_element); + pub fn walk_jsx_element<'a, V: Visit<'a>>(visitor: &mut V, elem: &JSXElement<'a>) { + let kind = AstKind::JSXElement(visitor.alloc(elem)); + visitor.enter_node(kind); + visitor.visit_jsx_opening_element(&elem.opening_element); for child in &elem.children { - self.visit_jsx_child(child); + visitor.visit_jsx_child(child); } if let Some(closing_elem) = &elem.closing_element { - self.visit_jsx_closing_element(closing_elem); + visitor.visit_jsx_closing_element(closing_elem); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_jsx_opening_element(&mut self, elem: &JSXOpeningElement<'a>) { - let kind = AstKind::JSXOpeningElement(self.alloc(elem)); - self.enter_node(kind); - self.visit_jsx_element_name(&elem.name); + pub fn walk_jsx_opening_element<'a, V: Visit<'a>>( + visitor: &mut V, + elem: &JSXOpeningElement<'a>, + ) { + let kind = AstKind::JSXOpeningElement(visitor.alloc(elem)); + visitor.enter_node(kind); + visitor.visit_jsx_element_name(&elem.name); for attribute in &elem.attributes { - self.visit_jsx_attribute_item(attribute); + visitor.visit_jsx_attribute_item(attribute); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_jsx_closing_element(&mut self, elem: &JSXClosingElement<'a>) { - let kind = AstKind::JSXClosingElement(self.alloc(elem)); - self.enter_node(kind); - self.visit_jsx_element_name(&elem.name); - self.leave_node(kind); + pub fn walk_jsx_closing_element<'a, V: Visit<'a>>( + visitor: &mut V, + elem: &JSXClosingElement<'a>, + ) { + let kind = AstKind::JSXClosingElement(visitor.alloc(elem)); + visitor.enter_node(kind); + visitor.visit_jsx_element_name(&elem.name); + visitor.leave_node(kind); } - fn visit_jsx_element_name(&mut self, name: &JSXElementName<'a>) { - let kind = AstKind::JSXElementName(self.alloc(name)); - self.enter_node(kind); + pub fn walk_jsx_element_name<'a, V: Visit<'a>>(visitor: &mut V, name: &JSXElementName<'a>) { + let kind = AstKind::JSXElementName(visitor.alloc(name)); + visitor.enter_node(kind); match name { - JSXElementName::Identifier(ident) => self.visit_jsx_identifier(ident), - JSXElementName::NamespacedName(expr) => self.visit_jsx_namespaced_name(expr), - JSXElementName::MemberExpression(expr) => self.visit_jsx_member_expression(expr), + JSXElementName::Identifier(ident) => visitor.visit_jsx_identifier(ident), + JSXElementName::NamespacedName(expr) => visitor.visit_jsx_namespaced_name(expr), + JSXElementName::MemberExpression(expr) => visitor.visit_jsx_member_expression(expr), } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_jsx_identifier(&mut self, ident: &JSXIdentifier<'a>) { - let kind = AstKind::JSXIdentifier(self.alloc(ident)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_jsx_identifier<'a, V: Visit<'a>>(visitor: &mut V, ident: &JSXIdentifier<'a>) { + let kind = AstKind::JSXIdentifier(visitor.alloc(ident)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_jsx_member_expression(&mut self, expr: &JSXMemberExpression<'a>) { - let kind = AstKind::JSXMemberExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_jsx_member_expression_object(&expr.object); - self.visit_jsx_identifier(&expr.property); - self.leave_node(kind); + pub fn walk_jsx_member_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &JSXMemberExpression<'a>, + ) { + let kind = AstKind::JSXMemberExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_jsx_member_expression_object(&expr.object); + visitor.visit_jsx_identifier(&expr.property); + visitor.leave_node(kind); } - fn visit_jsx_member_expression_object(&mut self, expr: &JSXMemberExpressionObject<'a>) { - let kind = AstKind::JSXMemberExpressionObject(self.alloc(expr)); - self.enter_node(kind); + pub fn walk_jsx_member_expression_object<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &JSXMemberExpressionObject<'a>, + ) { + let kind = AstKind::JSXMemberExpressionObject(visitor.alloc(expr)); + visitor.enter_node(kind); match expr { - JSXMemberExpressionObject::Identifier(ident) => self.visit_jsx_identifier(ident), + JSXMemberExpressionObject::Identifier(ident) => visitor.visit_jsx_identifier(ident), JSXMemberExpressionObject::MemberExpression(expr) => { - self.visit_jsx_member_expression(expr); + visitor.visit_jsx_member_expression(expr); } } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_jsx_namespaced_name(&mut self, name: &JSXNamespacedName<'a>) { - let kind = AstKind::JSXNamespacedName(self.alloc(name)); - self.enter_node(kind); - self.visit_jsx_identifier(&name.namespace); - self.visit_jsx_identifier(&name.property); - self.leave_node(kind); + pub fn walk_jsx_namespaced_name<'a, V: Visit<'a>>( + visitor: &mut V, + name: &JSXNamespacedName<'a>, + ) { + let kind = AstKind::JSXNamespacedName(visitor.alloc(name)); + visitor.enter_node(kind); + visitor.visit_jsx_identifier(&name.namespace); + visitor.visit_jsx_identifier(&name.property); + visitor.leave_node(kind); } - fn visit_jsx_attribute_item(&mut self, item: &JSXAttributeItem<'a>) { - let kind = AstKind::JSXAttributeItem(self.alloc(item)); - self.enter_node(kind); + pub fn walk_jsx_attribute_item<'a, V: Visit<'a>>(visitor: &mut V, item: &JSXAttributeItem<'a>) { + let kind = AstKind::JSXAttributeItem(visitor.alloc(item)); + visitor.enter_node(kind); match &item { - JSXAttributeItem::Attribute(attribute) => self.visit_jsx_attribute(attribute), + JSXAttributeItem::Attribute(attribute) => visitor.visit_jsx_attribute(attribute), JSXAttributeItem::SpreadAttribute(attribute) => { - self.visit_jsx_spread_attribute(attribute); + visitor.visit_jsx_spread_attribute(attribute); } } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_jsx_attribute(&mut self, attribute: &JSXAttribute<'a>) { + pub fn walk_jsx_attribute<'a, V: Visit<'a>>(visitor: &mut V, attribute: &JSXAttribute<'a>) { if let Some(value) = &attribute.value { - self.visit_jsx_attribute_value(value); + visitor.visit_jsx_attribute_value(value); } } - fn visit_jsx_spread_attribute(&mut self, attribute: &JSXSpreadAttribute<'a>) { - self.visit_expression(&attribute.argument); + pub fn walk_jsx_spread_attribute<'a, V: Visit<'a>>( + visitor: &mut V, + attribute: &JSXSpreadAttribute<'a>, + ) { + visitor.visit_expression(&attribute.argument); } - fn visit_jsx_attribute_value(&mut self, value: &JSXAttributeValue<'a>) { + pub fn walk_jsx_attribute_value<'a, V: Visit<'a>>( + visitor: &mut V, + value: &JSXAttributeValue<'a>, + ) { match value { JSXAttributeValue::ExpressionContainer(expr) => { - self.visit_jsx_expression_container(expr); + visitor.visit_jsx_expression_container(expr); } - JSXAttributeValue::Element(elem) => self.visit_jsx_element(elem), - JSXAttributeValue::Fragment(elem) => self.visit_jsx_fragment(elem), - JSXAttributeValue::StringLiteral(lit) => self.visit_string_literal(lit), + JSXAttributeValue::Element(elem) => visitor.visit_jsx_element(elem), + JSXAttributeValue::Fragment(elem) => visitor.visit_jsx_fragment(elem), + JSXAttributeValue::StringLiteral(lit) => visitor.visit_string_literal(lit), } } - fn visit_jsx_expression_container(&mut self, expr: &JSXExpressionContainer<'a>) { - let kind = AstKind::JSXExpressionContainer(self.alloc(expr)); - self.enter_node(kind); - self.visit_jsx_expression(&expr.expression); - self.leave_node(kind); + pub fn walk_jsx_expression_container<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &JSXExpressionContainer<'a>, + ) { + let kind = AstKind::JSXExpressionContainer(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_jsx_expression(&expr.expression); + visitor.leave_node(kind); } - fn visit_jsx_expression(&mut self, expr: &JSXExpression<'a>) { + pub fn walk_jsx_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &JSXExpression<'a>) { match expr { - JSXExpression::Expression(expr) => self.visit_expression(expr), + JSXExpression::Expression(expr) => visitor.visit_expression(expr), JSXExpression::EmptyExpression(_) => {} } } - fn visit_jsx_fragment(&mut self, elem: &JSXFragment<'a>) { - let kind = AstKind::JSXFragment(self.alloc(elem)); - self.enter_node(kind); + pub fn walk_jsx_fragment<'a, V: Visit<'a>>(visitor: &mut V, elem: &JSXFragment<'a>) { + let kind = AstKind::JSXFragment(visitor.alloc(elem)); + visitor.enter_node(kind); for child in &elem.children { - self.visit_jsx_child(child); + visitor.visit_jsx_child(child); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_jsx_child(&mut self, child: &JSXChild<'a>) { + pub fn walk_jsx_child<'a, V: Visit<'a>>(visitor: &mut V, child: &JSXChild<'a>) { match child { - JSXChild::Element(elem) => self.visit_jsx_element(elem), - JSXChild::Fragment(elem) => self.visit_jsx_fragment(elem), - JSXChild::ExpressionContainer(expr) => self.visit_jsx_expression_container(expr), - JSXChild::Spread(expr) => self.visit_jsx_spread_child(expr), - JSXChild::Text(expr) => self.visit_jsx_text(expr), + JSXChild::Element(elem) => visitor.visit_jsx_element(elem), + JSXChild::Fragment(elem) => visitor.visit_jsx_fragment(elem), + JSXChild::ExpressionContainer(expr) => visitor.visit_jsx_expression_container(expr), + JSXChild::Spread(expr) => visitor.visit_jsx_spread_child(expr), + JSXChild::Text(expr) => visitor.visit_jsx_text(expr), } } - fn visit_jsx_spread_child(&mut self, child: &JSXSpreadChild<'a>) { - self.visit_expression(&child.expression); + pub fn walk_jsx_spread_child<'a, V: Visit<'a>>(visitor: &mut V, child: &JSXSpreadChild<'a>) { + visitor.visit_expression(&child.expression); } - fn visit_jsx_text(&mut self, child: &JSXText<'a>) { - let kind = AstKind::JSXText(self.alloc(child)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_jsx_text<'a, V: Visit<'a>>(visitor: &mut V, child: &JSXText<'a>) { + let kind = AstKind::JSXText(visitor.alloc(child)); + visitor.enter_node(kind); + visitor.leave_node(kind); } /* ---------- Pattern ---------- */ - fn visit_binding_pattern(&mut self, pat: &BindingPattern<'a>) { + pub fn walk_binding_pattern<'a, V: Visit<'a>>(visitor: &mut V, pat: &BindingPattern<'a>) { match &pat.kind { BindingPatternKind::BindingIdentifier(ident) => { - self.visit_binding_identifier(ident); + visitor.visit_binding_identifier(ident); } - BindingPatternKind::ObjectPattern(pat) => self.visit_object_pattern(pat), - BindingPatternKind::ArrayPattern(pat) => self.visit_array_pattern(pat), - BindingPatternKind::AssignmentPattern(pat) => self.visit_assignment_pattern(pat), + BindingPatternKind::ObjectPattern(pat) => visitor.visit_object_pattern(pat), + BindingPatternKind::ArrayPattern(pat) => visitor.visit_array_pattern(pat), + BindingPatternKind::AssignmentPattern(pat) => visitor.visit_assignment_pattern(pat), } if let Some(type_annotation) = &pat.type_annotation { - self.visit_ts_type_annotation(type_annotation); + visitor.visit_ts_type_annotation(type_annotation); } } - fn visit_binding_identifier(&mut self, ident: &BindingIdentifier<'a>) { - let kind = AstKind::BindingIdentifier(self.alloc(ident)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_binding_identifier<'a, V: Visit<'a>>( + visitor: &mut V, + ident: &BindingIdentifier<'a>, + ) { + let kind = AstKind::BindingIdentifier(visitor.alloc(ident)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_object_pattern(&mut self, pat: &ObjectPattern<'a>) { - let kind = AstKind::ObjectPattern(self.alloc(pat)); - self.enter_node(kind); + pub fn walk_object_pattern<'a, V: Visit<'a>>(visitor: &mut V, pat: &ObjectPattern<'a>) { + let kind = AstKind::ObjectPattern(visitor.alloc(pat)); + visitor.enter_node(kind); for prop in &pat.properties { - self.visit_binding_property(prop); + visitor.visit_binding_property(prop); } if let Some(rest) = &pat.rest { - self.visit_rest_element(rest); + visitor.visit_rest_element(rest); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_binding_property(&mut self, prop: &BindingProperty<'a>) { - self.visit_property_key(&prop.key); - self.visit_binding_pattern(&prop.value); + pub fn walk_binding_property<'a, V: Visit<'a>>(visitor: &mut V, prop: &BindingProperty<'a>) { + visitor.visit_property_key(&prop.key); + visitor.visit_binding_pattern(&prop.value); } - fn visit_array_pattern(&mut self, pat: &ArrayPattern<'a>) { - let kind = AstKind::ArrayPattern(self.alloc(pat)); - self.enter_node(kind); + pub fn walk_array_pattern<'a, V: Visit<'a>>(visitor: &mut V, pat: &ArrayPattern<'a>) { + let kind = AstKind::ArrayPattern(visitor.alloc(pat)); + visitor.enter_node(kind); for pat in pat.elements.iter().flatten() { - self.visit_binding_pattern(pat); + visitor.visit_binding_pattern(pat); } if let Some(rest) = &pat.rest { - self.visit_rest_element(rest); + visitor.visit_rest_element(rest); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_rest_element(&mut self, pat: &BindingRestElement<'a>) { - let kind = AstKind::BindingRestElement(self.alloc(pat)); - self.enter_node(kind); - self.visit_binding_pattern(&pat.argument); - self.leave_node(kind); + pub fn walk_rest_element<'a, V: Visit<'a>>(visitor: &mut V, pat: &BindingRestElement<'a>) { + let kind = AstKind::BindingRestElement(visitor.alloc(pat)); + visitor.enter_node(kind); + visitor.visit_binding_pattern(&pat.argument); + visitor.leave_node(kind); } - fn visit_assignment_pattern(&mut self, pat: &AssignmentPattern<'a>) { - let kind = AstKind::AssignmentPattern(self.alloc(pat)); - self.enter_node(kind); - self.visit_binding_pattern(&pat.left); - self.visit_expression(&pat.right); - self.leave_node(kind); + pub fn walk_assignment_pattern<'a, V: Visit<'a>>(visitor: &mut V, pat: &AssignmentPattern<'a>) { + let kind = AstKind::AssignmentPattern(visitor.alloc(pat)); + visitor.enter_node(kind); + visitor.visit_binding_pattern(&pat.left); + visitor.visit_expression(&pat.right); + visitor.leave_node(kind); } /* ---------- Identifier ---------- */ - fn visit_identifier_reference(&mut self, ident: &IdentifierReference<'a>) { - let kind = AstKind::IdentifierReference(self.alloc(ident)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_identifier_reference<'a, V: Visit<'a>>( + visitor: &mut V, + ident: &IdentifierReference<'a>, + ) { + let kind = AstKind::IdentifierReference(visitor.alloc(ident)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_private_identifier(&mut self, ident: &PrivateIdentifier<'a>) { - let kind = AstKind::PrivateIdentifier(self.alloc(ident)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_private_identifier<'a, V: Visit<'a>>( + visitor: &mut V, + ident: &PrivateIdentifier<'a>, + ) { + let kind = AstKind::PrivateIdentifier(visitor.alloc(ident)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_label_identifier(&mut self, ident: &LabelIdentifier<'a>) { - let kind = AstKind::LabelIdentifier(self.alloc(ident)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_label_identifier<'a, V: Visit<'a>>(visitor: &mut V, ident: &LabelIdentifier<'a>) { + let kind = AstKind::LabelIdentifier(visitor.alloc(ident)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_identifier_name(&mut self, ident: &IdentifierName<'a>) { - let kind = AstKind::IdentifierName(self.alloc(ident)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_identifier_name<'a, V: Visit<'a>>(visitor: &mut V, ident: &IdentifierName<'a>) { + let kind = AstKind::IdentifierName(visitor.alloc(ident)); + visitor.enter_node(kind); + visitor.leave_node(kind); } /* ---------- Literal ---------- */ - fn visit_number_literal(&mut self, lit: &NumericLiteral<'a>) { - let kind = AstKind::NumericLiteral(self.alloc(lit)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_number_literal<'a, V: Visit<'a>>(visitor: &mut V, lit: &NumericLiteral<'a>) { + let kind = AstKind::NumericLiteral(visitor.alloc(lit)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_boolean_literal(&mut self, lit: &BooleanLiteral) { - let kind = AstKind::BooleanLiteral(self.alloc(lit)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_boolean_literal<'a, V: Visit<'a>>(visitor: &mut V, lit: &BooleanLiteral) { + let kind = AstKind::BooleanLiteral(visitor.alloc(lit)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_null_literal(&mut self, lit: &NullLiteral) { - let kind = AstKind::NullLiteral(self.alloc(lit)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_null_literal<'a, V: Visit<'a>>(visitor: &mut V, lit: &NullLiteral) { + let kind = AstKind::NullLiteral(visitor.alloc(lit)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_bigint_literal(&mut self, lit: &BigIntLiteral<'a>) { - let kind = AstKind::BigintLiteral(self.alloc(lit)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_bigint_literal<'a, V: Visit<'a>>(visitor: &mut V, lit: &BigIntLiteral<'a>) { + let kind = AstKind::BigintLiteral(visitor.alloc(lit)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_string_literal(&mut self, lit: &StringLiteral<'a>) { - let kind = AstKind::StringLiteral(self.alloc(lit)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_string_literal<'a, V: Visit<'a>>(visitor: &mut V, lit: &StringLiteral<'a>) { + let kind = AstKind::StringLiteral(visitor.alloc(lit)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_template_literal(&mut self, lit: &TemplateLiteral<'a>) { - let kind = AstKind::TemplateLiteral(self.alloc(lit)); - self.enter_node(kind); + pub fn walk_template_literal<'a, V: Visit<'a>>(visitor: &mut V, lit: &TemplateLiteral<'a>) { + let kind = AstKind::TemplateLiteral(visitor.alloc(lit)); + visitor.enter_node(kind); for elem in &lit.quasis { - self.visit_template_element(elem); + visitor.visit_template_element(elem); } for expr in &lit.expressions { - self.visit_expression(expr); + visitor.visit_expression(expr); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_reg_expr_literal(&mut self, lit: &RegExpLiteral<'a>) { - let kind = AstKind::RegExpLiteral(self.alloc(lit)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_reg_expr_literal<'a, V: Visit<'a>>(visitor: &mut V, lit: &RegExpLiteral<'a>) { + let kind = AstKind::RegExpLiteral(visitor.alloc(lit)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_template_element(&mut self, _elem: &TemplateElement) {} + pub fn walk_template_element<'a, V: Visit<'a>>(_visitor: &mut V, _elem: &TemplateElement) {} /* ---------- Module ---------- */ - fn visit_module_declaration(&mut self, decl: &ModuleDeclaration<'a>) { - let kind = AstKind::ModuleDeclaration(self.alloc(decl)); - self.enter_node(kind); + pub fn walk_module_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + decl: &ModuleDeclaration<'a>, + ) { + let kind = AstKind::ModuleDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); match decl { ModuleDeclaration::ImportDeclaration(decl) => { - self.visit_import_declaration(decl); + visitor.visit_import_declaration(decl); } ModuleDeclaration::ExportAllDeclaration(decl) => { - self.visit_export_all_declaration(decl); + visitor.visit_export_all_declaration(decl); } ModuleDeclaration::ExportDefaultDeclaration(decl) => { - self.visit_export_default_declaration(decl); + visitor.visit_export_default_declaration(decl); } ModuleDeclaration::ExportNamedDeclaration(decl) => { - self.visit_export_named_declaration(decl); + visitor.visit_export_named_declaration(decl); } ModuleDeclaration::TSExportAssignment(decl) => { - self.visit_expression(&decl.expression); + visitor.visit_expression(&decl.expression); } ModuleDeclaration::TSNamespaceExportDeclaration(_) => {} } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_import_declaration(&mut self, decl: &ImportDeclaration<'a>) { - let kind = AstKind::ImportDeclaration(self.alloc(decl)); - self.enter_node(kind); + pub fn walk_import_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + decl: &ImportDeclaration<'a>, + ) { + let kind = AstKind::ImportDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); if let Some(specifiers) = &decl.specifiers { for specifier in specifiers { - self.visit_import_declaration_specifier(specifier); + visitor.visit_import_declaration_specifier(specifier); } } - self.visit_string_literal(&decl.source); + visitor.visit_string_literal(&decl.source); if let Some(with_clause) = &decl.with_clause { - self.visit_with_clause(with_clause); + visitor.visit_with_clause(with_clause); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_with_clause(&mut self, with_clause: &WithClause<'a>) { + pub fn walk_with_clause<'a, V: Visit<'a>>(visitor: &mut V, with_clause: &WithClause<'a>) { for attribute in &with_clause.with_entries { - self.visit_import_attribute(attribute); + visitor.visit_import_attribute(attribute); } } - fn visit_import_attribute(&mut self, attribute: &ImportAttribute<'a>) { - self.visit_import_attribute_key(&attribute.key); - self.visit_string_literal(&attribute.value); + pub fn walk_import_attribute<'a, V: Visit<'a>>( + visitor: &mut V, + attribute: &ImportAttribute<'a>, + ) { + visitor.visit_import_attribute_key(&attribute.key); + visitor.visit_string_literal(&attribute.value); } - fn visit_import_attribute_key(&mut self, key: &ImportAttributeKey<'a>) { + pub fn walk_import_attribute_key<'a, V: Visit<'a>>( + visitor: &mut V, + key: &ImportAttributeKey<'a>, + ) { match key { - ImportAttributeKey::Identifier(ident) => self.visit_identifier_name(ident), - ImportAttributeKey::StringLiteral(ident) => self.visit_string_literal(ident), + ImportAttributeKey::Identifier(ident) => visitor.visit_identifier_name(ident), + ImportAttributeKey::StringLiteral(ident) => visitor.visit_string_literal(ident), } } - fn visit_import_declaration_specifier(&mut self, specifier: &ImportDeclarationSpecifier<'a>) { + pub fn walk_import_declaration_specifier<'a, V: Visit<'a>>( + visitor: &mut V, + specifier: &ImportDeclarationSpecifier<'a>, + ) { match &specifier { ImportDeclarationSpecifier::ImportSpecifier(specifier) => { - self.visit_import_specifier(specifier); + visitor.visit_import_specifier(specifier); } ImportDeclarationSpecifier::ImportDefaultSpecifier(specifier) => { - self.visit_import_default_specifier(specifier); + visitor.visit_import_default_specifier(specifier); } ImportDeclarationSpecifier::ImportNamespaceSpecifier(specifier) => { - self.visit_import_name_specifier(specifier); + visitor.visit_import_name_specifier(specifier); } } } - fn visit_import_specifier(&mut self, specifier: &ImportSpecifier<'a>) { - let kind = AstKind::ImportSpecifier(self.alloc(specifier)); - self.enter_node(kind); + pub fn walk_import_specifier<'a, V: Visit<'a>>( + visitor: &mut V, + specifier: &ImportSpecifier<'a>, + ) { + let kind = AstKind::ImportSpecifier(visitor.alloc(specifier)); + visitor.enter_node(kind); // TODO: imported - self.visit_binding_identifier(&specifier.local); - self.leave_node(kind); + visitor.visit_binding_identifier(&specifier.local); + visitor.leave_node(kind); } - fn visit_import_default_specifier(&mut self, specifier: &ImportDefaultSpecifier<'a>) { - let kind = AstKind::ImportDefaultSpecifier(self.alloc(specifier)); - self.enter_node(kind); - self.visit_binding_identifier(&specifier.local); - self.leave_node(kind); + pub fn walk_import_default_specifier<'a, V: Visit<'a>>( + visitor: &mut V, + specifier: &ImportDefaultSpecifier<'a>, + ) { + let kind = AstKind::ImportDefaultSpecifier(visitor.alloc(specifier)); + visitor.enter_node(kind); + visitor.visit_binding_identifier(&specifier.local); + visitor.leave_node(kind); } - fn visit_import_name_specifier(&mut self, specifier: &ImportNamespaceSpecifier<'a>) { - let kind = AstKind::ImportNamespaceSpecifier(self.alloc(specifier)); - self.enter_node(kind); - self.visit_binding_identifier(&specifier.local); - self.leave_node(kind); + pub fn walk_import_name_specifier<'a, V: Visit<'a>>( + visitor: &mut V, + specifier: &ImportNamespaceSpecifier<'a>, + ) { + let kind = AstKind::ImportNamespaceSpecifier(visitor.alloc(specifier)); + visitor.enter_node(kind); + visitor.visit_binding_identifier(&specifier.local); + visitor.leave_node(kind); } - fn visit_export_all_declaration(&mut self, decl: &ExportAllDeclaration<'a>) { - let kind = AstKind::ExportAllDeclaration(self.alloc(decl)); - self.enter_node(kind); - self.visit_string_literal(&decl.source); - self.leave_node(kind); + pub fn walk_export_all_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + decl: &ExportAllDeclaration<'a>, + ) { + let kind = AstKind::ExportAllDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); + visitor.visit_string_literal(&decl.source); + visitor.leave_node(kind); } - fn visit_export_default_declaration(&mut self, decl: &ExportDefaultDeclaration<'a>) { - let kind = AstKind::ExportDefaultDeclaration(self.alloc(decl)); - self.enter_node(kind); + pub fn walk_export_default_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + decl: &ExportDefaultDeclaration<'a>, + ) { + let kind = AstKind::ExportDefaultDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); match &decl.declaration { - ExportDefaultDeclarationKind::Expression(expr) => self.visit_expression(expr), + ExportDefaultDeclarationKind::Expression(expr) => visitor.visit_expression(expr), ExportDefaultDeclarationKind::FunctionDeclaration(func) => { - self.visit_function(func, None); + visitor.visit_function(func, None); } - ExportDefaultDeclarationKind::ClassDeclaration(class) => self.visit_class(class), + ExportDefaultDeclarationKind::ClassDeclaration(class) => visitor.visit_class(class), _ => {} } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_export_named_declaration(&mut self, decl: &ExportNamedDeclaration<'a>) { - let kind = AstKind::ExportNamedDeclaration(self.alloc(decl)); - self.enter_node(kind); + pub fn walk_export_named_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + decl: &ExportNamedDeclaration<'a>, + ) { + let kind = AstKind::ExportNamedDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); if let Some(decl) = &decl.declaration { - self.visit_declaration(decl); + visitor.visit_declaration(decl); } if let Some(ref source) = decl.source { - self.visit_string_literal(source); + visitor.visit_string_literal(source); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_enum_member(&mut self, member: &TSEnumMember<'a>) { - let kind = AstKind::TSEnumMember(self.alloc(member)); - self.enter_node(kind); + pub fn walk_enum_member<'a, V: Visit<'a>>(visitor: &mut V, member: &TSEnumMember<'a>) { + let kind = AstKind::TSEnumMember(visitor.alloc(member)); + visitor.enter_node(kind); if let Some(initializer) = &member.initializer { - self.visit_expression(initializer); + visitor.visit_expression(initializer); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_enum(&mut self, decl: &TSEnumDeclaration<'a>) { - let kind = AstKind::TSEnumDeclaration(self.alloc(decl)); - self.enter_node(kind); - self.visit_binding_identifier(&decl.id); - self.enter_scope(ScopeFlags::empty()); + pub fn walk_enum<'a, V: Visit<'a>>(visitor: &mut V, decl: &TSEnumDeclaration<'a>) { + let kind = AstKind::TSEnumDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); + visitor.visit_binding_identifier(&decl.id); + visitor.enter_scope(ScopeFlags::empty()); for member in &decl.members { - self.visit_enum_member(member); + visitor.visit_enum_member(member); } - self.leave_scope(); - self.leave_node(kind); + visitor.leave_scope(); + visitor.leave_node(kind); } - fn visit_declaration(&mut self, decl: &Declaration<'a>) { + pub fn walk_declaration<'a, V: Visit<'a>>(visitor: &mut V, decl: &Declaration<'a>) { match decl { - Declaration::VariableDeclaration(decl) => self.visit_variable_declaration(decl), - Declaration::FunctionDeclaration(func) => self.visit_function(func, None), + Declaration::VariableDeclaration(decl) => visitor.visit_variable_declaration(decl), + Declaration::FunctionDeclaration(func) => visitor.visit_function(func, None), Declaration::ClassDeclaration(class) => { debug_assert_eq!(class.r#type, ClassType::ClassDeclaration); - self.visit_class(class); + visitor.visit_class(class); } - Declaration::UsingDeclaration(decl) => self.visit_using_declaration(decl), + Declaration::UsingDeclaration(decl) => visitor.visit_using_declaration(decl), Declaration::TSModuleDeclaration(module) => { - self.visit_ts_module_declaration(module); + visitor.visit_ts_module_declaration(module); } Declaration::TSTypeAliasDeclaration(decl) => { - self.visit_ts_type_alias_declaration(decl); + visitor.visit_ts_type_alias_declaration(decl); } - Declaration::TSEnumDeclaration(decl) => self.visit_enum(decl), + Declaration::TSEnumDeclaration(decl) => visitor.visit_enum(decl), Declaration::TSImportEqualsDeclaration(decl) => { - self.visit_ts_import_equals_declaration(decl); + visitor.visit_ts_import_equals_declaration(decl); } Declaration::TSInterfaceDeclaration(decl) => { - self.visit_ts_interface_declaration(decl); + visitor.visit_ts_interface_declaration(decl); } } } - fn visit_ts_import_equals_declaration(&mut self, decl: &TSImportEqualsDeclaration<'a>) { - let kind = AstKind::TSImportEqualsDeclaration(self.alloc(decl)); - self.enter_node(kind); - self.visit_binding_identifier(&decl.id); - self.visit_ts_module_reference(&decl.module_reference); - self.leave_node(kind); + /* ---------- TypeScript ---------- */ + + pub fn walk_ts_import_equals_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + decl: &TSImportEqualsDeclaration<'a>, + ) { + let kind = AstKind::TSImportEqualsDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); + visitor.visit_binding_identifier(&decl.id); + visitor.visit_ts_module_reference(&decl.module_reference); + visitor.leave_node(kind); } - fn visit_ts_module_reference(&mut self, reference: &TSModuleReference<'a>) { + pub fn walk_ts_module_reference<'a, V: Visit<'a>>( + visitor: &mut V, + reference: &TSModuleReference<'a>, + ) { match reference { - TSModuleReference::TypeName(name) => self.visit_ts_type_name(name), + TSModuleReference::TypeName(name) => visitor.visit_ts_type_name(name), TSModuleReference::ExternalModuleReference(reference) => { - self.visit_ts_external_module_reference(reference); + visitor.visit_ts_external_module_reference(reference); } } } - fn visit_ts_type_name(&mut self, name: &TSTypeName<'a>) { - let kind = AstKind::TSTypeName(self.alloc(name)); - self.enter_node(kind); + pub fn walk_ts_type_name<'a, V: Visit<'a>>(visitor: &mut V, name: &TSTypeName<'a>) { + let kind = AstKind::TSTypeName(visitor.alloc(name)); + visitor.enter_node(kind); match &name { - TSTypeName::IdentifierReference(ident) => self.visit_identifier_reference(ident), - TSTypeName::QualifiedName(name) => self.visit_ts_qualified_name(name), + TSTypeName::IdentifierReference(ident) => visitor.visit_identifier_reference(ident), + TSTypeName::QualifiedName(name) => visitor.visit_ts_qualified_name(name), } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_external_module_reference(&mut self, reference: &TSExternalModuleReference<'a>) { - let kind = AstKind::TSExternalModuleReference(self.alloc(reference)); - self.enter_node(kind); - self.visit_string_literal(&reference.expression); - self.leave_node(kind); + pub fn walk_ts_external_module_reference<'a, V: Visit<'a>>( + visitor: &mut V, + reference: &TSExternalModuleReference<'a>, + ) { + let kind = AstKind::TSExternalModuleReference(visitor.alloc(reference)); + visitor.enter_node(kind); + visitor.visit_string_literal(&reference.expression); + visitor.leave_node(kind); } - fn visit_ts_qualified_name(&mut self, name: &TSQualifiedName<'a>) { - let kind = AstKind::TSQualifiedName(self.alloc(name)); - self.enter_node(kind); - self.visit_ts_type_name(&name.left); - self.visit_identifier_name(&name.right); - self.leave_node(kind); + pub fn walk_ts_qualified_name<'a, V: Visit<'a>>(visitor: &mut V, name: &TSQualifiedName<'a>) { + let kind = AstKind::TSQualifiedName(visitor.alloc(name)); + visitor.enter_node(kind); + visitor.visit_ts_type_name(&name.left); + visitor.visit_identifier_name(&name.right); + visitor.leave_node(kind); } - fn visit_ts_module_declaration(&mut self, decl: &TSModuleDeclaration<'a>) { - let kind = AstKind::TSModuleDeclaration(self.alloc(decl)); - self.enter_node(kind); + pub fn walk_ts_module_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + decl: &TSModuleDeclaration<'a>, + ) { + let kind = AstKind::TSModuleDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); match &decl.id { - TSModuleDeclarationName::Identifier(ident) => self.visit_identifier_name(ident), - TSModuleDeclarationName::StringLiteral(lit) => self.visit_string_literal(lit), + TSModuleDeclarationName::Identifier(ident) => visitor.visit_identifier_name(ident), + TSModuleDeclarationName::StringLiteral(lit) => visitor.visit_string_literal(lit), } match &decl.body { TSModuleDeclarationBody::TSModuleDeclaration(decl) => { - self.visit_ts_module_declaration(decl); + visitor.visit_ts_module_declaration(decl); } - TSModuleDeclarationBody::TSModuleBlock(block) => self.visit_ts_module_block(block), + TSModuleDeclarationBody::TSModuleBlock(block) => visitor.visit_ts_module_block(block), } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_module_block(&mut self, block: &TSModuleBlock<'a>) { - let kind = AstKind::TSModuleBlock(self.alloc(block)); - self.enter_scope(ScopeFlags::TsModuleBlock); - self.enter_node(kind); - self.visit_statements(&block.body); - self.leave_node(kind); - self.leave_scope(); + pub fn walk_ts_module_block<'a, V: Visit<'a>>(visitor: &mut V, block: &TSModuleBlock<'a>) { + let kind = AstKind::TSModuleBlock(visitor.alloc(block)); + visitor.enter_scope(ScopeFlags::TsModuleBlock); + visitor.enter_node(kind); + visitor.visit_statements(&block.body); + visitor.leave_node(kind); + visitor.leave_scope(); } - fn visit_ts_type_alias_declaration(&mut self, decl: &TSTypeAliasDeclaration<'a>) { - let kind = AstKind::TSTypeAliasDeclaration(self.alloc(decl)); - self.enter_node(kind); - self.visit_binding_identifier(&decl.id); + pub fn walk_ts_type_alias_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + decl: &TSTypeAliasDeclaration<'a>, + ) { + let kind = AstKind::TSTypeAliasDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); + visitor.visit_binding_identifier(&decl.id); if let Some(parameters) = &decl.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); + visitor.visit_ts_type_parameter_declaration(parameters); } - self.visit_ts_type(&decl.type_annotation); - self.leave_node(kind); + visitor.visit_ts_type(&decl.type_annotation); + visitor.leave_node(kind); } - fn visit_ts_interface_declaration(&mut self, decl: &TSInterfaceDeclaration<'a>) { - let kind = AstKind::TSInterfaceDeclaration(self.alloc(decl)); - self.enter_node(kind); - self.visit_binding_identifier(&decl.id); + pub fn walk_ts_interface_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + decl: &TSInterfaceDeclaration<'a>, + ) { + let kind = AstKind::TSInterfaceDeclaration(visitor.alloc(decl)); + visitor.enter_node(kind); + visitor.visit_binding_identifier(&decl.id); if let Some(parameters) = &decl.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); + visitor.visit_ts_type_parameter_declaration(parameters); } for signature in &decl.body.body { - self.visit_ts_signature(signature); + visitor.visit_ts_signature(signature); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_as_expression(&mut self, expr: &TSAsExpression<'a>) { - let kind = AstKind::TSAsExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.expression); - self.visit_ts_type(&expr.type_annotation); - self.leave_node(kind); + pub fn walk_ts_as_expression<'a, V: Visit<'a>>(visitor: &mut V, expr: &TSAsExpression<'a>) { + let kind = AstKind::TSAsExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.expression); + visitor.visit_ts_type(&expr.type_annotation); + visitor.leave_node(kind); } - fn visit_ts_satisfies_expression(&mut self, expr: &TSSatisfiesExpression<'a>) { - let kind = AstKind::TSSatisfiesExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.expression); - self.visit_ts_type(&expr.type_annotation); - self.leave_node(kind); + pub fn walk_ts_satisfies_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &TSSatisfiesExpression<'a>, + ) { + let kind = AstKind::TSSatisfiesExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.expression); + visitor.visit_ts_type(&expr.type_annotation); + visitor.leave_node(kind); } - fn visit_ts_non_null_expression(&mut self, expr: &TSNonNullExpression<'a>) { - let kind = AstKind::TSNonNullExpression(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.expression); - self.leave_node(kind); + pub fn walk_ts_non_null_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &TSNonNullExpression<'a>, + ) { + let kind = AstKind::TSNonNullExpression(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.expression); + visitor.leave_node(kind); } - fn visit_ts_type_assertion(&mut self, expr: &TSTypeAssertion<'a>) { - let kind = AstKind::TSTypeAssertion(self.alloc(expr)); - self.enter_node(kind); - self.visit_expression(&expr.expression); - self.visit_ts_type(&expr.type_annotation); - self.leave_node(kind); + pub fn walk_ts_type_assertion<'a, V: Visit<'a>>(visitor: &mut V, expr: &TSTypeAssertion<'a>) { + let kind = AstKind::TSTypeAssertion(visitor.alloc(expr)); + visitor.enter_node(kind); + visitor.visit_expression(&expr.expression); + visitor.visit_ts_type(&expr.type_annotation); + visitor.leave_node(kind); } - fn visit_ts_instantiation_expression(&mut self, expr: &TSInstantiationExpression<'a>) { - self.visit_expression(&expr.expression); - self.visit_ts_type_parameter_instantiation(&expr.type_parameters); + pub fn walk_ts_instantiation_expression<'a, V: Visit<'a>>( + visitor: &mut V, + expr: &TSInstantiationExpression<'a>, + ) { + visitor.visit_expression(&expr.expression); + visitor.visit_ts_type_parameter_instantiation(&expr.type_parameters); } - fn visit_ts_type_annotation(&mut self, annotation: &TSTypeAnnotation<'a>) { - let kind = AstKind::TSTypeAnnotation(self.alloc(annotation)); - self.enter_node(kind); - self.visit_ts_type(&annotation.type_annotation); - self.leave_node(kind); + pub fn walk_ts_type_annotation<'a, V: Visit<'a>>( + visitor: &mut V, + annotation: &TSTypeAnnotation<'a>, + ) { + let kind = AstKind::TSTypeAnnotation(visitor.alloc(annotation)); + visitor.enter_node(kind); + visitor.visit_ts_type(&annotation.type_annotation); + visitor.leave_node(kind); } - fn visit_ts_type(&mut self, ty: &TSType<'a>) { + pub fn walk_ts_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSType<'a>) { match ty { - TSType::TSAnyKeyword(ty) => self.visit_ts_any_keyword(ty), - TSType::TSNullKeyword(ty) => self.visit_ts_null_keyword(ty), - TSType::TSVoidKeyword(ty) => self.visit_ts_void_keyword(ty), - TSType::TSIntersectionType(ty) => self.visit_ts_intersection_type(ty), - TSType::TSTypeReference(ty) => self.visit_ts_type_reference(ty), - TSType::TSUnionType(ty) => self.visit_ts_union_type(ty), - TSType::TSLiteralType(ty) => self.visit_ts_literal_type(ty), - TSType::TSArrayType(ty) => self.visit_ts_array_type(ty), - TSType::TSConditionalType(ty) => self.visit_ts_conditional_type(ty), - TSType::TSConstructorType(ty) => self.visit_ts_constructor_type(ty), - TSType::TSFunctionType(ty) => self.visit_ts_function_type(ty), - TSType::TSMappedType(ty) => self.visit_ts_mapped_type(ty), - TSType::TSTupleType(ty) => self.visit_ts_tuple_type(ty), - TSType::TSTypeOperatorType(ty) => self.visit_ts_type_operator_type(ty), - TSType::TSTypePredicate(ty) => self.visit_ts_type_predicate(ty), - TSType::TSTypeLiteral(ty) => self.visit_ts_type_literal(ty), - TSType::TSIndexedAccessType(ty) => self.visit_ts_indexed_access_type(ty), - TSType::TSTypeQuery(ty) => self.visit_ts_type_query(ty), + TSType::TSAnyKeyword(ty) => visitor.visit_ts_any_keyword(ty), + TSType::TSNullKeyword(ty) => visitor.visit_ts_null_keyword(ty), + TSType::TSVoidKeyword(ty) => visitor.visit_ts_void_keyword(ty), + TSType::TSIntersectionType(ty) => visitor.visit_ts_intersection_type(ty), + TSType::TSTypeReference(ty) => visitor.visit_ts_type_reference(ty), + TSType::TSUnionType(ty) => visitor.visit_ts_union_type(ty), + TSType::TSLiteralType(ty) => visitor.visit_ts_literal_type(ty), + TSType::TSArrayType(ty) => visitor.visit_ts_array_type(ty), + TSType::TSConditionalType(ty) => visitor.visit_ts_conditional_type(ty), + TSType::TSConstructorType(ty) => visitor.visit_ts_constructor_type(ty), + TSType::TSFunctionType(ty) => visitor.visit_ts_function_type(ty), + TSType::TSMappedType(ty) => visitor.visit_ts_mapped_type(ty), + TSType::TSTupleType(ty) => visitor.visit_ts_tuple_type(ty), + TSType::TSTypeOperatorType(ty) => visitor.visit_ts_type_operator_type(ty), + TSType::TSTypePredicate(ty) => visitor.visit_ts_type_predicate(ty), + TSType::TSTypeLiteral(ty) => visitor.visit_ts_type_literal(ty), + TSType::TSIndexedAccessType(ty) => visitor.visit_ts_indexed_access_type(ty), + TSType::TSTypeQuery(ty) => visitor.visit_ts_type_query(ty), _ => {} } } - fn visit_ts_type_literal(&mut self, ty: &TSTypeLiteral<'a>) { - let kind = AstKind::TSTypeLiteral(self.alloc(ty)); - self.enter_node(kind); + pub fn walk_ts_type_literal<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSTypeLiteral<'a>) { + let kind = AstKind::TSTypeLiteral(visitor.alloc(ty)); + visitor.enter_node(kind); for signature in &ty.members { - self.visit_ts_signature(signature); + visitor.visit_ts_signature(signature); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_indexed_access_type(&mut self, ty: &TSIndexedAccessType<'a>) { - let kind = AstKind::TSIndexedAccessType(self.alloc(ty)); - self.enter_node(kind); - self.visit_ts_type(&ty.object_type); - self.visit_ts_type(&ty.index_type); - self.leave_node(kind); + pub fn walk_ts_indexed_access_type<'a, V: Visit<'a>>( + visitor: &mut V, + ty: &TSIndexedAccessType<'a>, + ) { + let kind = AstKind::TSIndexedAccessType(visitor.alloc(ty)); + visitor.enter_node(kind); + visitor.visit_ts_type(&ty.object_type); + visitor.visit_ts_type(&ty.index_type); + visitor.leave_node(kind); } - fn visit_ts_type_predicate(&mut self, ty: &TSTypePredicate<'a>) { + pub fn walk_ts_type_predicate<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSTypePredicate<'a>) { if let Some(annotation) = &ty.type_annotation { - self.visit_ts_type_annotation(annotation); + visitor.visit_ts_type_annotation(annotation); } } - fn visit_ts_type_operator_type(&mut self, ty: &TSTypeOperator<'a>) { - self.visit_ts_type(&ty.type_annotation); + pub fn walk_ts_type_operator_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSTypeOperator<'a>) { + visitor.visit_ts_type(&ty.type_annotation); } - fn visit_ts_tuple_type(&mut self, ty: &TSTupleType<'a>) { + pub fn walk_ts_tuple_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSTupleType<'a>) { for element in &ty.element_types { - self.visit_ts_tuple_element(element); + visitor.visit_ts_tuple_element(element); } } - fn visit_ts_tuple_element(&mut self, ty: &TSTupleElement<'a>) { + pub fn walk_ts_tuple_element<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSTupleElement<'a>) { match ty { - TSTupleElement::TSType(ty) => self.visit_ts_type(ty), - TSTupleElement::TSOptionalType(ty) => self.visit_ts_type(&ty.type_annotation), - TSTupleElement::TSRestType(ty) => self.visit_ts_type(&ty.type_annotation), - TSTupleElement::TSNamedTupleMember(ty) => self.visit_ts_type(&ty.element_type), + TSTupleElement::TSType(ty) => visitor.visit_ts_type(ty), + TSTupleElement::TSOptionalType(ty) => visitor.visit_ts_type(&ty.type_annotation), + TSTupleElement::TSRestType(ty) => visitor.visit_ts_type(&ty.type_annotation), + TSTupleElement::TSNamedTupleMember(ty) => visitor.visit_ts_type(&ty.element_type), }; } - fn visit_ts_mapped_type(&mut self, ty: &TSMappedType<'a>) { - self.visit_ts_type_parameter(&ty.type_parameter); + pub fn walk_ts_mapped_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSMappedType<'a>) { + visitor.visit_ts_type_parameter(&ty.type_parameter); if let Some(name) = &ty.name_type { - self.visit_ts_type(name); + visitor.visit_ts_type(name); } if let Some(type_annotation) = &ty.type_annotation { - self.visit_ts_type(type_annotation); + visitor.visit_ts_type(type_annotation); } } - fn visit_ts_function_type(&mut self, ty: &TSFunctionType<'a>) { - self.visit_formal_parameters(&ty.params); + pub fn walk_ts_function_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSFunctionType<'a>) { + visitor.visit_formal_parameters(&ty.params); if let Some(parameters) = &ty.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); + visitor.visit_ts_type_parameter_declaration(parameters); } - self.visit_ts_type_annotation(&ty.return_type); + visitor.visit_ts_type_annotation(&ty.return_type); } - fn visit_ts_type_parameter(&mut self, ty: &TSTypeParameter<'a>) { - let kind = AstKind::TSTypeParameter(self.alloc(ty)); - self.enter_scope(ScopeFlags::empty()); - self.enter_node(kind); + pub fn walk_ts_type_parameter<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSTypeParameter<'a>) { + let kind = AstKind::TSTypeParameter(visitor.alloc(ty)); + visitor.enter_scope(ScopeFlags::empty()); + visitor.enter_node(kind); if let Some(constraint) = &ty.constraint { - self.visit_ts_type(constraint); + visitor.visit_ts_type(constraint); } if let Some(default) = &ty.default { - self.visit_ts_type(default); + visitor.visit_ts_type(default); } - self.leave_node(kind); - self.leave_scope(); + visitor.leave_node(kind); + visitor.leave_scope(); } - fn visit_ts_type_parameter_instantiation(&mut self, ty: &TSTypeParameterInstantiation<'a>) { - let kind = AstKind::TSTypeParameterInstantiation(self.alloc(ty)); - self.enter_node(kind); + pub fn walk_ts_type_parameter_instantiation<'a, V: Visit<'a>>( + visitor: &mut V, + ty: &TSTypeParameterInstantiation<'a>, + ) { + let kind = AstKind::TSTypeParameterInstantiation(visitor.alloc(ty)); + visitor.enter_node(kind); for ts_parameter in &ty.params { - self.visit_ts_type(ts_parameter); + visitor.visit_ts_type(ts_parameter); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_type_parameter_declaration(&mut self, ty: &TSTypeParameterDeclaration<'a>) { - let kind = AstKind::TSTypeParameterDeclaration(self.alloc(ty)); - self.enter_node(kind); + pub fn walk_ts_type_parameter_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + ty: &TSTypeParameterDeclaration<'a>, + ) { + let kind = AstKind::TSTypeParameterDeclaration(visitor.alloc(ty)); + visitor.enter_node(kind); for ts_parameter in &ty.params { - self.visit_ts_type_parameter(ts_parameter); + visitor.visit_ts_type_parameter(ts_parameter); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_constructor_type(&mut self, ty: &TSConstructorType<'a>) { - self.visit_formal_parameters(&ty.params); + pub fn walk_ts_constructor_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSConstructorType<'a>) { + visitor.visit_formal_parameters(&ty.params); if let Some(parameters) = &ty.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); + visitor.visit_ts_type_parameter_declaration(parameters); } - self.visit_ts_type_annotation(&ty.return_type); + visitor.visit_ts_type_annotation(&ty.return_type); } - fn visit_ts_conditional_type(&mut self, ty: &TSConditionalType<'a>) { - self.visit_ts_type(&ty.check_type); - self.visit_ts_type(&ty.extends_type); - self.visit_ts_type(&ty.true_type); - self.visit_ts_type(&ty.false_type); + pub fn walk_ts_conditional_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSConditionalType<'a>) { + visitor.visit_ts_type(&ty.check_type); + visitor.visit_ts_type(&ty.extends_type); + visitor.visit_ts_type(&ty.true_type); + visitor.visit_ts_type(&ty.false_type); } - fn visit_ts_array_type(&mut self, ty: &TSArrayType<'a>) { - self.visit_ts_type(&ty.element_type); + pub fn walk_ts_array_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSArrayType<'a>) { + visitor.visit_ts_type(&ty.element_type); } - fn visit_ts_null_keyword(&mut self, ty: &TSNullKeyword) { - let kind = AstKind::TSNullKeyword(self.alloc(ty)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_ts_null_keyword<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSNullKeyword) { + let kind = AstKind::TSNullKeyword(visitor.alloc(ty)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_ts_any_keyword(&mut self, ty: &TSAnyKeyword) { - let kind = AstKind::TSAnyKeyword(self.alloc(ty)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_ts_any_keyword<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSAnyKeyword) { + let kind = AstKind::TSAnyKeyword(visitor.alloc(ty)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_ts_void_keyword(&mut self, ty: &TSVoidKeyword) { - let kind = AstKind::TSVoidKeyword(self.alloc(ty)); - self.enter_node(kind); - self.leave_node(kind); + pub fn walk_ts_void_keyword<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSVoidKeyword) { + let kind = AstKind::TSVoidKeyword(visitor.alloc(ty)); + visitor.enter_node(kind); + visitor.leave_node(kind); } - fn visit_ts_intersection_type(&mut self, ty: &TSIntersectionType<'a>) { - let kind = AstKind::TSIntersectionType(self.alloc(ty)); - self.enter_node(kind); + pub fn walk_ts_intersection_type<'a, V: Visit<'a>>( + visitor: &mut V, + ty: &TSIntersectionType<'a>, + ) { + let kind = AstKind::TSIntersectionType(visitor.alloc(ty)); + visitor.enter_node(kind); for ty in &ty.types { - self.visit_ts_type(ty); + visitor.visit_ts_type(ty); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_type_reference(&mut self, ty: &TSTypeReference<'a>) { - let kind = AstKind::TSTypeReference(self.alloc(ty)); - self.enter_node(kind); - self.visit_ts_type_name(&ty.type_name); + pub fn walk_ts_type_reference<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSTypeReference<'a>) { + let kind = AstKind::TSTypeReference(visitor.alloc(ty)); + visitor.enter_node(kind); + visitor.visit_ts_type_name(&ty.type_name); if let Some(parameters) = &ty.type_parameters { - self.visit_ts_type_parameter_instantiation(parameters); + visitor.visit_ts_type_parameter_instantiation(parameters); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_union_type(&mut self, ty: &TSUnionType<'a>) { - let kind = AstKind::TSUnionType(self.alloc(ty)); - self.enter_node(kind); + pub fn walk_ts_union_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSUnionType<'a>) { + let kind = AstKind::TSUnionType(visitor.alloc(ty)); + visitor.enter_node(kind); for ty in &ty.types { - self.visit_ts_type(ty); + visitor.visit_ts_type(ty); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_literal_type(&mut self, ty: &TSLiteralType<'a>) { - let kind = AstKind::TSLiteralType(self.alloc(ty)); - self.enter_node(kind); + pub fn walk_ts_literal_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSLiteralType<'a>) { + let kind = AstKind::TSLiteralType(visitor.alloc(ty)); + visitor.enter_node(kind); match &ty.literal { - TSLiteral::BigintLiteral(lit) => self.visit_bigint_literal(lit), - TSLiteral::BooleanLiteral(lit) => self.visit_boolean_literal(lit), - TSLiteral::NullLiteral(lit) => self.visit_null_literal(lit), - TSLiteral::NumericLiteral(lit) => self.visit_number_literal(lit), - TSLiteral::RegExpLiteral(lit) => self.visit_reg_expr_literal(lit), - TSLiteral::StringLiteral(lit) => self.visit_string_literal(lit), - TSLiteral::TemplateLiteral(lit) => self.visit_template_literal(lit), - TSLiteral::UnaryExpression(expr) => self.visit_unary_expression(expr), + TSLiteral::BigintLiteral(lit) => visitor.visit_bigint_literal(lit), + TSLiteral::BooleanLiteral(lit) => visitor.visit_boolean_literal(lit), + TSLiteral::NullLiteral(lit) => visitor.visit_null_literal(lit), + TSLiteral::NumericLiteral(lit) => visitor.visit_number_literal(lit), + TSLiteral::RegExpLiteral(lit) => visitor.visit_reg_expr_literal(lit), + TSLiteral::StringLiteral(lit) => visitor.visit_string_literal(lit), + TSLiteral::TemplateLiteral(lit) => visitor.visit_template_literal(lit), + TSLiteral::UnaryExpression(expr) => visitor.visit_unary_expression(expr), } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_signature(&mut self, signature: &TSSignature<'a>) { + pub fn walk_ts_signature<'a, V: Visit<'a>>(visitor: &mut V, signature: &TSSignature<'a>) { match &signature { - TSSignature::TSPropertySignature(sig) => self.visit_ts_property_signature(sig), + TSSignature::TSPropertySignature(sig) => visitor.visit_ts_property_signature(sig), TSSignature::TSCallSignatureDeclaration(sig) => { - self.visit_ts_call_signature_declaration(sig); + visitor.visit_ts_call_signature_declaration(sig); } - TSSignature::TSIndexSignature(sig) => self.visit_ts_index_signature(sig), - TSSignature::TSMethodSignature(sig) => self.visit_ts_method_signature(sig), + TSSignature::TSIndexSignature(sig) => visitor.visit_ts_index_signature(sig), + TSSignature::TSMethodSignature(sig) => visitor.visit_ts_method_signature(sig), TSSignature::TSConstructSignatureDeclaration(sig) => { - self.visit_ts_construct_signature_declaration(sig); + visitor.visit_ts_construct_signature_declaration(sig); } } } - fn visit_ts_construct_signature_declaration( - &mut self, + pub fn walk_ts_construct_signature_declaration<'a, V: Visit<'a>>( + visitor: &mut V, signature: &TSConstructSignatureDeclaration<'a>, ) { - self.visit_formal_parameters(&signature.params); + visitor.visit_formal_parameters(&signature.params); if let Some(parameters) = &signature.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); + visitor.visit_ts_type_parameter_declaration(parameters); } if let Some(annotation) = &signature.return_type { - self.visit_ts_type_annotation(annotation); + visitor.visit_ts_type_annotation(annotation); } } - fn visit_ts_method_signature(&mut self, signature: &TSMethodSignature<'a>) { - let kind = AstKind::TSMethodSignature(self.alloc(signature)); - self.enter_node(kind); - self.visit_formal_parameters(&signature.params); + pub fn walk_ts_method_signature<'a, V: Visit<'a>>( + visitor: &mut V, + signature: &TSMethodSignature<'a>, + ) { + let kind = AstKind::TSMethodSignature(visitor.alloc(signature)); + visitor.enter_node(kind); + visitor.visit_formal_parameters(&signature.params); if let Some(parameters) = &signature.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); + visitor.visit_ts_type_parameter_declaration(parameters); } if let Some(annotation) = &signature.return_type { - self.visit_ts_type_annotation(annotation); + visitor.visit_ts_type_annotation(annotation); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_index_signature_name(&mut self, name: &TSIndexSignatureName<'a>) { - self.visit_ts_type_annotation(&name.type_annotation); + pub fn walk_ts_index_signature_name<'a, V: Visit<'a>>( + visitor: &mut V, + name: &TSIndexSignatureName<'a>, + ) { + visitor.visit_ts_type_annotation(&name.type_annotation); } - fn visit_ts_index_signature(&mut self, signature: &TSIndexSignature<'a>) { + pub fn walk_ts_index_signature<'a, V: Visit<'a>>( + visitor: &mut V, + signature: &TSIndexSignature<'a>, + ) { for name in &signature.parameters { - self.visit_ts_index_signature_name(name); + visitor.visit_ts_index_signature_name(name); } - self.visit_ts_type_annotation(&signature.type_annotation); + visitor.visit_ts_type_annotation(&signature.type_annotation); } - fn visit_ts_property_signature(&mut self, signature: &TSPropertySignature<'a>) { - let kind = AstKind::TSPropertySignature(self.alloc(signature)); - self.enter_node(kind); - self.visit_property_key(&signature.key); + pub fn walk_ts_property_signature<'a, V: Visit<'a>>( + visitor: &mut V, + signature: &TSPropertySignature<'a>, + ) { + let kind = AstKind::TSPropertySignature(visitor.alloc(signature)); + visitor.enter_node(kind); + visitor.visit_property_key(&signature.key); if let Some(annotation) = &signature.type_annotation { - self.visit_ts_type_annotation(annotation); + visitor.visit_ts_type_annotation(annotation); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_call_signature_declaration(&mut self, signature: &TSCallSignatureDeclaration<'a>) { - self.visit_formal_parameters(&signature.params); + pub fn walk_ts_call_signature_declaration<'a, V: Visit<'a>>( + visitor: &mut V, + signature: &TSCallSignatureDeclaration<'a>, + ) { + visitor.visit_formal_parameters(&signature.params); if let Some(parameters) = &signature.type_parameters { - self.visit_ts_type_parameter_declaration(parameters); + visitor.visit_ts_type_parameter_declaration(parameters); } if let Some(annotation) = &signature.return_type { - self.visit_ts_type_annotation(annotation); + visitor.visit_ts_type_annotation(annotation); } } - fn visit_ts_type_query(&mut self, ty: &TSTypeQuery<'a>) { - let kind = AstKind::TSTypeQuery(self.alloc(ty)); - self.enter_node(kind); + pub fn walk_ts_type_query<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSTypeQuery<'a>) { + let kind = AstKind::TSTypeQuery(visitor.alloc(ty)); + visitor.enter_node(kind); match &ty.expr_name { - TSTypeQueryExprName::TSTypeName(name) => self.visit_ts_type_name(name), - TSTypeQueryExprName::TSImportType(import) => self.visit_ts_import_type(import), + TSTypeQueryExprName::TSTypeName(name) => visitor.visit_ts_type_name(name), + TSTypeQueryExprName::TSImportType(import) => visitor.visit_ts_import_type(import), } if let Some(type_parameters) = &ty.type_parameters { - self.visit_ts_type_parameter_instantiation(type_parameters); + visitor.visit_ts_type_parameter_instantiation(type_parameters); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_import_type(&mut self, ty: &TSImportType<'a>) { - let kind = AstKind::TSImportType(self.alloc(ty)); - self.enter_node(kind); - self.visit_ts_type(&ty.argument); + pub fn walk_ts_import_type<'a, V: Visit<'a>>(visitor: &mut V, ty: &TSImportType<'a>) { + let kind = AstKind::TSImportType(visitor.alloc(ty)); + visitor.enter_node(kind); + visitor.visit_ts_type(&ty.argument); if let Some(name) = &ty.qualifier { - self.visit_ts_type_name(name); + visitor.visit_ts_type_name(name); } if let Some(attrs) = &ty.attributes { - self.visit_ts_import_attributes(attrs); + visitor.visit_ts_import_attributes(attrs); } if let Some(type_parameter) = &ty.type_parameters { - self.visit_ts_type_parameter_instantiation(type_parameter); + visitor.visit_ts_type_parameter_instantiation(type_parameter); } - self.leave_node(kind); + visitor.leave_node(kind); } - fn visit_ts_import_attributes(&mut self, attributes: &TSImportAttributes<'a>) { + pub fn walk_ts_import_attributes<'a, V: Visit<'a>>( + visitor: &mut V, + attributes: &TSImportAttributes<'a>, + ) { for element in &attributes.elements { - self.visit_ts_import_attribute(element); + visitor.visit_ts_import_attribute(element); } } - fn visit_ts_import_attribute(&mut self, attribute: &TSImportAttribute<'a>) { - self.visit_ts_import_attribute_name(&attribute.name); - self.visit_expression(&attribute.value); + pub fn walk_ts_import_attribute<'a, V: Visit<'a>>( + visitor: &mut V, + attribute: &TSImportAttribute<'a>, + ) { + visitor.visit_ts_import_attribute_name(&attribute.name); + visitor.visit_expression(&attribute.value); } - fn visit_ts_import_attribute_name(&mut self, name: &TSImportAttributeName<'a>) { + pub fn walk_ts_import_attribute_name<'a, V: Visit<'a>>( + visitor: &mut V, + name: &TSImportAttributeName<'a>, + ) { match name { - TSImportAttributeName::Identifier(ident) => self.visit_identifier_name(ident), - TSImportAttributeName::StringLiteral(ident) => self.visit_string_literal(ident), + TSImportAttributeName::Identifier(ident) => visitor.visit_identifier_name(ident), + TSImportAttributeName::StringLiteral(ident) => visitor.visit_string_literal(ident), } } } diff --git a/crates/oxc_module_lexer/src/lib.rs b/crates/oxc_module_lexer/src/lib.rs index 535e5f224ae23..fdcc2a28f07c3 100644 --- a/crates/oxc_module_lexer/src/lib.rs +++ b/crates/oxc_module_lexer/src/lib.rs @@ -2,8 +2,12 @@ //! //! * +use oxc_ast::walk::{ + walk_export_all_declaration, walk_export_named_declaration, walk_import_declaration, + walk_import_expression, walk_meta_property, walk_module_declaration, walk_statement, +}; #[allow(clippy::wildcard_imports)] -use oxc_ast::{ast::*, syntax_directed_operations::BoundNames, AstKind, Visit}; +use oxc_ast::{ast::*, syntax_directed_operations::BoundNames, Visit}; use oxc_span::{Atom, GetSpan}; #[derive(Debug, Clone)] @@ -109,161 +113,170 @@ impl<'a> ModuleLexer<'a> { } impl<'a> Visit<'a> for ModuleLexer<'a> { - fn enter_node(&mut self, kind: AstKind<'a>) { - match kind { - kind if self.facade && kind.is_statement() => { + fn visit_statement(&mut self, stmt: &Statement<'a>) { + if self.facade + && !matches!(stmt, Statement::ModuleDeclaration(..) | Statement::Declaration(..)) + { + self.facade = false; + } + + walk_statement(self, stmt); + } + + fn visit_module_declaration(&mut self, decl: &ModuleDeclaration<'a>) { + if !self.has_module_syntax { + self.has_module_syntax = true; + } + walk_module_declaration(self, decl); + } + + // import.meta + fn visit_meta_property(&mut self, prop: &MetaProperty<'a>) { + if !self.has_module_syntax { + self.has_module_syntax = true; + } + if prop.meta.name == "import" && prop.property.name == "meta" { + self.imports.push(ImportSpecifier { + n: None, + s: prop.span.start, + e: prop.span.end, + ss: prop.span.start, + se: prop.span.end, + d: ImportType::ImportMeta, + a: None, + }); + } + walk_meta_property(self, prop); + } + + // import("foo") + fn visit_import_expression(&mut self, expr: &ImportExpression<'a>) { + let (source, source_span_start, source_span_end) = + if let Expression::StringLiteral(s) = &expr.source { + (Some(s.value.clone()), s.span.start, s.span.end) + } else { + let span = expr.source.span(); + (None, span.start, span.end) + }; + self.imports.push(ImportSpecifier { + n: source, + s: source_span_start, + e: source_span_end, + ss: expr.span.start, + se: expr.span.end, + d: ImportType::DynamicImport(expr.span.start + 6), + a: expr.arguments.first().map(|e| e.span().start), + }); + walk_import_expression(self, expr); + } + + fn visit_import_declaration(&mut self, decl: &ImportDeclaration<'a>) { + let assertions = decl + .with_clause + .as_ref() + .filter(|c| c.with_entries.first().is_some_and(|a| a.key.as_atom() == "type")) + .map(|c| c.span.start); + self.imports.push(ImportSpecifier { + n: Some(decl.source.value.clone()), + s: decl.source.span.start + 1, // +- 1 for removing string quotes + e: decl.source.span.end - 1, + ss: decl.span.start, + se: decl.span.end, + d: ImportType::StaticImport, + a: assertions, + }); + walk_import_declaration(self, decl); + } + + fn visit_export_named_declaration(&mut self, decl: &ExportNamedDeclaration<'a>) { + if let Some(source) = &decl.source { + // export { named } from 'foo' + self.imports.push(ImportSpecifier { + n: Some(source.value.clone()), + s: source.span.start + 1, + e: source.span.end - 1, + ss: decl.span.start, + se: decl.span.end, + d: ImportType::StaticImport, + a: None, + }); + } + + // export const/let/var/function/class ... + if let Some(decl) = &decl.declaration { + if self.facade { self.facade = false; } - AstKind::ModuleDeclaration(_) if !self.has_module_syntax => { - self.has_module_syntax = true; - } - // import.meta - AstKind::MetaProperty(prop) => { - if !self.has_module_syntax { - self.has_module_syntax = true; - } - if prop.meta.name == "import" && prop.property.name == "meta" { - self.imports.push(ImportSpecifier { - n: None, - s: prop.span.start, - e: prop.span.end, - ss: prop.span.start, - se: prop.span.end, - d: ImportType::ImportMeta, - a: None, - }); - } - } - // import("foo") - AstKind::ImportExpression(expr) => { - let (source, source_span_start, source_span_end) = - if let Expression::StringLiteral(s) = &expr.source { - (Some(s.value.clone()), s.span.start, s.span.end) - } else { - let span = expr.source.span(); - (None, span.start, span.end) - }; - self.imports.push(ImportSpecifier { - n: source, - s: source_span_start, - e: source_span_end, - ss: expr.span.start, - se: expr.span.end, - d: ImportType::DynamicImport(expr.span.start + 6), - a: expr.arguments.first().map(|e| e.span().start), - }); - } - AstKind::ImportDeclaration(decl) => { - let assertions = decl - .with_clause - .as_ref() - .filter(|c| c.with_entries.first().is_some_and(|a| a.key.as_atom() == "type")) - .map(|c| c.span.start); - self.imports.push(ImportSpecifier { - n: Some(decl.source.value.clone()), - s: decl.source.span.start + 1, // +- 1 for removing string quotes - e: decl.source.span.end - 1, - ss: decl.span.start, - se: decl.span.end, - d: ImportType::StaticImport, - a: assertions, - }); - } - AstKind::ExportNamedDeclaration(decl) => { - if let Some(source) = &decl.source { - // export { named } from 'foo' - self.imports.push(ImportSpecifier { - n: Some(source.value.clone()), - s: source.span.start + 1, - e: source.span.end - 1, - ss: decl.span.start, - se: decl.span.end, - d: ImportType::StaticImport, - a: None, - }); - } - - // export const/let/var/function/class ... - if let Some(decl) = &decl.declaration { - if self.facade { - self.facade = false; - } - decl.bound_names(&mut |ident| { - self.exports.push(ExportSpecifier { - n: ident.name.clone(), - ln: Some(ident.name.clone()), - s: ident.span.start, - e: ident.span.end, - ls: None, - le: None, - }); - }); - } - - // export { named } - self.exports.extend(decl.specifiers.iter().map(|s| { - let (exported_start, exported_end) = match &s.exported { - ModuleExportName::Identifier(ident) => (ident.span.start, ident.span.end), - // +1 -1 to remove the string quotes - ModuleExportName::StringLiteral(s) => (s.span.start + 1, s.span.end - 1), - }; - ExportSpecifier { - n: s.exported.name().clone(), - ln: decl.source.is_none().then(|| s.local.name().clone()), - s: exported_start, - e: exported_end, - ls: Some(s.local.span().start), - le: Some(s.local.span().end), - } - })); - } - // export default foo - AstKind::ExportDefaultDeclaration(decl) => { - if self.facade { - self.facade = false; - } - let ln = match &decl.declaration { - ExportDefaultDeclarationKind::FunctionDeclaration(func) => func.id.as_ref(), - ExportDefaultDeclarationKind::ClassDeclaration(class) => class.id.as_ref(), - ExportDefaultDeclarationKind::Expression(_) - | ExportDefaultDeclarationKind::TSInterfaceDeclaration(_) - | ExportDefaultDeclarationKind::TSEnumDeclaration(_) => None, - }; + decl.bound_names(&mut |ident| { self.exports.push(ExportSpecifier { - n: decl.exported.name().clone(), - ln: ln.map(|id| id.name.clone()), - s: decl.exported.span().start, - e: decl.exported.span().end, + n: ident.name.clone(), + ln: Some(ident.name.clone()), + s: ident.span.start, + e: ident.span.end, ls: None, le: None, }); + }); + } + + // export { named } + self.exports.extend(decl.specifiers.iter().map(|s| { + let (exported_start, exported_end) = match &s.exported { + ModuleExportName::Identifier(ident) => (ident.span.start, ident.span.end), + // +1 -1 to remove the string quotes + ModuleExportName::StringLiteral(s) => (s.span.start + 1, s.span.end - 1), + }; + ExportSpecifier { + n: s.exported.name().clone(), + ln: decl.source.is_none().then(|| s.local.name().clone()), + s: exported_start, + e: exported_end, + ls: Some(s.local.span().start), + le: Some(s.local.span().end), } - AstKind::ExportAllDeclaration(decl) => { - // export * as ns from 'foo' - if let Some(exported) = &decl.exported { - let n = exported.name().clone(); - let s = exported.span().start; - let e = exported.span().end; - self.exports.push(ExportSpecifier { - n: n.clone(), - ln: None, - s, - e, - ls: None, - le: None, - }); - self.imports.push(ImportSpecifier { - n: Some(n), - s, - e, - ss: decl.span.start, - se: decl.span.end, - d: ImportType::StaticImport, - a: None, - }); - } - } - _ => {} + })); + walk_export_named_declaration(self, decl); + } + + // export default foo + fn visit_export_default_declaration(&mut self, decl: &ExportDefaultDeclaration<'a>) { + if self.facade { + self.facade = false; + } + let ln = match &decl.declaration { + ExportDefaultDeclarationKind::FunctionDeclaration(func) => func.id.as_ref(), + ExportDefaultDeclarationKind::ClassDeclaration(class) => class.id.as_ref(), + ExportDefaultDeclarationKind::Expression(_) + | ExportDefaultDeclarationKind::TSInterfaceDeclaration(_) + | ExportDefaultDeclarationKind::TSEnumDeclaration(_) => None, + }; + self.exports.push(ExportSpecifier { + n: decl.exported.name().clone(), + ln: ln.map(|id| id.name.clone()), + s: decl.exported.span().start, + e: decl.exported.span().end, + ls: None, + le: None, + }); + } + + fn visit_export_all_declaration(&mut self, decl: &ExportAllDeclaration<'a>) { + // export * as ns from 'foo' + if let Some(exported) = &decl.exported { + let n = exported.name().clone(); + let s = exported.span().start; + let e = exported.span().end; + self.exports.push(ExportSpecifier { n: n.clone(), ln: None, s, e, ls: None, le: None }); + self.imports.push(ImportSpecifier { + n: Some(n), + s, + e, + ss: decl.span.start, + se: decl.span.end, + d: ImportType::StaticImport, + a: None, + }); } + walk_export_all_declaration(self, decl); } } diff --git a/crates/oxc_parser/examples/visitor.rs b/crates/oxc_parser/examples/visitor.rs index 32f3c064a6c0d..2d3d559024a1c 100644 --- a/crates/oxc_parser/examples/visitor.rs +++ b/crates/oxc_parser/examples/visitor.rs @@ -1,9 +1,14 @@ use std::{env, path::Path}; use oxc_allocator::Allocator; -use oxc_ast::{AstKind, Visit}; +use oxc_ast::{ + ast::{Class, Function}, + walk::{walk_class, walk_function}, + Visit, +}; use oxc_parser::Parser; use oxc_span::SourceType; +use oxc_syntax::scope::ScopeFlags; // Instruction: // create a `test.js`, @@ -39,15 +44,13 @@ struct ASTPass { } impl<'a> Visit<'a> for ASTPass { - fn enter_node(&mut self, kind: AstKind<'a>) { - match kind { - AstKind::Function(_) => { - self.number_of_functions += 1; - } - AstKind::Class(_) => { - self.number_of_classes += 1; - } - _ => {} - } + fn visit_function(&mut self, func: &Function<'a>, flags: Option) { + self.number_of_functions += 1; + walk_function(self, func, flags); + } + + fn visit_class(&mut self, class: &Class<'a>) { + self.number_of_classes += 1; + walk_class(self, class); } } From 9057ebea9509248397061b16b49576377f146684 Mon Sep 17 00:00:00 2001 From: Boshen Date: Mon, 25 Mar 2024 11:00:28 +0800 Subject: [PATCH 10/11] chore: enable renovate "lockFileMaintenance" --- .github/renovate.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/renovate.json b/.github/renovate.json index a000a88680a81..81eda38383a85 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -33,5 +33,8 @@ "matchManagers": ["npm"], "enabled": false } - ] + ], + "lockFileMaintenance": { + "enabled": true + } } From 3d761f17c2188a48dd0871c05e77c9326c93bdf9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:24:30 +0800 Subject: [PATCH 11/11] chore(deps): lock file maintenance rust crates (#2804) --- Cargo.lock | 118 ++++++++++++++++------------------- crates/oxc_linter/Cargo.toml | 2 +- tasks/coverage/Cargo.toml | 2 +- 3 files changed, 55 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ea31de63e52de..162279a29e2a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -52,13 +52,13 @@ checksum = "7330592adf847ee2e3513587b4db2db410a0d751378654e7e993d9adcbe5c795" [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -69,7 +69,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -80,9 +80,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -169,7 +169,7 @@ checksum = "9a8d5b11f7fa1068e5bbac8ab6c8c2c6940047f69185987446b60c995d4bf89c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -214,9 +214,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cast" @@ -274,9 +274,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.2" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" dependencies = [ "clap_builder", ] @@ -449,7 +449,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad291aa74992b9b7a7e88c38acbbf6ad7e107f1d90ee8775b7bc1fc3394f485c" dependencies = [ "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -565,9 +565,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "fixedbitset" @@ -669,7 +669,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -891,17 +891,6 @@ dependencies = [ "yaml-rust", ] -[[package]] -name = "is-terminal" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "is_ci" version = "1.2.0" @@ -1090,7 +1079,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1171,7 +1160,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1186,7 +1175,7 @@ dependencies = [ "quote", "regex", "semver 1.0.22", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1325,7 +1314,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1698,9 +1687,9 @@ dependencies = [ [[package]] name = "oxc_resolver" -version = "1.6.2" +version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e25e001325ea3e526424f01c6bdd5fda061eec2cc4cb21b6e64e660c0d8a14a1" +checksum = "2a4f9f34e553d819007f46b435a32b3bef39240cf2af2bf40288bb24dca1621a" dependencies = [ "dashmap", "dunce", @@ -1889,7 +1878,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1943,7 +1932,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1978,7 +1967,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -2020,7 +2009,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", "version_check", "yansi", ] @@ -2208,9 +2197,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ "bitflags 2.5.0", "errno", @@ -2235,9 +2224,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" +checksum = "868e20fada228fefaf6b652e00cc73623d54f8171e7352c18bb281571f2d92da" [[package]] name = "rustls-webpki" @@ -2341,7 +2330,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -2352,7 +2341,7 @@ checksum = "e578a843d40b4189a4d66bba51d7684f57da5bd7c304c64e14bd63efbef49509" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -2375,14 +2364,14 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] name = "serde_yaml" -version = "0.9.33" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0623d197252096520c6f2a5e1171ee436e5af99a5d7caa2891e55e61950e6d9" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ "indexmap", "itoa", @@ -2452,9 +2441,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smawk" @@ -2517,11 +2506,10 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "supports-color" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +checksum = "9829b314621dfc575df4e409e79f9d6a66a3bd707ab73f23cb4aa3a854ac854f" dependencies = [ - "is-terminal", "is_ci", ] @@ -2538,9 +2526,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" dependencies = [ "proc-macro2", "quote", @@ -2593,7 +2581,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -2658,7 +2646,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -2743,7 +2731,7 @@ checksum = "84fd902d4e0b9a4b27f2f440108dc034e1758628a9b702f8ec61ad66355422fa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -2771,7 +2759,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -2835,7 +2823,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -2961,9 +2949,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" [[package]] name = "valuable" @@ -3014,7 +3002,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", "wasm-bindgen-shared", ] @@ -3036,7 +3024,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3258,9 +3246,9 @@ dependencies = [ [[package]] name = "yansi" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c2861d76f58ec8fc95708b9b1e417f7b12fd72ad33c01fa6886707092dea0d3" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "zeroize" diff --git a/crates/oxc_linter/Cargo.toml b/crates/oxc_linter/Cargo.toml index c8443189000fa..d9fa81b973585 100644 --- a/crates/oxc_linter/Cargo.toml +++ b/crates/oxc_linter/Cargo.toml @@ -29,7 +29,7 @@ oxc_semantic = { workspace = true } oxc_syntax = { workspace = true } oxc_codegen = { workspace = true } oxc_index = { workspace = true } -oxc_resolver = { version = "1.6.2" } +oxc_resolver = { version = "1.6.3" } rayon = { workspace = true } lazy_static = { workspace = true } # used in oxc_macros diff --git a/tasks/coverage/Cargo.toml b/tasks/coverage/Cargo.toml index 1943cb649e39d..e86ce7f43c610 100644 --- a/tasks/coverage/Cargo.toml +++ b/tasks/coverage/Cargo.toml @@ -48,5 +48,5 @@ tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } console = "0.15.8" encoding_rs = "0.8.33" encoding_rs_io = "0.1.7" -serde_yaml = "0.9.33" +serde_yaml = "0.9.34" similar = "2.4.0"