MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / handleDebugSessionStart

Method handleDebugSessionStart

src/extension/commands/debug.ts:584–629  ·  view source on GitHub ↗
(s: vs.DebugSession)

Source from the content-addressed store, hash-verified

582 }
583
584 public handleDebugSessionStart(s: vs.DebugSession): DartDebugSessionInformation | undefined {
585 if (s.type !== "dart")
586 return;
587
588 const session = new DartDebugSessionInformation(s);
589 // If we're the first fresh debug session, reset all settings to default.
590 // Subsequent launches will inherit the "current" values.
591 if (debugSessions.length === 0)
592 this.vmServices.resetToDefaults();
593 debugSessions.push(session);
594 this.updateDebugSessionsStatus();
595 debugSessionStartedEmitter.fire(session);
596 debugSessionsChangedEmitter.fire();
597
598 if (s.configuration.debuggerType === DebuggerType.Flutter || s.configuration.debuggerType === DebuggerType.Web) {
599 // TODO(dantup): Can these use session.flutterMode in preference?
600 const isProfileMode = s.configuration.toolArgs?.includes("--profile");
601 const isReleaseMode = s.configuration.toolArgs?.includes("--release");
602
603 if (isReleaseMode) {
604 void vs.commands.executeCommand("setContext", isInFlutterReleaseModeDebugSessionContext, true);
605 } else if (isProfileMode) {
606 isInFlutterProfileModeDebugSession = true;
607 void vs.commands.executeCommand("setContext", isInFlutterProfileModeDebugSessionContext, true);
608 } else {
609 isInFlutterDebugModeDebugSession = true;
610 void vs.commands.executeCommand("setContext", isInFlutterDebugModeDebugSessionContext, true);
611 }
612 } else if (s.configuration.debuggerType === DebuggerType.Dart) {
613 void vs.commands.executeCommand("setContext", isInDartDebugSessionContext, true);
614 }
615
616 // Process any queued events that came in before the session start
617 // event.
618 const eventsToProcess = pendingCustomEvents.filter((e) => e.session.id === s.id);
619 pendingCustomEvents = pendingCustomEvents.filter((e) => e.session.id !== s.id);
620
621 eventsToProcess.forEach((e) => {
622 this.logger.info(`Processing delayed event ${e.event} for session ${e.session.id}`);
623 void this.handleCustomEventWithSession(session, e);
624 });
625
626 this.debugOptions.show();
627
628 return session;
629 }
630
631 public handleDebugSessionCustomEvent(e: vs.DebugSessionCustomEvent): void {
632 if (this.handleCustomEvent(e))

Callers 1

constructorMethod · 0.95

Calls 7

resetToDefaultsMethod · 0.80
executeCommandMethod · 0.65
infoMethod · 0.65
fireMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected