11import * as React from 'react' ;
22import * as Rdom from 'react-dom' ;
33import * as bqrs from 'semmle-bqrs' ;
4- import { ElementBase , LocationValue , PrimitiveColumnValue , PrimitiveTypeKind , ResultSetSchema , tryGetResolvableLocation } from 'semmle-bqrs' ;
4+ import { ElementBase , PrimitiveColumnValue , PrimitiveTypeKind , ResultSetSchema , tryGetResolvableLocation } from 'semmle-bqrs' ;
55import { assertNever } from '../helpers-pure' ;
66import { DatabaseInfo , FromResultsViewMsg , Interpretation , IntoResultsViewMsg , SortedResultSetInfo , RawResultsSortState , NavigatePathMsg , QueryMetadata , ResultsPaths } from '../interface-types' ;
77import { EventHandlers as EventHandlerList } from './event-handler-list' ;
88import { ResultTables } from './result-tables' ;
9+ import { RawResultSet , ResultValue , ResultRow } from '../adapt' ;
910
1011/**
1112 * results.tsx
@@ -23,31 +24,13 @@ interface VsCodeApi {
2324declare const acquireVsCodeApi : ( ) => VsCodeApi ;
2425export const vscode = acquireVsCodeApi ( ) ;
2526
26- export interface ResultElement {
27- label : string ;
28- location ?: LocationValue ;
29- }
30-
31- export interface ResultUri {
32- uri : string ;
33- }
34-
35- export type ResultValue = ResultElement | ResultUri | string ;
36-
37- export type ResultRow = ResultValue [ ] ;
38-
3927export type RawTableResultSet = { t : 'RawResultSet' } & RawResultSet ;
4028export type PathTableResultSet = { t : 'SarifResultSet' ; readonly schema : ResultSetSchema ; name : string } & Interpretation ;
4129
4230export type ResultSet =
4331 | RawTableResultSet
4432 | PathTableResultSet ;
4533
46- export interface RawResultSet {
47- readonly schema : ResultSetSchema ;
48- readonly rows : readonly ResultRow [ ] ;
49- }
50-
5134async function * getChunkIterator ( response : Response ) : AsyncIterableIterator < Uint8Array > {
5235 if ( ! response . ok ) {
5336 throw new Error ( `Failed to load results: (${ response . status } ) ${ response . statusText } ` ) ;
@@ -63,7 +46,7 @@ async function* getChunkIterator(response: Response): AsyncIterableIterator<Uint
6346}
6447
6548function translatePrimitiveValue ( value : PrimitiveColumnValue , type : PrimitiveTypeKind ) :
66- ResultValue {
49+ ResultValue {
6750
6851 switch ( type ) {
6952 case 'i' :
@@ -127,6 +110,7 @@ async function parseResultSets(response: Response): Promise<readonly ResultSet[]
127110
128111interface ResultsInfo {
129112 resultsPath : string ;
113+ resultSets : ResultSet [ ] | undefined ;
130114 origResultsPaths : ResultsPaths ;
131115 database : DatabaseInfo ;
132116 interpretation : Interpretation | undefined ;
@@ -187,6 +171,7 @@ class App extends React.Component<{}, ResultsViewState> {
187171 case 'setState' :
188172 this . updateStateWithNewResultsInfo ( {
189173 resultsPath : msg . resultsPath ,
174+ resultSets : msg . resultSets ?. map ( x => ( { t : 'RawResultSet' , ...x } ) ) ,
190175 origResultsPaths : msg . origResultsPaths ,
191176 sortedResultsMap : new Map ( Object . entries ( msg . sortedResultsMap ) ) ,
192177 database : msg . database ,
@@ -247,8 +232,9 @@ class App extends React.Component<{}, ResultsViewState> {
247232 let results : Results | null = null ;
248233 let statusText = '' ;
249234 try {
235+ const resultSets = resultsInfo . resultSets || await this . getResultSets ( resultsInfo ) ;
250236 results = {
251- resultSets : await this . getResultSets ( resultsInfo ) ,
237+ resultSets,
252238 database : resultsInfo . database ,
253239 sortStates : this . getSortStates ( resultsInfo )
254240 } ;
0 commit comments