summaryrefslogtreecommitdiff
path: root/cli/lsp/language_server.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-08-02 16:57:25 -0400
committerGitHub <noreply@github.com>2023-08-02 16:57:25 -0400
commit480894e5c8f9532a4c42477cdf5c058cb8e9e1e3 (patch)
tree7241c8864439b60c97f2140ccdef17ed07a5dbcf /cli/lsp/language_server.rs
parente8d03119a0599ef8d811f8fa33ad1a580adf5511 (diff)
feat(unstable/lsp): support navigating to deno_modules folder (#20030)
Closes #20015 Closes https://github.com/denoland/vscode_deno/issues/850 (only for deno_modules, but I don't think this will be possible for the global cache)
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r--cli/lsp/language_server.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 4c3ee1013..06fefcaeb 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -88,7 +88,7 @@ use crate::cache::DenoDir;
use crate::cache::FastInsecureHasher;
use crate::cache::GlobalHttpCache;
use crate::cache::HttpCache;
-use crate::cache::LocalHttpCache;
+use crate::cache::LocalLspHttpCache;
use crate::factory::CliFactory;
use crate::file_fetcher::FileFetcher;
use crate::graph_util;
@@ -204,7 +204,7 @@ pub struct Inner {
/// An abstraction that handles interactions with TypeScript.
pub ts_server: Arc<TsServer>,
/// A map of specifiers and URLs used to translate over the LSP.
- pub url_map: Arc<urls::LspUrlMap>,
+ pub url_map: urls::LspUrlMap,
}
impl LanguageServer {
@@ -905,16 +905,18 @@ impl Inner {
self.module_registries_location = module_registries_location;
// update the cache path
let global_cache = Arc::new(GlobalHttpCache::new(dir.deps_folder_path()));
- let cache: Arc<dyn HttpCache> =
- match self.config.maybe_deno_modules_dir_path() {
- Some(local_path) => {
- Arc::new(LocalHttpCache::new(local_path, global_cache))
- }
- None => global_cache,
- };
+ let maybe_local_cache =
+ self.config.maybe_deno_modules_dir_path().map(|local_path| {
+ Arc::new(LocalLspHttpCache::new(local_path, global_cache.clone()))
+ });
+ let cache: Arc<dyn HttpCache> = maybe_local_cache
+ .clone()
+ .map(|c| c as Arc<dyn HttpCache>)
+ .unwrap_or(global_cache);
self.deps_http_cache = cache.clone();
self.documents.set_cache(cache.clone());
self.cache_metadata.set_cache(cache);
+ self.url_map.set_cache(maybe_local_cache);
self.maybe_global_cache_path = new_cache_path;
Ok(())
}
@@ -2946,6 +2948,7 @@ impl Inner {
snapshot: self.snapshot(),
config: self.config.snapshot(),
lint_options: self.lint_options.clone(),
+ url_map: self.url_map.clone(),
};
if let Err(err) = self.diagnostics_server.update(snapshot) {
error!("Cannot update diagnostics: {}", err);