krzysztof.sikora 4 anni fa
parent
commit
946c793df8
6 ha cambiato i file con 53 aggiunte e 47 eliminazioni
  1. 5 5
      src/debugger-configuration.ts
  2. 9 9
      src/editor-finder.ts
  3. 16 13
      src/index.ts
  4. 11 8
      src/service.ts
  5. 3 3
      test/debugger.spec.ts
  6. 9 9
      test/service.spec.ts

+ 5 - 5
src/parameters-mixer.ts → 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<IDebuggerParametersMixer>(
-  '@jupyterlab/debugger:parameters-mixer'
+export const IDebuggerConfig = new Token<IDebuggerConfig>(
+  '@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;

+ 9 - 9
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<CodeEditorWrapper>
     >({
@@ -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

+ 16 - 13
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<IDebugger> = {
   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<IDebuggerParametersMixer> = {
-  id: '@jupyterlab/debugger:parameters-mixer',
-  provides: IDebuggerParametersMixer,
+const configuration: JupyterFrontEndPlugin<IDebuggerConfig> = {
+  id: '@jupyterlab/debugger:configuration',
+  provides: IDebuggerConfig,
   autoStart: true,
-  activate: (): IDebuggerParametersMixer => new ParametersMixer()
+  activate: (): IDebuggerConfig => new DebuggerConfiguration()
 };
 
 /**
@@ -304,12 +307,12 @@ const finder: JupyterFrontEndPlugin<IDebuggerEditorFinder> = {
   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<IDebuggerEditorFinder> = {
     return new EditorFinder({
       shell: app.shell,
       editorServices,
-      parametersMixer,
+      debuggerConfiguration,
       notebookTracker,
       consoleTracker,
       editorTracker
@@ -579,7 +582,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
   variables,
   main,
   finder,
-  mixer
+  configuration
 ];
 
 export default plugins;

+ 11 - 8
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;
   }
 }

+ 3 - 3
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();

+ 9 - 9
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 () => {