summaryrefslogtreecommitdiff
path: root/cli/lsp/diagnostics.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-07-08 16:06:45 -0400
committerGitHub <noreply@github.com>2023-07-08 16:06:45 -0400
commit21cc279481ac5bffc29641e917e868dca42189d3 (patch)
tree4e0201da6a5d6beaff5139a84e4c52ec5e9affd6 /cli/lsp/diagnostics.rs
parentf3095b8d311c85f633d280a980f76062015f8974 (diff)
refactor: abstract away file system to be buried inside HttpCache (#19760)
This improves the HttpCache to make it being stored on the file system an implementation detail.
Diffstat (limited to 'cli/lsp/diagnostics.rs')
-rw-r--r--cli/lsp/diagnostics.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs
index 415fe142d..b202e47d6 100644
--- a/cli/lsp/diagnostics.rs
+++ b/cli/lsp/diagnostics.rs
@@ -1169,6 +1169,7 @@ async fn generate_deno_diagnostics(
#[cfg(test)]
mod tests {
use super::*;
+ use crate::cache::HttpCache;
use crate::lsp::config::ConfigSnapshot;
use crate::lsp::config::Settings;
use crate::lsp::config::SpecifierSettings;
@@ -1187,7 +1188,8 @@ mod tests {
location: &Path,
maybe_import_map: Option<(&str, &str)>,
) -> StateSnapshot {
- let mut documents = Documents::new(location.to_path_buf());
+ let cache = HttpCache::new(location.to_path_buf());
+ let mut documents = Documents::new(cache);
for (specifier, source, version, language_id) in fixtures {
let specifier =
resolve_url(specifier).expect("failed to create specifier");
@@ -1209,7 +1211,12 @@ mod tests {
StateSnapshot {
documents,
maybe_import_map,
- ..Default::default()
+ assets: Default::default(),
+ cache_metadata: cache::CacheMetadata::new(HttpCache::new(
+ location.to_path_buf(),
+ )),
+ maybe_node_resolver: None,
+ maybe_npm_resolver: None,
}
}
@@ -1242,7 +1249,7 @@ mod tests {
async fn test_enabled_then_disabled_specifier() {
let temp_dir = TempDir::new();
let specifier = ModuleSpecifier::parse("file:///a.ts").unwrap();
- let (snapshot, _) = setup(
+ let (snapshot, cache_location) = setup(
&temp_dir,
&[(
"file:///a.ts",
@@ -1256,7 +1263,8 @@ let c: number = "a";
None,
);
let snapshot = Arc::new(snapshot);
- let ts_server = TsServer::new(Default::default());
+ let cache = HttpCache::new(cache_location);
+ let ts_server = TsServer::new(Default::default(), cache);
// test enabled
{
@@ -1337,7 +1345,7 @@ let c: number = "a";
#[tokio::test]
async fn test_cancelled_ts_diagnostics_request() {
let temp_dir = TempDir::new();
- let (snapshot, _) = setup(
+ let (snapshot, cache_location) = setup(
&temp_dir,
&[(
"file:///a.ts",
@@ -1348,7 +1356,8 @@ let c: number = "a";
None,
);
let snapshot = Arc::new(snapshot);
- let ts_server = TsServer::new(Default::default());
+ let cache = HttpCache::new(cache_location);
+ let ts_server = TsServer::new(Default::default(), cache);
let config = mock_config();
let token = CancellationToken::new();