mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(semantic): change build_module_record to accept &Path instead of PathBuf
This commit is contained in:
parent
946c867b27
commit
3ae94b8801
8 changed files with 15 additions and 18 deletions
|
|
@ -186,7 +186,7 @@ pub trait CompilerInterface {
|
|||
) -> SemanticBuilderReturn<'a> {
|
||||
SemanticBuilder::new(source_text, source_type)
|
||||
.with_check_syntax_error(self.check_semantic_error())
|
||||
.build_module_record(source_path.to_path_buf(), program)
|
||||
.build_module_record(source_path, program)
|
||||
.build(program)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ impl Runtime {
|
|||
.with_build_jsdoc(true)
|
||||
.with_trivias(trivias)
|
||||
.with_check_syntax_error(check_syntax_errors)
|
||||
.build_module_record(path.to_path_buf(), program);
|
||||
.build_module_record(path, program);
|
||||
let module_record = semantic_builder.module_record();
|
||||
|
||||
if self.linter.options().plugins.import {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ fn main() -> std::io::Result<()> {
|
|||
let program = allocator.alloc(parser_ret.program);
|
||||
|
||||
let semantic = SemanticBuilder::new(&source_text, source_type)
|
||||
.build_module_record(path.to_path_buf(), program)
|
||||
.build_module_record(path, program)
|
||||
// Enable additional syntax checks not performed by the parser
|
||||
.with_check_syntax_error(true)
|
||||
// Inform Semantic about comments found while parsing
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::{
|
||||
cell::{Cell, RefCell},
|
||||
path::PathBuf,
|
||||
path::Path,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
|
|
@ -195,10 +195,11 @@ impl<'a> SemanticBuilder<'a> {
|
|||
#[must_use]
|
||||
pub fn build_module_record(
|
||||
mut self,
|
||||
resolved_absolute_path: PathBuf,
|
||||
resolved_absolute_path: &Path,
|
||||
program: &Program<'a>,
|
||||
) -> Self {
|
||||
let mut module_record_builder = ModuleRecordBuilder::new(resolved_absolute_path);
|
||||
let mut module_record_builder =
|
||||
ModuleRecordBuilder::new(resolved_absolute_path.to_path_buf());
|
||||
module_record_builder.visit(program);
|
||||
self.module_record = Arc::new(module_record_builder.build());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ pub use builder::ModuleRecordBuilder;
|
|||
|
||||
#[cfg(test)]
|
||||
mod module_record_tests {
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
use std::{path::Path, sync::Arc};
|
||||
|
||||
use oxc_allocator::Allocator;
|
||||
use oxc_parser::Parser;
|
||||
|
|
@ -21,7 +21,7 @@ mod module_record_tests {
|
|||
let program = allocator.alloc(ret.program);
|
||||
let semantic_ret = SemanticBuilder::new(source_text, source_type)
|
||||
.with_trivias(ret.trivias)
|
||||
.build_module_record(PathBuf::new(), program)
|
||||
.build_module_record(Path::new(""), program)
|
||||
.build(program);
|
||||
Arc::clone(&semantic_ret.semantic.module_record)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ impl Oxc {
|
|||
let semantic_ret = SemanticBuilder::new(source_text, source_type)
|
||||
.with_trivias(trivias.clone())
|
||||
.with_check_syntax_error(true)
|
||||
.build_module_record(path.clone(), &program)
|
||||
.build_module_record(&path, &program)
|
||||
.build(&program);
|
||||
|
||||
if run_options.syntax.unwrap_or_default() {
|
||||
|
|
@ -285,7 +285,7 @@ impl Oxc {
|
|||
let semantic_ret = SemanticBuilder::new(source_text, source_type)
|
||||
.with_cfg(true)
|
||||
.with_trivias(trivias.clone())
|
||||
.build_module_record(path.to_path_buf(), program)
|
||||
.build_module_record(path, program)
|
||||
.build(program);
|
||||
let semantic = Rc::new(semantic_ret.semantic);
|
||||
let linter_ret = Linter::default().run(path, Rc::clone(&semantic));
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
use std::{
|
||||
env,
|
||||
path::{Path, PathBuf},
|
||||
rc::Rc,
|
||||
};
|
||||
use std::{env, path::Path, rc::Rc};
|
||||
|
||||
use oxc_allocator::Allocator;
|
||||
use oxc_benchmark::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
|
|
@ -35,7 +31,7 @@ fn bench_linter(criterion: &mut Criterion) {
|
|||
let semantic_ret = SemanticBuilder::new(source_text, source_type)
|
||||
.with_trivias(ret.trivias)
|
||||
.with_cfg(true)
|
||||
.build_module_record(PathBuf::new(), program)
|
||||
.build_module_record(Path::new(""), program)
|
||||
.build(program);
|
||||
let filter = vec![
|
||||
(AllowWarnDeny::Deny, "all".into()),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::path::PathBuf;
|
||||
use std::path::Path;
|
||||
|
||||
use oxc_allocator::Allocator;
|
||||
use oxc_benchmark::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
|
|
@ -26,7 +26,7 @@ fn bench_semantic(criterion: &mut Criterion) {
|
|||
let ret = SemanticBuilder::new(source_text, source_type)
|
||||
.with_trivias(ret.trivias.clone())
|
||||
.with_build_jsdoc(true)
|
||||
.build_module_record(PathBuf::new(), program)
|
||||
.build_module_record(Path::new(""), program)
|
||||
.build(program);
|
||||
let ret = black_box(ret);
|
||||
ret.errors
|
||||
|
|
|
|||
Loading…
Reference in a new issue