forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filtering breakpoints on exception in debugger (jupyterlab#13601)
* Adds a filter selection to the ExceptionBreakpoints of the debugger * Add test on this feature * Disable the button if the debugger is stopped * Fix tests * fix eslint * Fix the command for the commandPalette * Fix debugger tests * Update packages/debugger/src/panels/breakpoints/index.ts Co-authored-by: Frédéric Collonval <[email protected]> * Update packages/debugger-extension/src/index.ts Co-authored-by: Frédéric Collonval <[email protected]> * Add docstring and clean the code * Fix wrong type * Replace some screenshots tests by CSS matching * Allows selecting several filters, as available from DAP * Await for gutters before select them in UI test Co-authored-by: Frédéric Collonval <[email protected]>
- Loading branch information
1 parent
88fa178
commit c725a22
Showing
17 changed files
with
438 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+4.26 KB
...ger.test.ts-snapshots/debugger-stop-on-raised-exception-documentation-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.31 KB
....test.ts-snapshots/debugger-stop-on-unhandled-exception-documentation-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+74 Bytes
(100%)
galata/test/documentation/screenshots/debugger-breakpoints.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
packages/debugger/src/panels/breakpoints/pauseonexceptions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
import * as React from 'react'; | ||
import { | ||
MenuSvg, | ||
ToolbarButton, | ||
ToolbarButtonComponent | ||
} from '@jupyterlab/ui-components'; | ||
import { IDebugger } from '../../tokens'; | ||
import { Breakpoints } from './index'; | ||
|
||
const PAUSE_ON_EXCEPTION_CLASS = 'jp-debugger-pauseOnExceptions'; | ||
const PAUSE_ON_EXCEPTION_BUTTON_CLASS = 'jp-PauseOnExceptions'; | ||
const PAUSE_ON_EXCEPTION_MENU_CLASS = 'jp-PauseOnExceptions-menu'; | ||
|
||
/** | ||
* A button which display a menu on click, to select the filter. | ||
*/ | ||
export class PauseOnExceptionsWidget extends ToolbarButton { | ||
/** | ||
* Constructor of the button. | ||
*/ | ||
constructor(props: PauseOnExceptions.IProps) { | ||
super(); | ||
this._menu = new PauseOnExceptionsMenu({ | ||
service: props.service, | ||
commands: { | ||
registry: props.commands.registry, | ||
pauseOnExceptions: props.commands.pauseOnExceptions | ||
} | ||
}); | ||
|
||
this.node.className = PAUSE_ON_EXCEPTION_CLASS; | ||
|
||
this._props = props; | ||
this._props.className = PAUSE_ON_EXCEPTION_BUTTON_CLASS; | ||
this._props.service.eventMessage.connect((_, event): void => { | ||
if (event.event === 'initialized' || event.event === 'terminated') { | ||
this.onChange(); | ||
} | ||
}, this); | ||
this._props.enabled = this._props.service.pauseOnExceptionsIsValid(); | ||
this._props.service.pauseOnExceptionChanged.connect(this.onChange, this); | ||
} | ||
|
||
/** | ||
* Called when the debugger is initialized or the filter changed. | ||
*/ | ||
onChange() { | ||
const session = this._props.service.session; | ||
const exceptionBreakpointFilters = session?.exceptionBreakpointFilters; | ||
this._props.className = PAUSE_ON_EXCEPTION_BUTTON_CLASS; | ||
if (this._props.service.session?.isStarted && exceptionBreakpointFilters) { | ||
if (session.isPausingOnException()) { | ||
this._props.className += ' lm-mod-toggled'; | ||
} | ||
this._props.enabled = true; | ||
} else { | ||
this._props.enabled = false; | ||
} | ||
this.update(); | ||
} | ||
|
||
/** | ||
* open menu on click. | ||
*/ | ||
onclick = () => { | ||
this._menu.open( | ||
this.node.getBoundingClientRect().left, | ||
this.node.getBoundingClientRect().bottom | ||
); | ||
}; | ||
|
||
render(): JSX.Element { | ||
return <ToolbarButtonComponent {...this._props} onClick={this.onclick} />; | ||
} | ||
|
||
private _menu: PauseOnExceptionsMenu; | ||
private _props: PauseOnExceptions.IProps; | ||
} | ||
|
||
/** | ||
* A menu with all the available filter from the debugger as entries. | ||
*/ | ||
export class PauseOnExceptionsMenu extends MenuSvg { | ||
/** | ||
* The constructor of the menu. | ||
*/ | ||
constructor(props: PauseOnExceptions.IProps) { | ||
super({ commands: props.commands.registry }); | ||
this._service = props.service; | ||
this._command = props.commands.pauseOnExceptions; | ||
|
||
props.service.eventMessage.connect((_, event): void => { | ||
if (event.event === 'initialized') { | ||
this._build(); | ||
} | ||
}, this); | ||
|
||
this._build(); | ||
this.addClass(PAUSE_ON_EXCEPTION_MENU_CLASS); | ||
} | ||
|
||
private _build(): void { | ||
this.clearItems(); | ||
const exceptionsBreakpointFilters = | ||
this._service.session?.exceptionBreakpointFilters ?? []; | ||
exceptionsBreakpointFilters.map((filter, _) => { | ||
this.addItem({ | ||
command: this._command, | ||
args: { | ||
filter: filter.filter, | ||
description: filter.description as string | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
private _service: IDebugger; | ||
private _command: string; | ||
} | ||
|
||
/** | ||
* A namespace for the widget. | ||
*/ | ||
export namespace PauseOnExceptions { | ||
/** | ||
* The properties of the widget and menu. | ||
*/ | ||
export interface IProps extends ToolbarButtonComponent.IProps { | ||
/** | ||
* The debugger service linked to the widget. | ||
*/ | ||
service: IDebugger; | ||
/** | ||
* The commands registry and the command ID associated to the menu. | ||
*/ | ||
commands: Breakpoints.ICommands; | ||
} | ||
} |
Oops, something went wrong.