@@ -19,7 +19,6 @@ import { assertNever } from './helpers-pure';
1919import {
2020 FromResultsViewMsg ,
2121 Interpretation ,
22- INTERPRETED_RESULTS_PER_RUN_LIMIT ,
2322 IntoResultsViewMsg ,
2423 QueryMetadata ,
2524 ResultsPaths ,
@@ -28,6 +27,7 @@ import {
2827 InterpretedResultsSortState ,
2928 SortDirection ,
3029 RAW_RESULTS_PAGE_SIZE ,
30+ INTERPRETED_RESULTS_PAGE_SIZE ,
3131} from './interface-types' ;
3232import { Logger } from './logging' ;
3333import * as messages from './messages' ;
@@ -459,6 +459,10 @@ export class InterfaceManager extends DisposableObject {
459459 resultsPaths ,
460460 sourceInfo
461461 ) ;
462+ sarif . runs . forEach ( run => {
463+ if ( run . results !== undefined )
464+ sortInterpretedResults ( run . results , sortState ) ;
465+ } ) ;
462466 const interpretation : Interpretation = {
463467 sarif,
464468 sourceLocationPrefix,
@@ -469,38 +473,36 @@ export class InterfaceManager extends DisposableObject {
469473 return interpretation ;
470474 }
471475
472- private async getTruncatedResults (
473- metadata : QueryMetadata | undefined ,
474- resultsPaths : ResultsPaths ,
475- sourceInfo : cli . SourceInfo | undefined ,
476- sourceLocationPrefix : string ,
477- sortState : InterpretedResultsSortState | undefined
478- ) : Promise < Interpretation > {
479- // For performance reasons, limit the number of results we try
480- // to serialize and send to the webview. TODO: possibly also
481- // limit number of paths per result, number of steps per path,
482- // or throw an error if we are in aggregate trying to send
483- // massively too much data, as it can make the extension
484- // unresponsive.
485- const interpretation = await this . _getInterpretedResults ( metadata , resultsPaths , sourceInfo , sourceLocationPrefix , sortState ) ;
486- interpretation . sarif . runs . forEach ( ( run ) => {
487- if ( run . results !== undefined ) {
488- sortInterpretedResults ( run . results , sortState ) ;
489- if ( run . results . length > INTERPRETED_RESULTS_PER_RUN_LIMIT ) {
490- interpretation . numTruncatedResults +=
491- run . results . length - INTERPRETED_RESULTS_PER_RUN_LIMIT ;
492- run . results = run . results . slice ( 0 , INTERPRETED_RESULTS_PER_RUN_LIMIT ) ;
493- }
476+ private getPageOfInterpretedResults (
477+ pageNumber : number
478+ ) : Interpretation {
479+
480+ function getPageOfRun ( run : Sarif . Run ) : Sarif . Run {
481+ return {
482+ ...run , results : run . results ?. slice (
483+ INTERPRETED_RESULTS_PAGE_SIZE * pageNumber ,
484+ INTERPRETED_RESULTS_PAGE_SIZE * ( pageNumber + 1 )
485+ )
494486 }
495- } ) ;
496- return interpretation ;
487+ }
488+
489+ if ( this . _interpretation === undefined ) {
490+ throw new Error ( 'Tried to get interpreted results before interpretation finished' ) ;
491+ }
492+ if ( this . _interpretation . sarif . runs . length !== 1 ) {
493+ this . logger . log ( `Warning: SARIF file had ${ this . _interpretation . sarif . runs . length } runs, expected 1` ) ;
494+ }
495+ const interp = this . _interpretation ;
496+ return {
497+ ...interp ,
498+ sarif : { ...interp . sarif , runs : [ getPageOfRun ( interp . sarif . runs [ 0 ] ) ] } ,
499+ }
497500 }
498501
499502 private async interpretResultsInfo (
500503 query : QueryInfo ,
501504 sortState : InterpretedResultsSortState | undefined
502505 ) : Promise < Interpretation | undefined > {
503- let interpretation : Interpretation | undefined = undefined ;
504506 if (
505507 ( await query . canHaveInterpretedResults ( ) ) &&
506508 query . quickEvalPosition === undefined // never do results interpretation if quickEval
@@ -517,7 +519,7 @@ export class InterfaceManager extends DisposableObject {
517519 sourceArchive : sourceArchiveUri . fsPath ,
518520 sourceLocationPrefix,
519521 } ;
520- interpretation = await this . getTruncatedResults (
522+ await this . _getInterpretedResults (
521523 query . metadata ,
522524 query . resultsPaths ,
523525 sourceInfo ,
@@ -532,7 +534,7 @@ export class InterfaceManager extends DisposableObject {
532534 ) ;
533535 }
534536 }
535- return interpretation ;
537+ return this . getPageOfInterpretedResults ( 0 ) ;
536538 }
537539
538540 private async showResultsAsDiagnostics (
@@ -551,7 +553,8 @@ export class InterfaceManager extends DisposableObject {
551553 sourceArchive : sourceArchiveUri . fsPath ,
552554 sourceLocationPrefix,
553555 } ;
554- const interpretation = await this . getTruncatedResults (
556+ // TODO: Performance-testing to determine whether this truncation is necessary.
557+ const interpretation = await this . _getInterpretedResults (
555558 metadata ,
556559 resultsInfo ,
557560 sourceInfo ,
0 commit comments