Skip to content

Commit de28894

Browse files
committed
debt: create tree using instatationService
1 parent 2275bfe commit de28894

7 files changed

Lines changed: 35 additions & 62 deletions

File tree

src/vs/workbench/contrib/debug/browser/callStackView.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import { IAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
2626
import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
2727
import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
2828
import { ITreeRenderer, ITreeNode, ITreeContextMenuEvent, IAsyncDataSource } from 'vs/base/browser/ui/tree/tree';
29-
import { TreeResourceNavigator2, WorkbenchAsyncDataTree, IListService } from 'vs/platform/list/browser/listService';
30-
import { IThemeService } from 'vs/platform/theme/common/themeService';
29+
import { TreeResourceNavigator2, WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService';
3130
import { onUnexpectedError } from 'vs/base/common/errors';
3231
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
3332
import { createMatches, FuzzyScore } from 'vs/base/common/filters';
@@ -46,7 +45,7 @@ export class CallStackView extends ViewletPanel {
4645
private ignoreFocusStackFrameEvent: boolean;
4746
private callStackItemType: IContextKey<string>;
4847
private dataSource: CallStackDataSource;
49-
private tree: WorkbenchAsyncDataTree<string | IStackFrame | IThread | IDebugSession | ThreadAndSessionIds | IDebugModel | IStackFrame[], CallStackItem, FuzzyScore>;
48+
private tree: WorkbenchAsyncDataTree<CallStackItem | IDebugModel, CallStackItem, FuzzyScore>;
5049
private contributedContextMenu: IMenu;
5150

5251
constructor(
@@ -58,9 +57,7 @@ export class CallStackView extends ViewletPanel {
5857
@IEditorService private readonly editorService: IEditorService,
5958
@IConfigurationService configurationService: IConfigurationService,
6059
@IMenuService menuService: IMenuService,
61-
@IContextKeyService private readonly contextKeyService: IContextKeyService,
62-
@IThemeService private readonly themeService: IThemeService,
63-
@IListService private readonly listService: IListService
60+
@IContextKeyService readonly contextKeyService: IContextKeyService,
6461
) {
6562
super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('callstackSection', "Call Stack Section") }, keybindingService, contextMenuService, configurationService);
6663
this.callStackItemType = CONTEXT_CALLSTACK_ITEM_TYPE.bindTo(contextKeyService);
@@ -103,7 +100,7 @@ export class CallStackView extends ViewletPanel {
103100
const treeContainer = renderViewTree(container);
104101

105102
this.dataSource = new CallStackDataSource();
106-
this.tree = new WorkbenchAsyncDataTree(treeContainer, new CallStackDelegate(), [
103+
this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree, treeContainer, new CallStackDelegate(), [
107104
new SessionsRenderer(),
108105
new ThreadsRenderer(),
109106
this.instantiationService.createInstance(StackFramesRenderer),
@@ -122,7 +119,7 @@ export class CallStackView extends ViewletPanel {
122119
return `showMore ${element[0].getId()}`;
123120
}
124121

125-
return element.getId();
122+
return (<IStackFrame | IThread | IDebugSession | ThreadAndSessionIds>element).getId();
126123
}
127124
},
128125
keyboardNavigationLabelProvider: {
@@ -143,7 +140,7 @@ export class CallStackView extends ViewletPanel {
143140
return nls.localize('showMoreStackFrames2', "Show More Stack Frames");
144141
}
145142
}
146-
}, this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService);
143+
}) as WorkbenchAsyncDataTree<CallStackItem | IDebugModel, CallStackItem, FuzzyScore>;
147144

148145
this.tree.setInput(this.debugService.getModel()).then(undefined, onUnexpectedError);
149146

src/vs/workbench/contrib/debug/browser/debugHover.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ import { getExactExpressionStartAndEnd } from 'vs/workbench/contrib/debug/common
2626
import { AsyncDataTree } from 'vs/base/browser/ui/tree/asyncDataTree';
2727
import { IAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
2828
import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
29-
import { WorkbenchAsyncDataTree, IListService } from 'vs/platform/list/browser/listService';
30-
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
31-
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
29+
import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService';
3230
import { coalesce } from 'vs/base/common/arrays';
33-
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
3431
import { IAsyncDataSource } from 'vs/base/browser/ui/tree/tree';
3532
import { VariablesRenderer } from 'vs/workbench/contrib/debug/browser/variablesView';
3633

@@ -61,10 +58,6 @@ export class DebugHoverWidget implements IContentWidget {
6158
@IDebugService private readonly debugService: IDebugService,
6259
@IInstantiationService private readonly instantiationService: IInstantiationService,
6360
@IThemeService private readonly themeService: IThemeService,
64-
@IContextKeyService private readonly contextKeyService: IContextKeyService,
65-
@IListService private readonly listService: IListService,
66-
@IConfigurationService private readonly configurationService: IConfigurationService,
67-
@IKeybindingService private readonly keybindingService: IKeybindingService
6861
) {
6962
this.toDispose = [];
7063

@@ -81,13 +74,13 @@ export class DebugHoverWidget implements IContentWidget {
8174
this.treeContainer.setAttribute('role', 'tree');
8275
this.dataSource = new DebugHoverDataSource();
8376

84-
this.tree = new WorkbenchAsyncDataTree(this.treeContainer, new DebugHoverDelegate(), [this.instantiationService.createInstance(VariablesRenderer)],
77+
this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree, this.treeContainer, new DebugHoverDelegate(), [this.instantiationService.createInstance(VariablesRenderer)],
8578
this.dataSource, {
8679
ariaLabel: nls.localize('treeAriaLabel', "Debug Hover"),
8780
accessibilityProvider: new DebugHoverAccessibilityProvider(),
8881
mouseSupport: false,
8982
horizontalScrolling: true
90-
}, this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService);
83+
}) as any as AsyncDataTree<IExpression, IExpression, any>;
9184

9285
this.valueContainer = $('.value');
9386
this.valueContainer.tabIndex = 0;

src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
2929
import { ITreeRenderer, ITreeNode, ITreeFilter, TreeVisibility, TreeFilterResult, IAsyncDataSource } from 'vs/base/browser/ui/tree/tree';
3030
import { IAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
3131
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
32-
import { WorkbenchAsyncDataTree, IListService, TreeResourceNavigator2 } from 'vs/platform/list/browser/listService';
33-
import { IThemeService } from 'vs/platform/theme/common/themeService';
32+
import { WorkbenchAsyncDataTree, TreeResourceNavigator2 } from 'vs/platform/list/browser/listService';
3433
import { dispose } from 'vs/base/common/lifecycle';
3534
import { createMatches, FuzzyScore } from 'vs/base/common/filters';
3635
import { DebugContentProvider } from 'vs/workbench/contrib/debug/common/debugContentProvider';
@@ -387,12 +386,10 @@ export class LoadedScriptsView extends ViewletPanel {
387386
@IInstantiationService private readonly instantiationService: IInstantiationService,
388387
@IConfigurationService configurationService: IConfigurationService,
389388
@IEditorService private readonly editorService: IEditorService,
390-
@IContextKeyService private readonly contextKeyService: IContextKeyService,
389+
@IContextKeyService readonly contextKeyService: IContextKeyService,
391390
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
392391
@IEnvironmentService private readonly environmentService: IEnvironmentService,
393392
@IDebugService private readonly debugService: IDebugService,
394-
@IListService private readonly listService: IListService,
395-
@IThemeService private readonly themeService: IThemeService
396393
) {
397394
super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('loadedScriptsSection', "Loaded Scripts Section") }, keybindingService, contextMenuService, configurationService);
398395
this.loadedScriptsItemType = CONTEXT_LOADED_SCRIPTS_ITEM_TYPE.bindTo(contextKeyService);
@@ -411,22 +408,21 @@ export class LoadedScriptsView extends ViewletPanel {
411408
this.treeLabels = this.instantiationService.createInstance(ResourceLabels, { onDidChangeVisibility: this.onDidChangeBodyVisibility } as IResourceLabelsContainer);
412409
this.disposables.push(this.treeLabels);
413410

414-
this.tree = new WorkbenchAsyncDataTree(this.treeContainer, new LoadedScriptsDelegate(),
411+
this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree, this.treeContainer, new LoadedScriptsDelegate(),
415412
[new LoadedScriptsRenderer(this.treeLabels)],
416413
new LoadedScriptsDataSource(),
417414
{
418415
identityProvider: {
419-
getId: element => element.getId()
416+
getId: element => (<LoadedScriptsItem>element).getId()
420417
},
421418
keyboardNavigationLabelProvider: {
422-
getKeyboardNavigationLabel: element => element.getLabel()
419+
getKeyboardNavigationLabel: element => (<LoadedScriptsItem>element).getLabel()
423420
},
424421
filter: this.filter,
425422
accessibilityProvider: new LoadedSciptsAccessibilityProvider(),
426423
ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'loadedScriptsAriaLabel' }, "Debug Loaded Scripts"),
427-
},
428-
this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService
429-
);
424+
}
425+
) as WorkbenchAsyncDataTree<LoadedScriptsItem, LoadedScriptsItem, FuzzyScore>;
430426

