浏览代码

Move Variables interfaces to tokens

Jeremy Tuloup 4 年之前
父节点
当前提交
807ae8502a
共有 6 个文件被更改,包括 49 次插入58 次删除
  1. 2 2
      src/panels/variables/grid.ts
  2. 1 5
      src/panels/variables/index.ts
  3. 6 38
      src/panels/variables/model.ts
  4. 3 3
      src/panels/variables/tree.tsx
  5. 1 1
      src/service.ts
  6. 36 9
      src/tokens.ts

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

@@ -208,7 +208,7 @@ export class VariableDataGridModel extends DataModel {
    *
    * @param scopes The scopes.
    */
-  setData(scopes: VariablesModel.IScope[]): void {
+  setData(scopes: IDebugger.IScope[]): void {
     this._clearData();
     this.emitChanged({
       type: 'model-reset',
@@ -278,7 +278,7 @@ export namespace VariablesBodyGrid {
     /**
      * The optional initial scopes data.
      */
-    scopes?: VariablesModel.IScope[];
+    scopes?: IDebugger.IScope[];
   }
 }
 

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

@@ -13,8 +13,6 @@ import { VariablesBodyGrid, VariablesGrid } from './grid';
 
 import { VariablesHeader } from './header';
 
-import { VariablesModel } from './model';
-
 import { VariablesBodyTree } from './tree';
 
 /**
@@ -109,9 +107,7 @@ export class Variables extends Panel {
  *
  * @param variable The variable.
  */
-export const convertType = (
-  variable: VariablesModel.IVariable
-): string | number => {
+export const convertType = (variable: IDebugger.IVariable): string | number => {
   const { type, value } = variable;
   switch (type) {
     case 'int':

+ 6 - 38
src/panels/variables/model.ts

@@ -3,8 +3,6 @@
 
 import { ISignal, Signal } from '@lumino/signaling';
 
-import { DebugProtocol } from 'vscode-debugprotocol';
-
 import { IDebugger } from '../../tokens';
 
 /**
@@ -14,14 +12,14 @@ export class VariablesModel implements IDebugger.Model.IVariables {
   /**
    * Get all the scopes.
    */
-  get scopes(): VariablesModel.IScope[] {
+  get scopes(): IDebugger.IScope[] {
     return this._state;
   }
 
   /**
    * Set the scopes.
    */
-  set scopes(scopes: VariablesModel.IScope[]) {
+  set scopes(scopes: IDebugger.IScope[]) {
     this._state = scopes;
     this._changed.emit();
   }
@@ -36,7 +34,7 @@ export class VariablesModel implements IDebugger.Model.IVariables {
   /**
    * Signal emitted when the current variable has been expanded.
    */
-  get variableExpanded(): ISignal<this, VariablesModel.IVariable> {
+  get variableExpanded(): ISignal<this, IDebugger.IVariable> {
     return this._variableExpanded;
   }
 
@@ -45,41 +43,11 @@ export class VariablesModel implements IDebugger.Model.IVariables {
    *
    * @param variable The variable to expand.
    */
-  expandVariable(variable: VariablesModel.IVariable): void {
+  expandVariable(variable: IDebugger.IVariable): void {
     this._variableExpanded.emit(variable);
   }
 
-  private _state: VariablesModel.IScope[] = [];
-  private _variableExpanded = new Signal<this, VariablesModel.IVariable>(this);
+  private _state: IDebugger.IScope[] = [];
+  private _variableExpanded = new Signal<this, IDebugger.IVariable>(this);
   private _changed = new Signal<this, void>(this);
 }
-
-/**
- * A namespace for VariablesModel `statics`.
- */
-export namespace VariablesModel {
-  /**
-   * An interface for a variable.
-   */
-  export interface IVariable extends DebugProtocol.Variable {
-    /**
-     * Whether the variable is expanded.
-     */
-    expanded?: boolean;
-  }
-
-  /**
-   * An interface for a scope.
-   */
-  export interface IScope {
-    /**
-     * The name of the scope.
-     */
-    name: string;
-
-    /**
-     * The list of variables.
-     */
-    variables: IVariable[];
-  }
-}

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

@@ -73,7 +73,7 @@ export class VariablesBodyTree extends ReactWidget {
     this.update();
   }
 
-  private _scopes: VariablesModel.IScope[] = [];
+  private _scopes: IDebugger.IScope[] = [];
   private _filter = new Set<string>();
   private _service: IDebugger;
 }
@@ -91,7 +91,7 @@ const VariablesComponent = ({
   service,
   filter
 }: {
-  data: VariablesModel.IVariable[];
+  data: IDebugger.IVariable[];
   service: IDebugger;
   filter?: Set<string>;
 }): JSX.Element => {
@@ -133,7 +133,7 @@ const VariableComponent = ({
   service,
   filter
 }: {
-  data: VariablesModel.IVariable;
+  data: IDebugger.IVariable;
   service: IDebugger;
   filter?: Set<string>;
 }): JSX.Element => {

+ 1 - 1
src/service.ts

@@ -411,7 +411,7 @@ export class DebuggerService implements IDebugger, IDisposable {
   private _convertScopes(
     scopes: DebugProtocol.Scope[],
     variables: DebugProtocol.Variable[]
-  ): VariablesModel.IScope[] {
+  ): IDebugger.IScope[] {
     if (!variables || !scopes) {
       return;
     }

+ 36 - 9
src/tokens.ts

@@ -13,10 +13,6 @@ import { ISignal, Signal } from '@lumino/signaling';
 
 import { DebugProtocol } from 'vscode-debugprotocol';
 
-import { SourcesModel } from './panels/sources/model';
-
-import { VariablesModel } from './panels/variables/model';
-
 /**
  * An interface describing an application's visual debugger.
  */
@@ -180,6 +176,31 @@ export namespace IDebugger {
     active: boolean;
   }
 
+  /**
+   * An interface for a variable.
+   */
+  export interface IVariable extends DebugProtocol.Variable {
+    /**
+     * Whether the variable is expanded.
+     */
+    expanded?: boolean;
+  }
+
+  /**
+   * An interface for a scope.
+   */
+  export interface IScope {
+    /**
+     * The name of the scope.
+     */
+    name: string;
+
+    /**
+     * The list of variables.
+     */
+    variables: IVariable[];
+  }
+
   /**
    * Debugger file and hashing configuration.
    */
@@ -656,12 +677,18 @@ export namespace IDebugger {
       /**
        * Signal emitted when the current source changes.
        */
-      readonly currentSourceChanged: ISignal<SourcesModel, IDebugger.Source>;
+      readonly currentSourceChanged: ISignal<
+        IDebugger.Model.ISources,
+        IDebugger.Source
+      >;
 
       /**
        * Signal emitted when a source should be open in the main area.
        */
-      readonly currentSourceOpened: ISignal<SourcesModel, IDebugger.Source>;
+      readonly currentSourceOpened: ISignal<
+        IDebugger.Model.ISources,
+        IDebugger.Source
+      >;
 
       /**
        * Open a source in the main area.
@@ -681,19 +708,19 @@ export namespace IDebugger {
       /**
        * The variable scopes.
        */
-      scopes: VariablesModel.IScope[];
+      scopes: IDebugger.IScope[];
 
       /**
        * Signal emitted when the current variable has been expanded.
        */
-      readonly variableExpanded: ISignal<this, VariablesModel.IVariable>;
+      readonly variableExpanded: ISignal<this, IDebugger.IVariable>;
 
       /**
        * Expand a variable.
        *
        * @param variable The variable to expand.
        */
-      expandVariable(variable: VariablesModel.IVariable): void;
+      expandVariable(variable: IDebugger.IVariable): void;
     }
   }
 }