1
1
import type { ResolveValueQuery , ResolveValueQueryResult } from './resolve-value-query-format' ;
2
- import { staticSlicing } from '../../../slicing/static/static-slicer' ;
3
- import { reconstructToCode } from '../../../reconstruct/reconstruct' ;
4
- import { doNotAutoSelect } from '../../../reconstruct/auto-select/auto-select-defaults' ;
5
- import { makeMagicCommentHandler } from '../../../reconstruct/auto-select/magic-comments' ;
6
2
import { log } from '../../../util/log' ;
7
3
import type { BasicQueryData } from '../../base-query-format' ;
8
4
import { slicingCriterionToId } from '../../../slicing/criterion/parse' ;
@@ -13,30 +9,33 @@ export function fingerPrintOfQuery(query: ResolveValueQuery): string {
13
9
return JSON . stringify ( query ) ;
14
10
}
15
11
16
- export function executeResolveValueQuery ( { dataflow : { graph, environment } , ast } : BasicQueryData , queries : readonly ResolveValueQuery [ ] ) : ResolveValueQueryResult {
12
+ export function executeResolveValueQuery ( { dataflow : { graph, environment } } : BasicQueryData , queries : readonly ResolveValueQuery [ ] ) : ResolveValueQueryResult {
13
+ const idMap = graph . idMap ;
14
+
15
+ if ( ! idMap ) {
16
+ throw new Error ( 'idMap was undefined' ) ;
17
+ }
18
+
17
19
const start = Date . now ( ) ;
18
- const results : ResolveValueQueryResult [ 'results' ] = [ ] ;
20
+ const results : ResolveValueQueryResult [ 'results' ] = { } ;
19
21
for ( const query of queries ) {
20
22
const key = fingerPrintOfQuery ( query ) ;
21
23
22
24
if ( results [ key ] ) {
23
25
log . warn ( `Duplicate Key for slicing-query: ${ key } , skipping...` ) ;
24
26
}
25
27
26
- const ids = query . criteria . map ( criteria => slicingCriterionToId ( criteria , graph . idMap ! ) ) ;
28
+ const ids = query . criteria . map ( criteria => slicingCriterionToId ( criteria , idMap ) ) ;
27
29
const values = new Set < unknown > ( ) ;
28
30
29
- const resolveStart = Date . now ( ) ;
30
31
for ( const id of ids ) {
31
- resolveToValues ( recoverName ( id , graph . idMap ) , environment , graph )
32
- ?. forEach ( values . add ) ;
32
+ resolveToValues ( recoverName ( id , idMap ) , environment , graph )
33
+ ?. forEach ( v => values . add ( v ) ) ;
33
34
}
34
- const resolveEnd = Date . now ( ) ;
35
35
36
36
results [ key ] = {
37
- values : values . values ( ) ,
38
- '.meta' : { timing : resolveEnd - resolveStart }
39
- }
37
+ values : [ ...values ]
38
+ } ;
40
39
}
41
40
return {
42
41
'.meta' : {
0 commit comments