431427
this.tree.setInput(root);
432428

src/vs/workbench/contrib/debug/browser/repl.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ import { ReplCollapseAllAction, CopyAction } from 'vs/workbench/contrib/debug/br
5656
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
5757
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
5858
import { removeAnsiEscapeCodes } from 'vs/base/common/strings';
59-
import { WorkbenchAsyncDataTree, IListService } from 'vs/platform/list/browser/listService';
59+
import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService';
6060
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
6161
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
6262
import { RunOnceScheduler } from 'vs/base/common/async';
63-
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
6463
import { FuzzyScore, createMatches } from 'vs/base/common/filters';
6564
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
6665
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
@@ -116,10 +115,8 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
116115
@IContextKeyService private readonly contextKeyService: IContextKeyService,
117116
@ICodeEditorService codeEditorService: ICodeEditorService,
118117
@IContextMenuService private readonly contextMenuService: IContextMenuService,
119-
@IListService private readonly listService: IListService,
120118
@IConfigurationService private readonly configurationService: IConfigurationService,
121119
@ITextResourcePropertiesService private readonly textResourcePropertiesService: ITextResourcePropertiesService,
122-
@IKeybindingService private readonly keybindingService: IKeybindingService,
123120
@IClipboardService private readonly clipboardService: IClipboardService
124121
) {
125122
super(REPL_ID, telemetryService, themeService, storageService);
@@ -369,21 +366,21 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
369366
this.createReplInput(this.container);
370367

371368
this.replDelegate = new ReplDelegate(this.configurationService);
372-
this.tree = new WorkbenchAsyncDataTree<IDebugSession, IReplElement, FuzzyScore>(treeContainer, this.replDelegate, [
369+
this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree, treeContainer, this.replDelegate, [
373370
this.instantiationService.createInstance(VariablesRenderer),
374371
this.instantiationService.createInstance(ReplSimpleElementsRenderer),
375372
new ReplExpressionsRenderer(),
376373
new ReplRawObjectsRenderer()
377374
], new ReplDataSource(), {
378375
ariaLabel: nls.localize('replAriaLabel', "Read Eval Print Loop Panel"),
379376
accessibilityProvider: new ReplAccessibilityProvider(),
380-
identityProvider: { getId: element => element.getId() },
377+
identityProvider: { getId: element => (<IReplElement>element).getId() },
381378
mouseSupport: false,
382379
keyboardNavigationLabelProvider: { getKeyboardNavigationLabel: e => e },
383380
horizontalScrolling: false,
384381
setRowLineHeight: false,
385382
supportDynamicHeights: true
386-
}, this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService);
383+
}) as WorkbenchAsyncDataTree<IDebugSession, IReplElement, FuzzyScore>;
387384

