summaryrefslogtreecommitdiff
path: root/cli/lsp/tsc.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-02-08 21:45:10 +1100
committerGitHub <noreply@github.com>2021-02-08 21:45:10 +1100
commite368c5d0f9d69e69438cb0a8a8deb49d7b02901a (patch)
treeb4375b56374f3aad19089e0f1016b1b892dc972c /cli/lsp/tsc.rs
parent09b79463d71f3b144a0cfd878108a012c87464ca (diff)
feat(lsp): add implementations code lens (#9441)
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r--cli/lsp/tsc.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index 67286e288..6614ce8e6 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -497,8 +497,16 @@ impl NavigationTree {
specifier: &ModuleSpecifier,
source: &CodeLensSource,
) -> lsp::CodeLens {
+ let range = if let Some(name_span) = &self.name_span {
+ name_span.to_range(line_index)
+ } else if !self.spans.is_empty() {
+ let span = &self.spans[0];
+ span.to_range(line_index)
+ } else {
+ lsp::Range::default()
+ };
lsp::CodeLens {
- range: self.name_span.clone().unwrap().to_range(line_index),
+ range,
command: None,
data: Some(json!({
"specifier": specifier,
@@ -542,6 +550,17 @@ pub struct ImplementationLocation {
display_parts: Vec<SymbolDisplayPart>,
}
+impl ImplementationLocation {
+ pub fn to_location(&self, line_index: &LineIndex) -> lsp::Location {
+ let uri =
+ utils::normalize_file_name(&self.document_span.file_name).unwrap();
+ lsp::Location {
+ uri,
+ range: self.document_span.text_span.to_range(line_index),
+ }
+ }
+}
+
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RenameLocation {