Prechádzať zdrojové kódy

Rename CellManager to EditorHandler

Jeremy Tuloup 5 rokov pred
rodič
commit
8cb8b8c5a7
3 zmenil súbory, kde vykonal 30 pridanie a 34 odobranie
  1. 12 14
      src/handlers/console.ts
  2. 9 10
      src/handlers/editor.ts
  3. 9 10
      src/handlers/notebook.ts

+ 12 - 14
src/handlers/console.ts

@@ -11,7 +11,7 @@ import { Signal } from '@phosphor/signaling';
 
 import { Breakpoints } from '../breakpoints';
 
-import { CellManager } from '../handlers/editor';
+import { EditorHandler } from '../handlers/editor';
 
 import { IDebugger } from '../tokens';
 
@@ -23,12 +23,11 @@ export class ConsoleHandler implements IDisposable {
     this.debuggerService = options.debuggerService;
     this.consoleTracker = options.tracker;
     this.breakpoints = this.debuggerModel.breakpointsModel;
-    this.cellManager = new CellManager({
+    this.editorHandler = new EditorHandler({
       activeCell: this.consoleTracker.currentWidget.console.promptCell,
       breakpointsModel: this.breakpoints,
       debuggerModel: this.debuggerModel,
-      debuggerService: this.debuggerService,
-      type: 'console'
+      debuggerService: this.debuggerService
     });
     this.consoleTracker.currentWidget.console.promptCellCreated.connect(
       this.promptCellCreated,
@@ -36,11 +35,6 @@ export class ConsoleHandler implements IDisposable {
     );
   }
 
-  private consoleTracker: IConsoleTracker;
-  private debuggerModel: Debugger.Model;
-  private debuggerService: IDebugger;
-  private breakpoints: Breakpoints.Model;
-  private cellManager: CellManager;
   isDisposed: boolean;
 
   dispose(): void {
@@ -48,16 +42,20 @@ export class ConsoleHandler implements IDisposable {
       return;
     }
     this.isDisposed = true;
-    this.cellManager.dispose();
+    this.editorHandler.dispose();
     Signal.clearData(this);
   }
 
   protected promptCellCreated(sender: CodeConsole, update: CodeCell) {
-    if (this.cellManager) {
-      this.cellManager.previousCell = this.cellManager.activeCell;
-      this.cellManager.activeCell = update;
-    }
+    this.editorHandler.previousCell = this.editorHandler.activeCell;
+    this.editorHandler.activeCell = update;
   }
+
+  private consoleTracker: IConsoleTracker;
+  private debuggerModel: Debugger.Model;
+  private debuggerService: IDebugger;
+  private breakpoints: Breakpoints.Model;
+  private editorHandler: EditorHandler;
 }
 
 export namespace DebuggerConsoleHandler {

+ 9 - 10
src/handlers/editor.ts

@@ -15,7 +15,7 @@ import { Signal } from '@phosphor/signaling';
 
 import { Editor } from 'codemirror';
 
-import { Breakpoints, SessionTypes } from '../breakpoints';
+import { Breakpoints } from '../breakpoints';
 
 import { Callstack } from '../callstack';
 
@@ -27,8 +27,8 @@ const LINE_HIGHLIGHT_CLASS = 'jp-breakpoint-line-highlight';
 
 const CELL_CHANGED_TIMEOUT = 1000;
 
-export class CellManager implements IDisposable {
-  constructor(options: CellManager.IOptions) {
+export class EditorHandler implements IDisposable {
+  constructor(options: EditorHandler.IOptions) {
     // TODO: should we use the client name or a debug session id?
     this._id = options.debuggerService.session.client.name;
     this._debuggerService = options.debuggerService;
@@ -48,7 +48,7 @@ export class CellManager implements IDisposable {
 
     this._debuggerModel.callstackModel.currentFrameChanged.connect(
       (_, frame) => {
-        CellManager.clearHighlight(this.activeCell);
+        EditorHandler.clearHighlight(this.activeCell);
         if (!frame) {
           return;
         }
@@ -86,8 +86,8 @@ export class CellManager implements IDisposable {
       this._cellMonitor.dispose();
     }
     this.removeGutterClick(this.activeCell);
-    CellManager.clearHighlight(this.activeCell);
-    CellManager.clearGutter(this.activeCell);
+    EditorHandler.clearHighlight(this.activeCell);
+    EditorHandler.clearGutter(this.activeCell);
     Signal.clearData(this);
     this.isDisposed = true;
   }
@@ -201,7 +201,7 @@ export class CellManager implements IDisposable {
     }
 
     editor.focus();
-    CellManager.clearGutter(this.activeCell);
+    EditorHandler.clearGutter(this.activeCell);
 
     const isRemoveGutter = !!info.gutterMarkers;
     let breakpoints: Breakpoints.IBreakpoint[] = this.getBreakpoints(
@@ -232,7 +232,7 @@ export class CellManager implements IDisposable {
       breakpoints.length === 0 &&
       this._id === this._debuggerService.session.client.name
     ) {
-      CellManager.clearGutter(cell);
+      EditorHandler.clearGutter(cell);
     } else {
       breakpoints.forEach(breakpoint => {
         editor.editor.setGutterMarker(
@@ -274,13 +274,12 @@ export class CellManager implements IDisposable {
   > = null;
 }
 
-export namespace CellManager {
+export namespace EditorHandler {
   export interface IOptions {
     debuggerModel: Debugger.Model;
     debuggerService: IDebugger;
     breakpointsModel: Breakpoints.Model;
     activeCell?: CodeCell;
-    type: SessionTypes;
   }
 
   /**

+ 9 - 10
src/handlers/notebook.ts

@@ -21,7 +21,7 @@ import { IDebugger } from '../tokens';
 
 import { Callstack } from '../callstack';
 
-import { CellManager } from './editor';
+import { EditorHandler } from './editor';
 
 export class NotebookHandler implements IDisposable {
   constructor(options: NotebookHandler.IOptions) {
@@ -33,11 +33,10 @@ export class NotebookHandler implements IDisposable {
     this.id = options.id;
     this.breakpoints = this.debuggerModel.breakpointsModel;
 
-    this.cellManager = new CellManager({
+    this.editorHandler = new EditorHandler({
       breakpointsModel: this.breakpoints,
       debuggerModel: this.debuggerModel,
       debuggerService: this.debuggerService,
-      type: 'notebook',
       activeCell: this.notebookTracker.activeCell as CodeCell
     });
 
@@ -60,15 +59,15 @@ export class NotebookHandler implements IDisposable {
     }
     this.isDisposed = true;
     this.cleanAllCells();
-    this.cellManager.dispose();
+    this.editorHandler.dispose();
     Signal.clearData(this);
   }
 
   protected cleanAllCells() {
     const cells = this.notebookPanel.content.widgets;
     cells.forEach(cell => {
-      CellManager.clearHighlight(cell);
-      CellManager.clearGutter(cell);
+      EditorHandler.clearHighlight(cell);
+      EditorHandler.clearGutter(cell);
     });
   }
 
@@ -79,7 +78,7 @@ export class NotebookHandler implements IDisposable {
     if (notebookTracker.currentWidget.id !== this.id) {
       return;
     }
-    this.cellManager.activeCell = codeCell;
+    this.editorHandler.activeCell = codeCell;
   }
 
   private onCurrentFrameChanged(
@@ -92,7 +91,7 @@ export class NotebookHandler implements IDisposable {
     }
 
     const cells = notebook.content.widgets;
-    cells.forEach(cell => CellManager.clearHighlight(cell));
+    cells.forEach(cell => EditorHandler.clearHighlight(cell));
 
     if (!frame) {
       return;
@@ -106,7 +105,7 @@ export class NotebookHandler implements IDisposable {
         return;
       }
       notebook.content.activeCellIndex = i;
-      CellManager.showCurrentLine(cell, frame);
+      EditorHandler.showCurrentLine(cell, frame);
     });
   }
 
@@ -114,8 +113,8 @@ export class NotebookHandler implements IDisposable {
   private debuggerModel: Debugger.Model;
   private debuggerService: IDebugger;
   private breakpoints: Breakpoints.Model;
-  private cellManager: CellManager;
   private notebookPanel: NotebookPanel;
+  private editorHandler: EditorHandler;
   private id: string;
 }