callStackView.ts 21.4 KB
Newer Older
I
isidor 已提交
1 2 3 4 5 6 7 8 9
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as nls from 'vs/nls';
import { RunOnceScheduler } from 'vs/base/common/async';
import * as dom from 'vs/base/browser/dom';
import { TPromise } from 'vs/base/common/winjs.base';
10
import { TreeViewsViewletPanel, IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
11
import { IDebugService, State, IStackFrame, IDebugSession, IThread, CONTEXT_CALLSTACK_ITEM_TYPE } from 'vs/workbench/parts/debug/common/debug';
12
import { Thread, StackFrame, ThreadAndSessionIds, Model } from 'vs/workbench/parts/debug/common/debugModel';
I
isidor 已提交
13 14 15 16
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { MenuId } from 'vs/platform/actions/common/actions';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
17
import { BaseDebugController, twistiePixels, renderViewTree } from 'vs/workbench/parts/debug/browser/baseDebugView';
18 19
import { ITree, IActionProvider, IDataSource, IRenderer, IAccessibilityProvider } from 'vs/base/parts/tree/browser/tree';
import { IAction, IActionItem } from 'vs/base/common/actions';
20
import { RestartAction, StopAction, ContinueAction, StepOverAction, StepIntoAction, StepOutAction, PauseAction, RestartFrameAction, TerminateThreadAction } from 'vs/workbench/parts/debug/browser/debugActions';
21 22
import { CopyStackTraceAction } from 'vs/workbench/parts/debug/electron-browser/electronDebugActions';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
B
Benjamin Pasero 已提交
23
import { TreeResourceNavigator, WorkbenchTree } from 'vs/platform/list/browser/listService';
24
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
25
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
26
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
27
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
28
import { IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
I
isidor 已提交
29
import { ILabelService } from 'vs/platform/label/common/label';
30
import { DebugSession } from 'vs/workbench/parts/debug/electron-browser/debugSession';
I
isidor 已提交
31

32
const $ = dom.$;
I
isidor 已提交
33

34
export class CallStackView extends TreeViewsViewletPanel {
I
isidor 已提交
35 36

	private static readonly MEMENTO = 'callstackview.memento';
37 38
	private pauseMessage: HTMLSpanElement;
	private pauseMessageLabel: HTMLSpanElement;
I
isidor 已提交
39 40
	private onCallStackChangeScheduler: RunOnceScheduler;
	private settings: any;
41
	private needsRefresh: boolean;
42
	private ignoreSelectionChangedEvent: boolean;
S
Sandeep Somavarapu 已提交
43
	private treeContainer: HTMLElement;
44
	private callStackItemType: IContextKey<string>;
I
isidor 已提交
45 46 47 48 49 50 51

	constructor(
		private options: IViewletViewOptions,
		@IContextMenuService contextMenuService: IContextMenuService,
		@IDebugService private debugService: IDebugService,
		@IKeybindingService keybindingService: IKeybindingService,
		@IInstantiationService private instantiationService: IInstantiationService,
52
		@IEditorService private editorService: IEditorService,
53
		@IConfigurationService configurationService: IConfigurationService,
54
		@IContextKeyService contextKeyService: IContextKeyService
I
isidor 已提交
55
	) {
56
		super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('callstackSection', "Call Stack Section") }, keybindingService, contextMenuService, configurationService);
I
isidor 已提交
57
		this.settings = options.viewletSettings;
58
		this.callStackItemType = CONTEXT_CALLSTACK_ITEM_TYPE.bindTo(contextKeyService);
I
isidor 已提交
59 60 61 62

		// Create scheduler to prevent unnecessary flashing of tree when reacting to changes
		this.onCallStackChangeScheduler = new RunOnceScheduler(() => {
			let newTreeInput: any = this.debugService.getModel();
I
isidor 已提交
63 64 65
			const sessions = this.debugService.getModel().getSessions();
			if (!this.debugService.getViewModel().isMultiSessionView() && sessions.length) {
				const threads = sessions[0].getAllThreads();
I
isidor 已提交
66
				// Only show the threads in the call stack if there is more than 1 thread.
I
isidor 已提交
67
				newTreeInput = threads.length === 1 ? threads[0] : sessions[0];
I
isidor 已提交
68 69 70 71 72
			}

			// Only show the global pause message if we do not display threads.
			// Otherwise there will be a pause message per thread and there is no need for a global one.
			if (newTreeInput instanceof Thread && newTreeInput.stoppedDetails) {
73
				this.pauseMessageLabel.textContent = newTreeInput.stoppedDetails.description || nls.localize('debugStopped', "Paused on {0}", newTreeInput.stoppedDetails.reason);
I
isidor 已提交
74
				if (newTreeInput.stoppedDetails.text) {
75
					this.pauseMessageLabel.title = newTreeInput.stoppedDetails.text;
I
isidor 已提交
76
				}
77 78
				dom.toggleClass(this.pauseMessageLabel, 'exception', newTreeInput.stoppedDetails.reason === 'exception');
				this.pauseMessage.hidden = false;
I
isidor 已提交
79
			} else {
80
				this.pauseMessage.hidden = true;
I
isidor 已提交
81 82
			}

83
			this.needsRefresh = false;
I
isidor 已提交
84
			(this.tree.getInput() === newTreeInput ? this.tree.refresh() : this.tree.setInput(newTreeInput))
85
				.then(() => this.updateTreeSelection());
I
isidor 已提交
86 87 88
		}, 50);
	}

J
Jackson Kearl 已提交
89
	protected renderHeaderTitle(container: HTMLElement): void {
J
Jackson Kearl 已提交
90 91 92 93
		let titleContainer = dom.append(container, $('.debug-call-stack-title'));
		super.renderHeaderTitle(titleContainer, this.options.title);

		this.pauseMessage = dom.append(titleContainer, $('span.pause-message'));
94 95
		this.pauseMessage.hidden = true;
		this.pauseMessageLabel = dom.append(this.pauseMessage, $('span.label'));
I
isidor 已提交
96 97 98 99 100
	}

	public renderBody(container: HTMLElement): void {
		dom.addClass(container, 'debug-call-stack');
		this.treeContainer = renderViewTree(container);
I
isidor 已提交
101
		const actionProvider = new CallStackActionProvider(this.debugService, this.keybindingService, this.instantiationService);
102
		const controller = this.instantiationService.createInstance(CallStackController, actionProvider, MenuId.DebugCallStackContext, {});
I
isidor 已提交
103

104
		this.tree = this.instantiationService.createInstance(WorkbenchTree, this.treeContainer, {
105
			dataSource: new CallStackDataSource(),
106 107
			renderer: this.instantiationService.createInstance(CallStackRenderer),
			accessibilityProvider: this.instantiationService.createInstance(CallstackAccessibilityProvider),
I
isidor 已提交
108 109 110
			controller
		}, {
				ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'callStackAriaLabel' }, "Debug Call Stack"),
111
				twistiePixels
112
			});