388385
this.toDispose.push(this.tree.onContextMenu(e => this.onContextMenu(e)));
389386
// Make sure to select the session if debugging is already active

src/vs/workbench/contrib/debug/browser/variablesView.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
2323
import { ITreeRenderer, ITreeNode, ITreeMouseEvent, ITreeContextMenuEvent, IAsyncDataSource } from 'vs/base/browser/ui/tree/tree';
2424
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
2525
import { Emitter } from 'vs/base/common/event';
26-
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
27-
import { WorkbenchAsyncDataTree, IListService } from 'vs/platform/list/browser/listService';
28-
import { IThemeService } from 'vs/platform/theme/common/themeService';
26+
import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService';
2927
import { onUnexpectedError } from 'vs/base/common/errors';
3028
import { FuzzyScore, createMatches } from 'vs/base/common/filters';
3129
import { HighlightedLabel, IHighlight } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
@@ -47,9 +45,6 @@ export class VariablesView extends ViewletPanel {
4745
@IKeybindingService keybindingService: IKeybindingService,
4846
@IConfigurationService configurationService: IConfigurationService,
4947
@IInstantiationService private readonly instantiationService: IInstantiationService,
50-
@IContextKeyService private readonly contextKeyService: IContextKeyService,
51-
@IListService private readonly listService: IListService,
52-
@IThemeService private readonly themeService: IThemeService
5348
) {
5449
super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('variablesSection', "Variables Section") }, keybindingService, contextMenuService, configurationService);
5550

@@ -74,14 +69,14 @@ export class VariablesView extends ViewletPanel {
7469
dom.addClass(container, 'debug-variables');
7570
const treeContainer = renderViewTree(container);
7671

77-
this.tree = new WorkbenchAsyncDataTree(treeContainer, new VariablesDelegate(),
72+
this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree, treeContainer, new VariablesDelegate(),
7873
[this.instantiationService.createInstance(VariablesRenderer), new ScopesRenderer()],
7974
new VariablesDataSource(), {
8075
ariaLabel: nls.localize('variablesAriaTreeLabel', "Debug Variables"),
8176
accessibilityProvider: new VariablesAccessibilityProvider(),
82-
identityProvider: { getId: element => element.getId() },
77+
identityProvider: { getId: element => (<IExpression | IScope>element).getId() },
8378
keyboardNavigationLabelProvider: { getKeyboardNavigationLabel: e => e }
84-
}, this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService);
79+
}) as WorkbenchAsyncDataTree<IViewModel | IExpression | IScope, IExpression | IScope, FuzzyScore>;
8580

8681
this.tree.setInput(this.debugService.getViewModel()).then(null, onUnexpectedError);
8782

src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
2121
import { IViewletPanelOptions, ViewletPanel } from 'vs/workbench/browser/parts/views/panelViewlet';
2222
import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
2323
import { IAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
24-
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
25-
import { WorkbenchAsyncDataTree, IListService } from 'vs/platform/list/browser/listService';
26-
import { IThemeService } from 'vs/platform/theme/common/themeService';
24+
import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService';
2725
import { IAsyncDataSource, ITreeMouseEvent, ITreeContextMenuEvent, ITreeDragAndDrop, ITreeDragOverReaction } from 'vs/base/browser/ui/tree/tree';
2826
import { IDragAndDropData } from 'vs/base/browser/dnd';
2927
import { onUnexpectedError } from 'vs/base/common/errors';
@@ -47,9 +45,6 @@ export class WatchExpressionsView extends ViewletPanel {
4745
@IKeybindingService keybindingService: IKeybindingService,
4846
@IInstantiationService private readonly instantiationService: IInstantiationService,
4947
@IConfigurationService configurationService: IConfigurationService,
50-
@IContextKeyService private readonly contextKeyService: IContextKeyService,
51-
@IListService private readonly listService: IListService,
52-
@IThemeService private readonly themeService: IThemeService
5348
) {
5449
super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('watchExpressionsSection', "Watch Expressions Section") }, keybindingService, contextMenuService, configurationService);
5550

@@ -64,14 +59,14 @@ export class WatchExpressionsView extends ViewletPanel {
6459
const treeContainer = renderViewTree(container);
6560

6661
const expressionsRenderer = this.instantiationService.createInstance(WatchExpressionsRenderer);
67-
this.tree = new WorkbenchAsyncDataTree(treeContainer, new WatchExpressionsDelegate(), [expressionsRenderer, this.instantiationService.createInstance(VariablesRenderer)],
62+
this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree, treeContainer, new WatchExpressionsDelegate(), [expressionsRenderer, this.instantiationService.createInstance(VariablesRenderer)],
6863
new WatchExpressionsDataSource(), {
6964
ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'watchAriaTreeLabel' }, "Debug Watch Expressions"),
7065
accessibilityProvider: new WatchExpressionsAccessibilityProvider(),
71-
identityProvider: { getId: element => element.getId() },
66+
identityProvider: { getId: element => (<IExpression>element).getId() },
7267
keyboardNavigationLabelProvider: { getKeyboardNavigationLabel: e => e },
7368
dnd: new WatchExpressionsDragAndDrop(this.debugService),
74-
}, this.contextKeyService, this.listService, this.themeService, this.configurationService, this.keybindingService);
69+
}) as WorkbenchAsyncDataTree<IDebugService | IExpression, IExpression, FuzzyScore>;
7570

7671
this.tree.setInput(this.debugService).then(undefined, onUnexpectedError);
7772
CONTEXT_WATCH_EXPRESSIONS_FOCUSED.bindTo(this.tree.contextKeyService);

0 commit comments

Comments
 (0)