callStackView.ts 21.0 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, DebugModel } 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
import { CopyStackTraceAction } from 'vs/workbench/parts/debug/electron-browser/electronDebugActions';
B
Benjamin Pasero 已提交
22
import { TreeResourceNavigator, WorkbenchTree } from 'vs/platform/list/browser/listService';
23
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
24
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
25
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
26
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
27
import { IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
I
isidor 已提交
28
import { ILabelService } from 'vs/platform/label/common/label';
29
import { DebugSession } from 'vs/workbench/parts/debug/electron-browser/debugSession';
I
isidor 已提交
30

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

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

35 36
	private pauseMessage: HTMLSpanElement;
	private pauseMessageLabel: HTMLSpanElement;
I
isidor 已提交
37
	private onCallStackChangeScheduler: RunOnceScheduler;
38
	private needsRefresh: boolean;
39
	private ignoreSelectionChangedEvent: boolean;
S
Sandeep Somavarapu 已提交
40
	private treeContainer: HTMLElement;
41
	private callStackItemType: IContextKey<string>;
I
isidor 已提交
42 43 44 45 46 47 48

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

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

			// 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) {
69
				this.pauseMessageLabel.textContent = newTreeInput.stoppedDetails.description || nls.localize('debugStopped', "Paused on {0}", newTreeInput.stoppedDetails.reason);
I
isidor 已提交
70
				if (newTreeInput.stoppedDetails.text) {
71
					this.pauseMessageLabel.title = newTreeInput.stoppedDetails.text;
I
isidor 已提交
72
				}
73 74
				dom.toggleClass(this.pauseMessageLabel, 'exception', newTreeInput.stoppedDetails.reason === 'exception');
				this.pauseMessage.hidden = false;
I
isidor 已提交
75
			} else {
76
				this.pauseMessage.hidden = true;
I
isidor 已提交
77 78
			}

79
			this.needsRefresh = false;
I
isidor 已提交
80
			(this.tree.getInput() === newTreeInput ? this.tree.refresh() : this.tree.setInput(newTreeInput))
81
				.then(() => this.updateTreeSelection());
I
isidor 已提交
82 83 84
		}, 50);
	}

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

		this.pauseMessage = dom.append(titleContainer, $('span.pause-message'));
90 91
		this.pauseMessage.hidden = true;
		this.pauseMessageLabel = dom.append(this.pauseMessage, $('span.label'));
I
isidor 已提交
92 93 94 95 96
	}

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

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

B
Benjamin Pasero 已提交
110 111 112
		const callstackNavigator = new TreeResourceNavigator(this.tree);
		this.disposables.push(callstackNavigator);
		this.disposables.push(callstackNavigator.openResource(e => {
113 114 115
			if (this.ignoreSelectionChangedEvent) {
				return;
			}
116

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

		this.disposables.push(this.debugService.getModel().onDidChangeCallStack(() => {
151 152 153 154 155
			if (!this.isVisible()) {
				this.needsRefresh = true;
				return;
			}

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

166
			this.updateTreeSelection();
167
		}));
I
isidor 已提交
168 169 170 171 172 173 174

		// 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 已提交
175 176 177 178 179 180 181
	layoutBody(size: number): void {
		if (this.treeContainer) {
			this.treeContainer.style.height = size + 'px';
		}
		super.layoutBody(size);
	}

I
isidor 已提交
182 183 184
	private updateTreeSelection(): TPromise<void> {
		if (!this.tree.getInput()) {
			// Tree not initialized yet
I
isidor 已提交
185
			return Promise.resolve(null);
I
isidor 已提交
186 187 188 189
		}

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

I
isidor 已提交
200
		if (!thread) {
I
isidor 已提交
201
			if (!session) {
I
isidor 已提交
202
				this.tree.clearSelection();
I
isidor 已提交
203
				return Promise.resolve(null);
I
isidor 已提交
204 205
			}

I
isidor 已提交
206 207
			updateSelection(session);
			return this.tree.reveal(session);
I
isidor 已提交
208 209
		}

I
isidor 已提交
210
		return this.tree.expandAll([thread.session, thread]).then(() => {
I
isidor 已提交
211
			if (!stackFrame) {
I
isidor 已提交
212
				return Promise.resolve(null);
I
isidor 已提交
213 214
			}

215
			updateSelection(stackFrame);
I
isidor 已提交
216 217 218 219
			return this.tree.reveal(stackFrame);
		});
	}

220 221 222 223 224
	public setVisible(visible: boolean): void {
		super.setVisible(visible);
		if (visible && this.needsRefresh) {
			this.onCallStackChangeScheduler.schedule();
		}
225
	}
I
isidor 已提交
226 227
}

228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
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 已提交
246
	constructor(private debugService: IDebugService, private keybindingService: IKeybindingService, private instantiationService: IInstantiationService) {
247 248 249 250 251 252 253 254
		// noop
	}

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

	public getActions(tree: ITree, element: any): TPromise<IAction[]> {
I
isidor 已提交
255
		return Promise.resolve([]);
256 257 258 259 260 261 262 263
	}

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

	public getSecondaryActions(tree: ITree, element: any): TPromise<IAction[]> {
		const actions: IAction[] = [];
264
		if (element instanceof DebugSession) {
I
isidor 已提交
265
			actions.push(this.instantiationService.createInstance(RestartAction, RestartAction.ID, RestartAction.LABEL));
266 267 268 269 270 271 272 273 274 275 276
			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));
			}
277 278 279

			actions.push(new Separator());
			actions.push(new TerminateThreadAction(TerminateThreadAction.ID, TerminateThreadAction.LABEL, this.debugService, this.keybindingService));
280
		} else if (element instanceof StackFrame) {
281
			if (element.thread.session.capabilities.supportsRestartFrame) {
282 283 284 285 286
				actions.push(new RestartFrameAction(RestartFrameAction.ID, RestartFrameAction.LABEL, this.debugService, this.keybindingService));
			}
			actions.push(new CopyStackTraceAction(CopyStackTraceAction.ID, CopyStackTraceAction.LABEL));
		}