I
isidor 已提交
113

B
Benjamin Pasero 已提交
114 115 116
		const callstackNavigator = new TreeResourceNavigator(this.tree);
		this.disposables.push(callstackNavigator);
		this.disposables.push(callstackNavigator.openResource(e => {
117 118 119
			if (this.ignoreSelectionChangedEvent) {
				return;
			}
120

121
			const element = e.element;
122
			if (element instanceof StackFrame) {
I
isidor 已提交
123
				this.debugService.focusStackFrame(element, element.thread, element.thread.session, true);
124
				element.openInEditor(this.editorService, e.editorOptions.preserveFocus, e.sideBySide, e.editorOptions.pinned);
125 126
			}
			if (element instanceof Thread) {
I
isidor 已提交
127
				this.debugService.focusStackFrame(undefined, element, element.session, true);
128
			}
129
			if (element instanceof DebugSession) {
130 131
				this.debugService.focusStackFrame(undefined, undefined, element, true);
			}
I
isidor 已提交
132 133 134
			if (element instanceof ThreadAndSessionIds) {
				const session = this.debugService.getModel().getSessions().filter(p => p.getId() === element.sessionId).pop();
				const thread = session && session.getThread(element.threadId);
135 136
				if (thread) {
					(<Thread>thread).fetchCallStack()
137
						.then(() => this.tree.refresh());
138
				}
I
isidor 已提交
139 140
			}
		}));
