1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 23:34:47 -05:00

fix(lsp): use registry cache for completion search (#23094)

This commit is contained in:
Nayeem Rahman 2024-03-27 16:02:05 +00:00 committed by GitHub
parent 49f97d5f85
commit 726ddabf1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -504,23 +504,14 @@ impl Inner {
module_registries_location.clone(), module_registries_location.clone(),
http_client.clone(), http_client.clone(),
); );
let location = dir.deps_folder_path(); let jsr_search_api =
let deps_http_cache = Arc::new(GlobalHttpCache::new( CliJsrSearchApi::new(module_registries.file_fetcher.clone());
location,
crate::cache::RealDenoCacheEnv,
));
let mut deps_file_fetcher = FileFetcher::new(
deps_http_cache.clone(),
CacheSetting::RespectHeaders,
true,
http_client.clone(),
Default::default(),
None,
);
deps_file_fetcher.set_download_log_level(super::logging::lsp_log_level());
let jsr_search_api = CliJsrSearchApi::new(deps_file_fetcher);
let npm_search_api = let npm_search_api =
CliNpmSearchApi::new(module_registries.file_fetcher.clone()); CliNpmSearchApi::new(module_registries.file_fetcher.clone());
let deps_http_cache = Arc::new(GlobalHttpCache::new(
dir.deps_folder_path(),
crate::cache::RealDenoCacheEnv,
));
let documents = Documents::new(deps_http_cache.clone()); let documents = Documents::new(deps_http_cache.clone());
let cache_metadata = cache::CacheMetadata::new(deps_http_cache.clone()); let cache_metadata = cache::CacheMetadata::new(deps_http_cache.clone());
let performance = Arc::new(Performance::default()); let performance = Arc::new(Performance::default());
@ -752,34 +743,26 @@ impl Inner {
)?; )?;
let root_cert_store_provider = let root_cert_store_provider =
Arc::new(LspRootCertStoreProvider(root_cert_store)); Arc::new(LspRootCertStoreProvider(root_cert_store));
let module_registries_location = dir.registries_folder_path();
self.http_client = Arc::new(HttpClient::new( self.http_client = Arc::new(HttpClient::new(
Some(root_cert_store_provider), Some(root_cert_store_provider),
workspace_settings workspace_settings
.unsafely_ignore_certificate_errors .unsafely_ignore_certificate_errors
.clone(), .clone(),
)); ));
self.module_registries_location = dir.registries_folder_path();
self.module_registries = ModuleRegistry::new( self.module_registries = ModuleRegistry::new(
module_registries_location.clone(), self.module_registries_location.clone(),
self.http_client.clone(), self.http_client.clone(),
); );
self.module_registries_location = module_registries_location; self.jsr_search_api =
CliJsrSearchApi::new(self.module_registries.file_fetcher.clone());
self.npm.search_api =
CliNpmSearchApi::new(self.module_registries.file_fetcher.clone());
// update the cache path // update the cache path
let global_cache = Arc::new(GlobalHttpCache::new( let global_cache = Arc::new(GlobalHttpCache::new(
dir.deps_folder_path(), dir.deps_folder_path(),
crate::cache::RealDenoCacheEnv, crate::cache::RealDenoCacheEnv,
)); ));
let mut deps_file_fetcher = FileFetcher::new(
global_cache.clone(),
CacheSetting::RespectHeaders,
true,
self.http_client.clone(),
Default::default(),
None,
);
deps_file_fetcher.set_download_log_level(super::logging::lsp_log_level());
self.jsr_search_api = CliJsrSearchApi::new(deps_file_fetcher.clone());
self.npm.search_api = CliNpmSearchApi::new(deps_file_fetcher);
let maybe_local_cache = let maybe_local_cache =
self.config.tree.root_vendor_dir().map(|local_path| { self.config.tree.root_vendor_dir().map(|local_path| {
Arc::new(LocalLspHttpCache::new(local_path, global_cache.clone())) Arc::new(LocalLspHttpCache::new(local_path, global_cache.clone()))