I
isidor 已提交
287
		return Promise.resolve(actions);
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
	}

	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 {
306
		return element instanceof DebugModel || element instanceof DebugSession || (element instanceof Thread && (<Thread>element).stopped);
307 308 309 310 311 312
	}

	public getChildren(tree: ITree, element: any): TPromise<any> {
		if (element instanceof Thread) {
			return this.getThreadChildren(element);
		}
313
		if (element instanceof DebugModel) {
I
isidor 已提交
314
			return Promise.resolve(element.getSessions());
315 316
		}

317
		const session = <IDebugSession>element;
I
isidor 已提交
318
		return Promise.resolve(session.getAllThreads());
319 320 321 322
	}

	private getThreadChildren(thread: Thread): TPromise<any> {
		let callStack: any[] = thread.getCallStack();
I
isidor 已提交
323
		let callStackPromise: TPromise<any> = Promise.resolve(null);
324 325 326 327 328
		if (!callStack || !callStack.length) {
			callStackPromise = thread.fetchCallStack().then(() => callStack = thread.getCallStack());
		}

		return callStackPromise.then(() => {
329
			if (callStack.length === 1 && thread.session.capabilities.supportsDelayedStackTraceLoading) {
330 331 332 333 334 335 336 337 338
				// 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 已提交
339
				callStack = callStack.concat([new ThreadAndSessionIds(thread.session.getId(), thread.threadId)]);
340 341 342 343 344 345 346
			}

			return callStack;
		});
	}

	public getParent(tree: ITree, element: any): TPromise<any> {
I
isidor 已提交
347
		return Promise.resolve(null);
348 349 350 351 352 353 354 355 356 357
	}
}

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

I
isidor 已提交
358 359
interface ISessionTemplateData {
	session: HTMLElement;
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
	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 已提交
387
	private static readonly SESSION_TEMPLATE_ID = 'session';
388 389

	constructor(
I
isidor 已提交
390
		@ILabelService private labelService: ILabelService
391 392 393 394 395 396 397 398 399
	) {
		// noop
	}

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

	public getTemplateId(tree: ITree, element: any): string {
400
		if (element instanceof DebugSession) {
I
isidor 已提交
401
			return CallStackRenderer.SESSION_TEMPLATE_ID;
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
		}
		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 已提交
417 418 419 420 421
		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'));
422 423 424 425 426 427 428 429 430 431 432 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
			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 已提交
461 462
		if (templateId === CallStackRenderer.SESSION_TEMPLATE_ID) {
			this.renderSession(element, templateData);
463 464 465 466 467 468 469
		} 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 已提交
470
			this.renderLoadMore(templateData);
471 472 473
		}
	}

474
	private renderSession(session: IDebugSession, data: ISessionTemplateData): void {
I
isidor 已提交
475
		data.session.title = nls.localize({ key: 'session', comment: ['Session is a noun'] }, "Session");
I
isidor 已提交
476
		data.name.textContent = session.getLabel();
I
isidor 已提交
477
		const stoppedThread = session.getAllThreads().filter(t => t.stopped).pop();
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499

		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 已提交
500
	private renderLoadMore(data: ILoadMoreTemplateData): void {
501 502 503 504 505 506 507 508
		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 已提交
509
		data.file.title = stackFrame.source.inMemory ? stackFrame.source.uri.path : this.labelService.getUriLabel(stackFrame.source.uri);
510 511 512 513 514
		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 已提交
515
		data.fileName.textContent = stackFrame.getSpecificSourceName();
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
		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 已提交
534
	constructor() {
535 536 537 538 539 540 541 542
		// 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 已提交
543
			return nls.localize('stackFrameAriaLabel', "Stack Frame {0} line {1} {2}, callstack, debug", element.name, element.range.startLineNumber, element.getSpecificSourceName());
544 545 546 547 548
		}

		return null;
	}
}