@jupyterlab/debugger 4.0.0-alpha.9 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/debugger.d.ts +3 -1
- package/lib/debugger.js +5 -3
- package/lib/debugger.js.map +1 -1
- package/lib/dialogs/evaluate.d.ts +5 -0
- package/lib/dialogs/evaluate.js +16 -6
- package/lib/dialogs/evaluate.js.map +1 -1
- package/lib/factory.d.ts +1 -1
- package/lib/factory.js +15 -9
- package/lib/factory.js.map +1 -1
- package/lib/handler.js +15 -7
- package/lib/handler.js.map +1 -1
- package/lib/handlers/console.js +9 -3
- package/lib/handlers/console.js.map +1 -1
- package/lib/handlers/editor.d.ts +26 -12
- package/lib/handlers/editor.js +166 -89
- package/lib/handlers/editor.js.map +1 -1
- package/lib/handlers/file.js +6 -2
- package/lib/handlers/file.js.map +1 -1
- package/lib/handlers/notebook.d.ts +0 -7
- package/lib/handlers/notebook.js +11 -17
- package/lib/handlers/notebook.js.map +1 -1
- package/lib/icons.d.ts +2 -1
- package/lib/icons.js +6 -1
- package/lib/icons.js.map +1 -1
- package/lib/model.js +1 -0
- package/lib/model.js.map +1 -1
- package/lib/panels/breakpoints/index.d.ts +2 -2
- package/lib/panels/breakpoints/index.js +9 -7
- package/lib/panels/breakpoints/index.js.map +1 -1
- package/lib/panels/breakpoints/pauseonexceptions.d.ts +53 -0
- package/lib/panels/breakpoints/pauseonexceptions.js +98 -0
- package/lib/panels/breakpoints/pauseonexceptions.js.map +1 -0
- package/lib/panels/callstack/index.d.ts +1 -1
- package/lib/panels/kernelSources/body.d.ts +5 -7
- package/lib/panels/kernelSources/body.js +37 -47
- package/lib/panels/kernelSources/body.js.map +1 -1
- package/lib/panels/kernelSources/filter.d.ts +1 -2
- package/lib/panels/kernelSources/filter.js +2 -2
- package/lib/panels/kernelSources/filter.js.map +1 -1
- package/lib/panels/kernelSources/index.js +1 -1
- package/lib/panels/kernelSources/index.js.map +1 -1
- package/lib/panels/kernelSources/model.d.ts +10 -1
- package/lib/panels/kernelSources/model.js +19 -1
- package/lib/panels/kernelSources/model.js.map +1 -1
- package/lib/panels/sources/body.js +5 -3
- package/lib/panels/sources/body.js.map +1 -1
- package/lib/panels/sources/sourcepath.js +1 -1
- package/lib/panels/sources/sourcepath.js.map +1 -1
- package/lib/panels/variables/grid.d.ts +23 -10
- package/lib/panels/variables/grid.js +42 -367
- package/lib/panels/variables/grid.js.map +1 -1
- package/lib/panels/variables/gridpanel.d.ts +138 -0
- package/lib/panels/variables/gridpanel.js +362 -0
- package/lib/panels/variables/gridpanel.js.map +1 -0
- package/lib/panels/variables/mimerenderer.js +9 -1
- package/lib/panels/variables/mimerenderer.js.map +1 -1
- package/lib/panels/variables/scope.js +4 -0
- package/lib/panels/variables/scope.js.map +1 -1
- package/lib/panels/variables/tree.d.ts +1 -0
- package/lib/panels/variables/tree.js +136 -47
- package/lib/panels/variables/tree.js.map +1 -1
- package/lib/service.d.ts +20 -6
- package/lib/service.js +84 -59
- package/lib/service.js.map +1 -1
- package/lib/session.d.ts +20 -6
- package/lib/session.js +59 -11
- package/lib/session.js.map +1 -1
- package/lib/sidebar.js +1 -1
- package/lib/sources.d.ts +2 -2
- package/lib/sources.js +32 -17
- package/lib/sources.js.map +1 -1
- package/lib/tokens.d.ts +57 -13
- package/lib/tokens.js.map +1 -1
- package/package.json +38 -46
- package/src/config.ts +78 -0
- package/src/debugger.ts +154 -0
- package/src/dialogs/evaluate.ts +144 -0
- package/src/factory.ts +72 -0
- package/src/handler.ts +528 -0
- package/src/handlers/console.ts +118 -0
- package/src/handlers/editor.ts +469 -0
- package/src/handlers/file.ts +86 -0
- package/src/handlers/notebook.ts +128 -0
- package/src/hash.ts +69 -0
- package/src/icons.ts +64 -0
- package/src/index.ts +16 -0
- package/src/model.ts +155 -0
- package/src/panels/breakpoints/body.tsx +145 -0
- package/src/panels/breakpoints/index.ts +116 -0
- package/src/panels/breakpoints/model.ts +74 -0
- package/src/panels/breakpoints/pauseonexceptions.tsx +141 -0
- package/src/panels/callstack/body.tsx +96 -0
- package/src/panels/callstack/index.ts +152 -0
- package/src/panels/callstack/model.ts +86 -0
- package/src/panels/kernelSources/body.tsx +139 -0
- package/src/panels/kernelSources/filter.tsx +44 -0
- package/src/panels/kernelSources/index.tsx +106 -0
- package/src/panels/kernelSources/model.ts +160 -0
- package/src/panels/sources/body.ts +161 -0
- package/src/panels/sources/index.tsx +85 -0
- package/src/panels/sources/model.ts +94 -0
- package/src/panels/sources/sourcepath.tsx +31 -0
- package/src/panels/variables/grid.ts +145 -0
- package/src/panels/variables/gridpanel.ts +453 -0
- package/src/panels/variables/index.ts +199 -0
- package/src/panels/variables/mimerenderer.ts +125 -0
- package/src/panels/variables/model.ts +61 -0
- package/src/panels/variables/scope.tsx +132 -0
- package/src/panels/variables/tree.tsx +521 -0
- package/src/service.ts +1009 -0
- package/src/session.ts +342 -0
- package/src/sidebar.ts +194 -0
- package/src/sources.ts +327 -0
- package/src/svg.d.ts +9 -0
- package/src/tokens.ts +1071 -0
- package/style/breakpoints.css +21 -12
- package/style/callstack.css +2 -2
- package/style/icons/exceptions.svg +10 -0
- package/style/index.css +1 -1
- package/style/index.js +1 -1
- package/style/kernelSources.css +3 -9
- package/style/sources.css +1 -1
- package/style/variables.css +68 -21
package/src/hash.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
// Most of the implementation below is adapted from the following repository:
|
|
5
|
+
// https://github.com/garycourt/murmurhash-js/blob/master/murmurhash2_gc.js
|
|
6
|
+
// Which has the following MIT License:
|
|
7
|
+
//
|
|
8
|
+
// Copyright (c) 2011 Gary Court
|
|
9
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
10
|
+
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
11
|
+
// and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
12
|
+
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
15
|
+
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
16
|
+
|
|
17
|
+
// The implementation below uses case fallthrough as part of the algorithm.
|
|
18
|
+
/* eslint-disable no-fallthrough */
|
|
19
|
+
|
|
20
|
+
const m = 0x5bd1e995;
|
|
21
|
+
const encoder = new TextEncoder();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Calculate the murmurhash2 for a given string and seed.
|
|
25
|
+
*
|
|
26
|
+
* @param str The string to calculate the Murmur2 hash for.
|
|
27
|
+
* @param seed The seed.
|
|
28
|
+
*
|
|
29
|
+
* @returns The Murmurhash2 hash.
|
|
30
|
+
*/
|
|
31
|
+
export function murmur2(str: string, seed: number): number {
|
|
32
|
+
const data = encoder.encode(str);
|
|
33
|
+
let len = data.length;
|
|
34
|
+
let h = seed ^ len;
|
|
35
|
+
let i = 0;
|
|
36
|
+
|
|
37
|
+
while (len >= 4) {
|
|
38
|
+
let k =
|
|
39
|
+
(data[i] & 0xff) |
|
|
40
|
+
((data[++i] & 0xff) << 8) |
|
|
41
|
+
((data[++i] & 0xff) << 16) |
|
|
42
|
+
((data[++i] & 0xff) << 24);
|
|
43
|
+
|
|
44
|
+
k = (k & 0xffff) * m + ((((k >>> 16) * m) & 0xffff) << 16);
|
|
45
|
+
k ^= k >>> 24;
|
|
46
|
+
k = (k & 0xffff) * m + ((((k >>> 16) * m) & 0xffff) << 16);
|
|
47
|
+
|
|
48
|
+
h = ((h & 0xffff) * m + ((((h >>> 16) * m) & 0xffff) << 16)) ^ k;
|
|
49
|
+
|
|
50
|
+
len -= 4;
|
|
51
|
+
++i;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
switch (len) {
|
|
55
|
+
case 3:
|
|
56
|
+
h ^= (data[i + 2] & 0xff) << 16;
|
|
57
|
+
case 2:
|
|
58
|
+
h ^= (data[i + 1] & 0xff) << 8;
|
|
59
|
+
case 1:
|
|
60
|
+
h ^= data[i] & 0xff;
|
|
61
|
+
h = (h & 0xffff) * m + ((((h >>> 16) * m) & 0xffff) << 16);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
h ^= h >>> 13;
|
|
65
|
+
h = (h & 0xffff) * m + ((((h >>> 16) * m) & 0xffff) << 16);
|
|
66
|
+
h ^= h >>> 15;
|
|
67
|
+
|
|
68
|
+
return h >>> 0;
|
|
69
|
+
}
|
package/src/icons.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { LabIcon } from '@jupyterlab/ui-components';
|
|
5
|
+
|
|
6
|
+
import closeAllSvgStr from '../style/icons/close-all.svg';
|
|
7
|
+
import stepIntoSvgStr from '../style/icons/step-into.svg';
|
|
8
|
+
import stepOutSvgStr from '../style/icons/step-out.svg';
|
|
9
|
+
import stepOverSvgStr from '../style/icons/step-over.svg';
|
|
10
|
+
import variableSvgStr from '../style/icons/variable.svg';
|
|
11
|
+
import pauseSvgStr from '../style/icons/pause.svg';
|
|
12
|
+
import viewBreakpointSvgStr from '../style/icons/view-breakpoint.svg';
|
|
13
|
+
import openKernelSourceSvgStr from '../style/icons/open-kernel-source.svg';
|
|
14
|
+
import exceptionSvgStr from '../style/icons/exceptions.svg';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
runIcon as continueIcon,
|
|
18
|
+
stopIcon as terminateIcon
|
|
19
|
+
} from '@jupyterlab/ui-components';
|
|
20
|
+
|
|
21
|
+
export const closeAllIcon = new LabIcon({
|
|
22
|
+
name: 'debugger:close-all',
|
|
23
|
+
svgstr: closeAllSvgStr
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const exceptionIcon = new LabIcon({
|
|
27
|
+
name: 'debugger:pause-on-exception',
|
|
28
|
+
svgstr: exceptionSvgStr
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const pauseIcon = new LabIcon({
|
|
32
|
+
name: 'debugger:pause',
|
|
33
|
+
svgstr: pauseSvgStr
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const stepIntoIcon = new LabIcon({
|
|
37
|
+
name: 'debugger:step-into',
|
|
38
|
+
svgstr: stepIntoSvgStr
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const stepOverIcon = new LabIcon({
|
|
42
|
+
name: 'debugger:step-over',
|
|
43
|
+
svgstr: stepOverSvgStr
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const stepOutIcon = new LabIcon({
|
|
47
|
+
name: 'debugger:step-out',
|
|
48
|
+
svgstr: stepOutSvgStr
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const variableIcon = new LabIcon({
|
|
52
|
+
name: 'debugger:variable',
|
|
53
|
+
svgstr: variableSvgStr
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export const viewBreakpointIcon = new LabIcon({
|
|
57
|
+
name: 'debugger:view-breakpoint',
|
|
58
|
+
svgstr: viewBreakpointSvgStr
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const openKernelSourceIcon = new LabIcon({
|
|
62
|
+
name: 'debugger:open-kernel-source',
|
|
63
|
+
svgstr: openKernelSourceSvgStr
|
|
64
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
/**
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
* @module debugger
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export { Debugger } from './debugger';
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
IDebugger,
|
|
12
|
+
IDebuggerConfig,
|
|
13
|
+
IDebuggerSources,
|
|
14
|
+
IDebuggerSidebar,
|
|
15
|
+
IDebuggerHandler
|
|
16
|
+
} from './tokens';
|
package/src/model.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { IDebugger } from './tokens';
|
|
5
|
+
|
|
6
|
+
import { ISignal, Signal } from '@lumino/signaling';
|
|
7
|
+
|
|
8
|
+
import { BreakpointsModel } from './panels/breakpoints/model';
|
|
9
|
+
|
|
10
|
+
import { CallstackModel } from './panels/callstack/model';
|
|
11
|
+
|
|
12
|
+
import { SourcesModel } from './panels/sources/model';
|
|
13
|
+
|
|
14
|
+
import { KernelSourcesModel } from './panels/kernelSources/model';
|
|
15
|
+
|
|
16
|
+
import { VariablesModel } from './panels/variables/model';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A model for a debugger.
|
|
20
|
+
*/
|
|
21
|
+
export class DebuggerModel implements IDebugger.Model.IService {
|
|
22
|
+
/**
|
|
23
|
+
* Instantiate a new DebuggerModel
|
|
24
|
+
*/
|
|
25
|
+
constructor() {
|
|
26
|
+
this.breakpoints = new BreakpointsModel();
|
|
27
|
+
this.callstack = new CallstackModel();
|
|
28
|
+
this.variables = new VariablesModel();
|
|
29
|
+
this.sources = new SourcesModel({
|
|
30
|
+
currentFrameChanged: this.callstack.currentFrameChanged
|
|
31
|
+
});
|
|
32
|
+
this.kernelSources = new KernelSourcesModel();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The breakpoints model.
|
|
37
|
+
*/
|
|
38
|
+
readonly breakpoints: BreakpointsModel;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The callstack model.
|
|
42
|
+
*/
|
|
43
|
+
readonly callstack: CallstackModel;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The variables model.
|
|
47
|
+
*/
|
|
48
|
+
readonly variables: VariablesModel;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The sources model.
|
|
52
|
+
*/
|
|
53
|
+
readonly sources: SourcesModel;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The sources model.
|
|
57
|
+
*/
|
|
58
|
+
readonly kernelSources: KernelSourcesModel;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A signal emitted when the debugger widget is disposed.
|
|
62
|
+
*/
|
|
63
|
+
get disposed(): ISignal<this, void> {
|
|
64
|
+
return this._disposed;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Whether the kernel support rich variable rendering based on mime type.
|
|
69
|
+
*/
|
|
70
|
+
get hasRichVariableRendering(): boolean {
|
|
71
|
+
return this._hasRichVariableRendering;
|
|
72
|
+
}
|
|
73
|
+
set hasRichVariableRendering(v: boolean) {
|
|
74
|
+
this._hasRichVariableRendering = v;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Whether the model is disposed.
|
|
79
|
+
*/
|
|
80
|
+
get isDisposed(): boolean {
|
|
81
|
+
return this._isDisposed;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The set of threads in stopped state.
|
|
86
|
+
*/
|
|
87
|
+
get stoppedThreads(): Set<number> {
|
|
88
|
+
return this._stoppedThreads;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Assigns the parameters to the set of threads in stopped state.
|
|
93
|
+
*/
|
|
94
|
+
set stoppedThreads(threads: Set<number>) {
|
|
95
|
+
this._stoppedThreads = threads;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The current debugger title.
|
|
100
|
+
*/
|
|
101
|
+
get title(): string {
|
|
102
|
+
return this._title;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Set the current debugger title.
|
|
107
|
+
*/
|
|
108
|
+
set title(title: string) {
|
|
109
|
+
if (title === this._title) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this._title = title ?? '-';
|
|
113
|
+
this._titleChanged.emit(title);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A signal emitted when the title changes.
|
|
118
|
+
*/
|
|
119
|
+
get titleChanged(): ISignal<this, string> {
|
|
120
|
+
return this._titleChanged;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Dispose the model.
|
|
125
|
+
*/
|
|
126
|
+
dispose(): void {
|
|
127
|
+
if (this._isDisposed) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
this._isDisposed = true;
|
|
131
|
+
this.kernelSources.dispose();
|
|
132
|
+
this._disposed.emit();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Clear the model.
|
|
137
|
+
*/
|
|
138
|
+
clear(): void {
|
|
139
|
+
this._stoppedThreads.clear();
|
|
140
|
+
const breakpoints = new Map<string, IDebugger.IBreakpoint[]>();
|
|
141
|
+
this.breakpoints.restoreBreakpoints(breakpoints);
|
|
142
|
+
this.callstack.frames = [];
|
|
143
|
+
this.variables.scopes = [];
|
|
144
|
+
this.sources.currentSource = null;
|
|
145
|
+
this.kernelSources.kernelSources = null;
|
|
146
|
+
this.title = '-';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private _disposed = new Signal<this, void>(this);
|
|
150
|
+
private _isDisposed = false;
|
|
151
|
+
private _hasRichVariableRendering = false;
|
|
152
|
+
private _stoppedThreads = new Set<number>();
|
|
153
|
+
private _title = '-';
|
|
154
|
+
private _titleChanged = new Signal<this, string>(this);
|
|
155
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { ReactWidget } from '@jupyterlab/ui-components';
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
|
+
import { IDebugger } from '../../tokens';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The body for a Breakpoints Panel.
|
|
10
|
+
*/
|
|
11
|
+
export class BreakpointsBody extends ReactWidget {
|
|
12
|
+
/**
|
|
13
|
+
* Instantiate a new Body for the Breakpoints Panel.
|
|
14
|
+
*
|
|
15
|
+
* @param model The model for the breakpoints.
|
|
16
|
+
*/
|
|
17
|
+
constructor(model: IDebugger.Model.IBreakpoints) {
|
|
18
|
+
super();
|
|
19
|
+
this._model = model;
|
|
20
|
+
this.addClass('jp-DebuggerBreakpoints-body');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Render the BreakpointsComponent.
|
|
25
|
+
*/
|
|
26
|
+
render(): JSX.Element {
|
|
27
|
+
return <BreakpointsComponent model={this._model} />;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private _model: IDebugger.Model.IBreakpoints;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A React component to display a list of breakpoints.
|
|
35
|
+
*
|
|
36
|
+
* @param {object} props The component props.
|
|
37
|
+
* @param props.model The model for the breakpoints.
|
|
38
|
+
*/
|
|
39
|
+
const BreakpointsComponent = ({
|
|
40
|
+
model
|
|
41
|
+
}: {
|
|
42
|
+
model: IDebugger.Model.IBreakpoints;
|
|
43
|
+
}): JSX.Element => {
|
|
44
|
+
const [breakpoints, setBreakpoints] = useState(
|
|
45
|
+
Array.from(model.breakpoints.entries())
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const updateBreakpoints = (
|
|
50
|
+
_: IDebugger.Model.IBreakpoints,
|
|
51
|
+
updates: IDebugger.IBreakpoint[]
|
|
52
|
+
): void => {
|
|
53
|
+
setBreakpoints(Array.from(model.breakpoints.entries()));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const restoreBreakpoints = (_: IDebugger.Model.IBreakpoints): void => {
|
|
57
|
+
setBreakpoints(Array.from(model.breakpoints.entries()));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
model.changed.connect(updateBreakpoints);
|
|
61
|
+
model.restored.connect(restoreBreakpoints);
|
|
62
|
+
|
|
63
|
+
return (): void => {
|
|
64
|
+
model.changed.disconnect(updateBreakpoints);
|
|
65
|
+
model.restored.disconnect(restoreBreakpoints);
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<>
|
|
71
|
+
{breakpoints.map(entry => (
|
|
72
|
+
<BreakpointCellComponent
|
|
73
|
+
key={entry[0]}
|
|
74
|
+
breakpoints={entry[1]}
|
|
75
|
+
model={model}
|
|
76
|
+
/>
|
|
77
|
+
))}
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A React Component to display breakpoints grouped by source file.
|
|
84
|
+
*
|
|
85
|
+
* @param {object} props The component props.
|
|
86
|
+
* @param props.breakpoints The list of breakpoints.
|
|
87
|
+
* @param props.model The model for the breakpoints.
|
|
88
|
+
*/
|
|
89
|
+
const BreakpointCellComponent = ({
|
|
90
|
+
breakpoints,
|
|
91
|
+
model
|
|
92
|
+
}: {
|
|
93
|
+
breakpoints: IDebugger.IBreakpoint[];
|
|
94
|
+
model: IDebugger.Model.IBreakpoints;
|
|
95
|
+
}): JSX.Element => {
|
|
96
|
+
return (
|
|
97
|
+
<>
|
|
98
|
+
{breakpoints
|
|
99
|
+
.sort((a, b) => {
|
|
100
|
+
return (a.line ?? 0) - (b.line ?? 0);
|
|
101
|
+
})
|
|
102
|
+
.map((breakpoint: IDebugger.IBreakpoint, index) => (
|
|
103
|
+
<BreakpointComponent
|
|
104
|
+
key={(breakpoint.source?.path ?? '') + index}
|
|
105
|
+
breakpoint={breakpoint}
|
|
106
|
+
model={model}
|
|
107
|
+
/>
|
|
108
|
+
))}
|
|
109
|
+
</>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A React Component to display a single breakpoint.
|
|
115
|
+
*
|
|
116
|
+
* @param {object} props The component props.
|
|
117
|
+
* @param props.breakpoint The breakpoint.
|
|
118
|
+
* @param props.model The model for the breakpoints.
|
|
119
|
+
*/
|
|
120
|
+
const BreakpointComponent = ({
|
|
121
|
+
breakpoint,
|
|
122
|
+
model
|
|
123
|
+
}: {
|
|
124
|
+
breakpoint: IDebugger.IBreakpoint;
|
|
125
|
+
model: IDebugger.Model.IBreakpoints;
|
|
126
|
+
}): JSX.Element => {
|
|
127
|
+
const moveToEndFirstCharIfSlash = (breakpointSourcePath: string): string => {
|
|
128
|
+
return breakpointSourcePath[0] === '/'
|
|
129
|
+
? breakpointSourcePath.slice(1) + '/'
|
|
130
|
+
: breakpointSourcePath;
|
|
131
|
+
};
|
|
132
|
+
return (
|
|
133
|
+
<div
|
|
134
|
+
className={'jp-DebuggerBreakpoint'}
|
|
135
|
+
onClick={(): void => model.clicked.emit(breakpoint)}
|
|
136
|
+
title={breakpoint.source?.path}
|
|
137
|
+
>
|
|
138
|
+
<span className={'jp-DebuggerBreakpoint-marker'}>●</span>
|
|
139
|
+
<span className={'jp-DebuggerBreakpoint-source jp-left-truncated'}>
|
|
140
|
+
{moveToEndFirstCharIfSlash(breakpoint.source?.path ?? '')}
|
|
141
|
+
</span>
|
|
142
|
+
<span className={'jp-DebuggerBreakpoint-line'}>{breakpoint.line}</span>
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { Dialog, showDialog } from '@jupyterlab/apputils';
|
|
5
|
+
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
6
|
+
import { PanelWithToolbar, ToolbarButton } from '@jupyterlab/ui-components';
|
|
7
|
+
import { CommandRegistry } from '@lumino/commands';
|
|
8
|
+
import { Signal } from '@lumino/signaling';
|
|
9
|
+
import { Panel } from '@lumino/widgets';
|
|
10
|
+
import { closeAllIcon, exceptionIcon } from '../../icons';
|
|
11
|
+
import { IDebugger } from '../../tokens';
|
|
12
|
+
import { BreakpointsBody } from './body';
|
|
13
|
+
import { PauseOnExceptionsWidget } from './pauseonexceptions';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A Panel to show a list of breakpoints.
|
|
17
|
+
*/
|
|
18
|
+
export class Breakpoints extends PanelWithToolbar {
|
|
19
|
+
/**
|
|
20
|
+
* Instantiate a new Breakpoints Panel.
|
|
21
|
+
*
|
|
22
|
+
* @param options The instantiation options for a Breakpoints Panel.
|
|
23
|
+
*/
|
|
24
|
+
constructor(options: Breakpoints.IOptions) {
|
|
25
|
+
super(options);
|
|
26
|
+
const { model, service, commands } = options;
|
|
27
|
+
const trans = (options.translator ?? nullTranslator).load('jupyterlab');
|
|
28
|
+
this.title.label = trans.__('Breakpoints');
|
|
29
|
+
|
|
30
|
+
const body = new BreakpointsBody(model);
|
|
31
|
+
|
|
32
|
+
this.toolbar.addItem(
|
|
33
|
+
'pauseOnException',
|
|
34
|
+
new PauseOnExceptionsWidget({
|
|
35
|
+
service: service,
|
|
36
|
+
commands: commands,
|
|
37
|
+
icon: exceptionIcon,
|
|
38
|
+
tooltip: trans.__('Pause on exception filter')
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
this.toolbar.addItem(
|
|
43
|
+
'closeAll',
|
|
44
|
+
new ToolbarButton({
|
|
45
|
+
icon: closeAllIcon,
|
|
46
|
+
onClick: async (): Promise<void> => {
|
|
47
|
+
if (model.breakpoints.size === 0) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const result = await showDialog({
|
|
51
|
+
title: trans.__('Remove All Breakpoints'),
|
|
52
|
+
body: trans.__('Are you sure you want to remove all breakpoints?'),
|
|
53
|
+
buttons: [
|
|
54
|
+
Dialog.okButton({ label: trans.__('Remove breakpoints') }),
|
|
55
|
+
Dialog.cancelButton()
|
|
56
|
+
],
|
|
57
|
+
hasClose: true
|
|
58
|
+
});
|
|
59
|
+
if (result.button.accept) {
|
|
60
|
+
return service.clearBreakpoints();
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
tooltip: trans.__('Remove All Breakpoints')
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
this.addWidget(body);
|
|
68
|
+
this.addClass('jp-DebuggerBreakpoints');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
readonly clicked = new Signal<this, IDebugger.IBreakpoint>(this);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A namespace for Breakpoints `statics`.
|
|
76
|
+
*/
|
|
77
|
+
export namespace Breakpoints {
|
|
78
|
+
/**
|
|
79
|
+
* The toolbar commands and registry for the breakpoints.
|
|
80
|
+
*/
|
|
81
|
+
export interface ICommands {
|
|
82
|
+
/**
|
|
83
|
+
* The command registry.
|
|
84
|
+
*/
|
|
85
|
+
registry: CommandRegistry;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The pause on exceptions command ID.
|
|
89
|
+
*/
|
|
90
|
+
pauseOnExceptions: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Instantiation options for `Breakpoints`.
|
|
94
|
+
*/
|
|
95
|
+
export interface IOptions extends Panel.IOptions {
|
|
96
|
+
/**
|
|
97
|
+
* The breakpoints model.
|
|
98
|
+
*/
|
|
99
|
+
model: IDebugger.Model.IBreakpoints;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The debugger service.
|
|
103
|
+
*/
|
|
104
|
+
service: IDebugger;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The toolbar commands interface for the callstack.
|
|
108
|
+
*/
|
|
109
|
+
commands: ICommands;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The application language translator..
|
|
113
|
+
*/
|
|
114
|
+
translator?: ITranslator;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { ISignal, Signal } from '@lumino/signaling';
|
|
5
|
+
|
|
6
|
+
import { IDebugger } from '../../tokens';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A model for a list of breakpoints.
|
|
10
|
+
*/
|
|
11
|
+
export class BreakpointsModel implements IDebugger.Model.IBreakpoints {
|
|
12
|
+
/**
|
|
13
|
+
* Signal emitted when the model changes.
|
|
14
|
+
*/
|
|
15
|
+
get changed(): ISignal<this, IDebugger.IBreakpoint[]> {
|
|
16
|
+
return this._changed;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Signal emitted when the breakpoints are restored.
|
|
21
|
+
*/
|
|
22
|
+
get restored(): ISignal<this, void> {
|
|
23
|
+
return this._restored;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Signal emitted when a breakpoint is clicked.
|
|
28
|
+
*/
|
|
29
|
+
get clicked(): Signal<this, IDebugger.IBreakpoint> {
|
|
30
|
+
return this._clicked;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get all the breakpoints.
|
|
35
|
+
*/
|
|
36
|
+
get breakpoints(): Map<string, IDebugger.IBreakpoint[]> {
|
|
37
|
+
return this._breakpoints;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Set the breakpoints for a given id (path).
|
|
42
|
+
*
|
|
43
|
+
* @param id The code id (path).
|
|
44
|
+
* @param breakpoints The list of breakpoints.
|
|
45
|
+
*/
|
|
46
|
+
setBreakpoints(id: string, breakpoints: IDebugger.IBreakpoint[]): void {
|
|
47
|
+
this._breakpoints.set(id, breakpoints);
|
|
48
|
+
this._changed.emit(breakpoints);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get the breakpoints for a given id (path).
|
|
53
|
+
*
|
|
54
|
+
* @param id The code id (path).
|
|
55
|
+
*/
|
|
56
|
+
getBreakpoints(id: string): IDebugger.IBreakpoint[] {
|
|
57
|
+
return this._breakpoints.get(id) ?? [];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Restore a map of breakpoints.
|
|
62
|
+
*
|
|
63
|
+
* @param breakpoints The map of breakpoints
|
|
64
|
+
*/
|
|
65
|
+
restoreBreakpoints(breakpoints: Map<string, IDebugger.IBreakpoint[]>): void {
|
|
66
|
+
this._breakpoints = breakpoints;
|
|
67
|
+
this._restored.emit();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private _breakpoints = new Map<string, IDebugger.IBreakpoint[]>();
|
|
71
|
+
private _changed = new Signal<this, IDebugger.IBreakpoint[]>(this);
|
|
72
|
+
private _restored = new Signal<this, void>(this);
|
|
73
|
+
private _clicked = new Signal<this, IDebugger.IBreakpoint>(this);
|
|
74
|
+
}
|