summaryrefslogtreecommitdiff
path: root/cli/lsp
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-09-28 07:55:01 -0400
committerGitHub <noreply@github.com>2024-09-28 07:55:01 -0400
commitfc739dc5eb2769e4608ccf08d23ca8ff0fcc19c5 (patch)
tree9c5bca411f4b9a6aea5a190d88217f4925563ad3 /cli/lsp
parentb694efb3849c4737e8ad617a9a48d5488e21d5da (diff)
refactor: use deno_path_util (#25918)
Diffstat (limited to 'cli/lsp')
-rw-r--r--cli/lsp/analysis.rs4
-rw-r--r--cli/lsp/cache.rs10
-rw-r--r--cli/lsp/completions.rs4
-rw-r--r--cli/lsp/config.rs14
-rw-r--r--cli/lsp/documents.rs8
-rw-r--r--cli/lsp/language_server.rs16
-rw-r--r--cli/lsp/resolver.rs4
-rw-r--r--cli/lsp/tsc.rs4
8 files changed, 32 insertions, 32 deletions
diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs
index fee9c86cb..80db66d64 100644
--- a/cli/lsp/analysis.rs
+++ b/cli/lsp/analysis.rs
@@ -23,8 +23,8 @@ use deno_core::serde::Serialize;
use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::ModuleSpecifier;
+use deno_path_util::url_to_file_path;
use deno_runtime::deno_node::PathClean;
-use deno_runtime::fs_util::specifier_to_file_path;
use deno_semver::jsr::JsrPackageNvReference;
use deno_semver::jsr::JsrPackageReqReference;
use deno_semver::npm::NpmPackageReqReference;
@@ -401,7 +401,7 @@ impl<'a> TsResponseImportMapper<'a> {
.flatten()?;
let root_folder = package_json.path.parent()?;
- let specifier_path = specifier_to_file_path(specifier).ok()?;
+ let specifier_path = url_to_file_path(specifier).ok()?;
let mut search_paths = vec![specifier_path.clone()];
// TypeScript will provide a .js extension for quick fixes, so do
// a search for the .d.ts file instead
diff --git a/cli/lsp/cache.rs b/cli/lsp/cache.rs
index a32087842..db10dc967 100644
--- a/cli/lsp/cache.rs
+++ b/cli/lsp/cache.rs
@@ -10,7 +10,7 @@ use crate::lsp::logging::lsp_warn;
use deno_core::url::Url;
use deno_core::ModuleSpecifier;
-use deno_runtime::fs_util::specifier_to_file_path;
+use deno_path_util::url_to_file_path;
use std::collections::BTreeMap;
use std::fs;
use std::path::Path;
@@ -24,7 +24,7 @@ pub fn calculate_fs_version(
) -> Option<String> {
match specifier.scheme() {
"npm" | "node" | "data" | "blob" => None,
- "file" => specifier_to_file_path(specifier)
+ "file" => url_to_file_path(specifier)
.ok()
.and_then(|path| calculate_fs_version_at_path(&path)),
_ => calculate_fs_version_in_cache(cache, specifier, file_referrer),
@@ -82,7 +82,7 @@ impl Default for LspCache {
impl LspCache {
pub fn new(global_cache_url: Option<Url>) -> Self {
let global_cache_path = global_cache_url.and_then(|s| {
- specifier_to_file_path(&s)
+ url_to_file_path(&s)
.inspect(|p| {
lsp_log!("Resolved global cache path: \"{}\"", p.to_string_lossy());
})
@@ -165,7 +165,7 @@ impl LspCache {
&self,
specifier: &ModuleSpecifier,
) -> Option<ModuleSpecifier> {
- let path = specifier_to_file_path(specifier).ok()?;
+ let path = url_to_file_path(specifier).ok()?;
let vendor = self
.vendors_by_scope
.iter()
@@ -176,7 +176,7 @@ impl LspCache {
}
pub fn is_valid_file_referrer(&self, specifier: &ModuleSpecifier) -> bool {
- if let Ok(path) = specifier_to_file_path(specifier) {
+ if let Ok(path) = url_to_file_path(specifier) {
if !path.starts_with(&self.deno_dir().root) {
return true;
}
diff --git a/cli/lsp/completions.rs b/cli/lsp/completions.rs
index b3d6fbbd0..a040be569 100644
--- a/cli/lsp/completions.rs
+++ b/cli/lsp/completions.rs
@@ -29,7 +29,7 @@ use deno_core::serde::Serialize;
use deno_core::serde_json::json;
use deno_core::url::Position;
use deno_core::ModuleSpecifier;
-use deno_runtime::fs_util::specifier_to_file_path;
+use deno_path_util::url_to_file_path;
use deno_semver::jsr::JsrPackageReqReference;
use deno_semver::package::PackageNv;
use import_map::ImportMap;
@@ -380,7 +380,7 @@ fn get_local_completions(
ResolutionMode::Execution,
)
.ok()?;
- let resolved_parent_path = specifier_to_file_path(&resolved_parent).ok()?;
+ let resolved_parent_path = url_to_file_path(&resolved_parent).ok()?;
let raw_parent =
&text[..text.char_indices().rfind(|(_, c)| *c == '/')?.0 + 1];
if resolved_parent_path.is_dir() {
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs
index e55e7b734..dcb6120a4 100644
--- a/cli/lsp/config.rs
+++ b/cli/lsp/config.rs
@@ -36,8 +36,8 @@ use deno_core::ModuleSpecifier;
use deno_lint::linter::LintConfig as DenoLintConfig;
use deno_npm::npm_rc::ResolvedNpmRc;
use deno_package_json::PackageJsonCache;
+use deno_path_util::url_to_file_path;
use deno_runtime::deno_node::PackageJson;
-use deno_runtime::fs_util::specifier_to_file_path;
use indexmap::IndexSet;
use lsp_types::ClientCapabilities;
use std::collections::BTreeMap;
@@ -801,7 +801,7 @@ impl Settings {
/// Returns `None` if the value should be deferred to the presence of a
/// `deno.json` file.
pub fn specifier_enabled(&self, specifier: &ModuleSpecifier) -> Option<bool> {
- let Ok(path) = specifier_to_file_path(specifier) else {
+ let Ok(path) = url_to_file_path(specifier) else {
// Non-file URLs are not disabled by these settings.
return Some(true);
};
@@ -810,7 +810,7 @@ impl Settings {
let mut disable_paths = vec![];
let mut enable_paths = None;
if let Some(folder_uri) = folder_uri {
- if let Ok(folder_path) = specifier_to_file_path(folder_uri) {
+ if let Ok(folder_path) = url_to_file_path(folder_uri) {
disable_paths = settings
.disable_paths
.iter()
@@ -847,12 +847,12 @@ impl Settings {
&self,
specifier: &ModuleSpecifier,
) -> (&WorkspaceSettings, Option<&ModuleSpecifier>) {
- let Ok(path) = specifier_to_file_path(specifier) else {
+ let Ok(path) = url_to_file_path(specifier) else {
return (&self.unscoped, self.first_folder.as_ref());
};
for (folder_uri, settings) in self.by_workspace_folder.iter().rev() {
if let Some(settings) = settings {
- let Ok(folder_path) = specifier_to_file_path(folder_uri) else {
+ let Ok(folder_path) = url_to_file_path(folder_uri) else {
continue;
};
if path.starts_with(folder_path) {
@@ -1767,7 +1767,7 @@ impl ConfigTree {
let config_file_path = (|| {
let config_setting = ws_settings.config.as_ref()?;
let config_uri = folder_uri.join(config_setting).ok()?;
- specifier_to_file_path(&config_uri).ok()
+ url_to_file_path(&config_uri).ok()
})();
if config_file_path.is_some() || ws_settings.import_map.is_some() {
scopes.insert(
@@ -1844,7 +1844,7 @@ impl ConfigTree {
let scope = config_file.specifier.join(".").unwrap();
let json_text = serde_json::to_string(&config_file.json).unwrap();
let test_fs = deno_runtime::deno_fs::InMemoryFs::default();
- let config_path = specifier_to_file_path(&config_file.specifier).unwrap();
+ let config_path = url_to_file_path(&config_file.specifier).unwrap();
test_fs.setup_text_files(vec![(
config_path.to_string_lossy().to_string(),
json_text,
diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs
index e96b8831b..7d1ca6810 100644
--- a/cli/lsp/documents.rs
+++ b/cli/lsp/documents.rs
@@ -26,8 +26,8 @@ use deno_core::parking_lot::Mutex;
use deno_core::ModuleSpecifier;
use deno_graph::source::ResolutionMode;
use deno_graph::Resolution;
+use deno_path_util::url_to_file_path;
use deno_runtime::deno_node;
-use deno_runtime::fs_util::specifier_to_file_path;
use deno_semver::jsr::JsrPackageReqReference;
use deno_semver::npm::NpmPackageReqReference;
use deno_semver::package::PackageReq;
@@ -849,7 +849,7 @@ impl FileSystemDocuments {
file_referrer: Option<&ModuleSpecifier>,
) -> Option<Arc<Document>> {
let doc = if specifier.scheme() == "file" {
- let path = specifier_to_file_path(specifier).ok()?;
+ let path = url_to_file_path(specifier).ok()?;
let bytes = fs::read(path).ok()?;
let content =
deno_graph::source::decode_owned_source(specifier, bytes, None).ok()?;
@@ -1136,7 +1136,7 @@ impl Documents {
return true;
}
if specifier.scheme() == "file" {
- return specifier_to_file_path(&specifier)
+ return url_to_file_path(&specifier)
.map(|p| p.is_file())
.unwrap_or(false);
}
@@ -1325,7 +1325,7 @@ impl Documents {
let fs_docs = &self.file_system_docs;
// Clean up non-existent documents.
fs_docs.docs.retain(|specifier, _| {
- let Ok(path) = specifier_to_file_path(specifier) else {
+ let Ok(path) = url_to_file_path(specifier) else {
// Remove non-file schemed docs (deps). They may not be dependencies
// anymore after updating resolvers.
return false;
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 216b14de6..3fe969ba3 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -15,9 +15,9 @@ use deno_core::url::Url;
use deno_core::ModuleSpecifier;
use deno_graph::GraphKind;
use deno_graph::Resolution;
+use deno_path_util::url_to_file_path;
use deno_runtime::deno_tls::rustls::RootCertStore;
use deno_runtime::deno_tls::RootCertStoreProvider;
-use deno_runtime::fs_util::specifier_to_file_path;
use deno_semver::jsr::JsrPackageReqReference;
use indexmap::Equivalent;
use indexmap::IndexSet;
@@ -626,7 +626,7 @@ impl Inner {
let maybe_root_path = self
.config
.root_uri()
- .and_then(|uri| specifier_to_file_path(uri).ok());
+ .and_then(|uri| url_to_file_path(uri).ok());
let root_cert_store = get_root_cert_store(
maybe_root_path,
workspace_settings.certificate_stores.clone(),
@@ -802,7 +802,7 @@ impl Inner {
let mut roots = config
.workspace_folders
.iter()
- .filter_map(|p| specifier_to_file_path(&p.0).ok())
+ .filter_map(|p| url_to_file_path(&p.0).ok())
.collect::<Vec<_>>();
roots.sort();
let roots = roots
@@ -1124,7 +1124,7 @@ impl Inner {
{
return;
}
- match specifier_to_file_path(&specifier) {
+ match url_to_file_path(&specifier) {
Ok(path) if is_importable_ext(&path) => {}
_ => return,
}
@@ -1362,7 +1362,7 @@ impl Inner {
{
specifier = uri_to_url(&params.text_document.uri);
}
- let file_path = specifier_to_file_path(&specifier).map_err(|err| {
+ let file_path = url_to_file_path(&specifier).map_err(|err| {
error!("{:#}", err);
LspError::invalid_request()
})?;
@@ -2508,7 +2508,7 @@ impl Inner {
let maybe_root_path_owned = self
.config
.root_uri()
- .and_then(|uri| specifier_to_file_path(uri).ok());
+ .and_then(|uri| url_to_file_path(uri).ok());
let mut resolved_items = Vec::<CallHierarchyIncomingCall>::new();
for item in incoming_calls.iter() {
if let Some(resolved) = item.try_resolve_call_hierarchy_incoming_call(
@@ -2554,7 +2554,7 @@ impl Inner {
let maybe_root_path_owned = self
.config
.root_uri()
- .and_then(|uri| specifier_to_file_path(uri).ok());
+ .and_then(|uri| url_to_file_path(uri).ok());
let mut resolved_items = Vec::<CallHierarchyOutgoingCall>::new();
for item in outgoing_calls.iter() {
if let Some(resolved) = item.try_resolve_call_hierarchy_outgoing_call(
@@ -2603,7 +2603,7 @@ impl Inner {
let maybe_root_path_owned = self
.config
.root_uri()
- .and_then(|uri| specifier_to_file_path(uri).ok());
+ .and_then(|uri| url_to_file_path(uri).ok());
let mut resolved_items = Vec::<CallHierarchyItem>::new();
match one_or_many {
tsc::OneOrMany::One(item) => {
diff --git a/cli/lsp/resolver.rs b/cli/lsp/resolver.rs
index 2844eb6f9..f98b23a3f 100644
--- a/cli/lsp/resolver.rs
+++ b/cli/lsp/resolver.rs
@@ -10,10 +10,10 @@ use deno_graph::source::Resolver;
use deno_graph::GraphImport;
use deno_graph::ModuleSpecifier;
use deno_npm::NpmSystemInfo;
+use deno_path_util::url_to_file_path;
use deno_runtime::deno_fs;
use deno_runtime::deno_node::NodeResolver;
use deno_runtime::deno_node::PackageJson;
-use deno_runtime::fs_util::specifier_to_file_path;
use deno_semver::jsr::JsrPackageReqReference;
use deno_semver::npm::NpmPackageReqReference;
use deno_semver::package::PackageNv;
@@ -443,7 +443,7 @@ async fn create_npm_resolver(
fs: Arc::new(deno_fs::RealFs),
root_node_modules_dir: config_data.and_then(|config_data| {
config_data.node_modules_dir.clone().or_else(|| {
- specifier_to_file_path(&config_data.scope)
+ url_to_file_path(&config_data.scope)
.ok()
.map(|p| p.join("node_modules/"))
})
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index fe3708d3c..c8b5c47f8 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -62,7 +62,7 @@ use deno_core::ModuleSpecifier;
use deno_core::OpState;
use deno_core::PollEventLoopOptions;
use deno_core::RuntimeOptions;
-use deno_runtime::fs_util::specifier_to_file_path;
+use deno_path_util::url_to_file_path;
use deno_runtime::inspector_server::InspectorServer;
use deno_runtime::tokio_util::create_basic_runtime;
use indexmap::IndexMap;
@@ -3191,7 +3191,7 @@ impl CallHierarchyItem {
let use_file_name = self.is_source_file_item();
let maybe_file_path = if uri.scheme().is_some_and(|s| s.as_str() == "file")
{
- specifier_to_file_path(&uri_to_url(&uri)).ok()
+ url_to_file_path(&uri_to_url(&uri)).ok()
} else {
None
};