1
1
import * as React from 'react' ;
2
2
import * as Rdom from 'react-dom' ;
3
3
import * 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' ;
5
5
import { assertNever } from '../helpers-pure' ;
6
6
import { DatabaseInfo , FromResultsViewMsg , Interpretation , IntoResultsViewMsg , SortedResultSetInfo , RawResultsSortState , NavigatePathMsg , QueryMetadata , ResultsPaths } from '../interface-types' ;
7
7
import { EventHandlers as EventHandlerList } from './event-handler-list' ;
8
8
import { ResultTables } from './result-tables' ;
9
+ import { RawResultSet , ResultValue , ResultRow } from '../adapt' ;
9
10
10
11
/**
11
12
* results.tsx
@@ -23,31 +24,13 @@ interface VsCodeApi {
23
24
declare const acquireVsCodeApi : ( ) => VsCodeApi ;
24
25
export const vscode = acquireVsCodeApi ( ) ;
25
26
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
-
39
27
export type RawTableResultSet = { t : 'RawResultSet' } & RawResultSet ;
40
28
export type PathTableResultSet = { t : 'SarifResultSet' ; readonly schema : ResultSetSchema ; name : string } & Interpretation ;
41
29
42
30
export type ResultSet =
43
31
| RawTableResultSet
44
32
| PathTableResultSet ;
45
33
46
- export interface RawResultSet {
47
- readonly schema : ResultSetSchema ;
48
- readonly rows : readonly ResultRow [ ] ;
49
- }
50
-
51
34
async function * getChunkIterator ( response : Response ) : AsyncIterableIterator < Uint8Array > {
52
35
if ( ! response . ok ) {
53
36
throw new Error ( `Failed to load results: (${ response . status } ) ${ response . statusText } ` ) ;
@@ -62,9 +45,7 @@ async function* getChunkIterator(response: Response): AsyncIterableIterator<Uint
62
45
}
63
46
}
64
47
65
- function translatePrimitiveValue ( value : PrimitiveColumnValue , type : PrimitiveTypeKind ) :
66
- ResultValue {
67
-
48
+ function translatePrimitiveValue ( value : PrimitiveColumnValue , type : PrimitiveTypeKind ) : ResultValue {
68
49
switch ( type ) {
69
50
case 'i' :
70
51
case 'f' :
@@ -127,6 +108,7 @@ async function parseResultSets(response: Response): Promise<readonly ResultSet[]
127
108
128
109
interface ResultsInfo {
129
110
resultsPath : string ;
111
+ resultSets : ResultSet [ ] | undefined ;
130
112
origResultsPaths : ResultsPaths ;
131
113
database : DatabaseInfo ;
132
114
interpretation : Interpretation | undefined ;
@@ -187,6 +169,7 @@ class App extends React.Component<{}, ResultsViewState> {
187
169
case 'setState' :
188
170
this . updateStateWithNewResultsInfo ( {
189
171
resultsPath : msg . resultsPath ,
172
+ resultSets : msg . resultSets ?. map ( x => ( { t : 'RawResultSet' , ...x } ) ) ,
190
173
origResultsPaths : msg . origResultsPaths ,
191
174
sortedResultsMap : new Map ( Object . entries ( msg . sortedResultsMap ) ) ,
192
175
database : msg . database ,
@@ -247,8 +230,9 @@ class App extends React.Component<{}, ResultsViewState> {
247
230
let results : Results | null = null ;
248
231
let statusText = '' ;
249
232
try {
233
+ const resultSets = resultsInfo . resultSets || await this . getResultSets ( resultsInfo ) ;
250
234
results = {
251
- resultSets : await this . getResultSets ( resultsInfo ) ,
235
+ resultSets,
252
236
database : resultsInfo . database ,
253
237
sortStates : this . getSortStates ( resultsInfo )
254
238
} ;
0 commit comments