@@ -10,7 +10,7 @@ import { CodeQLCliServer } from './cli';
1010import { DatabaseItem , DatabaseManager } from './databases' ;
1111import { showAndLogErrorMessage } from './helpers' ;
1212import { assertNever } from './helpers-pure' ;
13- import { FromResultsViewMsg , Interpretation , INTERPRETED_RESULTS_PER_RUN_LIMIT , IntoResultsViewMsg , QueryMetadata , ResultsPaths , SortedResultSetInfo , SortedResultsMap } from './interface-types' ;
13+ import { FromResultsViewMsg , Interpretation , INTERPRETED_RESULTS_PER_RUN_LIMIT , IntoResultsViewMsg , QueryMetadata , ResultsPaths , SortedResultSetInfo , SortedResultsMap , InterpretedResultsSortState } from './interface-types' ;
1414import { Logger } from './logging' ;
1515import * as messages from './messages' ;
1616import { CompletedQuery , interpretResults } from './query-results' ;
@@ -190,6 +190,17 @@ export class InterfaceManager extends DisposableObject {
190190 await this . showResults ( this . _displayedQuery , WebviewReveal . NotForced , true ) ;
191191 break ;
192192 }
193+ case 'changeInterpretedSort' : {
194+ if ( this . _displayedQuery === undefined ) {
195+ showAndLogErrorMessage ( "Failed to sort results since evaluation info was unknown." ) ;
196+ break ;
197+ }
198+ // Notify the webview that it should expect new results.
199+ await this . postMessage ( { t : 'resultsUpdating' } ) ;
200+ await this . _displayedQuery . updateInterpretedSortState ( this . cliServer , msg . sortState ) ;
201+ await this . showResults ( this . _displayedQuery , WebviewReveal . NotForced , true ) ;
202+ break ;
203+ }
193204 default :
194205 assertNever ( msg ) ;
195206 }
@@ -223,7 +234,7 @@ export class InterfaceManager extends DisposableObject {
223234 return ;
224235 }
225236
226- const interpretation = await this . interpretResultsInfo ( results . query ) ;
237+ const interpretation = await this . interpretResultsInfo ( results . query , results . interpretedResultsSortState ) ;
227238
228239 const sortedResultsMap : SortedResultsMap = { } ;
229240 results . sortedResultsInfo . forEach ( ( v , k ) =>
@@ -268,7 +279,7 @@ export class InterfaceManager extends DisposableObject {
268279 } ) ;
269280 }
270281
271- private async getTruncatedResults ( metadata : QueryMetadata | undefined , resultsPaths : ResultsPaths , sourceInfo : cli . SourceInfo | undefined , sourceLocationPrefix : string ) : Promise < Interpretation > {
282+ private async getTruncatedResults ( metadata : QueryMetadata | undefined , resultsPaths : ResultsPaths , sourceInfo : cli . SourceInfo | undefined , sourceLocationPrefix : string , sortState : InterpretedResultsSortState ) : Promise < Interpretation > {
272283 const sarif = await interpretResults ( this . cliServer , metadata , resultsPaths . resultsPath , sourceInfo ) ;
273284 // For performance reasons, limit the number of results we try
274285 // to serialize and send to the webview. TODO: possibly also
@@ -285,11 +296,10 @@ export class InterfaceManager extends DisposableObject {
285296 }
286297 }
287298 } ) ;
288- return { sarif, sourceLocationPrefix, numTruncatedResults } ;
289- ;
299+ return { sarif, sourceLocationPrefix, numTruncatedResults, sortState } ;
290300 }
291301
292- private async interpretResultsInfo ( query : QueryInfo ) : Promise < Interpretation | undefined > {
302+ private async interpretResultsInfo ( query : QueryInfo , sortState : InterpretedResultsSortState ) : Promise < Interpretation | undefined > {
293303 let interpretation : Interpretation | undefined = undefined ;
294304 if ( await query . hasInterpretedResults ( )
295305 && query . quickEvalPosition === undefined // never do results interpretation if quickEval
@@ -300,7 +310,7 @@ export class InterfaceManager extends DisposableObject {
300310 const sourceInfo = sourceArchiveUri === undefined ?
301311 undefined :
302312 { sourceArchive : sourceArchiveUri . fsPath , sourceLocationPrefix } ;
303- interpretation = await this . getTruncatedResults ( query . metadata , query . resultsPaths , sourceInfo , sourceLocationPrefix ) ;
313+ interpretation = await this . getTruncatedResults ( query . metadata , query . resultsPaths , sourceInfo , sourceLocationPrefix , sortState ) ;
304314 }
305315 catch ( e ) {
306316 // If interpretation fails, accept the error and continue
@@ -318,7 +328,13 @@ export class InterfaceManager extends DisposableObject {
318328 const sourceInfo = sourceArchiveUri === undefined ?
319329 undefined :
320330 { sourceArchive : sourceArchiveUri . fsPath , sourceLocationPrefix } ;
321- const interpretation = await this . getTruncatedResults ( metadata , resultsInfo , sourceInfo , sourceLocationPrefix ) ;
331+ const interpretation = await this . getTruncatedResults (
332+ metadata ,
333+ resultsInfo ,
334+ sourceInfo ,
335+ sourceLocationPrefix ,
336+ { sortBy : 'file-position' } // sort order doesn't matter for showing diagnostics in parallel
337+ ) ;
322338
323339 try {
324340 await this . showProblemResultsAsDiagnostics ( interpretation , database ) ;
0 commit comments