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

6
import nls = require('vs/nls');
I
isidor 已提交
7
import { TPromise } from 'vs/base/common/winjs.base';
E
Erich Gamma 已提交
8
import lifecycle = require('vs/base/common/lifecycle');
I
isidor 已提交
9
import { CommonKeybindings } from 'vs/base/common/keyCodes';
E
Erich Gamma 已提交
10 11
import paths = require('vs/base/common/paths');
import async = require('vs/base/common/async');
12
import errors = require('vs/base/common/errors');
E
Erich Gamma 已提交
13 14 15 16 17 18 19 20
import strings = require('vs/base/common/strings');
import { isMacintosh } from 'vs/base/common/platform';
import dom = require('vs/base/browser/dom');
import mouse = require('vs/base/browser/mouseEvent');
import keyboard = require('vs/base/browser/keyboardEvent');
import labels = require('vs/base/common/labels');
import actions = require('vs/base/common/actions');
import actionbar = require('vs/base/browser/ui/actionbar/actionbar');
J
Joao Moreno 已提交
21
import tree = require('vs/base/parts/tree/browser/tree');
E
Erich Gamma 已提交
22 23 24 25 26 27
import inputbox = require('vs/base/browser/ui/inputbox/inputBox');
import treedefaults = require('vs/base/parts/tree/browser/treeDefaults');
import renderer = require('vs/base/parts/tree/browser/actionsRenderer');
import debug = require('vs/workbench/parts/debug/common/debug');
import model = require('vs/workbench/parts/debug/common/debugModel');
import viewmodel = require('vs/workbench/parts/debug/common/debugViewModel');
28
import debugactions = require('vs/workbench/parts/debug/electron-browser/debugActions');
E
Erich Gamma 已提交
29 30 31 32
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IMessageService } from 'vs/platform/message/common/message';
33
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
E
Erich Gamma 已提交
34

