mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(linter): make Runtime's members private (#6440)
Protecting `Runtime`'s API in preparation of multli-config support.
This commit is contained in:
parent
c00f669435
commit
002078afe3
2 changed files with 16 additions and 9 deletions
|
|
@ -85,14 +85,13 @@ impl LintService {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn number_of_dependencies(&self) -> usize {
|
pub fn number_of_dependencies(&self) -> usize {
|
||||||
self.runtime.modules.len() - self.runtime.paths.len()
|
self.runtime.number_of_dependencies()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Panics
|
/// # Panics
|
||||||
pub fn run(&self, tx_error: &DiagnosticSender) {
|
pub fn run(&self, tx_error: &DiagnosticSender) {
|
||||||
self.runtime
|
self.runtime
|
||||||
.paths
|
.iter_paths()
|
||||||
.iter()
|
|
||||||
.par_bridge()
|
.par_bridge()
|
||||||
.for_each_with(&self.runtime, |runtime, path| runtime.process_path(path, tx_error));
|
.for_each_with(&self.runtime, |runtime, path| runtime.process_path(path, tx_error));
|
||||||
tx_error.send(None).unwrap();
|
tx_error.send(None).unwrap();
|
||||||
|
|
@ -108,8 +107,7 @@ impl LintService {
|
||||||
tx_error: &DiagnosticSender,
|
tx_error: &DiagnosticSender,
|
||||||
) -> Vec<crate::Message<'a>> {
|
) -> Vec<crate::Message<'a>> {
|
||||||
self.runtime
|
self.runtime
|
||||||
.paths
|
.iter_paths()
|
||||||
.iter()
|
|
||||||
.flat_map(|path| {
|
.flat_map(|path| {
|
||||||
let source_type = oxc_span::SourceType::from_path(path).unwrap();
|
let source_type = oxc_span::SourceType::from_path(path).unwrap();
|
||||||
self.runtime.init_cache_state(path);
|
self.runtime.init_cache_state(path);
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,12 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Runtime {
|
pub struct Runtime {
|
||||||
pub(super) cwd: Box<Path>,
|
cwd: Box<Path>,
|
||||||
/// All paths to lint
|
/// All paths to lint
|
||||||
pub(super) paths: FxHashSet<Box<Path>>,
|
paths: FxHashSet<Box<Path>>,
|
||||||
pub(super) linter: Linter,
|
pub(super) linter: Linter,
|
||||||
pub(super) resolver: Option<Resolver>,
|
resolver: Option<Resolver>,
|
||||||
pub(super) modules: ModuleCache,
|
modules: ModuleCache,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Runtime {
|
impl Runtime {
|
||||||
|
|
@ -300,7 +300,16 @@ impl Runtime {
|
||||||
|
|
||||||
self.modules.init_cache_state(path)
|
self.modules.init_cache_state(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ignore_path(&self, path: &Path) {
|
fn ignore_path(&self, path: &Path) {
|
||||||
self.resolver.is_some().then(|| self.modules.ignore_path(path));
|
self.resolver.is_some().then(|| self.modules.ignore_path(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn number_of_dependencies(&self) -> usize {
|
||||||
|
self.modules.len() - self.paths.len()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn iter_paths(&self) -> impl Iterator<Item = &Box<Path>> + '_ {
|
||||||
|
self.paths.iter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue