markersView.ts 34.5 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';
J
João Moreno 已提交
10
import { IAction, IActionViewItem, Action, Separator } 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';
29
import { WorkbenchObjectTree, 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';
J
João Moreno 已提交
36
import { 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);
J
jeanp413 已提交
117

S
Sandeep Somavarapu 已提交
118
		this.markersViewModel = this._register(instantiationService.createInstance(MarkersViewModel, this.panelState['multiline']));
S
Sandeep Somavarapu 已提交
119 120
		for (const resourceMarker of this.markersWorkbenchService.markersModel.resourceMarkers) {
			resourceMarker.markers.forEach(marker => this.markersViewModel.add(marker));
J
jeanp413 已提交
121
		}
S
Sandeep Somavarapu 已提交
122
		this._register(this.markersViewModel.onDidChange(marker => this.onDidChangeViewState(marker)));
J
jeanp413 已提交
123

S
Sandeep Somavarapu 已提交
124
		this.setCurrentActiveEditor();
125 126 127 128 129

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

		// actions
130 131
		this.regiserActions();
		this.filters = this._register(new MarkersFilters({
132 133 134 135 136
			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 已提交
137
			excludedFiles: !!this.panelState['useFilesExclude'],
138 139
			activeFile: !!this.panelState['activeFile'],
			layout: new dom.Dimension(0, 0)
140
		}));
141 142
	}

143
	public renderBody(parent: HTMLElement): void {
J
Joao Moreno 已提交
144
		super.renderBody(parent);
S
Sandeep Somavarapu 已提交
145

146
		dom.addClass(parent, 'markers-panel');
147

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

S
Sandeep Somavarapu 已提交
150
		this.createFilterActionBar(container);
S
Sandeep Somavarapu 已提交
151
		this.createArialLabelElement(container);
152
		this.createMessageBox(container);
S
Sandeep Somavarapu 已提交
153
		this.createTree(container);
154
		this.createListeners();
155

J
Joao Moreno 已提交
156
		this.updateFilter();
S
Sandeep Somavarapu 已提交
157

158 159 160 161 162 163 164
		this._register(this.onDidChangeVisibility(visible => {
			if (visible) {
				this.refreshPanel();
			} else {
				this.rangeHighlightDecorations.removeHighlightRange();
			}
		}));
S
Sandeep Somavarapu 已提交
165

166
		this.filterActionBar!.push(new Action(`workbench.actions.treeView.${this.id}.filter`));
167
		this.renderContent();
168 169
	}

S
Sandeep Somavarapu 已提交
170
	public getTitle(): string {
B
Benjamin Pasero 已提交
171
		return Messages.MARKERS_PANEL_TITLE_PROBLEMS;
S
Sandeep Somavarapu 已提交
172 173
	}

174
	public layoutBody(height: number, width: number): void {
J
João Moreno 已提交
175
		super.layoutBody(height, width);
176 177 178
		const wasSmallLayout = this.smallLayout;
		this.smallLayout = width < 600 && height > 100;
		if (this.smallLayout !== wasSmallLayout) {
S
Sandeep Somavarapu 已提交
179
			if (this.filterActionBar) {
180
				dom.toggleClass(this.filterActionBar.getContainer(), 'hide', !this.smallLayout);
S
Sandeep Somavarapu 已提交
181
			}
S
Sandeep Somavarapu 已提交
182
		}
183
		const contentHeight = this.smallLayout ? height - 44 : height;
S
Sandeep Somavarapu 已提交
184 185 186 187 188 189
		if (this.tree) {
			this.tree.layout(contentHeight, width);
		}
		if (this.messageBoxContainer) {
			this.messageBoxContainer.style.height = `${contentHeight}px`;
		}
190
		this.filters.layout = new dom.Dimension(this.smallLayout ? width : width - 200, height);
191 192
	}

S
Sandeep Somavarapu 已提交
193
	public focus(): void {
S
Sandeep Somavarapu 已提交
194
		if (this.tree && this.tree.getHTMLElement() === document.activeElement) {
195 196 197
			return;
		}

J
Joao Moreno 已提交
198
		if (this.hasNoProblems() && this.messageBoxContainer) {
S
Sandeep Somavarapu 已提交
199
			this.messageBoxContainer.focus();
S
Sandeep Somavarapu 已提交
200
		} else if (this.tree) {
S
Sandeep Somavarapu 已提交
201 202
			this.tree.domFocus();
			this.setTreeSelection();
S
Sandeep Somavarapu 已提交
203
		}
S
Sandeep Somavarapu 已提交
204 205
	}