I
isidor 已提交
35 36 37
const $ = dom.emmet;
const booleanRegex = /^true|false$/i;
const stringRegex = /^(['"]).*\1$/;
E
Erich Gamma 已提交
38

39
export function renderExpressionValue(expressionOrValue: debug.IExpression|string, container: HTMLElement, showChanged: boolean): void {
40
	let value = typeof expressionOrValue === 'string' ? expressionOrValue : expressionOrValue.value;
E
Erich Gamma 已提交
41

I
isidor 已提交
42
	// remove stale classes
E
Erich Gamma 已提交
43
	container.className = 'value';
I
isidor 已提交
44
	// when resolving expressions we represent errors from the server as a variable with name === null.
45
	if (value === null || ((expressionOrValue instanceof model.Expression || expressionOrValue instanceof model.Variable) && !expressionOrValue.available)) {
E
Erich Gamma 已提交
46
		dom.addClass(container, 'unavailable');
47 48 49
		if (value !== model.Expression.DEFAULT_VALUE) {
			dom.addClass(container, 'error');
		}
E
Erich Gamma 已提交
50 51 52 53 54 55 56 57
	} else if (!isNaN(+value)) {
		dom.addClass(container, 'number');
	} else if (booleanRegex.test(value)) {
		dom.addClass(container, 'boolean');
	} else if (stringRegex.test(value)) {
		dom.addClass(container, 'string');
	}

58 59 60 61
	if (showChanged && (<any>expressionOrValue).valueChanged) {
		// value changed color has priority over other colors.
		container.className = 'value changed';
	}
E
Erich Gamma 已提交
62 63 64 65
	container.textContent = value;
	container.title = value;
}

66
export function renderVariable(tree: tree.ITree, variable: model.Variable, data: IVariableTemplateData, showChanged: boolean): void {
67
	if (variable.available) {
68
		data.name.textContent = variable.name + ':';
69 70
	}

E
Erich Gamma 已提交
71
	if (variable.value) {
72
		renderExpressionValue(variable, data.value, showChanged);
E
Erich Gamma 已提交
73 74 75 76 77 78
	} else {
		data.value.textContent = '';
		data.value.title = '';
	}
}

79
function renderRenameBox(debugService: debug.IDebugService, contextViewService: IContextViewService, tree: tree.ITree, element: any, container: HTMLElement, placeholder: string, ariaLabel: string): void {
80 81 82 83 84
	let inputBoxContainer = dom.append(container, $('.inputBoxContainer'));
	let inputBox = new inputbox.InputBox(inputBoxContainer, contextViewService, {
		validationOptions: {
			validation: null,
			showMessage: false
85
		},
86 87
		placeholder: placeholder,
		ariaLabel: ariaLabel
88 89
	});

90
	inputBox.value = element.name ? element.name : '';
91 92
	inputBox.focus();

I
isidor 已提交
93 94
	let disposed = false;
	const toDispose: [lifecycle.IDisposable] = [inputBox];
95

I
isidor 已提交
96
	const wrapUp = async.once<any, void>((renamed: boolean) => {
97 98
		if (!disposed) {
			disposed = true;
99 100 101 102 103 104 105
			if (element instanceof model.Expression && renamed && inputBox.value) {
				debugService.renameWatchExpression(element.getId(), inputBox.value).done(null, errors.onUnexpectedError);
			} else if (element instanceof model.Expression && !element.name) {
				debugService.clearWatchExpressions(element.getId());
			} else if (element instanceof model.FunctionBreakpoint && renamed && inputBox.value) {
				debugService.renameFunctionBreakpoint(element.getId(), inputBox.value).done(null, errors.onUnexpectedError);
			} else if (element instanceof model.FunctionBreakpoint && !element.name) {
106
				debugService.removeFunctionBreakpoints(element.getId()).done(null, errors.onUnexpectedError);
107
			}
108

109 110
			tree.clearHighlight();
			tree.DOMFocus();
111
			tree.setFocus(element);
112

I
isidor 已提交
113
			// need to remove the input box since this template will be reused.
114 115 116 117 118 119
			container.removeChild(inputBoxContainer);
			lifecycle.disposeAll(toDispose);
		}
	});

	toDispose.push(dom.addStandardDisposableListener(inputBox.inputElement, 'keydown', (e: dom.IKeyboardEvent) => {
I
isidor 已提交
120 121
		const isEscape = e.equals(CommonKeybindings.ESCAPE);
		const isEnter = e.equals(CommonKeybindings.ENTER);
122 123 124 125 126 127 128 129 130
		if (isEscape || isEnter) {
			wrapUp(isEnter);
		}
	}));
	toDispose.push(dom.addDisposableListener(inputBox.inputElement, 'blur', () => {
		wrapUp(true);
	}));
}

131 132 133 134 135 136 137 138
function getSourceName(source: Source, contextService: IWorkspaceContextService): string {
	if (source.inMemory) {
		return source.name;
	}

	return labels.getPathLabel(paths.basename(source.uri.fsPath), contextService);
}

E
Erich Gamma 已提交
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
export class BaseDebugController extends treedefaults.DefaultController {

	constructor(protected debugService: debug.IDebugService, private contextMenuService: IContextMenuService, private actionProvider: renderer.IActionProvider, private focusOnContextMenu = true) {
		super();

		if (isMacintosh) {
			this.downKeyBindingDispatcher.set(CommonKeybindings.CTRLCMD_BACKSPACE, this.onDelete.bind(this));
		} else {
			this.downKeyBindingDispatcher.set(CommonKeybindings.DELETE, this.onDelete.bind(this));
			this.downKeyBindingDispatcher.set(CommonKeybindings.SHIFT_DELETE, this.onDelete.bind(this));
		}
	}

	public onContextMenu(tree: tree.ITree, element: debug.IEnablement, event: tree.ContextMenuEvent): boolean {
		if (event.target && event.target.tagName && event.target.tagName.toLowerCase() === 'input') {
			return false;
		}

		event.preventDefault();
		event.stopPropagation();

		if (this.focusOnContextMenu) {
			tree.setFocus(element);
		}

		if (this.actionProvider.hasSecondaryActions(tree, element)) {
I
isidor 已提交
165
			const anchor = { x: event.posx + 1, y: event.posy };
E
Erich Gamma 已提交
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
			this.contextMenuService.showContextMenu({
				getAnchor: () => anchor,
				getActions: () => this.actionProvider.getSecondaryActions(tree, element),
				onHide: (wasCancelled?: boolean) => {
					if (wasCancelled) {
						tree.DOMFocus();
					}
				},
				getActionsContext: () => element
			});

			return true;
		}

		return false;
	}

	protected onDelete(tree: tree.ITree, event: keyboard.StandardKeyboardEvent): boolean {
		return false;
	}
}

I
isidor 已提交
188
// call stack
E
Erich Gamma 已提交
189 190 191 192 193 194 195 196 197 198 199

export class CallStackDataSource implements tree.IDataSource {

	public getId(tree: tree.ITree, element: any): string {
		return element.getId();
	}

	public hasChildren(tree: tree.ITree, element: any): boolean {
		return element instanceof model.Model || element instanceof model.Thread;
	}

I
isidor 已提交
200
	public getChildren(tree: tree.ITree, element: any): TPromise<any> {
E
Erich Gamma 已提交
201
		if (element instanceof model.Thread) {
A
Alex Dima 已提交
202
			return TPromise.as((<model.Thread> element).callStack);
E
Erich Gamma 已提交
203 204
		}

I
isidor 已提交
205 206
		const threads = (<model.Model> element).getThreads();
		const threadsArray: debug.IThread[] = [];
I
isidor 已提交
207 208 209
		Object.keys(threads).forEach(threadId => {
			threadsArray.push(threads[threadId]);
		});
E
Erich Gamma 已提交
210 211

		if (threadsArray.length === 1) {
A
Alex Dima 已提交
212
			return TPromise.as(threadsArray[0].callStack);
E
Erich Gamma 已提交
213
		} else {
A
Alex Dima 已提交
214
			return TPromise.as(threadsArray);
E
Erich Gamma 已提交
215 216 217
		}
	}

I
isidor 已提交
218
	public getParent(tree: tree.ITree, element: any): TPromise<any> {
A
Alex Dima 已提交
219
		return TPromise.as(null);
E
Erich Gamma 已提交
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
	}
}

interface IThreadTemplateData {
	name: HTMLElement;
}

interface IStackFrameTemplateData {
	stackFrame: HTMLElement;
	label : HTMLElement;
	file : HTMLElement;
	fileName : HTMLElement;
	lineNumber : HTMLElement;
}

export class CallStackRenderer implements tree.IRenderer {

	private static THREAD_TEMPLATE_ID = 'thread';
	private static STACK_FRAME_TEMPLATE_ID = 'stackFrame';

	constructor(@IWorkspaceContextService private contextService: IWorkspaceContextService) {
		// noop
	}

	public getHeight(tree:tree.ITree, element:any): number {
I
isidor 已提交
245
		return 22;
E
Erich Gamma 已提交
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
	}

	public getTemplateId(tree: tree.ITree, element: any): string {
		if (element instanceof model.Thread) {
			return CallStackRenderer.THREAD_TEMPLATE_ID;
		}
		if (element instanceof model.StackFrame) {
			return CallStackRenderer.STACK_FRAME_TEMPLATE_ID;
		}

		return null;
	}

	public renderTemplate(tree: tree.ITree, templateId: string, container: HTMLElement): any {
		if (templateId === CallStackRenderer.THREAD_TEMPLATE_ID) {
			let data: IThreadTemplateData = Object.create(null);
			data.name = dom.append(container, $('.thread'));

			return data;
		}

		let data: IStackFrameTemplateData = Object.create(null);
		data.stackFrame = dom.append(container, $('.stack-frame'));
		data.label = dom.append(data.stackFrame, $('span.label'));
		data.file = dom.append(data.stackFrame, $('.file'));
		data.fileName = dom.append(data.file, $('span.file-name'));
		data.lineNumber = dom.append(data.file, $('span.line-number'));

		return data;
	}

	public renderElement(tree: tree.ITree, element: any, templateId: string, templateData: any): void {
		if (templateId === CallStackRenderer.THREAD_TEMPLATE_ID) {
			this.renderThread(element, templateData);
		} else {
			this.renderStackFrame(element, templateData);
		}
	}

	private renderThread(thread: debug.IThread, data: IThreadTemplateData): void {
		data.name.textContent = thread.name;
	}

	private renderStackFrame(stackFrame: debug.IStackFrame, data: IStackFrameTemplateData): void {
		stackFrame.source.available ? dom.removeClass(data.stackFrame, 'disabled') : dom.addClass(data.stackFrame, 'disabled');
		data.file.title = stackFrame.source.uri.fsPath;
		data.label.textContent = stackFrame.name;
293
		data.fileName.textContent = getSourceName(stackFrame.source, this.contextService);
294
		data.lineNumber.textContent = stackFrame.lineNumber !== undefined ? `${ stackFrame.lineNumber }` : '';
E
Erich Gamma 已提交
295 296 297 298 299 300 301
	}

	public disposeTemplate(tree: tree.ITree, templateId: string, templateData: any): void {
		// noop
	}
}

302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
export class CallstackAccessibilityProvider implements tree.IAccessibilityProvider {

	constructor(@IWorkspaceContextService private contextService: IWorkspaceContextService) {
		// noop
	}

	public getAriaLabel(tree: tree.ITree, element: any): string {
		if (element instanceof model.Thread) {
			return nls.localize('threadAriaLabel', "Thread {0}, callstack, debug", (<model.Thread>element).name);
		}
		if (element instanceof model.StackFrame) {
			return nls.localize('stackFrameAriaLabel', "Stack Frame {0} on line {1} in {2}, callstack, debug", (<model.StackFrame>element).name, (<model.StackFrame>element).lineNumber, getSourceName((<model.StackFrame>element).source, this.contextService));
		}

		return null;
	}
}

I
isidor 已提交
320
// variables
E
Erich Gamma 已提交
321

I
isidor 已提交
322
export class VariablesActionProvider implements renderer.IActionProvider {
E
Erich Gamma 已提交
323 324 325 326 327 328 329 330 331 332 333

	private instantiationService: IInstantiationService;

	constructor(instantiationService: IInstantiationService) {
		this.instantiationService = instantiationService;
	}

	public hasActions(tree: tree.ITree, element: any): boolean {
		return false;
	}

I
isidor 已提交
334
	public getActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
A
Alex Dima 已提交
335
		return TPromise.as([]);
I
isidor 已提交
336 337
	}

E
Erich Gamma 已提交
338 339 340 341
	public hasSecondaryActions(tree: tree.ITree, element: any): boolean {
		return element instanceof model.Variable;
	}

I
isidor 已提交
342
	public getSecondaryActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
E
Erich Gamma 已提交
343 344
		let actions: actions.Action[] = [];
		const variable = <model.Variable> element;
I
isidor 已提交
345
		actions.push(this.instantiationService.createInstance(debugactions.AddToWatchExpressionsAction, debugactions.AddToWatchExpressionsAction.ID, debugactions.AddToWatchExpressionsAction.LABEL, variable));
E
Erich Gamma 已提交
346
		if (variable.reference === 0) {
I
isidor 已提交
347
			actions.push(this.instantiationService.createInstance(debugactions.CopyValueAction, debugactions.CopyValueAction.ID, debugactions.CopyValueAction.LABEL, variable));
E
Erich Gamma 已提交
348 349
		}

A
Alex Dima 已提交
350
		return TPromise.as(actions);
E
Erich Gamma 已提交
351
	}
I
isidor 已提交
352 353 354 355

	public getActionItem(tree: tree.ITree, element: any, action: actions.IAction): actionbar.IActionItem {
		return null;
	}
E
Erich Gamma 已提交
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
}

