From e94058098913ba51debcca4eba48e819f0c57835 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Wed, 17 Jun 2020 14:16:35 +0200 Subject: [PATCH 01/29] Editor handler for console and file debug --- src/handler.ts | 8 +++++--- src/handlers/console.ts | 12 +++++++++++- src/handlers/file.ts | 12 +++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/handler.ts b/src/handler.ts index c46aec13..384c76e3 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -221,13 +221,15 @@ export class DebuggerHandler { case 'console': this._handlers[widget.id] = new ConsoleHandler({ debuggerService: this._service, - widget: widget as ConsolePanel + widget: widget as ConsolePanel, + editorFinder: this._editorFinder }); break; case 'file': this._handlers[widget.id] = new FileHandler({ debuggerService: this._service, - widget: widget as DocumentWidget + widget: widget as DocumentWidget, + editorFinder: this._editorFinder }); break; default: @@ -396,7 +398,7 @@ export namespace DebuggerHandler { /** * The editor finder. */ - editorFinder?: IDebuggerEditorFinder; + editorFinder: IDebuggerEditorFinder; } /** diff --git a/src/handlers/console.ts b/src/handlers/console.ts index bfbc7cc7..88e54c31 100644 --- a/src/handlers/console.ts +++ b/src/handlers/console.ts @@ -17,6 +17,8 @@ import { EditorHandler } from '../handlers/editor'; import { IDebugger } from '../tokens'; +import { IDebuggerEditorFinder } from '../editor-finder'; + /** * A handler for consoles. */ @@ -29,6 +31,7 @@ export class ConsoleHandler implements IDisposable { constructor(options: ConsoleHandler.IOptions) { this._debuggerService = options.debuggerService; this._consolePanel = options.widget; + this._editorFinder = options.editorFinder; this._cellMap = new ObservableMap(); const codeConsole = this._consolePanel.console; @@ -76,7 +79,8 @@ export class ConsoleHandler implements IDisposable { const codeCell = cell as CodeCell; const editorHandler = new EditorHandler({ debuggerService: this._debuggerService, - editor: codeCell.editor + editor: codeCell.editor, + editorFinder: this._editorFinder }); codeCell.disposed.connect(() => { this._cellMap.delete(modelId); @@ -87,6 +91,7 @@ export class ConsoleHandler implements IDisposable { private _consolePanel: ConsolePanel; private _debuggerService: IDebugger; + private _editorFinder: IDebuggerEditorFinder; private _cellMap: IObservableMap = null; } @@ -107,5 +112,10 @@ export namespace ConsoleHandler { * The widget to handle. */ widget: ConsolePanel; + + /** + * The editor finder instance. + */ + editorFinder: IDebuggerEditorFinder; } } diff --git a/src/handlers/file.ts b/src/handlers/file.ts index 7d4c1862..dbdbe34d 100644 --- a/src/handlers/file.ts +++ b/src/handlers/file.ts @@ -13,6 +13,8 @@ import { EditorHandler } from '../handlers/editor'; import { IDebugger } from '../tokens'; +import { IDebuggerEditorFinder } from '../editor-finder'; + /** * A handler for files. */ @@ -25,10 +27,12 @@ export class FileHandler implements IDisposable { constructor(options: FileHandler.IOptions) { this._debuggerService = options.debuggerService; this._fileEditor = options.widget.content; + this._editorFinder = options.editorFinder; this._editorHandler = new EditorHandler({ debuggerService: this._debuggerService, - editor: this._fileEditor.editor + editor: this._fileEditor.editor, + editorFinder: this._editorFinder }); } @@ -50,6 +54,7 @@ export class FileHandler implements IDisposable { } private _fileEditor: FileEditor; + private _editorFinder: IDebuggerEditorFinder; private _debuggerService: IDebugger; private _editorHandler: EditorHandler; } @@ -71,5 +76,10 @@ export namespace FileHandler { * The widget to handle. */ widget: DocumentWidget; + + /** + * The editor finder instance. + */ + editorFinder: IDebuggerEditorFinder; } } From 53874c50a8303154b497b68acc50f3d39f358533 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Thu, 18 Jun 2020 17:49:52 +0200 Subject: [PATCH 02/29] Refactor editor finder related with #473 --- src/editor-finder.ts | 62 +++++++++++++++++++++++++++++------- src/handler.ts | 24 ++++---------- src/handlers/console.ts | 12 +------ src/handlers/editor.ts | 15 ++------- src/handlers/file.ts | 12 +------ src/handlers/notebook.ts | 12 +------ src/index.ts | 27 +++++++--------- src/service.ts | 68 ++++++++++++---------------------------- src/tokens.ts | 12 ++----- 9 files changed, 95 insertions(+), 149 deletions(-) diff --git a/src/editor-finder.ts b/src/editor-finder.ts index c920b090..48dfe98b 100644 --- a/src/editor-finder.ts +++ b/src/editor-finder.ts @@ -25,7 +25,7 @@ import { IDisposable } from '@lumino/disposable'; import { Signal } from '@lumino/signaling'; -import { IDebugger } from './tokens'; +import { murmur2 } from 'murmurhash-js'; /** * A class to find instances of code editors across notebook, console and files widgets @@ -38,7 +38,6 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { */ constructor(options: EditorFinder.IOptions) { this._shell = options.shell; - this._service = options.service; this._notebookTracker = options.notebookTracker; this._consoleTracker = options.consoleTracker; this._editorTracker = options.editorTracker; @@ -65,6 +64,42 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { Signal.clearData(this); } + /** + * Computes an id based on the given code. + * + * @param code The source code. + */ + public getCodeId(code: string): string { + return this._tmpFilePrefix + this._hashMethod(code) + this._tmpFileSuffix; + } + + /** + * Set the hash parameters for the current session. + * + * @param method The hash method. + * @param seed The seed for the hash method. + */ + public setHashParameters(method: string, seed: number): void { + if (method === 'Murmur2') { + this._hashMethod = (code: string): string => { + return murmur2(code, seed).toString(); + }; + } else { + throw new Error('hash method not supported ' + method); + } + } + + /** + * Set the parameters used for the temporary files (e.g. cells). + * + * @param prefix The prefix used for the temporary files. + * @param suffix The suffix used for the temporary files. + */ + public setTmpFileParameters(prefix: string, suffix: string): void { + this._tmpFilePrefix = prefix; + this._tmpFileSuffix = suffix; + } + /** * Find the editor for a source matching the current debug session * by iterating through all the widgets in each of the notebook, @@ -119,7 +154,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { cells.forEach((cell, i) => { // check the event is for the correct cell const code = cell.model.value.text; - const cellId = this._service.getCodeId(code); + const cellId = this.getCodeId(code); if (source !== cellId) { return; } @@ -161,7 +196,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { const cells = consoleWidget.console.cells; each(cells, cell => { const code = cell.model.value.text; - const codeId = this._service.getCodeId(code); + const codeId = this.getCodeId(code); if (source !== codeId) { return; } @@ -203,7 +238,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this._service.getCodeId(code); + const codeId = this.getCodeId(code); if (source !== codeId) { return; } @@ -235,7 +270,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this._service.getCodeId(code); + const codeId = this.getCodeId(code); if (widget.title.caption !== source && source !== codeId) { return; } @@ -246,7 +281,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { }); return editors; } - private _service: IDebugger; + // private _service: IDebugger; private _shell: JupyterFrontEnd.IShell; private _readOnlyEditorTracker: WidgetTracker< MainAreaWidget @@ -254,6 +289,10 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { private _notebookTracker: INotebookTracker | null; private _consoleTracker: IConsoleTracker | null; private _editorTracker: IEditorTracker | null; + + private _hashMethod: (code: string) => string; + private _tmpFilePrefix: string; + private _tmpFileSuffix: string; } /** * A namespace for editor finder statics. @@ -283,11 +322,6 @@ export namespace EditorFinder { */ notebookTracker?: INotebookTracker; - /** - * The debugger service. - */ - service: IDebugger; - /** * The application shell. */ @@ -310,4 +344,8 @@ export interface IDebuggerEditorFinder { source: string, focus: boolean ): IIterator; + + setHashParameters(method: string, seed: number): void; + setTmpFileParameters(prefix: string, suffix: string): void; + getCodeId(code: string): string; } diff --git a/src/handler.ts b/src/handler.ts index 384c76e3..dc83e504 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -31,8 +31,6 @@ import { DebugSession } from './session'; import { IDebugger } from './tokens'; -import { IDebuggerEditorFinder } from './editor-finder'; - import { ConsoleHandler } from './handlers/console'; import { FileHandler } from './handlers/file'; @@ -83,7 +81,6 @@ export class DebuggerHandler { this._type = options.type; this._shell = options.shell; this._service = options.service; - this._editorFinder = options.editorFinder; } /** @@ -214,22 +211,19 @@ export class DebuggerHandler { case 'notebook': this._handlers[widget.id] = new NotebookHandler({ debuggerService: this._service, - widget: widget as NotebookPanel, - editorFinder: this._editorFinder + widget: widget as NotebookPanel }); break; case 'console': this._handlers[widget.id] = new ConsoleHandler({ debuggerService: this._service, - widget: widget as ConsolePanel, - editorFinder: this._editorFinder + widget: widget as ConsolePanel }); break; case 'file': this._handlers[widget.id] = new FileHandler({ debuggerService: this._service, - widget: widget as DocumentWidget, - editorFinder: this._editorFinder + widget: widget as DocumentWidget }); break; default: @@ -293,7 +287,7 @@ export class DebuggerHandler { } else { this._service.session.connection = connection; this._previousConnection = connection; - await this._service.restoreState(true, this._editorFinder); + await this._service.restoreState(true); await createHandler(); } }; @@ -314,14 +308,14 @@ export class DebuggerHandler { : null; this._service.session.connection = connection; } - await this._service.restoreState(false, this._editorFinder); + await this._service.restoreState(false); addToolbarButton(); // check the state of the debug session if (!this._service.isStarted) { removeHandlers(); this._service.session.connection = this._previousConnection ?? connection; - await this._service.restoreState(false, this._editorFinder); + await this._service.restoreState(false); return; } @@ -337,7 +331,6 @@ export class DebuggerHandler { private _type: DebuggerHandler.SessionType; private _shell: JupyterFrontEnd.IShell; private _service: IDebugger; - private _editorFinder: IDebuggerEditorFinder; private _previousConnection: Session.ISessionConnection; private _handlers: { [id: string]: DebuggerHandler.SessionHandler[DebuggerHandler.SessionType]; @@ -394,11 +387,6 @@ export namespace DebuggerHandler { * The debugger service. */ service: IDebugger; - - /** - * The editor finder. - */ - editorFinder: IDebuggerEditorFinder; } /** diff --git a/src/handlers/console.ts b/src/handlers/console.ts index 88e54c31..bfbc7cc7 100644 --- a/src/handlers/console.ts +++ b/src/handlers/console.ts @@ -17,8 +17,6 @@ import { EditorHandler } from '../handlers/editor'; import { IDebugger } from '../tokens'; -import { IDebuggerEditorFinder } from '../editor-finder'; - /** * A handler for consoles. */ @@ -31,7 +29,6 @@ export class ConsoleHandler implements IDisposable { constructor(options: ConsoleHandler.IOptions) { this._debuggerService = options.debuggerService; this._consolePanel = options.widget; - this._editorFinder = options.editorFinder; this._cellMap = new ObservableMap(); const codeConsole = this._consolePanel.console; @@ -79,8 +76,7 @@ export class ConsoleHandler implements IDisposable { const codeCell = cell as CodeCell; const editorHandler = new EditorHandler({ debuggerService: this._debuggerService, - editor: codeCell.editor, - editorFinder: this._editorFinder + editor: codeCell.editor }); codeCell.disposed.connect(() => { this._cellMap.delete(modelId); @@ -91,7 +87,6 @@ export class ConsoleHandler implements IDisposable { private _consolePanel: ConsolePanel; private _debuggerService: IDebugger; - private _editorFinder: IDebuggerEditorFinder; private _cellMap: IObservableMap = null; } @@ -112,10 +107,5 @@ export namespace ConsoleHandler { * The widget to handle. */ widget: ConsolePanel; - - /** - * The editor finder instance. - */ - editorFinder: IDebuggerEditorFinder; } } diff --git a/src/handlers/editor.ts b/src/handlers/editor.ts index 2c04212e..8d413bbf 100644 --- a/src/handlers/editor.ts +++ b/src/handlers/editor.ts @@ -15,8 +15,6 @@ import { Signal } from '@lumino/signaling'; import { Editor } from 'codemirror'; -import { IDebuggerEditorFinder } from '../editor-finder'; - import { IDebugger } from '../tokens'; import { BreakpointsModel } from '../breakpoints/model'; @@ -47,7 +45,6 @@ export class EditorHandler implements IDisposable { this._path = options.path; this._debuggerService = options.debuggerService; this._editor = options.editor; - this._editorFinder = options.editorFinder; this._onModelChanged(); this._debuggerService.modelChanged.connect(this._onModelChanged, this); @@ -163,8 +160,7 @@ export class EditorHandler implements IDisposable { void this._debuggerService.updateBreakpoints( this._editor.model.value.text, breakpoints, - this._path, - this._editorFinder + this._path ); } @@ -196,8 +192,7 @@ export class EditorHandler implements IDisposable { void this._debuggerService.updateBreakpoints( this._editor.model.value.text, breakpoints, - this._path, - this._editorFinder + this._path ); }; @@ -249,7 +244,6 @@ export class EditorHandler implements IDisposable { private _id: string; private _path: string; private _editor: CodeEditor.IEditor; - private _editorFinder: IDebuggerEditorFinder; private _debuggerModel: DebuggerModel; private _breakpointsModel: BreakpointsModel; private _debuggerService: IDebugger; @@ -281,11 +275,6 @@ export namespace EditorHandler { * An optional path to a source file. */ path?: string; - - /** - * The editor finder. - */ - editorFinder?: IDebuggerEditorFinder; } /** diff --git a/src/handlers/file.ts b/src/handlers/file.ts index dbdbe34d..7d4c1862 100644 --- a/src/handlers/file.ts +++ b/src/handlers/file.ts @@ -13,8 +13,6 @@ import { EditorHandler } from '../handlers/editor'; import { IDebugger } from '../tokens'; -import { IDebuggerEditorFinder } from '../editor-finder'; - /** * A handler for files. */ @@ -27,12 +25,10 @@ export class FileHandler implements IDisposable { constructor(options: FileHandler.IOptions) { this._debuggerService = options.debuggerService; this._fileEditor = options.widget.content; - this._editorFinder = options.editorFinder; this._editorHandler = new EditorHandler({ debuggerService: this._debuggerService, - editor: this._fileEditor.editor, - editorFinder: this._editorFinder + editor: this._fileEditor.editor }); } @@ -54,7 +50,6 @@ export class FileHandler implements IDisposable { } private _fileEditor: FileEditor; - private _editorFinder: IDebuggerEditorFinder; private _debuggerService: IDebugger; private _editorHandler: EditorHandler; } @@ -76,10 +71,5 @@ export namespace FileHandler { * The widget to handle. */ widget: DocumentWidget; - - /** - * The editor finder instance. - */ - editorFinder: IDebuggerEditorFinder; } } diff --git a/src/handlers/notebook.ts b/src/handlers/notebook.ts index 7df504a8..1a636bd6 100644 --- a/src/handlers/notebook.ts +++ b/src/handlers/notebook.ts @@ -11,8 +11,6 @@ import { IDisposable } from '@lumino/disposable'; import { Signal } from '@lumino/signaling'; -import { IDebuggerEditorFinder } from '../editor-finder'; - import { EditorHandler } from './editor'; import { IDebugger } from '../tokens'; @@ -30,7 +28,6 @@ export class NotebookHandler implements IDisposable { this._debuggerService = options.debuggerService; this._notebookPanel = options.widget; this._cellMap = new ObservableMap(); - this._editorFinder = options.editorFinder; const notebook = this._notebookPanel.content; notebook.activeCellChanged.connect(this._onActiveCellChanged, this); @@ -79,8 +76,7 @@ export class NotebookHandler implements IDisposable { const codeCell = cell as CodeCell; const editorHandler = new EditorHandler({ debuggerService: this._debuggerService, - editor: codeCell.editor, - editorFinder: this._editorFinder + editor: codeCell.editor }); codeCell.disposed.connect(() => { this._cellMap.delete(modelId); @@ -103,7 +99,6 @@ export class NotebookHandler implements IDisposable { } private _debuggerService: IDebugger; - private _editorFinder: IDebuggerEditorFinder; private _notebookPanel: NotebookPanel; private _cellMap: IObservableMap = null; } @@ -125,10 +120,5 @@ export namespace NotebookHandler { * The widget to handle. */ widget: NotebookPanel; - - /** - * Editor finder object. - */ - editorFinder: IDebuggerEditorFinder; } } diff --git a/src/index.ts b/src/index.ts index 0d2b0bfe..d0d672f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -89,8 +89,7 @@ const consoles: JupyterFrontEndPlugin = { const handler = new DebuggerHandler({ type: 'console', shell: app.shell, - service: debug, - editorFinder + service: debug }); debug.model.disposed.connect(() => { handler.disposeAll(debug); @@ -128,20 +127,18 @@ const consoles: JupyterFrontEndPlugin = { const files: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:files', autoStart: true, - requires: [IDebugger, IEditorTracker, IDebuggerEditorFinder], + requires: [IDebugger, IEditorTracker], optional: [ILabShell], activate: ( app: JupyterFrontEnd, debug: IDebugger, editorTracker: IEditorTracker, - editorFinder: IDebuggerEditorFinder, labShell: ILabShell ) => { const handler = new DebuggerHandler({ type: 'file', shell: app.shell, - service: debug, - editorFinder + service: debug }); debug.model.disposed.connect(() => { handler.disposeAll(debug); @@ -202,20 +199,18 @@ const files: JupyterFrontEndPlugin = { const notebooks: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:notebooks', autoStart: true, - requires: [IDebugger, INotebookTracker, IDebuggerEditorFinder], + requires: [IDebugger, INotebookTracker], optional: [ILabShell], activate: ( app: JupyterFrontEnd, service: IDebugger, notebookTracker: INotebookTracker, - editorFinder: IDebuggerEditorFinder, labShell: ILabShell ) => { const handler = new DebuggerHandler({ type: 'notebook', shell: app.shell, - service, - editorFinder + service }); service.model.disposed.connect(() => { handler.disposeAll(service); @@ -277,8 +272,12 @@ const service: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:service', autoStart: true, provides: IDebugger, - activate: (app: JupyterFrontEnd) => - new DebuggerService({ specsManager: app.serviceManager.kernelspecs }) + requires: [IDebuggerEditorFinder], + activate: (app: JupyterFrontEnd, editorFinder: IDebuggerEditorFinder) => + new DebuggerService({ + specsManager: app.serviceManager.kernelspecs, + editorFinder + }) }; /** @@ -288,11 +287,10 @@ const finder: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:editor-finder', autoStart: true, provides: IDebuggerEditorFinder, - requires: [IDebugger, IEditorServices], + requires: [IEditorServices], optional: [INotebookTracker, IConsoleTracker, IEditorTracker], activate: ( app: JupyterFrontEnd, - service: IDebugger, editorServices: IEditorServices, notebookTracker: INotebookTracker | null, consoleTracker: IConsoleTracker | null, @@ -300,7 +298,6 @@ const finder: JupyterFrontEndPlugin = { ): IDebuggerEditorFinder => { return new EditorFinder({ shell: app.shell, - service, editorServices, notebookTracker, consoleTracker, diff --git a/src/service.ts b/src/service.ts index 9c1bb017..77ce7f1e 100644 --- a/src/service.ts +++ b/src/service.ts @@ -9,8 +9,6 @@ import { IDisposable } from '@lumino/disposable'; import { ISignal, Signal } from '@lumino/signaling'; -import { murmur2 } from 'murmurhash-js'; - import { DebugProtocol } from 'vscode-debugprotocol'; import { CallstackModel } from './callstack/model'; @@ -41,6 +39,7 @@ export class DebuggerService implements IDebugger, IDisposable { this._session = null; this._specsManager = options.specsManager; this._model = new DebuggerModel(); + this._editorFinder = options.editorFinder; } /** @@ -164,7 +163,7 @@ export class DebuggerService implements IDebugger, IDisposable { * @param code The source code. */ getCodeId(code: string): string { - return this._tmpFilePrefix + this._hashMethod(code) + this._tmpFileSuffix; + return this._editorFinder.getCodeId(code); } /** @@ -215,12 +214,8 @@ export class DebuggerService implements IDebugger, IDisposable { * Restore the state of a debug session. * * @param autoStart - If true, starts the debugger if it has not been started. - * @param editorFinder - The editor finder instance. */ - async restoreState( - autoStart: boolean, - editorFinder?: IDebuggerEditorFinder - ): Promise { + async restoreState(autoStart: boolean): Promise { if (!this.model || !this.session) { return; } @@ -230,8 +225,9 @@ export class DebuggerService implements IDebugger, IDisposable { const breakpoints = this._mapBreakpoints(reply.body.breakpoints); const stoppedThreads = new Set(reply.body.stoppedThreads); - this._setHashParameters(hashMethod, hashSeed); - this._setTmpFileParameters(tmpFilePrefix, tmpFileSuffix); + this._editorFinder.setHashParameters(hashMethod, hashSeed); + this._editorFinder.setTmpFileParameters(tmpFilePrefix, tmpFileSuffix); + this._model.stoppedThreads = stoppedThreads; if (!this.isStarted && (autoStart || stoppedThreads.size !== 0)) { @@ -242,8 +238,8 @@ export class DebuggerService implements IDebugger, IDisposable { this._model.title = this.isStarted ? this.session?.connection?.name : '-'; } - if (editorFinder) { - const filtered = this._filterBreakpoints(breakpoints, editorFinder); + if (this._editorFinder) { + const filtered = this._filterBreakpoints(breakpoints, this._editorFinder); this._model.breakpoints.restoreBreakpoints(filtered); } else { this._model.breakpoints.restoreBreakpoints(breakpoints); @@ -316,13 +312,11 @@ export class DebuggerService implements IDebugger, IDisposable { * @param code - The code in the cell where the breakpoints are set. * @param breakpoints - The list of breakpoints to set. * @param path - Optional path to the file where to set the breakpoints. - * @param editorFinder - The editor finder object */ async updateBreakpoints( code: string, breakpoints: IDebugger.IBreakpoint[], - path?: string, - editorFinder?: IDebuggerEditorFinder + path?: string ): Promise { if (!this.session.isStarted) { return; @@ -337,8 +331,11 @@ export class DebuggerService implements IDebugger, IDisposable { const remoteBreakpoints = this._mapBreakpoints(state.body.breakpoints); // Set the local copy of breakpoints to reflect only editors that exist. - if (editorFinder) { - const filtered = this._filterBreakpoints(remoteBreakpoints, editorFinder); + if (this._editorFinder) { + const filtered = this._filterBreakpoints( + remoteBreakpoints, + this._editorFinder + ); this._model.breakpoints.restoreBreakpoints(filtered); } else { this._model.breakpoints.restoreBreakpoints(remoteBreakpoints); @@ -667,33 +664,6 @@ export class DebuggerService implements IDebugger, IDisposable { return 1; } - /** - * Set the hash parameters for the current session. - * - * @param method The hash method. - * @param seed The seed for the hash method. - */ - private _setHashParameters(method: string, seed: number): void { - if (method === 'Murmur2') { - this._hashMethod = (code: string): string => { - return murmur2(code, seed).toString(); - }; - } else { - throw new Error('hash method not supported ' + method); - } - } - - /** - * Set the parameters used for the temporary files (e.g. cells). - * - * @param prefix The prefix used for the temporary files. - * @param suffix The suffix used for the temporary files. - */ - private _setTmpFileParameters(prefix: string, suffix: string): void { - this._tmpFilePrefix = prefix; - this._tmpFileSuffix = suffix; - } - private _isDisposed = false; private _session: IDebugger.ISession; private _model: DebuggerModel; @@ -702,10 +672,7 @@ export class DebuggerService implements IDebugger, IDisposable { private _eventMessage = new Signal(this); private _specsManager: KernelSpec.IManager; - - private _hashMethod: (code: string) => string; - private _tmpFilePrefix: string; - private _tmpFileSuffix: string; + private _editorFinder: IDebuggerEditorFinder; } /** @@ -720,5 +687,10 @@ export namespace DebuggerService { * The kernel specs manager. */ specsManager: KernelSpec.IManager; + + /** + * The editor finder instance. + */ + editorFinder: IDebuggerEditorFinder; } } diff --git a/src/tokens.ts b/src/tokens.ts index b3a3a514..9851dc6f 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -5,8 +5,6 @@ import { KernelMessage, Session } from '@jupyterlab/services'; import { Token } from '@lumino/coreutils'; -import { IDebuggerEditorFinder } from './editor-finder'; - import { IObservableDisposable } from '@lumino/disposable'; import { ISignal } from '@lumino/signaling'; @@ -87,12 +85,8 @@ export interface IDebugger { * * @param autoStart - when true, starts the debugger * if it has not been started yet. - * @param editorFinder - The editor finder instance */ - restoreState( - autoStart: boolean, - editorFinder?: IDebuggerEditorFinder - ): Promise; + restoreState(autoStart: boolean): Promise; /** * Continues the execution of the current thread. @@ -120,13 +114,11 @@ export interface IDebugger { * @param code - The code in the cell where the breakpoints are set. * @param breakpoints - The list of breakpoints to set. * @param path - Optional path to the file where to set the breakpoints. - * @param editorFinder - The editor finder object. */ updateBreakpoints( code: string, breakpoints: IDebugger.IBreakpoint[], - path?: string, - editorFinder?: IDebuggerEditorFinder + path?: string ): Promise; /** From c2d2e1670efe54d546688870a0b3c216441059b5 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Thu, 18 Jun 2020 18:03:22 +0200 Subject: [PATCH 03/29] Optional param for service (test case) --- src/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service.ts b/src/service.ts index 77ce7f1e..f6365001 100644 --- a/src/service.ts +++ b/src/service.ts @@ -691,6 +691,6 @@ export namespace DebuggerService { /** * The editor finder instance. */ - editorFinder: IDebuggerEditorFinder; + editorFinder?: IDebuggerEditorFinder; } } From 903cb46594905273c0192b132657bb803991774a Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Thu, 18 Jun 2020 18:12:57 +0200 Subject: [PATCH 04/29] nullish and undefined editor finder instance prevent --- src/service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/service.ts b/src/service.ts index f6365001..c38f505f 100644 --- a/src/service.ts +++ b/src/service.ts @@ -163,7 +163,7 @@ export class DebuggerService implements IDebugger, IDisposable { * @param code The source code. */ getCodeId(code: string): string { - return this._editorFinder.getCodeId(code); + return this._editorFinder.getCodeId(code) ?? ''; } /** @@ -225,8 +225,10 @@ export class DebuggerService implements IDebugger, IDisposable { const breakpoints = this._mapBreakpoints(reply.body.breakpoints); const stoppedThreads = new Set(reply.body.stoppedThreads); - this._editorFinder.setHashParameters(hashMethod, hashSeed); - this._editorFinder.setTmpFileParameters(tmpFilePrefix, tmpFileSuffix); + if (this._editorFinder) { + this._editorFinder.setHashParameters(hashMethod, hashSeed); + this._editorFinder.setTmpFileParameters(tmpFilePrefix, tmpFileSuffix); + } this._model.stoppedThreads = stoppedThreads; From e80b42567bfd8b0daeb7c3d2b1be0f3f3599d3c3 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Thu, 18 Jun 2020 18:28:00 +0200 Subject: [PATCH 05/29] Test --- src/service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service.ts b/src/service.ts index c38f505f..2442b094 100644 --- a/src/service.ts +++ b/src/service.ts @@ -163,7 +163,7 @@ export class DebuggerService implements IDebugger, IDisposable { * @param code The source code. */ getCodeId(code: string): string { - return this._editorFinder.getCodeId(code) ?? ''; + return this._editorFinder?.getCodeId(code) ?? ''; } /** @@ -674,7 +674,7 @@ export class DebuggerService implements IDebugger, IDisposable { private _eventMessage = new Signal(this); private _specsManager: KernelSpec.IManager; - private _editorFinder: IDebuggerEditorFinder; + private _editorFinder: IDebuggerEditorFinder | null; } /** From 0c5bbbe912d47fb02d2c0a2cce22a027e5bd05ff Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Fri, 19 Jun 2020 12:20:46 +0200 Subject: [PATCH 06/29] Separated class for hash method. --- src/editor-finder.ts | 61 ++++++------------------------- src/index.ts | 29 ++++++++++++--- src/parameters-mixer.ts | 81 +++++++++++++++++++++++++++++++++++++++++ src/service.ts | 17 ++++++--- test/service.spec.ts | 13 ++++++- 5 files changed, 140 insertions(+), 61 deletions(-) create mode 100644 src/parameters-mixer.ts diff --git a/src/editor-finder.ts b/src/editor-finder.ts index 48dfe98b..4e38584e 100644 --- a/src/editor-finder.ts +++ b/src/editor-finder.ts @@ -25,7 +25,7 @@ import { IDisposable } from '@lumino/disposable'; import { Signal } from '@lumino/signaling'; -import { murmur2 } from 'murmurhash-js'; +import { IDebuggerParametersMixer } from './parameters-mixer'; /** * A class to find instances of code editors across notebook, console and files widgets @@ -41,6 +41,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { this._notebookTracker = options.notebookTracker; this._consoleTracker = options.consoleTracker; this._editorTracker = options.editorTracker; + this._parametersMixer = options.parametersMixer; this._readOnlyEditorTracker = new WidgetTracker< MainAreaWidget >({ @@ -64,42 +65,6 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { Signal.clearData(this); } - /** - * Computes an id based on the given code. - * - * @param code The source code. - */ - public getCodeId(code: string): string { - return this._tmpFilePrefix + this._hashMethod(code) + this._tmpFileSuffix; - } - - /** - * Set the hash parameters for the current session. - * - * @param method The hash method. - * @param seed The seed for the hash method. - */ - public setHashParameters(method: string, seed: number): void { - if (method === 'Murmur2') { - this._hashMethod = (code: string): string => { - return murmur2(code, seed).toString(); - }; - } else { - throw new Error('hash method not supported ' + method); - } - } - - /** - * Set the parameters used for the temporary files (e.g. cells). - * - * @param prefix The prefix used for the temporary files. - * @param suffix The suffix used for the temporary files. - */ - public setTmpFileParameters(prefix: string, suffix: string): void { - this._tmpFilePrefix = prefix; - this._tmpFileSuffix = suffix; - } - /** * Find the editor for a source matching the current debug session * by iterating through all the widgets in each of the notebook, @@ -154,7 +119,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { cells.forEach((cell, i) => { // check the event is for the correct cell const code = cell.model.value.text; - const cellId = this.getCodeId(code); + const cellId = this._parametersMixer.getCodeId(code); if (source !== cellId) { return; } @@ -196,7 +161,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { const cells = consoleWidget.console.cells; each(cells, cell => { const code = cell.model.value.text; - const codeId = this.getCodeId(code); + const codeId = this._parametersMixer.getCodeId(code); if (source !== codeId) { return; } @@ -238,7 +203,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this.getCodeId(code); + const codeId = this._parametersMixer.getCodeId(code); if (source !== codeId) { return; } @@ -270,7 +235,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this.getCodeId(code); + const codeId = this._parametersMixer.getCodeId(code); if (widget.title.caption !== source && source !== codeId) { return; } @@ -289,10 +254,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { private _notebookTracker: INotebookTracker | null; private _consoleTracker: IConsoleTracker | null; private _editorTracker: IEditorTracker | null; - - private _hashMethod: (code: string) => string; - private _tmpFilePrefix: string; - private _tmpFileSuffix: string; + private _parametersMixer: IDebuggerParametersMixer; } /** * A namespace for editor finder statics. @@ -326,6 +288,11 @@ export namespace EditorFinder { * The application shell. */ shell: JupyterFrontEnd.IShell; + + /** + * The instance of parameters mixer with hash method. + */ + parametersMixer: IDebuggerParametersMixer; } /** * A token for a editor finder handler find method plugin @@ -344,8 +311,4 @@ export interface IDebuggerEditorFinder { source: string, focus: boolean ): IIterator; - - setHashParameters(method: string, seed: number): void; - setTmpFileParameters(prefix: string, suffix: string): void; - getCodeId(code: string): string; } diff --git a/src/index.ts b/src/index.ts index d0d672f5..a7061dbc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,6 +54,8 @@ import { DebuggerModel } from './model'; import { VariablesBodyGrid } from './variables/grid'; +import { IDebuggerParametersMixer, ParametersMixer } from './parameters-mixer'; + /** * The command IDs used by the debugger plugin. */ @@ -272,14 +274,28 @@ const service: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:service', autoStart: true, provides: IDebugger, - requires: [IDebuggerEditorFinder], - activate: (app: JupyterFrontEnd, editorFinder: IDebuggerEditorFinder) => + requires: [IDebuggerEditorFinder, IDebuggerParametersMixer], + activate: ( + app: JupyterFrontEnd, + editorFinder: IDebuggerEditorFinder, + parametersMixer: IDebuggerParametersMixer + ) => new DebuggerService({ specsManager: app.serviceManager.kernelspecs, - editorFinder + editorFinder, + parametersMixer }) }; +/** + * A plugin that provides a parameters mixer with hash method. + */ +const mixer: JupyterFrontEndPlugin = { + id: '@jupyterlab/debugger:parameters-mixer', + autoStart: true, + activate: () => new ParametersMixer() +}; + /** * A plugin that tracks editors, console and file editors used for debugging. */ @@ -287,11 +303,12 @@ const finder: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:editor-finder', autoStart: true, provides: IDebuggerEditorFinder, - requires: [IEditorServices], + requires: [IEditorServices, IDebuggerParametersMixer], optional: [INotebookTracker, IConsoleTracker, IEditorTracker], activate: ( app: JupyterFrontEnd, editorServices: IEditorServices, + parametersMixer: IDebuggerParametersMixer, notebookTracker: INotebookTracker | null, consoleTracker: IConsoleTracker | null, editorTracker: IEditorTracker | null @@ -299,6 +316,7 @@ const finder: JupyterFrontEndPlugin = { return new EditorFinder({ shell: app.shell, editorServices, + parametersMixer, notebookTracker, consoleTracker, editorTracker @@ -559,7 +577,8 @@ const plugins: JupyterFrontEndPlugin[] = [ tracker, variables, main, - finder + finder, + mixer ]; export default plugins; diff --git a/src/parameters-mixer.ts b/src/parameters-mixer.ts new file mode 100644 index 00000000..9c95efc0 --- /dev/null +++ b/src/parameters-mixer.ts @@ -0,0 +1,81 @@ +// Copyright (c) Jupyter Development Team. +// Distributed under the terms of the Modified BSD License. + +import { Token } from '@lumino/coreutils'; + +import { Signal } from '@lumino/signaling'; + +import { murmur2 } from 'murmurhash-js'; + +/** + * A class to hash code. + */ +export class ParametersMixer implements IDebuggerParametersMixer { + /** + * Whether the handler is disposed. + */ + isDisposed: boolean; + + /** + * Dispose the objects. + */ + dispose(): void { + if (this.isDisposed) { + return; + } + this.isDisposed = true; + Signal.clearData(this); + } + + /** + * Computes an id based on the given code. + * + * @param code The source code. + */ + public getCodeId(code: string): string { + return this._tmpFilePrefix + this._hashMethod(code) + this._tmpFileSuffix; + } + + /** + * Set the hash parameters for the current session. + * + * @param method The hash method. + * @param seed The seed for the hash method. + */ + public setHashParameters(method: string, seed: number): void { + if (method === 'Murmur2') { + this._hashMethod = (code: string): string => { + return murmur2(code, seed).toString(); + }; + } else { + throw new Error('hash method not supported ' + method); + } + } + + /** + * Set the parameters used for the temporary files (e.g. cells). + * + * @param prefix The prefix used for the temporary files. + * @param suffix The suffix used for the temporary files. + */ + public setTmpFileParameters(prefix: string, suffix: string): void { + this._tmpFilePrefix = prefix; + this._tmpFileSuffix = suffix; + } + + private _hashMethod: (code: string) => string; + private _tmpFilePrefix: string; + private _tmpFileSuffix: string; +} + +export const IDebuggerParametersMixer = new Token( + '@jupyterlab/debugger:parameters-mixer' +); +/** + * Interface for parameters mixer plugin + */ +export interface IDebuggerParametersMixer { + setHashParameters(method: string, seed: number): void; + setTmpFileParameters(prefix: string, suffix: string): void; + getCodeId(code: string): string; +} diff --git a/src/service.ts b/src/service.ts index 2442b094..cc7c7898 100644 --- a/src/service.ts +++ b/src/service.ts @@ -21,6 +21,8 @@ import { IDebuggerEditorFinder } from './editor-finder'; import { VariablesModel } from './variables/model'; +import { IDebuggerParametersMixer } from './parameters-mixer'; + /** * A concrete implementation of IDebugger. */ @@ -40,6 +42,7 @@ export class DebuggerService implements IDebugger, IDisposable { this._specsManager = options.specsManager; this._model = new DebuggerModel(); this._editorFinder = options.editorFinder; + this._parametersMixer = options.parametersMixer; } /** @@ -163,7 +166,7 @@ export class DebuggerService implements IDebugger, IDisposable { * @param code The source code. */ getCodeId(code: string): string { - return this._editorFinder?.getCodeId(code) ?? ''; + return this._parametersMixer.getCodeId(code); } /** @@ -225,10 +228,8 @@ export class DebuggerService implements IDebugger, IDisposable { const breakpoints = this._mapBreakpoints(reply.body.breakpoints); const stoppedThreads = new Set(reply.body.stoppedThreads); - if (this._editorFinder) { - this._editorFinder.setHashParameters(hashMethod, hashSeed); - this._editorFinder.setTmpFileParameters(tmpFilePrefix, tmpFileSuffix); - } + this._parametersMixer.setHashParameters(hashMethod, hashSeed); + this._parametersMixer.setTmpFileParameters(tmpFilePrefix, tmpFileSuffix); this._model.stoppedThreads = stoppedThreads; @@ -675,6 +676,7 @@ export class DebuggerService implements IDebugger, IDisposable { private _specsManager: KernelSpec.IManager; private _editorFinder: IDebuggerEditorFinder | null; + private _parametersMixer: IDebuggerParametersMixer; } /** @@ -694,5 +696,10 @@ export namespace DebuggerService { * The editor finder instance. */ editorFinder?: IDebuggerEditorFinder; + + /** + * The parameters mixer instance with hash method. + */ + parametersMixer: IDebuggerParametersMixer; } } diff --git a/test/service.spec.ts b/test/service.spec.ts index e0292755..6a6d4104 100644 --- a/test/service.spec.ts +++ b/test/service.spec.ts @@ -21,6 +21,11 @@ import { IDebugger } from '../src/tokens'; import { KERNELSPECS, handleRequest } from './utils'; +import { + IDebuggerParametersMixer, + ParametersMixer +} from '../src/parameters-mixer'; + /** * A Test class to mock a KernelSpecManager */ @@ -54,6 +59,7 @@ describe('Debugging support', () => { let specsManager: TestKernelSpecManager; let service: DebuggerService; + let parametersMixer: IDebuggerParametersMixer; let xpython: Session.ISessionConnection; let ipykernel: Session.ISessionConnection; @@ -75,7 +81,8 @@ describe('Debugging support', () => { specsManager = new TestKernelSpecManager({ standby: 'never' }); specsManager.intercept = specs; await specsManager.refreshSpecs(); - service = new DebuggerService({ specsManager }); + parametersMixer = new ParametersMixer(); + service = new DebuggerService({ specsManager, parametersMixer }); }); afterAll(async () => { @@ -101,6 +108,7 @@ describe('DebuggerService', () => { const specsManager = new KernelSpecManager(); let connection: Session.ISessionConnection; let model: DebuggerModel; + let parametersMixer: IDebuggerParametersMixer; let session: IDebugger.ISession; let service: IDebugger; @@ -113,7 +121,8 @@ describe('DebuggerService', () => { await connection.changeKernel({ name: 'xpython' }); session = new DebugSession({ connection }); model = new DebuggerModel(); - service = new DebuggerService({ specsManager }); + parametersMixer = new ParametersMixer(); + service = new DebuggerService({ specsManager, parametersMixer }); }); afterEach(async () => { From 57af03b7c21952972b1de0284d968b92a7cfb23a Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Fri, 19 Jun 2020 12:22:46 +0200 Subject: [PATCH 07/29] Two line From 3dc3dec75babc64bee27bd40a93816a28378057b Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Fri, 19 Jun 2020 12:28:14 +0200 Subject: [PATCH 08/29] Debugger test changed --- test/debugger.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/debugger.spec.ts b/test/debugger.spec.ts index 1f39fe96..054fd887 100644 --- a/test/debugger.spec.ts +++ b/test/debugger.spec.ts @@ -13,6 +13,8 @@ import { Debugger } from '../src/debugger'; import { DebuggerService } from '../src/service'; +import { ParametersMixer } from '../src/parameters-mixer'; + /** * A test sidebar. */ @@ -31,7 +33,8 @@ afterAll(async () => { describe('Debugger', () => { const specsManager = new KernelSpecManager(); - const service = new DebuggerService({ specsManager }); + const parametersMixer = new ParametersMixer(); + const service = new DebuggerService({ specsManager, parametersMixer }); const registry = new CommandRegistry(); const factoryService = new CodeMirrorEditorFactory(); const mimeTypeService = new CodeMirrorMimeTypeService(); From 1f8512ec5cbb3a4969f472d77ae2be671f010943 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Tue, 23 Jun 2020 15:25:58 +0200 Subject: [PATCH 09/29] Provider error solved --- src/editor-finder.ts | 1 - src/index.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor-finder.ts b/src/editor-finder.ts index 4e38584e..3b761619 100644 --- a/src/editor-finder.ts +++ b/src/editor-finder.ts @@ -246,7 +246,6 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { }); return editors; } - // private _service: IDebugger; private _shell: JupyterFrontEnd.IShell; private _readOnlyEditorTracker: WidgetTracker< MainAreaWidget diff --git a/src/index.ts b/src/index.ts index a7061dbc..92f7aa51 100644 --- a/src/index.ts +++ b/src/index.ts @@ -292,6 +292,7 @@ const service: JupyterFrontEndPlugin = { */ const mixer: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:parameters-mixer', + provides: IDebuggerParametersMixer, autoStart: true, activate: () => new ParametersMixer() }; From 2af814bfe0515c1cdd6f664d71a55e62ddc4416c Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Tue, 23 Jun 2020 15:35:08 +0200 Subject: [PATCH 10/29] Return provider --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 92f7aa51..bbd4d726 100644 --- a/src/index.ts +++ b/src/index.ts @@ -294,7 +294,7 @@ const mixer: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:parameters-mixer', provides: IDebuggerParametersMixer, autoStart: true, - activate: () => new ParametersMixer() + activate: (): IDebuggerParametersMixer => new ParametersMixer() }; /** From 946c793df8aef33edf90be186782bc8216eec62d Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Wed, 24 Jun 2020 11:15:31 +0200 Subject: [PATCH 11/29] Refactored name --- ...ers-mixer.ts => debugger-configuration.ts} | 10 +++---- src/editor-finder.ts | 18 ++++++------ src/index.ts | 29 ++++++++++--------- src/service.ts | 19 +++++++----- test/debugger.spec.ts | 6 ++-- test/service.spec.ts | 18 ++++++------ 6 files changed, 53 insertions(+), 47 deletions(-) rename src/{parameters-mixer.ts => debugger-configuration.ts} (86%) diff --git a/src/parameters-mixer.ts b/src/debugger-configuration.ts similarity index 86% rename from src/parameters-mixer.ts rename to src/debugger-configuration.ts index 9c95efc0..6d1ef86e 100644 --- a/src/parameters-mixer.ts +++ b/src/debugger-configuration.ts @@ -10,7 +10,7 @@ import { murmur2 } from 'murmurhash-js'; /** * A class to hash code. */ -export class ParametersMixer implements IDebuggerParametersMixer { +export class DebuggerConfiguration implements IDebuggerConfig { /** * Whether the handler is disposed. */ @@ -68,13 +68,13 @@ export class ParametersMixer implements IDebuggerParametersMixer { private _tmpFileSuffix: string; } -export const IDebuggerParametersMixer = new Token( - '@jupyterlab/debugger:parameters-mixer' +export const IDebuggerConfig = new Token( + '@jupyterlab/debugger:configuration' ); /** - * Interface for parameters mixer plugin + * Interface for configuration plugin */ -export interface IDebuggerParametersMixer { +export interface IDebuggerConfig { setHashParameters(method: string, seed: number): void; setTmpFileParameters(prefix: string, suffix: string): void; getCodeId(code: string): string; diff --git a/src/editor-finder.ts b/src/editor-finder.ts index 3b761619..53013933 100644 --- a/src/editor-finder.ts +++ b/src/editor-finder.ts @@ -25,7 +25,7 @@ import { IDisposable } from '@lumino/disposable'; import { Signal } from '@lumino/signaling'; -import { IDebuggerParametersMixer } from './parameters-mixer'; +import { IDebuggerConfig } from './debugger-configuration'; /** * A class to find instances of code editors across notebook, console and files widgets @@ -41,7 +41,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { this._notebookTracker = options.notebookTracker; this._consoleTracker = options.consoleTracker; this._editorTracker = options.editorTracker; - this._parametersMixer = options.parametersMixer; + this._debuggerConfiguration = options.debuggerConfiguration; this._readOnlyEditorTracker = new WidgetTracker< MainAreaWidget >({ @@ -119,7 +119,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { cells.forEach((cell, i) => { // check the event is for the correct cell const code = cell.model.value.text; - const cellId = this._parametersMixer.getCodeId(code); + const cellId = this._debuggerConfiguration.getCodeId(code); if (source !== cellId) { return; } @@ -161,7 +161,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { const cells = consoleWidget.console.cells; each(cells, cell => { const code = cell.model.value.text; - const codeId = this._parametersMixer.getCodeId(code); + const codeId = this._debuggerConfiguration.getCodeId(code); if (source !== codeId) { return; } @@ -203,7 +203,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this._parametersMixer.getCodeId(code); + const codeId = this._debuggerConfiguration.getCodeId(code); if (source !== codeId) { return; } @@ -235,7 +235,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this._parametersMixer.getCodeId(code); + const codeId = this._debuggerConfiguration.getCodeId(code); if (widget.title.caption !== source && source !== codeId) { return; } @@ -253,7 +253,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { private _notebookTracker: INotebookTracker | null; private _consoleTracker: IConsoleTracker | null; private _editorTracker: IEditorTracker | null; - private _parametersMixer: IDebuggerParametersMixer; + private _debuggerConfiguration: IDebuggerConfig; } /** * A namespace for editor finder statics. @@ -289,9 +289,9 @@ export namespace EditorFinder { shell: JupyterFrontEnd.IShell; /** - * The instance of parameters mixer with hash method. + * The instance of configuration with hash method. */ - parametersMixer: IDebuggerParametersMixer; + debuggerConfiguration: IDebuggerConfig; } /** * A token for a editor finder handler find method plugin diff --git a/src/index.ts b/src/index.ts index bbd4d726..fa705bfa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,7 +54,10 @@ import { DebuggerModel } from './model'; import { VariablesBodyGrid } from './variables/grid'; -import { IDebuggerParametersMixer, ParametersMixer } from './parameters-mixer'; +import { + IDebuggerConfig, + DebuggerConfiguration +} from './debugger-configuration'; /** * The command IDs used by the debugger plugin. @@ -274,27 +277,27 @@ const service: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:service', autoStart: true, provides: IDebugger, - requires: [IDebuggerEditorFinder, IDebuggerParametersMixer], + requires: [IDebuggerEditorFinder, IDebuggerConfig], activate: ( app: JupyterFrontEnd, editorFinder: IDebuggerEditorFinder, - parametersMixer: IDebuggerParametersMixer + debuggerConfiguration: IDebuggerConfig ) => new DebuggerService({ specsManager: app.serviceManager.kernelspecs, editorFinder, - parametersMixer + debuggerConfiguration }) }; /** - * A plugin that provides a parameters mixer with hash method. + * A plugin that provides a configuration with hash method. */ -const mixer: JupyterFrontEndPlugin = { - id: '@jupyterlab/debugger:parameters-mixer', - provides: IDebuggerParametersMixer, +const configuration: JupyterFrontEndPlugin = { + id: '@jupyterlab/debugger:configuration', + provides: IDebuggerConfig, autoStart: true, - activate: (): IDebuggerParametersMixer => new ParametersMixer() + activate: (): IDebuggerConfig => new DebuggerConfiguration() }; /** @@ -304,12 +307,12 @@ const finder: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:editor-finder', autoStart: true, provides: IDebuggerEditorFinder, - requires: [IEditorServices, IDebuggerParametersMixer], + requires: [IEditorServices, IDebuggerConfig], optional: [INotebookTracker, IConsoleTracker, IEditorTracker], activate: ( app: JupyterFrontEnd, editorServices: IEditorServices, - parametersMixer: IDebuggerParametersMixer, + debuggerConfiguration: IDebuggerConfig, notebookTracker: INotebookTracker | null, consoleTracker: IConsoleTracker | null, editorTracker: IEditorTracker | null @@ -317,7 +320,7 @@ const finder: JupyterFrontEndPlugin = { return new EditorFinder({ shell: app.shell, editorServices, - parametersMixer, + debuggerConfiguration, notebookTracker, consoleTracker, editorTracker @@ -579,7 +582,7 @@ const plugins: JupyterFrontEndPlugin[] = [ variables, main, finder, - mixer + configuration ]; export default plugins; diff --git a/src/service.ts b/src/service.ts index cc7c7898..492856eb 100644 --- a/src/service.ts +++ b/src/service.ts @@ -21,7 +21,7 @@ import { IDebuggerEditorFinder } from './editor-finder'; import { VariablesModel } from './variables/model'; -import { IDebuggerParametersMixer } from './parameters-mixer'; +import { IDebuggerConfig } from './debugger-configuration'; /** * A concrete implementation of IDebugger. @@ -42,7 +42,7 @@ export class DebuggerService implements IDebugger, IDisposable { this._specsManager = options.specsManager; this._model = new DebuggerModel(); this._editorFinder = options.editorFinder; - this._parametersMixer = options.parametersMixer; + this._debuggerConfiguration = options.debuggerConfiguration; } /** @@ -166,7 +166,7 @@ export class DebuggerService implements IDebugger, IDisposable { * @param code The source code. */ getCodeId(code: string): string { - return this._parametersMixer.getCodeId(code); + return this._debuggerConfiguration.getCodeId(code); } /** @@ -228,8 +228,11 @@ export class DebuggerService implements IDebugger, IDisposable { const breakpoints = this._mapBreakpoints(reply.body.breakpoints); const stoppedThreads = new Set(reply.body.stoppedThreads); - this._parametersMixer.setHashParameters(hashMethod, hashSeed); - this._parametersMixer.setTmpFileParameters(tmpFilePrefix, tmpFileSuffix); + this._debuggerConfiguration.setHashParameters(hashMethod, hashSeed); + this._debuggerConfiguration.setTmpFileParameters( + tmpFilePrefix, + tmpFileSuffix + ); this._model.stoppedThreads = stoppedThreads; @@ -676,7 +679,7 @@ export class DebuggerService implements IDebugger, IDisposable { private _specsManager: KernelSpec.IManager; private _editorFinder: IDebuggerEditorFinder | null; - private _parametersMixer: IDebuggerParametersMixer; + private _debuggerConfiguration: IDebuggerConfig; } /** @@ -698,8 +701,8 @@ export namespace DebuggerService { editorFinder?: IDebuggerEditorFinder; /** - * The parameters mixer instance with hash method. + * The configuration instance with hash method. */ - parametersMixer: IDebuggerParametersMixer; + debuggerConfiguration: IDebuggerConfig; } } diff --git a/test/debugger.spec.ts b/test/debugger.spec.ts index 054fd887..d1ecdcef 100644 --- a/test/debugger.spec.ts +++ b/test/debugger.spec.ts @@ -13,7 +13,7 @@ import { Debugger } from '../src/debugger'; import { DebuggerService } from '../src/service'; -import { ParametersMixer } from '../src/parameters-mixer'; +import { DebuggerConfiguration } from '../src/debugger-configuration'; /** * A test sidebar. @@ -33,8 +33,8 @@ afterAll(async () => { describe('Debugger', () => { const specsManager = new KernelSpecManager(); - const parametersMixer = new ParametersMixer(); - const service = new DebuggerService({ specsManager, parametersMixer }); + const debuggerConfiguration = new DebuggerConfiguration(); + const service = new DebuggerService({ specsManager, debuggerConfiguration }); const registry = new CommandRegistry(); const factoryService = new CodeMirrorEditorFactory(); const mimeTypeService = new CodeMirrorMimeTypeService(); diff --git a/test/service.spec.ts b/test/service.spec.ts index 6a6d4104..424c7c0a 100644 --- a/test/service.spec.ts +++ b/test/service.spec.ts @@ -22,9 +22,9 @@ import { IDebugger } from '../src/tokens'; import { KERNELSPECS, handleRequest } from './utils'; import { - IDebuggerParametersMixer, - ParametersMixer -} from '../src/parameters-mixer'; + DebuggerConfiguration, + IDebuggerConfig +} from '../src/debugger-configuration'; /** * A Test class to mock a KernelSpecManager @@ -59,7 +59,7 @@ describe('Debugging support', () => { let specsManager: TestKernelSpecManager; let service: DebuggerService; - let parametersMixer: IDebuggerParametersMixer; + let debuggerConfiguration: IDebuggerConfig; let xpython: Session.ISessionConnection; let ipykernel: Session.ISessionConnection; @@ -81,8 +81,8 @@ describe('Debugging support', () => { specsManager = new TestKernelSpecManager({ standby: 'never' }); specsManager.intercept = specs; await specsManager.refreshSpecs(); - parametersMixer = new ParametersMixer(); - service = new DebuggerService({ specsManager, parametersMixer }); + debuggerConfiguration = new DebuggerConfiguration(); + service = new DebuggerService({ specsManager, debuggerConfiguration }); }); afterAll(async () => { @@ -108,7 +108,7 @@ describe('DebuggerService', () => { const specsManager = new KernelSpecManager(); let connection: Session.ISessionConnection; let model: DebuggerModel; - let parametersMixer: IDebuggerParametersMixer; + let debuggerConfiguration: IDebuggerConfig; let session: IDebugger.ISession; let service: IDebugger; @@ -121,8 +121,8 @@ describe('DebuggerService', () => { await connection.changeKernel({ name: 'xpython' }); session = new DebugSession({ connection }); model = new DebuggerModel(); - parametersMixer = new ParametersMixer(); - service = new DebuggerService({ specsManager, parametersMixer }); + debuggerConfiguration = new DebuggerConfiguration(); + service = new DebuggerService({ specsManager, debuggerConfiguration }); }); afterEach(async () => { From 5e74dc35aaf7f79dd45f2d3159729926776003be Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Wed, 24 Jun 2020 12:17:40 +0200 Subject: [PATCH 12/29] Refactor _filterBreakpoints method\ --- src/service.ts | 46 ++++++++++++---------------------------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/src/service.ts b/src/service.ts index 492856eb..c7975885 100644 --- a/src/service.ts +++ b/src/service.ts @@ -245,7 +245,7 @@ export class DebuggerService implements IDebugger, IDisposable { } if (this._editorFinder) { - const filtered = this._filterBreakpoints(breakpoints, this._editorFinder); + const filtered = this._filterBreakpoints(breakpoints); this._model.breakpoints.restoreBreakpoints(filtered); } else { this._model.breakpoints.restoreBreakpoints(breakpoints); @@ -338,10 +338,7 @@ export class DebuggerService implements IDebugger, IDisposable { // Set the local copy of breakpoints to reflect only editors that exist. if (this._editorFinder) { - const filtered = this._filterBreakpoints( - remoteBreakpoints, - this._editorFinder - ); + const filtered = this._filterBreakpoints(remoteBreakpoints); this._model.breakpoints.restoreBreakpoints(filtered); } else { this._model.breakpoints.restoreBreakpoints(remoteBreakpoints); @@ -421,40 +418,21 @@ export class DebuggerService implements IDebugger, IDisposable { * @param editorFinder - The editor finder object. */ private _filterBreakpoints( - breakpoints: Map, - editorFinder: IDebuggerEditorFinder + breakpoints: Map ): Map { const path = this._session.connection.path; - const associatedBreakpoints = ( - remoteBreakpoints: Map, - editorFinder: IDebuggerEditorFinder - ): string[] => { - const associatedBreakpoints: string[] = []; - for (const [key, value] of remoteBreakpoints) { - each(editorFinder.find(path, key, false), () => { - if (value.length > 0) { - associatedBreakpoints.push(key); - } - }); - } - return associatedBreakpoints; - }; - - const breakpointsForRestore = ( - breakpoints: Map, - editorFinder: IDebuggerEditorFinder - ): Map => { - let bpMapForRestore = new Map(); - associatedBreakpoints(breakpoints, editorFinder).forEach(path => { - Array.from(breakpoints.entries()).forEach(value => { - if (value[0] === path) { - bpMapForRestore.set(value[0], breakpoints.get(value[0])); + let bpMapForRestore = new Map(); + for (let collection of breakpoints) { + const [id, list] = collection; + list.forEach(() => { + each(this._editorFinder.find(path, id, false), () => { + if (list.length > 0) { + bpMapForRestore.set(id, list); } }); }); - return bpMapForRestore; - }; - return breakpointsForRestore(breakpoints, editorFinder); + } + return bpMapForRestore; } /** From 4f21ea1147ef53ef2c6c492aca18bf191472c082 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Wed, 24 Jun 2020 12:29:17 +0200 Subject: [PATCH 13/29] Doc string correction --- src/service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/service.ts b/src/service.ts index c7975885..54fe6b94 100644 --- a/src/service.ts +++ b/src/service.ts @@ -415,7 +415,6 @@ export class DebuggerService implements IDebugger, IDisposable { * * @param breakpoints - Map of breakpoints. * - * @param editorFinder - The editor finder object. */ private _filterBreakpoints( breakpoints: Map From 7114c374196b6fb6ac941be3494f359435cd4f9d Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Tue, 30 Jun 2020 13:48:29 +0200 Subject: [PATCH 14/29] Multiple kernels hash parameters solution --- src/debugger-configuration.ts | 30 +++++++++++++++++++-------- src/editor-finder.ts | 39 ++++++++++++++++++++++------------- src/handlers/tracker.ts | 22 ++++++++++++++------ src/service.ts | 25 ++++++++++++++++------ 4 files changed, 81 insertions(+), 35 deletions(-) diff --git a/src/debugger-configuration.ts b/src/debugger-configuration.ts index 6d1ef86e..0213be4f 100644 --- a/src/debugger-configuration.ts +++ b/src/debugger-configuration.ts @@ -31,9 +31,14 @@ export class DebuggerConfiguration implements IDebuggerConfig { * Computes an id based on the given code. * * @param code The source code. + * @param kernelName The kernel name from current session. */ - public getCodeId(code: string): string { - return this._tmpFilePrefix + this._hashMethod(code) + this._tmpFileSuffix; + public getCodeId(code: string, kernelName: string): string { + return ( + this._tmpFileAssociatedWithKernel.get(kernelName)[0] + + this._hashMethod(code) + + this._tmpFileAssociatedWithKernel.get(kernelName)[1] + ); } /** @@ -57,15 +62,18 @@ export class DebuggerConfiguration implements IDebuggerConfig { * * @param prefix The prefix used for the temporary files. * @param suffix The suffix used for the temporary files. + * @param kernelName The kernel name from current session. */ - public setTmpFileParameters(prefix: string, suffix: string): void { - this._tmpFilePrefix = prefix; - this._tmpFileSuffix = suffix; + public setTmpFileParameters( + prefix: string, + suffix: string, + kernelName: string + ): void { + this._tmpFileAssociatedWithKernel.set(kernelName, [prefix, suffix]); } private _hashMethod: (code: string) => string; - private _tmpFilePrefix: string; - private _tmpFileSuffix: string; + private _tmpFileAssociatedWithKernel = new Map(); } export const IDebuggerConfig = new Token( @@ -76,6 +84,10 @@ export const IDebuggerConfig = new Token( */ export interface IDebuggerConfig { setHashParameters(method: string, seed: number): void; - setTmpFileParameters(prefix: string, suffix: string): void; - getCodeId(code: string): string; + setTmpFileParameters( + prefix: string, + suffix: string, + kernelName: string + ): void; + getCodeId(code: string, kernelName: string): string; } diff --git a/src/editor-finder.ts b/src/editor-finder.ts index 53013933..81cb0824 100644 --- a/src/editor-finder.ts +++ b/src/editor-finder.ts @@ -73,17 +73,19 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { * @param debugSessionPath The path for the current debug session. * @param source The source to find. * @param focus - Set to true to focus on the relevant cell. Default to false. + * @param kernelName The kernel name of current session. */ find( debugSessionPath: string, source: string, - focus: boolean + focus: boolean, + kernelName: string ): IIterator { return chain( - this._findInNotebooks(debugSessionPath, source, focus), - this._findInConsoles(debugSessionPath, source, focus), - this._findInEditors(debugSessionPath, source, focus), - this._findInReadOnlyEditors(debugSessionPath, source, focus) + this._findInNotebooks(debugSessionPath, source, focus, kernelName), + this._findInConsoles(debugSessionPath, source, focus, kernelName), + this._findInEditors(debugSessionPath, source, focus, kernelName), + this._findInReadOnlyEditors(debugSessionPath, source, focus, kernelName) ); } @@ -93,11 +95,13 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { * @param debugSessionPath The path for the current debug session. * @param source The source to find. * @param focus - Set to true to focus on the relevant cell. Default to false. + * @param kernelName The kernel name from current session. */ private _findInNotebooks( debugSessionPath: string, source: string, - focus: boolean + focus: boolean, + kernelName: string ): CodeEditor.IEditor[] { if (!this._notebookTracker) { return []; @@ -119,7 +123,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { cells.forEach((cell, i) => { // check the event is for the correct cell const code = cell.model.value.text; - const cellId = this._debuggerConfiguration.getCodeId(code); + const cellId = this._debuggerConfiguration.getCodeId(code, kernelName); if (source !== cellId) { return; } @@ -141,11 +145,13 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { * @param debugSessionPath The path for the current debug session. * @param source The source to find. * @param focus - Set to true to focus on the relevant cell. Default to false. + * @param kernelName The kernel name from current session. */ private _findInConsoles( debugSessionPath: string, source: string, - focus: boolean + focus: boolean, + kernelName: string ): CodeEditor.IEditor[] { if (!this._consoleTracker) { return []; @@ -161,7 +167,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { const cells = consoleWidget.console.cells; each(cells, cell => { const code = cell.model.value.text; - const codeId = this._debuggerConfiguration.getCodeId(code); + const codeId = this._debuggerConfiguration.getCodeId(code, kernelName); if (source !== codeId) { return; } @@ -181,11 +187,13 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { * @param debugSessionPath The path for the current debug session. * @param source The source to find. * @param focus - Set to true to focus on the relevant cell. Default to false. + * @param kernelName The kernel name from current session. */ private _findInEditors( debugSessionPath: string, source: string, - focus: boolean + focus: boolean, + kernelName: string ): CodeEditor.IEditor[] { if (!this._editorTracker) { return; @@ -203,7 +211,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this._debuggerConfiguration.getCodeId(code); + const codeId = this._debuggerConfiguration.getCodeId(code, kernelName); if (source !== codeId) { return; } @@ -221,11 +229,13 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { * @param debugSessionPath The path for the current debug session. * @param source The source to find. * @param focus Set to true to focus on the relevant cell. Default to false. + * @param kernelName The kernel name from current session. */ private _findInReadOnlyEditors( debugSessionPath: string, source: string, - focus: boolean + focus: boolean, + kernelName: string ): CodeEditor.IEditor[] { const editors: CodeEditor.IEditor[] = []; this._readOnlyEditorTracker.forEach(widget => { @@ -235,7 +245,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this._debuggerConfiguration.getCodeId(code); + const codeId = this._debuggerConfiguration.getCodeId(code, kernelName); if (widget.title.caption !== source && source !== codeId) { return; } @@ -308,6 +318,7 @@ export interface IDebuggerEditorFinder { find( debugSessionPath: string, source: string, - focus: boolean + focus: boolean, + kernelName: string ): IIterator; } diff --git a/src/handlers/tracker.ts b/src/handlers/tracker.ts index d1b1bdf9..a4a7ad3f 100644 --- a/src/handlers/tracker.ts +++ b/src/handlers/tracker.ts @@ -124,11 +124,15 @@ export class TrackerHandler implements IDisposable { ): void { const debugSessionPath = this._debuggerService.session?.connection?.path; const source = frame?.source.path ?? null; - each(this._editorFinder.find(debugSessionPath, source, true), editor => { - requestAnimationFrame(() => { - EditorHandler.showCurrentLine(editor, frame.line); - }); - }); + const kernelName = this._debuggerService.session.connection.kernel.name; + each( + this._editorFinder.find(debugSessionPath, source, true, kernelName), + editor => { + requestAnimationFrame(() => { + EditorHandler.showCurrentLine(editor, frame.line); + }); + } + ); } /** @@ -146,7 +150,13 @@ export class TrackerHandler implements IDisposable { } const debugSessionPath = this._debuggerService.session.connection.path; const { content, mimeType, path } = source; - const results = this._editorFinder.find(debugSessionPath, path, false); + const kernelName = this._debuggerService.session.connection.kernel.name; + const results = this._editorFinder.find( + debugSessionPath, + path, + false, + kernelName + ); if (results.next()) { return; } diff --git a/src/service.ts b/src/service.ts index 54fe6b94..729fa255 100644 --- a/src/service.ts +++ b/src/service.ts @@ -166,7 +166,10 @@ export class DebuggerService implements IDebugger, IDisposable { * @param code The source code. */ getCodeId(code: string): string { - return this._debuggerConfiguration.getCodeId(code); + return this._debuggerConfiguration.getCodeId( + code, + this.session.connection.kernel.name + ); } /** @@ -227,11 +230,13 @@ export class DebuggerService implements IDebugger, IDisposable { const { hashMethod, hashSeed, tmpFilePrefix, tmpFileSuffix } = reply.body; const breakpoints = this._mapBreakpoints(reply.body.breakpoints); const stoppedThreads = new Set(reply.body.stoppedThreads); + const kernelName = this.session.connection.kernel.name; this._debuggerConfiguration.setHashParameters(hashMethod, hashSeed); this._debuggerConfiguration.setTmpFileParameters( tmpFilePrefix, - tmpFileSuffix + tmpFileSuffix, + kernelName ); this._model.stoppedThreads = stoppedThreads; @@ -424,11 +429,19 @@ export class DebuggerService implements IDebugger, IDisposable { for (let collection of breakpoints) { const [id, list] = collection; list.forEach(() => { - each(this._editorFinder.find(path, id, false), () => { - if (list.length > 0) { - bpMapForRestore.set(id, list); + each( + this._editorFinder.find( + path, + id, + false, + this.session.connection.kernel.name + ), + () => { + if (list.length > 0) { + bpMapForRestore.set(id, list); + } } - }); + ); }); } return bpMapForRestore; From 531ebf33553de170566faa51e366ca2462f853b1 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Tue, 30 Jun 2020 14:36:05 +0200 Subject: [PATCH 15/29] Attempt of work around test error --- src/debugger-configuration.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/debugger-configuration.ts b/src/debugger-configuration.ts index 0213be4f..f8dc634f 100644 --- a/src/debugger-configuration.ts +++ b/src/debugger-configuration.ts @@ -35,9 +35,9 @@ export class DebuggerConfiguration implements IDebuggerConfig { */ public getCodeId(code: string, kernelName: string): string { return ( - this._tmpFileAssociatedWithKernel.get(kernelName)[0] + + this._tmpFileAssociatedWithKernel.get(kernelName || 'no_kernel')[0] + this._hashMethod(code) + - this._tmpFileAssociatedWithKernel.get(kernelName)[1] + this._tmpFileAssociatedWithKernel.get(kernelName || 'no_kernel')[1] ); } @@ -69,7 +69,10 @@ export class DebuggerConfiguration implements IDebuggerConfig { suffix: string, kernelName: string ): void { - this._tmpFileAssociatedWithKernel.set(kernelName, [prefix, suffix]); + this._tmpFileAssociatedWithKernel.set(kernelName || 'no_kernel', [ + prefix, + suffix + ]); } private _hashMethod: (code: string) => string; From 8ba174f29ca00331f95cacd13a6bc75be80b3e8d Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Tue, 30 Jun 2020 15:38:59 +0200 Subject: [PATCH 16/29] Revert work around --- src/debugger-configuration.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/debugger-configuration.ts b/src/debugger-configuration.ts index f8dc634f..0213be4f 100644 --- a/src/debugger-configuration.ts +++ b/src/debugger-configuration.ts @@ -35,9 +35,9 @@ export class DebuggerConfiguration implements IDebuggerConfig { */ public getCodeId(code: string, kernelName: string): string { return ( - this._tmpFileAssociatedWithKernel.get(kernelName || 'no_kernel')[0] + + this._tmpFileAssociatedWithKernel.get(kernelName)[0] + this._hashMethod(code) + - this._tmpFileAssociatedWithKernel.get(kernelName || 'no_kernel')[1] + this._tmpFileAssociatedWithKernel.get(kernelName)[1] ); } @@ -69,10 +69,7 @@ export class DebuggerConfiguration implements IDebuggerConfig { suffix: string, kernelName: string ): void { - this._tmpFileAssociatedWithKernel.set(kernelName || 'no_kernel', [ - prefix, - suffix - ]); + this._tmpFileAssociatedWithKernel.set(kernelName, [prefix, suffix]); } private _hashMethod: (code: string) => string; From fdb4e0331f29bbc9bcfd5ba9ecebccf67f93ef44 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Tue, 7 Jul 2020 16:58:19 +0200 Subject: [PATCH 17/29] Kernel name to setHashParameters --- src/debugger-configuration.ts | 23 ++++++++++++++++------- src/service.ts | 6 +++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/debugger-configuration.ts b/src/debugger-configuration.ts index 0213be4f..2075b699 100644 --- a/src/debugger-configuration.ts +++ b/src/debugger-configuration.ts @@ -46,14 +46,23 @@ export class DebuggerConfiguration implements IDebuggerConfig { * * @param method The hash method. * @param seed The seed for the hash method. + * @param kernelName Kernel name for algorithm selection */ - public setHashParameters(method: string, seed: number): void { - if (method === 'Murmur2') { - this._hashMethod = (code: string): string => { - return murmur2(code, seed).toString(); - }; + public setHashParameters( + method: string, + seed: number, + kernelName: string + ): void { + if (kernelName === 'xpython') { + if (method === 'Murmur2') { + this._hashMethod = (code: string): string => { + return murmur2(code, seed).toString(); + }; + } else { + throw new Error('hash method not supported ' + method); + } } else { - throw new Error('hash method not supported ' + method); + throw new Error('Kernel not supported ' + kernelName); } } @@ -83,7 +92,7 @@ export const IDebuggerConfig = new Token( * Interface for configuration plugin */ export interface IDebuggerConfig { - setHashParameters(method: string, seed: number): void; + setHashParameters(method: string, seed: number, kernelName: string): void; setTmpFileParameters( prefix: string, suffix: string, diff --git a/src/service.ts b/src/service.ts index 729fa255..c5ceab88 100644 --- a/src/service.ts +++ b/src/service.ts @@ -232,7 +232,11 @@ export class DebuggerService implements IDebugger, IDisposable { const stoppedThreads = new Set(reply.body.stoppedThreads); const kernelName = this.session.connection.kernel.name; - this._debuggerConfiguration.setHashParameters(hashMethod, hashSeed); + this._debuggerConfiguration.setHashParameters( + hashMethod, + hashSeed, + kernelName + ); this._debuggerConfiguration.setTmpFileParameters( tmpFilePrefix, tmpFileSuffix, From 96561f56c67ed9c25c596b53ab99538c500b6eb9 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Thu, 9 Jul 2020 16:24:02 +0200 Subject: [PATCH 18/29] Refactor of parameters for method --- src/debugger-configuration.ts | 95 +++++++++++++++++++--------- src/editor-finder.ts | 112 ++++++++++++++++------------------ src/handlers/tracker.ts | 15 +++-- src/service.ts | 24 ++++---- 4 files changed, 139 insertions(+), 107 deletions(-) diff --git a/src/debugger-configuration.ts b/src/debugger-configuration.ts index 2075b699..5b85e9c0 100644 --- a/src/debugger-configuration.ts +++ b/src/debugger-configuration.ts @@ -8,7 +8,7 @@ import { Signal } from '@lumino/signaling'; import { murmur2 } from 'murmurhash-js'; /** - * A class to hash code. + * A class that holds debugger configuration for a kernel. */ export class DebuggerConfiguration implements IDebuggerConfig { /** @@ -35,31 +35,26 @@ export class DebuggerConfiguration implements IDebuggerConfig { */ public getCodeId(code: string, kernelName: string): string { return ( - this._tmpFileAssociatedWithKernel.get(kernelName)[0] + + this._tmpFileAssociatedWithKernel.get(kernelName).tmpFilePrefix + this._hashMethod(code) + - this._tmpFileAssociatedWithKernel.get(kernelName)[1] + this._tmpFileAssociatedWithKernel.get(kernelName).tmpFileSuffix ); } /** * Set the hash parameters for the current session. * - * @param method The hash method. - * @param seed The seed for the hash method. - * @param kernelName Kernel name for algorithm selection + * @param hashParams - Unified parameters for hash method */ - public setHashParameters( - method: string, - seed: number, - kernelName: string - ): void { + public setHashParameters(hashParams: IHashParameters): void { + const { kernelName, hashMethod, hashSeed } = hashParams; if (kernelName === 'xpython') { - if (method === 'Murmur2') { + if (hashMethod === 'Murmur2') { this._hashMethod = (code: string): string => { - return murmur2(code, seed).toString(); + return murmur2(code, hashSeed).toString(); }; } else { - throw new Error('hash method not supported ' + method); + throw new Error('hash method not supported ' + hashMethod); } } else { throw new Error('Kernel not supported ' + kernelName); @@ -69,20 +64,64 @@ export class DebuggerConfiguration implements IDebuggerConfig { /** * Set the parameters used for the temporary files (e.g. cells). * - * @param prefix The prefix used for the temporary files. - * @param suffix The suffix used for the temporary files. - * @param kernelName The kernel name from current session. + * @param fileParams - Unified parameters for mapping */ - public setTmpFileParameters( - prefix: string, - suffix: string, - kernelName: string - ): void { - this._tmpFileAssociatedWithKernel.set(kernelName, [prefix, suffix]); + public setTmpFileParameters(fileParams: ITmpFileParameters): void { + const { kernelName, tmpFilePrefix, tmpFileSuffix } = fileParams; + this._tmpFileAssociatedWithKernel.set(kernelName, { + tmpFilePrefix, + tmpFileSuffix + }); } private _hashMethod: (code: string) => string; - private _tmpFileAssociatedWithKernel = new Map(); + private _tmpFileAssociatedWithKernel = new Map(); +} + +/** + * Interface with unified parameters of method for mapping temporary file. + * + */ +interface ITmpFileParameters extends IFileParameters { + /** + * Name of current kernel. + */ + kernelName: string; +} + +/** + * Interface with prefix and suffix for map. + */ +interface IFileParameters { + /** + * Prefix of temporary file. + */ + tmpFilePrefix: string; + + /** + * Suffix of temporary file. + */ + tmpFileSuffix: string; +} + +/** + * Interface with unified parameters of hashing method. + */ +interface IHashParameters { + /** + * Type of hash method. + */ + hashMethod: string; + + /** + * Hash seed + */ + hashSeed: number; + + /** + * Name of current kernel. + */ + kernelName: string; } export const IDebuggerConfig = new Token( @@ -92,11 +131,7 @@ export const IDebuggerConfig = new Token( * Interface for configuration plugin */ export interface IDebuggerConfig { - setHashParameters(method: string, seed: number, kernelName: string): void; - setTmpFileParameters( - prefix: string, - suffix: string, - kernelName: string - ): void; + setHashParameters(hashParams: IHashParameters): void; + setTmpFileParameters(fileParams: ITmpFileParameters): void; getCodeId(code: string, kernelName: string): string; } diff --git a/src/editor-finder.ts b/src/editor-finder.ts index 81cb0824..4a438ed6 100644 --- a/src/editor-finder.ts +++ b/src/editor-finder.ts @@ -70,42 +70,28 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { * by iterating through all the widgets in each of the notebook, * console, file editor, and read-only file editor trackers. * - * @param debugSessionPath The path for the current debug session. - * @param source The source to find. - * @param focus - Set to true to focus on the relevant cell. Default to false. - * @param kernelName The kernel name of current session. + * @param findParams - Unified parameters for a source matching */ - find( - debugSessionPath: string, - source: string, - focus: boolean, - kernelName: string - ): IIterator { + find(findParams: IFindParameters): IIterator { return chain( - this._findInNotebooks(debugSessionPath, source, focus, kernelName), - this._findInConsoles(debugSessionPath, source, focus, kernelName), - this._findInEditors(debugSessionPath, source, focus, kernelName), - this._findInReadOnlyEditors(debugSessionPath, source, focus, kernelName) + this._findInNotebooks(findParams), + this._findInConsoles(findParams), + this._findInEditors(findParams), + this._findInReadOnlyEditors(findParams) ); } /** * Find the editor for a source matching the current debug session * - * @param debugSessionPath The path for the current debug session. - * @param source The source to find. - * @param focus - Set to true to focus on the relevant cell. Default to false. - * @param kernelName The kernel name from current session. + * @param findParams - Unified parameters for a source matching */ - private _findInNotebooks( - debugSessionPath: string, - source: string, - focus: boolean, - kernelName: string - ): CodeEditor.IEditor[] { + private _findInNotebooks(findParams: IFindParameters): CodeEditor.IEditor[] { if (!this._notebookTracker) { return []; } + const { debugSessionPath, source, focus, kernelName } = findParams; + const editors: CodeEditor.IEditor[] = []; this._notebookTracker.forEach(notebookPanel => { const sessionContext = notebookPanel.sessionContext; @@ -142,20 +128,14 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { /** * Find the editor for a source matching the current debug session * - * @param debugSessionPath The path for the current debug session. - * @param source The source to find. - * @param focus - Set to true to focus on the relevant cell. Default to false. - * @param kernelName The kernel name from current session. + * @param findParams - Unified parameters for a source matching */ - private _findInConsoles( - debugSessionPath: string, - source: string, - focus: boolean, - kernelName: string - ): CodeEditor.IEditor[] { + private _findInConsoles(findParams: IFindParameters): CodeEditor.IEditor[] { if (!this._consoleTracker) { return []; } + const { debugSessionPath, source, focus, kernelName } = findParams; + const editors: CodeEditor.IEditor[] = []; this._consoleTracker.forEach(consoleWidget => { const sessionContext = consoleWidget.sessionContext; @@ -184,20 +164,14 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { * Find the editor for a source matching the current debug session * from the editor tracker. * - * @param debugSessionPath The path for the current debug session. - * @param source The source to find. - * @param focus - Set to true to focus on the relevant cell. Default to false. - * @param kernelName The kernel name from current session. + * @param findParams - Unified parameters for a source matching */ - private _findInEditors( - debugSessionPath: string, - source: string, - focus: boolean, - kernelName: string - ): CodeEditor.IEditor[] { + private _findInEditors(findParams: IFindParameters): CodeEditor.IEditor[] { if (!this._editorTracker) { return; } + const { debugSessionPath, source, focus, kernelName } = findParams; + const editors: CodeEditor.IEditor[] = []; this._editorTracker.forEach(doc => { const fileEditor = doc.content; @@ -226,17 +200,13 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { /** * Find an editor for a source from the read-only editor tracker. * - * @param debugSessionPath The path for the current debug session. - * @param source The source to find. - * @param focus Set to true to focus on the relevant cell. Default to false. - * @param kernelName The kernel name from current session. + * @param findParams - Unified parameters for a source matching */ private _findInReadOnlyEditors( - debugSessionPath: string, - source: string, - focus: boolean, - kernelName: string + findParams: IFindParameters ): CodeEditor.IEditor[] { + const { source, focus, kernelName } = findParams; + const editors: CodeEditor.IEditor[] = []; this._readOnlyEditorTracker.forEach(widget => { const editor = widget.content?.editor; @@ -303,22 +273,44 @@ export namespace EditorFinder { */ debuggerConfiguration: IDebuggerConfig; } +} + +/** + * Unified parameters for find method + */ +interface IFindParameters { /** - * A token for a editor finder handler find method plugin - * + * Path of session connection. */ + debugSessionPath: string; + + /** + * Source path + */ + source: string; + + /** + * Extra flag prevent disable focus. + */ + focus: boolean; + + /** + * Name of current kernel. + */ + kernelName: string; } + +/** + * A token for a editor finder handler find method plugin + * + */ export const IDebuggerEditorFinder = new Token( '@jupyterlab/debugger:editor-finder' ); + /** * Interface for separated find method from editor finder plugin */ export interface IDebuggerEditorFinder { - find( - debugSessionPath: string, - source: string, - focus: boolean, - kernelName: string - ): IIterator; + find(findParams: IFindParameters): IIterator; } diff --git a/src/handlers/tracker.ts b/src/handlers/tracker.ts index a4a7ad3f..69af7b73 100644 --- a/src/handlers/tracker.ts +++ b/src/handlers/tracker.ts @@ -126,7 +126,12 @@ export class TrackerHandler implements IDisposable { const source = frame?.source.path ?? null; const kernelName = this._debuggerService.session.connection.kernel.name; each( - this._editorFinder.find(debugSessionPath, source, true, kernelName), + this._editorFinder.find({ + debugSessionPath, + source, + focus: true, + kernelName + }), editor => { requestAnimationFrame(() => { EditorHandler.showCurrentLine(editor, frame.line); @@ -151,12 +156,12 @@ export class TrackerHandler implements IDisposable { const debugSessionPath = this._debuggerService.session.connection.path; const { content, mimeType, path } = source; const kernelName = this._debuggerService.session.connection.kernel.name; - const results = this._editorFinder.find( + const results = this._editorFinder.find({ debugSessionPath, - path, - false, + source: path, + focus: false, kernelName - ); + }); if (results.next()) { return; } diff --git a/src/service.ts b/src/service.ts index c5ceab88..c7a46145 100644 --- a/src/service.ts +++ b/src/service.ts @@ -231,17 +231,16 @@ export class DebuggerService implements IDebugger, IDisposable { const breakpoints = this._mapBreakpoints(reply.body.breakpoints); const stoppedThreads = new Set(reply.body.stoppedThreads); const kernelName = this.session.connection.kernel.name; - - this._debuggerConfiguration.setHashParameters( + this._debuggerConfiguration.setHashParameters({ hashMethod, hashSeed, kernelName - ); - this._debuggerConfiguration.setTmpFileParameters( + }); + this._debuggerConfiguration.setTmpFileParameters({ tmpFilePrefix, tmpFileSuffix, kernelName - ); + }); this._model.stoppedThreads = stoppedThreads; @@ -428,18 +427,19 @@ export class DebuggerService implements IDebugger, IDisposable { private _filterBreakpoints( breakpoints: Map ): Map { - const path = this._session.connection.path; + const debugSessionPath = this._session.connection.path; + const kernelName = this.session.connection.kernel.name; let bpMapForRestore = new Map(); for (let collection of breakpoints) { const [id, list] = collection; list.forEach(() => { each( - this._editorFinder.find( - path, - id, - false, - this.session.connection.kernel.name - ), + this._editorFinder.find({ + debugSessionPath, + source: id, + focus: false, + kernelName + }), () => { if (list.length > 0) { bpMapForRestore.set(id, list); From 9ed4f17658e5bf22e022dc11376b7cf333b39087 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Fri, 19 Jun 2020 12:22:46 +0200 Subject: [PATCH 19/29] Two line From 1681f752f2b9ed796dfab9c57f0feeaf79c1313a Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Fri, 10 Jul 2020 03:24:06 +0100 Subject: [PATCH 20/29] Some clean up and refactoring --- src/debugger-configuration.ts | 137 ---------------------------------- src/debugger.ts | 69 +++++++++++++++++ src/editor-finder.ts | 29 ++++--- src/index.ts | 33 ++++---- src/service.ts | 42 +++++------ src/tokens.ts | 63 +++++++++++++++- 6 files changed, 174 insertions(+), 199 deletions(-) delete mode 100644 src/debugger-configuration.ts diff --git a/src/debugger-configuration.ts b/src/debugger-configuration.ts deleted file mode 100644 index 5b85e9c0..00000000 --- a/src/debugger-configuration.ts +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) Jupyter Development Team. -// Distributed under the terms of the Modified BSD License. - -import { Token } from '@lumino/coreutils'; - -import { Signal } from '@lumino/signaling'; - -import { murmur2 } from 'murmurhash-js'; - -/** - * A class that holds debugger configuration for a kernel. - */ -export class DebuggerConfiguration implements IDebuggerConfig { - /** - * Whether the handler is disposed. - */ - isDisposed: boolean; - - /** - * Dispose the objects. - */ - dispose(): void { - if (this.isDisposed) { - return; - } - this.isDisposed = true; - Signal.clearData(this); - } - - /** - * Computes an id based on the given code. - * - * @param code The source code. - * @param kernelName The kernel name from current session. - */ - public getCodeId(code: string, kernelName: string): string { - return ( - this._tmpFileAssociatedWithKernel.get(kernelName).tmpFilePrefix + - this._hashMethod(code) + - this._tmpFileAssociatedWithKernel.get(kernelName).tmpFileSuffix - ); - } - - /** - * Set the hash parameters for the current session. - * - * @param hashParams - Unified parameters for hash method - */ - public setHashParameters(hashParams: IHashParameters): void { - const { kernelName, hashMethod, hashSeed } = hashParams; - if (kernelName === 'xpython') { - if (hashMethod === 'Murmur2') { - this._hashMethod = (code: string): string => { - return murmur2(code, hashSeed).toString(); - }; - } else { - throw new Error('hash method not supported ' + hashMethod); - } - } else { - throw new Error('Kernel not supported ' + kernelName); - } - } - - /** - * Set the parameters used for the temporary files (e.g. cells). - * - * @param fileParams - Unified parameters for mapping - */ - public setTmpFileParameters(fileParams: ITmpFileParameters): void { - const { kernelName, tmpFilePrefix, tmpFileSuffix } = fileParams; - this._tmpFileAssociatedWithKernel.set(kernelName, { - tmpFilePrefix, - tmpFileSuffix - }); - } - - private _hashMethod: (code: string) => string; - private _tmpFileAssociatedWithKernel = new Map(); -} - -/** - * Interface with unified parameters of method for mapping temporary file. - * - */ -interface ITmpFileParameters extends IFileParameters { - /** - * Name of current kernel. - */ - kernelName: string; -} - -/** - * Interface with prefix and suffix for map. - */ -interface IFileParameters { - /** - * Prefix of temporary file. - */ - tmpFilePrefix: string; - - /** - * Suffix of temporary file. - */ - tmpFileSuffix: string; -} - -/** - * Interface with unified parameters of hashing method. - */ -interface IHashParameters { - /** - * Type of hash method. - */ - hashMethod: string; - - /** - * Hash seed - */ - hashSeed: number; - - /** - * Name of current kernel. - */ - kernelName: string; -} - -export const IDebuggerConfig = new Token( - '@jupyterlab/debugger:configuration' -); -/** - * Interface for configuration plugin - */ -export interface IDebuggerConfig { - setHashParameters(hashParams: IHashParameters): void; - setTmpFileParameters(fileParams: ITmpFileParameters): void; - getCodeId(code: string, kernelName: string): string; -} diff --git a/src/debugger.ts b/src/debugger.ts index c09132d5..a2ecada3 100644 --- a/src/debugger.ts +++ b/src/debugger.ts @@ -5,8 +5,12 @@ import { IEditorServices } from '@jupyterlab/codeeditor'; import { bugIcon } from '@jupyterlab/ui-components'; +import { Signal } from '@lumino/signaling'; + import { Panel, SplitPanel, Widget } from '@lumino/widgets'; +import { murmur2 } from 'murmurhash-js'; + import { Breakpoints } from './breakpoints'; import { Callstack } from './callstack'; @@ -25,6 +29,71 @@ import { Variables } from './variables'; * A namespace for `Debugger` statics. */ export namespace Debugger { + /** + * A class that holds debugger configuration for a kernel. + */ + export class Config implements IDebugger.IConfig { + /** + * Whether the handler is disposed. + */ + isDisposed: boolean; + + /** + * Dispose the objects. + */ + dispose(): void { + if (this.isDisposed) { + return; + } + this.isDisposed = true; + Signal.clearData(this); + } + + /** + * Computes an id based on the given code. + * + * @param code The source code. + * @param kernel The kernel name from current session. + */ + getCodeId(code: string, kernel: string): string { + const { prefix, suffix } = this._fileParams.get(kernel); + return `${prefix}${this._hashMethod(code)}${suffix}`; + } + + /** + * Set the hash parameters for a kernel. + * + * @param params - Hashing parameters for a kernel. + */ + public setHashParams(params: IDebugger.IConfig.HashParams): void { + const { kernel, method, seed } = params; + if (kernel === 'xpython') { + if (method === 'Murmur2') { + this._hashMethod = (code: string): string => { + return murmur2(code, seed).toString(); + }; + } else { + throw new Error('hash method not supported ' + method); + } + } else { + throw new Error('Kernel not supported ' + kernel); + } + } + + /** + * Set the parameters used for the temporary files (e.g. cells). + * + * @param params - Temporary file prefix and suffix for a kernel. + */ + public setTmpFileParams(params: IDebugger.IConfig.FileParams): void { + const { kernel, prefix, suffix } = params; + this._fileParams.set(kernel, { kernel, prefix, suffix }); + } + + private _fileParams = new Map(); + private _hashMethod: (code: string) => string; + } + /** * A debugger sidebar. */ diff --git a/src/editor-finder.ts b/src/editor-finder.ts index 4a438ed6..54e646b6 100644 --- a/src/editor-finder.ts +++ b/src/editor-finder.ts @@ -25,7 +25,7 @@ import { IDisposable } from '@lumino/disposable'; import { Signal } from '@lumino/signaling'; -import { IDebuggerConfig } from './debugger-configuration'; +import { IDebugger } from './tokens'; /** * A class to find instances of code editors across notebook, console and files widgets @@ -37,16 +37,14 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { * @param options The instantiation options for a EditorFinder. */ constructor(options: EditorFinder.IOptions) { + this._config = options.config; this._shell = options.shell; this._notebookTracker = options.notebookTracker; this._consoleTracker = options.consoleTracker; this._editorTracker = options.editorTracker; - this._debuggerConfiguration = options.debuggerConfiguration; this._readOnlyEditorTracker = new WidgetTracker< MainAreaWidget - >({ - namespace: '@jupyterlab/debugger' - }); + >({ namespace: '@jupyterlab/debugger' }); } /** @@ -109,7 +107,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { cells.forEach((cell, i) => { // check the event is for the correct cell const code = cell.model.value.text; - const cellId = this._debuggerConfiguration.getCodeId(code, kernelName); + const cellId = this._config.getCodeId(code, kernelName); if (source !== cellId) { return; } @@ -147,7 +145,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { const cells = consoleWidget.console.cells; each(cells, cell => { const code = cell.model.value.text; - const codeId = this._debuggerConfiguration.getCodeId(code, kernelName); + const codeId = this._config.getCodeId(code, kernelName); if (source !== codeId) { return; } @@ -185,7 +183,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this._debuggerConfiguration.getCodeId(code, kernelName); + const codeId = this._config.getCodeId(code, kernelName); if (source !== codeId) { return; } @@ -215,7 +213,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this._debuggerConfiguration.getCodeId(code, kernelName); + const codeId = this._config.getCodeId(code, kernelName); if (widget.title.caption !== source && source !== codeId) { return; } @@ -230,10 +228,11 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { private _readOnlyEditorTracker: WidgetTracker< MainAreaWidget >; + + private _config: IDebugger.IConfig; private _notebookTracker: INotebookTracker | null; private _consoleTracker: IConsoleTracker | null; private _editorTracker: IEditorTracker | null; - private _debuggerConfiguration: IDebuggerConfig; } /** * A namespace for editor finder statics. @@ -243,6 +242,11 @@ export namespace EditorFinder { * The options used to initialize a EditorFinder object. */ export interface IOptions { + /** + * The instance of configuration with hash method. + */ + config: IDebugger.IConfig; + /** * An optional editor finder for consoles. */ @@ -267,11 +271,6 @@ export namespace EditorFinder { * The application shell. */ shell: JupyterFrontEnd.IShell; - - /** - * The instance of configuration with hash method. - */ - debuggerConfiguration: IDebuggerConfig; } } diff --git a/src/index.ts b/src/index.ts index fa705bfa..4523c67b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,8 +19,6 @@ import { IEditorServices } from '@jupyterlab/codeeditor'; import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console'; -import { ISettingRegistry } from '@jupyterlab/settingregistry'; - import { DocumentWidget } from '@jupyterlab/docregistry'; import { FileEditor, IEditorTracker } from '@jupyterlab/fileeditor'; @@ -29,6 +27,8 @@ import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook'; import { Session } from '@jupyterlab/services'; +import { ISettingRegistry } from '@jupyterlab/settingregistry'; + import { EditorFinder, IDebuggerEditorFinder } from './editor-finder'; import { @@ -48,17 +48,12 @@ import { DebuggerService } from './service'; import { DebuggerHandler } from './handler'; -import { IDebugger } from './tokens'; +import { IDebugger, IDebuggerConfig } from './tokens'; import { DebuggerModel } from './model'; import { VariablesBodyGrid } from './variables/grid'; -import { - IDebuggerConfig, - DebuggerConfiguration -} from './debugger-configuration'; - /** * The command IDs used by the debugger plugin. */ @@ -277,27 +272,27 @@ const service: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:service', autoStart: true, provides: IDebugger, - requires: [IDebuggerEditorFinder, IDebuggerConfig], + requires: [IDebuggerConfig, IDebuggerEditorFinder], activate: ( app: JupyterFrontEnd, - editorFinder: IDebuggerEditorFinder, - debuggerConfiguration: IDebuggerConfig + config: IDebugger.IConfig, + editorFinder: IDebuggerEditorFinder ) => new DebuggerService({ - specsManager: app.serviceManager.kernelspecs, + config, editorFinder, - debuggerConfiguration + specsManager: app.serviceManager.kernelspecs }) }; /** * A plugin that provides a configuration with hash method. */ -const configuration: JupyterFrontEndPlugin = { - id: '@jupyterlab/debugger:configuration', +const configuration: JupyterFrontEndPlugin = { + id: '@jupyterlab/debugger:config', provides: IDebuggerConfig, autoStart: true, - activate: (): IDebuggerConfig => new DebuggerConfiguration() + activate: () => new Debugger.Config() }; /** @@ -307,20 +302,20 @@ const finder: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:editor-finder', autoStart: true, provides: IDebuggerEditorFinder, - requires: [IEditorServices, IDebuggerConfig], + requires: [IDebuggerConfig, IEditorServices], optional: [INotebookTracker, IConsoleTracker, IEditorTracker], activate: ( app: JupyterFrontEnd, + config: IDebugger.IConfig, editorServices: IEditorServices, - debuggerConfiguration: IDebuggerConfig, notebookTracker: INotebookTracker | null, consoleTracker: IConsoleTracker | null, editorTracker: IEditorTracker | null ): IDebuggerEditorFinder => { return new EditorFinder({ + config, shell: app.shell, editorServices, - debuggerConfiguration, notebookTracker, consoleTracker, editorTracker diff --git a/src/service.ts b/src/service.ts index c7a46145..f3fef0dd 100644 --- a/src/service.ts +++ b/src/service.ts @@ -13,16 +13,14 @@ import { DebugProtocol } from 'vscode-debugprotocol'; import { CallstackModel } from './callstack/model'; +import { IDebuggerEditorFinder } from './editor-finder'; + import { DebuggerModel } from './model'; import { IDebugger } from './tokens'; -import { IDebuggerEditorFinder } from './editor-finder'; - import { VariablesModel } from './variables/model'; -import { IDebuggerConfig } from './debugger-configuration'; - /** * A concrete implementation of IDebugger. */ @@ -33,6 +31,7 @@ export class DebuggerService implements IDebugger, IDisposable { * @param options The instantiation options for a DebuggerService. */ constructor(options: DebuggerService.IOptions) { + this._config = options.config; // Avoids setting session with invalid client // session should be set only when a notebook or // a console get the focus. @@ -42,7 +41,6 @@ export class DebuggerService implements IDebugger, IDisposable { this._specsManager = options.specsManager; this._model = new DebuggerModel(); this._editorFinder = options.editorFinder; - this._debuggerConfiguration = options.debuggerConfiguration; } /** @@ -166,10 +164,7 @@ export class DebuggerService implements IDebugger, IDisposable { * @param code The source code. */ getCodeId(code: string): string { - return this._debuggerConfiguration.getCodeId( - code, - this.session.connection.kernel.name - ); + return this._config.getCodeId(code, this.session.connection.kernel.name); } /** @@ -231,15 +226,15 @@ export class DebuggerService implements IDebugger, IDisposable { const breakpoints = this._mapBreakpoints(reply.body.breakpoints); const stoppedThreads = new Set(reply.body.stoppedThreads); const kernelName = this.session.connection.kernel.name; - this._debuggerConfiguration.setHashParameters({ - hashMethod, - hashSeed, - kernelName + this._config.setHashParams({ + kernel: kernelName, + method: hashMethod, + seed: hashSeed }); - this._debuggerConfiguration.setTmpFileParameters({ - tmpFilePrefix, - tmpFileSuffix, - kernelName + this._config.setTmpFileParams({ + kernel: kernelName, + prefix: tmpFilePrefix, + suffix: tmpFileSuffix }); this._model.stoppedThreads = stoppedThreads; @@ -664,16 +659,15 @@ export class DebuggerService implements IDebugger, IDisposable { return 1; } + private _config: IDebugger.IConfig; + private _editorFinder: IDebuggerEditorFinder | null; + private _eventMessage = new Signal(this); private _isDisposed = false; - private _session: IDebugger.ISession; private _model: DebuggerModel; - private _sessionChanged = new Signal(this); private _modelChanged = new Signal(this); - private _eventMessage = new Signal(this); - + private _session: IDebugger.ISession; + private _sessionChanged = new Signal(this); private _specsManager: KernelSpec.IManager; - private _editorFinder: IDebuggerEditorFinder | null; - private _debuggerConfiguration: IDebuggerConfig; } /** @@ -697,6 +691,6 @@ export namespace DebuggerService { /** * The configuration instance with hash method. */ - debuggerConfiguration: IDebuggerConfig; + config: IDebugger.IConfig; } } diff --git a/src/tokens.ts b/src/tokens.ts index 9851dc6f..2c4d5fdb 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -64,10 +64,8 @@ export interface IDebugger { /** * Starts a debugger. - * Precondition: !isStarted - */ - start(): Promise; - + * Precondition: ! start(): Promise; + /** * Stops the debugger. * Precondition: isStarted @@ -199,6 +197,56 @@ export namespace IDebugger { export interface IBreakpoint extends DebugProtocol.Breakpoint { active: boolean; } + /** + * Interface for debugger file and hashing configuration. + */ + export interface IConfig { + getCodeId(code: string, kernelName: string): string; + setHashParams(params: IConfig.HashParams): void; + setTmpFileParams(params: IConfig.FileParams): void; + } + + export namespace IConfig { + /** + * Temporary file prefix and suffix for a kernel. + */ + export type FileParams = { + /** + * The kernel name. + */ + kernel: string; + + /** + * Prefix added to temporary files created by the kernel per cell. + */ + prefix: string; + + /** + * Suffix added temporary files created by the kernel per cell. + */ + suffix: string; + }; + + /** + * Hashing parameters for a kernel. + */ + export type HashParams = { + /** + * The kernel name. + */ + kernel: string; + + /** + * The hash method. + */ + method: string; + + /** + * The hash seed. + */ + seed: number; + }; + } /** * The interface for a source file. @@ -376,3 +424,10 @@ export namespace IDebugger { * A token for a tracker for an application's visual debugger instances. */ export const IDebugger = new Token('@jupyterlab/debugger'); + +/** + * The debugger configuration token. + */ +export const IDebuggerConfig = new Token( + '@jupyterlab/debugger:config' +); From be605a03d949c0c5265c179139f9cbe68f3c490b Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Fri, 10 Jul 2020 03:58:11 +0100 Subject: [PATCH 21/29] Update doc strings --- src/debugger.ts | 10 +++++----- src/tokens.ts | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/debugger.ts b/src/debugger.ts index a2ecada3..290e9fbb 100644 --- a/src/debugger.ts +++ b/src/debugger.ts @@ -50,7 +50,7 @@ export namespace Debugger { } /** - * Computes an id based on the given code. + * Returns an id based on the given code. * * @param code The source code. * @param kernel The kernel name from current session. @@ -61,11 +61,11 @@ export namespace Debugger { } /** - * Set the hash parameters for a kernel. + * Sets the hash parameters for a kernel. * * @param params - Hashing parameters for a kernel. */ - public setHashParams(params: IDebugger.IConfig.HashParams): void { + setHashParams(params: IDebugger.IConfig.HashParams): void { const { kernel, method, seed } = params; if (kernel === 'xpython') { if (method === 'Murmur2') { @@ -81,11 +81,11 @@ export namespace Debugger { } /** - * Set the parameters used for the temporary files (e.g. cells). + * Sets the parameters used for the temp files (e.g. cells) for a kernel. * * @param params - Temporary file prefix and suffix for a kernel. */ - public setTmpFileParams(params: IDebugger.IConfig.FileParams): void { + setTmpFileParams(params: IDebugger.IConfig.FileParams): void { const { kernel, prefix, suffix } = params; this._fileParams.set(kernel, { kernel, prefix, suffix }); } diff --git a/src/tokens.ts b/src/tokens.ts index 2c4d5fdb..ac09a14f 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -198,14 +198,35 @@ export namespace IDebugger { active: boolean; } /** - * Interface for debugger file and hashing configuration. + * Debugger file and hashing configuration. */ export interface IConfig { + /** + * Returns an id based on the given code. + * + * @param code The source code. + * @param kernel The kernel name from current session. + */ getCodeId(code: string, kernelName: string): string; + + /** + * Sets the hash parameters for a kernel. + * + * @param params - Hashing parameters for a kernel. + */ setHashParams(params: IConfig.HashParams): void; + + /** + * Sets the parameters used for the temp files (e.g. cells) for a kernel. + * + * @param params - Temporary file prefix and suffix for a kernel. + */ setTmpFileParams(params: IConfig.FileParams): void; } + /** + * Debugger file and hashing configuration. + */ export namespace IConfig { /** * Temporary file prefix and suffix for a kernel. @@ -421,7 +442,7 @@ export namespace IDebugger { } /** - * A token for a tracker for an application's visual debugger instances. + * The visual debugger token. */ export const IDebugger = new Token('@jupyterlab/debugger'); From 3106fac49f6732bf45e196c8773747f34877bfd7 Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Fri, 10 Jul 2020 12:19:31 +0200 Subject: [PATCH 22/29] Test updated --- test/debugger.spec.ts | 6 ++---- test/service.spec.ts | 17 +++++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/test/debugger.spec.ts b/test/debugger.spec.ts index d1ecdcef..ab04a567 100644 --- a/test/debugger.spec.ts +++ b/test/debugger.spec.ts @@ -13,8 +13,6 @@ import { Debugger } from '../src/debugger'; import { DebuggerService } from '../src/service'; -import { DebuggerConfiguration } from '../src/debugger-configuration'; - /** * A test sidebar. */ @@ -33,8 +31,8 @@ afterAll(async () => { describe('Debugger', () => { const specsManager = new KernelSpecManager(); - const debuggerConfiguration = new DebuggerConfiguration(); - const service = new DebuggerService({ specsManager, debuggerConfiguration }); + const config = new Debugger.Config(); + const service = new DebuggerService({ specsManager, config }); const registry = new CommandRegistry(); const factoryService = new CodeMirrorEditorFactory(); const mimeTypeService = new CodeMirrorMimeTypeService(); diff --git a/test/service.spec.ts b/test/service.spec.ts index 424c7c0a..a3c81099 100644 --- a/test/service.spec.ts +++ b/test/service.spec.ts @@ -21,10 +21,7 @@ import { IDebugger } from '../src/tokens'; import { KERNELSPECS, handleRequest } from './utils'; -import { - DebuggerConfiguration, - IDebuggerConfig -} from '../src/debugger-configuration'; +import { Debugger } from '../src/debugger'; /** * A Test class to mock a KernelSpecManager @@ -59,7 +56,7 @@ describe('Debugging support', () => { let specsManager: TestKernelSpecManager; let service: DebuggerService; - let debuggerConfiguration: IDebuggerConfig; + let config: IDebugger.IConfig; let xpython: Session.ISessionConnection; let ipykernel: Session.ISessionConnection; @@ -81,8 +78,8 @@ describe('Debugging support', () => { specsManager = new TestKernelSpecManager({ standby: 'never' }); specsManager.intercept = specs; await specsManager.refreshSpecs(); - debuggerConfiguration = new DebuggerConfiguration(); - service = new DebuggerService({ specsManager, debuggerConfiguration }); + config = new Debugger.Config(); + service = new DebuggerService({ specsManager, config }); }); afterAll(async () => { @@ -108,7 +105,7 @@ describe('DebuggerService', () => { const specsManager = new KernelSpecManager(); let connection: Session.ISessionConnection; let model: DebuggerModel; - let debuggerConfiguration: IDebuggerConfig; + let config: IDebugger.IConfig; let session: IDebugger.ISession; let service: IDebugger; @@ -121,8 +118,8 @@ describe('DebuggerService', () => { await connection.changeKernel({ name: 'xpython' }); session = new DebugSession({ connection }); model = new DebuggerModel(); - debuggerConfiguration = new DebuggerConfiguration(); - service = new DebuggerService({ specsManager, debuggerConfiguration }); + config = new Debugger.Config(); + service = new DebuggerService({ specsManager, config }); }); afterEach(async () => { From d5fff95ef06c5c931994fe9b25d8bfdf8bb7df3a Mon Sep 17 00:00:00 2001 From: "krzysztof.sikora" Date: Fri, 10 Jul 2020 12:33:03 +0200 Subject: [PATCH 23/29] Fix typo issue into tokens --- src/tokens.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tokens.ts b/src/tokens.ts index ac09a14f..53d9a340 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -64,8 +64,10 @@ export interface IDebugger { /** * Starts a debugger. - * Precondition: ! start(): Promise; - + * Precondition: !isStarted + */ + start(): Promise; + /** * Stops the debugger. * Precondition: isStarted From db0cffb7d338996345177ed5bfe4dd8af5ccd341 Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Fri, 10 Jul 2020 11:50:31 +0100 Subject: [PATCH 24/29] Refactor setHashParams() --- src/debugger.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/debugger.ts b/src/debugger.ts index 290e9fbb..77fad568 100644 --- a/src/debugger.ts +++ b/src/debugger.ts @@ -57,7 +57,13 @@ export namespace Debugger { */ getCodeId(code: string, kernel: string): string { const { prefix, suffix } = this._fileParams.get(kernel); - return `${prefix}${this._hashMethod(code)}${suffix}`; + const hash = this._hashMethods.get(kernel); + + if (!hash) { + throw new Error(`Kernel (${kernel}) has no hashing params.`); + } + + return `${prefix}${hash(code)}${suffix}`; } /** @@ -67,16 +73,12 @@ export namespace Debugger { */ setHashParams(params: IDebugger.IConfig.HashParams): void { const { kernel, method, seed } = params; - if (kernel === 'xpython') { - if (method === 'Murmur2') { - this._hashMethod = (code: string): string => { - return murmur2(code, seed).toString(); - }; - } else { - throw new Error('hash method not supported ' + method); - } - } else { - throw new Error('Kernel not supported ' + kernel); + switch (method) { + case 'Murmur2': + this._hashMethods.set(kernel, code => murmur2(code, seed).toString()); + break; + default: + throw new Error(`Hash method (${method}) is not supported.`); } } @@ -91,7 +93,7 @@ export namespace Debugger { } private _fileParams = new Map(); - private _hashMethod: (code: string) => string; + private _hashMethods = new Map string>(); } /** From ea63089cbf05cd1a4c50ca535f7217dcd38f95cc Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Fri, 10 Jul 2020 12:58:40 +0100 Subject: [PATCH 25/29] More clean up and refactoring --- src/editor-finder.ts | 38 +++++++++++++++++++------------------- src/handlers/tracker.ts | 17 ++++++----------- src/index.ts | 16 +++++++--------- src/service.ts | 24 +++++++++++------------- src/tokens.ts | 2 +- 5 files changed, 44 insertions(+), 53 deletions(-) diff --git a/src/editor-finder.ts b/src/editor-finder.ts index 54e646b6..76e7b513 100644 --- a/src/editor-finder.ts +++ b/src/editor-finder.ts @@ -88,13 +88,13 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { if (!this._notebookTracker) { return []; } - const { debugSessionPath, source, focus, kernelName } = findParams; + const { focus, kernel, path, source } = findParams; const editors: CodeEditor.IEditor[] = []; this._notebookTracker.forEach(notebookPanel => { const sessionContext = notebookPanel.sessionContext; - if (sessionContext.path !== debugSessionPath) { + if (path !== sessionContext.path) { return; } @@ -107,7 +107,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { cells.forEach((cell, i) => { // check the event is for the correct cell const code = cell.model.value.text; - const cellId = this._config.getCodeId(code, kernelName); + const cellId = this._config.getCodeId(code, kernel); if (source !== cellId) { return; } @@ -132,20 +132,20 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { if (!this._consoleTracker) { return []; } - const { debugSessionPath, source, focus, kernelName } = findParams; + const { focus, kernel, path, source } = findParams; const editors: CodeEditor.IEditor[] = []; this._consoleTracker.forEach(consoleWidget => { const sessionContext = consoleWidget.sessionContext; - if (sessionContext.path !== debugSessionPath) { + if (path !== sessionContext.path) { return; } const cells = consoleWidget.console.cells; each(cells, cell => { const code = cell.model.value.text; - const codeId = this._config.getCodeId(code, kernelName); + const codeId = this._config.getCodeId(code, kernel); if (source !== codeId) { return; } @@ -168,12 +168,12 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { if (!this._editorTracker) { return; } - const { debugSessionPath, source, focus, kernelName } = findParams; + const { focus, kernel, path, source } = findParams; const editors: CodeEditor.IEditor[] = []; this._editorTracker.forEach(doc => { const fileEditor = doc.content; - if (debugSessionPath !== fileEditor.context.path) { + if (path !== fileEditor.context.path) { return; } @@ -183,7 +183,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this._config.getCodeId(code, kernelName); + const codeId = this._config.getCodeId(code, kernel); if (source !== codeId) { return; } @@ -203,7 +203,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { private _findInReadOnlyEditors( findParams: IFindParameters ): CodeEditor.IEditor[] { - const { source, focus, kernelName } = findParams; + const { focus, kernel, source } = findParams; const editors: CodeEditor.IEditor[] = []; this._readOnlyEditorTracker.forEach(widget => { @@ -213,7 +213,7 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } const code = editor.model.value.text; - const codeId = this._config.getCodeId(code, kernelName); + const codeId = this._config.getCodeId(code, kernel); if (widget.title.caption !== source && source !== codeId) { return; } @@ -279,24 +279,24 @@ export namespace EditorFinder { */ interface IFindParameters { /** - * Path of session connection. + * Extra flag prevent disable focus. */ - debugSessionPath: string; + focus: boolean; /** - * Source path + * Name of current kernel. */ - source: string; + kernel: string; /** - * Extra flag prevent disable focus. + * Path of session connection. */ - focus: boolean; + path: string; /** - * Name of current kernel. + * Source path */ - kernelName: string; + source: string; } /** diff --git a/src/handlers/tracker.ts b/src/handlers/tracker.ts index 69af7b73..4838ac1e 100644 --- a/src/handlers/tracker.ts +++ b/src/handlers/tracker.ts @@ -122,15 +122,12 @@ export class TrackerHandler implements IDisposable { _: CallstackModel, frame: CallstackModel.IFrame ): void { - const debugSessionPath = this._debuggerService.session?.connection?.path; - const source = frame?.source.path ?? null; - const kernelName = this._debuggerService.session.connection.kernel.name; each( this._editorFinder.find({ - debugSessionPath, - source, focus: true, - kernelName + kernel: this._debuggerService.session.connection.kernel.name, + path: this._debuggerService.session?.connection?.path, + source: frame?.source.path ?? null }), editor => { requestAnimationFrame(() => { @@ -153,14 +150,12 @@ export class TrackerHandler implements IDisposable { if (!source) { return; } - const debugSessionPath = this._debuggerService.session.connection.path; const { content, mimeType, path } = source; - const kernelName = this._debuggerService.session.connection.kernel.name; const results = this._editorFinder.find({ - debugSessionPath, - source: path, focus: false, - kernelName + kernel: this._debuggerService.session.connection.kernel.name, + path: this._debuggerService.session.connection.path, + source: path }); if (results.next()) { return; diff --git a/src/index.ts b/src/index.ts index 4523c67b..f3ede9ee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -505,21 +505,19 @@ const main: JupyterFrontEndPlugin = { if (settingRegistry) { const setting = await settingRegistry.load(main.id); - const updateVariableSettings = (): void => { + const updateSettings = (): void => { const filters = setting.get('variableFilters').composite as { [key: string]: string[]; }; - const kernelName = service.session?.connection?.kernel?.name; - const list = filters[kernelName]; - if (!list) { - return; + const list = filters[service.session?.connection?.kernel?.name]; + if (list) { + sidebar.variables.filter = new Set(list); } - sidebar.variables.filter = new Set(list); }; - updateVariableSettings(); - setting.changed.connect(updateVariableSettings); - sidebar.service.sessionChanged.connect(updateVariableSettings); + updateSettings(); + setting.changed.connect(updateSettings); + sidebar.service.sessionChanged.connect(updateSettings); } if (themeManager) { diff --git a/src/service.ts b/src/service.ts index f3fef0dd..9a17618e 100644 --- a/src/service.ts +++ b/src/service.ts @@ -222,19 +222,19 @@ export class DebuggerService implements IDebugger, IDisposable { } const reply = await this.session.restoreState(); - const { hashMethod, hashSeed, tmpFilePrefix, tmpFileSuffix } = reply.body; + const { body } = reply; const breakpoints = this._mapBreakpoints(reply.body.breakpoints); const stoppedThreads = new Set(reply.body.stoppedThreads); - const kernelName = this.session.connection.kernel.name; + this._config.setHashParams({ - kernel: kernelName, - method: hashMethod, - seed: hashSeed + kernel: this.session.connection.kernel.name, + method: body.hashMethod, + seed: body.hashSeed }); this._config.setTmpFileParams({ - kernel: kernelName, - prefix: tmpFilePrefix, - suffix: tmpFileSuffix + kernel: this.session.connection.kernel.name, + prefix: body.tmpFilePrefix, + suffix: body.tmpFileSuffix }); this._model.stoppedThreads = stoppedThreads; @@ -422,18 +422,16 @@ export class DebuggerService implements IDebugger, IDisposable { private _filterBreakpoints( breakpoints: Map ): Map { - const debugSessionPath = this._session.connection.path; - const kernelName = this.session.connection.kernel.name; let bpMapForRestore = new Map(); for (let collection of breakpoints) { const [id, list] = collection; list.forEach(() => { each( this._editorFinder.find({ - debugSessionPath, - source: id, focus: false, - kernelName + kernel: this.session.connection.kernel.name, + path: this._session.connection.path, + source: id }), () => { if (list.length > 0) { diff --git a/src/tokens.ts b/src/tokens.ts index 53d9a340..dd632014 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -209,7 +209,7 @@ export namespace IDebugger { * @param code The source code. * @param kernel The kernel name from current session. */ - getCodeId(code: string, kernelName: string): string; + getCodeId(code: string, kernel: string): string; /** * Sets the hash parameters for a kernel. From dcbad2672a627f0ff60669fab4e30816c1933236 Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Fri, 10 Jul 2020 14:04:27 +0100 Subject: [PATCH 26/29] Refactor editor finder --- src/editor-finder.ts | 104 +++++++++++++--------------------------- src/handlers/tracker.ts | 18 +++---- src/index.ts | 16 +++---- src/service.ts | 14 +++--- src/tokens.ts | 55 +++++++++++++++++++++ 5 files changed, 112 insertions(+), 95 deletions(-) diff --git a/src/editor-finder.ts b/src/editor-finder.ts index 76e7b513..2c6a5b0f 100644 --- a/src/editor-finder.ts +++ b/src/editor-finder.ts @@ -19,8 +19,6 @@ import { INotebookTracker } from '@jupyterlab/notebook'; import { chain, each, IIterator } from '@lumino/algorithm'; -import { Token } from '@lumino/coreutils'; - import { IDisposable } from '@lumino/disposable'; import { Signal } from '@lumino/signaling'; @@ -30,7 +28,7 @@ import { IDebugger } from './tokens'; /** * A class to find instances of code editors across notebook, console and files widgets */ -export class EditorFinder implements IDisposable, IDebuggerEditorFinder { +export class EditorFinder implements IDisposable, IDebugger.IEditorFinder { /** * Instantiate a new EditorFinder. * @@ -64,31 +62,33 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } /** - * Find the editor for a source matching the current debug session - * by iterating through all the widgets in each of the notebook, - * console, file editor, and read-only file editor trackers. + * Returns an iterator of editors for a source matching the current debug + * session by iterating through all the widgets in each of the supported + * debugger types (i.e., consoles, files, notebooks). * - * @param findParams - Unified parameters for a source matching + * @param params - The editor search parameters. */ - find(findParams: IFindParameters): IIterator { + find(params: IDebugger.IEditorFinder.Params): IIterator { return chain( - this._findInNotebooks(findParams), - this._findInConsoles(findParams), - this._findInEditors(findParams), - this._findInReadOnlyEditors(findParams) + this._findInConsoles(params), + this._findInEditors(params), + this._findInNotebooks(params), + this._findInReadOnlyEditors(params) ); } /** - * Find the editor for a source matching the current debug session + * Find relevant editors matching the search params in the notebook tracker. * - * @param findParams - Unified parameters for a source matching + * @param params - The editor search parameters. */ - private _findInNotebooks(findParams: IFindParameters): CodeEditor.IEditor[] { + private _findInNotebooks( + params: IDebugger.IEditorFinder.Params + ): CodeEditor.IEditor[] { if (!this._notebookTracker) { return []; } - const { focus, kernel, path, source } = findParams; + const { focus, kernel, path, source } = params; const editors: CodeEditor.IEditor[] = []; this._notebookTracker.forEach(notebookPanel => { @@ -113,7 +113,8 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } if (focus) { notebook.activeCellIndex = i; - const rect = notebook.activeCell.inputArea.node.getBoundingClientRect(); + const { node } = notebook.activeCell.inputArea; + const rect = node.getBoundingClientRect(); notebook.scrollToPosition(rect.bottom, 45); this._shell.activateById(notebookPanel.id); } @@ -124,15 +125,17 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } /** - * Find the editor for a source matching the current debug session + * Find relevant editors matching the search params in the console tracker. * - * @param findParams - Unified parameters for a source matching + * @param params - The editor search parameters. */ - private _findInConsoles(findParams: IFindParameters): CodeEditor.IEditor[] { + private _findInConsoles( + params: IDebugger.IEditorFinder.Params + ): CodeEditor.IEditor[] { if (!this._consoleTracker) { return []; } - const { focus, kernel, path, source } = findParams; + const { focus, kernel, path, source } = params; const editors: CodeEditor.IEditor[] = []; this._consoleTracker.forEach(consoleWidget => { @@ -159,16 +162,17 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } /** - * Find the editor for a source matching the current debug session - * from the editor tracker. + * Find relevant editors matching the search params in the editor tracker. * - * @param findParams - Unified parameters for a source matching + * @param params - The editor search parameters. */ - private _findInEditors(findParams: IFindParameters): CodeEditor.IEditor[] { + private _findInEditors( + params: IDebugger.IEditorFinder.Params + ): CodeEditor.IEditor[] { if (!this._editorTracker) { return; } - const { focus, kernel, path, source } = findParams; + const { focus, kernel, path, source } = params; const editors: CodeEditor.IEditor[] = []; this._editorTracker.forEach(doc => { @@ -196,14 +200,14 @@ export class EditorFinder implements IDisposable, IDebuggerEditorFinder { } /** - * Find an editor for a source from the read-only editor tracker. + * Find relevant editors matching the search params in the read-only tracker. * - * @param findParams - Unified parameters for a source matching + * @param params - The editor search parameters. */ private _findInReadOnlyEditors( - findParams: IFindParameters + params: IDebugger.IEditorFinder.Params ): CodeEditor.IEditor[] { - const { focus, kernel, source } = findParams; + const { focus, kernel, source } = params; const editors: CodeEditor.IEditor[] = []; this._readOnlyEditorTracker.forEach(widget => { @@ -273,43 +277,3 @@ export namespace EditorFinder { shell: JupyterFrontEnd.IShell; } } - -/** - * Unified parameters for find method - */ -interface IFindParameters { - /** - * Extra flag prevent disable focus. - */ - focus: boolean; - - /** - * Name of current kernel. - */ - kernel: string; - - /** - * Path of session connection. - */ - path: string; - - /** - * Source path - */ - source: string; -} - -/** - * A token for a editor finder handler find method plugin - * - */ -export const IDebuggerEditorFinder = new Token( - '@jupyterlab/debugger:editor-finder' -); - -/** - * Interface for separated find method from editor finder plugin - */ -export interface IDebuggerEditorFinder { - find(findParams: IFindParameters): IIterator; -} diff --git a/src/handlers/tracker.ts b/src/handlers/tracker.ts index 4838ac1e..8c1351bf 100644 --- a/src/handlers/tracker.ts +++ b/src/handlers/tracker.ts @@ -26,8 +26,6 @@ import { IDisposable } from '@lumino/disposable'; import { Signal } from '@lumino/signaling'; -import { IDebuggerEditorFinder } from '../editor-finder'; - import { EditorHandler } from './editor'; import { CallstackModel } from '../callstack/model'; @@ -188,14 +186,15 @@ export class TrackerHandler implements IDisposable { EditorHandler.showCurrentLine(editor, frame.line); } } - private _debuggerService: IDebugger; + private _debuggerModel: DebuggerModel; - private _shell: JupyterFrontEnd.IShell; + private _debuggerService: IDebugger; + private _editorFinder: IDebugger.IEditorFinder | null; private _readOnlyEditorFactory: ReadOnlyEditorFactory; private _readOnlyEditorTracker: WidgetTracker< MainAreaWidget >; - private _editorFinder: IDebuggerEditorFinder | null; + private _shell: JupyterFrontEnd.IShell; } /** @@ -211,6 +210,11 @@ export namespace TrackerHandler { */ debuggerService: IDebugger; + /** + * The editor finder. + */ + editorFinder: IDebugger.IEditorFinder; + /** * The editor services. */ @@ -220,10 +224,6 @@ export namespace TrackerHandler { * The application shell. */ shell: JupyterFrontEnd.IShell; - /** - * The editor finder. - */ - editorFinder: IDebuggerEditorFinder; } // TODO: move the interface and token below to token.ts? diff --git a/src/index.ts b/src/index.ts index f3ede9ee..45487331 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,7 +29,7 @@ import { Session } from '@jupyterlab/services'; import { ISettingRegistry } from '@jupyterlab/settingregistry'; -import { EditorFinder, IDebuggerEditorFinder } from './editor-finder'; +import { EditorFinder } from './editor-finder'; import { continueIcon, @@ -48,10 +48,10 @@ import { DebuggerService } from './service'; import { DebuggerHandler } from './handler'; -import { IDebugger, IDebuggerConfig } from './tokens'; - import { DebuggerModel } from './model'; +import { IDebugger, IDebuggerConfig, IDebuggerEditorFinder } from './tokens'; + import { VariablesBodyGrid } from './variables/grid'; /** @@ -82,7 +82,7 @@ const consoles: JupyterFrontEndPlugin = { activate: ( app: JupyterFrontEnd, debug: IDebugger, - editorFinder: IDebuggerEditorFinder, + editorFinder: IDebugger.IEditorFinder, consoleTracker: IConsoleTracker, labShell: ILabShell ) => { @@ -254,7 +254,7 @@ const tracker: JupyterFrontEndPlugin = { app: JupyterFrontEnd, debug: IDebugger, editorServices: IEditorServices, - editorFinder: IDebuggerEditorFinder + editorFinder: IDebugger.IEditorFinder ) => { new TrackerHandler({ shell: app.shell, @@ -276,7 +276,7 @@ const service: JupyterFrontEndPlugin = { activate: ( app: JupyterFrontEnd, config: IDebugger.IConfig, - editorFinder: IDebuggerEditorFinder + editorFinder: IDebugger.IEditorFinder ) => new DebuggerService({ config, @@ -298,7 +298,7 @@ const configuration: JupyterFrontEndPlugin = { /** * A plugin that tracks editors, console and file editors used for debugging. */ -const finder: JupyterFrontEndPlugin = { +const finder: JupyterFrontEndPlugin = { id: '@jupyterlab/debugger:editor-finder', autoStart: true, provides: IDebuggerEditorFinder, @@ -311,7 +311,7 @@ const finder: JupyterFrontEndPlugin = { notebookTracker: INotebookTracker | null, consoleTracker: IConsoleTracker | null, editorTracker: IEditorTracker | null - ): IDebuggerEditorFinder => { + ): IDebugger.IEditorFinder => { return new EditorFinder({ config, shell: app.shell, diff --git a/src/service.ts b/src/service.ts index 9a17618e..cac6969a 100644 --- a/src/service.ts +++ b/src/service.ts @@ -13,8 +13,6 @@ import { DebugProtocol } from 'vscode-debugprotocol'; import { CallstackModel } from './callstack/model'; -import { IDebuggerEditorFinder } from './editor-finder'; - import { DebuggerModel } from './model'; import { IDebugger } from './tokens'; @@ -658,7 +656,7 @@ export class DebuggerService implements IDebugger, IDisposable { } private _config: IDebugger.IConfig; - private _editorFinder: IDebuggerEditorFinder | null; + private _editorFinder: IDebugger.IEditorFinder | null; private _eventMessage = new Signal(this); private _isDisposed = false; private _model: DebuggerModel; @@ -677,18 +675,18 @@ export namespace DebuggerService { */ export interface IOptions { /** - * The kernel specs manager. + * The configuration instance with hash method. */ - specsManager: KernelSpec.IManager; + config: IDebugger.IConfig; /** * The editor finder instance. */ - editorFinder?: IDebuggerEditorFinder; + editorFinder?: IDebugger.IEditorFinder; /** - * The configuration instance with hash method. + * The kernel specs manager. */ - config: IDebugger.IConfig; + specsManager: KernelSpec.IManager; } } diff --git a/src/tokens.ts b/src/tokens.ts index dd632014..8a002919 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -1,8 +1,12 @@ // Copyright (c) Jupyter Development Team. // Distributed under the terms of the Modified BSD License. +import { CodeEditor } from '@jupyterlab/codeeditor'; + import { KernelMessage, Session } from '@jupyterlab/services'; +import { IIterator } from '@lumino/algorithm'; + import { Token } from '@lumino/coreutils'; import { IObservableDisposable } from '@lumino/disposable'; @@ -271,6 +275,50 @@ export namespace IDebugger { }; } + /** + * A utility to find text editors used by the debugger. + */ + export interface IEditorFinder { + /** + * Returns an iterator of editors for a source matching the current debug + * session by iterating through all the widgets in each of the supported + * debugger types (i.e., consoles, files, notebooks). + * + * @param params - The editor search parameters. + */ + find(params: IEditorFinder.Params): IIterator; + } + + /** + * A utility to find text editors used by the debugger. + */ + export namespace IEditorFinder { + /** + * Unified parameters for find method + */ + export type Params = { + /** + * Extra flag prevent disable focus. + */ + focus: boolean; + + /** + * Name of current kernel. + */ + kernel: string; + + /** + * Path of session connection. + */ + path: string; + + /** + * Source path + */ + source: string; + }; + } + /** * The interface for a source file. */ @@ -454,3 +502,10 @@ export const IDebugger = new Token('@jupyterlab/debugger'); export const IDebuggerConfig = new Token( '@jupyterlab/debugger:config' ); + +/** + * The debugger editor finder utility token. + */ +export const IDebuggerEditorFinder = new Token( + '@jupyterlab/debugger:editor-finder' +); From b618d350a9fba4e9f489d08562d7a2d0df1f169f Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Fri, 10 Jul 2020 16:35:56 +0100 Subject: [PATCH 27/29] Change hashing seed to `any` and make it optional to support future algorithms and remove superfluous dispose method --- src/debugger.ts | 20 +------------------- src/tokens.ts | 6 +++--- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/debugger.ts b/src/debugger.ts index 77fad568..e648649b 100644 --- a/src/debugger.ts +++ b/src/debugger.ts @@ -5,8 +5,6 @@ import { IEditorServices } from '@jupyterlab/codeeditor'; import { bugIcon } from '@jupyterlab/ui-components'; -import { Signal } from '@lumino/signaling'; - import { Panel, SplitPanel, Widget } from '@lumino/widgets'; import { murmur2 } from 'murmurhash-js'; @@ -33,22 +31,6 @@ export namespace Debugger { * A class that holds debugger configuration for a kernel. */ export class Config implements IDebugger.IConfig { - /** - * Whether the handler is disposed. - */ - isDisposed: boolean; - - /** - * Dispose the objects. - */ - dispose(): void { - if (this.isDisposed) { - return; - } - this.isDisposed = true; - Signal.clearData(this); - } - /** * Returns an id based on the given code. * @@ -83,7 +65,7 @@ export namespace Debugger { } /** - * Sets the parameters used for the temp files (e.g. cells) for a kernel. + * Sets the parameters used by the kernel to create temp files (e.g. cells). * * @param params - Temporary file prefix and suffix for a kernel. */ diff --git a/src/tokens.ts b/src/tokens.ts index 8a002919..cf072611 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -264,14 +264,14 @@ export namespace IDebugger { kernel: string; /** - * The hash method. + * The hashing method. */ method: string; /** - * The hash seed. + * An optional hashing seed provided by the kernel. */ - seed: number; + seed?: any; }; } From 89372011982c9e4d5de46143c02c71082c8d1067 Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Fri, 10 Jul 2020 16:43:03 +0100 Subject: [PATCH 28/29] Remove EditorFinder#dispose --- package.json | 3 +++ src/editor-finder.ts | 22 +--------------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index a01eda30..02a181dc 100644 --- a/package.json +++ b/package.json @@ -103,6 +103,9 @@ "typedoc": "^0.15.4", "typescript": "~3.9.2" }, + "resolutions": { + "@types/react": "~16.9.16" + }, "husky": { "hooks": { "pre-commit": "lint-staged" diff --git a/src/editor-finder.ts b/src/editor-finder.ts index 2c6a5b0f..69ab1c0c 100644 --- a/src/editor-finder.ts +++ b/src/editor-finder.ts @@ -19,16 +19,12 @@ import { INotebookTracker } from '@jupyterlab/notebook'; import { chain, each, IIterator } from '@lumino/algorithm'; -import { IDisposable } from '@lumino/disposable'; - -import { Signal } from '@lumino/signaling'; - import { IDebugger } from './tokens'; /** * A class to find instances of code editors across notebook, console and files widgets */ -export class EditorFinder implements IDisposable, IDebugger.IEditorFinder { +export class EditorFinder implements IDebugger.IEditorFinder { /** * Instantiate a new EditorFinder. * @@ -45,22 +41,6 @@ export class EditorFinder implements IDisposable, IDebugger.IEditorFinder { >({ namespace: '@jupyterlab/debugger' }); } - /** - * Whether the handler is disposed. - */ - isDisposed: boolean; - - /** - * Dispose the handler. - */ - dispose(): void { - if (this.isDisposed) { - return; - } - this.isDisposed = true; - Signal.clearData(this); - } - /** * Returns an iterator of editors for a source matching the current debug * session by iterating through all the widgets in each of the supported From d24e6d53e60ae622d8e6852d82464917af23931b Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Fri, 10 Jul 2020 17:00:10 +0100 Subject: [PATCH 29/29] Update yarn.lock --- package.json | 3 --- yarn.lock | 46 +++++++++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 02a181dc..a01eda30 100644 --- a/package.json +++ b/package.json @@ -103,9 +103,6 @@ "typedoc": "^0.15.4", "typescript": "~3.9.2" }, - "resolutions": { - "@types/react": "~16.9.16" - }, "husky": { "hooks": { "pre-commit": "lint-staged" diff --git a/yarn.lock b/yarn.lock index 66d8dea0..1c9d844b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1807,9 +1807,9 @@ integrity sha512-PxJwTlcFOBRPqv9pSoC3O1FpKN8GnM5hMJIkG6U3omH8b4GAh28fO1c+TMR4oxj0BG43/ICbrIK3KBfzad2heg== "@types/node@*": - version "14.0.19" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.19.tgz#994d99708822bca643a2364f8aeed04a16e0f5a1" - integrity sha512-yf3BP/NIXF37BjrK5klu//asUWitOEoUP5xE1mhSUjazotwJ/eJDgEmMQNlOeWOVv72j24QQ+3bqXHE++CFGag== + version "14.0.22" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.22.tgz#23ea4d88189cec7d58f9e6b66f786b215eb61bdc" + integrity sha512-emeGcJvdiZ4Z3ohbmw93E/64jRzUHAItSHt8nF7M4TGgQTiWqFVGB8KNpLGFmUHmHLvjvBgFwVlqNcq+VuGv9g== "@types/normalize-package-data@^2.4.0": version "2.4.0" @@ -1827,9 +1827,9 @@ integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw== "@types/react@~16.9.16": - version "16.9.41" - resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.41.tgz#925137ee4d2ff406a0ecf29e8e9237390844002e" - integrity sha512-6cFei7F7L4wwuM+IND/Q2cV1koQUvJ8iSV+Gwn0c3kvABZ691g7sp3hfEQHOUBJtccl1gPi+EyNjMIl9nGA0ug== + version "16.9.42" + resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.42.tgz#9776508d59c1867bbf9bd7f036dab007fdaa1cb7" + integrity sha512-iGy6HwfVfotqJ+PfRZ4eqPHPP5NdPZgQlr0lTs8EfkODRBV9cYy8QMKcC9qPCe1JrESC1Im6SrCFR6tQgg74ag== dependencies: "@types/prop-types" "*" csstype "^2.2.0" @@ -2385,9 +2385,9 @@ camelcase@^5.0.0, camelcase@^5.3.1: integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== caniuse-lite@^1.0.30001093: - version "1.0.30001096" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001096.tgz#5a4541af5317dc21f91f5b24d453030a35f919c0" - integrity sha512-PFTw9UyVfbkcMEFs82q8XVlRayj7HKvnhu5BLcmjGpv+SNyiWasCcWXPGJuO0rK0dhLRDJmtZcJ+LHUfypbw1w== + version "1.0.30001097" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001097.tgz#1129c40c9f5ee3282158da08fd915d301f4a9bd8" + integrity sha512-TeuSleKt/vWXaPkLVFqGDnbweYfq4IaZ6rUugFf3rWY6dlII8StUZ8Ddin0PkADfgYZ4wRqCdO2ORl4Rn5eZIA== canvas@^2.6.1: version "2.6.1" @@ -2971,9 +2971,9 @@ ecc-jsbn@~0.1.1: safer-buffer "^2.1.0" electron-to-chromium@^1.3.488: - version "1.3.492" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.492.tgz#bde16082a05a124266e5ecc9cf0ce53d137f2919" - integrity sha512-AD6v9Y2wN0HuoRH4LwCmlSHjkKq51D1U52bTuvM5uPzisbHVm3Hms15c42TBFLewxnSqxAynK/tbeaUi4Rnjqw== + version "1.3.496" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.496.tgz#3f43d32930481d82ad3663d79658e7c59a58af0b" + integrity sha512-TXY4mwoyowwi4Lsrq9vcTUYBThyc1b2hXaTZI13p8/FRhY2CTaq5lK+DVjhYkKiTLsKt569Xes+0J5JsVXFurQ== elegant-spinner@^1.0.1: version "1.0.1" @@ -3975,9 +3975,9 @@ ini@~1.3.0: integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== inquirer@^7.0.0: - version "7.3.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.0.tgz#aa3e7cb0c18a410c3c16cdd2bc9dcbe83c4d333e" - integrity sha512-K+LZp6L/6eE5swqIcVXrxl21aGDU4S50gKH0/d96OMQnSBCyGyZl/oZhbkVmdp5sBoINHd4xZvFSARh2dk6DWA== + version "7.3.1" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.1.tgz#ac6aba1abdfdd5ad34e7069370411edba17f6439" + integrity sha512-/+vOpHQHhoh90Znev8BXiuw1TDQ7IDxWsQnFafUEoK5+4uN5Eoz1p+3GqOj/NtzEi9VzWKQcV9Bm+i8moxedsA== dependencies: ansi-escapes "^4.2.1" chalk "^4.1.0" @@ -3985,7 +3985,7 @@ inquirer@^7.0.0: cli-width "^3.0.0" external-editor "^3.0.3" figures "^3.0.0" - lodash "^4.17.15" + lodash "^4.17.16" mute-stream "0.0.8" run-async "^2.4.0" rxjs "^6.6.0" @@ -5045,10 +5045,10 @@ lodash.sortby@^4.7.0: resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= -lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15: - version "4.17.17" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.17.tgz#d9018b3acc57a95c9dcf4a45c6b63b877b6c2d45" - integrity sha512-/B2DjOphAoqi5BX4Gg2oh4UR0Gy/A7xYAMh3aSECEKzwS3eCDEpS0Cals1Ktvxwlal3bBJNc+5W9kNIcADdw5Q== +lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.16: + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== log-symbols@^1.0.2: version "1.0.2" @@ -5322,9 +5322,9 @@ needle@^2.2.1: sax "^1.2.4" neo-async@^2.6.0: - version "2.6.1" - resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c" - integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw== + version "2.6.2" + resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" + integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== nice-try@^1.0.4: version "1.0.5"