@@ -9,7 +9,7 @@ import * as types from 'vs/base/common/types';
99import Severity from 'vs/base/common/severity' ;
1010import URI from 'vs/base/common/uri' ;
1111import { Range , IRange } from 'vs/editor/common/core/range' ;
12- import { IMarker , MarkerStatistics } from 'vs/platform/markers/common/markers' ;
12+ import { IMarker } from 'vs/platform/markers/common/markers' ;
1313import { IFilter , IMatch , or , matchesContiguousSubString , matchesPrefix , matchesFuzzy } from 'vs/base/common/filters' ;
1414import Messages from 'vs/workbench/parts/markers/common/messages' ;
1515import { Schemas } from 'vs/base/common/network' ;
@@ -24,9 +24,12 @@ export class Resource {
2424 private _name : string = null ;
2525 private _path : string = null ;
2626
27- constructor ( public uri : URI , public markers : Marker [ ] ,
28- public statistics : MarkerStatistics ,
29- public matches : IMatch [ ] = [ ] ) {
27+ constructor (
28+ readonly uri : URI ,
29+ readonly uriMatches : IMatch [ ] = [ ] ,
30+ readonly markers : Marker [ ] ,
31+ ) {
32+ markers . sort ( Marker . compare ) ;
3033 }
3134
3235 public get path ( ) : string {
@@ -42,12 +45,29 @@ export class Resource {
4245 }
4346 return this . _name ;
4447 }
48+
49+ static compare ( a : Resource , b : Resource ) : number {
50+ let [ firstMarkerOfA ] = a . markers ;
51+ let [ firstMarkerOfB ] = b . markers ;
52+ let res = 0 ;
53+ if ( firstMarkerOfA && firstMarkerOfB ) {
54+ res = Severity . compare ( firstMarkerOfA . marker . severity , firstMarkerOfB . marker . severity ) ;
55+ }
56+ if ( res === 0 ) {
57+ res = a . path . localeCompare ( b . path ) || a . name . localeCompare ( b . name ) ;
58+ }
59+ return res ;
60+ }
4561}
4662
4763export class Marker {
48- constructor ( public id : string , public marker : IMarker ,
49- public labelMatches : IMatch [ ] = [ ] ,
50- public sourceMatches : IMatch [ ] = [ ] ) { }
64+
65+ constructor (
66+ readonly id : string ,
67+ readonly marker : IMarker ,
68+ readonly labelMatches : IMatch [ ] = [ ] ,
69+ readonly sourceMatches : IMatch [ ] = [ ]
70+ ) { }
5171
5272 public get resource ( ) : URI {
5373 return this . marker . resource ;
@@ -68,6 +88,10 @@ export class Marker {
6888 ] . join ( '\n' ) ;
6989 }
7090
91+ static compare ( a : Marker , b : Marker ) : number {
92+ return Severity . compare ( a . marker . severity , b . marker . severity )
93+ || Range . compareRangesUsingStarts ( a . marker , b . marker ) ;
94+ }
7195}
7296
7397export class FilterOptions {
@@ -171,10 +195,6 @@ export class MarkersModel {
171195 return count ;
172196 }
173197
174- public get nonFilteredResources ( ) : Resource [ ] {
175- return this . _nonFilteredResources ;
176- }
177-
178198 public getBulkUpdater ( ) : BulkUpdater {
179199 return {
180200 add : ( resourceUri : URI , markers : IMarker [ ] ) => {
@@ -189,19 +209,16 @@ export class MarkersModel {
189209 public update ( filterOptions : FilterOptions ) : void ;
190210 public update ( resourceUri : URI , markers : IMarker [ ] ) : void ;
191211 public update ( markers : IMarker [ ] ) : void ;
192- public update ( arg1 ?: any , arg2 ?: any ) {
212+ public update ( arg1 ?: FilterOptions | URI | IMarker [ ] , arg2 ?: IMarker [ ] ) {
193213 if ( arg1 instanceof FilterOptions ) {
194214 this . _filterOptions = arg1 ;
195215 }
196-
197216 if ( arg1 instanceof URI ) {
198217 this . updateResource ( arg1 , arg2 ) ;
199218 }
200-
201219 if ( types . isArray ( arg1 ) ) {
202220 this . updateMarkers ( arg1 ) ;
203221 }
204-
205222 this . refresh ( ) ;
206223 }
207224
@@ -252,7 +269,7 @@ export class MarkersModel {
252269 }
253270 }
254271 const matches = this . _filterOptions . hasFilters ( ) ? FilterOptions . _filter ( this . _filterOptions . filter , paths . basename ( uri . fsPath ) ) : [ ] ;
255- return new Resource ( uri , markers , this . getStatistics ( values ) , matches || [ ] ) ;
272+ return new Resource ( uri , matches || [ ] , markers ) ;
256273 }
257274
258275 private toMarker ( marker : IMarker , index : number , uri : string ) : Marker {
@@ -283,27 +300,6 @@ export class MarkersModel {
283300 return false ;
284301 }
285302
286- private getStatistics ( markers : IMarker [ ] ) : MarkerStatistics {
287- let errors = 0 , warnings = 0 , infos = 0 , unknowns = 0 ;
288- for ( const marker of markers ) {
289- switch ( marker . severity ) {
290- case Severity . Error :
291- errors ++ ;
292- break ;
293- case Severity . Warning :
294- warnings ++ ;
295- break ;
296- case Severity . Info :
297- infos ++ ;
298- break ;
299- default :
300- unknowns ++ ;
301- break ;
302- }
303- }
304- return { errors, warnings, infos, unknowns } ;
305- }
306-
307303 public dispose ( ) : void {
308304 this . markersByResource . clear ( ) ;
309305 this . _filteredResources = [ ] ;
@@ -324,28 +320,11 @@ export class MarkersModel {
324320
325321 public static compare ( a : any , b : any ) : number {
326322 if ( a instanceof Resource && b instanceof Resource ) {
327- return MarkersModel . compareResources ( a , b ) ;
323+ return Resource . compare ( a , b ) ;
328324 }
329325 if ( a instanceof Marker && b instanceof Marker ) {
330- return MarkersModel . compareMarkers ( a , b ) ;
326+ return Marker . compare ( a , b ) ;
331327 }
332328 return 0 ;
333329 }
334-
335- private static compareResources ( a : Resource , b : Resource ) : number {
336- if ( a . statistics . errors === 0 && b . statistics . errors > 0 ) {
337- return 1 ;
338- }
339- if ( b . statistics . errors === 0 && a . statistics . errors > 0 ) {
340- return - 1 ;
341- }
342- return a . path . localeCompare ( b . path ) || a . name . localeCompare ( b . name ) ;
343- }
344-
345- private static compareMarkers ( a : Marker , b : Marker ) : number {
346- if ( a . marker . severity === b . marker . severity ) {
347- return Range . compareRangesUsingStarts ( a . marker , b . marker ) ;
348- }
349- return a . marker . severity > b . marker . severity ? - 1 : 1 ;
350- }
351- }
330+ }
0 commit comments