export class VariablesDataSource implements tree.IDataSource {

	constructor(private debugService: debug.IDebugService) {
		// noop
	}

	public getId(tree: tree.ITree, element: any): string {
		return element.getId();
	}

	public hasChildren(tree: tree.ITree, element: any): boolean {
		if (element instanceof viewmodel.ViewModel || element instanceof model.Scope) {
			return true;
		}

		let variable = <model.Variable> element;
		return variable.reference !== 0 && !strings.equalsIgnoreCase(variable.value, 'null');
	}

I
isidor 已提交
377
	public getChildren(tree: tree.ITree, element: any): TPromise<any> {
E
Erich Gamma 已提交
378 379
		if (element instanceof viewmodel.ViewModel) {
			let focusedStackFrame = (<viewmodel.ViewModel> element).getFocusedStackFrame();
A
Alex Dima 已提交
380
			return focusedStackFrame ? focusedStackFrame.getScopes(this.debugService) : TPromise.as([]);
E
Erich Gamma 已提交
381 382 383 384 385 386
		}

		let scope = <model.Scope> element;
		return scope.getChildren(this.debugService);
	}

I
isidor 已提交
387
	public getParent(tree: tree.ITree, element: any): TPromise<any> {
A
Alex Dima 已提交
388
		return TPromise.as(null);
E
Erich Gamma 已提交
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
	}
}

interface IScopeTemplateData {
	name: HTMLElement;
}

export interface IVariableTemplateData {
	expression: HTMLElement;
	name: HTMLElement;
	value: HTMLElement;
}

export class VariablesRenderer implements tree.IRenderer {

	private static SCOPE_TEMPLATE_ID = 'scope';
	private static VARIABLE_TEMPLATE_ID = 'variable';

407
	public getHeight(tree: tree.ITree, element: any): number {
I
isidor 已提交
408
		return 22;
E
Erich Gamma 已提交
409 410 411 412 413 414
	}

	public getTemplateId(tree: tree.ITree, element: any): string {
		if (element instanceof model.Scope) {
			return VariablesRenderer.SCOPE_TEMPLATE_ID;
		}
415
		if (element instanceof model.Variable) {
E
Erich Gamma 已提交
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
			return VariablesRenderer.VARIABLE_TEMPLATE_ID;
		}

		return null;
	}

	public renderTemplate(tree: tree.ITree, templateId: string, container: HTMLElement): any {
		if (templateId === VariablesRenderer.SCOPE_TEMPLATE_ID) {
			let data: IScopeTemplateData = Object.create(null);
			data.name = dom.append(container, $('.scope'));

			return data;
		}

		let data: IVariableTemplateData = Object.create(null);
		data.expression = dom.append(container, $(isMacintosh ? '.expression.mac' : '.expression.win-linux'));
		data.name = dom.append(data.expression, $('span.name'));
		data.value = dom.append(data.expression, $('span.value'));

		return data;
	}

