diff --git a/Cargo.lock b/Cargo.lock index 0ee9bf60c7768..cd3201dc1f5e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1559,6 +1559,7 @@ dependencies = [ "oxc", "oxc_prettier", "oxc_tasks_common", + "oxc_tasks_transform_checker", "phf 0.11.2", "pico-args", "rayon", @@ -1956,6 +1957,20 @@ dependencies = [ "url", ] +[[package]] +name = "oxc_tasks_transform_checker" +version = "0.0.0" +dependencies = [ + "indexmap", + "oxc_allocator", + "oxc_ast", + "oxc_diagnostics", + "oxc_semantic", + "oxc_span", + "oxc_syntax", + "rustc-hash", +] + [[package]] name = "oxc_transform_conformance" version = "0.0.0" @@ -1964,6 +1979,7 @@ dependencies = [ "indexmap", "oxc", "oxc_tasks_common", + "oxc_tasks_transform_checker", "pico-args", "walkdir", ] diff --git a/Cargo.toml b/Cargo.toml index 5e36b893b97b0..a6f1a6c55a89c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,6 +104,7 @@ oxc_linter = { path = "crates/oxc_linter" } oxc_macros = { path = "crates/oxc_macros" } oxc_prettier = { path = "crates/oxc_prettier" } oxc_tasks_common = { path = "tasks/common" } +oxc_tasks_transform_checker = { path = "tasks/transform_checker" } napi = "3.0.0-alpha" napi-build = "2.1.3" diff --git a/crates/oxc_semantic/src/lib.rs b/crates/oxc_semantic/src/lib.rs index bb384397ac268..f863183136fe6 100644 --- a/crates/oxc_semantic/src/lib.rs +++ b/crates/oxc_semantic/src/lib.rs @@ -17,7 +17,6 @@ pub use oxc_syntax::{ }; pub mod dot; -pub mod post_transform_checker; mod binder; mod builder; diff --git a/tasks/coverage/Cargo.toml b/tasks/coverage/Cargo.toml index 32d70b79213dd..240b3e925e242 100644 --- a/tasks/coverage/Cargo.toml +++ b/tasks/coverage/Cargo.toml @@ -25,6 +25,7 @@ doctest = false oxc = { workspace = true, features = ["full", "isolated_declarations", "serialize", "sourcemap"] } oxc_prettier = { workspace = true } oxc_tasks_common = { workspace = true } +oxc_tasks_transform_checker = { workspace = true } console = { workspace = true } encoding_rs = { workspace = true } diff --git a/tasks/coverage/src/driver.rs b/tasks/coverage/src/driver.rs index 670ff6e9a0b0e..02e8694297af0 100644 --- a/tasks/coverage/src/driver.rs +++ b/tasks/coverage/src/driver.rs @@ -1,5 +1,7 @@ use std::{ops::ControlFlow, path::PathBuf}; +use rustc_hash::FxHashSet; + use oxc::{ allocator::Allocator, ast::{ast::Program, Trivias}, @@ -8,15 +10,12 @@ use oxc::{ minifier::CompressOptions, parser::{ParseOptions, ParserReturn}, regular_expression::{Parser, ParserOptions}, - semantic::{ - post_transform_checker::{check_semantic_after_transform, check_semantic_ids}, - Semantic, SemanticBuilderReturn, - }, + semantic::{Semantic, SemanticBuilderReturn}, span::{SourceType, Span}, transformer::{TransformOptions, TransformerReturn}, CompilerInterface, }; -use rustc_hash::FxHashSet; +use oxc_tasks_transform_checker::{check_semantic_after_transform, check_semantic_ids}; use crate::suite::TestResult; diff --git a/tasks/transform_checker/Cargo.toml b/tasks/transform_checker/Cargo.toml new file mode 100644 index 0000000000000..ba52a86583ca3 --- /dev/null +++ b/tasks/transform_checker/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "oxc_tasks_transform_checker" +version = "0.0.0" +edition.workspace = true +license.workspace = true +publish = false + +[lints] +workspace = true + +[lib] +test = false +doctest = false + +[dependencies] +oxc_allocator = { workspace = true } +oxc_ast = { workspace = true } +oxc_diagnostics = { workspace = true } +oxc_semantic = { workspace = true } +oxc_span = { workspace = true } +oxc_syntax = { workspace = true } + +indexmap = { workspace = true } +rustc-hash = { workspace = true } diff --git a/crates/oxc_semantic/src/post_transform_checker.rs b/tasks/transform_checker/src/lib.rs similarity index 99% rename from crates/oxc_semantic/src/post_transform_checker.rs rename to tasks/transform_checker/src/lib.rs index 2ced622c8ba41..3d29bf3f83abc 100644 --- a/crates/oxc_semantic/src/post_transform_checker.rs +++ b/tasks/transform_checker/src/lib.rs @@ -95,9 +95,10 @@ use indexmap::IndexMap; use rustc_hash::FxHasher; use oxc_allocator::{Allocator, CloneIn}; -#[allow(clippy::wildcard_imports)] +#[allow(clippy::wildcard_imports, clippy::allow_attributes)] use oxc_ast::{ast::*, visit::walk, Visit}; use oxc_diagnostics::OxcDiagnostic; +use oxc_semantic::{ScopeTree, SemanticBuilder, SymbolTable}; use oxc_span::CompactStr; use oxc_syntax::{ reference::ReferenceId, @@ -105,8 +106,6 @@ use oxc_syntax::{ symbol::SymbolId, }; -use crate::{ScopeTree, SemanticBuilder, SymbolTable}; - type FxIndexMap = IndexMap>; /// Check `ScopeTree` and `SymbolTable` are correct after transform diff --git a/tasks/transform_conformance/Cargo.toml b/tasks/transform_conformance/Cargo.toml index 356c7983ca862..4a7c0ccf8b035 100644 --- a/tasks/transform_conformance/Cargo.toml +++ b/tasks/transform_conformance/Cargo.toml @@ -24,6 +24,7 @@ doctest = false [dependencies] oxc = { workspace = true, features = ["full"] } oxc_tasks_common = { workspace = true } +oxc_tasks_transform_checker = { workspace = true } cow-utils = { workspace = true } indexmap = { workspace = true } diff --git a/tasks/transform_conformance/src/driver.rs b/tasks/transform_conformance/src/driver.rs index 4d95bb0567d36..a776e55eb9236 100644 --- a/tasks/transform_conformance/src/driver.rs +++ b/tasks/transform_conformance/src/driver.rs @@ -6,11 +6,11 @@ use oxc::{ codegen::{CodeGenerator, CodegenOptions}, diagnostics::OxcDiagnostic, mangler::Mangler, - semantic::post_transform_checker::check_semantic_after_transform, span::SourceType, transformer::{TransformOptions, TransformerReturn}, CompilerInterface, }; +use oxc_tasks_transform_checker::check_semantic_after_transform; pub struct Driver { check_semantic: bool,