This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
debugger.ts
195 lines (159 loc) · 4.16 KB
/
debugger.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import { IEditorServices } from '@jupyterlab/codeeditor';
import { bugIcon } from '@jupyterlab/ui-components';
import { Panel, SplitPanel, Widget } from '@lumino/widgets';
import { Breakpoints } from './breakpoints';
import { Callstack } from './callstack';
import { DebuggerModel } from './model';
import { DebuggerService } from './service';
import { Sources } from './sources';
import { IDebugger } from './tokens';
import { Variables } from './variables';
/**
* A namespace for `Debugger` statics.
*/
export namespace Debugger {
/**
* A debugger sidebar.
*/
export class Sidebar extends Panel {
/**
* Instantiate a new Debugger.Sidebar
*
* @param options The instantiation options for a Debugger.Sidebar
*/
constructor(options: Sidebar.IOptions) {
super();
this.id = 'jp-debugger-sidebar';
this.title.iconRenderer = bugIcon;
this.addClass('jp-DebuggerSidebar');
const { callstackCommands, editorServices, service } = options;
this.model = service.model as DebuggerModel;
this.service = service as DebuggerService;
this.service.model = this.model;
this.variables = new Variables({
model: this.model.variables,
commands: callstackCommands.registry,
service
});
this.callstack = new Callstack({
commands: callstackCommands,
model: this.model.callstack
});
this.breakpoints = new Breakpoints({
service,
model: this.model.breakpoints
});
this.sources = new Sources({
model: this.model.sources,
service,
editorServices
});
const header = new Sidebar.Header();
this.addWidget(header);
this.model.titleChanged.connect((_, title) => {
header.title.label = title;
});
const body = new SplitPanel();
body.orientation = 'vertical';
body.addWidget(this.variables);
body.addWidget(this.callstack);
body.addWidget(this.breakpoints);
body.addWidget(this.sources);
body.addClass('jp-DebuggerSidebar-body');
this.addWidget(body);
}
/**
* Whether the sidebar is disposed.
*/
isDisposed: boolean;
/**
* Dispose the sidebar.
*/
dispose(): void {
if (this.isDisposed) {
return;
}
this.model.dispose();
this.service.model = null;
super.dispose();
}
/**
* The debugger model.
*/
readonly model: DebuggerModel;
/**
* The debugger service.
*/
readonly service: DebuggerService;
/**
* The variables widget.
*/
readonly variables: Variables;
/**
* The callstack widget.
*/
readonly callstack: Callstack;
/**
* The breakpoints widget.
*/
readonly breakpoints: Breakpoints;
/**
* The sources widget.
*/
readonly sources: Sources;
}
/**
* A namespace for Sidebar `statics`
*/
export namespace Sidebar {
/**
* Instantiation options for `Sidebar`.
*/
export interface IOptions {
/**
* The debug service.
*/
service: IDebugger;
/**
* The callstack toolbar commands.
*/
callstackCommands: Callstack.ICommands;
/**
* The editor services.
*/
editorServices: IEditorServices;
}
/**
* The header for a debugger sidebar.
*/
export class Header extends Widget {
/**
* Instantiate a new sidebar header.
*/
constructor() {
super({ node: Private.createHeader() });
this.title.changed.connect(_ => {
this.node.querySelector('h2').textContent = this.title.label;
});
}
}
}
}
/**
* A namespace for private module data.
*/
namespace Private {
/**
* Create a sidebar header node.
*/
export function createHeader(): HTMLElement {
const header = document.createElement('header');
const title = document.createElement('h2');
title.textContent = '-';
title.classList.add('jp-left-truncated');
header.appendChild(title);
return header;
}
}