Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lsp): upgrade check on init and notification #21105

Merged
merged 12 commits into from
Nov 14, 2023
Merged
Prev Previous commit
Next Next commit
Revert ""deno.disableUpgradeCheck" workspace setting"
This reverts commit 2c4d55a.
  • Loading branch information
nayeemrmn committed Nov 7, 2023
commit 142467a505142ac3687ef7b16907aaddce30f2a4
9 changes: 0 additions & 9 deletions cli/lsp/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,6 @@ pub struct WorkspaceSettings {
#[serde(default = "default_document_preload_limit")]
pub document_preload_limit: usize,

#[serde(default)]
pub disable_upgrade_check: bool,

#[serde(default)]
pub suggest: DenoCompletionSettings,

Expand Down Expand Up @@ -507,7 +504,6 @@ impl Default for WorkspaceSettings {
internal_debug: false,
lint: true,
document_preload_limit: default_document_preload_limit(),
disable_upgrade_check: false,
suggest: Default::default(),
testing: Default::default(),
tls_certificate: None,
Expand Down Expand Up @@ -886,10 +882,6 @@ impl Config {
}
}

pub fn disabled_upgrade_check(&self) -> bool {
self.settings.unscoped.disable_upgrade_check
}

/// Determine if any inlay hints are enabled. This allows short circuiting
/// when there are no inlay hints enabled.
pub fn enabled_inlay_hints_for_specifier(
Expand Down Expand Up @@ -1354,7 +1346,6 @@ mod tests {
internal_debug: false,
lint: true,
document_preload_limit: 1_000,
disable_upgrade_check: false,
suggest: DenoCompletionSettings {
imports: ImportCompletionSettings {
auto_discover: true,
Expand Down
32 changes: 14 additions & 18 deletions cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3114,10 +3114,8 @@ impl tower_lsp::LanguageServer for LanguageServer {

async fn initialized(&self, _: InitializedParams) {
let mut registrations = Vec::with_capacity(2);
let disabled_upgrade_check;
let client = {
let mut ls = self.0.write().await;
disabled_upgrade_check = ls.config.disabled_upgrade_check();
if ls
.config
.client_capabilities
Expand Down Expand Up @@ -3190,23 +3188,21 @@ impl tower_lsp::LanguageServer for LanguageServer {

lsp_log!("Server ready.");

if !disabled_upgrade_check {
let http_client = self.0.read().await.http_client.clone();
match check_for_upgrades_for_lsp(http_client).await {
Ok(version_info) => {
client.send_did_upgrade_check_notification(
lsp_custom::DidUpgradeCheckNotificationParams {
upgrade_available: version_info.map(
|(latest_version, is_canary)| lsp_custom::UpgradeAvailable {
latest_version,
is_canary,
},
),
},
);
}
Err(err) => error!("Failed to check for upgrades: {err}"),
let http_client = self.0.read().await.http_client.clone();
match check_for_upgrades_for_lsp(http_client).await {
Ok(version_info) => {
client.send_did_upgrade_check_notification(
lsp_custom::DidUpgradeCheckNotificationParams {
upgrade_available: version_info.map(
|(latest_version, is_canary)| lsp_custom::UpgradeAvailable {
latest_version,
is_canary,
},
),
},
);
}
Err(err) => error!("Failed to check for upgrades: {err}"),
}
}

Expand Down
1 change: 0 additions & 1 deletion cli/lsp/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ pub fn get_repl_workspace_settings() -> WorkspaceSettings {
internal_debug: false,
lint: false,
document_preload_limit: 0, // don't pre-load any modules as it's expensive and not useful for the repl
disable_upgrade_check: false,
tls_certificate: None,
unsafely_ignore_certificate_errors: None,
unstable: false,
Expand Down
4 changes: 1 addition & 3 deletions cli/tests/integration/lsp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,6 @@ fn lsp_workspace_disable_enable_paths() {
"enable": false,
"disablePaths": ["./worker/node.ts"],
"enablePaths": ["./worker"],
"disableUpgradeCheck": true,
} }),
);

Expand Down Expand Up @@ -6410,8 +6409,7 @@ fn lsp_semantic_tokens_for_disabled_module() {
builder.set_deno_enable(false);
},
json!({ "deno": {
"enable": false,
"disableUpgradeCheck": true,
"enable": false
} }),
);
client.did_open(json!({
Expand Down
1 change: 0 additions & 1 deletion test_util/src/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,6 @@ impl LspClient {
"config": null,
"importMap": null,
"lint": true,
"disableUpgradeCheck": true,
"suggest": {
"autoImports": true,
"completeFunctionCalls": false,
Expand Down