summaryrefslogtreecommitdiff
path: root/cli/lsp/tsc.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-08-01 20:49:09 -0400
committerGitHub <noreply@github.com>2023-08-02 00:49:09 +0000
commit1cefa831fd74b14121494045a347024502d74e34 (patch)
treecc7791cf674e427fe4165262db416e6c537e99a3 /cli/lsp/tsc.rs
parent36ae37604a0ddab4349df6eb6fafb8ae39fd20fc (diff)
feat(unstable): optional `deno_modules` directory (#19977)
Closes #15633
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r--cli/lsp/tsc.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index 662b48061..b26fa57bc 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -99,7 +99,7 @@ type Request = (
pub struct TsServer(mpsc::UnboundedSender<Request>);
impl TsServer {
- pub fn new(performance: Arc<Performance>, cache: HttpCache) -> Self {
+ pub fn new(performance: Arc<Performance>, cache: Arc<dyn HttpCache>) -> Self {
let (tx, mut rx) = mpsc::unbounded_channel::<Request>();
let _join_handle = thread::spawn(move || {
let mut ts_runtime = js_runtime(performance, cache);
@@ -3245,7 +3245,10 @@ fn op_script_version(
/// Create and setup a JsRuntime based on a snapshot. It is expected that the
/// supplied snapshot is an isolate that contains the TypeScript language
/// server.
-fn js_runtime(performance: Arc<Performance>, cache: HttpCache) -> JsRuntime {
+fn js_runtime(
+ performance: Arc<Performance>,
+ cache: Arc<dyn HttpCache>,
+) -> JsRuntime {
JsRuntime::new(RuntimeOptions {
extensions: vec![deno_tsc::init_ops(performance, cache)],
startup_snapshot: Some(tsc::compiler_snapshot()),
@@ -3265,7 +3268,7 @@ deno_core::extension!(deno_tsc,
],
options = {
performance: Arc<Performance>,
- cache: HttpCache,
+ cache: Arc<dyn HttpCache>,
},
state = |state, options| {
state.put(State::new(
@@ -3906,6 +3909,7 @@ fn request(
#[cfg(test)]
mod tests {
use super::*;
+ use crate::cache::GlobalHttpCache;
use crate::cache::HttpCache;
use crate::http_util::HeadersMap;
use crate::lsp::cache::CacheMetadata;
@@ -3923,7 +3927,7 @@ mod tests {
fixtures: &[(&str, &str, i32, LanguageId)],
location: &Path,
) -> StateSnapshot {
- let cache = HttpCache::new(location.to_path_buf());
+ let cache = Arc::new(GlobalHttpCache::new(location.to_path_buf()));
let mut documents = Documents::new(cache.clone());
for (specifier, source, version, language_id) in fixtures {
let specifier =
@@ -3952,7 +3956,7 @@ mod tests {
sources: &[(&str, &str, i32, LanguageId)],
) -> (JsRuntime, Arc<StateSnapshot>, PathBuf) {
let location = temp_dir.path().join("deps").to_path_buf();
- let cache = HttpCache::new(location.clone());
+ let cache = Arc::new(GlobalHttpCache::new(location.clone()));
let state_snapshot = Arc::new(mock_state_snapshot(sources, &location));
let mut runtime = js_runtime(Default::default(), cache);
start(&mut runtime, debug).unwrap();
@@ -4432,7 +4436,7 @@ mod tests {
LanguageId::TypeScript,
)],
);
- let cache = HttpCache::new(location);
+ let cache = Arc::new(GlobalHttpCache::new(location));
let specifier_dep =
resolve_url("https://deno.land/x/example/a.ts").unwrap();
cache