Skip to content

Commit 38abcd7

Browse files
authored
(1) Implement generic oak_cache (#1298)
Part of #1234 Part of a series of PRs to get the sources mechanism integrated with oak. Most of the PRs revolve around restructuring the cache in a way that I think makes a lot more sense (particularly if we want it to be usable elsewhere). We end up with: - `oak_cache` - Generic `Cache` mechanism - `oak_srcref` - Home to `SrcrefCache`, requires R, extracts the `srcref` attribute - `oak_source` - Home to `SourceCache`, which knows how to download CRAN R package tarballs and R version tarballs And `oak_sources` gets removed at the end. When I worked on the caching stuff earlier, I struggled to reconcile with the fact that different caching sources return different things. We have 3 things we can return: - srcrefs, which is just the reconstructed `R/` folder - CRAN R package tarballs, which is a single R package in its entirety - CRAN R version tarballs, which is a single R version in its entirety Rather than trying to squish these together into a single cache mechanism, which required us to drop useful things from the CRAN downloads to align with the more minimal result we get from the srcref extractor, we now keep them separate in separate caches, so we end up with: - `oak_srcref::SrcrefCache` feeding to `.cache/oak/srcref/` - `oak_source::SourceCache::cran` feeding to `.cache/oak/source/cran/` - `oak_source::SourceCache::r` feeding to `.cache/oak/source/r/` Each cache folder now has a consistent structure that also maximizes information retention. i.e. in the CRAN download we keep the entire R package source, including things like `man/`, `src/`, and any `inst/` folder you might have included. I imagine this could be useful in the future (navigating to C functions?). I'm also hoping that `oak_source` can be useful on its own without requiring the heavier R dependency that `oak_srcref` has. The end result of this series of 5 PRs is a production level `SourceHandler` that is integrated in the LSP that pulls sources using `oak_srcref` and `oak_source` when you are in a debug build. Release builds still don't have it turned on yet. And it isn't being utilized in any LSP features yet. I'll turn them on one by one after merging this series.
2 parents d0569cc + 6361e5e commit 38abcd7

4 files changed

Lines changed: 470 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ log = "0.4.29"
7575
mime_guess = "2.0.5"
7676
nix = { version = "0.31", features = ["fs", "poll", "process", "signal"] }
7777
notify = "8.2.0"
78+
oak_cache = { path = "crates/oak_cache" }
7879
oak_core = { path = "crates/oak_core" }
7980
oak_db = { path = "crates/oak_db" }
8081
oak_fs = { path = "crates/oak_fs" }

crates/oak_cache/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "oak_cache"
3+
version = "0.1.0"
4+
authors.workspace = true
5+
edition.workspace = true
6+
rust-version.workspace = true
7+
license.workspace = true
8+
9+
[dependencies]
10+
anyhow.workspace = true
11+
etcetera.workspace = true
12+
log.workspace = true
13+
oak_fs.workspace = true
14+
15+
[dev-dependencies]
16+
tempfile.workspace = true
17+
18+
[lints]
19+
workspace = true

0 commit comments

Comments
 (0)