@@ -30,7 +30,6 @@ export const tmpDirDisposal = {
3030 }
3131} ;
3232
33- let queryCounter = 0 ;
3433
3534export class UserCancellationException extends Error { }
3635
@@ -43,30 +42,32 @@ export class UserCancellationException extends Error { }
4342export class QueryInfo {
4443 compiledQueryPath : string ;
4544 resultsInfo : ResultsInfo ;
45+ private static nextQueryId = 0 ;
46+
4647 /**
4748 * Map from result set name to SortedResultSetInfo.
4849 */
4950 sortedResultsInfo : Map < string , SortedResultSetInfo > ;
5051 dataset : vscode . Uri ; // guarantee the existence of a well-defined dataset dir at this point
51-
52+ queryId : number ;
5253 constructor (
5354 public program : messages . QlProgram ,
5455 public dbItem : DatabaseItem ,
5556 public queryDbscheme : string , // the dbscheme file the query expects, based on library path resolution
5657 public quickEvalPosition ?: messages . Position ,
5758 public metadata ?: cli . QueryMetadata ,
5859 ) {
59- this . compiledQueryPath = path . join ( tmpDir . name , `compiledQuery${ queryCounter } .qlo` ) ;
60+ this . queryId = QueryInfo . nextQueryId ++ ;
61+ this . compiledQueryPath = path . join ( tmpDir . name , `compiledQuery${ this . queryId } .qlo` ) ;
6062 this . resultsInfo = {
61- resultsPath : path . join ( tmpDir . name , `results${ queryCounter } .bqrs` ) ,
62- interpretedResultsPath : path . join ( tmpDir . name , `interpretedResults${ queryCounter } .sarif` )
63+ resultsPath : path . join ( tmpDir . name , `results${ this . queryId } .bqrs` ) ,
64+ interpretedResultsPath : path . join ( tmpDir . name , `interpretedResults${ this . queryId } .sarif` )
6365 } ;
6466 this . sortedResultsInfo = new Map ( ) ;
6567 if ( dbItem . contents === undefined ) {
6668 throw new Error ( 'Can\'t run query on invalid database.' ) ;
6769 }
6870 this . dataset = dbItem . contents . datasetUri ;
69- queryCounter ++ ;
7071 }
7172
7273 async run (
@@ -160,7 +161,7 @@ export class QueryInfo {
160161 }
161162
162163 const sortedResultSetInfo : SortedResultSetInfo = {
163- resultsPath : path . join ( tmpDir . name , `sortedResults${ queryCounter } -${ resultSetName } .bqrs` ) ,
164+ resultsPath : path . join ( tmpDir . name , `sortedResults${ this . queryId } -${ resultSetName } .bqrs` ) ,
164165 sortState
165166 } ;
166167
0 commit comments