From 8301ae680e3f034521bd09afcb8e90ff4e4e0b3f Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 6 Mar 2018 11:17:54 +0100 Subject: [PATCH] move sorting and filter-state into marker view model #14783 --- .../parts/markers/browser/markersPanel.ts | 22 +- .../markers/browser/markersTreeViewer.ts | 34 ++- .../workbench/parts/markers/common/markers.ts | 21 +- .../parts/markers/common/markersModel.ts | 282 +++++++++--------- .../markersElectronContributions.ts | 4 +- .../markers/test/common/markersModel.test.ts | 51 ++-- 6 files changed, 212 insertions(+), 202 deletions(-) diff --git a/src/vs/workbench/parts/markers/browser/markersPanel.ts b/src/vs/workbench/parts/markers/browser/markersPanel.ts index 24a9ca2c98ab7..46d1e4e18e844 100644 --- a/src/vs/workbench/parts/markers/browser/markersPanel.ts +++ b/src/vs/workbench/parts/markers/browser/markersPanel.ts @@ -139,7 +139,7 @@ export class MarkersPanel extends Panel { "source" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } } */ - this.telemetryService.publicLog('problems.marker.opened', { source: marker.marker.source }); + this.telemetryService.publicLog('problems.marker.opened', { source: marker.raw.source }); this.editorService.openEditor({ resource: marker.resource, options: { @@ -197,6 +197,7 @@ export class MarkersPanel extends Panel { const controller = this.instantiationService.createInstance(Controller); this.tree = this.instantiationService.createInstance(WorkbenchTree, this.treeContainer, { dataSource: new Viewer.DataSource(), + filter: new Viewer.DataFilter(), renderer, controller, sorter: new Viewer.Sorter(), @@ -294,13 +295,12 @@ export class MarkersPanel extends Panel { } private autoExpand(): void { - for (const resource of this.markersWorkbenchService.markersModel.filteredResources) { - const resourceUri = resource.uri.toString(); - if (!this.autoExpanded.has(resourceUri)) { + this.markersWorkbenchService.markersModel.forEachFilteredResource(resource => { + if (!this.autoExpanded.has(resource.uri.toString())) { this.tree.expand(resource).done(null, errors.onUnexpectedError); - this.autoExpanded.add(resourceUri); + this.autoExpanded.add(resource.uri.toString()); } - } + }); } private autoReveal(focus: boolean = false): void { @@ -332,13 +332,15 @@ export class MarkersPanel extends Panel { } private getResourceForCurrentActiveResource(): Resource { + let res: Resource = null; if (this.currentActiveResource) { - let resources = this.markersWorkbenchService.markersModel.filteredResources.filter((resource): boolean => { - return this.currentActiveResource.toString() === resource.uri.toString(); + this.markersWorkbenchService.markersModel.forEachFilteredResource(resource => { + if (!res && resource.uri.toString() === this.currentActiveResource.toString()) { + res = resource; + } }); - return resources.length > 0 ? resources[0] : null; } - return null; + return res; } private hasSelectedMarkerFor(resource: Resource): boolean { diff --git a/src/vs/workbench/parts/markers/browser/markersTreeViewer.ts b/src/vs/workbench/parts/markers/browser/markersTreeViewer.ts index f819166580300..ab5b816e8363c 100644 --- a/src/vs/workbench/parts/markers/browser/markersTreeViewer.ts +++ b/src/vs/workbench/parts/markers/browser/markersTreeViewer.ts @@ -7,7 +7,7 @@ import { TPromise, Promise } from 'vs/base/common/winjs.base'; import * as dom from 'vs/base/browser/dom'; import * as network from 'vs/base/common/network'; -import { IDataSource, ITree, IRenderer, IAccessibilityProvider, ISorter } from 'vs/base/parts/tree/browser/tree'; +import { IDataSource, ITree, IRenderer, IAccessibilityProvider, ISorter, IFilter } from 'vs/base/parts/tree/browser/tree'; import Severity from 'vs/base/common/severity'; import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge'; import { FileLabel, ResourceLabel } from 'vs/workbench/browser/labels'; @@ -41,7 +41,7 @@ interface IMarkerTemplateData { } export class DataSource implements IDataSource { - public getId(tree: ITree, element: any): string { + public getId(tree: ITree, element: MarkersModel | Resource | Marker): string { if (element instanceof MarkersModel) { return 'root'; } @@ -49,7 +49,7 @@ export class DataSource implements IDataSource { return element.uri.toString(); } if (element instanceof Marker) { - return (element).id; + return element.id; } return ''; } @@ -58,12 +58,12 @@ export class DataSource implements IDataSource { return element instanceof MarkersModel || element instanceof Resource; } - public getChildren(tree: ITree, element: any): Promise { + public getChildren(tree: ITree, element: MarkersModel | Resource): Promise { if (element instanceof MarkersModel) { - return TPromise.as((element).filteredResources); + return Promise.as(element.resources); } if (element instanceof Resource) { - return TPromise.as(element.markers); + return Promise.as(element.markers); } return null; } @@ -73,6 +73,18 @@ export class DataSource implements IDataSource { } } +export class DataFilter implements IFilter { + public isVisible(tree: ITree, element: Resource | Marker | any): boolean { + if (element instanceof Resource) { + return element.filteredMarkersCount > 0; + } + if (element instanceof Marker) { + return element.isSelected; + } + return true; + } +} + export class Renderer implements IRenderer { private static readonly RESOURCE_TEMPLATE_ID = 'resource-template'; @@ -164,13 +176,13 @@ export class Renderer implements IRenderer { } else if ((templateData).resourceLabel) { (templateData).resourceLabel.setLabel({ name: element.name, description: element.uri.toString(), resource: element.uri }, { matches: element.uriMatches }); } - templateData.count.setCount(element.markers.length); + templateData.count.setCount(element.filteredMarkersCount); } private renderMarkerElement(tree: ITree, element: Marker, templateData: IMarkerTemplateData) { - let marker = element.marker; + let marker = element.raw; templateData.icon.className = 'icon ' + Renderer.iconClassNameFor(marker); - templateData.description.set(marker.message, element.labelMatches); + templateData.description.set(marker.message, element.messageMatches); templateData.description.element.title = marker.message; dom.toggleClass(templateData.source.element, 'marker-source', !!marker.source); @@ -211,10 +223,10 @@ export class MarkersTreeAccessibilityProvider implements IAccessibilityProvider public getAriaLabel(tree: ITree, element: any): string { if (element instanceof Resource) { - return Messages.MARKERS_TREE_ARIA_LABEL_RESOURCE(element.name, element.markers.length); + return Messages.MARKERS_TREE_ARIA_LABEL_RESOURCE(element.name, element.filteredMarkersCount); } if (element instanceof Marker) { - return Messages.MARKERS_TREE_ARIA_LABEL_MARKER(element.marker); + return Messages.MARKERS_TREE_ARIA_LABEL_MARKER(element.raw); } return null; } diff --git a/src/vs/workbench/parts/markers/common/markers.ts b/src/vs/workbench/parts/markers/common/markers.ts index f86fee2b300f3..6bf86a6064b1a 100644 --- a/src/vs/workbench/parts/markers/common/markers.ts +++ b/src/vs/workbench/parts/markers/common/markers.ts @@ -42,24 +42,23 @@ export class MarkersWorkbenchService extends Disposable implements IMarkersWorkb } filter(filter: string): void { - this.markersModel.update(new FilterOptions(filter)); + this.markersModel.updateFilterOptions(new FilterOptions(filter)); this.refreshBadge(); } private onMarkerChanged(resources: URI[]): void { - const bulkUpdater = this.markersModel.getBulkUpdater(); - for (const resource of resources) { - bulkUpdater.add(resource, this.markerService.read({ resource })); - } - bulkUpdater.done(); + this.markersModel.updateMarkers(updater => { + for (const resource of resources) { + updater(resource, this.markerService.read({ resource })); + } + }); this.refreshBadge(); this._onDidChangeMarkersForResources.fire(resources); } private refreshBadge(): void { - const total = this.markersModel.total(); - const count = this.markersModel.count(); - const message = total === count ? localize('totalProblems', 'Total {0} Problems', total) : localize('filteredProblems', 'Showing {0} of {1} Problems', count, total); - this.activityService.showActivity(Constants.MARKERS_PANEL_ID, new NumberBadge(count, () => message)); + const { total, filtered } = this.markersModel.stats(); + const message = total === filtered ? localize('totalProblems', 'Total {0} Problems', total) : localize('filteredProblems', 'Showing {0} of {1} Problems', filtered, total); + this.activityService.showActivity(Constants.MARKERS_PANEL_ID, new NumberBadge(filtered, () => message)); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/parts/markers/common/markersModel.ts b/src/vs/workbench/parts/markers/common/markersModel.ts index e5c7491b5136f..6fb8111487550 100644 --- a/src/vs/workbench/parts/markers/common/markersModel.ts +++ b/src/vs/workbench/parts/markers/common/markersModel.ts @@ -5,7 +5,6 @@ 'use strict'; import * as paths from 'vs/base/common/paths'; -import * as types from 'vs/base/common/types'; import Severity from 'vs/base/common/severity'; import URI from 'vs/base/common/uri'; import { Range, IRange } from 'vs/editor/common/core/range'; @@ -13,20 +12,19 @@ import { IMarker } from 'vs/platform/markers/common/markers'; import { IFilter, IMatch, or, matchesContiguousSubString, matchesPrefix, matchesFuzzy } from 'vs/base/common/filters'; import Messages from 'vs/workbench/parts/markers/common/messages'; import { Schemas } from 'vs/base/common/network'; - -export interface BulkUpdater { - add(resource: URI, markers: IMarker[]): void; - done(): void; -} +import { groupBy, isFalsyOrEmpty } from 'vs/base/common/arrays'; +import { values } from 'vs/base/common/map'; export class Resource { private _name: string = null; private _path: string = null; + filteredMarkersCount: number = 0; + uriMatches: IMatch[] = []; + constructor( readonly uri: URI, - readonly uriMatches: IMatch[] = [], readonly markers: Marker[], ) { markers.sort(Marker.compare); @@ -51,7 +49,7 @@ export class Resource { let [firstMarkerOfB] = b.markers; let res = 0; if (firstMarkerOfA && firstMarkerOfB) { - res = Severity.compare(firstMarkerOfA.marker.severity, firstMarkerOfB.marker.severity); + res = Severity.compare(firstMarkerOfA.raw.severity, firstMarkerOfB.raw.severity); } if (res === 0) { res = a.path.localeCompare(b.path) || a.name.localeCompare(b.name); @@ -62,85 +60,63 @@ export class Resource { export class Marker { + isSelected: boolean = false; + messageMatches: IMatch[] = []; + sourceMatches: IMatch[] = []; + constructor( readonly id: string, - readonly marker: IMarker, - readonly labelMatches: IMatch[] = [], - readonly sourceMatches: IMatch[] = [] + readonly raw: IMarker, ) { } public get resource(): URI { - return this.marker.resource; + return this.raw.resource; } public get range(): IRange { - return this.marker; + return this.raw; } public toString(): string { return [ - `file: '${this.marker.resource}'`, - `severity: '${Severity.toString(this.marker.severity)}'`, - `message: '${this.marker.message}'`, - `at: '${this.marker.startLineNumber},${this.marker.startColumn}'`, - `source: '${this.marker.source ? this.marker.source : ''}'`, - `code: '${this.marker.code ? this.marker.code : ''}'` + `file: '${this.raw.resource}'`, + `severity: '${Severity.toString(this.raw.severity)}'`, + `message: '${this.raw.message}'`, + `at: '${this.raw.startLineNumber},${this.raw.startColumn}'`, + `source: '${this.raw.source ? this.raw.source : ''}'`, + `code: '${this.raw.code ? this.raw.code : ''}'` ].join('\n'); } static compare(a: Marker, b: Marker): number { - return Severity.compare(a.marker.severity, b.marker.severity) - || Range.compareRangesUsingStarts(a.marker, b.marker); + return Severity.compare(a.raw.severity, b.raw.severity) + || Range.compareRangesUsingStarts(a.raw, b.raw); } } export class FilterOptions { - static _filter: IFilter = or(matchesPrefix, matchesContiguousSubString); - static _fuzzyFilter: IFilter = or(matchesPrefix, matchesContiguousSubString, matchesFuzzy); + static readonly _filter: IFilter = or(matchesPrefix, matchesContiguousSubString); + static readonly _fuzzyFilter: IFilter = or(matchesPrefix, matchesContiguousSubString, matchesFuzzy); - private _filterErrors: boolean = false; - private _filterWarnings: boolean = false; - private _filterInfos: boolean = false; - private _filter: string = ''; - private _completeFilter: string = ''; + readonly filterErrors: boolean = false; + readonly filterWarnings: boolean = false; + readonly filterInfos: boolean = false; + readonly filter: string = ''; + readonly completeFilter: string = ''; constructor(filter: string = '') { if (filter) { - this.parse(filter); + this.completeFilter = filter; + this.filter = filter.trim(); + this.filterErrors = this.matches(this.filter, Messages.MARKERS_PANEL_FILTER_ERRORS); + this.filterWarnings = this.matches(this.filter, Messages.MARKERS_PANEL_FILTER_WARNINGS); + this.filterInfos = this.matches(this.filter, Messages.MARKERS_PANEL_FILTER_INFOS); } } - public get filterErrors(): boolean { - return this._filterErrors; - } - - public get filterWarnings(): boolean { - return this._filterWarnings; - } - - public get filterInfos(): boolean { - return this._filterInfos; - } - - public get filter(): string { - return this._filter; - } - - public get completeFilter(): string { - return this._completeFilter; - } - public hasFilters(): boolean { - return !!this._filter; - } - - private parse(filter: string) { - this._completeFilter = filter; - this._filter = filter.trim(); - this._filterErrors = this.matches(this._filter, Messages.MARKERS_PANEL_FILTER_ERRORS); - this._filterWarnings = this.matches(this._filter, Messages.MARKERS_PANEL_FILTER_WARNINGS); - this._filterInfos = this.matches(this._filter, Messages.MARKERS_PANEL_FILTER_INFOS); + return !!this.filter; } private matches(prefix: string, word: string): boolean { @@ -151,134 +127,148 @@ export class FilterOptions { export class MarkersModel { - private markersByResource: Map; - - private _filteredResources: Resource[]; - private _nonFilteredResources: Resource[]; + private _markersByResource: Map; private _filterOptions: FilterOptions; constructor(markers: IMarker[] = []) { - this.markersByResource = new Map(); + this._markersByResource = new Map(); this._filterOptions = new FilterOptions(); - this.update(markers); + + for (const group of groupBy(markers, MarkersModel._compareMarkersByUri)) { + const resource = this.createResource(group[0].resource, group); + this._markersByResource.set(resource.uri.toString(), resource); + } + } + + private static _compareMarkersByUri(a: IMarker, b: IMarker) { + if (a.resource.toString() < b.resource.toString()) { + return -1; + } else if (a.resource.toString() > b.resource.toString()) { + return 1; + } else { + return 0; + } } public get filterOptions(): FilterOptions { return this._filterOptions; } - public get filteredResources(): Resource[] { - return this._filteredResources; + public get resources(): Resource[] { + return values(this._markersByResource); + } + + public forEachFilteredResource(callback: (resource: Resource) => any) { + this._markersByResource.forEach(resource => { + if (resource.filteredMarkersCount > 0) { + callback(resource); + } + }); } public hasFilteredResources(): boolean { - return this.filteredResources.length > 0; + let res = false; + this._markersByResource.forEach(resource => { + res = res || resource.filteredMarkersCount > 0; + }); + return res; } public hasResources(): boolean { - return this.markersByResource.size > 0; + return this._markersByResource.size > 0; } public hasResource(resource: URI): boolean { - return this.markersByResource.has(resource.toString()); + return this._markersByResource.has(resource.toString()); } - public total(): number { + public stats(): { total: number, filtered: number } { let total = 0; - this.markersByResource.forEach(markers => total = total + markers.length); - return total; - } + let filtered = 0; + this._markersByResource.forEach(resource => { + total += resource.markers.length; + filtered += resource.filteredMarkersCount; + }); + return { total, filtered }; - public count(): number { - let count = 0; - this.filteredResources.forEach(resource => count = count + resource.markers.length); - return count; } - public getBulkUpdater(): BulkUpdater { - return { - add: (resourceUri: URI, markers: IMarker[]) => { - this.updateResource(resourceUri, markers); - }, - done: () => { - this.refresh(); + public updateMarkers(callback: (updater: (resource: URI, markers: IMarker[]) => any) => void): void { + callback((resource, markers) => { + if (isFalsyOrEmpty(markers)) { + this._markersByResource.delete(resource.toString()); + } else { + this._markersByResource.set(resource.toString(), this.createResource(resource, markers)); } - }; + }); } - public update(filterOptions: FilterOptions): void; - public update(resourceUri: URI, markers: IMarker[]): void; - public update(markers: IMarker[]): void; - public update(arg1?: FilterOptions | URI | IMarker[], arg2?: IMarker[]) { - if (arg1 instanceof FilterOptions) { - this._filterOptions = arg1; + public updateFilterOptions(filterOptions: FilterOptions): void { + this._filterOptions = filterOptions; + if (!this._filterOptions.hasFilters()) { + // reset all filters/matches + this._markersByResource.forEach(resource => { + resource.filteredMarkersCount = resource.markers.length; + resource.uriMatches = []; + + for (const marker of resource.markers) { + marker.isSelected = true; + marker.messageMatches = []; + marker.sourceMatches = []; + } + }); + } else { + // update properly + this._markersByResource.forEach(resource => { + + resource.uriMatches = this._filterOptions.hasFilters() ? FilterOptions._filter(this._filterOptions.filter, paths.basename(resource.uri.fsPath)) : []; + resource.filteredMarkersCount = 0; + + for (const marker of resource.markers) { + marker.messageMatches = this._filterOptions.hasFilters() ? FilterOptions._fuzzyFilter(this._filterOptions.filter, marker.raw.message) : []; + marker.sourceMatches = marker.raw.source && this._filterOptions.hasFilters() ? FilterOptions._filter(this._filterOptions.filter, marker.raw.source) : []; + marker.isSelected = this.filterMarker(marker.raw); + if (marker.isSelected) { + resource.filteredMarkersCount += 1; + } + } + }); } - if (arg1 instanceof URI) { - this.updateResource(arg1, arg2); - } - if (types.isArray(arg1)) { - this.updateMarkers(arg1); - } - this.refresh(); } - private refresh(): void { - this.refreshResources(); - } + private createResource(uri: URI, rawMarkers: IMarker[]): Resource { - private refreshResources(): void { - this._nonFilteredResources = []; - this._filteredResources = []; - this.markersByResource.forEach((values, uri) => { - const filteredResource = this.toFilteredResource(URI.parse(uri), values); - if (filteredResource.markers.length) { - this._filteredResources.push(filteredResource); - } else { - this._nonFilteredResources.push(filteredResource); - } - }); - } + const markers: Marker[] = []; + const resource = new Resource(uri, markers); - private updateResource(resourceUri: URI, markers: IMarker[]) { - if (this.markersByResource.has(resourceUri.toString())) { - this.markersByResource.delete(resourceUri.toString()); - } - if (markers.length > 0) { - this.markersByResource.set(resourceUri.toString(), markers); - } - } + resource.filteredMarkersCount = 0; + resource.uriMatches = this._filterOptions.hasFilters() ? FilterOptions._filter(this._filterOptions.filter, paths.basename(uri.fsPath)) : []; - private updateMarkers(markers: IMarker[]) { - markers.forEach((marker: IMarker) => { - let uri: URI = marker.resource; - let markers: IMarker[] = this.markersByResource.get(uri.toString()); - if (!markers) { - markers = []; - this.markersByResource.set(uri.toString(), markers); - } + for (let i = 0; i < rawMarkers.length; i++) { + let marker = this.createMarker(rawMarkers[i], i, uri.toString()); markers.push(marker); - }); - } - - private toFilteredResource(uri: URI, values: IMarker[]) { - let markers: Marker[] = []; - for (let i = 0; i < values.length; i++) { - const m = values[i]; - if (uri.scheme !== Schemas.walkThrough && uri.scheme !== Schemas.walkThroughSnippet && (!this._filterOptions.hasFilters() || this.filterMarker(m))) { - markers.push(this.toMarker(m, i, uri.toString())); + if (marker.isSelected) { + resource.filteredMarkersCount += 1; } } - const matches = this._filterOptions.hasFilters() ? FilterOptions._filter(this._filterOptions.filter, paths.basename(uri.fsPath)) : []; - return new Resource(uri, matches || [], markers); + return resource; } - private toMarker(marker: IMarker, index: number, uri: string): Marker { - const labelMatches = this._filterOptions.hasFilters() ? FilterOptions._fuzzyFilter(this._filterOptions.filter, marker.message) : []; - const sourceMatches = marker.source && this._filterOptions.hasFilters() ? FilterOptions._filter(this._filterOptions.filter, marker.source) : []; - return new Marker(uri + index, marker, labelMatches || [], sourceMatches || []); + private createMarker(marker: IMarker, index: number, uri: string): Marker { + const res = new Marker(uri + index, marker); + res.messageMatches = this._filterOptions.hasFilters() ? FilterOptions._fuzzyFilter(this._filterOptions.filter, marker.message) : []; + res.sourceMatches = marker.source && this._filterOptions.hasFilters() ? FilterOptions._filter(this._filterOptions.filter, marker.source) : []; + res.isSelected = this.filterMarker(marker); + return res; } private filterMarker(marker: IMarker): boolean { + if (!this._filterOptions.hasFilters()) { + return true; + } + if (marker.resource.scheme === Schemas.walkThrough || marker.resource.scheme === Schemas.walkThroughSnippet) { + return false; + } if (this._filterOptions.filterErrors && Severity.Error === marker.severity) { return true; } @@ -301,9 +291,7 @@ export class MarkersModel { } public dispose(): void { - this.markersByResource.clear(); - this._filteredResources = []; - this._nonFilteredResources = []; + this._markersByResource.clear(); } public getMessage(): string { diff --git a/src/vs/workbench/parts/markers/electron-browser/markersElectronContributions.ts b/src/vs/workbench/parts/markers/electron-browser/markersElectronContributions.ts index 1c2bb45930218..fd27e672ab89d 100644 --- a/src/vs/workbench/parts/markers/electron-browser/markersElectronContributions.ts +++ b/src/vs/workbench/parts/markers/electron-browser/markersElectronContributions.ts @@ -64,7 +64,7 @@ function copyMessage(panelService: IPanelService) { if (activePanel instanceof MarkersPanel) { const element = (activePanel).getFocusElement(); if (element instanceof Marker) { - clipboard.writeText(element.marker.message); + clipboard.writeText(element.raw.message); } } } @@ -125,4 +125,4 @@ function registerAction(desc: IActionDescriptor) { win: keys.win }); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/parts/markers/test/common/markersModel.test.ts b/src/vs/workbench/parts/markers/test/common/markersModel.test.ts index eacdf1fcc13b9..005aa4146b816 100644 --- a/src/vs/workbench/parts/markers/test/common/markersModel.test.ts +++ b/src/vs/workbench/parts/markers/test/common/markersModel.test.ts @@ -11,6 +11,15 @@ import Severity from 'vs/base/common/severity'; import { IMarker } from 'vs/platform/markers/common/markers'; import { MarkersModel, Marker, Resource } from 'vs/workbench/parts/markers/common/markersModel'; +class TestMarkersModel extends MarkersModel { + + get filteredResources(): Resource[] { + let res: Resource[] = []; + this.forEachFilteredResource(resource => res.push(resource)); + return res; + } +} + suite('MarkersModel Test', () => { test('getFilteredResource return markers grouped by resource', function () { @@ -20,7 +29,7 @@ suite('MarkersModel Test', () => { let marker4 = aMarker('res3'); let marker5 = aMarker('res4'); let marker6 = aMarker('res2'); - let testObject = new MarkersModel([marker1, marker2, marker3, marker4, marker5, marker6]); + let testObject = new TestMarkersModel([marker1, marker2, marker3, marker4, marker5, marker6]); let actuals = testObject.filteredResources; @@ -52,7 +61,7 @@ suite('MarkersModel Test', () => { let marker4 = aMarker('b/res3'); let marker5 = aMarker('res4'); let marker6 = aMarker('c/res2', Severity.Info); - let testObject = new MarkersModel([marker1, marker2, marker3, marker4, marker5, marker6]); + let testObject = new TestMarkersModel([marker1, marker2, marker3, marker4, marker5, marker6]); let actuals = testObject.filteredResources.sort(MarkersModel.compare); @@ -71,7 +80,7 @@ suite('MarkersModel Test', () => { let marker4 = aMarker('b/res3'); let marker5 = aMarker('res4'); let marker6 = aMarker('c/res2'); - let testObject = new MarkersModel([marker1, marker2, marker3, marker4, marker5, marker6]); + let testObject = new TestMarkersModel([marker1, marker2, marker3, marker4, marker5, marker6]); let actuals = testObject.filteredResources.sort(MarkersModel.compare); @@ -99,25 +108,25 @@ suite('MarkersModel Test', () => { let marker13 = aWarningWithRange(5); let marker14 = anErrorWithRange(4); let marker15 = anErrorWithRange(8, 2, 8, 4); - let testObject = new MarkersModel([marker1, marker2, marker3, marker4, marker5, marker6, marker7, marker8, marker9, marker10, marker11, marker12, marker13, marker14, marker15]); + let testObject = new TestMarkersModel([marker1, marker2, marker3, marker4, marker5, marker6, marker7, marker8, marker9, marker10, marker11, marker12, marker13, marker14, marker15]); let actuals = testObject.filteredResources[0].markers.sort(MarkersModel.compare); - assert.equal(actuals[0].marker, marker6); - assert.equal(actuals[1].marker, marker14); - assert.equal(actuals[2].marker, marker7); - assert.equal(actuals[3].marker, marker9); - assert.equal(actuals[4].marker, marker11); - assert.equal(actuals[5].marker, marker3); - assert.equal(actuals[6].marker, marker15); - assert.equal(actuals[7].marker, marker10); - assert.equal(actuals[8].marker, marker2); - assert.equal(actuals[9].marker, marker13); - assert.equal(actuals[10].marker, marker1); - assert.equal(actuals[11].marker, marker8); - assert.equal(actuals[12].marker, marker5); - assert.equal(actuals[13].marker, marker12); - assert.equal(actuals[14].marker, marker4); + assert.equal(actuals[0].raw, marker6); + assert.equal(actuals[1].raw, marker14); + assert.equal(actuals[2].raw, marker7); + assert.equal(actuals[3].raw, marker9); + assert.equal(actuals[4].raw, marker11); + assert.equal(actuals[5].raw, marker3); + assert.equal(actuals[6].raw, marker15); + assert.equal(actuals[7].raw, marker10); + assert.equal(actuals[8].raw, marker2); + assert.equal(actuals[9].raw, marker13); + assert.equal(actuals[10].raw, marker1); + assert.equal(actuals[11].raw, marker8); + assert.equal(actuals[12].raw, marker5); + assert.equal(actuals[13].raw, marker12); + assert.equal(actuals[14].raw, marker4); }); test('toString()', function () { @@ -131,7 +140,7 @@ suite('MarkersModel Test', () => { function hasMarker(markers: Marker[], marker: IMarker): boolean { return markers.filter((m): boolean => { - return m.marker === marker; + return m.raw === marker; }).length === 1; } @@ -196,4 +205,4 @@ suite('MarkersModel Test', () => { source }; } -}); \ No newline at end of file +});