debugger beta: Fix dap_schema for DAP extensions (#31173)
We now actually call dap_schema provided by extensions instead of defaulting to a null `serde_json::Value`. We still need to update the Json LSP whenever a new dap is installed. Release Notes: - N/A
This commit is contained in:
parent
baf6d82cd4
commit
06f725d51b
13 changed files with 35 additions and 22 deletions
|
@ -386,7 +386,7 @@ pub trait DebugAdapter: 'static + Send + Sync {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dap_schema(&self) -> serde_json::Value;
|
async fn dap_schema(&self) -> serde_json::Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
@ -434,7 +434,7 @@ impl DebugAdapter for FakeAdapter {
|
||||||
DebugAdapterName(Self::ADAPTER_NAME.into())
|
DebugAdapterName(Self::ADAPTER_NAME.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dap_schema(&self) -> serde_json::Value {
|
async fn dap_schema(&self) -> serde_json::Value {
|
||||||
serde_json::Value::Null
|
serde_json::Value::Null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,16 @@ impl DapRegistry {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn adapters_schema(&self) -> task::AdapterSchemas {
|
pub async fn adapters_schema(&self) -> task::AdapterSchemas {
|
||||||
let mut schemas = AdapterSchemas(vec![]);
|
let mut schemas = AdapterSchemas(vec![]);
|
||||||
|
|
||||||
for (name, adapter) in self.0.read().adapters.iter() {
|
// Clone to avoid holding lock over await points
|
||||||
|
let adapters = self.0.read().adapters.clone();
|
||||||
|
|
||||||
|
for (name, adapter) in adapters.into_iter() {
|
||||||
schemas.0.push(AdapterSchema {
|
schemas.0.push(AdapterSchema {
|
||||||
adapter: name.clone().into(),
|
adapter: name.into(),
|
||||||
schema: adapter.dap_schema(),
|
schema: adapter.dap_schema().await,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ impl DebugAdapter for CodeLldbDebugAdapter {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dap_schema(&self) -> serde_json::Value {
|
async fn dap_schema(&self) -> serde_json::Value {
|
||||||
json!({
|
json!({
|
||||||
"properties": {
|
"properties": {
|
||||||
"request": {
|
"request": {
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl DebugAdapter for GdbDebugAdapter {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dap_schema(&self) -> serde_json::Value {
|
async fn dap_schema(&self) -> serde_json::Value {
|
||||||
json!({
|
json!({
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl DebugAdapter for GoDebugAdapter {
|
||||||
Some(SharedString::new_static("Go").into())
|
Some(SharedString::new_static("Go").into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dap_schema(&self) -> serde_json::Value {
|
async fn dap_schema(&self) -> serde_json::Value {
|
||||||
// Create common properties shared between launch and attach
|
// Create common properties shared between launch and attach
|
||||||
let common_properties = json!({
|
let common_properties = json!({
|
||||||
"debugAdapter": {
|
"debugAdapter": {
|
||||||
|
|
|
@ -170,7 +170,7 @@ impl DebugAdapter for JsDebugAdapter {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dap_schema(&self) -> serde_json::Value {
|
async fn dap_schema(&self) -> serde_json::Value {
|
||||||
json!({
|
json!({
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,7 +101,7 @@ impl PhpDebugAdapter {
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl DebugAdapter for PhpDebugAdapter {
|
impl DebugAdapter for PhpDebugAdapter {
|
||||||
fn dap_schema(&self) -> serde_json::Value {
|
async fn dap_schema(&self) -> serde_json::Value {
|
||||||
json!({
|
json!({
|
||||||
"properties": {
|
"properties": {
|
||||||
"request": {
|
"request": {
|
||||||
|
|
|
@ -210,7 +210,7 @@ impl DebugAdapter for PythonDebugAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dap_schema(&self) -> serde_json::Value {
|
async fn dap_schema(&self) -> serde_json::Value {
|
||||||
json!({
|
json!({
|
||||||
"properties": {
|
"properties": {
|
||||||
"request": {
|
"request": {
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl DebugAdapter for RubyDebugAdapter {
|
||||||
Some(SharedString::new_static("Ruby").into())
|
Some(SharedString::new_static("Ruby").into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dap_schema(&self) -> serde_json::Value {
|
async fn dap_schema(&self) -> serde_json::Value {
|
||||||
json!({
|
json!({
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,8 +61,8 @@ impl DebugAdapter for ExtensionDapAdapter {
|
||||||
self.debug_adapter_name.as_ref().into()
|
self.debug_adapter_name.as_ref().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dap_schema(&self) -> serde_json::Value {
|
async fn dap_schema(&self) -> serde_json::Value {
|
||||||
serde_json::Value::Null
|
self.extension.get_dap_schema().await.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_binary(
|
async fn get_binary(
|
||||||
|
|
|
@ -144,7 +144,7 @@ pub trait Extension: Send + Sync + 'static {
|
||||||
worktree: Arc<dyn WorktreeDelegate>,
|
worktree: Arc<dyn WorktreeDelegate>,
|
||||||
) -> Result<DebugAdapterBinary>;
|
) -> Result<DebugAdapterBinary>;
|
||||||
|
|
||||||
async fn dap_schema(&self) -> Result<serde_json::Value>;
|
async fn get_dap_schema(&self) -> Result<serde_json::Value>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_wasm_extension_version(
|
pub fn parse_wasm_extension_version(
|
||||||
|
|
|
@ -399,7 +399,7 @@ impl extension::Extension for WasmExtension {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn dap_schema(&self) -> Result<serde_json::Value> {
|
async fn get_dap_schema(&self) -> Result<serde_json::Value> {
|
||||||
self.call(|extension, store| {
|
self.call(|extension, store| {
|
||||||
async move {
|
async move {
|
||||||
extension
|
extension
|
||||||
|
|
|
@ -26,7 +26,7 @@ use std::{
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use task::{TaskTemplate, TaskTemplates, VariableName};
|
use task::{AdapterSchemas, TaskTemplate, TaskTemplates, VariableName};
|
||||||
use util::{ResultExt, archive::extract_zip, fs::remove_matching, maybe, merge_json_value_into};
|
use util::{ResultExt, archive::extract_zip, fs::remove_matching, maybe, merge_json_value_into};
|
||||||
|
|
||||||
const SERVER_PATH: &str =
|
const SERVER_PATH: &str =
|
||||||
|
@ -76,7 +76,11 @@ impl JsonLspAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_workspace_config(language_names: Vec<String>, cx: &mut App) -> Value {
|
fn get_workspace_config(
|
||||||
|
language_names: Vec<String>,
|
||||||
|
adapter_schemas: AdapterSchemas,
|
||||||
|
cx: &mut App,
|
||||||
|
) -> Value {
|
||||||
let keymap_schema = KeymapFile::generate_json_schema_for_registered_actions(cx);
|
let keymap_schema = KeymapFile::generate_json_schema_for_registered_actions(cx);
|
||||||
let font_names = &cx.text_system().all_font_names();
|
let font_names = &cx.text_system().all_font_names();
|
||||||
let settings_schema = cx.global::<SettingsStore>().json_schema(
|
let settings_schema = cx.global::<SettingsStore>().json_schema(
|
||||||
|
@ -87,7 +91,6 @@ impl JsonLspAdapter {
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
||||||
let adapter_schemas = cx.global::<DapRegistry>().adapters_schema();
|
|
||||||
let tasks_schema = task::TaskTemplates::generate_json_schema();
|
let tasks_schema = task::TaskTemplates::generate_json_schema();
|
||||||
let debug_schema = task::DebugTaskFile::generate_json_schema(&adapter_schemas);
|
let debug_schema = task::DebugTaskFile::generate_json_schema(&adapter_schemas);
|
||||||
let snippets_schema = snippet_provider::format::VsSnippetsFile::generate_json_schema();
|
let snippets_schema = snippet_provider::format::VsSnippetsFile::generate_json_schema();
|
||||||
|
@ -163,8 +166,15 @@ impl JsonLspAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut writer = self.workspace_config.write().await;
|
let mut writer = self.workspace_config.write().await;
|
||||||
let config =
|
|
||||||
cx.update(|cx| Self::get_workspace_config(self.languages.language_names(), cx))?;
|
let adapter_schemas = cx
|
||||||
|
.read_global::<DapRegistry, _>(|dap_registry, _| dap_registry.to_owned())?
|
||||||
|
.adapters_schema()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let config = cx.update(|cx| {
|
||||||
|
Self::get_workspace_config(self.languages.language_names().clone(), adapter_schemas, cx)
|
||||||
|
})?;
|
||||||
writer.replace(config.clone());
|
writer.replace(config.clone());
|
||||||
return Ok(config);
|
return Ok(config);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue