Skip to content

Commit

Permalink
chore(transform_conformance): do not print comments yet (#5788)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Sep 15, 2024
1 parent 033b907 commit 213dbc0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
15 changes: 15 additions & 0 deletions tasks/transform_conformance/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use std::{mem, ops::ControlFlow, path::Path};

use oxc::{
ast::ast::Program,
ast::Trivias,
codegen::{CodeGenerator, CodegenOptions},
diagnostics::OxcDiagnostic,
mangler::Mangler,
semantic::post_transform_checker::check_semantic_after_transform,
span::SourceType,
transformer::{TransformOptions, TransformerReturn},
Expand Down Expand Up @@ -53,6 +56,18 @@ impl CompilerInterface for Driver {
}
ControlFlow::Continue(())
}

// Disable comments
fn codegen<'a>(
&self,
program: &Program<'a>,
_source_text: &'a str,
_trivias: &Trivias,
mangler: Option<Mangler>,
options: CodegenOptions,
) -> String {
CodeGenerator::new().with_options(options).with_mangler(mangler).build(program).source_text
}
}

impl Driver {
Expand Down
9 changes: 8 additions & 1 deletion tasks/transform_conformance/src/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,14 @@ impl TestCase for ConformanceTestCase {
|output| {
// Get expected code by parsing the source text, so we can get the same code generated result.
let ret = Parser::new(&allocator, &output, source_type).parse();
CodeGenerator::new().build(&ret.program).source_text
CodeGenerator::new()
// .enable_comment(
// &output,
// ret.trivias,
// CommentOptions { preserve_annotate_comments: true },
// )
.build(&ret.program)
.source_text
},
);

Expand Down

0 comments on commit 213dbc0

Please sign in to comment.