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 } ` ) ;
@@ -62,9 +45,7 @@ async function* getChunkIterator(response: Response): AsyncIterableIterator<Uint
6245 }
6346}
6447
65- function translatePrimitiveValue ( value : PrimitiveColumnValue , type : PrimitiveTypeKind ) :
66- ResultValue {
67-
48+ function translatePrimitiveValue ( value : PrimitiveColumnValue , type : PrimitiveTypeKind ) : ResultValue {
6849 switch ( type ) {
6950 case 'i' :
7051 case 'f' :
@@ -127,6 +108,7 @@ async function parseResultSets(response: Response): Promise<readonly ResultSet[]
127108
128109interface ResultsInfo {
129110 resultsPath : string ;
111+ resultSets : ResultSet [ ] | undefined ;
130112 origResultsPaths : ResultsPaths ;
131113 database : DatabaseInfo ;
132114 interpretation : Interpretation | undefined ;
@@ -187,6 +169,7 @@ class App extends React.Component<{}, ResultsViewState> {
187169 case 'setState' :
188170 this . updateStateWithNewResultsInfo ( {
189171 resultsPath : msg . resultsPath ,
172+ resultSets : msg . resultSets ?. map ( x => ( { t : 'RawResultSet' , ...x } ) ) ,
190173 origResultsPaths : msg . origResultsPaths ,
191174 sortedResultsMap : new Map ( Object . entries ( msg . sortedResultsMap ) ) ,
192175 database : msg . database ,
@@ -247,8 +230,9 @@ class App extends React.Component<{}, ResultsViewState> {
247230 let results : Results | null = null ;
248231 let statusText = '' ;
249232 try {
233+ const resultSets = resultsInfo . resultSets || await this . getResultSets ( resultsInfo ) ;
250234 results = {
251- resultSets : await this . getResultSets ( resultsInfo ) ,
235+ resultSets,
252236 database : resultsInfo . database ,
253237 sortStates : this . getSortStates ( resultsInfo )
254238 } ;
0 commit comments