diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-01-19 17:10:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-19 17:10:14 -0500 |
commit | f73a5fbc89c1e1255ae886b1dfe23329d7ad8713 (patch) | |
tree | 9e5054ef3ff6ef2ba3d55283ca8b6ec6cdb764de /cli/lsp/tsc.rs | |
parent | 6cf05220e3370365a2c6ce8116d1c5624004ca59 (diff) |
refactor(lsp): reduce data stored in `StateSnapshot` (#13426)
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r-- | cli/lsp/tsc.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index c61f7c215..268646506 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -14,6 +14,7 @@ use super::semantic_tokens; use super::semantic_tokens::SemanticTokensBuilder; use super::text; use super::text::LineIndex; +use super::urls::LspUrlMap; use super::urls::INVALID_SPECIFIER; use crate::config_file::TsConfig; @@ -265,13 +266,13 @@ impl Assets { specifier: &ModuleSpecifier, // todo(dsherret): this shouldn't be a parameter, but instead retrieved via // a constructor dependency - get_snapshot: impl Fn() -> LspResult<Arc<StateSnapshot>>, + get_snapshot: impl Fn() -> Arc<StateSnapshot>, ) -> LspResult<Option<AssetDocument>> { // Race conditions are ok to happen here since the assets are static if let Some(maybe_asset) = self.get_cached(specifier) { Ok(maybe_asset) } else { - let maybe_asset = get_asset(specifier, &self.ts_server, get_snapshot()?) + let maybe_asset = get_asset(specifier, &self.ts_server, get_snapshot()) .await .map_err(|err| { error!("Error getting asset {}: {}", specifier, err); @@ -1528,12 +1529,11 @@ impl ReferenceEntry { pub(crate) fn to_location( &self, line_index: Arc<LineIndex>, - language_server: &language_server::Inner, + url_map: &LspUrlMap, ) -> lsp::Location { let specifier = normalize_specifier(&self.document_span.file_name) .unwrap_or_else(|_| INVALID_SPECIFIER.clone()); - let uri = language_server - .url_map + let uri = url_map .normalize_specifier(&specifier) .unwrap_or_else(|_| INVALID_SPECIFIER.clone()); lsp::Location { @@ -2628,7 +2628,6 @@ fn start( state_snapshot: &StateSnapshot, ) -> Result<(), AnyError> { let root_uri = state_snapshot - .config .root_uri .clone() .unwrap_or_else(|| Url::parse("cache:///").unwrap()); |