summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-01-23 06:12:41 +0000
committerGitHub <noreply@github.com>2024-01-23 06:12:41 +0000
commitec97c7dd4b5c1be83639769990ca6d37345089ca (patch)
tree809e7e4c4571ad8e4fe4359277d0e0923af334cf /cli
parent2af0c0a3c6ea017bef2481c1a1ce0806457d5427 (diff)
feat(lsp): include scope uri in "deno/didChangeDenoConfiguration" (#22002)
Diffstat (limited to 'cli')
-rw-r--r--cli/lsp/language_server.rs107
-rw-r--r--cli/lsp/lsp_custom.rs3
-rw-r--r--cli/tests/integration/lsp_tests.rs18
3 files changed, 74 insertions, 54 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 8355b4fe2..87b33b5cb 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -1630,19 +1630,23 @@ impl Inner {
{
files_to_check.insert(url.clone());
}
- config_changes.extend(
- params
- .changes
- .iter()
- .filter(|e| files_to_check.contains(&e.uri))
- .map(|e| lsp_custom::DenoConfigurationChangeEvent {
- uri: e.uri.clone(),
- typ: lsp_custom::DenoConfigurationChangeType::from_file_change_type(
- e.typ,
- ),
- configuration_type: lsp_custom::DenoConfigurationType::DenoJson,
- }),
- );
+ if let Some(root_uri) = self.config.root_uri() {
+ config_changes.extend(
+ params
+ .changes
+ .iter()
+ .filter(|e| files_to_check.contains(&e.uri))
+ .map(|e| lsp_custom::DenoConfigurationChangeEvent {
+ scope_uri: root_uri.clone(),
+ file_uri: e.uri.clone(),
+ typ:
+ lsp_custom::DenoConfigurationChangeType::from_file_change_type(
+ e.typ,
+ ),
+ configuration_type: lsp_custom::DenoConfigurationType::DenoJson,
+ }),
+ );
+ }
if let Err(err) = self.update_tsconfig().await {
self.client.show_message(MessageType::WARNING, err);
}
@@ -1664,19 +1668,24 @@ impl Inner {
if let Some(package_json) = &self.maybe_package_json {
files_to_check.insert(package_json.specifier());
}
- config_changes.extend(
- params
- .changes
- .iter()
- .filter(|e| files_to_check.contains(&e.uri))
- .map(|e| lsp_custom::DenoConfigurationChangeEvent {
- uri: e.uri.clone(),
- typ: lsp_custom::DenoConfigurationChangeType::from_file_change_type(
- e.typ,
- ),
- configuration_type: lsp_custom::DenoConfigurationType::PackageJson,
- }),
- );
+ if let Some(root_uri) = self.config.root_uri() {
+ config_changes.extend(
+ params
+ .changes
+ .iter()
+ .filter(|e| files_to_check.contains(&e.uri))
+ .map(|e| lsp_custom::DenoConfigurationChangeEvent {
+ scope_uri: root_uri.clone(),
+ file_uri: e.uri.clone(),
+ typ:
+ lsp_custom::DenoConfigurationChangeType::from_file_change_type(
+ e.typ,
+ ),
+ configuration_type:
+ lsp_custom::DenoConfigurationType::PackageJson,
+ }),
+ );
+ }
touched = true;
}
@@ -3317,27 +3326,31 @@ impl tower_lsp::LanguageServer for LanguageServer {
ls.maybe_testing_server = Some(test_server);
}
- let mut config_events = vec![];
- if let Some(config_file) = ls.config.maybe_config_file() {
- config_events.push(lsp_custom::DenoConfigurationChangeEvent {
- uri: config_file.specifier.clone(),
- typ: lsp_custom::DenoConfigurationChangeType::Added,
- configuration_type: lsp_custom::DenoConfigurationType::DenoJson,
- });
- }
- if let Some(package_json) = &ls.maybe_package_json {
- config_events.push(lsp_custom::DenoConfigurationChangeEvent {
- uri: package_json.specifier(),
- typ: lsp_custom::DenoConfigurationChangeType::Added,
- configuration_type: lsp_custom::DenoConfigurationType::PackageJson,
- });
- }
- if !config_events.is_empty() {
- ls.client.send_did_change_deno_configuration_notification(
- lsp_custom::DidChangeDenoConfigurationNotificationParams {
- changes: config_events,
- },
- );
+ if let Some(root_uri) = ls.config.root_uri() {
+ let mut config_events = vec![];
+ if let Some(config_file) = ls.config.maybe_config_file() {
+ config_events.push(lsp_custom::DenoConfigurationChangeEvent {
+ scope_uri: root_uri.clone(),
+ file_uri: config_file.specifier.clone(),
+ typ: lsp_custom::DenoConfigurationChangeType::Added,
+ configuration_type: lsp_custom::DenoConfigurationType::DenoJson,
+ });
+ }
+ if let Some(package_json) = &ls.maybe_package_json {
+ config_events.push(lsp_custom::DenoConfigurationChangeEvent {
+ scope_uri: root_uri.clone(),
+ file_uri: package_json.specifier(),
+ typ: lsp_custom::DenoConfigurationChangeType::Added,
+ configuration_type: lsp_custom::DenoConfigurationType::PackageJson,
+ });
+ }
+ if !config_events.is_empty() {
+ ls.client.send_did_change_deno_configuration_notification(
+ lsp_custom::DidChangeDenoConfigurationNotificationParams {
+ changes: config_events,
+ },
+ );
+ }
}
(ls.client.clone(), ls.http_client.clone())
diff --git a/cli/lsp/lsp_custom.rs b/cli/lsp/lsp_custom.rs
index 63f50d39f..a1fe392f1 100644
--- a/cli/lsp/lsp_custom.rs
+++ b/cli/lsp/lsp_custom.rs
@@ -89,7 +89,8 @@ pub enum DenoConfigurationType {
#[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DenoConfigurationChangeEvent {
- pub uri: lsp::Url,
+ pub scope_uri: lsp::Url,
+ pub file_uri: lsp::Url,
#[serde(rename = "type")]
pub typ: DenoConfigurationChangeType,
pub configuration_type: DenoConfigurationType,
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index ba44c670d..3ea6d2ab5 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -856,7 +856,8 @@ fn lsp_did_change_deno_configuration_notification() {
res,
Some(json!({
"changes": [{
- "uri": temp_dir.uri().join("deno.json").unwrap(),
+ "scopeUri": temp_dir.uri(),
+ "fileUri": temp_dir.uri().join("deno.json").unwrap(),
"type": "added",
"configurationType": "denoJson"
}],
@@ -879,7 +880,8 @@ fn lsp_did_change_deno_configuration_notification() {
res,
Some(json!({
"changes": [{
- "uri": temp_dir.uri().join("deno.json").unwrap(),
+ "scopeUri": temp_dir.uri(),
+ "fileUri": temp_dir.uri().join("deno.json").unwrap(),
"type": "changed",
"configurationType": "denoJson"
}],
@@ -899,7 +901,8 @@ fn lsp_did_change_deno_configuration_notification() {
res,
Some(json!({
"changes": [{
- "uri": temp_dir.uri().join("deno.json").unwrap(),
+ "scopeUri": temp_dir.uri(),
+ "fileUri": temp_dir.uri().join("deno.json").unwrap(),
"type": "removed",
"configurationType": "denoJson"
}],
@@ -919,7 +922,8 @@ fn lsp_did_change_deno_configuration_notification() {
res,
Some(json!({
"changes": [{
- "uri": temp_dir.uri().join("package.json").unwrap(),
+ "scopeUri": temp_dir.uri(),
+ "fileUri": temp_dir.uri().join("package.json").unwrap(),
"type": "added",
"configurationType": "packageJson"
}],
@@ -939,7 +943,8 @@ fn lsp_did_change_deno_configuration_notification() {
res,
Some(json!({
"changes": [{
- "uri": temp_dir.uri().join("package.json").unwrap(),
+ "scopeUri": temp_dir.uri(),
+ "fileUri": temp_dir.uri().join("package.json").unwrap(),
"type": "changed",
"configurationType": "packageJson"
}],
@@ -959,7 +964,8 @@ fn lsp_did_change_deno_configuration_notification() {
res,
Some(json!({
"changes": [{
- "uri": temp_dir.uri().join("package.json").unwrap(),
+ "scopeUri": temp_dir.uri(),
+ "fileUri": temp_dir.uri().join("package.json").unwrap(),
"type": "removed",
"configurationType": "packageJson"
}],