summaryrefslogtreecommitdiff
path: root/cli/cache/caches.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/cache/caches.rs')
-rw-r--r--cli/cache/caches.rs33
1 files changed, 22 insertions, 11 deletions
diff --git a/cli/cache/caches.rs b/cli/cache/caches.rs
index 0b60d0bec..62bec8a00 100644
--- a/cli/cache/caches.rs
+++ b/cli/cache/caches.rs
@@ -12,8 +12,8 @@ use super::node::NODE_ANALYSIS_CACHE_DB;
use super::parsed_source::PARSED_SOURCE_CACHE_DB;
use super::DenoDir;
-#[derive(Default)]
pub struct Caches {
+ dir: DenoDir,
fmt_incremental_cache_db: OnceCell<CacheDB>,
lint_incremental_cache_db: OnceCell<CacheDB>,
dep_analysis_db: OnceCell<CacheDB>,
@@ -22,6 +22,17 @@ pub struct Caches {
}
impl Caches {
+ pub fn new(dir: DenoDir) -> Self {
+ Self {
+ dir,
+ fmt_incremental_cache_db: Default::default(),
+ lint_incremental_cache_db: Default::default(),
+ dep_analysis_db: Default::default(),
+ node_analysis_db: Default::default(),
+ type_checking_cache_db: Default::default(),
+ }
+ }
+
fn make_db(
cell: &OnceCell<CacheDB>,
config: &'static CacheDBConfiguration,
@@ -32,43 +43,43 @@ impl Caches {
.clone()
}
- pub fn fmt_incremental_cache_db(&self, dir: &DenoDir) -> CacheDB {
+ pub fn fmt_incremental_cache_db(&self) -> CacheDB {
Self::make_db(
&self.fmt_incremental_cache_db,
&INCREMENTAL_CACHE_DB,
- dir.fmt_incremental_cache_db_file_path(),
+ self.dir.fmt_incremental_cache_db_file_path(),
)
}
- pub fn lint_incremental_cache_db(&self, dir: &DenoDir) -> CacheDB {
+ pub fn lint_incremental_cache_db(&self) -> CacheDB {
Self::make_db(
&self.lint_incremental_cache_db,
&INCREMENTAL_CACHE_DB,
- dir.lint_incremental_cache_db_file_path(),
+ self.dir.lint_incremental_cache_db_file_path(),
)
}
- pub fn dep_analysis_db(&self, dir: &DenoDir) -> CacheDB {
+ pub fn dep_analysis_db(&self) -> CacheDB {
Self::make_db(
&self.dep_analysis_db,
&PARSED_SOURCE_CACHE_DB,
- dir.dep_analysis_db_file_path(),
+ self.dir.dep_analysis_db_file_path(),
)
}
- pub fn node_analysis_db(&self, dir: &DenoDir) -> CacheDB {
+ pub fn node_analysis_db(&self) -> CacheDB {
Self::make_db(
&self.node_analysis_db,
&NODE_ANALYSIS_CACHE_DB,
- dir.node_analysis_db_file_path(),
+ self.dir.node_analysis_db_file_path(),
)
}
- pub fn type_checking_cache_db(&self, dir: &DenoDir) -> CacheDB {
+ pub fn type_checking_cache_db(&self) -> CacheDB {
Self::make_db(
&self.type_checking_cache_db,
&TYPE_CHECK_CACHE_DB,
- dir.type_checking_cache_db_file_path(),
+ self.dir.type_checking_cache_db_file_path(),
)
}
}