Skip to content

Commit 1fd8d09

Browse files
authoredOct 16, 2024··
Revert "feat(lsp): "deno/didRefreshDenoConfigurationTree" notificatio… (#26320)
…ns (#26215)" This reverts commit 06778e4 because benchmarks are failing on `main`.
1 parent f7dba52 commit 1fd8d09

File tree

6 files changed

+13
-304
lines changed

6 files changed

+13
-304
lines changed
 

‎cli/lsp/capabilities.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ pub fn server_capabilities(
147147
moniker_provider: None,
148148
experimental: Some(json!({
149149
"denoConfigTasks": true,
150-
"testingApi": true,
151-
"didRefreshDenoConfigurationTreeNotifications": true,
150+
"testingApi":true,
152151
})),
153152
inlay_hint_provider: Some(OneOf::Left(true)),
154153
position_encoding: None,
154+
// TODO(nayeemrmn): Support pull-based diagnostics.
155155
diagnostic_provider: None,
156156
inline_value_provider: None,
157157
inline_completion_provider: None,

‎cli/lsp/client.rs

-35
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,6 @@ impl Client {
9292
});
9393
}
9494

95-
pub fn send_did_refresh_deno_configuration_tree_notification(
96-
&self,
97-
params: lsp_custom::DidRefreshDenoConfigurationTreeNotificationParams,
98-
) {
99-
// do on a task in case the caller currently is in the lsp lock
100-
let client = self.0.clone();
101-
spawn(async move {
102-
client
103-
.send_did_refresh_deno_configuration_tree_notification(params)
104-
.await;
105-
});
106-
}
107-
10895
pub fn send_did_change_deno_configuration_notification(
10996
&self,
11097
params: lsp_custom::DidChangeDenoConfigurationNotificationParams,
@@ -182,10 +169,6 @@ trait ClientTrait: Send + Sync {
182169
params: lsp_custom::DiagnosticBatchNotificationParams,
183170
);
184171
async fn send_test_notification(&self, params: TestingNotification);
185-
async fn send_did_refresh_deno_configuration_tree_notification(
186-
&self,
187-
params: lsp_custom::DidRefreshDenoConfigurationTreeNotificationParams,
188-
);
189172
async fn send_did_change_deno_configuration_notification(
190173
&self,
191174
params: lsp_custom::DidChangeDenoConfigurationNotificationParams,
@@ -266,18 +249,6 @@ impl ClientTrait for TowerClient {
266249
}
267250
}
268251

269-
async fn send_did_refresh_deno_configuration_tree_notification(
270-
&self,
271-
params: lsp_custom::DidRefreshDenoConfigurationTreeNotificationParams,
272-
) {
273-
self
274-
.0
275-
.send_notification::<lsp_custom::DidRefreshDenoConfigurationTreeNotification>(
276-
params,
277-
)
278-
.await
279-
}
280-
281252
async fn send_did_change_deno_configuration_notification(
282253
&self,
283254
params: lsp_custom::DidChangeDenoConfigurationNotificationParams,
@@ -395,12 +366,6 @@ impl ClientTrait for ReplClient {
395366

396367
async fn send_test_notification(&self, _params: TestingNotification) {}
397368

398-
async fn send_did_refresh_deno_configuration_tree_notification(
399-
&self,
400-
_params: lsp_custom::DidRefreshDenoConfigurationTreeNotificationParams,
401-
) {
402-
}
403-
404369
async fn send_did_change_deno_configuration_notification(
405370
&self,
406371
_params: lsp_custom::DidChangeDenoConfigurationNotificationParams,

‎cli/lsp/config.rs

+3-45
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ use std::sync::Arc;
5050
use tower_lsp::lsp_types as lsp;
5151

5252
use super::logging::lsp_log;
53-
use super::lsp_custom;
54-
use super::urls::url_to_uri;
5553
use crate::args::discover_npmrc_from_workspace;
5654
use crate::args::has_flag_env_var;
5755
use crate::args::CliLockfile;
@@ -1718,14 +1716,14 @@ impl ConfigTree {
17181716
.unwrap_or_else(|| Arc::new(FmtConfig::new_with_base(PathBuf::from("/"))))
17191717
}
17201718

1721-
/// Returns (scope_url, type).
1719+
/// Returns (scope_uri, type).
17221720
pub fn watched_file_type(
17231721
&self,
17241722
specifier: &ModuleSpecifier,
17251723
) -> Option<(&ModuleSpecifier, ConfigWatchedFileType)> {
1726-
for (scope_url, data) in self.scopes.iter() {
1724+
for (scope_uri, data) in self.scopes.iter() {
17271725
if let Some(typ) = data.watched_files.get(specifier) {
1728-
return Some((scope_url, *typ));
1726+
return Some((scope_uri, *typ));
17291727
}
17301728
}
17311729
None
@@ -1749,46 +1747,6 @@ impl ConfigTree {
17491747
.any(|data| data.watched_files.contains_key(specifier))
17501748
}
17511749

1752-
pub fn to_did_refresh_params(
1753-
&self,
1754-
) -> lsp_custom::DidRefreshDenoConfigurationTreeNotificationParams {
1755-
let data = self
1756-
.scopes
1757-
.values()
1758-
.filter_map(|data| {
1759-
let workspace_root_scope_uri =
1760-
Some(data.member_dir.workspace.root_dir())
1761-
.filter(|s| *s != data.member_dir.dir_url())
1762-
.and_then(|s| url_to_uri(s).ok());
1763-
Some(lsp_custom::DenoConfigurationData {
1764-
scope_uri: url_to_uri(&data.scope).ok()?,
1765-
deno_json: data.maybe_deno_json().and_then(|c| {
1766-
if workspace_root_scope_uri.is_some()
1767-
&& Some(&c.specifier)
1768-
== data
1769-
.member_dir
1770-
.workspace
1771-
.root_deno_json()
1772-
.map(|c| &c.specifier)
1773-
{
1774-
return None;
1775-
}
1776-
Some(lsp::TextDocumentIdentifier {
1777-
uri: url_to_uri(&c.specifier).ok()?,
1778-
})
1779-
}),
1780-
package_json: data.maybe_pkg_json().and_then(|p| {
1781-
Some(lsp::TextDocumentIdentifier {
1782-
uri: url_to_uri(&p.specifier()).ok()?,
1783-
})
1784-
}),
1785-
workspace_root_scope_uri,
1786-
})
1787-
})
1788-
.collect();
1789-
lsp_custom::DidRefreshDenoConfigurationTreeNotificationParams { data }
1790-
}
1791-
17921750
pub async fn refresh(
17931751
&mut self,
17941752
settings: &Settings,

‎cli/lsp/language_server.rs

-5
Original file line numberDiff line numberDiff line change
@@ -963,11 +963,6 @@ impl Inner {
963963
.tree
964964
.refresh(&self.config.settings, &self.workspace_files, &file_fetcher)
965965
.await;
966-
self
967-
.client
968-
.send_did_refresh_deno_configuration_tree_notification(
969-
self.config.tree.to_did_refresh_params(),
970-
);
971966
for config_file in self.config.tree.config_files() {
972967
(|| {
973968
let compiler_options = config_file.to_compiler_options().ok()?.options;

‎cli/lsp/lsp_custom.rs

+3-27
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,6 @@ pub struct DiagnosticBatchNotificationParams {
4646
pub messages_len: usize,
4747
}
4848

49-
#[derive(Debug, Deserialize, Serialize)]
50-
#[serde(rename_all = "camelCase")]
51-
pub struct DenoConfigurationData {
52-
pub scope_uri: lsp::Uri,
53-
pub workspace_root_scope_uri: Option<lsp::Uri>,
54-
pub deno_json: Option<lsp::TextDocumentIdentifier>,
55-
pub package_json: Option<lsp::TextDocumentIdentifier>,
56-
}
57-
58-
#[derive(Debug, Deserialize, Serialize)]
59-
#[serde(rename_all = "camelCase")]
60-
pub struct DidRefreshDenoConfigurationTreeNotificationParams {
61-
pub data: Vec<DenoConfigurationData>,
62-
}
63-
64-
pub enum DidRefreshDenoConfigurationTreeNotification {}
65-
66-
impl lsp::notification::Notification
67-
for DidRefreshDenoConfigurationTreeNotification
68-
{
69-
type Params = DidRefreshDenoConfigurationTreeNotificationParams;
70-
const METHOD: &'static str = "deno/didRefreshDenoConfigurationTree";
71-
}
72-
7349
#[derive(Debug, Eq, Hash, PartialEq, Copy, Clone, Deserialize, Serialize)]
7450
#[serde(rename_all = "camelCase")]
7551
pub enum DenoConfigurationChangeType {
@@ -112,22 +88,21 @@ pub struct DidChangeDenoConfigurationNotificationParams {
11288
pub changes: Vec<DenoConfigurationChangeEvent>,
11389
}
11490

115-
// TODO(nayeemrmn): This is being replaced by
116-
// `DidRefreshDenoConfigurationTreeNotification` for Deno > v2.0.0. Remove it
117-
// soon.
11891
pub enum DidChangeDenoConfigurationNotification {}
11992

12093
impl lsp::notification::Notification
12194
for DidChangeDenoConfigurationNotification
12295
{
12396
type Params = DidChangeDenoConfigurationNotificationParams;
97+
12498
const METHOD: &'static str = "deno/didChangeDenoConfiguration";
12599
}
126100

127101
pub enum DidUpgradeCheckNotification {}
128102

129103
impl lsp::notification::Notification for DidUpgradeCheckNotification {
130104
type Params = DidUpgradeCheckNotificationParams;
105+
131106
const METHOD: &'static str = "deno/didUpgradeCheck";
132107
}
133108

@@ -150,5 +125,6 @@ pub enum DiagnosticBatchNotification {}
150125

151126
impl lsp::notification::Notification for DiagnosticBatchNotification {
152127
type Params = DiagnosticBatchNotificationParams;
128+
153129
const METHOD: &'static str = "deno/internalTestDiagnosticBatch";
154130
}

‎tests/integration/lsp_tests.rs

+5-190
Original file line numberDiff line numberDiff line change
@@ -1049,191 +1049,6 @@ fn lsp_workspace_enable_paths_no_workspace_configuration() {
10491049
client.shutdown();
10501050
}
10511051

1052-
#[test]
1053-
fn lsp_did_refresh_deno_configuration_tree_notification() {
1054-
let context = TestContextBuilder::new().use_temp_cwd().build();
1055-
let temp_dir = context.temp_dir();
1056-
temp_dir.create_dir_all("workspace/member1");
1057-
temp_dir.create_dir_all("workspace/member2");
1058-
temp_dir.create_dir_all("non_workspace1");
1059-
temp_dir.create_dir_all("non_workspace2");
1060-
temp_dir.write(
1061-
"workspace/deno.json",
1062-
json!({
1063-
"workspace": [
1064-
"member1",
1065-
"member2",
1066-
],
1067-
})
1068-
.to_string(),
1069-
);
1070-
temp_dir.write("workspace/member1/deno.json", json!({}).to_string());
1071-
temp_dir.write("workspace/member1/package.json", json!({}).to_string());
1072-
temp_dir.write("workspace/member2/package.json", json!({}).to_string());
1073-
temp_dir.write("non_workspace1/deno.json", json!({}).to_string());
1074-
let mut client = context.new_lsp_command().build();
1075-
client.initialize_default();
1076-
let res = client
1077-
.read_notification_with_method::<Value>(
1078-
"deno/didRefreshDenoConfigurationTree",
1079-
)
1080-
.unwrap();
1081-
assert_eq!(
1082-
res,
1083-
json!({
1084-
"data": [
1085-
{
1086-
"scopeUri": temp_dir.url().join("non_workspace1/").unwrap(),
1087-
"workspaceRootScopeUri": null,
1088-
"denoJson": {
1089-
"uri": temp_dir.url().join("non_workspace1/deno.json").unwrap(),
1090-
},
1091-
"packageJson": null,
1092-
},
1093-
{
1094-
"scopeUri": temp_dir.url().join("workspace/").unwrap(),
1095-
"workspaceRootScopeUri": null,
1096-
"denoJson": {
1097-
"uri": temp_dir.url().join("workspace/deno.json").unwrap(),
1098-
},
1099-
"packageJson": null,
1100-
},
1101-
{
1102-
"scopeUri": temp_dir.url().join("workspace/member1/").unwrap(),
1103-
"workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
1104-
"denoJson": {
1105-
"uri": temp_dir.url().join("workspace/member1/deno.json").unwrap(),
1106-
},
1107-
"packageJson": {
1108-
"uri": temp_dir.url().join("workspace/member1/package.json").unwrap(),
1109-
},
1110-
},
1111-
{
1112-
"scopeUri": temp_dir.url().join("workspace/member2/").unwrap(),
1113-
"workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
1114-
"denoJson": null,
1115-
"packageJson": {
1116-
"uri": temp_dir.url().join("workspace/member2/package.json").unwrap(),
1117-
},
1118-
},
1119-
],
1120-
}),
1121-
);
1122-
temp_dir.write("non_workspace2/deno.json", json!({}).to_string());
1123-
client.did_change_watched_files(json!({
1124-
"changes": [{
1125-
"uri": temp_dir.url().join("non_workspace2/deno.json").unwrap(),
1126-
"type": 1,
1127-
}],
1128-
}));
1129-
let res = client
1130-
.read_notification_with_method::<Value>(
1131-
"deno/didRefreshDenoConfigurationTree",
1132-
)
1133-
.unwrap();
1134-
assert_eq!(
1135-
res,
1136-
json!({
1137-
"data": [
1138-
{
1139-
"scopeUri": temp_dir.url().join("non_workspace1/").unwrap(),
1140-
"workspaceRootScopeUri": null,
1141-
"denoJson": {
1142-
"uri": temp_dir.url().join("non_workspace1/deno.json").unwrap(),
1143-
},
1144-
"packageJson": null,
1145-
},
1146-
{
1147-
"scopeUri": temp_dir.url().join("non_workspace2/").unwrap(),
1148-
"workspaceRootScopeUri": null,
1149-
"denoJson": {
1150-
"uri": temp_dir.url().join("non_workspace2/deno.json").unwrap(),
1151-
},
1152-
"packageJson": null,
1153-
},
1154-
{
1155-
"scopeUri": temp_dir.url().join("workspace/").unwrap(),
1156-
"workspaceRootScopeUri": null,
1157-
"denoJson": {
1158-
"uri": temp_dir.url().join("workspace/deno.json").unwrap(),
1159-
},
1160-
"packageJson": null,
1161-
},
1162-
{
1163-
"scopeUri": temp_dir.url().join("workspace/member1/").unwrap(),
1164-
"workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
1165-
"denoJson": {
1166-
"uri": temp_dir.url().join("workspace/member1/deno.json").unwrap(),
1167-
},
1168-
"packageJson": {
1169-
"uri": temp_dir.url().join("workspace/member1/package.json").unwrap(),
1170-
},
1171-
},
1172-
{
1173-
"scopeUri": temp_dir.url().join("workspace/member2/").unwrap(),
1174-
"workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
1175-
"denoJson": null,
1176-
"packageJson": {
1177-
"uri": temp_dir.url().join("workspace/member2/package.json").unwrap(),
1178-
},
1179-
},
1180-
],
1181-
}),
1182-
);
1183-
client.change_configuration(json!({
1184-
"deno": {
1185-
"disablePaths": ["non_workspace1"],
1186-
},
1187-
}));
1188-
let res = client
1189-
.read_notification_with_method::<Value>(
1190-
"deno/didRefreshDenoConfigurationTree",
1191-
)
1192-
.unwrap();
1193-
assert_eq!(
1194-
res,
1195-
json!({
1196-
"data": [
1197-
{
1198-
"scopeUri": temp_dir.url().join("non_workspace2/").unwrap(),
1199-
"workspaceRootScopeUri": null,
1200-
"denoJson": {
1201-
"uri": temp_dir.url().join("non_workspace2/deno.json").unwrap(),
1202-
},
1203-
"packageJson": null,
1204-
},
1205-
{
1206-
"scopeUri": temp_dir.url().join("workspace/").unwrap(),
1207-
"workspaceRootScopeUri": null,
1208-
"denoJson": {
1209-
"uri": temp_dir.url().join("workspace/deno.json").unwrap(),
1210-
},
1211-
"packageJson": null,
1212-
},
1213-
{
1214-
"scopeUri": temp_dir.url().join("workspace/member1/").unwrap(),
1215-
"workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
1216-
"denoJson": {
1217-
"uri": temp_dir.url().join("workspace/member1/deno.json").unwrap(),
1218-
},
1219-
"packageJson": {
1220-
"uri": temp_dir.url().join("workspace/member1/package.json").unwrap(),
1221-
},
1222-
},
1223-
{
1224-
"scopeUri": temp_dir.url().join("workspace/member2/").unwrap(),
1225-
"workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
1226-
"denoJson": null,
1227-
"packageJson": {
1228-
"uri": temp_dir.url().join("workspace/member2/package.json").unwrap(),
1229-
},
1230-
},
1231-
],
1232-
}),
1233-
);
1234-
client.shutdown();
1235-
}
1236-
12371052
#[test]
12381053
fn lsp_did_change_deno_configuration_notification() {
12391054
let context = TestContextBuilder::new().use_temp_cwd().build();
@@ -9588,15 +9403,14 @@ fn lsp_auto_discover_registry() {
95889403
"triggerCharacter": "@"
95899404
}),
95909405
);
9591-
let res = client
9592-
.read_notification_with_method::<Value>("deno/registryState")
9593-
.unwrap();
9406+
let (method, res) = client.read_notification();
9407+
assert_eq!(method, "deno/registryState");
95949408
assert_eq!(
95959409
res,
9596-
json!({
9410+
Some(json!({
95979411
"origin": "http://localhost:4545",
95989412
"suggestions": true,
9599-
}),
9413+
}))
96009414
);
96019415
client.shutdown();
96029416
}
@@ -10303,6 +10117,7 @@ fn lsp_diagnostics_refresh_dependents() {
1030310117
assert_eq!(json!(diagnostics.all()), json!([])); // no diagnostics now
1030410118

1030510119
client.shutdown();
10120+
assert_eq!(client.queue_len(), 0);
1030610121
}
1030710122

1030810123
// Regression test for https://github.com/denoland/deno/issues/10897.

0 commit comments

Comments
 (0)
Please sign in to comment.