diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2021-06-05 07:31:44 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-05 07:31:44 +1000 |
commit | e8be116ab6d06bed764ad9b6cb253d8de36ae73d (patch) | |
tree | 47f0ac3695ce7dd76fc9af1d7991c7ba685adf85 /cli/lsp/tsc.rs | |
parent | 1abff0e333861211b5186527bc1c1371709ce3e4 (diff) |
fix(lsp): refactor, fix issues and add benchmark for code lens (#10841)
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r-- | cli/lsp/tsc.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 6a476054f..834ac0a0c 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -1,8 +1,8 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use super::analysis::CodeLensSource; use super::analysis::ResolvedDependency; use super::analysis::ResolvedDependencyErr; +use super::code_lens; use super::config; use super::language_server; use super::language_server::StateSnapshot; @@ -103,6 +103,7 @@ pub struct AssetDocument { pub text: String, pub length: usize, pub line_index: LineIndex, + pub maybe_navigation_tree: Option<NavigationTree>, } impl AssetDocument { @@ -112,6 +113,7 @@ impl AssetDocument { text: text.to_string(), length: text.encode_utf16().count(), line_index: LineIndex::new(text), + maybe_navigation_tree: None, } } } @@ -150,6 +152,22 @@ impl Assets { ) -> Option<Option<AssetDocument>> { self.0.insert(k, v) } + + pub fn set_navigation_tree( + &mut self, + specifier: &ModuleSpecifier, + navigation_tree: NavigationTree, + ) -> Result<(), AnyError> { + let maybe_doc = self + .0 + .get_mut(specifier) + .ok_or_else(|| anyhow!("Missing asset."))?; + let doc = maybe_doc + .as_mut() + .ok_or_else(|| anyhow!("Cannot get doc mutable"))?; + doc.maybe_navigation_tree = Some(navigation_tree); + Ok(()) + } } /// Optionally returns an internal asset, first checking for any static assets @@ -610,7 +628,7 @@ impl NavigationTree { &self, line_index: &LineIndex, specifier: &ModuleSpecifier, - source: &CodeLensSource, + source: &code_lens::CodeLensSource, ) -> lsp::CodeLens { let range = if let Some(name_span) = &self.name_span { name_span.to_range(line_index) |