	public renderElement(tree: tree.ITree, element: any, templateId: string, templateData: any): void {
		if (templateId === VariablesRenderer.SCOPE_TEMPLATE_ID) {
			this.renderScope(element, templateData);
		} else {
442
			renderVariable(tree, element, templateData, true);
E
Erich Gamma 已提交
443 444 445 446 447 448 449 450 451 452 453 454
		}
	}

	private renderScope(scope: model.Scope, data: IScopeTemplateData): void {
		data.name.textContent = scope.name;
	}

	public disposeTemplate(tree: tree.ITree, templateId: string, templateData: any): void {
		// noop
	}
}

455 456 457 458 459 460 461 462 463 464 465 466 467 468
export class VariablesAccessibilityProvider implements tree.IAccessibilityProvider {

	public getAriaLabel(tree: tree.ITree, element: any): string {
		if (element instanceof model.Scope) {
			return nls.localize('variableScopeAriaLabel', "Scope {0}, variables, debug", (<model.Scope>element).name);
		}
		if (element instanceof model.Variable) {
			return nls.localize('variableAriaLabel', "Variable {0} has value {1}, variables, debug", (<model.Variable>element).name, (<model.Variable>element).value);
		}

		return null;
	}
}

I
isidor 已提交
469
// watch expressions
E
Erich Gamma 已提交
470

I
isidor 已提交
471
export class WatchExpressionsActionProvider implements renderer.IActionProvider {
E
Erich Gamma 已提交
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486

	private instantiationService: IInstantiationService;

	constructor(instantiationService: IInstantiationService) {
		this.instantiationService = instantiationService;
	}

	public hasActions(tree: tree.ITree, element: any): boolean {
		return element instanceof model.Expression && element.name;
	}

	public hasSecondaryActions(tree: tree.ITree, element: any): boolean {
		return true;
	}

I
isidor 已提交
487
	public getActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
A
Alex Dima 已提交
488
		return TPromise.as(this.getExpressionActions());
E
Erich Gamma 已提交
489 490 491
	}

	public getExpressionActions(): actions.IAction[] {
I
isidor 已提交
492
		return [this.instantiationService.createInstance(debugactions.RemoveWatchExpressionAction, debugactions.RemoveWatchExpressionAction.ID, debugactions.RemoveWatchExpressionAction.LABEL)];
E
Erich Gamma 已提交
493 494
	}

I
isidor 已提交
495
	public getSecondaryActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
I
isidor 已提交
496
		const actions: actions.Action[] = [];
E
Erich Gamma 已提交
497 498
		if (element instanceof model.Expression) {
			const expression = <model.Expression> element;
I
isidor 已提交
499 500
			actions.push(this.instantiationService.createInstance(debugactions.AddWatchExpressionAction, debugactions.AddWatchExpressionAction.ID, debugactions.AddWatchExpressionAction.LABEL));
			actions.push(this.instantiationService.createInstance(debugactions.RenameWatchExpressionAction, debugactions.RenameWatchExpressionAction.ID, debugactions.RenameWatchExpressionAction.LABEL, expression));
E
Erich Gamma 已提交
501
			if (expression.reference === 0) {
I
isidor 已提交
502
				actions.push(this.instantiationService.createInstance(debugactions.CopyValueAction, debugactions.CopyValueAction.ID, debugactions.CopyValueAction.LABEL, expression.value));
E
Erich Gamma 已提交
503 504 505
			}
			actions.push(new actionbar.Separator());

I
isidor 已提交
506 507
			actions.push(this.instantiationService.createInstance(debugactions.RemoveWatchExpressionAction, debugactions.RemoveWatchExpressionAction.ID, debugactions.RemoveWatchExpressionAction.LABEL));
			actions.push(this.instantiationService.createInstance(debugactions.RemoveAllWatchExpressionsAction, debugactions.RemoveAllWatchExpressionsAction.ID, debugactions.RemoveAllWatchExpressionsAction.LABEL));
E
Erich Gamma 已提交
508
		} else {
I
isidor 已提交
509
			actions.push(this.instantiationService.createInstance(debugactions.AddWatchExpressionAction, debugactions.AddWatchExpressionAction.ID, debugactions.AddWatchExpressionAction.LABEL));
E
Erich Gamma 已提交
510 511 512
			if (element instanceof model.Variable) {
				const variable = <model.Variable> element;
				if (variable.reference === 0) {
I
isidor 已提交
513
					actions.push(this.instantiationService.createInstance(debugactions.CopyValueAction, debugactions.CopyValueAction.ID, debugactions.CopyValueAction.LABEL, variable.value));
E
Erich Gamma 已提交
514 515 516
				}
				actions.push(new actionbar.Separator());
			}
I
isidor 已提交
517
			actions.push(this.instantiationService.createInstance(debugactions.RemoveAllWatchExpressionsAction, debugactions.RemoveAllWatchExpressionsAction.ID, debugactions.RemoveAllWatchExpressionsAction.LABEL));
E
Erich Gamma 已提交
518 519
		}

A
Alex Dima 已提交
520
		return TPromise.as(actions);
E
Erich Gamma 已提交
521
	}
I
isidor 已提交
522 523 524 525

	public getActionItem(tree: tree.ITree, element: any, action: actions.IAction): actionbar.IActionItem {
		return null;
	}
E
Erich Gamma 已提交
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
}

export class WatchExpressionsDataSource implements tree.IDataSource {

	constructor(private debugService: debug.IDebugService) {
		// noop
	}

	public getId(tree: tree.ITree, element: any): string {
		return element.getId();
	}

