Browse Source

Update some conventions, add license, minor clean up.

Afshin T. Darian 5 years ago
parent
commit
befcfa2069

+ 4 - 1
src/breakpoints/index.ts

@@ -1 +1,4 @@
-export * from './widget';
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+export * from './widget';

+ 2 - 0
src/breakpoints/utils/index.ts

@@ -0,0 +1,2 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.

+ 11 - 9
src/breakpoints/widget.ts

@@ -1,27 +1,29 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
 import { Widget, Panel } from '@phosphor/widgets';
+
 import { ToolbarWidget } from '../utils';
 
 export class BreakPointsWidget extends Panel {
+  readonly body: Panel;
+
   readonly header: Panel;
+
   readonly label: Widget;
-  readonly body: Panel;
-  readonly toolbar: ToolbarWidget;
 
-  readonly model_header = {
-    label: 'BreakPoints',
-    class: 'jp-DebuggerSidebarVariables-header'
-  };
+  readonly toolbar: ToolbarWidget;
 
   constructor() {
     super();
 
     this.header = new Panel();
-    this.header.addClass(this.model_header.class);
+    this.header.addClass('jp-DebuggerSidebarVariables-header');
     this.addWidget(this.header);
 
     this.label = new Widget();
-    this.label.node.textContent = this.model_header.label;
-    this.label.addClass(this.model_header.class + '-label');
+    this.label.node.textContent = 'BreakPoints';
+    this.label.addClass('jp-DebuggerSidebarVariables-header-label');
     this.header.addWidget(this.label);
 
     this.toolbar = new ToolbarWidget();

+ 4 - 1
src/callstack/index.ts

@@ -1 +1,4 @@
-export * from './widget';
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+export * from './widget';

+ 10 - 11
src/callstack/widget.ts

@@ -1,30 +1,29 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
 import { Widget, Panel } from '@phosphor/widgets';
+
 import { ToolbarWidget } from '../utils';
 
 export class CallstackWidget extends Panel {
   readonly header: Panel;
+
   readonly label: Widget;
-  readonly toolbar: ToolbarWidget;
 
-  readonly model_header = {
-    label: 'CallStack',
-    class: 'jp-DebuggerSidebarVariables-header'
-  };
+  readonly toolbar: ToolbarWidget;
 
   constructor() {
     super();
-    // header
+
     this.header = new Panel();
-    this.header.addClass(this.model_header.class);
+    this.header.addClass('jp-DebuggerSidebarVariables-header');
     this.addWidget(this.header);
 
     this.label = new Widget();
-    this.label.node.textContent = this.model_header.label;
-    this.label.addClass(this.model_header.class + '-label');
+    this.label.node.textContent = 'Call stack';
+    this.label.addClass('jp-DebuggerSidebarVariables-header-label');
     this.header.addWidget(this.label);
 
-    console.log('adding toolbar');
-    //toolbar
     this.toolbar = new ToolbarWidget();
     this.toolbar.createSpanElement(`fa fa-active`, 'Continue');
     this.toolbar.createSpanElement(`fa fa-stop`, 'Stop');

+ 11 - 6
src/sidebar.ts

@@ -2,17 +2,16 @@
 // Distributed under the terms of the Modified BSD License.
 
 import { SplitPanel } from '@phosphor/widgets';
-import { VariablesWidget } from './variables';
+
+import { BreakPointsWidget } from './breakpoints';
 
 import { Debugger } from './debugger';
+
 import { CallstackWidget } from './callstack';
-import { BreakPointsWidget } from './breakpoints';
 
-export class DebuggerSidebar extends SplitPanel {
-  variables: VariablesWidget;
-  callstack: CallstackWidget;
-  breakPoints: BreakPointsWidget;
+import { VariablesWidget } from './variables';
 
+export class DebuggerSidebar extends SplitPanel {
   constructor(model: Debugger.Model | null) {
     super();
     this.model = model;
@@ -28,6 +27,12 @@ export class DebuggerSidebar extends SplitPanel {
     this.addWidget(this.breakPoints);
   }
 
+  readonly variables: VariablesWidget;
+
+  readonly callstack: CallstackWidget;
+
+  readonly breakPoints: BreakPointsWidget;
+
   get model(): Debugger.Model | null {
     return this._model;
   }

+ 3 - 0
src/utils/index.ts

@@ -1 +1,4 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
 export * from './toolbar';

+ 4 - 0
src/utils/toolbar.ts

@@ -1,6 +1,10 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
 import { Widget } from '@phosphor/widgets';
 
 const TOOLBAR_CLASS = 'jp-DebuggerToolbar';
+
 const TOOLBAR_ITEM_CLASS = TOOLBAR_CLASS + '-item';
 
 export class ToolbarWidget extends Widget {

+ 4 - 1
src/variables/index.ts

@@ -1 +1,4 @@
-export * from './widget';
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+export * from './widget';

+ 14 - 13
src/variables/model.ts

@@ -1,6 +1,10 @@
-import { IVariable } from './variable';
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
 import { Signal, ISignal } from '@phosphor/signaling';
 
+import { IVariable } from './variable';
+
 export interface IVariablesModel {
   filter: string;
   variables: IVariable[];
@@ -30,11 +34,10 @@ export class Model implements IVariablesModel {
 
   get variables(): IVariable[] {
     if (this._filterState) {
-      return this._filterVariabiles();
+      return this._filterVariables();
     }
     return this._state;
   }
-
   set variables(variables: IVariable[]) {
     this._state = variables;
   }
@@ -42,7 +45,6 @@ export class Model implements IVariablesModel {
   get variable(): IVariable {
     return this._currentVariabile;
   }
-
   set variable(variable: IVariable) {
     if (this._currentVariabile === variable) {
       return;
@@ -54,35 +56,34 @@ export class Model implements IVariablesModel {
   get filter() {
     return this._filterState;
   }
-
   set filter(value) {
     if (this._filterState === value) {
       return;
     }
     this._filterState = value;
-    this._changeVariables.emit(this._filterVariabiles());
+    this._changeVariables.emit(this._filterVariables());
   }
 
   getCurrentVariables(): IVariable[] {
     return this.variables;
   }
 
-  fstFil = function(item_name: string) {
+  fstFil(name: string): boolean {
     return (
       this._filterState
         .split('')
-        .filter((ele: string, index: number) => item_name[index] === ele)
+        .filter((ele: string, index: number) => name[index] === ele)
         .join('') === this._filterState
     );
-  };
+  }
 
-  private _filterVariabiles(): IVariable[] {
+  private _filterVariables(): IVariable[] {
     return this._state.filter(ele => this.fstFil(ele.name));
   }
 
-  private _currentVariabile: IVariable;
-  private _state: IVariable[];
-  private _filterState: string = '';
   private _changeCurrentVariable = new Signal<this, IVariable>(this);
   private _changeVariables = new Signal<this, IVariable[]>(this);
+  private _currentVariabile: IVariable;
+  private _filterState: string = '';
+  private _state: IVariable[];
 }

+ 27 - 27
src/variables/variable.ts

@@ -1,29 +1,29 @@
-
-
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
 
 export interface IVariable {
-    /**
-     * The name of this variable.
-     */
-    readonly name: string;
-    /**
-     * The value of this variable.
-     */
-    readonly value: string;
-    /**
-     * The type of this variable.
-     */
-    readonly type: string | undefined;
-    /**
-     * The description of the variable.
-     */
-    readonly description: string | undefined;
-    /**
-     * a data URI or null.
-     */
-    readonly dataUri?: string;
-    /**
-     * a data URI or null.
-     */
-    readonly sourceUri?: string;
-}
+  /**
+   * The name of this variable.
+   */
+  readonly name: string;
+  /**
+   * The value of this variable.
+   */
+  readonly value: string;
+  /**
+   * The type of this variable.
+   */
+  readonly type: string | undefined;
+  /**
+   * The description of the variable.
+   */
+  readonly description: string | undefined;
+  /**
+   * a data URI or null.
+   */
+  readonly dataUri?: string;
+  /**
+   * a data URI or null.
+   */
+  readonly sourceUri?: string;
+}

+ 23 - 21
src/variables/widget.ts

@@ -1,5 +1,10 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
 import { Panel } from '@phosphor/widgets';
+
 import { IVariablesModel } from './model';
+
 import { VariableDescription } from './utils';
 
 const MOCK_DATA_ROW = {
@@ -20,37 +25,34 @@ const MOCK_DATA_ROW = {
 };
 
 export class VariablesWidget extends Panel {
-  readonly model: IVariablesModel;
-
-  readonly header: Panel;
-  readonly label: Panel;
-  readonly body: Panel;
-  readonly variable: Panel;
-  readonly searcher: Panel;
-
-  readonly model_header = {
-    label: 'Variables',
-    class: 'jp-DebuggerSidebarVariables-header'
-  };
-
   constructor() {
     super();
 
     this.model = IVariablesModel.create(MOCK_DATA_ROW.variables);
 
-    // header
     this.header = new Panel();
-    this.header.addClass(this.model_header.class);
+    this.header.addClass('jp-DebuggerSidebarVariables-header');
     this.addWidget(this.header);
 
     this.label = new Panel();
-    this.label.node.textContent = this.model_header.label;
-    this.label.addClass(this.model_header.class + '-label');
+    this.label.node.textContent = 'Variables';
+    this.label.addClass('jp-DebuggerSidebarVariables-header-label');
     this.header.addWidget(this.label);
 
-    //body
-    this.variable = new VariableDescription(this.model);
-    this.variable.addClass('jp-DebuggerSidebarVariables-body');
-    this.addWidget(this.variable);
+    this.variables = new VariableDescription(this.model);
+    this.variables.addClass('jp-DebuggerSidebarVariables-body');
+    this.addWidget(this.variables);
   }
+
+  readonly body: Panel;
+
+  readonly header: Panel;
+
+  readonly label: Panel;
+
+  readonly model: IVariablesModel;
+
+  readonly searcher: Panel;
+
+  readonly variables: Panel;
 }