141 142 143 144 145 146
		this.disposables.push(this.tree.onDidChangeFocus(() => {
			const focus = this.tree.getFocus();
			if (focus instanceof StackFrame) {
				this.callStackItemType.set('stackFrame');
			} else if (focus instanceof Thread) {
				this.callStackItemType.set('thread');
147
			} else if (focus instanceof DebugSession) {
148 149 150 151 152
				this.callStackItemType.set('session');
			} else {
				this.callStackItemType.reset();
			}
		}));
I
isidor 已提交
153 154

		this.disposables.push(this.debugService.getModel().onDidChangeCallStack(() => {
155 156 157 158 159
			if (!this.isVisible()) {
				this.needsRefresh = true;
				return;
			}

I
isidor 已提交
160 161 162 163
			if (!this.onCallStackChangeScheduler.isScheduled()) {
				this.onCallStackChangeScheduler.schedule();
			}
		}));
164 165 166 167 168 169
		this.disposables.push(this.debugService.getViewModel().onDidFocusStackFrame(() => {
			if (!this.isVisible) {
				this.needsRefresh = true;
				return;
			}

170
			this.updateTreeSelection();
171
		}));
I
isidor 已提交
172 173 174 175 176 177 178

		// Schedule the update of the call stack tree if the viewlet is opened after a session started #14684
		if (this.debugService.state === State.Stopped) {
			this.onCallStackChangeScheduler.schedule();
		}
	}

S
Sandeep Somavarapu 已提交
179 180 181 182 183 184 185
	layoutBody(size: number): void {
		if (this.treeContainer) {
			this.treeContainer.style.height = size + 'px';
		}
		super.layoutBody(size);
	}

I
isidor 已提交
186 187 188 189 190 191 192 193
	private updateTreeSelection(): TPromise<void> {
		if (!this.tree.getInput()) {
			// Tree not initialized yet
			return TPromise.as(null);
		}

		const stackFrame = this.debugService.getViewModel().focusedStackFrame;
		const thread = this.debugService.getViewModel().focusedThread;
I
isidor 已提交
194
		const session = this.debugService.getViewModel().focusedSession;
195
		const updateSelection = (element: IStackFrame | IDebugSession) => {
196 197 198 199 200 201 202 203
			this.ignoreSelectionChangedEvent = true;
			try {
				this.tree.setSelection([element]);
			} finally {
				this.ignoreSelectionChangedEvent = false;
			}
		};

I
isidor 已提交
204
		if (!thread) {
I
isidor 已提交
205
			if (!session) {
I
isidor 已提交
206 207 208 209
				this.tree.clearSelection();
				return TPromise.as(null);
			}

I
isidor 已提交
210 211
			updateSelection(session);
			return this.tree.reveal(session);
I
isidor 已提交
212 213
		}

I
isidor 已提交
214
		return this.tree.expandAll([thread.session, thread]).then(() => {
I
isidor 已提交
215 216 217 218
			if (!stackFrame) {
				return TPromise.as(null);
			}

219
			updateSelection(stackFrame);
I
isidor 已提交
220 221 222 223
			return this.tree.reveal(stackFrame);
		});
	}

224 225 226 227 228 229 230 231
	public setVisible(visible: boolean): TPromise<void> {
		return super.setVisible(visible).then(() => {
			if (visible && this.needsRefresh) {
				this.onCallStackChangeScheduler.schedule();
			}
		});
	}

I
isidor 已提交
232 233 234 235 236 237
	public shutdown(): void {
		this.settings[CallStackView.MEMENTO] = !this.isExpanded();
		super.shutdown();
	}
}

238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
class CallStackController extends BaseDebugController {
	protected getContext(element: any): any {
		if (element instanceof StackFrame) {
			if (element.source.inMemory) {
				return element.source.raw.path || element.source.reference;
			}

			return element.source.uri.toString();
		}
		if (element instanceof Thread) {
			return element.threadId;
		}
	}
}


