浏览代码

Remove casts to Debugger.Model

Jeremy Tuloup 4 年之前
父节点
当前提交
1fda19d0da

+ 1 - 1
src/debugger.ts

@@ -68,7 +68,7 @@ export namespace Debugger {
 
       const { callstackCommands, editorServices, service } = options;
 
-      const model = service.model as Debugger.Model;
+      const model = service.model;
 
       this.variables = new VariablesPanel({
         model: model.variables,

+ 1 - 1
src/handler.ts

@@ -226,7 +226,7 @@ export class DebuggerHandler {
       // clear the model if the handler being removed corresponds
       // to the current active debug session
       if (this._service.session?.connection?.path === connection?.path) {
-        const model = this._service.model as Debugger.Model;
+        const model = this._service.model;
         model.clear();
       }
 

+ 1 - 1
src/index.ts

@@ -345,7 +345,7 @@ const variables: JupyterFrontEndPlugin<void> = {
           return;
         }
 
-        const model = (service.model as Debugger.Model).variables;
+        const model = service.model.variables;
         const widget = new MainAreaWidget<VariablesBodyGrid>({
           content: new VariablesBodyGrid({
             model,

+ 7 - 9
src/panels/breakpoints/body.tsx

@@ -7,8 +7,6 @@ import React, { useEffect, useState } from 'react';
 
 import { IDebugger } from '../../tokens';
 
-import { BreakpointsModel } from './model';
-
 /**
  * The body for a Breakpoints Panel.
  */
@@ -18,7 +16,7 @@ export class BreakpointsBody extends ReactWidget {
    *
    * @param model The model for the breakpoints.
    */
-  constructor(model: BreakpointsModel) {
+  constructor(model: IDebugger.UI.IBreakpoints) {
     super();
     this._model = model;
     this.addClass('jp-DebuggerBreakpoints-body');
@@ -31,7 +29,7 @@ export class BreakpointsBody extends ReactWidget {
     return <BreakpointsComponent model={this._model} />;
   }
 
-  private _model: BreakpointsModel;
+  private _model: IDebugger.UI.IBreakpoints;
 }
 
 /**
@@ -43,7 +41,7 @@ export class BreakpointsBody extends ReactWidget {
 const BreakpointsComponent = ({
   model
 }: {
-  model: BreakpointsModel;
+  model: IDebugger.UI.IBreakpoints;
 }): JSX.Element => {
   const [breakpoints, setBreakpoints] = useState(
     Array.from(model.breakpoints.entries())
@@ -51,13 +49,13 @@ const BreakpointsComponent = ({
 
   useEffect(() => {
     const updateBreakpoints = (
-      _: BreakpointsModel,
+      _: IDebugger.UI.IBreakpoints,
       updates: IDebugger.IBreakpoint[]
     ): void => {
       setBreakpoints(Array.from(model.breakpoints.entries()));
     };
 
-    const restoreBreakpoints = (_: BreakpointsModel): void => {
+    const restoreBreakpoints = (_: IDebugger.UI.IBreakpoints): void => {
       setBreakpoints(Array.from(model.breakpoints.entries()));
     };
 
@@ -95,7 +93,7 @@ const BreakpointCellComponent = ({
   model
 }: {
   breakpoints: IDebugger.IBreakpoint[];
-  model: BreakpointsModel;
+  model: IDebugger.UI.IBreakpoints;
 }): JSX.Element => {
   return (
     <>
@@ -126,7 +124,7 @@ const BreakpointComponent = ({
   model
 }: {
   breakpoint: IDebugger.IBreakpoint;
-  model: BreakpointsModel;
+  model: IDebugger.UI.IBreakpoints;
 }): JSX.Element => {
   const moveToEndFirstCharIfSlash = (breakpointSourcePath: string): string => {
     return breakpointSourcePath[0] === '/'

+ 1 - 3
src/panels/breakpoints/index.ts

@@ -15,8 +15,6 @@ import { BreakpointsBody } from './body';
 
 import { BreakpointsHeader } from './header';
 
-import { BreakpointsModel } from './model';
-
 /**
  * A Panel to show a list of breakpoints.
  */
@@ -64,7 +62,7 @@ export namespace Breakpoints {
     /**
      * The breakpoints model.
      */
-    model: BreakpointsModel;
+    model: IDebugger.UI.IBreakpoints;
 
     /**
      * The debugger service.

+ 8 - 4
src/panels/callstack/body.tsx

@@ -5,7 +5,7 @@ import { ReactWidget } from '@jupyterlab/apputils';
 
 import React, { useEffect, useState } from 'react';
 
-import { CallstackModel } from './model';
+import { IDebugger } from '../../tokens';
 
 /**
  * The body for a Callstack Panel.
@@ -16,7 +16,7 @@ export class CallstackBody extends ReactWidget {
    *
    * @param model The model for the callstack.
    */
-  constructor(model: CallstackModel) {
+  constructor(model: IDebugger.UI.ICallstack) {
     super();
     this._model = model;
     this.addClass('jp-DebuggerCallstack-body');
@@ -29,7 +29,7 @@ export class CallstackBody extends ReactWidget {
     return <FramesComponent model={this._model} />;
   }
 
-  private _model: CallstackModel;
+  private _model: IDebugger.UI.ICallstack;
 }
 
 /**
@@ -38,7 +38,11 @@ export class CallstackBody extends ReactWidget {
  * @param {object} props The component props.
  * @param props.model The model for the callstack.
  */
-const FramesComponent = ({ model }: { model: CallstackModel }): JSX.Element => {
+const FramesComponent = ({
+  model
+}: {
+  model: IDebugger.UI.ICallstack;
+}): JSX.Element => {
   const [frames, setFrames] = useState(model.frames);
   const [selected, setSelected] = useState(model.frame);
 

+ 2 - 2
src/panels/callstack/index.ts

@@ -11,7 +11,7 @@ import { CallstackBody } from './body';
 
 import { CallstackHeader } from './header';
 
-import { CallstackModel } from './model';
+import { IDebugger } from '../../tokens';
 
 /**
  * A Panel to show a callstack.
@@ -127,6 +127,6 @@ export namespace Callstack {
     /**
      * The model for the callstack.
      */
-    model: CallstackModel;
+    model: IDebugger.UI.ICallstack;
   }
 }

+ 2 - 4
src/panels/sources/body.ts

@@ -19,8 +19,6 @@ import { IDebugger } from '../../tokens';
 
 import { ReadOnlyEditorFactory } from './factory';
 
-import { SourcesModel } from './model';
-
 /**
  * The body for a Sources Panel.
  */
@@ -130,7 +128,7 @@ export class SourcesBody extends Widget {
     this._editor.show();
   }
 
-  private _model: SourcesModel;
+  private _model: IDebugger.UI.ISources;
   private _editor: CodeEditorWrapper;
   private _editorHandler: EditorHandler;
   private _debuggerService: IDebugger;
@@ -153,7 +151,7 @@ export namespace SourcesBody {
     /**
      * The sources model.
      */
-    model: SourcesModel;
+    model: IDebugger.UI.ISources;
 
     /**
      * The editor services used to create new read-only editors.

+ 3 - 3
src/panels/sources/header.tsx

@@ -5,7 +5,7 @@ import { ReactWidget, Toolbar, UseSignal } from '@jupyterlab/apputils';
 
 import { PanelLayout, Widget } from '@lumino/widgets';
 
-import { SourcesModel } from './model';
+import { IDebugger } from '../../tokens';
 
 import React from 'react';
 
@@ -18,7 +18,7 @@ export class SourcesHeader extends Widget {
    *
    * @param model The model for the Sources.
    */
-  constructor(model: SourcesModel) {
+  constructor(model: IDebugger.UI.ISources) {
     super({ node: document.createElement('header') });
 
     const layout = new PanelLayout();
@@ -53,7 +53,7 @@ export class SourcesHeader extends Widget {
 const SourcePathComponent = ({
   model
 }: {
-  model: SourcesModel;
+  model: IDebugger.UI.ISources;
 }): JSX.Element => {
   return (
     <UseSignal signal={model.currentSourceChanged} initialSender={model}>

+ 1 - 3
src/panels/sources/index.ts

@@ -17,8 +17,6 @@ import { SourcesBody } from './body';
 
 import { SourcesHeader } from './header';
 
-import { SourcesModel } from './model';
-
 /**
  * A Panel that shows a preview of the source code while debugging.
  */
@@ -67,7 +65,7 @@ export namespace Sources {
     /**
      * The model for the sources.
      */
-    model: SourcesModel;
+    model: IDebugger.UI.ISources;
 
     /**
      * The editor services used to create new read-only editors.

+ 4 - 2
src/panels/variables/grid.ts

@@ -18,6 +18,8 @@ import { Panel } from '@lumino/widgets';
 
 import { CommandIDs } from '../../';
 
+import { IDebugger } from '../../tokens';
+
 import { VariablesModel } from './model';
 
 /**
@@ -64,7 +66,7 @@ export class VariablesBodyGrid extends Panel {
   }
 
   private _grid: VariablesGrid;
-  private _model: VariablesModel;
+  private _model: IDebugger.UI.IVariables;
 }
 
 /**
@@ -268,7 +270,7 @@ export namespace VariablesBodyGrid {
     /**
      * The variables model.
      */
-    model: VariablesModel;
+    model: IDebugger.UI.IVariables;
     /**
      * The commands registry.
      */

+ 1 - 1
src/panels/variables/index.ts

@@ -138,7 +138,7 @@ export namespace Variables {
     /**
      * The variables model.
      */
-    model: VariablesModel;
+    model: IDebugger.UI.IVariables;
     /**
      * The debugger service.
      */

+ 1 - 1
src/panels/variables/tree.tsx

@@ -197,7 +197,7 @@ namespace VariablesBodyTree {
     /**
      * The variables model.
      */
-    model: VariablesModel;
+    model: IDebugger.UI.IVariables;
     /**
      * The debugger service.
      */

+ 2 - 2
src/tokens.ts

@@ -9,7 +9,7 @@ import { Token } from '@lumino/coreutils';
 
 import { IObservableDisposable } from '@lumino/disposable';
 
-import { ISignal } from '@lumino/signaling';
+import { ISignal, Signal } from '@lumino/signaling';
 
 import { DebugProtocol } from 'vscode-debugprotocol';
 
@@ -171,7 +171,7 @@ export namespace IDebugger {
       /**
        * Signal emitted when a breakpoint is clicked.
        */
-      readonly clicked: ISignal<this, IDebugger.IBreakpoint>;
+      readonly clicked: Signal<this, IDebugger.IBreakpoint>;
 
       /**
        * Get all the breakpoints.