Explorar el Código

Update Debugger.Session

Afshin T. Darian hace 4 años
padre
commit
4596e82a01
Se han modificado 6 ficheros con 27 adiciones y 26 borrados
  1. 7 0
      src/debugger.ts
  2. 1 3
      src/handler.ts
  3. 5 5
      src/session.ts
  4. 2 4
      test/debugger.spec.ts
  5. 2 4
      test/service.spec.ts
  6. 10 10
      test/session.spec.ts

+ 7 - 0
src/debugger.ts

@@ -21,6 +21,8 @@ import { Variables as VariablesPanel } from './panels/variables';
 
 import { DebuggerService } from './service';
 
+import { DebuggerSession } from './session';
+
 import { DebuggerSources } from './sources';
 
 import { IDebugger } from './tokens';
@@ -44,6 +46,11 @@ export namespace Debugger {
    */
   export class Service extends DebuggerService {}
 
+  /**
+   * A concrete implementation of IDebugger.ISession.
+   */
+  export class Session extends DebuggerSession {}
+
   /**
    * A debugger sidebar.
    */

+ 1 - 3
src/handler.ts

@@ -27,8 +27,6 @@ import { DisposableSet } from '@lumino/disposable';
 
 import { Debugger } from './debugger';
 
-import { DebugSession } from './session';
-
 import { IDebugger } from './tokens';
 
 import { ConsoleHandler } from './handlers/console';
@@ -301,7 +299,7 @@ export class DebuggerHandler {
 
     // update the active debug session
     if (!this._service.session) {
-      this._service.session = new DebugSession({ connection });
+      this._service.session = new Debugger.Session({ connection });
     } else {
       this._previousConnection = this._service.session.connection.kernel
         ? this._service.session.connection

+ 5 - 5
src/session.ts

@@ -12,13 +12,13 @@ import { IDebugger } from './tokens';
 /**
  * A concrete implementation of IDebugger.ISession.
  */
-export class DebugSession implements IDebugger.ISession {
+export class DebuggerSession implements IDebugger.ISession {
   /**
    * Instantiate a new debug session
    *
    * @param options - The debug session instantiation options.
    */
-  constructor(options: DebugSession.IOptions) {
+  constructor(options: DebuggerSession.IOptions) {
     this.connection = options.connection;
   }
 
@@ -216,11 +216,11 @@ export class DebugSession implements IDebugger.ISession {
 }
 
 /**
- * A namespace for `DebugSession` statics.
+ * A namespace for `DebuggerSession` statics.
  */
-export namespace DebugSession {
+export namespace DebuggerSession {
   /**
-   * Instantiation options for a `DebugSession`.
+   * Instantiation options for a `DebuggerSession`.
    */
   export interface IOptions {
     /**

+ 2 - 4
test/debugger.spec.ts

@@ -31,8 +31,6 @@ import { DebuggerService } from '../src/service';
 
 import { DebuggerModel } from '../src/model';
 
-import { DebugSession } from '../src/session';
-
 import { SourcesBody } from '../src/panels/sources/body';
 
 import { SourcesHeader } from '../src/panels/sources/header';
@@ -73,7 +71,7 @@ describe('Debugger', () => {
   ].join('\n');
 
   let breakpoints: IDebugger.IBreakpoint[];
-  let session: DebugSession;
+  let session: Debugger.Session;
   let path: string;
   let connection: Session.ISessionConnection;
   let sidebar: TestSidebar;
@@ -86,7 +84,7 @@ describe('Debugger', () => {
     });
     await connection.changeKernel({ name: 'xpython' });
 
-    session = new DebugSession({ connection });
+    session = new Debugger.Session({ connection });
     service.session = session;
 
     sidebar = new TestSidebar({

+ 2 - 4
test/service.spec.ts

@@ -11,14 +11,12 @@ import {
 
 import { UUID, JSONExt } from '@lumino/coreutils';
 
-import { DebugSession } from '../src/session';
+import { Debugger } from '../src/debugger';
 
 import { IDebugger } from '../src/tokens';
 
 import { KERNELSPECS, handleRequest } from './utils';
 
-import { Debugger } from '../src/debugger';
-
 /**
  * A Test class to mock a KernelSpecManager
  */
@@ -112,7 +110,7 @@ describe('DebuggerService', () => {
       path: UUID.uuid4()
     });
     await connection.changeKernel({ name: 'xpython' });
-    session = new DebugSession({ connection });
+    session = new Debugger.Session({ connection });
     model = new Debugger.Model();
     config = new Debugger.Config();
     service = new Debugger.Service({ specsManager, config });

+ 10 - 10
test/session.spec.ts

@@ -15,9 +15,9 @@ import { PromiseDelegate, UUID } from '@lumino/coreutils';
 
 import { DebugProtocol } from 'vscode-debugprotocol';
 
-import { IDebugger } from '../src/tokens';
+import { Debugger } from '../src/debugger';
 
-import { DebugSession } from '../src/session';
+import { IDebugger } from '../src/tokens';
 
 const server = new JupyterServer();
 
@@ -30,7 +30,7 @@ afterAll(async () => {
   await server.shutdown();
 });
 
-describe('DebugSession', () => {
+describe('Debugger.Session', () => {
   let connection: Session.ISessionConnection;
 
   beforeEach(async () => {
@@ -49,7 +49,7 @@ describe('DebugSession', () => {
 
   describe('#isDisposed', () => {
     it('should return whether the object is disposed', () => {
-      const debugSession = new DebugSession({
+      const debugSession = new Debugger.Session({
         connection
       });
       expect(debugSession.isDisposed).toEqual(false);
@@ -60,7 +60,7 @@ describe('DebugSession', () => {
 
   describe('#eventMessage', () => {
     it('should be emitted when sending debug messages', async () => {
-      const debugSession = new DebugSession({
+      const debugSession = new Debugger.Session({
         connection
       });
       let events: string[] = [];
@@ -75,7 +75,7 @@ describe('DebugSession', () => {
 
   describe('#sendRequest success', () => {
     it('should send debug messages to the kernel', async () => {
-      const debugSession = new DebugSession({
+      const debugSession = new Debugger.Session({
         connection
       });
       await debugSession.start();
@@ -90,7 +90,7 @@ describe('DebugSession', () => {
 
   describe('#sendRequest failure', () => {
     it('should handle replies with success false', async () => {
-      const debugSession = new DebugSession({
+      const debugSession = new Debugger.Session({
         connection
       });
       await debugSession.start();
@@ -121,7 +121,7 @@ describe('protocol', () => {
   ];
 
   let connection: Session.ISessionConnection;
-  let debugSession: DebugSession;
+  let debugSession: Debugger.Session;
   let threadId = 1;
 
   beforeEach(async () => {
@@ -132,14 +132,14 @@ describe('protocol', () => {
       path
     });
     await connection.changeKernel({ name: 'xpython' });
-    debugSession = new DebugSession({
+    debugSession = new Debugger.Session({
       connection
     });
     await debugSession.start();
 
     const stoppedFuture = new PromiseDelegate<void>();
     debugSession.eventMessage.connect(
-      (sender: DebugSession, event: IDebugger.ISession.Event) => {
+      (sender: Debugger.Session, event: IDebugger.ISession.Event) => {
         switch (event.event) {
           case 'thread': {
             const msg = event as DebugProtocol.ThreadEvent;