mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
fix: revert lsp related internal specifiers (#17673)
To fix reports of breakage from #17655
This commit is contained in:
parent
34bfa2cb2c
commit
7f23063329
4 changed files with 18 additions and 22 deletions
|
@ -1050,7 +1050,7 @@ impl Inner {
|
|||
|
||||
async fn did_close(&mut self, params: DidCloseTextDocumentParams) {
|
||||
let mark = self.performance.mark("did_close", Some(¶ms));
|
||||
if params.text_document.uri.scheme() == "internal" {
|
||||
if params.text_document.uri.scheme() == "deno" {
|
||||
// we can ignore virtual text documents closing, as they don't need to
|
||||
// be tracked in memory, as they are static assets that won't change
|
||||
// already managed by the language service
|
||||
|
@ -2609,7 +2609,7 @@ impl tower_lsp::LanguageServer for LanguageServer {
|
|||
}
|
||||
|
||||
async fn did_open(&self, params: DidOpenTextDocumentParams) {
|
||||
if params.text_document.uri.scheme() == "internal" {
|
||||
if params.text_document.uri.scheme() == "deno" {
|
||||
// we can ignore virtual text documents opening, as they don't need to
|
||||
// be tracked in memory, as they are static assets that won't change
|
||||
// already managed by the language service
|
||||
|
@ -3121,7 +3121,7 @@ impl Inner {
|
|||
.performance
|
||||
.mark("virtual_text_document", Some(¶ms));
|
||||
let specifier = self.url_map.normalize_url(¶ms.text_document.uri);
|
||||
let contents = if specifier.as_str() == "internal:/status.md" {
|
||||
let contents = if specifier.as_str() == "deno:/status.md" {
|
||||
let mut contents = String::new();
|
||||
let mut documents_specifiers = self
|
||||
.documents
|
||||
|
|
|
@ -1154,15 +1154,11 @@ impl ImplementationLocation {
|
|||
language_server: &language_server::Inner,
|
||||
) -> lsp::Location {
|
||||
let specifier = normalize_specifier(&self.document_span.file_name)
|
||||
.unwrap_or_else(|_| {
|
||||
ModuleSpecifier::parse("internal://invalid").unwrap()
|
||||
});
|
||||
.unwrap_or_else(|_| ModuleSpecifier::parse("deno://invalid").unwrap());
|
||||
let uri = language_server
|
||||
.url_map
|
||||
.normalize_specifier(&specifier)
|
||||
.unwrap_or_else(|_| {
|
||||
ModuleSpecifier::parse("internal://invalid").unwrap()
|
||||
});
|
||||
.unwrap_or_else(|_| ModuleSpecifier::parse("deno://invalid").unwrap());
|
||||
lsp::Location {
|
||||
uri,
|
||||
range: self.document_span.text_span.to_range(line_index),
|
||||
|
|
|
@ -17,7 +17,7 @@ use std::sync::Arc;
|
|||
/// Used in situations where a default URL needs to be used where otherwise a
|
||||
/// panic is undesired.
|
||||
pub static INVALID_SPECIFIER: Lazy<ModuleSpecifier> =
|
||||
Lazy::new(|| ModuleSpecifier::parse("internal://invalid").unwrap());
|
||||
Lazy::new(|| ModuleSpecifier::parse("deno://invalid").unwrap());
|
||||
|
||||
/// Matches the `encodeURIComponent()` encoding from JavaScript, which matches
|
||||
/// the component percent encoding set.
|
||||
|
@ -81,7 +81,7 @@ impl LspUrlMapInner {
|
|||
}
|
||||
|
||||
/// A bi-directional map of URLs sent to the LSP client and internal module
|
||||
/// specifiers. We need to map internal specifiers into `internal:` schema URLs
|
||||
/// specifiers. We need to map internal specifiers into `deno:` schema URLs
|
||||
/// to allow the Deno language server to manage these as virtual documents.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct LspUrlMap(Arc<Mutex<LspUrlMapInner>>);
|
||||
|
@ -101,7 +101,7 @@ impl LspUrlMap {
|
|||
specifier.clone()
|
||||
} else {
|
||||
let specifier_str = if specifier.scheme() == "asset" {
|
||||
format!("internal:/asset{}", specifier.path())
|
||||
format!("deno:/asset{}", specifier.path())
|
||||
} else if specifier.scheme() == "data" {
|
||||
let data_url = DataUrl::process(specifier.as_str())
|
||||
.map_err(|e| uri_error(format!("{e:?}")))?;
|
||||
|
@ -114,7 +114,7 @@ impl LspUrlMap {
|
|||
media_type.as_ts_extension()
|
||||
};
|
||||
format!(
|
||||
"internal:/{}/data_url{}",
|
||||
"deno:/{}/data_url{}",
|
||||
hash_data_specifier(specifier),
|
||||
extension
|
||||
)
|
||||
|
@ -128,7 +128,7 @@ impl LspUrlMap {
|
|||
})
|
||||
.collect();
|
||||
path.push_str(&parts.join("/"));
|
||||
format!("internal:/{path}")
|
||||
format!("deno:/{path}")
|
||||
};
|
||||
let url = Url::parse(&specifier_str)?;
|
||||
inner.put(specifier.clone(), url.clone());
|
||||
|
@ -138,7 +138,7 @@ impl LspUrlMap {
|
|||
}
|
||||
}
|
||||
|
||||
/// Normalize URLs from the client, where "virtual" `internal:///` URLs are
|
||||
/// Normalize URLs from the client, where "virtual" `deno:///` URLs are
|
||||
/// converted into proper module specifiers, as well as handle situations
|
||||
/// where the client encodes a file URL differently than Rust does by default
|
||||
/// causing issues with string matching of URLs.
|
||||
|
@ -178,7 +178,7 @@ mod tests {
|
|||
.normalize_specifier(&fixture)
|
||||
.expect("could not handle specifier");
|
||||
let expected_url =
|
||||
Url::parse("internal:/https/deno.land/x/pkg%401.0.0/mod.ts").unwrap();
|
||||
Url::parse("deno:/https/deno.land/x/pkg%401.0.0/mod.ts").unwrap();
|
||||
assert_eq!(actual_url, expected_url);
|
||||
|
||||
let actual_specifier = map.normalize_url(&actual_url);
|
||||
|
@ -193,7 +193,7 @@ mod tests {
|
|||
let actual_url = map
|
||||
.normalize_specifier(&fixture)
|
||||
.expect("could not handle specifier");
|
||||
let expected_url = Url::parse("internal:/https/cdn.skypack.dev/-/postcss%40v8.2.9-E4SktPp9c0AtxrJHp8iV/dist%3Des2020%2Cmode%3Dtypes/lib/postcss.d.ts").unwrap();
|
||||
let expected_url = Url::parse("deno:/https/cdn.skypack.dev/-/postcss%40v8.2.9-E4SktPp9c0AtxrJHp8iV/dist%3Des2020%2Cmode%3Dtypes/lib/postcss.d.ts").unwrap();
|
||||
assert_eq!(actual_url, expected_url);
|
||||
|
||||
let actual_specifier = map.normalize_url(&actual_url);
|
||||
|
@ -207,7 +207,7 @@ mod tests {
|
|||
let actual_url = map
|
||||
.normalize_specifier(&fixture)
|
||||
.expect("could not handle specifier");
|
||||
let expected_url = Url::parse("internal:/c21c7fc382b2b0553dc0864aa81a3acacfb7b3d1285ab5ae76da6abec213fb37/data_url.ts").unwrap();
|
||||
let expected_url = Url::parse("deno:/c21c7fc382b2b0553dc0864aa81a3acacfb7b3d1285ab5ae76da6abec213fb37/data_url.ts").unwrap();
|
||||
assert_eq!(actual_url, expected_url);
|
||||
|
||||
let actual_specifier = map.normalize_url(&actual_url);
|
||||
|
|
|
@ -1073,7 +1073,7 @@ fn lsp_hover_asset() {
|
|||
"deno/virtualTextDocument",
|
||||
json!({
|
||||
"textDocument": {
|
||||
"uri": "internal:/asset/lib.deno.shared_globals.d.ts"
|
||||
"uri": "deno:/asset/lib.deno.shared_globals.d.ts"
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
@ -1084,7 +1084,7 @@ fn lsp_hover_asset() {
|
|||
"textDocument/hover",
|
||||
json!({
|
||||
"textDocument": {
|
||||
"uri": "internal:/asset/lib.es2015.symbol.wellknown.d.ts"
|
||||
"uri": "deno:/asset/lib.es2015.symbol.wellknown.d.ts"
|
||||
},
|
||||
"position": {
|
||||
"line": 109,
|
||||
|
@ -3103,7 +3103,7 @@ fn lsp_code_lens_non_doc_nav_tree() {
|
|||
"deno/virtualTextDocument",
|
||||
json!({
|
||||
"textDocument": {
|
||||
"uri": "internal:/asset/lib.deno.shared_globals.d.ts"
|
||||
"uri": "deno:/asset/lib.deno.shared_globals.d.ts"
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
@ -3115,7 +3115,7 @@ fn lsp_code_lens_non_doc_nav_tree() {
|
|||
"textDocument/codeLens",
|
||||
json!({
|
||||
"textDocument": {
|
||||
"uri": "internal:/asset/lib.deno.shared_globals.d.ts"
|
||||
"uri": "deno:/asset/lib.deno.shared_globals.d.ts"
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue