markersView.ts 33.9 KB
Newer Older
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import 'vs/css!./media/markers';
S
Sandeep Somavarapu 已提交
7

8
import { URI } from 'vs/base/common/uri';
9
import * as dom from 'vs/base/browser/dom';
10
import { IAction, IActionViewItem, Action } from 'vs/base/common/actions';
11
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
12
import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
S
Sandeep Somavarapu 已提交
13
import Constants from 'vs/workbench/contrib/markers/browser/constants';
S
Sandeep Somavarapu 已提交
14
import { Marker, ResourceMarkers, RelatedInformation, MarkerChangesEvent } from 'vs/workbench/contrib/markers/browser/markersModel';
S
Sandeep Somavarapu 已提交
15
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
16
import { MarkersFilterActionViewItem, MarkersFilters, IMarkersFiltersChangeEvent, IMarkerFilterController } from 'vs/workbench/contrib/markers/browser/markersViewActions';
S
Sandeep Somavarapu 已提交
17
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
S
Sandeep Somavarapu 已提交
18
import Messages from 'vs/workbench/contrib/markers/browser/messages';
19
import { RangeHighlightDecorations } from 'vs/workbench/browser/parts/editor/rangeDecorations';
M
Martin Aeschlimann 已提交
20
import { IThemeService, registerThemingParticipant, IColorTheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
21
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
S
Sandeep Somavarapu 已提交
22
import { IMarkersWorkbenchService } from 'vs/workbench/contrib/markers/browser/markers';
B
Benjamin Pasero 已提交
23
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
24
import { localize } from 'vs/nls';
25
import { IContextKey, IContextKeyService, ContextKeyEqualsExpr, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
J
João Moreno 已提交
26
import { Iterable } from 'vs/base/common/iterator';
S
Sandeep Somavarapu 已提交
27
import { ITreeElement, ITreeNode, ITreeContextMenuEvent, ITreeRenderer } from 'vs/base/browser/ui/tree/tree';
J
Joao Moreno 已提交
28
import { Relay, Event, Emitter } from 'vs/base/common/event';
J
João Moreno 已提交
29
import { WorkbenchObjectTree, TreeResourceNavigator, IListService, IWorkbenchObjectTreeOptions } from 'vs/platform/list/browser/listService';
S
Sandeep Somavarapu 已提交
30
import { FilterOptions } from 'vs/workbench/contrib/markers/browser/markersFilterOptions';
31 32 33
import { IExpression } from 'vs/base/common/glob';
import { deepClone } from 'vs/base/common/objects';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
S
Sandeep Somavarapu 已提交
34
import { FilterData, Filter, VirtualDelegate, ResourceMarkersRenderer, MarkerRenderer, RelatedInformationRenderer, TreeElement, MarkersTreeAccessibilityProvider, MarkersViewModel, ResourceDragAndDrop } from 'vs/workbench/contrib/markers/browser/markersTreeViewer';
J
Joao Moreno 已提交
35
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
S
Sandeep Somavarapu 已提交
36
import { Separator, ActionViewItem, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
37
import { IMenuService, MenuId, registerAction2, Action2 } from 'vs/platform/actions/common/actions';
J
Joao Moreno 已提交
38
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
S
Sandeep Somavarapu 已提交
39
import { StandardKeyboardEvent, IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
40
import { domEvent } from 'vs/base/browser/event';
B
Benjamin Pasero 已提交
41
import { ResourceLabels } from 'vs/workbench/browser/labels';
42
import { IMarker } from 'vs/platform/markers/common/markers';
43
import { withUndefinedAsNull } from 'vs/base/common/types';
44
import { MementoObject, Memento } from 'vs/workbench/common/memento';
S
Sandeep Somavarapu 已提交
45 46
import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
S
Sandeep Somavarapu 已提交
47
import { KeyCode } from 'vs/base/common/keyCodes';
48
import { editorLightBulbForeground, editorLightBulbAutoFixForeground } from 'vs/platform/theme/common/colorRegistry';
S
Sandeep Somavarapu 已提交
49
import { ViewPane, IViewPaneOptions } from 'vs/workbench/browser/parts/views/viewPaneContainer';
50
import { IViewDescriptorService } from 'vs/workbench/common/views';
51
import { IOpenerService } from 'vs/platform/opener/common/opener';
M
Martin Aeschlimann 已提交
52
import { Codicon } from 'vs/base/common/codicons';
J
Joao Moreno 已提交
53

J
João Moreno 已提交
54 55 56 57
function createResourceMarkersIterator(resourceMarkers: ResourceMarkers): Iterable<ITreeElement<TreeElement>> {
	return Iterable.map(resourceMarkers.markers, m => {
		const relatedInformationIt = Iterable.from(m.relatedInformation);
		const children = Iterable.map(relatedInformationIt, r => ({ element: r }));
J
Joao Moreno 已提交
58 59 60 61

		return { element: m, children };
	});
}
62

S
Sandeep Somavarapu 已提交
63
export class MarkersView extends ViewPane implements IMarkerFilterController {
64

S
Sandeep Somavarapu 已提交
65
	private lastSelectedRelativeTop: number = 0;
66
	private currentActiveResource: URI | null = null;
S
Sandeep Somavarapu 已提交
67

68 69 70
	private readonly rangeHighlightDecorations: RangeHighlightDecorations;
	private readonly filter: Filter;

S
Sandeep Somavarapu 已提交
71 72 73 74
	private tree: MarkersTree | undefined;
	private filterActionBar: ActionBar | undefined;
	private messageBoxContainer: HTMLElement | undefined;
	private ariaLabelElement: HTMLElement | undefined;
75
	readonly filters: MarkersFilters;
76

77
	private readonly panelState: MementoObject;
S
Sandeep Somavarapu 已提交
78

79 80
	private _onDidChangeFilterStats = this._register(new Emitter<{ total: number, filtered: number }>());
	readonly onDidChangeFilterStats: Event<{ total: number, filtered: number }> = this._onDidChangeFilterStats.event;
J
Joao Moreno 已提交
81 82
	private cachedFilterStats: { total: number; filtered: number; } | undefined = undefined;

83
	private currentResourceGotAddedToMarkersData: boolean = false;
S
Sandeep Somavarapu 已提交
84
	readonly markersViewModel: MarkersViewModel;
85 86 87
	private readonly smallLayoutContextKey: IContextKey<boolean>;
	private get smallLayout(): boolean { return !!this.smallLayoutContextKey.get(); }
	private set smallLayout(smallLayout: boolean) { this.smallLayoutContextKey.set(smallLayout); }
88

89 90
	readonly onDidChangeVisibility = this.onDidChangeBodyVisibility;

91 92 93
	private readonly _onDidFocusFilter: Emitter<void> = this._register(new Emitter<void>());
	readonly onDidFocusFilter: Event<void> = this._onDidFocusFilter.event;

S
Sandeep Somavarapu 已提交
94 95 96
	private readonly _onDidClearFilterText: Emitter<void> = this._register(new Emitter<void>());
	readonly onDidClearFilterText: Event<void> = this._onDidClearFilterText.event;

97
	constructor(
98
		options: IViewPaneOptions,
99
		@IInstantiationService instantiationService: IInstantiationService,
100
		@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
101
		@IEditorService private readonly editorService: IEditorService,
102
		@IConfigurationService configurationService: IConfigurationService,
103
		@ITelemetryService telemetryService: ITelemetryService,
104
		@IMarkersWorkbenchService private readonly markersWorkbenchService: IMarkersWorkbenchService,
J
Joao Moreno 已提交
105
		@IContextKeyService contextKeyService: IContextKeyService,
106
		@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
107
		@IContextMenuService contextMenuService: IContextMenuService,
108
		@IMenuService private readonly menuService: IMenuService,
109 110
		@IKeybindingService keybindingService: IKeybindingService,
		@IStorageService storageService: IStorageService,
111 112
		@IOpenerService openerService: IOpenerService,
		@IThemeService themeService: IThemeService,
113
	) {
114
		super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
115
		this.smallLayoutContextKey = Constants.MarkersViewSmallLayoutContextKey.bindTo(this.contextKeyService);
116
		this.panelState = new Memento(Constants.MARKERS_VIEW_STORAGE_ID, storageService).getMemento(StorageScope.WORKSPACE);
S
Sandeep Somavarapu 已提交
117 118
		this.markersViewModel = this._register(instantiationService.createInstance(MarkersViewModel, this.panelState['multiline']));
		this._register(this.markersViewModel.onDidChange(marker => this.onDidChangeViewState(marker)));
S
Sandeep Somavarapu 已提交
119
		this.setCurrentActiveEditor();
120 121 122 123 124

		this.filter = new Filter(new FilterOptions());
		this.rangeHighlightDecorations = this._register(this.instantiationService.createInstance(RangeHighlightDecorations));

		// actions
125 126
		this.regiserActions();
		this.filters = this._register(new MarkersFilters({
127 128 129 130 131
			filterText: this.panelState['filter'] || '',
			filterHistory: this.panelState['filterHistory'] || [],
			showErrors: this.panelState['showErrors'] !== false,
			showWarnings: this.panelState['showWarnings'] !== false,
			showInfos: this.panelState['showInfos'] !== false,
S
Sandeep Somavarapu 已提交
132
			excludedFiles: !!this.panelState['useFilesExclude'],
133 134
			activeFile: !!this.panelState['activeFile'],
			layout: new dom.Dimension(0, 0)
135
		}));
136 137
	}

138
	public renderBody(parent: HTMLElement): void {
J
Joao Moreno 已提交
139
		super.renderBody(parent);
S
Sandeep Somavarapu 已提交
140

141
		dom.addClass(parent, 'markers-panel');
142

S
Sandeep Somavarapu 已提交
143
		const container = dom.append(parent, dom.$('.markers-panel-container'));
S
Sandeep Somavarapu 已提交
144

S
Sandeep Somavarapu 已提交
145
		this.createFilterActionBar(container);
S
Sandeep Somavarapu 已提交
146
		this.createArialLabelElement(container);
147
		this.createMessageBox(container);
S
Sandeep Somavarapu 已提交
148
		this.createTree(container);
149
		this.createListeners();
150

J
Joao Moreno 已提交
151
		this.updateFilter();
S
Sandeep Somavarapu 已提交
152

153 154 155 156 157 158 159
		this._register(this.onDidChangeVisibility(visible => {
			if (visible) {
				this.refreshPanel();
			} else {
				this.rangeHighlightDecorations.removeHighlightRange();
			}
		}));
S
Sandeep Somavarapu 已提交
160

161
		this.filterActionBar!.push(new Action(`workbench.actions.treeView.${this.id}.filter`));
162
		this.renderContent();
163 164
	}

S
Sandeep Somavarapu 已提交
165
	public getTitle(): string {
B
Benjamin Pasero 已提交
166
		return Messages.MARKERS_PANEL_TITLE_PROBLEMS;
S
Sandeep Somavarapu 已提交
167 168
	}

169
	public layoutBody(height: number, width: number): void {
170 171 172
		const wasSmallLayout = this.smallLayout;
		this.smallLayout = width < 600 && height > 100;
		if (this.smallLayout !== wasSmallLayout) {
S
Sandeep Somavarapu 已提交
173
			if (this.filterActionBar) {
174
				dom.toggleClass(this.filterActionBar.getContainer(), 'hide', !this.smallLayout);
S
Sandeep Somavarapu 已提交
175
			}
S
Sandeep Somavarapu 已提交
176
		}
177
		const contentHeight = this.smallLayout ? height - 44 : height;
S
Sandeep Somavarapu 已提交
178 179 180 181 182 183
		if (this.tree) {
			this.tree.layout(contentHeight, width);
		}
		if (this.messageBoxContainer) {
			this.messageBoxContainer.style.height = `${contentHeight}px`;
		}
184
		this.filters.layout = new dom.Dimension(this.smallLayout ? width : width - 200, height);
185 186
	}

S
Sandeep Somavarapu 已提交
187
	public focus(): void {
S
Sandeep Somavarapu 已提交
188
		if (this.tree && this.tree.getHTMLElement() === document.activeElement) {
189 190 191
			return;
		}

J
Joao Moreno 已提交
192
		if (this.hasNoProblems() && this.messageBoxContainer) {
S
Sandeep Somavarapu 已提交
193
			this.messageBoxContainer.focus();
S
Sandeep Somavarapu 已提交
194
		} else if (this.tree) {
S
Sandeep Somavarapu 已提交
195 196
			this.tree.getHTMLElement().focus();
		}
S
Sandeep Somavarapu 已提交
197 198
	}

S
Sandeep Somavarapu 已提交
199
	public focusFilter(): void {
200 201 202
		this._onDidFocusFilter.fire();
	}

S
Sandeep Somavarapu 已提交
203 204 205 206
	public clearFilterText(): void {
		this._onDidClearFilterText.fire();
	}

207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
	private regiserActions(): void {
		const that = this;
		this._register(registerAction2(class extends Action2 {
			constructor() {
				super({
					id: `workbench.actions.treeView.${that.id}.collapseAll`,
					title: localize('collapseAll', "Collapse All"),
					menu: {
						id: MenuId.ViewTitle,
						when: ContextKeyEqualsExpr.create('view', that.id),
						group: 'navigation',
						order: Number.MAX_SAFE_INTEGER,
					},
					icon: { id: 'codicon/collapse-all' }
				});
			}
			async run(): Promise<void> {
				return that.collapseAll();
			}
		}));
		this._register(registerAction2(class extends Action2 {
			constructor() {
				super({
					id: `workbench.actions.treeView.${that.id}.filter`,
					title: localize('filter', "Filter"),
					menu: {
						id: MenuId.ViewTitle,
						when: ContextKeyExpr.and(ContextKeyEqualsExpr.create('view', that.id), Constants.MarkersViewSmallLayoutContextKey.negate()),
						group: 'navigation',
						order: 1,
					},
				});
			}
			async run(): Promise<void> { }
		}));
S
Sandeep Somavarapu 已提交
242 243
	}

S
Sandeep Somavarapu 已提交
244 245 246 247 248 249 250
	public showQuickFixes(marker: Marker): void {
		const viewModel = this.markersViewModel.getViewModel(marker);
		if (viewModel) {
			viewModel.quickFixAction.run();
		}
	}

S
Sandeep Somavarapu 已提交
251
	public openFileAtElement(element: any, preserveFocus: boolean, sideByside: boolean, pinned: boolean): boolean {
252 253
		const { resource, selection, event, data } = element instanceof Marker ? { resource: element.resource, selection: element.range, event: 'problems.selectDiagnostic', data: this.getTelemetryData(element.marker) } :
			element instanceof RelatedInformation ? { resource: element.raw.resource, selection: element.raw, event: 'problems.selectRelatedInformation', data: this.getTelemetryData(element.marker) } : { resource: null, selection: null, event: null, data: null };
M
Matt Bierner 已提交
254
		if (resource && selection && event) {
255 256 257 258 259 260 261 262 263 264 265 266 267
			/* __GDPR__
			"problems.selectDiagnostic" : {
				"source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
				"code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }
			}
			*/
			/* __GDPR__
				"problems.selectRelatedInformation" : {
					"source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
					"code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }
				}
			*/
			this.telemetryService.publicLog(event, data);
S
Sandeep Somavarapu 已提交
268
			this.editorService.openEditor({
269
				resource,
S
Sandeep Somavarapu 已提交
270
				options: {
271
					selection,
S
Sandeep Somavarapu 已提交
272 273
					preserveFocus,
					pinned,
274
					revealIfVisible: true
S
Sandeep Somavarapu 已提交
275
				},
276
			}, sideByside ? SIDE_GROUP : ACTIVE_GROUP).then(editor => {
S
Sandeep Somavarapu 已提交
277
				if (editor && preserveFocus) {
278
					this.rangeHighlightDecorations.highlightRange({ resource, range: selection }, <ICodeEditor>editor.getControl());
S
Sandeep Somavarapu 已提交
279 280 281
				} else {
					this.rangeHighlightDecorations.removeHighlightRange();
				}
282
			});
S
Sandeep Somavarapu 已提交
283 284 285 286 287 288 289
			return true;
		} else {
			this.rangeHighlightDecorations.removeHighlightRange();
		}
		return false;
	}

290
	private refreshPanel(markerOrChange?: Marker | MarkerChangesEvent): void {
S
Sandeep Somavarapu 已提交
291
		if (this.isVisible() && this.tree) {
J
Joao Moreno 已提交
292
			this.cachedFilterStats = undefined;
293

294 295 296 297 298 299
			if (markerOrChange) {
				if (markerOrChange instanceof Marker) {
					this.tree.rerender(markerOrChange);
				} else {
					if (markerOrChange.added.length || markerOrChange.removed.length) {
						// Reset complete tree
S
Sandeep Somavarapu 已提交
300
						this.resetTree();
301 302 303 304 305 306 307
					} else {
						// Update resource
						for (const updated of markerOrChange.updated) {
							this.tree.setChildren(updated, createResourceMarkersIterator(updated));
						}
					}
				}
308
			} else {
309
				// Reset complete tree
S
Sandeep Somavarapu 已提交
310
				this.resetTree();
311
			}
J
Joao Moreno 已提交
312 313

			const { total, filtered } = this.getFilterStats();
S
Sandeep Somavarapu 已提交
314
			this.tree.toggleVisibility(total === 0 || filtered === 0);
J
Joao Moreno 已提交
315
			this.renderMessage();
316
			this._onDidChangeFilterStats.fire(this.getFilterStats());
S
Sandeep Somavarapu 已提交
317
		}
318 319
	}

S
#1927  
Sandeep Somavarapu 已提交
320
	private onDidChangeViewState(marker?: Marker): void {
321
		this.refreshPanel(marker);
S
#1927  
Sandeep Somavarapu 已提交
322 323
	}

S
Sandeep Somavarapu 已提交
324
	private resetTree(): void {
S
Sandeep Somavarapu 已提交
325 326 327
		if (!this.tree) {
			return;
		}
S
Sandeep Somavarapu 已提交
328
		let resourceMarkers: ResourceMarkers[] = [];
329
		if (this.filters.activeFile) {
S
Sandeep Somavarapu 已提交
330 331 332 333 334 335 336 337 338
			if (this.currentActiveResource) {
				const activeResourceMarkers = this.markersWorkbenchService.markersModel.getResourceMarkers(this.currentActiveResource);
				if (activeResourceMarkers) {
					resourceMarkers = [activeResourceMarkers];
				}
			}
		} else {
			resourceMarkers = this.markersWorkbenchService.markersModel.resourceMarkers;
		}
J
João Moreno 已提交
339
		this.tree.setChildren(null, Iterable.map(resourceMarkers, m => ({ element: m, children: createResourceMarkersIterator(m) })));
S
Sandeep Somavarapu 已提交
340 341
	}

J
Joao Moreno 已提交
342
	private updateFilter() {
J
Joao Moreno 已提交
343
		this.cachedFilterStats = undefined;
344
		this.filter.options = new FilterOptions(this.filters.filterText, this.getFilesExcludeExpressions(), this.filters.showWarnings, this.filters.showErrors, this.filters.showInfos);
S
Sandeep Somavarapu 已提交
345 346 347
		if (this.tree) {
			this.tree.refilter();
		}
348
		this._onDidChangeFilterStats.fire(this.getFilterStats());
S
Sandeep Somavarapu 已提交
349 350

		const { total, filtered } = this.getFilterStats();
S
Sandeep Somavarapu 已提交
351 352 353
		if (this.tree) {
			this.tree.toggleVisibility(total === 0 || filtered === 0);
		}
J
Joao Moreno 已提交
354
		this.renderMessage();
J
Joao Moreno 已提交
355 356
	}

357
	private getFilesExcludeExpressions(): { root: URI, expression: IExpression }[] | IExpression {
358
		if (!this.filters.excludedFiles) {
359
			return [];
J
Joao Moreno 已提交
360 361 362
		}

		const workspaceFolders = this.workspaceContextService.getWorkspace().folders;
363 364 365
		return workspaceFolders.length
			? workspaceFolders.map(workspaceFolder => ({ root: workspaceFolder.uri, expression: this.getFilesExclude(workspaceFolder.uri) }))
			: this.getFilesExclude();
J
Joao Moreno 已提交
366 367 368 369 370 371
	}

	private getFilesExclude(resource?: URI): IExpression {
		return deepClone(this.configurationService.getValue('files.exclude', { resource })) || {};
	}

S
Sandeep Somavarapu 已提交
372 373 374
	private createFilterActionBar(parent: HTMLElement): void {
		this.filterActionBar = this._register(new ActionBar(parent, { actionViewItemProvider: action => this.getActionViewItem(action) }));
		dom.addClass(this.filterActionBar.getContainer(), 'markers-panel-filter-container');
375
		dom.toggleClass(this.filterActionBar.getContainer(), 'hide', !this.smallLayout);
S
Sandeep Somavarapu 已提交
376 377
	}

S
Sandeep Somavarapu 已提交
378
	private createMessageBox(parent: HTMLElement): void {
J
Joao Moreno 已提交
379
		this.messageBoxContainer = dom.append(parent, dom.$('.message-box-container'));
S
Sandeep Somavarapu 已提交
380 381 382 383 384 385
		this.messageBoxContainer.setAttribute('aria-labelledby', 'markers-panel-arialabel');
	}

	private createArialLabelElement(parent: HTMLElement): void {
		this.ariaLabelElement = dom.append(parent, dom.$(''));
		this.ariaLabelElement.setAttribute('id', 'markers-panel-arialabel');
S
Sandeep Somavarapu 已提交
386 387
	}

S
Sandeep Somavarapu 已提交
388
	private createTree(parent: HTMLElement): void {
J
Joao Moreno 已提交
389 390
		const onDidChangeRenderNodeCount = new Relay<ITreeNode<any, any>>();

391
		const treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this));
B
Benjamin Pasero 已提交
392

S
Sandeep Somavarapu 已提交
393
		const virtualDelegate = new VirtualDelegate(this.markersViewModel);
J
Joao Moreno 已提交
394
		const renderers = [
395
			this.instantiationService.createInstance(ResourceMarkersRenderer, treeLabels, onDidChangeRenderNodeCount.event),
S
Sandeep Somavarapu 已提交
396
			this.instantiationService.createInstance(MarkerRenderer, this.markersViewModel),
J
Joao Moreno 已提交
397
			this.instantiationService.createInstance(RelatedInformationRenderer)
J
Joao Moreno 已提交
398
		];
399
		const accessibilityProvider = this.instantiationService.createInstance(MarkersTreeAccessibilityProvider);
J
Joao Moreno 已提交
400

J
Joao Moreno 已提交
401 402
		const identityProvider = {
			getId(element: TreeElement) {
403
				return element.id;
J
Joao Moreno 已提交
404 405 406
			}
		};

S
Sandeep Somavarapu 已提交
407
		this.tree = this._register(this.instantiationService.createInstance(MarkersTree,
S
Sandeep Somavarapu 已提交
408
			'MarkersView',
S
Sandeep Somavarapu 已提交
409
			dom.append(parent, dom.$('.tree-container.show-file-icons')),
J
Joao Moreno 已提交
410
			virtualDelegate,
411
			renderers,
J
Joao Moreno 已提交
412
			{
413
				filter: this.filter,
J
Joao Moreno 已提交
414
				accessibilityProvider,
S
Sandeep Somavarapu 已提交
415
				identityProvider,
S
Sandeep Somavarapu 已提交
416
				dnd: new ResourceDragAndDrop(this.instantiationService),
S
Sandeep Somavarapu 已提交
417 418
				expandOnlyOnTwistieClick: (e: TreeElement) => e instanceof Marker && e.relatedInformation.length > 0,
				overrideStyles: {
419
					listBackground: this.getBackgroundColor()
S
Sandeep Somavarapu 已提交
420 421
				}
			},
S
Sandeep Somavarapu 已提交
422
		));
J
Joao Moreno 已提交
423

J
Joao Moreno 已提交
424 425
		onDidChangeRenderNodeCount.input = this.tree.onDidChangeRenderNodeCount;

426 427 428
		const markerFocusContextKey = Constants.MarkerFocusContextKey.bindTo(this.tree.contextKeyService);
		const relatedInformationFocusContextKey = Constants.RelatedInformationFocusContextKey.bindTo(this.tree.contextKeyService);
		this._register(this.tree.onDidChangeFocus(focus => {
429 430
			markerFocusContextKey.set(focus.elements.some(e => e instanceof Marker));
			relatedInformationFocusContextKey.set(focus.elements.some(e => e instanceof RelatedInformation));
431
		}));
J
Joao Moreno 已提交
432

J
João Moreno 已提交
433
		const markersNavigator = this._register(new TreeResourceNavigator(this.tree, { openOnFocus: true }));
J
Joao Moreno 已提交
434
		this._register(Event.debounce(markersNavigator.onDidOpenResource, (last, event) => event, 75, true)(options => {
435
			this.openFileAtElement(options.element, !!options.editorOptions.preserveFocus, options.sideBySide, !!options.editorOptions.pinned);
436
		}));
437 438 439 440 441 442 443 444 445 446 447 448
		this._register(this.tree.onDidChangeCollapseState(({ node }) => {
			const { element } = node;
			if (element instanceof RelatedInformation && !node.collapsed) {
				/* __GDPR__
				"problems.expandRelatedInformation" : {
					"source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
					"code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }
				}
				*/
				this.telemetryService.publicLog('problems.expandRelatedInformation', this.getTelemetryData(element.marker));
			}
		}));
J
Joao Moreno 已提交
449

M
Matt Bierner 已提交
450
		this._register(this.tree.onContextMenu(this.onContextMenu, this));
J
Joao Moreno 已提交
451 452

		this._register(this.configurationService.onDidChangeConfiguration(e => {
453
			if (this.filters.excludedFiles && e.affectsConfiguration('files.exclude')) {
J
Joao Moreno 已提交
454 455 456
				this.updateFilter();
			}
		}));
457 458

		// move focus to input, whenever a key is pressed in the panel container
J
Joao Moreno 已提交
459
		this._register(domEvent(parent, 'keydown')(e => {
S
Sandeep Somavarapu 已提交
460
			if (this.keybindingService.mightProducePrintableCharacter(new StandardKeyboardEvent(e))) {
461
				this.focusFilter();
462 463
			}
		}));
S
Sandeep Somavarapu 已提交
464 465

		this._register(Event.any<any>(this.tree.onDidChangeSelection, this.tree.onDidChangeFocus)(() => {
S
Sandeep Somavarapu 已提交
466
			const elements = [...this.tree!.getSelection(), ...this.tree!.getFocus()];
S
Sandeep Somavarapu 已提交
467 468 469 470 471 472 473 474 475
			for (const element of elements) {
				if (element instanceof Marker) {
					const viewModel = this.markersViewModel.getViewModel(element);
					if (viewModel) {
						viewModel.showLightBulb();
					}
				}
			}
		}));
S
Sandeep Somavarapu 已提交
476 477
	}

478
	private collapseAll(): void {
S
Sandeep Somavarapu 已提交
479 480 481 482 483 484 485
		if (this.tree) {
			this.tree.collapseAll();
			this.tree.setSelection([]);
			this.tree.setFocus([]);
			this.tree.getHTMLElement().focus();
			this.tree.focusFirst();
		}
S
Sandeep Somavarapu 已提交
486 487
	}

488
	private createListeners(): void {
489 490 491
		this._register(Event.any<MarkerChangesEvent | void>(this.markersWorkbenchService.markersModel.onDidChange, this.editorService.onDidActiveEditorChange)(changes => {
			if (changes) {
				this.onDidChangeModel(changes);
S
Sandeep Somavarapu 已提交
492 493 494
			} else {
				this.onActiveEditorChanged();
			}
495
		}));
S
Sandeep Somavarapu 已提交
496 497 498
		if (this.tree) {
			this._register(this.tree.onDidChangeSelection(() => this.onSelected()));
		}
499
		this._register(this.filters.onDidChange((event: IMarkersFiltersChangeEvent) => {
S
Sandeep Somavarapu 已提交
500
			this.reportFilteringUsed();
S
Sandeep Somavarapu 已提交
501 502 503
			if (event.activeFile) {
				this.refreshPanel();
			} else if (event.filterText || event.excludedFiles || event.showWarnings || event.showErrors || event.showInfos) {
J
Joao Moreno 已提交
504 505 506
				this.updateFilter();
			}
		}));
507 508
	}

509 510 511 512
	private onDidChangeModel(change: MarkerChangesEvent) {
		const resourceMarkers = [...change.added, ...change.removed, ...change.updated];
		const resources: URI[] = [];
		for (const { resource } of resourceMarkers) {
S
Sandeep Somavarapu 已提交
513
			this.markersViewModel.remove(resource);
S
#1927  
Sandeep Somavarapu 已提交
514 515 516
			const resourceMarkers = this.markersWorkbenchService.markersModel.getResourceMarkers(resource);
			if (resourceMarkers) {
				for (const marker of resourceMarkers.markers) {
S
Sandeep Somavarapu 已提交
517
					this.markersViewModel.add(marker);
S
#1927  
Sandeep Somavarapu 已提交
518 519
				}
			}
520
			resources.push(resource);
S
#1927  
Sandeep Somavarapu 已提交
521
		}
S
Sandeep Somavarapu 已提交
522
		this.currentResourceGotAddedToMarkersData = this.currentResourceGotAddedToMarkersData || this.isCurrentResourceGotAddedToMarkersData(resources);
523
		this.refreshPanel(change);
J
Joao Moreno 已提交
524 525 526 527 528
		this.updateRangeHighlights();
		if (this.currentResourceGotAddedToMarkersData) {
			this.autoReveal();
			this.currentResourceGotAddedToMarkersData = false;
		}
S
Sandeep Somavarapu 已提交
529 530
	}

531
	private isCurrentResourceGotAddedToMarkersData(changedResources: URI[]) {
M
Matt Bierner 已提交
532 533
		const currentlyActiveResource = this.currentActiveResource;
		if (!currentlyActiveResource) {
S
Sandeep Somavarapu 已提交
534 535
			return false;
		}
536 537
		const resourceForCurrentActiveResource = this.getResourceForCurrentActiveResource();
		if (resourceForCurrentActiveResource) {
S
Sandeep Somavarapu 已提交
538 539
			return false;
		}
M
Matt Bierner 已提交
540
		return changedResources.some(r => r.toString() === currentlyActiveResource.toString());
S
Sandeep Somavarapu 已提交
541 542
	}

B
Benjamin Pasero 已提交
543
	private onActiveEditorChanged(): void {
S
Sandeep Somavarapu 已提交
544
		this.setCurrentActiveEditor();
545
		if (this.filters.activeFile) {
S
Sandeep Somavarapu 已提交
546 547
			this.refreshPanel();
		}
S
Sandeep Somavarapu 已提交
548
		this.autoReveal();
S
Sandeep Somavarapu 已提交
549 550 551
	}

	private setCurrentActiveEditor(): void {
B
Benjamin Pasero 已提交
552
		const activeEditor = this.editorService.activeEditor;
553
		this.currentActiveResource = activeEditor ? withUndefinedAsNull(activeEditor.resource) : null;
S
Sandeep Somavarapu 已提交
554 555
	}

556
	private onSelected(): void {
S
Sandeep Somavarapu 已提交
557 558 559 560 561
		if (this.tree) {
			let selection = this.tree.getSelection();
			if (selection && selection.length > 0) {
				this.lastSelectedRelativeTop = this.tree!.getRelativeTop(selection[0]) || 0;
			}
562 563 564
		}
	}

J
Joao Moreno 已提交
565
	private hasNoProblems(): boolean {
S
Sandeep Somavarapu 已提交
566 567 568 569
		const { total, filtered } = this.getFilterStats();
		return total === 0 || filtered === 0;
	}

570
	private renderContent(): void {
J
Joao Moreno 已提交
571
		this.cachedFilterStats = undefined;
S
Sandeep Somavarapu 已提交
572
		this.resetTree();
S
Sandeep Somavarapu 已提交
573
		if (this.tree) {
J
Joao Moreno 已提交
574
			this.tree.toggleVisibility(this.hasNoProblems());
S
Sandeep Somavarapu 已提交
575
		}
S
Sandeep Somavarapu 已提交
576
		this.renderMessage();
S
Sandeep Somavarapu 已提交
577 578
	}

S
Sandeep Somavarapu 已提交
579
	private renderMessage(): void {
S
Sandeep Somavarapu 已提交
580 581 582
		if (!this.messageBoxContainer || !this.ariaLabelElement) {
			return;
		}
583
		dom.clearNode(this.messageBoxContainer);
J
Joao Moreno 已提交
584
		const { total, filtered } = this.getFilterStats();
J
Joao Moreno 已提交
585 586 587 588

		if (filtered === 0) {
			this.messageBoxContainer.style.display = 'block';
			this.messageBoxContainer.setAttribute('tabIndex', '0');
589
			if (this.filters.activeFile) {
S
Sandeep Somavarapu 已提交
590
				this.renderFilterMessageForActiveFile(this.messageBoxContainer);
J
Joao Moreno 已提交
591
			} else {
S
Sandeep Somavarapu 已提交
592 593 594 595 596
				if (total > 0) {
					this.renderFilteredByFilterMessage(this.messageBoxContainer);
				} else {
					this.renderNoProblemsMessage(this.messageBoxContainer);
				}
J
Joao Moreno 已提交
597
			}
S
Sandeep Somavarapu 已提交
598
		} else {
J
Joao Moreno 已提交
599 600 601 602 603 604 605
			this.messageBoxContainer.style.display = 'none';
			if (filtered === total) {
				this.ariaLabelElement.setAttribute('aria-label', localize('No problems filtered', "Showing {0} problems", total));
			} else {
				this.ariaLabelElement.setAttribute('aria-label', localize('problems filtered', "Showing {0} of {1} problems", filtered, total));
			}
			this.messageBoxContainer.removeAttribute('tabIndex');
S
Sandeep Somavarapu 已提交
606
		}
607 608
	}

S
Sandeep Somavarapu 已提交
609 610 611 612 613 614 615 616
	private renderFilterMessageForActiveFile(container: HTMLElement): void {
		if (this.currentActiveResource && this.markersWorkbenchService.markersModel.getResourceMarkers(this.currentActiveResource)) {
			this.renderFilteredByFilterMessage(container);
		} else {
			this.renderNoProblemsMessageForActiveFile(container);
		}
	}

J
Joao Moreno 已提交
617 618 619
	private renderFilteredByFilterMessage(container: HTMLElement) {
		const span1 = dom.append(container, dom.$('span'));
		span1.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_FILTERS;
S
Sandeep Somavarapu 已提交
620 621 622 623 624 625 626 627 628 629 630 631
		const link = dom.append(container, dom.$('a.messageAction'));
		link.textContent = localize('clearFilter', "Clear Filters");
		link.setAttribute('tabIndex', '0');
		const span2 = dom.append(container, dom.$('span'));
		span2.textContent = '.';
		dom.addStandardDisposableListener(link, dom.EventType.CLICK, () => this.clearFilters());
		dom.addStandardDisposableListener(link, dom.EventType.KEY_DOWN, (e: IKeyboardEvent) => {
			if (e.equals(KeyCode.Enter) || e.equals(KeyCode.Space)) {
				this.clearFilters();
				e.stopPropagation();
			}
		});
S
Sandeep Somavarapu 已提交
632
		this.ariaLabelElement!.setAttribute('aria-label', Messages.MARKERS_PANEL_NO_PROBLEMS_FILTERS);
J
Joao Moreno 已提交
633 634
	}

S
Sandeep Somavarapu 已提交
635 636 637
	private renderNoProblemsMessageForActiveFile(container: HTMLElement) {
		const span = dom.append(container, dom.$('span'));
		span.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_ACTIVE_FILE_BUILT;
S
Sandeep Somavarapu 已提交
638
		this.ariaLabelElement!.setAttribute('aria-label', Messages.MARKERS_PANEL_NO_PROBLEMS_ACTIVE_FILE_BUILT);
S
Sandeep Somavarapu 已提交
639 640
	}

J
Joao Moreno 已提交
641 642 643
	private renderNoProblemsMessage(container: HTMLElement) {
		const span = dom.append(container, dom.$('span'));
		span.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_BUILT;
S
Sandeep Somavarapu 已提交
644
		this.ariaLabelElement!.setAttribute('aria-label', Messages.MARKERS_PANEL_NO_PROBLEMS_BUILT);
J
Joao Moreno 已提交
645
	}
S
Sandeep Somavarapu 已提交
646

S
Sandeep Somavarapu 已提交
647
	private clearFilters(): void {
648 649 650 651 652
		this.filters.filterText = '';
		this.filters.excludedFiles = false;
		this.filters.showErrors = true;
		this.filters.showWarnings = true;
		this.filters.showInfos = true;
S
Sandeep Somavarapu 已提交
653 654
	}

S
Sandeep Somavarapu 已提交
655
	private autoReveal(focus: boolean = false): void {
S
Sandeep Somavarapu 已提交
656
		// No need to auto reveal if active file filter is on
657
		if (this.filters.activeFile || !this.tree) {
S
Sandeep Somavarapu 已提交
658 659
			return;
		}
660 661
		let autoReveal = this.configurationService.getValue<boolean>('problems.autoReveal');
		if (typeof autoReveal === 'boolean' && autoReveal) {
S
Sandeep Somavarapu 已提交
662 663 664 665 666 667 668 669 670 671
			let currentActiveResource = this.getResourceForCurrentActiveResource();
			if (currentActiveResource) {
				if (!this.tree.isCollapsed(currentActiveResource) && this.hasSelectedMarkerFor(currentActiveResource)) {
					this.tree.reveal(this.tree.getSelection()[0], this.lastSelectedRelativeTop);
					if (focus) {
						this.tree.setFocus(this.tree.getSelection());
					}
				} else {
					this.tree.expand(currentActiveResource);
					this.tree.reveal(currentActiveResource, 0);
J
Joao Moreno 已提交
672

S
Sandeep Somavarapu 已提交
673 674 675 676
					if (focus) {
						this.tree.setFocus([currentActiveResource]);
						this.tree.setSelection([currentActiveResource]);
					}
J
Joao Moreno 已提交
677
				}
S
Sandeep Somavarapu 已提交
678 679 680
			} else if (focus) {
				this.tree.setSelection([]);
				this.tree.focusFirst();
681 682 683 684
			}
		}
	}

685
	private getResourceForCurrentActiveResource(): ResourceMarkers | null {
J
Joao Moreno 已提交
686
		return this.currentActiveResource ? this.markersWorkbenchService.markersModel.getResourceMarkers(this.currentActiveResource) : null;
S
Sandeep Somavarapu 已提交
687 688
	}

689
	private hasSelectedMarkerFor(resource: ResourceMarkers): boolean {
S
Sandeep Somavarapu 已提交
690 691 692 693 694 695 696
		if (this.tree) {
			let selectedElement = this.tree.getSelection();
			if (selectedElement && selectedElement.length > 0) {
				if (selectedElement[0] instanceof Marker) {
					if (resource.resource.toString() === (<Marker>selectedElement[0]).marker.resource.toString()) {
						return true;
					}
S
Sandeep Somavarapu 已提交
697 698 699 700 701 702
				}
			}
		}
		return false;
	}

S
Sandeep Somavarapu 已提交
703
	private updateRangeHighlights() {
704
		this.rangeHighlightDecorations.removeHighlightRange();
S
Sandeep Somavarapu 已提交
705
		if (this.tree && this.tree.getHTMLElement() === document.activeElement) {
S
Sandeep Somavarapu 已提交
706 707 708 709 710
			this.highlightCurrentSelectedMarkerRange();
		}
	}

	private highlightCurrentSelectedMarkerRange() {
S
Sandeep Somavarapu 已提交
711
		const selections = this.tree ? this.tree.getSelection() : [];
J
Joao Moreno 已提交
712 713 714

		if (selections.length !== 1) {
			return;
S
Sandeep Somavarapu 已提交
715
		}
J
Joao Moreno 已提交
716 717 718 719 720 721 722 723

		const selection = selections[0];

		if (!(selection instanceof Marker)) {
			return;
		}

		this.rangeHighlightDecorations.highlightRange(selection);
S
Sandeep Somavarapu 已提交
724 725
	}

726
	private onContextMenu(e: ITreeContextMenuEvent<TreeElement | null>): void {
M
Matt Bierner 已提交
727 728
		const element = e.element;
		if (!element) {
J
Joao Moreno 已提交
729 730 731 732 733 734
			return;
		}

		e.browserEvent.preventDefault();
		e.browserEvent.stopPropagation();

S
Sandeep Somavarapu 已提交
735
		this.contextMenuService.showContextMenu({
M
Matt Bierner 已提交
736 737
			getAnchor: () => e.anchor!,
			getActions: () => this.getMenuActions(element),
738
			getActionViewItem: (action) => {
S
Sandeep Somavarapu 已提交
739 740
				const keybinding = this.keybindingService.lookupKeybinding(action.id);
				if (keybinding) {
741
					return new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel() });
J
Joao Moreno 已提交
742
				}
743
				return undefined;
S
Sandeep Somavarapu 已提交
744 745 746
			},
			onHide: (wasCancelled?: boolean) => {
				if (wasCancelled) {
S
Sandeep Somavarapu 已提交
747
					this.tree!.domFocus();
S
Sandeep Somavarapu 已提交
748 749
				}
			}
J
Joao Moreno 已提交
750 751 752
		});
	}

S
Sandeep Somavarapu 已提交
753
	private getMenuActions(element: TreeElement): IAction[] {
J
Joao Moreno 已提交
754 755 756
		const result: IAction[] = [];

		if (element instanceof Marker) {
S
Sandeep Somavarapu 已提交
757 758 759 760 761 762 763
			const viewModel = this.markersViewModel.getViewModel(element);
			if (viewModel) {
				const quickFixActions = viewModel.quickFixAction.quickFixes;
				if (quickFixActions.length) {
					result.push(...quickFixActions);
					result.push(new Separator());
				}
J
Joao Moreno 已提交
764 765 766
			}
		}

S
Sandeep Somavarapu 已提交
767
		const menu = this.menuService.createMenu(MenuId.ProblemsPanelContext, this.tree!.contextKeyService);
J
Joao Moreno 已提交
768 769 770 771 772 773 774 775 776 777 778 779 780
		const groups = menu.getActions();
		menu.dispose();

		for (let group of groups) {
			const [, actions] = group;
			result.push(...actions);
			result.push(new Separator());
		}

		result.pop(); // remove last separator
		return result;
	}

M
Matt Bierner 已提交
781
	public getFocusElement() {
S
Sandeep Somavarapu 已提交
782
		return this.tree ? this.tree.getFocus()[0] : undefined;
S
Sandeep Somavarapu 已提交
783 784
	}

785
	public getActionViewItem(action: IAction): IActionViewItem | undefined {
786 787
		if (action.id === `workbench.actions.treeView.${this.id}.filter`) {
			return this.instantiationService.createInstance(MarkersFilterActionViewItem, action, this);
788
		}
789
		return super.getActionViewItem(action);
S
Sandeep Somavarapu 已提交
790 791
	}

J
Joao Moreno 已提交
792 793 794 795 796 797 798 799 800 801
	getFilterStats(): { total: number; filtered: number; } {
		if (!this.cachedFilterStats) {
			this.cachedFilterStats = this.computeFilterStats();
		}

		return this.cachedFilterStats;
	}

	private computeFilterStats(): { total: number; filtered: number; } {
		let filtered = 0;
S
Sandeep Somavarapu 已提交
802 803
		if (this.tree) {
			const root = this.tree.getNode();
J
Joao Moreno 已提交
804

S
Sandeep Somavarapu 已提交
805 806 807 808 809
			for (const resourceMarkerNode of root.children) {
				for (const markerNode of resourceMarkerNode.children) {
					if (resourceMarkerNode.visible && markerNode.visible) {
						filtered++;
					}
J
Joao Moreno 已提交
810 811 812 813
				}
			}
		}

S
Sandeep Somavarapu 已提交
814
		return { total: this.markersWorkbenchService.markersModel.total, filtered };
J
Joao Moreno 已提交
815 816
	}

817 818 819 820
	private getTelemetryData({ source, code }: IMarker): any {
		return { source, code };
	}

S
Sandeep Somavarapu 已提交
821 822
	private reportFilteringUsed(): void {
		const data = {
823 824 825 826 827
			errors: this.filters.showErrors,
			warnings: this.filters.showWarnings,
			infos: this.filters.showInfos,
			activeFile: this.filters.activeFile,
			excludedFiles: this.filters.excludedFiles,
S
Sandeep Somavarapu 已提交
828 829 830 831 832 833 834 835 836 837 838 839 840
		};
		/* __GDPR__
			"problems.filter" : {
				"errors" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
				"warnings": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
				"infos": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
				"activeFile": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
				"excludedFiles": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
			}
		*/
		this.telemetryService.publicLog('problems.filter', data);
	}

841
	saveState(): void {
842 843 844 845 846 847 848
		this.panelState['filter'] = this.filters.filterText;
		this.panelState['filterHistory'] = this.filters.filterHistory;
		this.panelState['showErrors'] = this.filters.showErrors;
		this.panelState['showWarnings'] = this.filters.showWarnings;
		this.panelState['showInfos'] = this.filters.showInfos;
		this.panelState['useFilesExclude'] = this.filters.excludedFiles;
		this.panelState['activeFile'] = this.filters.activeFile;
S
Sandeep Somavarapu 已提交
849
		this.panelState['multiline'] = this.markersViewModel.multiline;
S
Sandeep Somavarapu 已提交
850

B
Benjamin Pasero 已提交
851
		super.saveState();
852 853
	}

I
isidor 已提交
854
}
S
Sandeep Somavarapu 已提交
855 856 857 858 859 860 861 862

