Merge branch 'sandy081/strictPropertyInit'

This commit is contained in:
Sandeep Somavarapu 2019-09-05 01:32:39 +02:00
commit 0e00b6d6e9
3 changed files with 52 additions and 56 deletions

View file

@ -69,23 +69,21 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
private lastSelectedRelativeTop: number = 0; private lastSelectedRelativeTop: number = 0;
private currentActiveResource: URI | null = null; private currentActiveResource: URI | null = null;
private tree: WorkbenchObjectTree<TreeElement, FilterData>; private readonly rangeHighlightDecorations: RangeHighlightDecorations;
private treeLabels: ResourceLabels; private readonly filter: Filter;
private rangeHighlightDecorations: RangeHighlightDecorations;
private actions: IAction[]; private tree!: WorkbenchObjectTree<TreeElement, FilterData>;
private collapseAllAction: IAction; private treeContainer!: HTMLElement;
private filterAction: MarkersFilterAction; private messageBoxContainer!: HTMLElement;
private filterInputActionViewItem: MarkersFilterActionViewItem; private ariaLabelElement!: HTMLElement;
private readonly collapseAllAction: IAction;
private readonly filterAction: MarkersFilterAction;
private filterInputActionViewItem: MarkersFilterActionViewItem | null = null;
private treeContainer: HTMLElement;
private messageBoxContainer: HTMLElement;
private ariaLabelElement: HTMLElement;
private readonly panelState: MementoObject; private readonly panelState: MementoObject;
private panelFoucusContextKey: IContextKey<boolean>; private panelFoucusContextKey: IContextKey<boolean>;
private filter: Filter;
private _onDidFilter = this._register(new Emitter<void>()); private _onDidFilter = this._register(new Emitter<void>());
readonly onDidFilter: Event<void> = this._onDidFilter.event; readonly onDidFilter: Event<void> = this._onDidFilter.event;
private cachedFilterStats: { total: number; filtered: number; } | undefined = undefined; private cachedFilterStats: { total: number; filtered: number; } | undefined = undefined;
@ -114,12 +112,18 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this.markersViewModel = instantiationService.createInstance(MarkersViewModel, this.panelState['multiline']); this.markersViewModel = instantiationService.createInstance(MarkersViewModel, this.panelState['multiline']);
this.markersViewModel.onDidChange(this.onDidChangeViewState, this, this.disposables); this.markersViewModel.onDidChange(this.onDidChangeViewState, this, this.disposables);
this.setCurrentActiveEditor(); this.setCurrentActiveEditor();
this.filter = new Filter(new FilterOptions());
this.rangeHighlightDecorations = this._register(this.instantiationService.createInstance(RangeHighlightDecorations));
// actions
this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => this.collapseAll());
this.filterAction = this.instantiationService.createInstance(MarkersFilterAction, { filterText: this.panelState['filter'] || '', filterHistory: this.panelState['filterHistory'] || [], useFilesExclude: !!this.panelState['useFilesExclude'] });
} }
public create(parent: HTMLElement): void { public create(parent: HTMLElement): void {
super.create(parent); super.create(parent);
this.rangeHighlightDecorations = this._register(this.instantiationService.createInstance(RangeHighlightDecorations));
dom.addClass(parent, 'markers-panel'); dom.addClass(parent, 'markers-panel');
@ -128,7 +132,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this.createArialLabelElement(container); this.createArialLabelElement(container);
this.createMessageBox(container); this.createMessageBox(container);
this.createTree(container); this.createTree(container);
this.createActions();
this.createListeners(); this.createListeners();
this.updateFilter(); this.updateFilter();
@ -178,10 +181,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
} }
public getActions(): IAction[] { public getActions(): IAction[] {
if (!this.actions) { return [this.filterAction, this.collapseAllAction];
this.createActions();
}
return this.actions;
} }
public showQuickFixes(marker: Marker): void { public showQuickFixes(marker: Marker): void {
@ -306,15 +306,14 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
const onDidChangeRenderNodeCount = new Relay<ITreeNode<any, any>>(); const onDidChangeRenderNodeCount = new Relay<ITreeNode<any, any>>();
this.treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this)); const treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this));
const virtualDelegate = new VirtualDelegate(this.markersViewModel); const virtualDelegate = new VirtualDelegate(this.markersViewModel);
const renderers = [ const renderers = [
this.instantiationService.createInstance(ResourceMarkersRenderer, this.treeLabels, onDidChangeRenderNodeCount.event), this.instantiationService.createInstance(ResourceMarkersRenderer, treeLabels, onDidChangeRenderNodeCount.event),
this.instantiationService.createInstance(MarkerRenderer, this.markersViewModel), this.instantiationService.createInstance(MarkerRenderer, this.markersViewModel),
this.instantiationService.createInstance(RelatedInformationRenderer) this.instantiationService.createInstance(RelatedInformationRenderer)
]; ];
this.filter = new Filter(new FilterOptions());
const accessibilityProvider = this.instantiationService.createInstance(MarkersTreeAccessibilityProvider); const accessibilityProvider = this.instantiationService.createInstance(MarkersTreeAccessibilityProvider);
const identityProvider = { const identityProvider = {
@ -396,17 +395,12 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
})); }));
} }
private createActions(): void { private collapseAll(): void {
this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => { this.tree.collapseAll();
this.tree.collapseAll(); this.tree.setSelection([]);
this.tree.setSelection([]); this.tree.setFocus([]);
this.tree.setFocus([]); this.tree.getHTMLElement().focus();
this.tree.getHTMLElement().focus(); this.tree.focusFirst();
this.tree.focusFirst();
});
this.filterAction = this.instantiationService.createInstance(MarkersFilterAction, { filterText: this.panelState['filter'] || '', filterHistory: this.panelState['filterHistory'] || [], useFilesExclude: !!this.panelState['useFilesExclude'] });
this.actions = [this.filterAction, this.collapseAllAction];
} }
private createListeners(): void { private createListeners(): void {
@ -423,7 +417,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this.updateFilter(); this.updateFilter();
} }
})); }));
this.actions.forEach(a => this._register(a));
} }
private onDidChangeModel(change: MarkerChangesEvent) { private onDidChangeModel(change: MarkerChangesEvent) {

View file

@ -118,10 +118,9 @@ export interface IMarkerFilterController {
export class MarkersFilterActionViewItem extends BaseActionViewItem { export class MarkersFilterActionViewItem extends BaseActionViewItem {
private delayedFilterUpdate: Delayer<void>; private delayedFilterUpdate: Delayer<void>;
private container: HTMLElement; private container: HTMLElement | null = null;
private filterInputBox: HistoryInputBox; private filterInputBox: HistoryInputBox | null = null;
private controlsContainer: HTMLInputElement; private filterBadge: HTMLElement | null = null;
private filterBadge: HTMLInputElement;
private focusContextKey: IContextKey<boolean>; private focusContextKey: IContextKey<boolean>;
constructor( constructor(
@ -172,13 +171,13 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem {
this.filterInputBox.inputElement.setAttribute('aria-labelledby', 'markers-panel-arialabel'); this.filterInputBox.inputElement.setAttribute('aria-labelledby', 'markers-panel-arialabel');
this._register(attachInputBoxStyler(this.filterInputBox, this.themeService)); this._register(attachInputBoxStyler(this.filterInputBox, this.themeService));
this.filterInputBox.value = this.action.filterText; this.filterInputBox.value = this.action.filterText;
this._register(this.filterInputBox.onDidChange(filter => this.delayedFilterUpdate.trigger(() => this.onDidInputChange(this.filterInputBox)))); this._register(this.filterInputBox.onDidChange(filter => this.delayedFilterUpdate.trigger(() => this.onDidInputChange(this.filterInputBox!))));
this._register(this.action.onDidChange((event: IMarkersFilterActionChangeEvent) => { this._register(this.action.onDidChange((event: IMarkersFilterActionChangeEvent) => {
if (event.filterText) { if (event.filterText) {
this.filterInputBox.value = this.action.filterText; this.filterInputBox!.value = this.action.filterText;
} }
})); }));
this._register(DOM.addStandardDisposableListener(this.filterInputBox.inputElement, DOM.EventType.KEY_DOWN, (e: any) => this.onInputKeyDown(e, this.filterInputBox))); this._register(DOM.addStandardDisposableListener(this.filterInputBox.inputElement, DOM.EventType.KEY_DOWN, (e: any) => this.onInputKeyDown(e, this.filterInputBox!)));
this._register(DOM.addStandardDisposableListener(container, DOM.EventType.KEY_DOWN, this.handleKeyboardEvent)); this._register(DOM.addStandardDisposableListener(container, DOM.EventType.KEY_DOWN, this.handleKeyboardEvent));
this._register(DOM.addStandardDisposableListener(container, DOM.EventType.KEY_UP, this.handleKeyboardEvent)); this._register(DOM.addStandardDisposableListener(container, DOM.EventType.KEY_UP, this.handleKeyboardEvent));
@ -189,24 +188,24 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem {
} }
private createControls(container: HTMLElement): void { private createControls(container: HTMLElement): void {
this.controlsContainer = DOM.append(container, DOM.$('.markers-panel-filter-controls')); const controlsContainer = DOM.append(container, DOM.$('.markers-panel-filter-controls'));
this.createBadge(this.controlsContainer); this.createBadge(controlsContainer);
this.createFilesExcludeCheckbox(this.controlsContainer); this.createFilesExcludeCheckbox(controlsContainer);
} }
private createBadge(container: HTMLElement): void { private createBadge(container: HTMLElement): void {
this.filterBadge = DOM.append(container, DOM.$('.markers-panel-filter-badge')); const filterBadge = this.filterBadge = DOM.append(container, DOM.$('.markers-panel-filter-badge'));
this._register(attachStylerCallback(this.themeService, { badgeBackground, badgeForeground, contrastBorder }, colors => { this._register(attachStylerCallback(this.themeService, { badgeBackground, badgeForeground, contrastBorder }, colors => {
const background = colors.badgeBackground ? colors.badgeBackground.toString() : null; const background = colors.badgeBackground ? colors.badgeBackground.toString() : null;
const foreground = colors.badgeForeground ? colors.badgeForeground.toString() : null; const foreground = colors.badgeForeground ? colors.badgeForeground.toString() : null;
const border = colors.contrastBorder ? colors.contrastBorder.toString() : null; const border = colors.contrastBorder ? colors.contrastBorder.toString() : null;
this.filterBadge.style.backgroundColor = background; filterBadge.style.backgroundColor = background;
this.filterBadge.style.borderWidth = border ? '1px' : null; filterBadge.style.borderWidth = border ? '1px' : null;
this.filterBadge.style.borderStyle = border ? 'solid' : null; filterBadge.style.borderStyle = border ? 'solid' : null;
this.filterBadge.style.borderColor = border; filterBadge.style.borderColor = border;
this.filterBadge.style.color = foreground; filterBadge.style.color = foreground;
})); }));
this.updateBadge(); this.updateBadge();
this._register(this.filterController.onDidFilter(() => this.updateBadge())); this._register(this.filterController.onDidFilter(() => this.updateBadge()));
@ -241,14 +240,18 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem {
} }
private updateBadge(): void { private updateBadge(): void {
const { total, filtered } = this.filterController.getFilterStats(); if (this.filterBadge) {
DOM.toggleClass(this.filterBadge, 'hidden', total === filtered || filtered === 0); const { total, filtered } = this.filterController.getFilterStats();
this.filterBadge.textContent = localize('showing filtered problems', "Showing {0} of {1}", filtered, total); DOM.toggleClass(this.filterBadge, 'hidden', total === filtered || filtered === 0);
this.adjustInputBox(); this.filterBadge.textContent = localize('showing filtered problems', "Showing {0} of {1}", filtered, total);
this.adjustInputBox();
}
} }
private adjustInputBox(): void { private adjustInputBox(): void {
this.filterInputBox.inputElement.style.paddingRight = DOM.hasClass(this.container, 'small') || DOM.hasClass(this.filterBadge, 'hidden') ? '25px' : '150px'; if (this.container && this.filterInputBox && this.filterBadge) {
this.filterInputBox.inputElement.style.paddingRight = DOM.hasClass(this.container, 'small') || DOM.hasClass(this.filterBadge, 'hidden') ? '25px' : '150px';
}
} }
// Action toolbar is swallowing some keys for action items which should not be for an input box // Action toolbar is swallowing some keys for action items which should not be for an input box

View file

@ -510,7 +510,7 @@ export class MarkerViewModel extends Disposable {
} }
} }
private _quickFixAction: QuickFixAction; private _quickFixAction: QuickFixAction | null = null;
get quickFixAction(): QuickFixAction { get quickFixAction(): QuickFixAction {
if (!this._quickFixAction) { if (!this._quickFixAction) {
this._quickFixAction = this._register(this.instantiationService.createInstance(QuickFixAction, this.marker)); this._quickFixAction = this._register(this.instantiationService.createInstance(QuickFixAction, this.marker));
@ -616,7 +616,7 @@ export class MarkersViewModel extends Disposable {
private bulkUpdate: boolean = false; private bulkUpdate: boolean = false;
private hoveredMarker: Marker | null; private hoveredMarker: Marker | null = null;
private hoverDelayer: Delayer<void> = new Delayer<void>(300); private hoverDelayer: Delayer<void> = new Delayer<void>(300);
constructor( constructor(