Browse Source

Move all model interface definitions to IDebugger.Model namespace

Afshin T. Darian 4 năm trước cách đây
mục cha
commit
b79e779e55

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

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

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

@@ -62,7 +62,7 @@ export namespace Breakpoints {
     /**
      * The breakpoints model.
      */
-    model: IDebugger.UI.IBreakpoints;
+    model: IDebugger.Model.IBreakpoints;
 
     /**
      * The debugger service.

+ 1 - 1
src/panels/breakpoints/model.ts

@@ -8,7 +8,7 @@ import { IDebugger } from '../../tokens';
 /**
  * A model for a list of breakpoints.
  */
-export class BreakpointsModel implements IDebugger.UI.IBreakpoints {
+export class BreakpointsModel implements IDebugger.Model.IBreakpoints {
   /**
    * Signal emitted when the model changes.
    */

+ 3 - 3
src/panels/callstack/body.tsx

@@ -16,7 +16,7 @@ export class CallstackBody extends ReactWidget {
    *
    * @param model The model for the callstack.
    */
-  constructor(model: IDebugger.UI.ICallstack) {
+  constructor(model: IDebugger.Model.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: IDebugger.UI.ICallstack;
+  private _model: IDebugger.Model.ICallstack;
 }
 
 /**
@@ -41,7 +41,7 @@ export class CallstackBody extends ReactWidget {
 const FramesComponent = ({
   model
 }: {
-  model: IDebugger.UI.ICallstack;
+  model: IDebugger.Model.ICallstack;
 }): JSX.Element => {
   const [frames, setFrames] = useState(model.frames);
   const [selected, setSelected] = useState(model.frame);

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

@@ -127,6 +127,6 @@ export namespace Callstack {
     /**
      * The model for the callstack.
      */
-    model: IDebugger.UI.ICallstack;
+    model: IDebugger.Model.ICallstack;
   }
 }

+ 1 - 1
src/panels/callstack/model.ts

@@ -10,7 +10,7 @@ import { IDebugger } from '../../tokens';
 /**
  * A model for a callstack.
  */
-export class CallstackModel implements IDebugger.UI.ICallstack {
+export class CallstackModel implements IDebugger.Model.ICallstack {
   /**
    * Get all the frames.
    */

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

@@ -128,7 +128,7 @@ export class SourcesBody extends Widget {
     this._editor.show();
   }
 
-  private _model: IDebugger.UI.ISources;
+  private _model: IDebugger.Model.ISources;
   private _editor: CodeEditorWrapper;
   private _editorHandler: EditorHandler;
   private _debuggerService: IDebugger;
@@ -151,7 +151,7 @@ export namespace SourcesBody {
     /**
      * The sources model.
      */
-    model: IDebugger.UI.ISources;
+    model: IDebugger.Model.ISources;
 
     /**
      * The editor services used to create new read-only editors.

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

@@ -18,7 +18,7 @@ export class SourcesHeader extends Widget {
    *
    * @param model The model for the Sources.
    */
-  constructor(model: IDebugger.UI.ISources) {
+  constructor(model: IDebugger.Model.ISources) {
     super({ node: document.createElement('header') });
 
     const layout = new PanelLayout();
@@ -53,7 +53,7 @@ export class SourcesHeader extends Widget {
 const SourcePathComponent = ({
   model
 }: {
-  model: IDebugger.UI.ISources;
+  model: IDebugger.Model.ISources;
 }): JSX.Element => {
   return (
     <UseSignal signal={model.currentSourceChanged} initialSender={model}>

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

@@ -65,7 +65,7 @@ export namespace Sources {
     /**
      * The model for the sources.
      */
-    model: IDebugger.UI.ISources;
+    model: IDebugger.Model.ISources;
 
     /**
      * The editor services used to create new read-only editors.

+ 1 - 1
src/panels/sources/model.ts

@@ -10,7 +10,7 @@ import { CallstackModel } from '../callstack/model';
 /**
  * The model to keep track of the current source being displayed.
  */
-export class SourcesModel implements IDebugger.UI.ISources {
+export class SourcesModel implements IDebugger.Model.ISources {
   /**
    * Instantiate a new Sources.Model
    *

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

@@ -66,7 +66,7 @@ export class VariablesBodyGrid extends Panel {
   }
 
   private _grid: VariablesGrid;
-  private _model: IDebugger.UI.IVariables;
+  private _model: IDebugger.Model.IVariables;
 }
 
 /**
@@ -270,7 +270,7 @@ export namespace VariablesBodyGrid {
     /**
      * The variables model.
      */
-    model: IDebugger.UI.IVariables;
+    model: IDebugger.Model.IVariables;
     /**
      * The commands registry.
      */

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

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

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

@@ -10,7 +10,7 @@ import { IDebugger } from '../../tokens';
 /**
  * A model for a variable explorer.
  */
-export class VariablesModel implements IDebugger.UI.IVariables {
+export class VariablesModel implements IDebugger.Model.IVariables {
   /**
    * Get all the scopes.
    */

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

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

+ 3 - 3
src/service.ts

@@ -63,9 +63,9 @@ export class DebuggerService implements IDebugger, IDisposable {
   }
 
   /**
-   * Returns the debugger model.
+   * Returns the debugger service's model.
    */
-  get model(): IDebugger.IModel {
+  get model(): IDebugger.Model.IService {
     return this._model;
   }
 
@@ -643,7 +643,7 @@ export class DebuggerService implements IDebugger, IDisposable {
   private _debuggerSources: IDebugger.ISources | null;
   private _eventMessage = new Signal<IDebugger, IDebugger.ISession.Event>(this);
   private _isDisposed = false;
-  private _model: IDebugger.IModel;
+  private _model: IDebugger.Model.IService;
   private _session: IDebugger.ISession;
   private _sessionChanged = new Signal<IDebugger, IDebugger.ISession>(this);
   private _specsManager: KernelSpec.IManager;

+ 49 - 49
src/tokens.ts

@@ -34,9 +34,9 @@ export interface IDebugger {
   readonly isStarted: boolean;
 
   /**
-   * The model of the debugger.
+   * The debugger service's model.
    */
-  readonly model: IDebugger.IModel;
+  readonly model: IDebugger.Model.IService;
 
   /**
    * The current debugger session.
@@ -204,51 +204,6 @@ export namespace IDebugger {
     setTmpFileParams(params: IConfig.FileParams): void;
   }
 
-  /**
-   * The data model for the debugger.
-   */
-  export interface IModel {
-    /**
-     * The breakpoints UI model.
-     */
-    readonly breakpoints: UI.IBreakpoints;
-
-    /**
-     * The callstack UI model.
-     */
-    readonly callstack: UI.ICallstack;
-
-    /**
-     * The variables UI model.
-     */
-    readonly variables: UI.IVariables;
-
-    /**
-     * The sources UI model.
-     */
-    readonly sources: UI.ISources;
-
-    /**
-     * The set of threads in stopped state.
-     */
-    stoppedThreads: Set<number>;
-
-    /**
-     * The current debugger title.
-     */
-    title: string;
-
-    /**
-     * A signal emitted when the title changes.
-     */
-    titleChanged: ISignal<this, string>;
-
-    /**
-     * Clear the model.
-     */
-    clear(): void;
-  }
-
   /**
    * A visual debugger session.
    */
@@ -558,9 +513,9 @@ export namespace IDebugger {
   }
 
   /**
-   * A namespace for UI interface definitions.
+   * A namespace for UI model definitions.
    */
-  export namespace UI {
+  export namespace Model {
     /**
      * The breakpoints UI model.
      */
@@ -633,6 +588,51 @@ export namespace IDebugger {
       readonly framesChanged: ISignal<this, CallstackModel.IFrame[]>;
     }
 
+    /**
+     * The data model for the debugger service.
+     */
+    export interface IService {
+      /**
+       * The breakpoints UI model.
+       */
+      readonly breakpoints: IBreakpoints;
+
+      /**
+       * The callstack UI model.
+       */
+      readonly callstack: ICallstack;
+
+      /**
+       * The variables UI model.
+       */
+      readonly variables: IVariables;
+
+      /**
+       * The sources UI model.
+       */
+      readonly sources: ISources;
+
+      /**
+       * The set of threads in stopped state.
+       */
+      stoppedThreads: Set<number>;
+
+      /**
+       * The current debugger title.
+       */
+      title: string;
+
+      /**
+       * A signal emitted when the title changes.
+       */
+      titleChanged: ISignal<this, string>;
+
+      /**
+       * Clear the model.
+       */
+      clear(): void;
+    }
+
     /**
      * The sources UI model.
      */