2022-01-27 11:41:43 +03:00
|
|
|
#![deny(warnings)]
|
|
|
|
|
2021-07-30 04:11:27 +03:00
|
|
|
extern crate swc_node_base;
|
|
|
|
|
2021-08-13 13:03:04 +03:00
|
|
|
use std::{
|
|
|
|
env,
|
2021-08-25 11:23:55 +03:00
|
|
|
fmt::{self, Debug},
|
2021-08-13 13:03:04 +03:00
|
|
|
fs::read_to_string,
|
|
|
|
panic::catch_unwind,
|
|
|
|
path::{Path, PathBuf},
|
|
|
|
time::Instant,
|
|
|
|
};
|
2022-02-09 09:33:32 +03:00
|
|
|
|
|
|
|
use ansi_term::Color;
|
2022-05-25 09:23:35 +03:00
|
|
|
use anyhow::Error;
|
2022-02-09 09:33:32 +03:00
|
|
|
use once_cell::sync::Lazy;
|
|
|
|
use serde::Deserialize;
|
2021-08-13 13:03:04 +03:00
|
|
|
use swc_common::{
|
2022-09-01 07:36:30 +03:00
|
|
|
comments::SingleThreadedComments,
|
|
|
|
errors::{Handler, HANDLER},
|
|
|
|
sync::Lrc,
|
|
|
|
util::take::Take,
|
|
|
|
EqIgnoreSpan, FileName, Mark, SourceMap, Spanned,
|
2021-08-13 13:03:04 +03:00
|
|
|
};
|
2021-05-23 09:39:59 +03:00
|
|
|
use swc_ecma_ast::*;
|
2021-10-21 17:09:00 +03:00
|
|
|
use swc_ecma_codegen::{
|
|
|
|
text_writer::{omit_trailing_semi, JsWriter, WriteJs},
|
|
|
|
Emitter,
|
|
|
|
};
|
2021-08-13 13:03:04 +03:00
|
|
|
use swc_ecma_minifier::{
|
|
|
|
optimize,
|
|
|
|
option::{
|
|
|
|
terser::TerserCompressorOptions, CompressOptions, ExtraOptions, MangleOptions,
|
|
|
|
MinifyOptions,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
use swc_ecma_parser::{
|
|
|
|
lexer::{input::SourceFileInput, Lexer},
|
2021-10-17 09:24:17 +03:00
|
|
|
EsConfig, Parser, Syntax,
|
2021-08-13 13:03:04 +03:00
|
|
|
};
|
2022-05-25 09:23:35 +03:00
|
|
|
use swc_ecma_testing::{exec_node_js, JsExecOptions};
|
2022-04-26 10:38:50 +03:00
|
|
|
use swc_ecma_transforms_base::{fixer::fixer, hygiene::hygiene, resolver};
|
2021-06-29 10:11:22 +03:00
|
|
|
use swc_ecma_utils::drop_span;
|
2022-05-07 09:08:23 +03:00
|
|
|
use swc_ecma_visit::{FoldWith, Visit, VisitMut, VisitMutWith, VisitWith};
|
2022-12-14 12:19:51 +03:00
|
|
|
use testing::{assert_eq, unignore_fixture, DebugUsingDisplay, NormalizedOutput};
|
2021-05-20 07:51:30 +03:00
|
|
|
|
2021-05-28 13:44:03 +03:00
|
|
|
fn load_txt(filename: &str) -> Vec<String> {
|
|
|
|
let lines = read_to_string(filename).unwrap();
|
|
|
|
lines
|
|
|
|
.lines()
|
|
|
|
.filter(|v| !v.trim().is_empty())
|
|
|
|
.map(|v| v.to_string())
|
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
|
2021-05-20 07:51:30 +03:00
|
|
|
fn is_ignored(path: &Path) -> bool {
|
2022-04-23 16:40:28 +03:00
|
|
|
static IGNORED: Lazy<Vec<String>> = Lazy::new(|| {
|
|
|
|
load_txt("tests/TODO.txt")
|
|
|
|
.into_iter()
|
|
|
|
.chain(load_txt("tests/postponed.txt"))
|
|
|
|
.collect()
|
|
|
|
});
|
2021-05-20 07:51:30 +03:00
|
|
|
|
2022-09-19 11:25:49 +03:00
|
|
|
static GOLDEN: Lazy<Vec<String>> = Lazy::new(|| load_txt("tests/passing.txt"));
|
2021-05-20 07:51:30 +03:00
|
|
|
|
2022-01-27 11:41:43 +03:00
|
|
|
let s = path.to_string_lossy().replace('-', "_").replace('\\', "/");
|
2021-05-20 07:51:30 +03:00
|
|
|
|
|
|
|
if IGNORED.iter().any(|ignored| s.contains(&**ignored)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-01-13 17:06:11 +03:00
|
|
|
if env::var("SKIP_GOLDEN").unwrap_or_default() == "1"
|
|
|
|
&& GOLDEN.iter().any(|ignored| s.contains(&**ignored))
|
|
|
|
{
|
|
|
|
return true;
|
2021-05-28 13:44:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if let Ok(one) = env::var("GOLDEN_ONLY") {
|
2022-01-13 17:06:11 +03:00
|
|
|
if one == "1" && GOLDEN.iter().all(|golden| !s.contains(&**golden)) {
|
|
|
|
return true;
|
2021-05-20 07:51:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2022-04-19 10:31:48 +03:00
|
|
|
#[derive(Debug, Default, Clone, Deserialize)]
|
|
|
|
struct TopLevelOnly {
|
|
|
|
#[serde(default, alias = "toplevel")]
|
|
|
|
top_level: bool,
|
|
|
|
}
|
|
|
|
|
2021-05-20 07:51:30 +03:00
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
|
|
#[serde(deny_unknown_fields)]
|
|
|
|
#[serde(untagged)]
|
|
|
|
enum TestMangleOptions {
|
|
|
|
Bool(bool),
|
|
|
|
Normal(MangleOptions),
|
|
|
|
}
|
|
|
|
|
2022-04-19 10:31:48 +03:00
|
|
|
impl TestMangleOptions {
|
|
|
|
fn parse(s: &str) -> Self {
|
|
|
|
let top_level = serde_json::from_str::<TopLevelOnly>(s).unwrap_or_default();
|
|
|
|
|
|
|
|
let mut data = serde_json::from_str::<Self>(s).expect("failed to deserialize mangle.json");
|
|
|
|
|
|
|
|
if let TestMangleOptions::Normal(v) = &mut data {
|
2023-01-10 09:42:49 +03:00
|
|
|
v.top_level = Some(top_level.top_level);
|
2022-04-19 10:31:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
data
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-31 09:30:06 +03:00
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
|
|
struct TestOptions {
|
|
|
|
#[serde(default)]
|
|
|
|
defaults: bool,
|
2022-04-20 01:02:33 +03:00
|
|
|
|
|
|
|
#[serde(default)]
|
|
|
|
passes: usize,
|
2021-07-31 09:30:06 +03:00
|
|
|
}
|
|
|
|
|
2021-05-21 09:57:17 +03:00
|
|
|
fn parse_compressor_config(cm: Lrc<SourceMap>, s: &str) -> (bool, CompressOptions) {
|
2021-07-31 09:30:06 +03:00
|
|
|
let opts: TestOptions =
|
2021-05-20 07:51:30 +03:00
|
|
|
serde_json::from_str(s).expect("failed to deserialize value into a compressor config");
|
2021-07-31 09:30:06 +03:00
|
|
|
let mut c: TerserCompressorOptions =
|
|
|
|
serde_json::from_str(s).expect("failed to deserialize value into a compressor config");
|
|
|
|
|
|
|
|
c.defaults = opts.defaults;
|
2022-04-17 18:52:29 +03:00
|
|
|
c.const_to_let = Some(false);
|
2022-04-29 11:40:16 +03:00
|
|
|
c.pristine_globals = Some(true);
|
2022-04-20 01:02:33 +03:00
|
|
|
c.passes = opts.passes;
|
2021-05-20 07:51:30 +03:00
|
|
|
|
2021-05-21 09:57:17 +03:00
|
|
|
(c.module, c.into_config(cm))
|
2021-05-20 07:51:30 +03:00
|
|
|
}
|
|
|
|
|
2021-05-28 13:44:03 +03:00
|
|
|
fn run(
|
|
|
|
cm: Lrc<SourceMap>,
|
|
|
|
handler: &Handler,
|
|
|
|
input: &Path,
|
|
|
|
config: &str,
|
|
|
|
mangle: Option<TestMangleOptions>,
|
2021-11-20 11:06:18 +03:00
|
|
|
skip_hygiene: bool,
|
2021-05-28 13:44:03 +03:00
|
|
|
) -> Option<Module> {
|
2022-09-01 07:36:30 +03:00
|
|
|
HANDLER.set(handler, || {
|
|
|
|
let disable_hygiene = mangle.is_some() || skip_hygiene;
|
2021-08-07 11:27:52 +03:00
|
|
|
|
2022-09-01 07:36:30 +03:00
|
|
|
let (_module, config) = parse_compressor_config(cm.clone(), config);
|
2021-10-24 13:52:09 +03:00
|
|
|
|
2022-09-01 07:36:30 +03:00
|
|
|
let fm = cm.load_file(input).expect("failed to load input.js");
|
|
|
|
let comments = SingleThreadedComments::default();
|
2021-05-28 13:44:03 +03:00
|
|
|
|
2022-09-01 07:36:30 +03:00
|
|
|
eprintln!("---- {} -----\n{}", Color::Green.paint("Input"), fm.src);
|
2021-05-28 13:44:03 +03:00
|
|
|
|
2022-09-01 07:36:30 +03:00
|
|
|
if env::var("SWC_RUN").unwrap_or_default() == "1" {
|
|
|
|
let stdout = stdout_of(&fm.src);
|
|
|
|
match stdout {
|
|
|
|
Ok(stdout) => {
|
|
|
|
eprintln!(
|
|
|
|
"---- {} -----\n{}",
|
|
|
|
Color::Green.paint("Stdout (expected)"),
|
|
|
|
stdout
|
|
|
|
);
|
|
|
|
}
|
|
|
|
Err(err) => {
|
|
|
|
eprintln!(
|
|
|
|
"---- {} -----\n{:?}",
|
|
|
|
Color::Green.paint("Error (of original source code)"),
|
|
|
|
err
|
|
|
|
);
|
|
|
|
}
|
2021-06-29 10:11:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-01 07:36:30 +03:00
|
|
|
let unresolved_mark = Mark::new();
|
|
|
|
let top_level_mark = Mark::new();
|
|
|
|
|
|
|
|
let minification_start = Instant::now();
|
|
|
|
|
|
|
|
let lexer = Lexer::new(
|
|
|
|
Syntax::Es(EsConfig {
|
|
|
|
jsx: true,
|
|
|
|
..Default::default()
|
2021-05-28 13:44:03 +03:00
|
|
|
}),
|
2022-09-01 07:36:30 +03:00
|
|
|
Default::default(),
|
|
|
|
SourceFileInput::from(&*fm),
|
|
|
|
Some(&comments),
|
|
|
|
);
|
|
|
|
|
|
|
|
let mut parser = Parser::new_from(lexer);
|
|
|
|
let program = parser
|
|
|
|
.parse_module()
|
|
|
|
.map_err(|err| {
|
|
|
|
err.into_diagnostic(handler).emit();
|
|
|
|
})
|
|
|
|
.map(|module| module.fold_with(&mut resolver(unresolved_mark, top_level_mark, false)));
|
|
|
|
|
|
|
|
// Ignore parser errors.
|
|
|
|
//
|
|
|
|
// This is typically related to strict mode caused by module context.
|
|
|
|
let program = match program {
|
|
|
|
Ok(v) => v,
|
|
|
|
_ => return None,
|
|
|
|
};
|
|
|
|
|
|
|
|
let optimization_start = Instant::now();
|
|
|
|
let mut output = optimize(
|
|
|
|
program.into(),
|
|
|
|
cm,
|
|
|
|
Some(&comments),
|
|
|
|
None,
|
|
|
|
&MinifyOptions {
|
|
|
|
compress: Some(config),
|
|
|
|
mangle: mangle.and_then(|v| match v {
|
|
|
|
TestMangleOptions::Bool(v) => {
|
|
|
|
if v {
|
|
|
|
Some(MangleOptions {
|
2023-01-10 09:42:49 +03:00
|
|
|
top_level: Some(false),
|
2022-09-01 07:36:30 +03:00
|
|
|
..Default::default()
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TestMangleOptions::Normal(v) => Some(v),
|
|
|
|
}),
|
|
|
|
..Default::default()
|
|
|
|
},
|
|
|
|
&ExtraOptions {
|
|
|
|
unresolved_mark,
|
|
|
|
top_level_mark,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
.expect_module();
|
|
|
|
let end = Instant::now();
|
|
|
|
tracing::info!(
|
|
|
|
"optimize({}) took {:?}",
|
|
|
|
input.display(),
|
|
|
|
end - optimization_start
|
|
|
|
);
|
|
|
|
|
|
|
|
if !disable_hygiene {
|
|
|
|
output.visit_mut_with(&mut hygiene())
|
|
|
|
}
|
2021-10-24 13:52:09 +03:00
|
|
|
|
2022-09-01 07:36:30 +03:00
|
|
|
let output = output.fold_with(&mut fixer(None));
|
2021-07-30 04:11:27 +03:00
|
|
|
|
2022-09-01 07:36:30 +03:00
|
|
|
let end = Instant::now();
|
|
|
|
tracing::info!(
|
|
|
|
"process({}) took {:?}",
|
|
|
|
input.display(),
|
|
|
|
end - minification_start
|
|
|
|
);
|
2021-05-28 13:44:03 +03:00
|
|
|
|
2022-09-01 07:36:30 +03:00
|
|
|
Some(output)
|
|
|
|
})
|
2021-05-28 13:44:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn stdout_of(code: &str) -> Result<String, Error> {
|
2022-05-25 09:23:35 +03:00
|
|
|
exec_node_js(
|
|
|
|
&format!(
|
2022-05-08 11:27:14 +03:00
|
|
|
"
|
2022-05-25 09:23:35 +03:00
|
|
|
{}
|
|
|
|
{}",
|
2022-05-08 11:27:14 +03:00
|
|
|
include_str!("./terser_exec_base.js"),
|
|
|
|
code
|
2022-05-25 09:23:35 +03:00
|
|
|
),
|
|
|
|
JsExecOptions {
|
|
|
|
cache: true,
|
|
|
|
module: false,
|
2022-09-21 10:23:10 +03:00
|
|
|
..Default::default()
|
2022-05-25 09:23:35 +03:00
|
|
|
},
|
|
|
|
)
|
2021-05-28 13:44:03 +03:00
|
|
|
}
|
|
|
|
|
2021-07-30 04:11:27 +03:00
|
|
|
fn find_config(dir: &Path) -> String {
|
|
|
|
let mut cur = Some(dir);
|
|
|
|
while let Some(dir) = cur {
|
|
|
|
let config = dir.join("config.json");
|
|
|
|
if config.exists() {
|
|
|
|
let config = read_to_string(&config).expect("failed to read config.json");
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
cur = dir.parent();
|
|
|
|
}
|
|
|
|
|
|
|
|
panic!("failed to find config file for {}", dir.display())
|
|
|
|
}
|
|
|
|
|
2022-04-20 09:52:03 +03:00
|
|
|
#[testing::fixture("tests/fixture/**/input.js")]
|
2022-10-14 02:00:32 +03:00
|
|
|
#[testing::fixture("tests/pass-1/**/input.js")]
|
2022-10-18 05:13:39 +03:00
|
|
|
#[testing::fixture("tests/pass-default/**/input.js")]
|
2022-04-19 11:20:12 +03:00
|
|
|
fn custom_fixture(input: PathBuf) {
|
2021-07-30 04:11:27 +03:00
|
|
|
let dir = input.parent().unwrap();
|
2022-01-13 17:06:11 +03:00
|
|
|
let config = find_config(dir);
|
2021-07-30 04:11:27 +03:00
|
|
|
eprintln!("---- {} -----\n{}", Color::Green.paint("Config"), config);
|
|
|
|
|
|
|
|
testing::run_test2(false, |cm, handler| {
|
2022-04-19 11:20:12 +03:00
|
|
|
let mangle = dir.join("mangle.json");
|
2023-03-14 07:56:21 +03:00
|
|
|
let mangle = read_to_string(mangle).ok();
|
2022-04-19 11:20:12 +03:00
|
|
|
if let Some(mangle) = &mangle {
|
|
|
|
eprintln!(
|
|
|
|
"---- {} -----\n{}",
|
|
|
|
Color::Green.paint("Mangle config"),
|
|
|
|
mangle
|
|
|
|
);
|
|
|
|
}
|
|
|
|
let mangle: Option<TestMangleOptions> =
|
|
|
|
mangle.map(|s| serde_json::from_str(&s).expect("failed to deserialize mangle.json"));
|
|
|
|
|
|
|
|
let output = run(cm.clone(), &handler, &input, &config, mangle, false);
|
2021-07-30 04:11:27 +03:00
|
|
|
let output_module = match output {
|
|
|
|
Some(v) => v,
|
|
|
|
None => return Ok(()),
|
|
|
|
};
|
|
|
|
|
2022-01-13 17:06:11 +03:00
|
|
|
let output = print(cm, &[output_module], false, false);
|
2021-07-30 04:11:27 +03:00
|
|
|
|
2022-03-01 12:55:45 +03:00
|
|
|
eprintln!("---- {} -----\n{}", Color::Green.paint("Output"), output);
|
2021-07-30 04:11:27 +03:00
|
|
|
|
|
|
|
println!("{}", input.display());
|
|
|
|
|
|
|
|
NormalizedOutput::from(output)
|
|
|
|
.compare_to_file(dir.join("output.js"))
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
})
|
|
|
|
.unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[testing::fixture("tests/projects/files/*.js")]
|
|
|
|
fn projects(input: PathBuf) {
|
2021-06-29 10:11:22 +03:00
|
|
|
let dir = input.parent().unwrap();
|
|
|
|
let config = dir.join("config.json");
|
2023-03-14 07:56:21 +03:00
|
|
|
let config = read_to_string(config).expect("failed to read config.json");
|
2021-06-29 10:11:22 +03:00
|
|
|
eprintln!("---- {} -----\n{}", Color::Green.paint("Config"), config);
|
|
|
|
|
|
|
|
testing::run_test2(false, |cm, handler| {
|
2021-11-20 11:06:18 +03:00
|
|
|
let output = run(cm.clone(), &handler, &input, &config, None, false);
|
2021-06-29 10:11:22 +03:00
|
|
|
let output_module = match output {
|
|
|
|
Some(v) => v,
|
|
|
|
None => return Ok(()),
|
|
|
|
};
|
|
|
|
|
2022-04-28 16:28:33 +03:00
|
|
|
let output = print(cm.clone(), &[output_module], false, false);
|
2021-06-29 10:11:22 +03:00
|
|
|
|
2022-03-01 12:55:45 +03:00
|
|
|
eprintln!("---- {} -----\n{}", Color::Green.paint("Output"), output);
|
2021-06-29 10:11:22 +03:00
|
|
|
|
|
|
|
println!("{}", input.display());
|
|
|
|
|
2022-04-28 16:28:33 +03:00
|
|
|
let minified = {
|
|
|
|
let output = run(
|
|
|
|
cm.clone(),
|
|
|
|
&handler,
|
|
|
|
&input,
|
|
|
|
r#"{ "defaults": true, "toplevel": true, "passes": 3 }"#,
|
|
|
|
Some(TestMangleOptions::Normal(MangleOptions {
|
2023-01-10 09:42:49 +03:00
|
|
|
top_level: Some(true),
|
2022-04-28 16:28:33 +03:00
|
|
|
..Default::default()
|
|
|
|
})),
|
|
|
|
false,
|
|
|
|
);
|
|
|
|
let output_module = match output {
|
|
|
|
Some(v) => v,
|
|
|
|
None => return Ok(()),
|
|
|
|
};
|
|
|
|
|
|
|
|
print(cm, &[output_module], true, true)
|
|
|
|
};
|
|
|
|
|
|
|
|
eprintln!(
|
|
|
|
"---- {} -----\n{}",
|
|
|
|
Color::Green.paint("Size"),
|
|
|
|
minified.len()
|
|
|
|
);
|
|
|
|
|
2021-06-29 10:11:22 +03:00
|
|
|
NormalizedOutput::from(output)
|
2021-07-30 04:11:27 +03:00
|
|
|
.compare_to_file(
|
|
|
|
dir.parent()
|
|
|
|
.unwrap()
|
|
|
|
.join("output")
|
|
|
|
.join(input.file_name().unwrap()),
|
|
|
|
)
|
2021-06-29 10:11:22 +03:00
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
})
|
|
|
|
.unwrap()
|
|
|
|
}
|
|
|
|
|
2022-09-29 03:41:13 +03:00
|
|
|
/// antd and typescript test is way too slow
|
|
|
|
#[testing::fixture("benches/full/*.js", exclude("typescript", "antd"))]
|
|
|
|
fn projects_bench(input: PathBuf) {
|
|
|
|
let dir = input
|
|
|
|
.parent()
|
|
|
|
.unwrap()
|
|
|
|
.parent()
|
|
|
|
.unwrap()
|
|
|
|
.parent()
|
|
|
|
.unwrap()
|
|
|
|
.join("tests")
|
|
|
|
.join("benches-full");
|
|
|
|
|
|
|
|
testing::run_test2(false, |cm, handler| {
|
|
|
|
let output = run(
|
|
|
|
cm.clone(),
|
|
|
|
&handler,
|
|
|
|
&input,
|
2022-10-14 02:00:32 +03:00
|
|
|
r#"{ "defaults": true, "toplevel": true, "passes": 3 }"#,
|
2022-09-29 03:41:13 +03:00
|
|
|
None,
|
|
|
|
false,
|
|
|
|
);
|
|
|
|
let output_module = match output {
|
|
|
|
Some(v) => v,
|
|
|
|
None => return Ok(()),
|
|
|
|
};
|
|
|
|
|
|
|
|
let output = print(cm, &[output_module], false, false);
|
|
|
|
|
|
|
|
eprintln!("---- {} -----\n{}", Color::Green.paint("Output"), output);
|
|
|
|
|
|
|
|
println!("{}", input.display());
|
|
|
|
|
|
|
|
NormalizedOutput::from(output)
|
|
|
|
.compare_to_file(dir.join(input.file_name().unwrap()))
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
})
|
2022-12-14 12:19:51 +03:00
|
|
|
.unwrap();
|
2022-09-29 03:41:13 +03:00
|
|
|
}
|
|
|
|
|
2021-05-20 07:51:30 +03:00
|
|
|
/// Tests ported from terser.
|
2021-07-29 08:18:21 +03:00
|
|
|
#[testing::fixture("tests/terser/compress/**/input.js")]
|
2021-05-20 07:51:30 +03:00
|
|
|
fn fixture(input: PathBuf) {
|
|
|
|
if is_ignored(&input) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let dir = input.parent().unwrap();
|
|
|
|
let config = dir.join("config.json");
|
2023-03-14 07:56:21 +03:00
|
|
|
let config = read_to_string(config).expect("failed to read config.json");
|
2021-05-20 07:51:30 +03:00
|
|
|
eprintln!("---- {} -----\n{}", Color::Green.paint("Config"), config);
|
|
|
|
|
|
|
|
testing::run_test2(false, |cm, handler| {
|
2021-05-21 09:57:17 +03:00
|
|
|
let mangle = dir.join("mangle.json");
|
2023-03-14 07:56:21 +03:00
|
|
|
let mangle = read_to_string(mangle).ok();
|
2021-05-21 09:57:17 +03:00
|
|
|
if let Some(mangle) = &mangle {
|
|
|
|
eprintln!(
|
|
|
|
"---- {} -----\n{}",
|
|
|
|
Color::Green.paint("Mangle config"),
|
|
|
|
mangle
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-04-19 10:31:48 +03:00
|
|
|
let mangle: Option<TestMangleOptions> = mangle.map(|s| TestMangleOptions::parse(&s));
|
2021-05-21 09:57:17 +03:00
|
|
|
|
2021-11-20 11:06:18 +03:00
|
|
|
let output = run(cm.clone(), &handler, &input, &config, mangle, false);
|
2021-06-29 10:11:22 +03:00
|
|
|
let output_module = match output {
|
2021-05-28 13:44:03 +03:00
|
|
|
Some(v) => v,
|
|
|
|
None => return Ok(()),
|
2021-05-20 07:51:30 +03:00
|
|
|
};
|
2021-06-29 10:11:22 +03:00
|
|
|
|
2021-11-20 11:06:18 +03:00
|
|
|
let output = print(cm.clone(), &[output_module.clone()], false, false);
|
2021-05-20 07:51:30 +03:00
|
|
|
|
2022-03-01 12:55:45 +03:00
|
|
|
eprintln!("---- {} -----\n{}", Color::Green.paint("Output"), output);
|
2021-05-20 07:51:30 +03:00
|
|
|
|
|
|
|
let expected = {
|
2023-03-14 07:56:21 +03:00
|
|
|
let expected = read_to_string(dir.join("output.js")).unwrap();
|
2021-05-20 07:51:30 +03:00
|
|
|
let fm = cm.new_source_file(FileName::Anon, expected);
|
|
|
|
let lexer = Lexer::new(
|
|
|
|
Default::default(),
|
|
|
|
Default::default(),
|
|
|
|
SourceFileInput::from(&*fm),
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
let mut parser = Parser::new_from(lexer);
|
|
|
|
let expected = parser.parse_module().map_err(|err| {
|
|
|
|
err.into_diagnostic(&handler).emit();
|
|
|
|
})?;
|
2021-05-23 09:39:59 +03:00
|
|
|
let mut expected = expected.fold_with(&mut fixer(None));
|
2021-06-29 10:11:22 +03:00
|
|
|
expected = drop_span(expected);
|
2022-05-07 09:08:23 +03:00
|
|
|
expected
|
|
|
|
.body
|
|
|
|
.retain(|s| !matches!(s, ModuleItem::Stmt(Stmt::Empty(..))));
|
|
|
|
|
|
|
|
let mut normalized_expected = expected.clone();
|
|
|
|
normalized_expected.visit_mut_with(&mut DropParens);
|
|
|
|
|
|
|
|
let mut actual = output_module.clone();
|
|
|
|
actual.visit_mut_with(&mut DropParens);
|
2021-06-29 10:11:22 +03:00
|
|
|
|
2022-05-07 09:08:23 +03:00
|
|
|
if actual.eq_ignore_span(&normalized_expected)
|
|
|
|
|| drop_span(actual.clone()) == normalized_expected
|
|
|
|
{
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
|
|
|
|
if print(cm.clone(), &[actual], false, false)
|
|
|
|
== print(cm.clone(), &[normalized_expected], false, false)
|
2021-06-29 10:11:22 +03:00
|
|
|
{
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
|
2021-11-20 11:06:18 +03:00
|
|
|
print(cm.clone(), &[expected], false, false)
|
2021-05-20 07:51:30 +03:00
|
|
|
};
|
2022-05-08 11:27:14 +03:00
|
|
|
{
|
|
|
|
// Check output.teraer.js
|
|
|
|
let identical = (|| -> Option<()> {
|
|
|
|
let expected = {
|
2023-03-14 07:56:21 +03:00
|
|
|
let expected = read_to_string(dir.join("output.terser.js")).ok()?;
|
2022-05-08 11:27:14 +03:00
|
|
|
let fm = cm.new_source_file(FileName::Anon, expected);
|
|
|
|
let lexer = Lexer::new(
|
|
|
|
Default::default(),
|
|
|
|
Default::default(),
|
|
|
|
SourceFileInput::from(&*fm),
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
let mut parser = Parser::new_from(lexer);
|
|
|
|
let expected = parser
|
|
|
|
.parse_module()
|
|
|
|
.map_err(|err| {
|
|
|
|
err.into_diagnostic(&handler).emit();
|
|
|
|
})
|
|
|
|
.ok()?;
|
|
|
|
let mut expected = expected.fold_with(&mut fixer(None));
|
|
|
|
expected = drop_span(expected);
|
|
|
|
expected
|
|
|
|
.body
|
|
|
|
.retain(|s| !matches!(s, ModuleItem::Stmt(Stmt::Empty(..))));
|
|
|
|
|
|
|
|
let mut normalized_expected = expected.clone();
|
|
|
|
normalized_expected.visit_mut_with(&mut DropParens);
|
|
|
|
|
|
|
|
let mut actual = output_module.clone();
|
|
|
|
actual.visit_mut_with(&mut DropParens);
|
|
|
|
|
|
|
|
if actual.eq_ignore_span(&normalized_expected)
|
|
|
|
|| drop_span(actual.clone()) == normalized_expected
|
|
|
|
{
|
|
|
|
return Some(());
|
|
|
|
}
|
|
|
|
|
|
|
|
if print(cm.clone(), &[actual], false, false)
|
|
|
|
== print(cm.clone(), &[normalized_expected], false, false)
|
|
|
|
{
|
|
|
|
return Some(());
|
|
|
|
}
|
|
|
|
|
|
|
|
print(cm.clone(), &[expected], false, false)
|
|
|
|
};
|
|
|
|
|
|
|
|
if output == expected {
|
|
|
|
return Some(());
|
|
|
|
}
|
|
|
|
|
|
|
|
None
|
|
|
|
})()
|
|
|
|
.is_some();
|
|
|
|
if identical {
|
2023-03-14 07:56:21 +03:00
|
|
|
let s = read_to_string(dir.join("output.terser.js"))
|
2022-05-08 11:27:14 +03:00
|
|
|
.expect("failed to read output.terser.js");
|
2023-03-14 07:56:21 +03:00
|
|
|
std::fs::write(dir.join("output.js"), s.as_bytes())
|
2022-05-08 11:27:14 +03:00
|
|
|
.expect("failed to update output.js");
|
|
|
|
}
|
|
|
|
}
|
2021-05-20 07:51:30 +03:00
|
|
|
|
|
|
|
if output == expected {
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
|
|
|
|
eprintln!(
|
|
|
|
"---- {} -----\n{}",
|
|
|
|
Color::Green.paint("Expected"),
|
|
|
|
expected
|
|
|
|
);
|
|
|
|
|
2021-05-28 13:44:03 +03:00
|
|
|
println!("{}", input.display());
|
|
|
|
|
2021-05-20 07:51:30 +03:00
|
|
|
if let Ok(expected_stdout) = read_to_string(dir.join("expected.stdout")) {
|
|
|
|
eprintln!(
|
|
|
|
"---- {} -----\n{}",
|
|
|
|
Color::Green.paint("Expected stdout"),
|
|
|
|
expected_stdout
|
|
|
|
);
|
|
|
|
|
2021-05-28 13:44:03 +03:00
|
|
|
let actual = stdout_of(&output).expect("failed to execute the optimized code");
|
2021-05-20 07:51:30 +03:00
|
|
|
assert_eq!(
|
|
|
|
DebugUsingDisplay(&actual),
|
|
|
|
DebugUsingDisplay(&expected_stdout)
|
|
|
|
);
|
|
|
|
if expected.trim().is_empty() {
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-13 17:06:11 +03:00
|
|
|
let output_str = print(cm, &[drop_span(output_module)], false, false);
|
2021-09-09 14:45:20 +03:00
|
|
|
|
2021-05-20 07:51:30 +03:00
|
|
|
if env::var("UPDATE").map(|s| s == "1").unwrap_or(false) {
|
|
|
|
let _ = catch_unwind(|| {
|
2021-09-09 14:45:20 +03:00
|
|
|
NormalizedOutput::from(output_str.clone())
|
2021-05-20 07:51:30 +03:00
|
|
|
.compare_to_file(dir.join("output.js"))
|
|
|
|
.unwrap();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-06-29 10:11:22 +03:00
|
|
|
assert_eq!(DebugUsingDisplay(&output_str), DebugUsingDisplay(&expected));
|
2021-05-20 07:51:30 +03:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
})
|
|
|
|
.unwrap()
|
|
|
|
}
|
|
|
|
|
2021-11-20 11:06:18 +03:00
|
|
|
fn print<N: swc_ecma_codegen::Node>(
|
|
|
|
cm: Lrc<SourceMap>,
|
|
|
|
nodes: &[N],
|
|
|
|
minify: bool,
|
|
|
|
skip_semi: bool,
|
|
|
|
) -> String {
|
2021-05-20 07:51:30 +03:00
|
|
|
let mut buf = vec![];
|
|
|
|
|
|
|
|
{
|
2021-10-21 17:09:00 +03:00
|
|
|
let mut wr: Box<dyn WriteJs> = Box::new(JsWriter::new(cm.clone(), "\n", &mut buf, None));
|
2021-11-20 11:06:18 +03:00
|
|
|
if minify || skip_semi {
|
2021-10-21 17:09:00 +03:00
|
|
|
wr = Box::new(omit_trailing_semi(wr));
|
|
|
|
}
|
|
|
|
|
2021-05-20 07:51:30 +03:00
|
|
|
let mut emitter = Emitter {
|
2022-05-15 08:07:21 +03:00
|
|
|
cfg: swc_ecma_codegen::Config {
|
|
|
|
minify,
|
|
|
|
..Default::default()
|
|
|
|
},
|
2022-01-13 17:06:11 +03:00
|
|
|
cm,
|
2021-05-20 07:51:30 +03:00
|
|
|
comments: None,
|
2021-10-21 17:09:00 +03:00
|
|
|
wr,
|
2021-05-20 07:51:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
for n in nodes {
|
|
|
|
n.emit_with(&mut emitter).unwrap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String::from_utf8(buf).unwrap()
|
|
|
|
}
|
2021-08-25 11:23:55 +03:00
|
|
|
|
|
|
|
struct Shower<'a> {
|
|
|
|
cm: Lrc<SourceMap>,
|
|
|
|
handler: &'a Handler,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Shower<'_> {
|
|
|
|
fn show<N>(&self, name: &str, node: &N)
|
|
|
|
where
|
|
|
|
N: Spanned + fmt::Debug + swc_ecma_codegen::Node,
|
|
|
|
{
|
|
|
|
let span = node.span();
|
|
|
|
|
|
|
|
if span.is_dummy() {
|
2021-11-20 11:06:18 +03:00
|
|
|
let src = print(self.cm.clone(), &[node], false, false);
|
2021-08-25 11:23:55 +03:00
|
|
|
self.handler
|
|
|
|
.struct_span_warn(span, &format!("{}: {}", name, src))
|
|
|
|
.emit();
|
|
|
|
} else {
|
|
|
|
self.handler.struct_span_warn(span, name).emit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn show_name<N>(&self, name: &str, node: &N)
|
|
|
|
where
|
|
|
|
N: Spanned + fmt::Debug,
|
|
|
|
{
|
|
|
|
let span = node.span();
|
|
|
|
|
|
|
|
if span.is_dummy() {
|
|
|
|
self.handler
|
|
|
|
.struct_span_warn(span, &format!("{:?}", node))
|
|
|
|
.emit();
|
|
|
|
} else {
|
|
|
|
self.handler.struct_span_warn(span, name).emit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Visit for Shower<'_> {
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_array_lit(&mut self, n: &ArrayLit) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ArrayLit", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_array_pat(&mut self, n: &ArrayPat) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ArrayPat", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_arrow_expr(&mut self, n: &ArrowExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ArrowExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_assign_expr(&mut self, n: &AssignExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("AssignExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_assign_pat(&mut self, n: &AssignPat) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("AssignPat", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_assign_pat_prop(&mut self, n: &AssignPatProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("AssignPatProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_assign_prop(&mut self, n: &AssignProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("AssignProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_await_expr(&mut self, n: &AwaitExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("AwaitExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_bin_expr(&mut self, n: &BinExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("BinExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_block_stmt(&mut self, n: &BlockStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("BlockStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_block_stmt_or_expr(&mut self, n: &BlockStmtOrExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("BlockStmtOrExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_bool(&mut self, n: &Bool) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Bool", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_break_stmt(&mut self, n: &BreakStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("BreakStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_call_expr(&mut self, n: &CallExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("CallExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_catch_clause(&mut self, n: &CatchClause) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("CatchClause", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_class(&mut self, n: &Class) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Class", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_class_decl(&mut self, n: &ClassDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ClassDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_class_expr(&mut self, n: &ClassExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ClassExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_class_member(&mut self, n: &ClassMember) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ClassMember", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_class_method(&mut self, n: &ClassMethod) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ClassMethod", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_class_prop(&mut self, n: &ClassProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ClassProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_computed_prop_name(&mut self, n: &ComputedPropName) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ComputedPropName", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_cond_expr(&mut self, n: &CondExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("CondExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_constructor(&mut self, n: &Constructor) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Constructor", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_continue_stmt(&mut self, n: &ContinueStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ContinueStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_debugger_stmt(&mut self, n: &DebuggerStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("DebuggerStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_decl(&mut self, n: &Decl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Decl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_decorator(&mut self, n: &Decorator) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Decorator", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_default_decl(&mut self, n: &DefaultDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show_name("DefaultDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_do_while_stmt(&mut self, n: &DoWhileStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("DoWhileStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_empty_stmt(&mut self, n: &EmptyStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("EmptyStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_export_all(&mut self, n: &ExportAll) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ExportAll", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_export_decl(&mut self, n: &ExportDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ExportDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_export_default_decl(&mut self, n: &ExportDefaultDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ExportDefaultDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_export_default_expr(&mut self, n: &ExportDefaultExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ExportDefaultExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_export_default_specifier(&mut self, n: &ExportDefaultSpecifier) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show_name("ExportDefaultSpecifier", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_export_named_specifier(&mut self, n: &ExportNamedSpecifier) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ExportNamedSpecifier", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_export_namespace_specifier(&mut self, n: &ExportNamespaceSpecifier) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ExportNamespaceSpecifier", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_export_specifier(&mut self, n: &ExportSpecifier) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ExportSpecifier", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_expr(&mut self, n: &Expr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Expr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_expr_or_spread(&mut self, n: &ExprOrSpread) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ExprOrSpread", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2022-01-10 16:54:42 +03:00
|
|
|
fn visit_callee(&mut self, n: &Callee) {
|
|
|
|
self.show("Callee", n);
|
2021-08-25 11:23:55 +03:00
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_fn_decl(&mut self, n: &FnDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("FnDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_fn_expr(&mut self, n: &FnExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("FnExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_for_in_stmt(&mut self, n: &ForInStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ForInStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_for_of_stmt(&mut self, n: &ForOfStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ForOfStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_for_stmt(&mut self, n: &ForStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ForStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_function(&mut self, n: &Function) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Function", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_getter_prop(&mut self, n: &GetterProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("GetterProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ident(&mut self, n: &Ident) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Ident", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_if_stmt(&mut self, n: &IfStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("IfStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_import_decl(&mut self, n: &ImportDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ImportDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_import_default_specifier(&mut self, n: &ImportDefaultSpecifier) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show_name("ImportDefaultSpecifier", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_import_named_specifier(&mut self, n: &ImportNamedSpecifier) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ImportNamedSpecifier", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_import_specifier(&mut self, n: &ImportSpecifier) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show_name("ImportSpecifier", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_import_star_as_specifier(&mut self, n: &ImportStarAsSpecifier) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show_name("ImportStarAsSpecifier", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_invalid(&mut self, n: &Invalid) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Invalid", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_attr(&mut self, n: &JSXAttr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXAttr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_attr_name(&mut self, n: &JSXAttrName) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXAttrName", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_attr_or_spread(&mut self, n: &JSXAttrOrSpread) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXAttrOrSpread", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_attr_value(&mut self, n: &JSXAttrValue) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXAttrValue", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_closing_element(&mut self, n: &JSXClosingElement) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXClosingElement", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_closing_fragment(&mut self, n: &JSXClosingFragment) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXClosingFragment", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_element(&mut self, n: &JSXElement) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXElement", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_element_child(&mut self, n: &JSXElementChild) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXElementChild", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_element_name(&mut self, n: &JSXElementName) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXElementName", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_empty_expr(&mut self, n: &JSXEmptyExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXEmptyExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_expr(&mut self, n: &JSXExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_expr_container(&mut self, n: &JSXExprContainer) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXExprContainer", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_fragment(&mut self, n: &JSXFragment) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXFragment", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_member_expr(&mut self, n: &JSXMemberExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXMemberExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_namespaced_name(&mut self, n: &JSXNamespacedName) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXNamespacedName", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_object(&mut self, n: &JSXObject) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXObject", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_opening_element(&mut self, n: &JSXOpeningElement) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXOpeningElement", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_opening_fragment(&mut self, n: &JSXOpeningFragment) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXOpeningFragment", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_spread_child(&mut self, n: &JSXSpreadChild) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXSpreadChild", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_jsx_text(&mut self, n: &JSXText) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("JSXText", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_key_value_pat_prop(&mut self, n: &KeyValuePatProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("KeyValuePatProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_key_value_prop(&mut self, n: &KeyValueProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("KeyValueProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_labeled_stmt(&mut self, n: &LabeledStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("LabeledStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_lit(&mut self, n: &Lit) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Lit", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_member_expr(&mut self, n: &MemberExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("MemberExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2022-01-10 16:54:42 +03:00
|
|
|
fn visit_super_prop_expr(&mut self, n: &SuperPropExpr) {
|
|
|
|
self.show("SuperPropExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_meta_prop_expr(&mut self, n: &MetaPropExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("MetaPropExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_method_prop(&mut self, n: &MethodProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("MethodProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_module(&mut self, n: &Module) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Module", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_module_decl(&mut self, n: &ModuleDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ModuleDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_named_export(&mut self, n: &NamedExport) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("NamedExport", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_new_expr(&mut self, n: &NewExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("NewExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_null(&mut self, n: &Null) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show_name("Null", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_number(&mut self, n: &Number) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Number", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_object_lit(&mut self, n: &ObjectLit) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ObjectLit", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_object_pat(&mut self, n: &ObjectPat) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ObjectPat", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_object_pat_prop(&mut self, n: &ObjectPatProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ObjectPatProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_opt_chain_expr(&mut self, n: &OptChainExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("OptChainExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_param(&mut self, n: &Param) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Param", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_param_or_ts_param_prop(&mut self, n: &ParamOrTsParamProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ParamOrTsParamProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_paren_expr(&mut self, n: &ParenExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ParenExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_pat(&mut self, n: &Pat) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Pat", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_pat_or_expr(&mut self, n: &PatOrExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("PatOrExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_private_method(&mut self, n: &PrivateMethod) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("PrivateMethod", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_private_name(&mut self, n: &PrivateName) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("PrivateName", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_private_prop(&mut self, n: &PrivateProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("PrivateProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_program(&mut self, n: &Program) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Program", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_prop(&mut self, n: &Prop) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Prop", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_prop_name(&mut self, n: &PropName) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("PropName", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_prop_or_spread(&mut self, n: &PropOrSpread) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("PropOrSpread", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_regex(&mut self, n: &Regex) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show_name("Regex", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_rest_pat(&mut self, n: &RestPat) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("RestPat", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_return_stmt(&mut self, n: &ReturnStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ReturnStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_script(&mut self, n: &Script) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Script", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_seq_expr(&mut self, n: &SeqExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("SeqExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_setter_prop(&mut self, n: &SetterProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("SetterProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_spread_element(&mut self, n: &SpreadElement) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("SpreadElement", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_str(&mut self, n: &Str) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Str", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_super(&mut self, n: &Super) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Super", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_switch_case(&mut self, n: &SwitchCase) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("SwitchCase", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_switch_stmt(&mut self, n: &SwitchStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("SwitchStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_tagged_tpl(&mut self, n: &TaggedTpl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TaggedTpl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_this_expr(&mut self, n: &ThisExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ThisExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_throw_stmt(&mut self, n: &ThrowStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("ThrowStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_tpl(&mut self, n: &Tpl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("Tpl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_tpl_element(&mut self, n: &TplElement) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TplElement", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_try_stmt(&mut self, n: &TryStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TryStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_array_type(&mut self, n: &TsArrayType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsArrayType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_as_expr(&mut self, n: &TsAsExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsAsExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_call_signature_decl(&mut self, n: &TsCallSignatureDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsCallSignatureDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_conditional_type(&mut self, n: &TsConditionalType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsConditionalType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_const_assertion(&mut self, n: &TsConstAssertion) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsConstAssertion", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_construct_signature_decl(&mut self, n: &TsConstructSignatureDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsConstructSignatureDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_constructor_type(&mut self, n: &TsConstructorType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsConstructorType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_entity_name(&mut self, n: &TsEntityName) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsEntityName", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_enum_decl(&mut self, n: &TsEnumDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsEnumDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_enum_member(&mut self, n: &TsEnumMember) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsEnumMember", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_enum_member_id(&mut self, n: &TsEnumMemberId) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsEnumMemberId", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_export_assignment(&mut self, n: &TsExportAssignment) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsExportAssignment", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_expr_with_type_args(&mut self, n: &TsExprWithTypeArgs) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsExprWithTypeArgs", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_external_module_ref(&mut self, n: &TsExternalModuleRef) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsExternalModuleRef", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_fn_or_constructor_type(&mut self, n: &TsFnOrConstructorType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsFnOrConstructorType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_fn_param(&mut self, n: &TsFnParam) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsFnParam", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_fn_type(&mut self, n: &TsFnType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsFnType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_import_equals_decl(&mut self, n: &TsImportEqualsDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsImportEqualsDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_import_type(&mut self, n: &TsImportType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsImportType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_index_signature(&mut self, n: &TsIndexSignature) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsIndexSignature", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_indexed_access_type(&mut self, n: &TsIndexedAccessType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsIndexedAccessType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_infer_type(&mut self, n: &TsInferType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsInferType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_interface_body(&mut self, n: &TsInterfaceBody) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsInterfaceBody", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_interface_decl(&mut self, n: &TsInterfaceDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsInterfaceDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_intersection_type(&mut self, n: &TsIntersectionType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsIntersectionType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_keyword_type(&mut self, n: &TsKeywordType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsKeywordType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_lit(&mut self, n: &TsLit) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsLit", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_lit_type(&mut self, n: &TsLitType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsLitType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_mapped_type(&mut self, n: &TsMappedType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsMappedType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_method_signature(&mut self, n: &TsMethodSignature) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsMethodSignature", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_module_block(&mut self, n: &TsModuleBlock) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsModuleBlock", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_module_decl(&mut self, n: &TsModuleDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsModuleDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_module_name(&mut self, n: &TsModuleName) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsModuleName", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_module_ref(&mut self, n: &TsModuleRef) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsModuleRef", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_namespace_body(&mut self, n: &TsNamespaceBody) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsNamespaceBody", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_namespace_decl(&mut self, n: &TsNamespaceDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsNamespaceDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_namespace_export_decl(&mut self, n: &TsNamespaceExportDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsNamespaceExportDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_non_null_expr(&mut self, n: &TsNonNullExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsNonNullExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_optional_type(&mut self, n: &TsOptionalType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsOptionalType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_param_prop(&mut self, n: &TsParamProp) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsParamProp", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_param_prop_param(&mut self, n: &TsParamPropParam) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsParamPropParam", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_parenthesized_type(&mut self, n: &TsParenthesizedType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsParenthesizedType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_property_signature(&mut self, n: &TsPropertySignature) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsPropertySignature", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_qualified_name(&mut self, n: &TsQualifiedName) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsQualifiedName", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_rest_type(&mut self, n: &TsRestType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsRestType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_this_type(&mut self, n: &TsThisType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsThisType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_this_type_or_ident(&mut self, n: &TsThisTypeOrIdent) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsThisTypeOrIdent", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_tuple_element(&mut self, n: &TsTupleElement) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTupleElement", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_tuple_type(&mut self, n: &TsTupleType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTupleType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type(&mut self, n: &TsType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_alias_decl(&mut self, n: &TsTypeAliasDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeAliasDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_ann(&mut self, n: &TsTypeAnn) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeAnn", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_assertion(&mut self, n: &TsTypeAssertion) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeAssertion", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_element(&mut self, n: &TsTypeElement) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeElement", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_lit(&mut self, n: &TsTypeLit) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeLit", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_operator(&mut self, n: &TsTypeOperator) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeOperator", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_param(&mut self, n: &TsTypeParam) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeParam", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_param_decl(&mut self, n: &TsTypeParamDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeParamDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_param_instantiation(&mut self, n: &TsTypeParamInstantiation) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeParamInstantiation", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_predicate(&mut self, n: &TsTypePredicate) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypePredicate", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_query(&mut self, n: &TsTypeQuery) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeQuery", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_query_expr(&mut self, n: &TsTypeQueryExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeQueryExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_type_ref(&mut self, n: &TsTypeRef) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsTypeRef", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_union_or_intersection_type(&mut self, n: &TsUnionOrIntersectionType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsUnionOrIntersectionType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_ts_union_type(&mut self, n: &TsUnionType) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("TsUnionType", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_unary_expr(&mut self, n: &UnaryExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("UnaryExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_update_expr(&mut self, n: &UpdateExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("UpdateExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_var_decl(&mut self, n: &VarDecl) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("VarDecl", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_var_decl_or_expr(&mut self, n: &VarDeclOrExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("VarDeclOrExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2023-05-10 07:16:44 +03:00
|
|
|
fn visit_for_head(&mut self, n: &ForHead) {
|
|
|
|
self.show("ForHead", n);
|
2021-08-25 11:23:55 +03:00
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_var_declarator(&mut self, n: &VarDeclarator) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("VarDeclarator", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_while_stmt(&mut self, n: &WhileStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("WhileStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_with_stmt(&mut self, n: &WithStmt) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("WithStmt", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_yield_expr(&mut self, n: &YieldExpr) {
|
2021-08-25 11:23:55 +03:00
|
|
|
self.show("YieldExpr", n);
|
|
|
|
n.visit_children_with(self)
|
|
|
|
}
|
|
|
|
}
|
2021-10-21 17:09:00 +03:00
|
|
|
|
|
|
|
#[testing::fixture("tests/full/**/input.js")]
|
|
|
|
fn full(input: PathBuf) {
|
|
|
|
let dir = input.parent().unwrap();
|
2022-01-13 17:06:11 +03:00
|
|
|
let config = find_config(dir);
|
2021-10-21 17:09:00 +03:00
|
|
|
eprintln!("---- {} -----\n{}", Color::Green.paint("Config"), config);
|
|
|
|
|
|
|
|
testing::run_test2(false, |cm, handler| {
|
2021-10-24 13:52:09 +03:00
|
|
|
let output = run(
|
|
|
|
cm.clone(),
|
|
|
|
&handler,
|
|
|
|
&input,
|
|
|
|
&config,
|
|
|
|
Some(TestMangleOptions::Normal(MangleOptions {
|
2023-01-10 09:42:49 +03:00
|
|
|
top_level: Some(true),
|
2021-10-24 13:52:09 +03:00
|
|
|
..Default::default()
|
|
|
|
})),
|
2021-11-20 11:06:18 +03:00
|
|
|
false,
|
2021-10-24 13:52:09 +03:00
|
|
|
);
|
2021-10-21 17:09:00 +03:00
|
|
|
let output_module = match output {
|
|
|
|
Some(v) => v,
|
|
|
|
None => return Ok(()),
|
|
|
|
};
|
|
|
|
|
2022-01-13 17:06:11 +03:00
|
|
|
let output = print(cm, &[output_module], true, true);
|
2021-10-21 17:09:00 +03:00
|
|
|
|
|
|
|
eprintln!("---- {} -----\n{}", Color::Green.paint("Output"), output);
|
|
|
|
|
|
|
|
println!("{}", input.display());
|
|
|
|
|
|
|
|
NormalizedOutput::from(output)
|
|
|
|
.compare_to_file(dir.join("output.js"))
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
})
|
2022-12-14 12:19:51 +03:00
|
|
|
.unwrap();
|
|
|
|
unignore_fixture(&input);
|
2021-10-21 17:09:00 +03:00
|
|
|
}
|
2022-05-07 09:08:23 +03:00
|
|
|
|
|
|
|
struct DropParens;
|
|
|
|
|
|
|
|
impl VisitMut for DropParens {
|
|
|
|
fn visit_mut_expr(&mut self, e: &mut Expr) {
|
|
|
|
e.visit_mut_children_with(self);
|
|
|
|
|
|
|
|
if let Expr::Paren(p) = e {
|
|
|
|
*e = *p.expr.take();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|