Skip to content

Commit cad1659

Browse files
committed
debug: add loaded scripts view
#37767
1 parent 18b5d32 commit cad1659

File tree

4 files changed

+116
-2
lines changed

4 files changed

+116
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as nls from 'vs/nls';
7+
import { TreeViewsViewletPanel, IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
8+
import { TPromise } from 'vs/base/common/winjs.base';
9+
import * as dom from 'vs/base/browser/dom';
10+
import { IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
11+
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
12+
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
13+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
14+
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
15+
import { WorkbenchTree } from 'vs/platform/list/browser/listService';
16+
import { renderViewTree, twistiePixels } from 'vs/workbench/parts/debug/browser/baseDebugView';
17+
import { IAccessibilityProvider, ITree, IRenderer, IDataSource } from 'vs/base/parts/tree/browser/tree';
18+
19+
export class LoadedScriptsView extends TreeViewsViewletPanel {
20+
21+
private treeContainer: HTMLElement;
22+
23+
constructor(
24+
options: IViewletViewOptions,
25+
@IContextMenuService contextMenuService: IContextMenuService,
26+
@IKeybindingService keybindingService: IKeybindingService,
27+
@IInstantiationService private instantiationService: IInstantiationService,
28+
@IConfigurationService configurationService: IConfigurationService,
29+
) {
30+
super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('loadedScriptsSection', "Loaded Scripts Section") }, keybindingService, contextMenuService, configurationService);
31+
}
32+
33+
protected renderBody(container: HTMLElement): void {
34+
dom.addClass(container, 'debug-loaded-scripts');
35+
this.treeContainer = renderViewTree(container);
36+
37+
this.tree = this.instantiationService.createInstance(WorkbenchTree, this.treeContainer, {
38+
dataSource: new LoadedScriptsDataSource(),
39+
renderer: this.instantiationService.createInstance(LoadedScriptsRenderer),
40+
accessibilityProvider: new LoadedSciptsAccessibilityProvider(),
41+
}, {
42+
ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'loadedScriptsAriaLabel' }, "Debug Loaded Scripts"),
43+
twistiePixels
44+
});
45+
}
46+
47+
layoutBody(size: number): void {
48+
if (this.treeContainer) {
49+
this.treeContainer.style.height = size + 'px';
50+
}
51+
super.layoutBody(size);
52+
}
53+
}
54+
55+
// A good example of data source, renderers, action providers and accessibilty providers can be found in the callStackView.ts
56+
57+
class LoadedScriptsDataSource implements IDataSource {
58+
59+
getId(tree: ITree, element: any): string {
60+
throw new Error('Method not implemented.');
61+
}
62+
63+
hasChildren(tree: ITree, element: any): boolean {
64+
throw new Error('Method not implemented.');
65+
}
66+
67+
getChildren(tree: ITree, element: any): TPromise<any> {
68+
throw new Error('Method not implemented.');
69+
}
70+
71+
getParent(tree: ITree, element: any): TPromise<any> {
72+
throw new Error('Method not implemented.');
73+
}
74+
}
75+
76+
class LoadedScriptsRenderer implements IRenderer {
77+
78+
getHeight(tree: ITree, element: any): number {
79+
throw new Error('Method not implemented.');
80+
}
81+
82+
getTemplateId(tree: ITree, element: any): string {
83+
throw new Error('Method not implemented.');
84+
}
85+
86+
renderTemplate(tree: ITree, templateId: string, container: HTMLElement) {
87+
throw new Error('Method not implemented.');
88+
}
89+
90+
renderElement(tree: ITree, element: any, templateId: string, templateData: any): void {
91+
throw new Error('Method not implemented.');
92+
}
93+
94+
disposeTemplate(tree: ITree, templateId: string, templateData: any): void {
95+
throw new Error('Method not implemented.');
96+
}
97+
}
98+
99+
class LoadedSciptsAccessibilityProvider implements IAccessibilityProvider {
100+
101+
public getAriaLabel(tree: ITree, element: any): string {
102+
return nls.localize('implement me', "implement me");
103+
}
104+
}

