summaryrefslogtreecommitdiff
path: root/cli/lsp/tsc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r--cli/lsp/tsc.rs40
1 files changed, 24 insertions, 16 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index fedaae588..3c70e4029 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -14,6 +14,7 @@ use super::refactor::EXTRACT_TYPE;
use super::semantic_tokens;
use super::semantic_tokens::SemanticTokensBuilder;
use super::text::LineIndex;
+use super::urls::LspClientUrl;
use super::urls::LspUrlMap;
use super::urls::INVALID_SPECIFIER;
@@ -36,7 +37,6 @@ use deno_core::serde::Serialize;
use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::serde_json::Value;
-use deno_core::url::Url;
use deno_core::JsRuntime;
use deno_core::ModuleSpecifier;
use deno_core::OpState;
@@ -842,7 +842,7 @@ impl DocumentSpan {
};
let link = lsp::LocationLink {
origin_selection_range,
- target_uri,
+ target_uri: target_uri.into_url(),
target_range,
target_selection_range,
};
@@ -864,7 +864,8 @@ impl DocumentSpan {
let mut target = language_server
.url_map
.normalize_specifier(&specifier)
- .ok()?;
+ .ok()?
+ .into_url();
target.set_fragment(Some(&format!(
"L{},{}",
range.start.line + 1,
@@ -915,7 +916,10 @@ impl NavigateToItem {
.normalize_specifier(&specifier)
.ok()?;
let range = self.text_span.to_range(line_index);
- let location = lsp::Location { uri, range };
+ let location = lsp::Location {
+ uri: uri.into_url(),
+ range,
+ };
let mut tags: Option<Vec<lsp::SymbolTag>> = None;
let kind_modifiers = parse_kind_modifier(&self.kind_modifiers);
@@ -1160,9 +1164,11 @@ impl ImplementationLocation {
let uri = language_server
.url_map
.normalize_specifier(&specifier)
- .unwrap_or_else(|_| ModuleSpecifier::parse("deno://invalid").unwrap());
+ .unwrap_or_else(|_| {
+ LspClientUrl::new(ModuleSpecifier::parse("deno://invalid").unwrap())
+ });
lsp::Location {
- uri,
+ uri: uri.into_url(),
range: self.document_span.text_span.to_range(line_index),
}
}
@@ -1196,8 +1202,10 @@ impl RenameLocations {
new_name: &str,
language_server: &language_server::Inner,
) -> Result<lsp::WorkspaceEdit, AnyError> {
- let mut text_document_edit_map: HashMap<Url, lsp::TextDocumentEdit> =
- HashMap::new();
+ let mut text_document_edit_map: HashMap<
+ LspClientUrl,
+ lsp::TextDocumentEdit,
+ > = HashMap::new();
for location in self.locations.iter() {
let specifier = normalize_specifier(&location.document_span.file_name)?;
let uri = language_server.url_map.normalize_specifier(&specifier)?;
@@ -1209,7 +1217,7 @@ impl RenameLocations {
uri.clone(),
lsp::TextDocumentEdit {
text_document: lsp::OptionalVersionedTextDocumentIdentifier {
- uri: uri.clone(),
+ uri: uri.as_url().clone(),
version: asset_or_doc.document_lsp_version(),
},
edits:
@@ -1698,9 +1706,9 @@ impl ReferenceEntry {
.unwrap_or_else(|_| INVALID_SPECIFIER.clone());
let uri = url_map
.normalize_specifier(&specifier)
- .unwrap_or_else(|_| INVALID_SPECIFIER.clone());
+ .unwrap_or_else(|_| LspClientUrl::new(INVALID_SPECIFIER.clone()));
lsp::Location {
- uri,
+ uri: uri.into_url(),
range: self.document_span.text_span.to_range(line_index),
}
}
@@ -1748,11 +1756,11 @@ impl CallHierarchyItem {
let uri = language_server
.url_map
.normalize_specifier(&target_specifier)
- .unwrap_or_else(|_| INVALID_SPECIFIER.clone());
+ .unwrap_or_else(|_| LspClientUrl::new(INVALID_SPECIFIER.clone()));
let use_file_name = self.is_source_file_item();
- let maybe_file_path = if uri.scheme() == "file" {
- specifier_to_file_path(&uri).ok()
+ let maybe_file_path = if uri.as_url().scheme() == "file" {
+ specifier_to_file_path(uri.as_url()).ok()
} else {
None
};
@@ -1760,7 +1768,7 @@ impl CallHierarchyItem {
if let Some(file_path) = maybe_file_path.as_ref() {
file_path.file_name().unwrap().to_string_lossy().to_string()
} else {
- uri.to_string()
+ uri.as_str().to_string()
}
} else {
self.name.clone()
@@ -1796,7 +1804,7 @@ impl CallHierarchyItem {
lsp::CallHierarchyItem {
name,
tags,
- uri,
+ uri: uri.into_url(),
detail: Some(detail),
kind: self.kind.clone().into(),
range: self.span.to_range(line_index.clone()),