summaryrefslogtreecommitdiff
path: root/cli/lsp/language_server.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-11-28 17:28:54 -0500
committerGitHub <noreply@github.com>2022-11-28 17:28:54 -0500
commit2d4c46c975eb916dc622cc729a1a8d397582a76f (patch)
tree445e819117acd2f94ffc9d7da7ed8e3e604435d0 /cli/lsp/language_server.rs
parentf526513d74d34ac254aa40ef9b73238cb21c395b (diff)
refactor: create util folder, move nap_sym to napi/sym, move http_cache to cache folder (#16857)
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r--cli/lsp/language_server.rs41
1 files changed, 21 insertions, 20 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 081bbf429..11897af9d 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -57,6 +57,8 @@ use super::tsc::Assets;
use super::tsc::AssetsSnapshot;
use super::tsc::TsServer;
use super::urls;
+use crate::args::get_root_cert_store;
+use crate::args::CacheSetting;
use crate::args::CliOptions;
use crate::args::ConfigFile;
use crate::args::Flags;
@@ -64,10 +66,7 @@ use crate::args::FmtConfig;
use crate::args::LintConfig;
use crate::args::TsConfig;
use crate::cache::DenoDir;
-use crate::file_fetcher::get_root_cert_store;
use crate::file_fetcher::get_source_from_data_url;
-use crate::file_fetcher::CacheSetting;
-use crate::fs_util;
use crate::graph_util::graph_valid;
use crate::http_util::HttpClient;
use crate::npm::NpmCache;
@@ -75,9 +74,12 @@ use crate::npm::NpmPackageResolver;
use crate::npm::RealNpmRegistryApi;
use crate::proc_state::import_map_from_text;
use crate::proc_state::ProcState;
-use crate::progress_bar::ProgressBar;
use crate::tools::fmt::format_file;
use crate::tools::fmt::format_parsed_source;
+use crate::util::fs::remove_dir_all_if_exists;
+use crate::util::path::ensure_directory_specifier;
+use crate::util::path::specifier_to_file_path;
+use crate::util::progress_bar::ProgressBar;
#[derive(Debug, Clone)]
pub struct LanguageServer(Arc<tokio::sync::Mutex<Inner>>);
@@ -407,7 +409,7 @@ impl Inner {
// file open and not a workspace. In those situations we can't
// automatically discover the configuration
if let Some(root_uri) = &self.config.root_uri {
- let root_path = fs_util::specifier_to_file_path(root_uri)?;
+ let root_path = specifier_to_file_path(root_uri)?;
let mut checked = std::collections::HashSet::new();
let maybe_config = ConfigFile::discover_from(&root_path, &mut checked)?;
Ok(maybe_config.map(|c| {
@@ -481,7 +483,7 @@ impl Inner {
let cache_url = if let Ok(url) = Url::from_file_path(cache_str) {
Ok(url)
} else if let Some(root_uri) = &self.config.root_uri {
- let root_path = fs_util::specifier_to_file_path(root_uri)?;
+ let root_path = specifier_to_file_path(root_uri)?;
let cache_path = root_path.join(cache_str);
Url::from_file_path(cache_path).map_err(|_| {
anyhow!("Bad file path for import path: {:?}", cache_str)
@@ -492,7 +494,7 @@ impl Inner {
cache_str
))
}?;
- let cache_path = fs_util::specifier_to_file_path(&cache_url)?;
+ let cache_path = specifier_to_file_path(&cache_url)?;
lsp_log!(
" Resolved cache path: \"{}\"",
cache_path.to_string_lossy()
@@ -521,7 +523,7 @@ impl Inner {
.config
.root_uri
.as_ref()
- .and_then(|uri| fs_util::specifier_to_file_path(uri).ok());
+ .and_then(|uri| specifier_to_file_path(uri).ok());
let root_cert_store = Some(get_root_cert_store(
maybe_root_path,
workspace_settings.certificate_stores.clone(),
@@ -569,7 +571,7 @@ impl Inner {
anyhow!("Bad data url for import map: {}", import_map_str)
})?)
} else if let Some(root_uri) = &self.config.root_uri {
- let root_path = fs_util::specifier_to_file_path(root_uri)?;
+ let root_path = specifier_to_file_path(root_uri)?;
let import_map_path = root_path.join(&import_map_str);
Some(Url::from_file_path(import_map_path).map_err(|_| {
anyhow!("Bad file path for import map: {}", import_map_str)
@@ -612,7 +614,7 @@ impl Inner {
let import_map_json = if import_map_url.scheme() == "data" {
get_source_from_data_url(&import_map_url)?.0
} else {
- let import_map_path = fs_util::specifier_to_file_path(&import_map_url)?;
+ let import_map_path = specifier_to_file_path(&import_map_url)?;
lsp_log!(
" Resolved import map: \"{}\"",
import_map_path.to_string_lossy()
@@ -768,7 +770,7 @@ impl Inner {
self.config.root_uri = params
.root_uri
.map(|s| self.url_map.normalize_url(&s))
- .map(fs_util::ensure_directory_specifier);
+ .map(ensure_directory_specifier);
if let Some(value) = params.initialization_options {
self.config.set_workspace_settings(value).map_err(|err| {
@@ -1137,11 +1139,10 @@ impl Inner {
_ => return Ok(None),
};
let mark = self.performance.mark("formatting", Some(&params));
- let file_path =
- fs_util::specifier_to_file_path(&specifier).map_err(|err| {
- error!("{}", err);
- LspError::invalid_request()
- })?;
+ let file_path = specifier_to_file_path(&specifier).map_err(|err| {
+ error!("{}", err);
+ LspError::invalid_request()
+ })?;
let fmt_options = if let Some(fmt_config) = self.maybe_fmt_config.as_ref() {
// skip formatting any files ignored by the config file
@@ -2063,7 +2064,7 @@ impl Inner {
.config
.root_uri
.as_ref()
- .and_then(|uri| fs_util::specifier_to_file_path(uri).ok());
+ .and_then(|uri| specifier_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(
@@ -2109,7 +2110,7 @@ impl Inner {
.config
.root_uri
.as_ref()
- .and_then(|uri| fs_util::specifier_to_file_path(uri).ok());
+ .and_then(|uri| specifier_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(
@@ -2162,7 +2163,7 @@ impl Inner {
.config
.root_uri
.as_ref()
- .and_then(|uri| fs_util::specifier_to_file_path(uri).ok());
+ .and_then(|uri| specifier_to_file_path(uri).ok());
let mut resolved_items = Vec::<CallHierarchyItem>::new();
match one_or_many {
tsc::OneOrMany::One(item) => {
@@ -3010,7 +3011,7 @@ impl Inner {
}
async fn reload_import_registries(&mut self) -> LspResult<Option<Value>> {
- fs_util::remove_dir_all_if_exists(&self.module_registries_location)
+ remove_dir_all_if_exists(&self.module_registries_location)
.await
.map_err(|err| {
error!("Unable to remove registries cache: {}", err);