S
Sandeep Somavarapu 已提交
206
	public focusFilter(): void {
207 208 209
		this._onDidFocusFilter.fire();
	}

S
Sandeep Somavarapu 已提交
210 211 212 213
	public clearFilterText(): void {
		this._onDidClearFilterText.fire();
	}

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 242 243 244 245 246 247 248
	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 已提交
249 250
	}

S
Sandeep Somavarapu 已提交
251 252 253 254 255 256 257
	public showQuickFixes(marker: Marker): void {
		const viewModel = this.markersViewModel.getViewModel(marker);
		if (viewModel) {
			viewModel.quickFixAction.run();
		}
	}

S
Sandeep Somavarapu 已提交
258
	public openFileAtElement(element: any, preserveFocus: boolean, sideByside: boolean, pinned: boolean): boolean {
259 260
		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 已提交
261
		if (resource && selection && event) {
262 263 264 265 266 267 268 269 270 271 272 273 274
			/* __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 已提交
275
			this.editorService.openEditor({
276
				resource,
S
Sandeep Somavarapu 已提交
277
				options: {
278
					selection,
S
Sandeep Somavarapu 已提交
279 280
					preserveFocus,
					pinned,
281
					revealIfVisible: true
S
Sandeep Somavarapu 已提交
282
				},
283
			}, sideByside ? SIDE_GROUP : ACTIVE_GROUP).then(editor => {
S
Sandeep Somavarapu 已提交
284
				if (editor && preserveFocus) {
285
					this.rangeHighlightDecorations.highlightRange({ resource, range: selection }, <ICodeEditor>editor.getControl());
S
Sandeep Somavarapu 已提交
286 287 288
				} else {
					this.rangeHighlightDecorations.removeHighlightRange();
				}
289
			});
S
Sandeep Somavarapu 已提交
290 291 292 293 294 295 296
			return true;
		} else {
			this.rangeHighlightDecorations.removeHighlightRange();
		}
		return false;
	}

297
	private refreshPanel(markerOrChange?: Marker | MarkerChangesEvent): void {
S
Sandeep Somavarapu 已提交
298
		if (this.isVisible() && this.tree) {
S
Sandeep Somavarapu 已提交
299
			const hasSelection = this.tree.getSelection().length > 0;
J
Joao Moreno 已提交
300
			this.cachedFilterStats = undefined;
301

302 303 304 305
			if (markerOrChange) {
				if (markerOrChange instanceof Marker) {
					this.tree.rerender(markerOrChange);
				} else {
306
					if (markerOrChange.added.size || markerOrChange.removed.size) {
307
						// Reset complete tree
S
Sandeep Somavarapu 已提交
308
						this.resetTree();
309 310 311 312
					} else {
						// Update resource
						for (const updated of markerOrChange.updated) {
							this.tree.setChildren(updated, createResourceMarkersIterator(updated));
313
							this.tree.rerender(updated);
314 315 316
						}
					}
				}
317
			} else {
318
				// Reset complete tree
S
Sandeep Somavarapu 已提交
319
				this.resetTree();
320
			}
J
Joao Moreno 已提交
321 322

			const { total, filtered } = this.getFilterStats();
S
Sandeep Somavarapu 已提交
323
			this.tree.toggleVisibility(total === 0 || filtered === 0);
J
Joao Moreno 已提交
324
			this.renderMessage();
325
			this._onDidChangeFilterStats.fire(this.getFilterStats());
S
Sandeep Somavarapu 已提交
326 327 328 329 330 331 332 333 334 335 336 337 338 339

			if (hasSelection) {
				this.setTreeSelection();
			}
		}
	}

	private setTreeSelection(): void {
		if (this.tree && this.tree.getSelection().length === 0) {
			const firstMarker = this.markersWorkbenchService.markersModel.resourceMarkers[0].markers[0];
			if (firstMarker) {
				this.tree.setFocus([firstMarker]);
				this.tree.setSelection([firstMarker]);
			}
S
Sandeep Somavarapu 已提交
340
		}
341 342
	}

S
#1927  
Sandeep Somavarapu 已提交
343
	private onDidChangeViewState(marker?: Marker): void {
344
		this.refreshPanel(marker);
S
#1927  
Sandeep Somavarapu 已提交
345 346
	}

S
Sandeep Somavarapu 已提交
347
	private resetTree(): void {
S
Sandeep Somavarapu 已提交
348 349 350
		if (!this.tree) {
			return;
		}
S
Sandeep Somavarapu 已提交
351
		let resourceMarkers: ResourceMarkers[] = [];
352
		if (this.filters.activeFile) {
S
Sandeep Somavarapu 已提交
353 354 355 356 357 358 359 360 361
			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 已提交
362
		this.tree.setChildren(null, Iterable.map(resourceMarkers, m => ({ element: m, children: createResourceMarkersIterator(m) })));
S
Sandeep Somavarapu 已提交
363 364
	}

J
Joao Moreno 已提交
365
	private updateFilter() {
J
Joao Moreno 已提交
366
		this.cachedFilterStats = undefined;
367
		this.filter.options = new FilterOptions(this.filters.filterText, this.getFilesExcludeExpressions(), this.filters.showWarnings, this.filters.showErrors, this.filters.showInfos);
S
Sandeep Somavarapu 已提交
368 369 370
		if (this.tree) {
			this.tree.refilter();
		}
371
		this._onDidChangeFilterStats.fire(this.getFilterStats());
S
Sandeep Somavarapu 已提交
372 373

		const { total, filtered } = this.getFilterStats();
S
Sandeep Somavarapu 已提交
374 375 376
		if (this.tree) {
			this.tree.toggleVisibility(total === 0 || filtered === 0);
		}
J
Joao Moreno 已提交
377
		this.renderMessage();
J
Joao Moreno 已提交
378 379
	}

380
	private getFilesExcludeExpressions(): { root: URI, expression: IExpression }[] | IExpression {
381
		if (!this.filters.excludedFiles) {
382
			return [];
J
Joao Moreno 已提交
383 384 385
		}

		const workspaceFolders = this.workspaceContextService.getWorkspace().folders;
386 387 388
		return workspaceFolders.length
			? workspaceFolders.map(workspaceFolder => ({ root: workspaceFolder.uri, expression: this.getFilesExclude(workspaceFolder.uri) }))
			: this.getFilesExclude();
J
Joao Moreno 已提交
389 390 391 392 393 394
	}

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

S
Sandeep Somavarapu 已提交
395 396 397
	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');
398
		dom.toggleClass(this.filterActionBar.getContainer(), 'hide', !this.smallLayout);
S
Sandeep Somavarapu 已提交
399 400
	}

S
Sandeep Somavarapu 已提交
401
	private createMessageBox(parent: HTMLElement): void {
J
Joao Moreno 已提交
402
		this.messageBoxContainer = dom.append(parent, dom.$('.message-box-container'));
S
Sandeep Somavarapu 已提交
403 404 405 406 407 408
		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 已提交
409 410
	}

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

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

S
Sandeep Somavarapu 已提交
416
		const virtualDelegate = new VirtualDelegate(this.markersViewModel);
J
Joao Moreno 已提交
417
		const renderers = [
418
			this.instantiationService.createInstance(ResourceMarkersRenderer, treeLabels, onDidChangeRenderNodeCount.event),
S
Sandeep Somavarapu 已提交
419
			this.instantiationService.createInstance(MarkerRenderer, this.markersViewModel),
J
Joao Moreno 已提交
420
			this.instantiationService.createInstance(RelatedInformationRenderer)
J
Joao Moreno 已提交
421
		];
422
		const accessibilityProvider = this.instantiationService.createInstance(MarkersTreeAccessibilityProvider);
J
Joao Moreno 已提交
423

J
Joao Moreno 已提交
424 425
		const identityProvider = {
			getId(element: TreeElement) {
426
				return element.id;
J
Joao Moreno 已提交
427 428 429
			}
		};

S
Sandeep Somavarapu 已提交
430
		this.tree = this._register(this.instantiationService.createInstance(MarkersTree,
S
Sandeep Somavarapu 已提交
431
			'MarkersView',
S
Sandeep Somavarapu 已提交
432
			dom.append(parent, dom.$('.tree-container.show-file-icons')),
J
Joao Moreno 已提交
433
			virtualDelegate,
434
			renderers,
J
Joao Moreno 已提交
435
			{
436
				filter: this.filter,
J
Joao Moreno 已提交
437
				accessibilityProvider,
S
Sandeep Somavarapu 已提交
438
				identityProvider,
S
Sandeep Somavarapu 已提交
439
				dnd: new ResourceDragAndDrop(this.instantiationService),
S
Sandeep Somavarapu 已提交
440 441
				expandOnlyOnTwistieClick: (e: TreeElement) => e instanceof Marker && e.relatedInformation.length > 0,
				overrideStyles: {
442
					listBackground: this.getBackgroundColor()
443 444
				},
				openOnFocus: true
S
Sandeep Somavarapu 已提交
445
			},
S
Sandeep Somavarapu 已提交
446
		));
J
Joao Moreno 已提交
447

J
Joao Moreno 已提交
448 449
		onDidChangeRenderNodeCount.input = this.tree.onDidChangeRenderNodeCount;

450 451 452
		const markerFocusContextKey = Constants.MarkerFocusContextKey.bindTo(this.tree.contextKeyService);
		const relatedInformationFocusContextKey = Constants.RelatedInformationFocusContextKey.bindTo(this.tree.contextKeyService);
		this._register(this.tree.onDidChangeFocus(focus => {
453 454
			markerFocusContextKey.set(focus.elements.some(e => e instanceof Marker));
			relatedInformationFocusContextKey.set(focus.elements.some(e => e instanceof RelatedInformation));
455
		}));
J
Joao Moreno 已提交
456

457
		this._register(Event.debounce(this.tree.onDidOpen, (last, event) => event, 75, true)(options => {
458
			this.openFileAtElement(options.element, !!options.editorOptions.preserveFocus, options.sideBySide, !!options.editorOptions.pinned);
459
		}));
460 461 462 463 464 465 466 467 468 469 470 471
		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 已提交
472

M
Matt Bierner 已提交
473
		this._register(this.tree.onContextMenu(this.onContextMenu, this));
J
Joao Moreno 已提交
474 475

		this._register(this.configurationService.onDidChangeConfiguration(e => {
476
			if (this.filters.excludedFiles && e.affectsConfiguration('files.exclude')) {
J
Joao Moreno 已提交
477 478 479
				this.updateFilter();
			}
		}));
480 481

		// move focus to input, whenever a key is pressed in the panel container
J
Joao Moreno 已提交
482
		this._register(domEvent(parent, 'keydown')(e => {
S
Sandeep Somavarapu 已提交
483
			if (this.keybindingService.mightProducePrintableCharacter(new StandardKeyboardEvent(e))) {
484
				this.focusFilter();
485 486
			}
		}));
S
Sandeep Somavarapu 已提交
487 488

		this._register(Event.any<any>(this.tree.onDidChangeSelection, this.tree.onDidChangeFocus)(() => {
S
Sandeep Somavarapu 已提交
489
			const elements = [...this.tree!.getSelection(), ...this.tree!.getFocus()];
S
Sandeep Somavarapu 已提交
490 491 492 493 494 495 496 497 498
			for (const element of elements) {
				if (element instanceof Marker) {
					const viewModel = this.markersViewModel.getViewModel(element);
					if (viewModel) {
						viewModel.showLightBulb();
					}
				}
			}
		}));
S
Sandeep Somavarapu 已提交
499 500
	}

501
	private collapseAll(): void {
S
Sandeep Somavarapu 已提交
502 503 504 505 506 507 508
		if (this.tree) {
			this.tree.collapseAll();
			this.tree.setSelection([]);
			this.tree.setFocus([]);
			this.tree.getHTMLElement().focus();
			this.tree.focusFirst();
		}
S
Sandeep Somavarapu 已提交
509 510
	}

511
	private createListeners(): void {
512 513 514
		this._register(Event.any<MarkerChangesEvent | void>(this.markersWorkbenchService.markersModel.onDidChange, this.editorService.onDidActiveEditorChange)(changes => {
			if (changes) {
				this.onDidChangeModel(changes);
S
Sandeep Somavarapu 已提交
515 516 517
			} else {
				this.onActiveEditorChanged();
			}
518
		}));
S
Sandeep Somavarapu 已提交
519 520 521
		if (this.tree) {
			this._register(this.tree.onDidChangeSelection(() => this.onSelected()));
		}
522
		this._register(this.filters.onDidChange((event: IMarkersFiltersChangeEvent) => {
S
Sandeep Somavarapu 已提交
523
			this.reportFilteringUsed();
S
Sandeep Somavarapu 已提交
524 525 526
			if (event.activeFile) {
				this.refreshPanel();
			} else if (event.filterText || event.excludedFiles || event.showWarnings || event.showErrors || event.showInfos) {
J
Joao Moreno 已提交
527 528 529
				this.updateFilter();
			}
		}));
530 531
	}

532 533 534 535
	private onDidChangeModel(change: MarkerChangesEvent) {
		const resourceMarkers = [...change.added, ...change.removed, ...change.updated];
		const resources: URI[] = [];
		for (const { resource } of resourceMarkers) {
S
Sandeep Somavarapu 已提交
536
			this.markersViewModel.remove(resource);
S
#1927  
Sandeep Somavarapu 已提交
537 538 539
			const resourceMarkers = this.markersWorkbenchService.markersModel.getResourceMarkers(resource);
			if (resourceMarkers) {
				for (const marker of resourceMarkers.markers) {
S
Sandeep Somavarapu 已提交
540
					this.markersViewModel.add(marker);
S
#1927  
Sandeep Somavarapu 已提交
541 542
				}
			}
543
			resources.push(resource);
S
#1927  
Sandeep Somavarapu 已提交
544
		}
S
Sandeep Somavarapu 已提交
545
		this.currentResourceGotAddedToMarkersData = this.currentResourceGotAddedToMarkersData || this.isCurrentResourceGotAddedToMarkersData(resources);
546
		this.refreshPanel(change);
J
Joao Moreno 已提交
547 548 549 550 551
		this.updateRangeHighlights();
		if (this.currentResourceGotAddedToMarkersData) {
			this.autoReveal();
			this.currentResourceGotAddedToMarkersData = false;
		}
S
Sandeep Somavarapu 已提交
552 553
	}

554
	private isCurrentResourceGotAddedToMarkersData(changedResources: URI[]) {
M
Matt Bierner 已提交
555 556
		const currentlyActiveResource = this.currentActiveResource;
		if (!currentlyActiveResource) {
S
Sandeep Somavarapu 已提交
557 558
			return false;
		}
559 560
		const resourceForCurrentActiveResource = this.getResourceForCurrentActiveResource();
		if (resourceForCurrentActiveResource) {
S
Sandeep Somavarapu 已提交
561 562
			return false;
		}
M
Matt Bierner 已提交
563
		return changedResources.some(r => r.toString() === currentlyActiveResource.toString());
S
Sandeep Somavarapu 已提交
564 565
	}

B
Benjamin Pasero 已提交
566
	private onActiveEditorChanged(): void {
S
Sandeep Somavarapu 已提交
567
		this.setCurrentActiveEditor();
568
		if (this.filters.activeFile) {
S
Sandeep Somavarapu 已提交
569 570
			this.refreshPanel();
		}
S
Sandeep Somavarapu 已提交
571
		this.autoReveal();
S
Sandeep Somavarapu 已提交
572 573 574
	}

	private setCurrentActiveEditor(): void {
B
Benjamin Pasero 已提交
575
		const activeEditor = this.editorService.activeEditor;
576
		this.currentActiveResource = activeEditor ? withUndefinedAsNull(activeEditor.resource) : null;
S
Sandeep Somavarapu 已提交
577 578
	}

579
	private onSelected(): void {
S
Sandeep Somavarapu 已提交
580 581 582 583 584
		if (this.tree) {
			let selection = this.tree.getSelection();
			if (selection && selection.length > 0) {
				this.lastSelectedRelativeTop = this.tree!.getRelativeTop(selection[0]) || 0;
			}
585 586 587
		}
	}

J
Joao Moreno 已提交
588
	private hasNoProblems(): boolean {
S
Sandeep Somavarapu 已提交
589 590 591 592
		const { total, filtered } = this.getFilterStats();
		return total === 0 || filtered === 0;
	}

593
	private renderContent(): void {
J
Joao Moreno 已提交
594
		this.cachedFilterStats = undefined;
S
Sandeep Somavarapu 已提交
595
		this.resetTree();
S
Sandeep Somavarapu 已提交
596
		if (this.tree) {
J
Joao Moreno 已提交
597
			this.tree.toggleVisibility(this.hasNoProblems());
S
Sandeep Somavarapu 已提交
598
		}
S
Sandeep Somavarapu 已提交
599
		this.renderMessage();
S
Sandeep Somavarapu 已提交
600 601
	}

S
Sandeep Somavarapu 已提交
602
	private renderMessage(): void {
S
Sandeep Somavarapu 已提交
603 604 605
		if (!this.messageBoxContainer || !this.ariaLabelElement) {
			return;
		}
606
		dom.clearNode(this.messageBoxContainer);
J
Joao Moreno 已提交
607
		const { total, filtered } = this.getFilterStats();
J
Joao Moreno 已提交
608 609 610 611

		if (filtered === 0) {
			this.messageBoxContainer.style.display = 'block';
			this.messageBoxContainer.setAttribute('tabIndex', '0');
612
			if (this.filters.activeFile) {
S
Sandeep Somavarapu 已提交
613
				this.renderFilterMessageForActiveFile(this.messageBoxContainer);
J
Joao Moreno 已提交
614
			} else {
S
Sandeep Somavarapu 已提交
615 616 617 618 619
				if (total > 0) {
					this.renderFilteredByFilterMessage(this.messageBoxContainer);
				} else {
					this.renderNoProblemsMessage(this.messageBoxContainer);
				}
J
Joao Moreno 已提交
620
			}
S
Sandeep Somavarapu 已提交
621
		} else {
J
Joao Moreno 已提交
622 623
			this.messageBoxContainer.style.display = 'none';
			if (filtered === total) {
624
				this.setAriaLabel(localize('No problems filtered', "Showing {0} problems", total));
J
Joao Moreno 已提交
625
			} else {
626
				this.setAriaLabel(localize('problems filtered', "Showing {0} of {1} problems", filtered, total));
J
Joao Moreno 已提交
627 628
			}
			this.messageBoxContainer.removeAttribute('tabIndex');
S
Sandeep Somavarapu 已提交
629
		}
630 631
	}

S
Sandeep Somavarapu 已提交
632 633 634 635 636 637 638 639
	private renderFilterMessageForActiveFile(container: HTMLElement): void {
		if (this.currentActiveResource && this.markersWorkbenchService.markersModel.getResourceMarkers(this.currentActiveResource)) {
			this.renderFilteredByFilterMessage(container);
		} else {
			this.renderNoProblemsMessageForActiveFile(container);
		}
	}

J
Joao Moreno 已提交
640 641 642
	private renderFilteredByFilterMessage(container: HTMLElement) {
		const span1 = dom.append(container, dom.$('span'));
		span1.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_FILTERS;
S
Sandeep Somavarapu 已提交
643 644 645 646 647 648 649 650 651 652 653 654
		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();
			}
		});
655
		this.setAriaLabel(Messages.MARKERS_PANEL_NO_PROBLEMS_FILTERS);
J
Joao Moreno 已提交
656 657
	}

S
Sandeep Somavarapu 已提交
658 659 660
	private renderNoProblemsMessageForActiveFile(container: HTMLElement) {
		const span = dom.append(container, dom.$('span'));
		span.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_ACTIVE_FILE_BUILT;
661
		this.setAriaLabel(Messages.MARKERS_PANEL_NO_PROBLEMS_ACTIVE_FILE_BUILT);
S
Sandeep Somavarapu 已提交
662 663
	}

J
Joao Moreno 已提交
664 665 666
	private renderNoProblemsMessage(container: HTMLElement) {
		const span = dom.append(container, dom.$('span'));
		span.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_BUILT;
667 668 669 670 671 672 673 674
		this.setAriaLabel(Messages.MARKERS_PANEL_NO_PROBLEMS_BUILT);
	}

	private setAriaLabel(label: string): void {
		if (this.tree) {
			this.tree.ariaLabel = label;
		}
		this.ariaLabelElement!.setAttribute('aria-label', label);
J
Joao Moreno 已提交
675
	}
S
Sandeep Somavarapu 已提交
676

S
Sandeep Somavarapu 已提交
677
	private clearFilters(): void {
678 679 680 681 682
		this.filters.filterText = '';
		this.filters.excludedFiles = false;
		this.filters.showErrors = true;
		this.filters.showWarnings = true;
		this.filters.showInfos = true;
S
Sandeep Somavarapu 已提交
683 684
	}

S
Sandeep Somavarapu 已提交
685
	private autoReveal(focus: boolean = false): void {
S
Sandeep Somavarapu 已提交
686
		// No need to auto reveal if active file filter is on
687
		if (this.filters.activeFile || !this.tree) {
S
Sandeep Somavarapu 已提交
688 689
			return;
		}
690 691
		let autoReveal = this.configurationService.getValue<boolean>('problems.autoReveal');
		if (typeof autoReveal === 'boolean' && autoReveal) {
S
Sandeep Somavarapu 已提交
692 693
			let currentActiveResource = this.getResourceForCurrentActiveResource();
			if (currentActiveResource) {
S
Sandeep Somavarapu 已提交
694
				if (this.tree.hasElement(currentActiveResource) && !this.tree.isCollapsed(currentActiveResource) && this.hasSelectedMarkerFor(currentActiveResource)) {
S
Sandeep Somavarapu 已提交
695 696 697 698 699 700 701
					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 已提交
702

S
Sandeep Somavarapu 已提交
703 704 705 706
					if (focus) {
						this.tree.setFocus([currentActiveResource]);
						this.tree.setSelection([currentActiveResource]);
					}
J
Joao Moreno 已提交
707
				}
S
Sandeep Somavarapu 已提交
708 709 710
			} else if (focus) {
				this.tree.setSelection([]);
				this.tree.focusFirst();
711 712 713 714
			}
		}
	}

715
	private getResourceForCurrentActiveResource(): ResourceMarkers | null {
J
Joao Moreno 已提交
716
		return this.currentActiveResource ? this.markersWorkbenchService.markersModel.getResourceMarkers(this.currentActiveResource) : null;
S
Sandeep Somavarapu 已提交
717 718
	}

719
	private hasSelectedMarkerFor(resource: ResourceMarkers): boolean {
S
Sandeep Somavarapu 已提交
720 721 722 723
		if (this.tree) {
			let selectedElement = this.tree.getSelection();
			if (selectedElement && selectedElement.length > 0) {
				if (selectedElement[0] instanceof Marker) {
724
					if (resource.has((<Marker>selectedElement[0]).marker.resource)) {
S
Sandeep Somavarapu 已提交
725 726
						return true;
					}
S
Sandeep Somavarapu 已提交
727 728 729 730 731 732
				}
			}
		}
		return false;
	}

S
Sandeep Somavarapu 已提交
733
	private updateRangeHighlights() {
734
		this.rangeHighlightDecorations.removeHighlightRange();
S
Sandeep Somavarapu 已提交
735
		if (this.tree && this.tree.getHTMLElement() === document.activeElement) {
S
Sandeep Somavarapu 已提交
736 737 738 739 740
			this.highlightCurrentSelectedMarkerRange();
		}
	}

	private highlightCurrentSelectedMarkerRange() {
S
Sandeep Somavarapu 已提交
741
		const selections = this.tree ? this.tree.getSelection() : [];
J
Joao Moreno 已提交
742 743 744

		if (selections.length !== 1) {
			return;
S
Sandeep Somavarapu 已提交
745
		}
J
Joao Moreno 已提交
746 747 748 749 750 751 752 753

		const selection = selections[0];

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

		this.rangeHighlightDecorations.highlightRange(selection);
S
Sandeep Somavarapu 已提交
754 755
	}

756
	private onContextMenu(e: ITreeContextMenuEvent<TreeElement | null>): void {
M
Matt Bierner 已提交
757 758
		const element = e.element;
		if (!element) {
J
Joao Moreno 已提交
759 760 761 762 763 764
			return;
		}

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

S
Sandeep Somavarapu 已提交
765
		this.contextMenuService.showContextMenu({
M
Matt Bierner 已提交
766 767
			getAnchor: () => e.anchor!,
			getActions: () => this.getMenuActions(element),
768
			getActionViewItem: (action) => {
S
Sandeep Somavarapu 已提交
769 770
				const keybinding = this.keybindingService.lookupKeybinding(action.id);
				if (keybinding) {
771
					return new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel() });
J
Joao Moreno 已提交
772
				}
773
				return undefined;
S
Sandeep Somavarapu 已提交
774 775 776
			},
			onHide: (wasCancelled?: boolean) => {
				if (wasCancelled) {
S
Sandeep Somavarapu 已提交
777
					this.tree!.domFocus();
S
Sandeep Somavarapu 已提交
778 779
				}
			}
J
Joao Moreno 已提交
780 781 782
		});
	}

S
Sandeep Somavarapu 已提交
783
	private getMenuActions(element: TreeElement): IAction[] {
J
Joao Moreno 已提交
784 785 786
		const result: IAction[] = [];

		if (element instanceof Marker) {
S
Sandeep Somavarapu 已提交
787 788 789 790 791 792 793
			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 已提交
794 795 796
			}
		}

S
Sandeep Somavarapu 已提交
797
		const menu = this.menuService.createMenu(MenuId.ProblemsPanelContext, this.tree!.contextKeyService);
J
Joao Moreno 已提交
798 799 800 801 802 803 804 805 806 807 808 809 810
		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 已提交
811
	public getFocusElement() {
S
Sandeep Somavarapu 已提交
812
		return this.tree ? this.tree.getFocus()[0] : undefined;
S
Sandeep Somavarapu 已提交
813 814
	}

815
	public getActionViewItem(action: IAction): IActionViewItem | undefined {
816 817
		if (action.id === `workbench.actions.treeView.${this.id}.filter`) {
			return this.instantiationService.createInstance(MarkersFilterActionViewItem, action, this);
818
		}
819
		return super.getActionViewItem(action);
S
Sandeep Somavarapu 已提交
820 821
	}

J
Joao Moreno 已提交
822 823 824 825 826 827 828 829 830 831
	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 已提交
832 833
		if (this.tree) {
			const root = this.tree.getNode();
J
Joao Moreno 已提交
834

S
Sandeep Somavarapu 已提交
835 836 837 838 839
			for (const resourceMarkerNode of root.children) {
				for (const markerNode of resourceMarkerNode.children) {
					if (resourceMarkerNode.visible && markerNode.visible) {
						filtered++;
					}
J
Joao Moreno 已提交
840 841 842 843
				}
			}
		}

S
Sandeep Somavarapu 已提交
844
		return { total: this.markersWorkbenchService.markersModel.total, filtered };
J
Joao Moreno 已提交
845 846
	}

847 848 849 850
	private getTelemetryData({ source, code }: IMarker): any {
		return { source, code };
	}

S
Sandeep Somavarapu 已提交
851 852
	private reportFilteringUsed(): void {
		const data = {
853 854 855 856 857
			errors: this.filters.showErrors,
			warnings: this.filters.showWarnings,
			infos: this.filters.showInfos,
			activeFile: this.filters.activeFile,
			excludedFiles: this.filters.excludedFiles,
S
Sandeep Somavarapu 已提交
858 859 860 861 862 863 864 865 866 867 868 869 870
		};
		/* __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);
	}

871
	saveState(): void {
872 873 874 875 876 877 878
		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 已提交
879
		this.panelState['multiline'] = this.markersViewModel.multiline;
S
Sandeep Somavarapu 已提交
880

B
Benjamin Pasero 已提交
881
		super.saveState();
882 883
	}

884 885 886 887
	dispose() {
		super.dispose();
	}

I
isidor 已提交
888
}
S
Sandeep Somavarapu 已提交
889 890 891 892 893 894 895 896

class MarkersTree extends WorkbenchObjectTree<TreeElement, FilterData> {

	constructor(
		user: string,
		readonly container: HTMLElement,
		delegate: IListVirtualDelegate<TreeElement>,
		renderers: ITreeRenderer<TreeElement, FilterData, any>[],
S
Sandeep Somavarapu 已提交
897
		options: IWorkbenchObjectTreeOptions<TreeElement, FilterData>,
S
Sandeep Somavarapu 已提交
898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917
		@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);
	}

}
918

M
Martin Aeschlimann 已提交
919
registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => {
920 921 922 923 924

	// Lightbulb Icon
	const editorLightBulbForegroundColor = theme.getColor(editorLightBulbForeground);
	if (editorLightBulbForegroundColor) {
		collector.addRule(`
M
Martin Aeschlimann 已提交
925
		.monaco-workbench .markers-panel-container ${Codicon.lightBulb.cssSelector} {
926 927 928 929 930 931 932 933
			color: ${editorLightBulbForegroundColor};
		}`);
	}

	// Lightbulb Auto Fix Icon
	const editorLightBulbAutoFixForegroundColor = theme.getColor(editorLightBulbAutoFixForeground);
	if (editorLightBulbAutoFixForegroundColor) {
		collector.addRule(`
M
Martin Aeschlimann 已提交
934
		.monaco-workbench .markers-panel-container ${Codicon.lightbulbAutofix.cssSelector} {
935 936 937 938 939
			color: ${editorLightBulbAutoFixForegroundColor};
		}`);
	}

});