// Copyright (c) Jupyter Development Team. // Distributed under the terms of the Modified BSD License. import { IDebugger } from './tokens'; import { ISignal, Signal } from '@lumino/signaling'; import { BreakpointsModel } from './panels/breakpoints/model'; import { CallstackModel } from './panels/callstack/model'; import { SourcesModel } from './panels/sources/model'; import { VariablesModel } from './panels/variables/model'; /** * A model for a debugger. */ export class DebuggerModel { /** * Instantiate a new DebuggerModel */ constructor() { this.breakpoints = new BreakpointsModel(); this.callstack = new CallstackModel(); this.variables = new VariablesModel(); this.sources = new SourcesModel({ currentFrameChanged: this.callstack.currentFrameChanged }); } /** * The breakpoints model. */ readonly breakpoints: BreakpointsModel; /** * The callstack model. */ readonly callstack: CallstackModel; /** * The variables model. */ readonly variables: VariablesModel; /** * The sources model. */ readonly sources: SourcesModel; /** * A signal emitted when the debugger widget is disposed. */ get disposed(): ISignal { return this._disposed; } /** * Whether the model is disposed. */ get isDisposed(): boolean { return this._isDisposed; } /** * The set of threads in stopped state. */ get stoppedThreads(): Set { return this._stoppedThreads; } /** * Assigns the parameters to the set of threads in stopped state. */ set stoppedThreads(threads: Set) { this._stoppedThreads = threads; } /** * The current debugger title. */ get title(): string { return this._title; } /** * Set the current debugger title. */ set title(title: string) { if (title === this._title) { return; } this._title = title ?? '-'; this._titleChanged.emit(title); } /** * A signal emitted when the title changes. */ get titleChanged(): ISignal { return this._titleChanged; } /** * Dispose the model. */ dispose(): void { if (this._isDisposed) { return; } this._isDisposed = true; this._disposed.emit(); } /** * Clear the model. */ clear(): void { this._stoppedThreads.clear(); const breakpoints = new Map(); this.breakpoints.restoreBreakpoints(breakpoints); this.callstack.frames = []; this.variables.scopes = []; this.sources.currentSource = null; this.title = '-'; } private _disposed = new Signal(this); private _isDisposed = false; private _stoppedThreads = new Set(); private _title = '-'; private _titleChanged = new Signal(this); }