From 8150cae6f3f6dad22a1fdefb4f617b639660fcdd Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Sat, 5 Jul 2025 18:34:16 -0400 Subject: [PATCH] clean up --- crates/dap_adapters/Cargo.toml | 2 -- crates/dap_adapters/src/codelldb.rs | 2 +- crates/dap_adapters/src/dap_adapters.rs | 38 ++++++++++++++----------- crates/dap_adapters/src/go.rs | 2 +- crates/dap_adapters/src/javascript.rs | 3 +- crates/dap_adapters/src/python.rs | 2 ++ crates/task/src/debug_format.rs | 31 -------------------- 7 files changed, 27 insertions(+), 53 deletions(-) diff --git a/crates/dap_adapters/Cargo.toml b/crates/dap_adapters/Cargo.toml index 6a438643ca5bcea664c692148fd431b10152b786..3be6deffe973d2a01511c8132563d5840eb42037 100644 --- a/crates/dap_adapters/Cargo.toml +++ b/crates/dap_adapters/Cargo.toml @@ -6,8 +6,6 @@ publish.workspace = true license = "GPL-3.0-or-later" [features] -# FIXME -default = ["update-schemas"] test-support = [ "dap/test-support", "gpui/test-support", diff --git a/crates/dap_adapters/src/codelldb.rs b/crates/dap_adapters/src/codelldb.rs index 5696844e3098f107250c1851b8802c45e842f759..f5b9f3352990f5b3b534b57882d5400438c8e520 100644 --- a/crates/dap_adapters/src/codelldb.rs +++ b/crates/dap_adapters/src/codelldb.rs @@ -90,7 +90,7 @@ impl CodeLldbDebugAdapter { #[cfg(feature = "update-schemas")] impl CodeLldbDebugAdapter { pub fn get_schema( - temp_dir: &TempDir, + temp_dir: &tempfile::TempDir, delegate: UpdateSchemasDapDelegate, ) -> anyhow::Result { let (package_json, package_nls_json) = get_vsix_package_json( diff --git a/crates/dap_adapters/src/dap_adapters.rs b/crates/dap_adapters/src/dap_adapters.rs index 1fb9c7af572ad2346b99ce8308a6a7e2cc8849fd..fa5e6aadb1decd221b0595d6a667d9f92645cb40 100644 --- a/crates/dap_adapters/src/dap_adapters.rs +++ b/crates/dap_adapters/src/dap_adapters.rs @@ -7,29 +7,25 @@ mod python; use std::sync::Arc; -use anyhow::{Context as _, Result}; +use anyhow::Result; use async_trait::async_trait; pub use codelldb::CodeLldbDebugAdapter; -use collections::HashMap; use dap::{ DapRegistry, adapters::{ self, AdapterVersion, DapDelegate, DebugAdapter, DebugAdapterBinary, DebugAdapterName, - DownloadedFileType, GithubRepo, + GithubRepo, }, configure_tcp_connection, }; -use fs::Fs as _; use gdb::GdbDebugAdapter; pub use go::GoDebugAdapter; -use gpui::{App, BorrowAppContext, http_client::github::GithubRelease}; +use gpui::{App, BorrowAppContext}; pub use javascript::JsDebugAdapter; use php::PhpDebugAdapter; pub use python::PythonDebugAdapter; -use serde::{Deserialize, Serialize}; use serde_json::json; -use task::{DebugScenario, EnvVariableReplacer, VariableName, ZedDebugConfig}; -use tempfile::TempDir; +use task::{DebugScenario, ZedDebugConfig}; pub fn init(cx: &mut App) { cx.update_default_global(|registry: &mut DapRegistry, _cx| { @@ -59,8 +55,8 @@ pub struct UpdateSchemasDapDelegate { impl UpdateSchemasDapDelegate { pub fn new() -> Self { let executor = gpui::background_executor(); - // FIXME - let client = Arc::new(reqwest_client::ReqwestClient::user_agent("Cole").unwrap()); + let client = + Arc::new(reqwest_client::ReqwestClient::user_agent("Zed DAP schema updater").unwrap()); let fs = Arc::new(fs::RealFs::new(None, executor.clone())); Self { client, @@ -106,7 +102,7 @@ impl dap::adapters::DapDelegate for UpdateSchemasDapDelegate { } #[cfg(feature = "update-schemas")] -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, serde::Serialize, serde::Deserialize)] struct PackageJsonConfigurationAttributes { #[serde(default, skip_serializing_if = "Option::is_none")] launch: Option, @@ -115,7 +111,7 @@ struct PackageJsonConfigurationAttributes { } #[cfg(feature = "update-schemas")] -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] struct PackageJsonDebugger { r#type: String, @@ -123,23 +119,28 @@ struct PackageJsonDebugger { } #[cfg(feature = "update-schemas")] -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, serde::Serialize, serde::Deserialize)] struct PackageJsonContributes { debuggers: Vec, } #[cfg(feature = "update-schemas")] -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, serde::Serialize, serde::Deserialize)] struct PackageJson { contributes: PackageJsonContributes, } +#[cfg(feature = "update-schemas")] fn get_vsix_package_json( - temp_dir: &TempDir, + temp_dir: &tempfile::TempDir, repo: &str, - asset_name: impl FnOnce(&GithubRelease) -> anyhow::Result, + asset_name: impl FnOnce(&gpui::http_client::github::GithubRelease) -> anyhow::Result, delegate: UpdateSchemasDapDelegate, ) -> anyhow::Result<(String, Option)> { + use anyhow::Context as _; + use dap::adapters::DownloadedFileType; + use fs::Fs as _; + let temp_dir = std::fs::canonicalize(temp_dir.path())?; let fs = delegate.fs.clone(); let client = delegate.client.clone(); @@ -179,10 +180,14 @@ fn get_vsix_package_json( }) } +#[cfg(feature = "update-schemas")] fn parse_package_json( package_json: String, package_nls_json: Option, ) -> anyhow::Result { + use collections::HashMap; + use task::{EnvVariableReplacer, VariableName}; + let package_nls_json = package_nls_json .map(|package_nls_json| { let package_nls_json = @@ -244,6 +249,7 @@ fn parse_package_json( Ok(package_json) } +#[cfg(feature = "update-schemas")] fn schema_for_configuration_attributes( attrs: PackageJsonConfigurationAttributes, ) -> serde_json::Value { diff --git a/crates/dap_adapters/src/go.rs b/crates/dap_adapters/src/go.rs index 39fc4711fd3b5fd5a645243326534eae257cd863..241e432dbf23c45359a8cd2cf037e229824d99c3 100644 --- a/crates/dap_adapters/src/go.rs +++ b/crates/dap_adapters/src/go.rs @@ -100,7 +100,7 @@ impl GoDebugAdapter { #[cfg(feature = "update-schemas")] impl GoDebugAdapter { pub fn get_schema( - temp_dir: &TempDir, + temp_dir: &tempfile::TempDir, delegate: UpdateSchemasDapDelegate, ) -> anyhow::Result { let (package_json, package_nls_json) = get_vsix_package_json( diff --git a/crates/dap_adapters/src/javascript.rs b/crates/dap_adapters/src/javascript.rs index 9c3ec857b16b48b5876b42f04f851130db01a2b3..4ffa6e51db76063def22e647382c06e61638c728 100644 --- a/crates/dap_adapters/src/javascript.rs +++ b/crates/dap_adapters/src/javascript.rs @@ -10,7 +10,6 @@ use std::{ sync::{LazyLock, OnceLock}, }; use task::DebugRequest; -use tempfile::TempDir; use util::{ResultExt, maybe}; use crate::*; @@ -279,7 +278,7 @@ impl DebugAdapter for JsDebugAdapter { #[cfg(feature = "update-schemas")] impl JsDebugAdapter { pub fn get_schema( - temp_dir: &TempDir, + temp_dir: &tempfile::TempDir, delegate: UpdateSchemasDapDelegate, ) -> anyhow::Result { let (package_json, package_nls_json) = get_vsix_package_json( diff --git a/crates/dap_adapters/src/python.rs b/crates/dap_adapters/src/python.rs index 7fc827ff989afe5a75fff603dc1766d8fd81653d..a677ec1db2c6b96987dd18e4064c4a0bbc08d3fb 100644 --- a/crates/dap_adapters/src/python.rs +++ b/crates/dap_adapters/src/python.rs @@ -358,6 +358,8 @@ impl PythonDebugAdapter { temp_dir: &TempDir, delegate: UpdateSchemasDapDelegate, ) -> anyhow::Result { + use fs::Fs as _; + let temp_dir = std::fs::canonicalize(temp_dir.path())?; let fs = delegate.fs.clone(); let executor = delegate.executor.clone(); diff --git a/crates/task/src/debug_format.rs b/crates/task/src/debug_format.rs index cf480392b119c8b6aed22842345fb9968b43fd95..b259b73bcba4981dfbb9c5f48a3dbc0952748ec3 100644 --- a/crates/task/src/debug_format.rs +++ b/crates/task/src/debug_format.rs @@ -352,37 +352,6 @@ impl DebugTaskFile { ) -> serde_json::Value { let mut generator = schemars::generate::SchemaSettings::draft2019_09().into_generator(); - // FIXME what is this doing - // if let Some(template_object) = build_task_schema - // .get_mut("anyOf") - // .and_then(|array| array.as_array_mut()) - // .and_then(|array| array.get_mut(1)) - // { - // if let Some(properties) = template_object - // .get_mut("properties") - // .and_then(|value| value.as_object_mut()) - // { - // if properties.remove("label").is_none() { - // debug_panic!( - // "Generated TaskTemplate json schema did not have expected 'label' field. \ - // Schema of 2nd alternative is: {template_object:?}" - // ); - // } - // } - - // if let Some(arr) = template_object - // .get_mut("required") - // .and_then(|array| array.as_array_mut()) - // { - // arr.retain(|v| v.as_str() != Some("label")); - // } - // } else { - // debug_panic!( - // "Generated TaskTemplate json schema did not match expectations. \ - // Schema is: {build_task_schema:?}" - // ); - // } - let adapter_names = adapter_schemas .iter() .map(|(adapter_name, _)| adapter_name.clone())