@@ -29,7 +29,7 @@ import {
2929 QueryServerConfigListener
3030} from './config' ;
3131import * as languageSupport from './languageSupport' ;
32- import { DatabaseManager } from './databases' ;
32+ import { DatabaseItem , DatabaseManager } from './databases' ;
3333import { DatabaseUI } from './databases-ui' ;
3434import {
3535 TemplateQueryDefinitionProvider ,
@@ -467,9 +467,12 @@ async function activateWithInstalledDistribution(
467467 selectedQuery : Uri | undefined ,
468468 progress : ProgressCallback ,
469469 token : CancellationToken ,
470+ databaseQuickPick : DatabaseItem | undefined ,
470471 ) : Promise < void > {
471472 if ( qs !== undefined ) {
472- const dbItem = await databaseUI . getDatabaseItem ( progress , token ) ;
473+ const dbItem = databaseQuickPick !== undefined
474+ ? databaseQuickPick
475+ : await databaseUI . getDatabaseItem ( progress , token ) ;
473476 if ( dbItem === undefined ) {
474477 throw new Error ( 'Can\'t run query without a selected database' ) ;
475478 }
@@ -549,13 +552,46 @@ async function activateWithInstalledDistribution(
549552 progress : ProgressCallback ,
550553 token : CancellationToken ,
551554 uri : Uri | undefined
552- ) => await compileAndRunQuery ( false , uri , progress , token ) ,
555+ ) => await compileAndRunQuery ( false , uri , progress , token , undefined ) ,
553556 {
554557 title : 'Running query' ,
555558 cancellable : true
556559 }
557560 )
558561 ) ;
562+ ctx . subscriptions . push (
563+ commandRunnerWithProgress (
564+ 'codeQL.runQueryOnMultipleDatabases' ,
565+ async (
566+ progress : ProgressCallback ,
567+ token : CancellationToken ,
568+ uri : Uri | undefined
569+ ) => {
570+ /**
571+ * Databases selected from the quick pick menu.
572+ */
573+ const quickpick = await window . showQuickPick (
574+ // TODO: Return items of type "DatabaseItem" instead of "string"
575+ // For this to work, I think we need "DatabaseItem" to extend "QuickPickItem":
576+ // https://code.visualstudio.com/api/references/vscode-api#QuickPickItem
577+ dbm . databaseItems . map ( dbItem => dbItem . name ) ,
578+ { canPickMany : true } ,
579+ ) ;
580+ if ( quickpick !== undefined ) {
581+ for ( const item of quickpick ) {
582+ // Instead of "item" (which is a string), we need the associated "DatabaseItem"...
583+ await compileAndRunQuery ( false , uri , progress , token , item ) ;
584+ }
585+ } else {
586+ void helpers . showAndLogErrorMessage ( 'No databases selected.' ) ;
587+ }
588+ } ,
589+ {
590+ title : 'Running query on selected databases' ,
591+ cancellable : true
592+ }
593+ )
594+ ) ;
559595 ctx . subscriptions . push (
560596 commandRunnerWithProgress (
561597 'codeQL.runQueries' ,
@@ -611,7 +647,7 @@ async function activateWithInstalledDistribution(
611647 } ) ;
612648
613649 await Promise . all ( queryUris . map ( async uri =>
614- compileAndRunQuery ( false , uri , wrappedProgress , token )
650+ compileAndRunQuery ( false , uri , wrappedProgress , token , undefined )
615651 . then ( ( ) => queriesRemaining -- )
616652 ) ) ;
617653 } ,
@@ -627,7 +663,7 @@ async function activateWithInstalledDistribution(
627663 progress : ProgressCallback ,
628664 token : CancellationToken ,
629665 uri : Uri | undefined
630- ) => await compileAndRunQuery ( true , uri , progress , token ) ,
666+ ) => await compileAndRunQuery ( true , uri , progress , token , undefined ) ,
631667 {
632668 title : 'Running query' ,
633669 cancellable : true
0 commit comments