class CallStackActionProvider implements IActionProvider {

I
isidor 已提交
256
	constructor(private debugService: IDebugService, private keybindingService: IKeybindingService, private instantiationService: IInstantiationService) {
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
		// noop
	}

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

	public getActions(tree: ITree, element: any): TPromise<IAction[]> {
		return TPromise.as([]);
	}

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

	public getSecondaryActions(tree: ITree, element: any): TPromise<IAction[]> {
		const actions: IAction[] = [];
274
		if (element instanceof DebugSession) {
I
isidor 已提交
275
			actions.push(this.instantiationService.createInstance(RestartAction, RestartAction.ID, RestartAction.LABEL));
276 277 278 279 280 281 282 283 284 285 286
			actions.push(new StopAction(StopAction.ID, StopAction.LABEL, this.debugService, this.keybindingService));
		} else if (element instanceof Thread) {
			const thread = <Thread>element;
			if (thread.stopped) {
				actions.push(new ContinueAction(ContinueAction.ID, ContinueAction.LABEL, this.debugService, this.keybindingService));
				actions.push(new StepOverAction(StepOverAction.ID, StepOverAction.LABEL, this.debugService, this.keybindingService));
				actions.push(new StepIntoAction(StepIntoAction.ID, StepIntoAction.LABEL, this.debugService, this.keybindingService));
				actions.push(new StepOutAction(StepOutAction.ID, StepOutAction.LABEL, this.debugService, this.keybindingService));
			} else {
				actions.push(new PauseAction(PauseAction.ID, PauseAction.LABEL, this.debugService, this.keybindingService));
			}
287 288 289

			actions.push(new Separator());
			actions.push(new TerminateThreadAction(TerminateThreadAction.ID, TerminateThreadAction.LABEL, this.debugService, this.keybindingService));
290
		} else if (element instanceof StackFrame) {
291
			if (element.thread.session.capabilities.supportsRestartFrame) {
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
				actions.push(new RestartFrameAction(RestartFrameAction.ID, RestartFrameAction.LABEL, this.debugService, this.keybindingService));
			}
			actions.push(new CopyStackTraceAction(CopyStackTraceAction.ID, CopyStackTraceAction.LABEL));
		}

		return TPromise.as(actions);
	}

	public getActionItem(tree: ITree, element: any, action: IAction): IActionItem {
		return null;
	}
}

class CallStackDataSource implements IDataSource {

	public getId(tree: ITree, element: any): string {
		if (typeof element === 'string') {
			return element;
		}

		return element.getId();
	}

	public hasChildren(tree: ITree, element: any): boolean {
316
		return element instanceof Model || element instanceof DebugSession || (element instanceof Thread && (<Thread>element).stopped);
317 318 319 320 321 322 323
	}

	public getChildren(tree: ITree, element: any): TPromise<any> {
		if (element instanceof Thread) {
			return this.getThreadChildren(element);
		}
		if (element instanceof Model) {
I
isidor 已提交
324
			return TPromise.as(element.getSessions());
325 326
		}

327
		const session = <IDebugSession>element;
I
isidor 已提交
328
		return TPromise.as(session.getAllThreads());
329 330 331 332 333 334 335 336 337 338
	}

	private getThreadChildren(thread: Thread): TPromise<any> {
		let callStack: any[] = thread.getCallStack();
		let callStackPromise: TPromise<any> = TPromise.as(null);
		if (!callStack || !callStack.length) {
			callStackPromise = thread.fetchCallStack().then(() => callStack = thread.getCallStack());
		}

		return callStackPromise.then(() => {
339
			if (callStack.length === 1 && thread.session.capabilities.supportsDelayedStackTraceLoading) {
340 341 342 343 344 345 346 347 348
				// To reduce flashing of the call stack view simply append the stale call stack
				// once we have the correct data the tree will refresh and we will no longer display it.
				callStack = callStack.concat(thread.getStaleCallStack().slice(1));
			}

			if (thread.stoppedDetails && thread.stoppedDetails.framesErrorMessage) {
				callStack = callStack.concat([thread.stoppedDetails.framesErrorMessage]);
			}
			if (thread.stoppedDetails && thread.stoppedDetails.totalFrames > callStack.length && callStack.length > 1) {
I
isidor 已提交
349
				callStack = callStack.concat([new ThreadAndSessionIds(thread.session.getId(), thread.threadId)]);
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
			}

			return callStack;
		});
	}

