From 79916226b74bf9593afacbcdfe9d58263bed132f Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Fri, 12 Feb 2021 22:49:42 +1100 Subject: fix(lsp): properly handle static assets (#9476) --- cli/lsp/language_server.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'cli/lsp/language_server.rs') diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 5b4ab0f99..7f7b693f9 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -50,6 +50,7 @@ use super::text; use super::text::LineIndex; use super::tsc; use super::tsc::AssetDocument; +use super::tsc::Assets; use super::tsc::TsServer; use super::utils; @@ -63,7 +64,7 @@ pub struct LanguageServer(Arc>); #[derive(Debug, Clone, Default)] pub struct StateSnapshot { - pub assets: HashMap>, + pub assets: Assets, pub documents: DocumentCache, pub performance: Performance, pub sources: Sources, @@ -73,7 +74,7 @@ pub struct StateSnapshot { pub(crate) struct Inner { /// Cached versions of "fixed" assets that can either be inlined in Rust or /// are part of the TypeScript snapshot and have to be fetched out. - assets: HashMap>, + assets: Assets, /// The LSP client that this LSP server is connected to. client: Client, /// Configuration information. @@ -86,7 +87,7 @@ pub(crate) struct Inner { /// file which will be used by the Deno LSP. maybe_config_uri: Option, /// An optional import map which is used to resolve modules. - pub maybe_import_map: Option, + pub(crate) maybe_import_map: Option, /// The URL for the import map which is used to determine relative imports. maybe_import_map_uri: Option, /// A map of all the cached navigation trees. @@ -203,7 +204,7 @@ impl Inner { } } else { let documents = &self.documents; - if documents.contains(specifier) { + if documents.contains_key(specifier) { documents.line_index(specifier) } else { self.sources.get_line_index(specifier) @@ -529,10 +530,8 @@ impl Inner { if let Some(maybe_asset) = self.assets.get(specifier) { return Ok(maybe_asset.clone()); } else { - let mut state_snapshot = self.snapshot(); let maybe_asset = - tsc::get_asset(&specifier, &self.ts_server, &mut state_snapshot) - .await?; + tsc::get_asset(&specifier, &self.ts_server, self.snapshot()).await?; self.assets.insert(specifier.clone(), maybe_asset.clone()); Ok(maybe_asset) } @@ -1887,7 +1886,7 @@ impl Inner { } // now that we have dependencies loaded, we need to re-analyze them and // invalidate some diagnostics - if self.documents.contains(&referrer) { + if self.documents.contains_key(&referrer) { if let Some(source) = self.documents.content(&referrer).unwrap() { self.analyze_dependencies(&referrer, &source); } -- cgit v1.2.3