WIP
This commit is contained in:
52
Cargo.lock
generated
52
Cargo.lock
generated
@@ -2991,6 +2991,34 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
|
||||
|
||||
[[package]]
|
||||
name = "dap"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dap 0.4.1-alpha1",
|
||||
"futures 0.3.28",
|
||||
"gpui",
|
||||
"log",
|
||||
"parking_lot",
|
||||
"postage",
|
||||
"release_channel",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"smol",
|
||||
"util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dap"
|
||||
version = "0.4.1-alpha1"
|
||||
source = "git+https://github.com/sztomi/dap-rs?branch=main#913a2a520416a2a81a1f09a7946f595d5ae3ee4a"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dashmap"
|
||||
version = "5.5.3"
|
||||
@@ -3039,6 +3067,29 @@ dependencies = [
|
||||
"util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "debugger_ui"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dap 0.1.0",
|
||||
"db",
|
||||
"editor",
|
||||
"gpui",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"ui",
|
||||
"workspace",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "debuggers"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dap 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "der"
|
||||
version = "0.6.1"
|
||||
@@ -12598,6 +12649,7 @@ dependencies = [
|
||||
"copilot",
|
||||
"copilot_ui",
|
||||
"db",
|
||||
"debugger_ui",
|
||||
"diagnostics",
|
||||
"editor",
|
||||
"embed-manifest",
|
||||
|
||||
@@ -19,6 +19,9 @@ members = [
|
||||
"crates/command_palette_hooks",
|
||||
"crates/copilot",
|
||||
"crates/copilot_ui",
|
||||
"crates/dap",
|
||||
"crates/debuggers",
|
||||
"crates/debugger_ui",
|
||||
"crates/db",
|
||||
"crates/diagnostics",
|
||||
"crates/editor",
|
||||
@@ -140,6 +143,9 @@ command_palette = { path = "crates/command_palette" }
|
||||
command_palette_hooks = { path = "crates/command_palette_hooks" }
|
||||
copilot = { path = "crates/copilot" }
|
||||
copilot_ui = { path = "crates/copilot_ui" }
|
||||
dap = { path = "crates/dap" }
|
||||
debuggers = { path = "crates/debuggers" }
|
||||
debugger_ui = { path = "crates/debugger_ui" }
|
||||
db = { path = "crates/db" }
|
||||
diagnostics = { path = "crates/diagnostics" }
|
||||
editor = { path = "crates/editor" }
|
||||
|
||||
27
crates/dap/Cargo.toml
Normal file
27
crates/dap/Cargo.toml
Normal file
@@ -0,0 +1,27 @@
|
||||
[package]
|
||||
name = "dap"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
license = "GPL-3.0-or-later"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
path = "src/dap.rs"
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
dap = { git = "https://github.com/sztomi/dap-rs", branch = "main" }
|
||||
futures.workspace = true
|
||||
gpui.workspace = true
|
||||
log.workspace = true
|
||||
parking_lot.workspace = true
|
||||
postage.workspace = true
|
||||
release_channel.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
smol.workspace = true
|
||||
util.workspace = true
|
||||
8
crates/dap/src/dap.rs
Normal file
8
crates/dap/src/dap.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use dap::requests::InitializeArguments;
|
||||
pub use dap::*;
|
||||
|
||||
pub trait DebuggerAdapter {
|
||||
fn initialize(&self, args: InitializeArguments) -> anyhow::Result<()>;
|
||||
}
|
||||
|
||||
// impl dyn DebuggerAdapter {}
|
||||
24
crates/debugger_ui/Cargo.toml
Normal file
24
crates/debugger_ui/Cargo.toml
Normal file
@@ -0,0 +1,24 @@
|
||||
[package]
|
||||
name = "debugger_ui"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
license = "GPL-3.0-or-later"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
dap.workspace = true
|
||||
db.workspace = true
|
||||
editor.workspace = true
|
||||
gpui.workspace = true
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
ui.workspace = true
|
||||
workspace.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
editor = { workspace = true, features = ["test-support"] }
|
||||
gpui = { workspace = true, features = ["test-support"] }
|
||||
132
crates/debugger_ui/src/debugger_panel.rs
Normal file
132
crates/debugger_ui/src/debugger_panel.rs
Normal file
@@ -0,0 +1,132 @@
|
||||
use gpui::{actions, AppContext, EventEmitter, FocusHandle, FocusableView, ViewContext};
|
||||
use ui::{
|
||||
div, h_flex, prelude, px, ButtonCommon, Element, IconButton, ParentElement, Pixels, Render,
|
||||
Styled, Tooltip, WindowContext,
|
||||
};
|
||||
use workspace::dock::{DockPosition, Panel, PanelEvent};
|
||||
|
||||
actions!(debug, [TogglePanel]);
|
||||
|
||||
pub struct DebugPanel {
|
||||
pub position: DockPosition,
|
||||
pub zoomed: bool,
|
||||
pub active: bool,
|
||||
pub focus_handle: FocusHandle,
|
||||
pub size: Pixels,
|
||||
}
|
||||
|
||||
impl DebugPanel {
|
||||
pub fn new(position: DockPosition, cx: &mut WindowContext) -> Self {
|
||||
Self {
|
||||
position,
|
||||
zoomed: false,
|
||||
active: false,
|
||||
focus_handle: cx.focus_handle(),
|
||||
size: px(300.),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl EventEmitter<PanelEvent> for DebugPanel {}
|
||||
|
||||
impl FocusableView for DebugPanel {
|
||||
fn focus_handle(&self, _cx: &AppContext) -> FocusHandle {
|
||||
self.focus_handle.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl Panel for DebugPanel {
|
||||
fn persistent_name() -> &'static str {
|
||||
"DebugPanel"
|
||||
}
|
||||
|
||||
fn position(&self, _cx: &prelude::WindowContext) -> workspace::dock::DockPosition {
|
||||
self.position
|
||||
}
|
||||
|
||||
fn position_is_valid(&self, _position: workspace::dock::DockPosition) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn set_position(
|
||||
&mut self,
|
||||
position: workspace::dock::DockPosition,
|
||||
_cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
self.position = position;
|
||||
// TODO:
|
||||
// cx.update_global::<SettingsStore>(f)
|
||||
}
|
||||
|
||||
fn size(&self, _cx: &prelude::WindowContext) -> prelude::Pixels {
|
||||
self.size
|
||||
}
|
||||
|
||||
fn set_size(&mut self, size: Option<prelude::Pixels>, _cx: &mut ViewContext<Self>) {
|
||||
self.size = size.unwrap();
|
||||
}
|
||||
|
||||
fn icon(&self, _cx: &prelude::WindowContext) -> Option<ui::IconName> {
|
||||
None
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &prelude::WindowContext) -> Option<&'static str> {
|
||||
None
|
||||
}
|
||||
|
||||
fn toggle_action(&self) -> Box<dyn gpui::Action> {
|
||||
Box::new(TogglePanel)
|
||||
}
|
||||
|
||||
fn icon_label(&self, _: &WindowContext) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
fn is_zoomed(&self, _cx: &WindowContext) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn starts_open(&self, _cx: &WindowContext) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn set_zoomed(&mut self, _zoomed: bool, _cx: &mut ViewContext<Self>) {}
|
||||
|
||||
fn set_active(&mut self, _active: bool, _cx: &mut ViewContext<Self>) {}
|
||||
}
|
||||
|
||||
impl Render for DebugPanel {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> impl prelude::IntoElement {
|
||||
div()
|
||||
.child(
|
||||
h_flex()
|
||||
.p_2()
|
||||
.gap_2()
|
||||
.child(
|
||||
IconButton::new("debug-play", ui::IconName::Play)
|
||||
.tooltip(move |cx| Tooltip::text("Start debug", cx)),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("debug-step-over", ui::IconName::Play)
|
||||
.tooltip(move |cx| Tooltip::text("Step over", cx)),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("debug-go-in", ui::IconName::Play)
|
||||
.tooltip(move |cx| Tooltip::text("Go in", cx)),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("debug-go-out", ui::IconName::Play)
|
||||
.tooltip(move |cx| Tooltip::text("Go out", cx)),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("debug-restart", ui::IconName::Play)
|
||||
.tooltip(move |cx| Tooltip::text("Restart", cx)),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("debug-stop", ui::IconName::Play)
|
||||
.tooltip(move |cx| Tooltip::text("Stop", cx)),
|
||||
),
|
||||
)
|
||||
.into_any()
|
||||
}
|
||||
}
|
||||
23
crates/debugger_ui/src/lib.rs
Normal file
23
crates/debugger_ui/src/lib.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use debugger_panel::{DebugPanel, TogglePanel};
|
||||
use gpui::{AppContext, ViewContext};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ui::Pixels;
|
||||
use workspace::Workspace;
|
||||
|
||||
pub mod debugger_panel;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct SerializedDebugPanel {
|
||||
width: Option<Pixels>,
|
||||
}
|
||||
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.observe_new_views(
|
||||
|workspace: &mut Workspace, _: &mut ViewContext<Workspace>| {
|
||||
workspace.register_action(|workspace, _action: &TogglePanel, cx| {
|
||||
workspace.focus_panel::<DebugPanel>(cx);
|
||||
});
|
||||
},
|
||||
)
|
||||
.detach();
|
||||
}
|
||||
13
crates/debuggers/Cargo.toml
Normal file
13
crates/debuggers/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "debuggers"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
license = "GPL-3.0-or-later"
|
||||
|
||||
[dependencies]
|
||||
dap.workspace = true
|
||||
anyhow.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
2
crates/debuggers/src/lib.rs
Normal file
2
crates/debuggers/src/lib.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
mod node;
|
||||
mod xdebug;
|
||||
9
crates/debuggers/src/node.rs
Normal file
9
crates/debuggers/src/node.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use dap::DebuggerAdapter;
|
||||
|
||||
pub struct JsAdapter;
|
||||
|
||||
impl DebuggerAdapter for JsAdapter {
|
||||
fn initialize(&self, args: dap::requests::InitializeArguments) -> anyhow::Result<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
12
crates/debuggers/src/xdebug.rs
Normal file
12
crates/debuggers/src/xdebug.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use dap::{requests::InitializeArguments, DebuggerAdapter};
|
||||
|
||||
pub struct Xdebug;
|
||||
|
||||
impl DebuggerAdapter for Xdebug {
|
||||
fn initialize(&self, _args: InitializeArguments) -> anyhow::Result<()> {
|
||||
if true != false {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ collections.workspace = true
|
||||
command_palette.workspace = true
|
||||
copilot.workspace = true
|
||||
copilot_ui.workspace = true
|
||||
debugger_ui.workspace = true
|
||||
db.workspace = true
|
||||
diagnostics.workspace = true
|
||||
editor.workspace = true
|
||||
|
||||
@@ -272,6 +272,7 @@ fn main() {
|
||||
project_symbols::init(cx);
|
||||
project_panel::init(Assets, cx);
|
||||
tasks_ui::init(cx);
|
||||
debugger_ui::init(cx);
|
||||
channel::init(&client, user_store.clone(), cx);
|
||||
search::init(cx);
|
||||
vim::init(cx);
|
||||
|
||||
@@ -7,6 +7,7 @@ use assistant::AssistantPanel;
|
||||
use breadcrumbs::Breadcrumbs;
|
||||
use client::ZED_URL_SCHEME;
|
||||
use collections::VecDeque;
|
||||
use debugger_ui::debugger_panel::DebugPanel;
|
||||
use editor::{scroll::Autoscroll, Editor, MultiBuffer};
|
||||
use gpui::{
|
||||
actions, point, px, AppContext, AsyncAppContext, Context, FocusableView, PromptLevel,
|
||||
@@ -201,6 +202,11 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
workspace_handle.clone(),
|
||||
cx.clone(),
|
||||
);
|
||||
|
||||
let debug_panel = workspace_handle.update(&mut cx.clone(), |workspace, cx| {
|
||||
cx.new_view(|cx| DebugPanel::new(workspace::dock::DockPosition::Bottom, cx))
|
||||
})?;
|
||||
|
||||
let (
|
||||
project_panel,
|
||||
terminal_panel,
|
||||
@@ -224,6 +230,7 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
workspace.add_panel(channels_panel, cx);
|
||||
workspace.add_panel(chat_panel, cx);
|
||||
workspace.add_panel(notification_panel, cx);
|
||||
workspace.add_panel(debug_panel, cx);
|
||||
cx.focus_self();
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user