	public hasChildren(tree: tree.ITree, element: any): boolean {
		if (element instanceof model.Model) {
			return true;
		}

I
isidor 已提交
543
		const watchExpression = <model.Expression> element;
E
Erich Gamma 已提交
544 545 546
		return watchExpression.reference !== 0 && !strings.equalsIgnoreCase(watchExpression.value, 'null');
	}

I
isidor 已提交
547
	public getChildren(tree: tree.ITree, element: any): TPromise<any> {
E
Erich Gamma 已提交
548
		if (element instanceof model.Model) {
A
Alex Dima 已提交
549
			return TPromise.as((<model.Model> element).getWatchExpressions());
E
Erich Gamma 已提交
550 551 552 553 554 555
		}

		let expression = <model.Expression> element;
		return expression.getChildren(this.debugService);
	}

I
isidor 已提交
556
	public getParent(tree: tree.ITree, element: any): TPromise<any> {
A
Alex Dima 已提交
557
		return TPromise.as(null);
E
Erich Gamma 已提交
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
	}
}

interface IWatchExpressionTemplateData extends IVariableTemplateData {
	actionBar: actionbar.ActionBar;
}

export class WatchExpressionsRenderer implements tree.IRenderer {

	private static WATCH_EXPRESSION_TEMPLATE_ID = 'watchExpression';
	private static VARIABLE_TEMPLATE_ID = 'variables';
	private toDispose: lifecycle.IDisposable[];
	private actionProvider: WatchExpressionsActionProvider;

	constructor(actionProvider: renderer.IActionProvider, private actionRunner: actions.IActionRunner,
		@IMessageService private messageService: IMessageService,
		@debug.IDebugService private debugService: debug.IDebugService,
		@IContextViewService private contextViewService: IContextViewService
	) {
		this.toDispose = [];
		this.actionProvider = <WatchExpressionsActionProvider> actionProvider;
	}

	public getHeight(tree:tree.ITree, element:any): number {
I
isidor 已提交
582
		return 22;
E
Erich Gamma 已提交
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
	}

	public getTemplateId(tree: tree.ITree, element: any): string {
		if (element instanceof model.Expression) {
			return WatchExpressionsRenderer.WATCH_EXPRESSION_TEMPLATE_ID;
		}

		return WatchExpressionsRenderer.VARIABLE_TEMPLATE_ID;
	}

	public renderTemplate(tree: tree.ITree, templateId: string, container: HTMLElement): any {
		let data: IWatchExpressionTemplateData = Object.create(null);
		if (templateId === WatchExpressionsRenderer.WATCH_EXPRESSION_TEMPLATE_ID) {
			data.actionBar = new actionbar.ActionBar(container, { actionRunner: this.actionRunner });
			data.actionBar.push(this.actionProvider.getExpressionActions() , { icon: true, label: false });
		}

		data.expression = dom.append(container, $(isMacintosh ? '.expression.mac' : '.expression.win-linux'));
		data.name = dom.append(data.expression, $('span.name'));
		data.value = dom.append(data.expression, $('span.value'));

		return data;
	}

	public renderElement(tree: tree.ITree, element: any, templateId: string, templateData: any): void {
		if (templateId === WatchExpressionsRenderer.WATCH_EXPRESSION_TEMPLATE_ID) {
			this.renderWatchExpression(tree, element, templateData);
		} else {
611
			renderVariable(tree, element, templateData, true);
E
Erich Gamma 已提交
612 613 614 615 616 617
		}
	}

	private renderWatchExpression(tree: tree.ITree, watchExpression: debug.IExpression, data: IWatchExpressionTemplateData): void {
		let selectedExpression = this.debugService.getViewModel().getSelectedExpression();
		if ((selectedExpression instanceof model.Expression && selectedExpression.getId() === watchExpression.getId()) || (watchExpression instanceof model.Expression && !watchExpression.name)) {
618
			renderRenameBox(this.debugService, this.contextViewService, tree, watchExpression, data.expression, nls.localize('watchExpressionPlaceholder', "Expression to watch"), nls.localize('watchExpressionInputAriaLabel', "Type watch expression"));
E
Erich Gamma 已提交
619 620 621
		}
		data.actionBar.context = watchExpression;

622 623
		data.name.textContent = `${watchExpression.name}:`;
		if (watchExpression.value) {
624
			renderExpressionValue(watchExpression, data.value, true);
E
Erich Gamma 已提交
625 626 627 628 629 630 631 632 633 634 635 636
		}
	}

	public disposeTemplate(tree: tree.ITree, templateId: string, templateData: any): void {
		// noop
	}

	public dispose(): void {
		this.toDispose = lifecycle.disposeAll(this.toDispose);
	}
}

637 638 639 640 641 642 643 644 645 646 647 648 649 650
export class WatchExpressionsAccessibilityProvider implements tree.IAccessibilityProvider {

	public getAriaLabel(tree: tree.ITree, element: any): string {
		if (element instanceof model.Expression) {
			return nls.localize('watchExpressionAriaLabel', "Expression {0} has value {1}, watch, debug", (<model.Expression>element).name, (<model.Expression>element).value);
		}
		if (element instanceof model.Variable) {
			return nls.localize('watchVariableAriaLabel', "Variable {0} has value {1}, watch, debug", (<model.Variable>element).name, (<model.Variable>element).value);
		}

		return null;
	}
}

E
Erich Gamma 已提交
651 652 653 654 655 656 657 658 659 660 661 662
export class WatchExpressionsController extends BaseDebugController {

	constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: renderer.IActionProvider) {
		super(debugService, contextMenuService, actionProvider);

		if (isMacintosh) {
			this.downKeyBindingDispatcher.set(CommonKeybindings.ENTER, this.onRename.bind(this));
		} else {
			this.downKeyBindingDispatcher.set(CommonKeybindings.F2, this.onRename.bind(this));
		}
	}