	public getParent(tree: ITree, element: any): TPromise<any> {
		return TPromise.as(null);
	}
}

interface IThreadTemplateData {
	thread: HTMLElement;
	name: HTMLElement;
	state: HTMLElement;
	stateLabel: HTMLSpanElement;
}

I
isidor 已提交
368 369
interface ISessionTemplateData {
	session: HTMLElement;
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
	name: HTMLElement;
	state: HTMLElement;
	stateLabel: HTMLSpanElement;
}

interface IErrorTemplateData {
	label: HTMLElement;
}

interface ILoadMoreTemplateData {
	label: HTMLElement;
}

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

class CallStackRenderer implements IRenderer {

	private static readonly THREAD_TEMPLATE_ID = 'thread';
	private static readonly STACK_FRAME_TEMPLATE_ID = 'stackFrame';
	private static readonly ERROR_TEMPLATE_ID = 'error';
	private static readonly LOAD_MORE_TEMPLATE_ID = 'loadMore';
I
isidor 已提交
397
	private static readonly SESSION_TEMPLATE_ID = 'session';
398 399 400

	constructor(
		@IWorkspaceContextService private contextService: IWorkspaceContextService,
I
isidor 已提交
401
		@ILabelService private labelService: ILabelService
402 403 404 405 406 407 408 409 410
	) {
		// noop
	}

	public getHeight(tree: ITree, element: any): number {
		return 22;
	}

	public getTemplateId(tree: ITree, element: any): string {
411
		if (element instanceof DebugSession) {
I
isidor 已提交
412
			return CallStackRenderer.SESSION_TEMPLATE_ID;
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
		}
		if (element instanceof Thread) {
			return CallStackRenderer.THREAD_TEMPLATE_ID;
		}
		if (element instanceof StackFrame) {
			return CallStackRenderer.STACK_FRAME_TEMPLATE_ID;
		}
		if (typeof element === 'string') {
			return CallStackRenderer.ERROR_TEMPLATE_ID;
		}

		return CallStackRenderer.LOAD_MORE_TEMPLATE_ID;
	}

	public renderTemplate(tree: ITree, templateId: string, container: HTMLElement): any {
I
isidor 已提交
428 429 430 431 432
		if (templateId === CallStackRenderer.SESSION_TEMPLATE_ID) {
			let data: ISessionTemplateData = Object.create(null);
			data.session = dom.append(container, $('.session'));
			data.name = dom.append(data.session, $('.name'));
			data.state = dom.append(data.session, $('.state'));
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
			data.stateLabel = dom.append(data.state, $('span.label'));

			return data;
		}

		if (templateId === CallStackRenderer.LOAD_MORE_TEMPLATE_ID) {
			let data: ILoadMoreTemplateData = Object.create(null);
			data.label = dom.append(container, $('.load-more'));

			return data;
		}
		if (templateId === CallStackRenderer.ERROR_TEMPLATE_ID) {
			let data: ILoadMoreTemplateData = Object.create(null);
			data.label = dom.append(container, $('.error'));

			return data;
		}
		if (templateId === CallStackRenderer.THREAD_TEMPLATE_ID) {
			let data: IThreadTemplateData = Object.create(null);
			data.thread = dom.append(container, $('.thread'));
			data.name = dom.append(data.thread, $('.name'));
			data.state = dom.append(data.thread, $('.state'));
			data.stateLabel = dom.append(data.state, $('span.label'));

			return data;
		}

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

		return data;
	}

