|
1 | 1 | use super::{
|
2 | 2 | breakpoint_store::BreakpointStore,
|
3 |
| - // Will need to uncomment this once we implement rpc message handler again |
4 |
| - // dap_command::{ |
5 |
| - // ContinueCommand, DapCommand, DisconnectCommand, NextCommand, PauseCommand, RestartCommand, |
6 |
| - // RestartStackFrameCommand, StepBackCommand, StepCommand, StepInCommand, StepOutCommand, |
7 |
| - // TerminateCommand, TerminateThreadsCommand, VariablesCommand, |
8 |
| - // }, |
| 3 | + locator_store::LocatorStore, |
9 | 4 | session::{self, Session},
|
10 | 5 | };
|
11 | 6 | use crate::{debugger, worktree_store::WorktreeStore, ProjectEnvironment};
|
@@ -87,6 +82,7 @@ pub struct LocalDapStore {
|
87 | 82 | language_registry: Arc<LanguageRegistry>,
|
88 | 83 | debug_adapters: Arc<DapRegistry>,
|
89 | 84 | toolchain_store: Arc<dyn LanguageToolchainStore>,
|
| 85 | + locator_store: Arc<LocatorStore>, |
90 | 86 | start_debugging_tx: futures::channel::mpsc::UnboundedSender<(SessionId, Message)>,
|
91 | 87 | _start_debugging_task: Task<()>,
|
92 | 88 | }
|
@@ -179,6 +175,7 @@ impl DapStore {
|
179 | 175 | debug_adapters,
|
180 | 176 | start_debugging_tx,
|
181 | 177 | _start_debugging_task,
|
| 178 | + locator_store: Arc::from(LocatorStore::new()), |
182 | 179 | next_session_id: Default::default(),
|
183 | 180 | }),
|
184 | 181 | downstream_client: None,
|
@@ -324,7 +321,7 @@ impl DapStore {
|
324 | 321 |
|
325 | 322 | pub fn new_session(
|
326 | 323 | &mut self,
|
327 |
| - config: DebugAdapterConfig, |
| 324 | + mut config: DebugAdapterConfig, |
328 | 325 | worktree: &Entity<Worktree>,
|
329 | 326 | parent_session: Option<Entity<Session>>,
|
330 | 327 | cx: &mut Context<Self>,
|
@@ -354,22 +351,39 @@ impl DapStore {
|
354 | 351 | }
|
355 | 352 |
|
356 | 353 | let (initialized_tx, initialized_rx) = oneshot::channel();
|
| 354 | + let locator_store = local_store.locator_store.clone(); |
| 355 | + let debug_adapters = local_store.debug_adapters.clone(); |
357 | 356 |
|
358 |
| - let start_client_task = Session::local( |
359 |
| - self.breakpoint_store.clone(), |
360 |
| - session_id, |
361 |
| - parent_session, |
362 |
| - delegate, |
363 |
| - config, |
364 |
| - local_store.start_debugging_tx.clone(), |
365 |
| - initialized_tx, |
366 |
| - local_store.debug_adapters.clone(), |
367 |
| - cx, |
368 |
| - ); |
| 357 | + let start_debugging_tx = local_store.start_debugging_tx.clone(); |
| 358 | + |
| 359 | + let task = cx.spawn(async move |this, cx| { |
| 360 | + if config.locator.is_some() { |
| 361 | + locator_store.resolve_debug_config(&mut config).await?; |
| 362 | + } |
| 363 | + |
| 364 | + let start_client_task = this.update(cx, |this, cx| { |
| 365 | + Session::local( |
| 366 | + this.breakpoint_store.clone(), |
| 367 | + session_id, |
| 368 | + parent_session, |
| 369 | + delegate, |
| 370 | + config, |
| 371 | + start_debugging_tx.clone(), |
| 372 | + initialized_tx, |
| 373 | + debug_adapters, |
| 374 | + cx, |
| 375 | + ) |
| 376 | + })?; |
| 377 | + |
| 378 | + this.update(cx, |_, cx| { |
| 379 | + create_new_session(session_id, initialized_rx, start_client_task, cx) |
| 380 | + })? |
| 381 | + .await |
| 382 | + }); |
369 | 383 |
|
370 |
| - let task = create_new_session(session_id, initialized_rx, start_client_task, cx); |
371 | 384 | (session_id, task)
|
372 | 385 | }
|
| 386 | + |
373 | 387 | #[cfg(any(test, feature = "test-support"))]
|
374 | 388 | pub fn new_fake_session(
|
375 | 389 | &mut self,
|
@@ -456,7 +470,10 @@ impl DapStore {
|
456 | 470 | request: DebugRequestDisposition::ReverseRequest(args),
|
457 | 471 | initialize_args: config.initialize_args.clone(),
|
458 | 472 | tcp_connection: config.tcp_connection.clone(),
|
| 473 | + locator: None, |
| 474 | + args: Default::default(), |
459 | 475 | };
|
| 476 | + |
460 | 477 | #[cfg(any(test, feature = "test-support"))]
|
461 | 478 | let new_session_task = {
|
462 | 479 | let caps = parent_session.read(cx).capabilities.clone();
|
|
0 commit comments