I
isidor 已提交
663
	protected onLeftClick(tree: tree.ITree, element: any, event: mouse.StandardMouseEvent): boolean {
I
isidor 已提交
664
		// double click on primitive value: open input box to be able to select and copy value.
E
Erich Gamma 已提交
665
		if (element instanceof model.Expression && event.detail === 2) {
I
isidor 已提交
666
			const expression = <debug.IExpression> element;
E
Erich Gamma 已提交
667 668 669 670 671 672 673 674 675 676
			if (expression.reference === 0) {
				this.debugService.getViewModel().setSelectedExpression(expression);
			}
			return true;
		}

		return super.onLeftClick(tree, element, event);
	}

	protected onRename(tree: tree.ITree, event: KeyboardEvent): boolean {
I
isidor 已提交
677
		const element = tree.getFocus();
E
Erich Gamma 已提交
678
		if (element instanceof model.Expression) {
I
isidor 已提交
679
			const watchExpression = <model.Expression> element;
E
Erich Gamma 已提交
680 681 682 683 684 685 686 687 688 689
			if (watchExpression.reference === 0) {
				this.debugService.getViewModel().setSelectedExpression(watchExpression);
			}
			return true;
		}

		return false;
	}

	protected onDelete(tree: tree.ITree, event: keyboard.StandardKeyboardEvent): boolean {
I
isidor 已提交
690
		const element = tree.getFocus();
E
Erich Gamma 已提交
691
		if (element instanceof model.Expression) {
I
isidor 已提交
692
			const we = <model.Expression> element;
E
Erich Gamma 已提交
693 694 695 696 697 698 699 700 701
			this.debugService.clearWatchExpressions(we.getId());

			return true;
		}

		return false;
	}
}

I
isidor 已提交
702
// breakpoints
E
Erich Gamma 已提交
703

I
isidor 已提交
704
export class BreakpointsActionProvider implements renderer.IActionProvider {
E
Erich Gamma 已提交
705 706

	constructor(private instantiationService: IInstantiationService) {
I
isidor 已提交
707
		// noop
E
Erich Gamma 已提交
708 709 710 711 712 713 714
	}

	public hasActions(tree: tree.ITree, element: any): boolean {
		return element instanceof model.Breakpoint;
	}

	public hasSecondaryActions(tree: tree.ITree, element: any): boolean {
715
		return element instanceof model.Breakpoint || element instanceof model.ExceptionBreakpoint || element instanceof model.FunctionBreakpoint;
E
Erich Gamma 已提交
716 717 718 719
	}

	public getActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
		if (element instanceof model.Breakpoint) {
A
Alex Dima 已提交
720
			return TPromise.as(this.getBreakpointActions());
E
Erich Gamma 已提交
721 722
		}

A
Alex Dima 已提交
723
		return TPromise.as([]);
E
Erich Gamma 已提交
724 725 726
	}

	public getBreakpointActions(): actions.IAction[] {
I
isidor 已提交
727
		return [this.instantiationService.createInstance(debugactions.RemoveBreakpointAction, debugactions.RemoveBreakpointAction.ID, debugactions.RemoveBreakpointAction.LABEL)];
E
Erich Gamma 已提交
728 729 730
	}

	public getSecondaryActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
I
isidor 已提交
731
		const actions: actions.Action[] = [this.instantiationService.createInstance(debugactions.ToggleEnablementAction, debugactions.ToggleEnablementAction.ID, debugactions.ToggleEnablementAction.LABEL)];
E
Erich Gamma 已提交
732 733
		actions.push(new actionbar.Separator());

734 735 736
		if (element instanceof model.Breakpoint || element instanceof model.FunctionBreakpoint) {
			actions.push(this.instantiationService.createInstance(debugactions.RemoveBreakpointAction, debugactions.RemoveBreakpointAction.ID, debugactions.RemoveBreakpointAction.LABEL));
		}
I
isidor 已提交
737
		actions.push(this.instantiationService.createInstance(debugactions.RemoveAllBreakpointsAction, debugactions.RemoveAllBreakpointsAction.ID, debugactions.RemoveAllBreakpointsAction.LABEL));
E
Erich Gamma 已提交
738 739
		actions.push(new actionbar.Separator());

I
isidor 已提交
740
		actions.push(this.instantiationService.createInstance(debugactions.ToggleBreakpointsActivatedAction, debugactions.ToggleBreakpointsActivatedAction.ID, debugactions.ToggleBreakpointsActivatedAction.LABEL));
E
Erich Gamma 已提交
741 742
		actions.push(new actionbar.Separator());

I
isidor 已提交
743 744
		actions.push(this.instantiationService.createInstance(debugactions.EnableAllBreakpointsAction, debugactions.EnableAllBreakpointsAction.ID, debugactions.EnableAllBreakpointsAction.LABEL));
		actions.push(this.instantiationService.createInstance(debugactions.DisableAllBreakpointsAction, debugactions.DisableAllBreakpointsAction.ID, debugactions.DisableAllBreakpointsAction.LABEL));
E
Erich Gamma 已提交
745 746
		actions.push(new actionbar.Separator());

I
isidor 已提交
747
		actions.push(this.instantiationService.createInstance(debugactions.AddFunctionBreakpointAction, debugactions.AddFunctionBreakpointAction.ID, debugactions.AddFunctionBreakpointAction.LABEL));
748 749 750
		if (element instanceof model.FunctionBreakpoint) {
			actions.push(this.instantiationService.createInstance(debugactions.RenameFunctionBreakpointAction, debugactions.RenameFunctionBreakpointAction.ID, debugactions.RenameFunctionBreakpointAction.LABEL));
		}
I
isidor 已提交
751
		actions.push(new actionbar.Separator());
I
isidor 已提交
752

I
isidor 已提交
753
		actions.push(this.instantiationService.createInstance(debugactions.ReapplyBreakpointsAction, debugactions.ReapplyBreakpointsAction.ID, debugactions.ReapplyBreakpointsAction.LABEL));
E
Erich Gamma 已提交
754

A
Alex Dima 已提交
755
		return TPromise.as(actions);
E
Erich Gamma 已提交
756
	}
I
isidor 已提交
757 758 759 760

	public getActionItem(tree: tree.ITree, element: any, action: actions.IAction): actionbar.IActionItem {
		return null;
	}
E
Erich Gamma 已提交
761 762 763 764 765 766 767 768 769 770 771 772
}

export class BreakpointsDataSource implements tree.IDataSource {

	public getId(tree: tree.ITree, element: any): string {
		return element.getId();
	}

