debugViewModel.ts 2.8 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
5

J
Johannes Rieken 已提交
6
import Event, { Emitter } from 'vs/base/common/event';
E
Erich Gamma 已提交
7 8
import debug = require('vs/workbench/parts/debug/common/debug');

9
export class ViewModel implements debug.IViewModel {
E
Erich Gamma 已提交
10 11

	private focusedStackFrame: debug.IStackFrame;
12
	private focusedThread: debug.IThread;
E
Erich Gamma 已提交
13
	private selectedExpression: debug.IExpression;
I
isidor 已提交
14
	private selectedFunctionBreakpoint: debug.IFunctionBreakpoint;
15
	private _activeSession: debug.IRawDebugSession;
16 17 18
	private _onDidFocusStackFrame: Emitter<debug.IStackFrame>;
	private _onDidSelectExpression: Emitter<debug.IExpression>;
	private _onDidSelectFunctionBreakpoint: Emitter<debug.IFunctionBreakpoint>;
19
	public changedWorkbenchViewState: boolean;
20 21 22 23 24

	constructor() {
		this._onDidFocusStackFrame = new Emitter<debug.IStackFrame>();
		this._onDidSelectExpression = new Emitter<debug.IExpression>();
		this._onDidSelectFunctionBreakpoint = new Emitter<debug.IFunctionBreakpoint>();
25
		this.changedWorkbenchViewState = false;
26
	}
E
Erich Gamma 已提交
27 28 29 30 31

	public getId(): string {
		return 'root';
	}

32 33 34 35
	public get activeSession(): debug.IRawDebugSession {
		return this._activeSession;
	}

E
Erich Gamma 已提交
36 37 38 39
	public getFocusedStackFrame(): debug.IStackFrame {
		return this.focusedStackFrame;
	}

40
	public setFocusedStackFrame(focusedStackFrame: debug.IStackFrame, focusedThread: debug.IThread, activeSession: debug.IRawDebugSession): void {
E
Erich Gamma 已提交
41
		this.focusedStackFrame = focusedStackFrame;
42
		this.focusedThread = focusedThread;
43
		this._activeSession = activeSession;
44 45 46 47 48
		this._onDidFocusStackFrame.fire(focusedStackFrame);
	}

	public get onDidFocusStackFrame(): Event<debug.IStackFrame> {
		return this._onDidFocusStackFrame.event;
E
Erich Gamma 已提交
49 50 51
	}

	public getFocusedThreadId(): number {
52
		return this.focusedThread ? this.focusedThread.threadId : 0;
E
Erich Gamma 已提交
53 54 55 56 57 58 59 60
	}

	public getSelectedExpression(): debug.IExpression {
		return this.selectedExpression;
	}

	public setSelectedExpression(expression: debug.IExpression) {
		this.selectedExpression = expression;
61 62 63 64 65
		this._onDidSelectExpression.fire(expression);
	}

	public get onDidSelectExpression(): Event<debug.IExpression> {
		return this._onDidSelectExpression.event;
E
Erich Gamma 已提交
66
	}
I
isidor 已提交
67 68 69 70 71 72 73

	public getSelectedFunctionBreakpoint(): debug.IFunctionBreakpoint {
		return this.selectedFunctionBreakpoint;
	}

	public setSelectedFunctionBreakpoint(functionBreakpoint: debug.IFunctionBreakpoint): void {
		this.selectedFunctionBreakpoint = functionBreakpoint;
74 75 76 77 78
		this._onDidSelectFunctionBreakpoint.fire(functionBreakpoint);
	}

	public get onDidSelectFunctionBreakpoint(): Event<debug.IFunctionBreakpoint> {
		return this._onDidSelectFunctionBreakpoint.event;
I
isidor 已提交
79
	}
E
Erich Gamma 已提交
80
}