src/vs/workbench/parts/debug/common/debug.ts

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry
3131
export const VARIABLES_VIEW_ID = 'workbench.debug.variablesView';
3232
export const WATCH_VIEW_ID = 'workbench.debug.watchExpressionsView';
3333
export const CALLSTACK_VIEW_ID = 'workbench.debug.callStackView';
34+
export const LOADED_SCRIPTS_VIEW_ID = 'workbench.debug.loadedScriptsView';
3435
export const BREAKPOINTS_VIEW_ID = 'workbench.debug.breakPointsView';
3536
export const REPL_ID = 'workbench.panel.repl';
3637
export const DEBUG_SERVICE_ID = 'debugService';
@@ -48,6 +49,7 @@ export const CONTEXT_VARIABLES_FOCUSED = new RawContextKey<boolean>('variablesFo
4849
export const CONTEXT_EXPRESSION_SELECTED = new RawContextKey<boolean>('expressionSelected', false);
4950
export const CONTEXT_BREAKPOINT_SELECTED = new RawContextKey<boolean>('breakpointSelected', false);
5051
export const CONTEXT_CALLSTACK_ITEM_TYPE = new RawContextKey<string>('callStackItemType', undefined);
52+
export const CONTEXT_LOADED_SCRIPTS_SUPPORTED = new RawContextKey<boolean>('loadedScriptsSupported', false);
5153

5254
export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug';
5355
export const DEBUG_SCHEME = 'debug';

src/vs/workbench/parts/debug/common/debugViewModel.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { Event, Emitter } from 'vs/base/common/event';
7-
import { CONTEXT_EXPRESSION_SELECTED, IViewModel, IStackFrame, ISession, IThread, IExpression, IFunctionBreakpoint, CONTEXT_BREAKPOINT_SELECTED } from 'vs/workbench/parts/debug/common/debug';
7+
import { CONTEXT_EXPRESSION_SELECTED, IViewModel, IStackFrame, ISession, IThread, IExpression, IFunctionBreakpoint, CONTEXT_BREAKPOINT_SELECTED, CONTEXT_LOADED_SCRIPTS_SUPPORTED } from 'vs/workbench/parts/debug/common/debug';
88
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
99

1010
export class ViewModel implements IViewModel {
@@ -20,6 +20,7 @@ export class ViewModel implements IViewModel {
2020
private multiSessionView: boolean;
2121
private expressionSelectedContextKey: IContextKey<boolean>;
2222
private breakpointSelectedContextKey: IContextKey<boolean>;
23+
private loadedScriptsSupportedContextKey: IContextKey<boolean>;
2324

2425
constructor(contextKeyService: IContextKeyService) {
2526
this._onDidFocusSession = new Emitter<ISession | undefined>();
@@ -28,6 +29,7 @@ export class ViewModel implements IViewModel {
2829
this.multiSessionView = false;
2930
this.expressionSelectedContextKey = CONTEXT_EXPRESSION_SELECTED.bindTo(contextKeyService);
3031
this.breakpointSelectedContextKey = CONTEXT_BREAKPOINT_SELECTED.bindTo(contextKeyService);
32+
this.loadedScriptsSupportedContextKey = CONTEXT_LOADED_SCRIPTS_SUPPORTED.bindTo(contextKeyService);
3133
}
3234

3335
public getId(): string {
@@ -66,6 +68,10 @@ export class ViewModel implements IViewModel {
6668
this._focusedThread = thread;
6769
this._focusedStackFrame = stackFrame;
6870

71+
this.loadedScriptsSupportedContextKey.set(session && session.raw.capabilities.supportsLoadedSourcesRequest);
72+
// @weinand remove the next line which always disables the context for the view to be shown
73+
this.loadedScriptsSupportedContextKey.set(false);
74+
6975
if (shouldEmit) {
7076
this._onDidFocusStackFrame.fire({ stackFrame, explicit });
7177
}

src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { CallStackView } from 'vs/workbench/parts/debug/electron-browser/callSta
2323
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
2424
import {
2525
IDebugService, VIEWLET_ID, REPL_ID, CONTEXT_NOT_IN_DEBUG_MODE, CONTEXT_IN_DEBUG_MODE, INTERNAL_CONSOLE_OPTIONS_SCHEMA,
26-
CONTEXT_DEBUG_STATE, VARIABLES_VIEW_ID, CALLSTACK_VIEW_ID, WATCH_VIEW_ID, BREAKPOINTS_VIEW_ID, VIEW_CONTAINER
26+
CONTEXT_DEBUG_STATE, VARIABLES_VIEW_ID, CALLSTACK_VIEW_ID, WATCH_VIEW_ID, BREAKPOINTS_VIEW_ID, VIEW_CONTAINER, LOADED_SCRIPTS_VIEW_ID, CONTEXT_LOADED_SCRIPTS_SUPPORTED
2727
} from 'vs/workbench/parts/debug/common/debug';
2828
import { IPartService } from 'vs/workbench/services/part/common/partService';
2929
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
@@ -51,6 +51,7 @@ import { DebugStatus } from 'vs/workbench/parts/debug/browser/debugStatus';
5151
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
5252
import { launchSchemaId } from 'vs/workbench/services/configuration/common/configuration';
5353
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
54+
import { LoadedScriptsView } from 'vs/workbench/parts/debug/browser/loadedScriptsView';
5455

5556
class OpenDebugViewletAction extends ToggleViewletAction {
5657
public static readonly ID = VIEWLET_ID;
@@ -111,6 +112,7 @@ Registry.as<PanelRegistry>(PanelExtensions.Panels).setDefaultPanelId(REPL_ID);
111112
ViewsRegistry.registerViews([{ id: VARIABLES_VIEW_ID, name: nls.localize('variables', "Variables"), ctor: VariablesView, order: 10, weight: 40, container: VIEW_CONTAINER, canToggleVisibility: true }]);
112113
ViewsRegistry.registerViews([{ id: WATCH_VIEW_ID, name: nls.localize('watch', "Watch"), ctor: WatchExpressionsView, order: 20, weight: 10, container: VIEW_CONTAINER, canToggleVisibility: true }]);
113114
ViewsRegistry.registerViews([{ id: CALLSTACK_VIEW_ID, name: nls.localize('callStack', "Call Stack"), ctor: CallStackView, order: 30, weight: 30, container: VIEW_CONTAINER, canToggleVisibility: true }]);
115+
ViewsRegistry.registerViews([{ id: LOADED_SCRIPTS_VIEW_ID, name: nls.localize('loadedScripts', "Loaded Scripts"), ctor: LoadedScriptsView, order: 35, weight: 10, container: VIEW_CONTAINER, canToggleVisibility: true, when: CONTEXT_LOADED_SCRIPTS_SUPPORTED }]);
114116
ViewsRegistry.registerViews([{ id: BREAKPOINTS_VIEW_ID, name: nls.localize('breakpoints', "Breakpoints"), ctor: BreakpointsView, order: 40, weight: 20, container: VIEW_CONTAINER, canToggleVisibility: true }]);
115117

116118
// register action to open viewlet

0 commit comments

Comments
 (0)