	public hasChildren(tree: tree.ITree, element: any): boolean {
		return element instanceof model.Model;
	}

I
isidor 已提交
773
	public getChildren(tree: tree.ITree, element: any): TPromise<any> {
I
isidor 已提交
774 775
		const model = <model.Model> element;
		const exBreakpoints = <debug.IEnablement[]> model.getExceptionBreakpoints();
E
Erich Gamma 已提交
776

A
Alex Dima 已提交
777
		return TPromise.as(exBreakpoints.concat(model.getFunctionBreakpoints()).concat(model.getBreakpoints()));
E
Erich Gamma 已提交
778 779
	}

I
isidor 已提交
780
	public getParent(tree: tree.ITree, element: any): TPromise<any> {
A
Alex Dima 已提交
781
		return TPromise.as(null);
E
Erich Gamma 已提交
782 783 784 785
	}
}

interface IExceptionBreakpointTemplateData {
786
	breakpoint: HTMLElement;
E
Erich Gamma 已提交
787 788 789 790 791 792 793 794 795 796 797
	name: HTMLElement;
	checkbox: HTMLInputElement;
	toDisposeBeforeRender: lifecycle.IDisposable[];
}

interface IBreakpointTemplateData extends IExceptionBreakpointTemplateData {
	actionBar: actionbar.ActionBar;
	lineNumber: HTMLElement;
	filePath: HTMLElement;
}

798 799 800 801
interface IFunctionBreakpointTemplateData extends IExceptionBreakpointTemplateData {
	actionBar: actionbar.ActionBar;
}

E
Erich Gamma 已提交
802 803 804
export class BreakpointsRenderer implements tree.IRenderer {

	private static EXCEPTION_BREAKPOINT_TEMPLATE_ID = 'exceptionBreakpoint';
805
	private static FUNCTION_BREAKPOINT_TEMPLATE_ID = 'functionBreakpoint';
E
Erich Gamma 已提交
806 807 808 809 810 811 812
	private static BREAKPOINT_TEMPLATE_ID = 'breakpoint';

	constructor(
		private actionProvider: BreakpointsActionProvider,
		private actionRunner: actions.IActionRunner,
		@IMessageService private messageService: IMessageService,
		@IWorkspaceContextService private contextService: IWorkspaceContextService,
813 814
		@debug.IDebugService private debugService: debug.IDebugService,
		@IContextViewService private contextViewService: IContextViewService
E
Erich Gamma 已提交
815 816 817 818 819
	) {
		// noop
	}

	public getHeight(tree:tree.ITree, element:any): number {
I
isidor 已提交
820
		return 22;
E
Erich Gamma 已提交
821 822 823 824 825 826
	}

	public getTemplateId(tree: tree.ITree, element: any): string {
		if (element instanceof model.Breakpoint) {
			return BreakpointsRenderer.BREAKPOINT_TEMPLATE_ID;
		}
827 828 829
		if (element instanceof model.FunctionBreakpoint) {
			return BreakpointsRenderer.FUNCTION_BREAKPOINT_TEMPLATE_ID;
		}
E
Erich Gamma 已提交
830 831 832 833 834 835 836 837
		if (element instanceof model.ExceptionBreakpoint) {
			return BreakpointsRenderer.EXCEPTION_BREAKPOINT_TEMPLATE_ID;
		}

		return null;
	}

	public renderTemplate(tree: tree.ITree, templateId: string, container: HTMLElement): any {
I
isidor 已提交
838
		const data: IBreakpointTemplateData = Object.create(null);
839
		if (templateId === BreakpointsRenderer.BREAKPOINT_TEMPLATE_ID || templateId === BreakpointsRenderer.FUNCTION_BREAKPOINT_TEMPLATE_ID) {
E
Erich Gamma 已提交
840 841 842 843
			data.actionBar = new actionbar.ActionBar(container, { actionRunner: this.actionRunner });
			data.actionBar.push(this.actionProvider.getBreakpointActions(), { icon: true, label: false });
		}

844
		data.breakpoint = dom.append(container, $('.breakpoint'));
E
Erich Gamma 已提交
845 846 847 848
		data.toDisposeBeforeRender = [];

		data.checkbox = <HTMLInputElement> $('input');
		data.checkbox.type = 'checkbox';
849 850 851 852
		if (!isMacintosh) {
			data.checkbox.className = 'checkbox-win-linux';
		}

853
		dom.append(data.breakpoint, data.checkbox);
E
Erich Gamma 已提交
854

855
		data.name = dom.append(data.breakpoint, $('span.name'));
E
Erich Gamma 已提交
856 857

		if (templateId === BreakpointsRenderer.BREAKPOINT_TEMPLATE_ID) {
858 859
			data.lineNumber = dom.append(data.breakpoint, $('span.line-number'));
			data.filePath = dom.append(data.breakpoint, $('span.file-path'));
E
Erich Gamma 已提交
860 861 862 863 864 865
		}

		return data;
	}

	public renderElement(tree: tree.ITree, element: any, templateId: string, templateData: any): void {
866 867 868 869 870
		templateData.toDisposeBeforeRender = lifecycle.disposeAll(templateData.toDisposeBeforeRender);
		templateData.toDisposeBeforeRender.push(dom.addStandardDisposableListener(templateData.checkbox, 'change', (e) => {
			this.debugService.toggleEnablement(element);
		}));

E
Erich Gamma 已提交
871 872
		if (templateId === BreakpointsRenderer.EXCEPTION_BREAKPOINT_TEMPLATE_ID) {
			this.renderExceptionBreakpoint(element, templateData);
873 874
		} else if (templateId === BreakpointsRenderer.FUNCTION_BREAKPOINT_TEMPLATE_ID) {
			this.renderFunctionBreakpoint(tree, element, templateData);
E
Erich Gamma 已提交
875 876 877 878 879 880
		} else {
			this.renderBreakpoint(tree, element, templateData);
		}
	}

