mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
refactor(semantic): call with_trivias before build_with_jsdoc (#5875)
This commit is contained in:
parent
3d13c6d1f9
commit
db4f16a98f
4 changed files with 5 additions and 4 deletions
|
|
@ -313,8 +313,8 @@ impl Runtime {
|
|||
// The semantic model is not built at this stage.
|
||||
let semantic_builder = SemanticBuilder::new(source_text)
|
||||
.with_cfg(true)
|
||||
.with_build_jsdoc(true)
|
||||
.with_trivias(trivias)
|
||||
.with_build_jsdoc(true)
|
||||
.with_check_syntax_error(check_syntax_errors)
|
||||
.build_module_record(path, program);
|
||||
let module_record = semantic_builder.module_record();
|
||||
|
|
|
|||
|
|
@ -157,8 +157,7 @@ impl<'a> SemanticBuilder<'a> {
|
|||
|
||||
#[must_use]
|
||||
pub fn with_trivias(mut self, trivias: Trivias) -> Self {
|
||||
self.trivias = trivias.clone();
|
||||
self.jsdoc = JSDocBuilder::new(self.source_text, trivias);
|
||||
self.trivias = trivias;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -176,8 +175,10 @@ impl<'a> SemanticBuilder<'a> {
|
|||
}
|
||||
|
||||
/// Enable/disable JSDoc parsing.
|
||||
/// `with_trivias` must be called prior to this call.
|
||||
#[must_use]
|
||||
pub fn with_build_jsdoc(mut self, yes: bool) -> Self {
|
||||
self.jsdoc = JSDocBuilder::new(self.source_text, self.trivias.clone());
|
||||
self.build_jsdoc = yes;
|
||||
self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ mod module_record_tests {
|
|||
let ret = Parser::new(&allocator, source_text, source_type).parse();
|
||||
let program = allocator.alloc(ret.program);
|
||||
let semantic_ret = SemanticBuilder::new(source_text)
|
||||
.with_trivias(ret.trivias)
|
||||
.build_module_record(Path::new(""), program)
|
||||
.build(program);
|
||||
Arc::clone(&semantic_ret.semantic.module_record)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ fn bench_linter(criterion: &mut Criterion) {
|
|||
let program = allocator.alloc(ret.program);
|
||||
let semantic_ret = SemanticBuilder::new(source_text)
|
||||
.with_trivias(ret.trivias)
|
||||
.with_build_jsdoc(true)
|
||||
.with_cfg(true)
|
||||
.build_module_record(Path::new(""), program)
|
||||
.build(program);
|
||||
|
|
|
|||
Loading…
Reference in a new issue