class MarkersTree extends WorkbenchObjectTree<TreeElement, FilterData> {

	constructor(
		user: string,
		readonly container: HTMLElement,
		delegate: IListVirtualDelegate<TreeElement>,
		renderers: ITreeRenderer<TreeElement, FilterData, any>[],
S
Sandeep Somavarapu 已提交
863
		options: IWorkbenchObjectTreeOptions<TreeElement, FilterData>,
S
Sandeep Somavarapu 已提交
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883
		@IContextKeyService contextKeyService: IContextKeyService,
		@IListService listService: IListService,
		@IThemeService themeService: IThemeService,
		@IConfigurationService configurationService: IConfigurationService,
		@IKeybindingService keybindingService: IKeybindingService,
		@IAccessibilityService accessibilityService: IAccessibilityService
	) {
		super(user, container, delegate, renderers, options, contextKeyService, listService, themeService, configurationService, keybindingService, accessibilityService);
	}

	layout(height: number, width: number): void {
		this.container.style.height = `${height}px`;
		super.layout(height, width);
	}

	toggleVisibility(hide: boolean): void {
		dom.toggleClass(this.container, 'hidden', hide);
	}

}
884

M
Martin Aeschlimann 已提交
885
registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => {
886 887 888 889 890

	// Lightbulb Icon
	const editorLightBulbForegroundColor = theme.getColor(editorLightBulbForeground);
	if (editorLightBulbForegroundColor) {
		collector.addRule(`
M
Martin Aeschlimann 已提交
891
		.monaco-workbench .markers-panel-container ${Codicon.lightBulb.cssSelector} {
892 893 894 895 896 897 898 899
			color: ${editorLightBulbForegroundColor};
		}`);
	}

	// Lightbulb Auto Fix Icon
	const editorLightBulbAutoFixForegroundColor = theme.getColor(editorLightBulbAutoFixForeground);
	if (editorLightBulbAutoFixForegroundColor) {
		collector.addRule(`
M
Martin Aeschlimann 已提交
900
		.monaco-workbench .markers-panel-container ${Codicon.lightbulbAutofix.cssSelector} {
901 902 903 904 905
			color: ${editorLightBulbAutoFixForegroundColor};
		}`);
	}

});