	private renderExceptionBreakpoint(exceptionBreakpoint: debug.IExceptionBreakpoint, data: IExceptionBreakpointTemplateData): void {
881
		data.name.textContent = exceptionBreakpoint.label || `${ exceptionBreakpoint.filter } exceptions`;;
E
Erich Gamma 已提交
882
		data.checkbox.checked = exceptionBreakpoint.enabled;
883
	}
E
Erich Gamma 已提交
884

885
	private renderFunctionBreakpoint(tree: tree.ITree, functionBreakpoint: debug.IFunctionBreakpoint, data: IFunctionBreakpointTemplateData): void {
I
isidor 已提交
886 887
		const selected = this.debugService.getViewModel().getSelectedFunctionBreakpoint();
		if (!functionBreakpoint.name || (selected && selected.getId() === functionBreakpoint.getId())) {
888
			renderRenameBox(this.debugService, this.contextViewService, tree, functionBreakpoint, data.breakpoint, nls.localize('functionBreakpointPlaceholder', "Function to break on"), nls.localize('functionBreakPointInputAriaLabel', "Type function breakpoint"));
889 890 891 892 893
		} else {
			this.debugService.getModel().areBreakpointsActivated() ? tree.removeTraits('disabled', [functionBreakpoint]) : tree.addTraits('disabled', [functionBreakpoint]);
			data.name.textContent = functionBreakpoint.name;
			data.checkbox.checked = functionBreakpoint.enabled;
		}
894
		data.actionBar.context = functionBreakpoint;
E
Erich Gamma 已提交
895 896 897
	}

	private renderBreakpoint(tree: tree.ITree, breakpoint: debug.IBreakpoint, data: IBreakpointTemplateData): void {
898
		this.debugService.getModel().areBreakpointsActivated() ? tree.removeTraits('disabled', [breakpoint]) : tree.addTraits('disabled', [breakpoint]);
E
Erich Gamma 已提交
899 900 901 902 903 904

		data.name.textContent = labels.getPathLabel(paths.basename(breakpoint.source.uri.fsPath), this.contextService);
		data.lineNumber.textContent = breakpoint.desiredLineNumber !== breakpoint.lineNumber ? breakpoint.desiredLineNumber + ' \u2192 ' + breakpoint.lineNumber : '' + breakpoint.lineNumber;
		data.filePath.textContent = labels.getPathLabel(paths.dirname(breakpoint.source.uri.fsPath), this.contextService);
		data.checkbox.checked = breakpoint.enabled;
		data.actionBar.context = breakpoint;
905 906 907
		if (breakpoint.condition) {
			data.breakpoint.title = breakpoint.condition;
		}
E
Erich Gamma 已提交
908 909 910
	}

	public disposeTemplate(tree: tree.ITree, templateId: string, templateData: any): void {
911
		if (templateId === BreakpointsRenderer.BREAKPOINT_TEMPLATE_ID || templateId === BreakpointsRenderer.FUNCTION_BREAKPOINT_TEMPLATE_ID) {
E
Erich Gamma 已提交
912 913 914 915 916
			templateData.actionBar.dispose();
		}
	}
}

917 918 919 920 921 922 923 924 925 926 927 928 929 930
export class BreakpointsAccessibilityProvider implements tree.IAccessibilityProvider {

	constructor(@IWorkspaceContextService private contextService: IWorkspaceContextService) {
		// noop
	}

	public getAriaLabel(tree: tree.ITree, element: any): string {
		if (element instanceof model.Breakpoint) {
			return nls.localize('breakpointAriaLabel', "Breakpoint on line {0} in {1}, breakpoints, debug", (<model.Breakpoint>element).lineNumber, getSourceName((<model.Breakpoint>element).source, this.contextService));
		}
		if (element instanceof model.FunctionBreakpoint) {
			return nls.localize('functionBreakpointAriaLabel', "Funktion breakpoint {0}, breakpoints, debug", (<model.FunctionBreakpoint>element).name);
		}
		if (element instanceof model.ExceptionBreakpoint) {
931
			return nls.localize('exceptionBreakpointAriaLabel', "Exception breakpoint {0}, breakpoints, debug", (<model.ExceptionBreakpoint>element).filter);
932 933 934 935 936 937
		}

		return null;
	}
}

E
Erich Gamma 已提交
938 939
export class BreakpointsController extends BaseDebugController {

I
isidor 已提交
940
	protected onLeftClick(tree:tree.ITree, element: any, event: mouse.StandardMouseEvent): boolean {
E
Erich Gamma 已提交
941 942 943 944
		if (element instanceof model.ExceptionBreakpoint) {
			return false;
		}

I
isidor 已提交
945 946 947 948 949 950
		if (element instanceof model.FunctionBreakpoint && event.detail === 2) {
			this.debugService.getViewModel().setSelectedFunctionBreakpoint(element);
			return true;
		}

		return super.onLeftClick(tree, element, event);
E
Erich Gamma 已提交
951 952
	}

I
isidor 已提交
953
	protected onUp(tree:tree.ITree, event:keyboard.StandardKeyboardEvent): boolean {
E
Erich Gamma 已提交
954 955 956
		return this.doNotFocusExceptionBreakpoint(tree, super.onUp(tree, event));
	}

I
isidor 已提交
957
	protected onPageUp(tree:tree.ITree, event:keyboard.StandardKeyboardEvent): boolean {
E
Erich Gamma 已提交
958 959 960
		return this.doNotFocusExceptionBreakpoint(tree, super.onPageUp(tree, event));
	}

F
Francois Valdy 已提交
961 962
	private doNotFocusExceptionBreakpoint(tree: tree.ITree, upSucceeded: boolean) : boolean {
		if (upSucceeded) {
I
isidor 已提交
963
			const focus = tree.getFocus();
E
Erich Gamma 已提交
964 965 966 967 968
			if (focus instanceof model.ExceptionBreakpoint) {
				tree.focusNth(2);
			}
		}

F
Francois Valdy 已提交
969
		return upSucceeded;
E
Erich Gamma 已提交
970 971 972
	}

	protected onDelete(tree: tree.ITree, event: keyboard.StandardKeyboardEvent): boolean {
973
		const element = tree.getFocus();
E
Erich Gamma 已提交
974
		if (element instanceof model.Breakpoint) {
975
			const bp = <model.Breakpoint> element;
976
			this.debugService.toggleBreakpoint({ uri: bp.source.uri, lineNumber: bp.lineNumber }).done(null, errors.onUnexpectedError);
977 978 979 980

			return true;
		} else if (element instanceof model.FunctionBreakpoint) {
			const fbp = <model.FunctionBreakpoint> element;
981
			this.debugService.removeFunctionBreakpoints(fbp.getId()).done(null, errors.onUnexpectedError);
E
Erich Gamma 已提交
982 983 984 985 986 987 988

			return true;
		}

		return false;
	}
}