@@ -95,7 +95,11 @@ export class LocalQueries extends DisposableObject {
9595 public getCommands ( ) : LocalQueryCommands {
9696 return {
9797 "codeQL.runQuery" : this . runQuery . bind ( this ) ,
98+ "codeQL.runPopulateUnderlayQuery" :
99+ this . runPopulateUnderlayQuery . bind ( this ) ,
98100 "codeQL.runQueryContextEditor" : this . runQuery . bind ( this ) ,
101+ "codeQL.runPopulateUnderlayQueryContextEditor" :
102+ this . runPopulateUnderlayQuery . bind ( this ) ,
99103 "codeQL.runQueryOnMultipleDatabases" :
100104 this . runQueryOnMultipleDatabases . bind ( this ) ,
101105 "codeQL.runQueryOnMultipleDatabasesContextEditor" :
@@ -113,7 +117,12 @@ export class LocalQueries extends DisposableObject {
113117 "codeQL.runQueries" : createMultiSelectionCommand (
114118 this . runQueries . bind ( this ) ,
115119 ) ,
120+ "codeQL.runPopulateUnderlayQueries" : createMultiSelectionCommand (
121+ this . runPopulateUnderlayQueries . bind ( this ) ,
122+ ) ,
116123 "codeQL.runQuerySuite" : this . runQuerySuite . bind ( this ) ,
124+ "codeQL.runPopulateUnderlayQuerySuite" :
125+ this . runPopulateUnderlayQuerySuite . bind ( this ) ,
117126 "codeQL.quickEval" : this . quickEval . bind ( this ) ,
118127 "codeQL.quickEvalCount" : this . quickEvalCount . bind ( this ) ,
119128 "codeQL.quickEvalContextEditor" : this . quickEval . bind ( this ) ,
@@ -152,6 +161,16 @@ export class LocalQueries extends DisposableObject {
152161 }
153162
154163 private async runQuery ( uri : Uri | undefined ) : Promise < void > {
164+ await this . runQueryInternal ( uri , false ) ;
165+ }
166+ private async runPopulateUnderlayQuery ( uri : Uri | undefined ) : Promise < void > {
167+ await this . runQueryInternal ( uri , true ) ;
168+ }
169+
170+ private async runQueryInternal (
171+ uri : Uri | undefined ,
172+ onlyPopulateUnderlay : boolean ,
173+ ) : Promise < void > {
155174 await withProgress (
156175 async ( progress , token ) => {
157176 await this . compileAndRunQuery (
@@ -160,10 +179,13 @@ export class LocalQueries extends DisposableObject {
160179 progress ,
161180 token ,
162181 undefined ,
182+ onlyPopulateUnderlay ,
163183 ) ;
164184 } ,
165185 {
166- title : "Running query" ,
186+ title : onlyPopulateUnderlay
187+ ? "Populate database underlay for query"
188+ : "Running query" ,
167189 cancellable : true ,
168190 } ,
169191 ) ;
@@ -181,8 +203,18 @@ export class LocalQueries extends DisposableObject {
181203 } ,
182204 ) ;
183205 }
184-
185206 private async runQueries ( fileURIs : Uri [ ] ) : Promise < void > {
207+ await this . runQueriesInternal ( fileURIs , false ) ;
208+ }
209+
210+ private async runPopulateUnderlayQueries ( fileURIs : Uri [ ] ) : Promise < void > {
211+ await this . runQueriesInternal ( fileURIs , true ) ;
212+ }
213+
214+ private async runQueriesInternal (
215+ fileURIs : Uri [ ] ,
216+ onlyPopulateUnderlay : boolean ,
217+ ) : Promise < void > {
186218 await withProgress (
187219 async ( progress , token ) => {
188220 const maxQueryCount = MAX_QUERIES . getValue < number > ( ) ;
@@ -235,18 +267,32 @@ export class LocalQueries extends DisposableObject {
235267 wrappedProgress ,
236268 token ,
237269 undefined ,
270+ onlyPopulateUnderlay ,
238271 ) . then ( ( ) => queriesRemaining -- ) ,
239272 ) ,
240273 ) ;
241274 } ,
242275 {
243- title : "Running queries" ,
276+ title : onlyPopulateUnderlay
277+ ? "Populate database underlay for queries"
278+ : "Running queries" ,
244279 cancellable : true ,
245280 } ,
246281 ) ;
247282 }
248283
249284 private async runQuerySuite ( fileUri : Uri ) : Promise < void > {
285+ await this . runQuerySuiteInternal ( fileUri , false ) ;
286+ }
287+
288+ private async runPopulateUnderlayQuerySuite ( fileUri : Uri ) : Promise < void > {
289+ await this . runQuerySuiteInternal ( fileUri , true ) ;
290+ }
291+
292+ private async runQuerySuiteInternal (
293+ fileUri : Uri ,
294+ onlyPopulateUnderlay : boolean ,
295+ ) : Promise < void > {
250296 await withProgress (
251297 async ( progress , token ) => {
252298 const suitePath = validateQuerySuiteUri ( fileUri ) ;
@@ -286,6 +332,9 @@ export class LocalQueries extends DisposableObject {
286332 true ,
287333 additionalPacks ,
288334 extensionPacks ,
335+ onlyPopulateUnderlay ,
336+ onlyPopulateUnderlay ,
337+ onlyPopulateUnderlay ,
289338 { } ,
290339 this . queryStorageDir ,
291340 basename ( suitePath ) ,
@@ -310,7 +359,8 @@ export class LocalQueries extends DisposableObject {
310359 localQueryRun . logger ,
311360 ) ;
312361
313- await localQueryRun . complete ( results , progress ) ;
362+ if ( ! onlyPopulateUnderlay )
363+ await localQueryRun . complete ( results , progress ) ;
314364
315365 return results ;
316366 } catch ( e ) {
@@ -328,7 +378,9 @@ export class LocalQueries extends DisposableObject {
328378 }
329379 } ,
330380 {
331- title : "Running query suite" ,
381+ title : onlyPopulateUnderlay
382+ ? "Populate database underlay for query suite"
383+ : "Running query suite" ,
332384 cancellable : true ,
333385 } ,
334386 ) ;
@@ -343,6 +395,7 @@ export class LocalQueries extends DisposableObject {
343395 progress ,
344396 token ,
345397 undefined ,
398+ false ,
346399 ) ;
347400 } ,
348401 {
@@ -361,6 +414,7 @@ export class LocalQueries extends DisposableObject {
361414 progress ,
362415 token ,
363416 undefined ,
417+ false ,
364418 ) ;
365419 } ,
366420 {
@@ -379,6 +433,7 @@ export class LocalQueries extends DisposableObject {
379433 progress ,
380434 token ,
381435 undefined ,
436+ false ,
382437 range ,
383438 ) ,
384439 {
@@ -489,6 +544,7 @@ export class LocalQueries extends DisposableObject {
489544 progress : ProgressCallback ,
490545 token : CancellationToken ,
491546 databaseItem : DatabaseItem | undefined ,
547+ onlyPopulateUnderlay : boolean ,
492548 range ?: Range ,
493549 templates ?: Record < string , string > ,
494550 ) : Promise < void > {
@@ -500,6 +556,7 @@ export class LocalQueries extends DisposableObject {
500556 databaseItem ,
501557 range ,
502558 templates ,
559+ onlyPopulateUnderlay ,
503560 ) ;
504561 }
505562
@@ -512,6 +569,7 @@ export class LocalQueries extends DisposableObject {
512569 databaseItem : DatabaseItem | undefined ,
513570 range ?: Range ,
514571 templates ?: Record < string , string > ,
572+ onlyPopulateUnderlay : boolean = false ,
515573 ) : Promise < CoreCompletedQuery > {
516574 await saveBeforeStart ( ) ;
517575
@@ -558,6 +616,9 @@ export class LocalQueries extends DisposableObject {
558616 true ,
559617 additionalPacks ,
560618 extensionPacks ,
619+ onlyPopulateUnderlay ,
620+ onlyPopulateUnderlay ,
621+ onlyPopulateUnderlay ,
561622 { } ,
562623 this . queryStorageDir ,
563624 basename ( selectedQuery . queryPath ) ,
@@ -583,7 +644,8 @@ export class LocalQueries extends DisposableObject {
583644 localQueryRun . logger ,
584645 ) ;
585646
586- await localQueryRun . complete ( results , progress ) ;
647+ if ( ! onlyPopulateUnderlay )
648+ await localQueryRun . complete ( results , progress ) ;
587649
588650 return results ;
589651 } catch ( e ) {
@@ -656,6 +718,7 @@ export class LocalQueries extends DisposableObject {
656718 progress ,
657719 token ,
658720 item . databaseItem ,
721+ false ,
659722 ) ;
660723 } catch ( e ) {
661724 skippedDatabases . push ( item . label ) ;
0 commit comments