mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
Merge branch 'main' into auto-config
This commit is contained in:
commit
38019a0f8c
2 changed files with 6 additions and 18 deletions
|
@ -79,7 +79,6 @@ pub(crate) struct StateSnapshot {
|
||||||
pub documents: Documents,
|
pub documents: Documents,
|
||||||
pub maybe_lint_config: Option<LintConfig>,
|
pub maybe_lint_config: Option<LintConfig>,
|
||||||
pub maybe_fmt_config: Option<FmtConfig>,
|
pub maybe_fmt_config: Option<FmtConfig>,
|
||||||
pub maybe_config_uri: Option<ModuleSpecifier>,
|
|
||||||
pub module_registries: registries::ModuleRegistry,
|
pub module_registries: registries::ModuleRegistry,
|
||||||
pub performance: Performance,
|
pub performance: Performance,
|
||||||
pub url_map: urls::LspUrlMap,
|
pub url_map: urls::LspUrlMap,
|
||||||
|
@ -114,9 +113,6 @@ pub(crate) struct Inner {
|
||||||
maybe_lint_config: Option<LintConfig>,
|
maybe_lint_config: Option<LintConfig>,
|
||||||
/// An optional configuration for formatter which has been taken from specified config file.
|
/// An optional configuration for formatter which has been taken from specified config file.
|
||||||
maybe_fmt_config: Option<FmtConfig>,
|
maybe_fmt_config: Option<FmtConfig>,
|
||||||
/// An optional URL which provides the location of a TypeScript configuration
|
|
||||||
/// file which will be used by the Deno LSP.
|
|
||||||
maybe_config_uri: Option<Url>,
|
|
||||||
/// An optional import map which is used to resolve modules.
|
/// An optional import map which is used to resolve modules.
|
||||||
pub(crate) maybe_import_map: Option<Arc<ImportMap>>,
|
pub(crate) maybe_import_map: Option<Arc<ImportMap>>,
|
||||||
/// The URL for the import map which is used to determine relative imports.
|
/// The URL for the import map which is used to determine relative imports.
|
||||||
|
@ -161,7 +157,6 @@ impl Inner {
|
||||||
maybe_fmt_config: None,
|
maybe_fmt_config: None,
|
||||||
maybe_cache_server: None,
|
maybe_cache_server: None,
|
||||||
maybe_config_file: None,
|
maybe_config_file: None,
|
||||||
maybe_config_uri: None,
|
|
||||||
maybe_import_map: None,
|
maybe_import_map: None,
|
||||||
maybe_import_map_uri: None,
|
maybe_import_map_uri: None,
|
||||||
module_registries,
|
module_registries,
|
||||||
|
@ -295,9 +290,7 @@ impl Inner {
|
||||||
// instead of returning URL in the tuple.
|
// instead of returning URL in the tuple.
|
||||||
/// Returns a tuple with parsed `ConfigFile` and `Url` pointing to that file.
|
/// Returns a tuple with parsed `ConfigFile` and `Url` pointing to that file.
|
||||||
/// If there's no config file specified in settings returns `None`.
|
/// If there's no config file specified in settings returns `None`.
|
||||||
fn get_config_file_and_url(
|
fn get_config_file(&self) -> Result<Option<ConfigFile>, AnyError> {
|
||||||
&self,
|
|
||||||
) -> Result<Option<(ConfigFile, Url)>, AnyError> {
|
|
||||||
let workspace_settings = self.config.get_workspace_settings();
|
let workspace_settings = self.config.get_workspace_settings();
|
||||||
let maybe_root_uri = self.config.root_uri.clone();
|
let maybe_root_uri = self.config.root_uri.clone();
|
||||||
let maybe_config = workspace_settings.config;
|
let maybe_config = workspace_settings.config;
|
||||||
|
@ -319,7 +312,7 @@ impl Inner {
|
||||||
lsp_log!(" Resolved configuration file: \"{}\"", config_url);
|
lsp_log!(" Resolved configuration file: \"{}\"", config_url);
|
||||||
|
|
||||||
let config_file = ConfigFile::from_specifier(&config_url)?;
|
let config_file = ConfigFile::from_specifier(&config_url)?;
|
||||||
return Ok(Some((config_file, config_url)));
|
return Ok(Some(config_file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +388,6 @@ impl Inner {
|
||||||
documents: self.documents.clone(),
|
documents: self.documents.clone(),
|
||||||
maybe_lint_config: self.maybe_lint_config.clone(),
|
maybe_lint_config: self.maybe_lint_config.clone(),
|
||||||
maybe_fmt_config: self.maybe_fmt_config.clone(),
|
maybe_fmt_config: self.maybe_fmt_config.clone(),
|
||||||
maybe_config_uri: self.maybe_config_uri.clone(),
|
|
||||||
module_registries: self.module_registries.clone(),
|
module_registries: self.module_registries.clone(),
|
||||||
performance: self.performance.clone(),
|
performance: self.performance.clone(),
|
||||||
url_map: self.url_map.clone(),
|
url_map: self.url_map.clone(),
|
||||||
|
@ -540,13 +532,10 @@ impl Inner {
|
||||||
|
|
||||||
fn update_config_file(&mut self) -> Result<(), AnyError> {
|
fn update_config_file(&mut self) -> Result<(), AnyError> {
|
||||||
self.maybe_config_file = None;
|
self.maybe_config_file = None;
|
||||||
self.maybe_config_uri = None;
|
|
||||||
self.maybe_fmt_config = None;
|
self.maybe_fmt_config = None;
|
||||||
self.maybe_lint_config = None;
|
self.maybe_lint_config = None;
|
||||||
|
|
||||||
let maybe_file_and_url = self.get_config_file_and_url()?;
|
if let Some(config_file) = self.get_config_file()? {
|
||||||
|
|
||||||
if let Some((config_file, config_url)) = maybe_file_and_url {
|
|
||||||
let lint_config = config_file
|
let lint_config = config_file
|
||||||
.to_lint_config()
|
.to_lint_config()
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
|
@ -561,7 +550,6 @@ impl Inner {
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
self.maybe_config_file = Some(config_file);
|
self.maybe_config_file = Some(config_file);
|
||||||
self.maybe_config_uri = Some(config_url);
|
|
||||||
self.maybe_lint_config = Some(lint_config);
|
self.maybe_lint_config = Some(lint_config);
|
||||||
self.maybe_fmt_config = Some(fmt_config);
|
self.maybe_fmt_config = Some(fmt_config);
|
||||||
}
|
}
|
||||||
|
@ -959,8 +947,8 @@ impl Inner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if the current tsconfig has changed, we need to reload it
|
// if the current tsconfig has changed, we need to reload it
|
||||||
if let Some(config_uri) = &self.maybe_config_uri {
|
if let Some(config_file) = &self.maybe_config_file {
|
||||||
if changes.iter().any(|uri| config_uri == uri) {
|
if changes.iter().any(|uri| config_file.specifier == *uri) {
|
||||||
if let Err(err) = self.update_config_file() {
|
if let Err(err) = self.update_config_file() {
|
||||||
self.client.show_message(MessageType::WARNING, err).await;
|
self.client.show_message(MessageType::WARNING, err).await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 233e6ffcd1af061e63a6bab810eb810f2bbae4bd
|
Subproject commit c342b5ca997c945ecb36487d7aa4932f0b9b0583
|
Loading…
Reference in a new issue