	public renderElement(tree: ITree, element: any, templateId: string, templateData: any): void {
I
isidor 已提交
472 473
		if (templateId === CallStackRenderer.SESSION_TEMPLATE_ID) {
			this.renderSession(element, templateData);
474 475 476 477 478 479 480
		} else if (templateId === CallStackRenderer.THREAD_TEMPLATE_ID) {
			this.renderThread(element, templateData);
		} else if (templateId === CallStackRenderer.STACK_FRAME_TEMPLATE_ID) {
			this.renderStackFrame(element, templateData);
		} else if (templateId === CallStackRenderer.ERROR_TEMPLATE_ID) {
			this.renderError(element, templateData);
		} else if (templateId === CallStackRenderer.LOAD_MORE_TEMPLATE_ID) {
I
isidor 已提交
481
			this.renderLoadMore(templateData);
482 483 484
		}
	}

485
	private renderSession(session: IDebugSession, data: ISessionTemplateData): void {
I
isidor 已提交
486 487 488
		data.session.title = nls.localize({ key: 'session', comment: ['Session is a noun'] }, "Session");
		data.name.textContent = session.getName(this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE);
		const stoppedThread = session.getAllThreads().filter(t => t.stopped).pop();
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510

		data.stateLabel.textContent = stoppedThread ? nls.localize('paused', "Paused")
			: nls.localize({ key: 'running', comment: ['indicates state'] }, "Running");
	}

	private renderThread(thread: IThread, data: IThreadTemplateData): void {
		data.thread.title = nls.localize('thread', "Thread");
		data.name.textContent = thread.name;

		if (thread.stopped) {
			data.stateLabel.textContent = thread.stoppedDetails.description ||
				thread.stoppedDetails.reason ? nls.localize({ key: 'pausedOn', comment: ['indicates reason for program being paused'] }, "Paused on {0}", thread.stoppedDetails.reason) : nls.localize('paused', "Paused");
		} else {
			data.stateLabel.textContent = nls.localize({ key: 'running', comment: ['indicates state'] }, "Running");
		}
	}

	private renderError(element: string, data: IErrorTemplateData) {
		data.label.textContent = element;
		data.label.title = element;
	}

I
isidor 已提交
511
	private renderLoadMore(data: ILoadMoreTemplateData): void {
512 513 514 515 516 517 518 519
		data.label.textContent = nls.localize('loadMoreStackFrames', "Load More Stack Frames");
	}

	private renderStackFrame(stackFrame: IStackFrame, data: IStackFrameTemplateData): void {
		dom.toggleClass(data.stackFrame, 'disabled', !stackFrame.source.available || stackFrame.source.presentationHint === 'deemphasize');
		dom.toggleClass(data.stackFrame, 'label', stackFrame.presentationHint === 'label');
		dom.toggleClass(data.stackFrame, 'subtle', stackFrame.presentationHint === 'subtle');

I
isidor 已提交
520
		data.file.title = stackFrame.source.inMemory ? stackFrame.source.name : this.labelService.getUriLabel(stackFrame.source.uri);
521 522 523 524 525
		if (stackFrame.source.raw.origin) {
			data.file.title += `\n${stackFrame.source.raw.origin}`;
		}
		data.label.textContent = stackFrame.name;
		data.label.title = stackFrame.name;
I
isidor 已提交
526
		data.fileName.textContent = stackFrame.getSpecificSourceName();
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
		if (stackFrame.range.startLineNumber !== undefined) {
			data.lineNumber.textContent = `${stackFrame.range.startLineNumber}`;
			if (stackFrame.range.startColumn) {
				data.lineNumber.textContent += `:${stackFrame.range.startColumn}`;
			}
			dom.removeClass(data.lineNumber, 'unavailable');
		} else {
			dom.addClass(data.lineNumber, 'unavailable');
		}
	}

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

class CallstackAccessibilityProvider implements IAccessibilityProvider {

I
isidor 已提交
545
	constructor() {
546 547 548 549 550 551 552 553
		// noop
	}

	public getAriaLabel(tree: ITree, element: any): string {
		if (element instanceof Thread) {
			return nls.localize('threadAriaLabel', "Thread {0}, callstack, debug", (<Thread>element).name);
		}
		if (element instanceof StackFrame) {
I
isidor 已提交
554
			return nls.localize('stackFrameAriaLabel', "Stack Frame {0} line {1} {2}, callstack, debug", element.name, element.range.startLineNumber, element.getSpecificSourceName());
555 556 557 558 559
		}

		return null;
	}
}