11import "source-map-support/register" ;
22import {
33 CancellationToken ,
4- commands ,
54 Disposable ,
65 env ,
76 ExtensionContext ,
@@ -111,7 +110,7 @@ import { DbModule } from "./databases/db-module";
111110import { redactableError } from "./pure/errors" ;
112111import { QueryHistoryDirs } from "./query-history/query-history-dirs" ;
113112import {
114- AllCommands ,
113+ AllExtensionCommands ,
115114 BaseCommands ,
116115 QueryServerCommands ,
117116 TestUICommands ,
@@ -266,6 +265,8 @@ export async function activate(
266265 addUnhandledRejectionListener ( ) ;
267266 install ( ) ;
268267
268+ const app = new ExtensionApp ( ctx ) ;
269+
269270 const codelensProvider = new QuickEvalCodeLensProvider ( ) ;
270271 languages . registerCodeLensProvider (
271272 { scheme : "file" , language : "ql" } ,
@@ -292,6 +293,7 @@ export async function activate(
292293 distributionConfigListener . onDidChangeConfiguration ( ( ) =>
293294 installOrUpdateThenTryActivate (
294295 ctx ,
296+ app ,
295297 distributionManager ,
296298 distributionConfigListener ,
297299 {
@@ -306,6 +308,7 @@ export async function activate(
306308 commandRunner ( checkForUpdatesCommand , ( ) =>
307309 installOrUpdateThenTryActivate (
308310 ctx ,
311+ app ,
309312 distributionManager ,
310313 distributionConfigListener ,
311314 {
@@ -325,6 +328,7 @@ export async function activate(
325328
326329 const codeQlExtension = await installOrUpdateThenTryActivate (
327330 ctx ,
331+ app ,
328332 distributionManager ,
329333 distributionConfigListener ,
330334 {
@@ -346,6 +350,7 @@ export async function activate(
346350
347351async function installOrUpdateDistributionWithProgressTitle (
348352 ctx : ExtensionContext ,
353+ app : ExtensionApp ,
349354 distributionManager : DistributionManager ,
350355 progressTitle : string ,
351356 config : DistributionUpdateConfig ,
@@ -390,7 +395,7 @@ async function installOrUpdateDistributionWithProgressTitle(
390395 "Restart and Upgrade" ,
391396 )
392397 ) {
393- await commands . executeCommand ( "workbench.action.reloadWindow" ) ;
398+ await app . commands . execute ( "workbench.action.reloadWindow" ) ;
394399 }
395400 } else {
396401 await withProgress (
@@ -417,6 +422,7 @@ async function installOrUpdateDistributionWithProgressTitle(
417422
418423async function installOrUpdateDistribution (
419424 ctx : ExtensionContext ,
425+ app : ExtensionApp ,
420426 distributionManager : DistributionManager ,
421427 config : DistributionUpdateConfig ,
422428) : Promise < void > {
@@ -437,6 +443,7 @@ async function installOrUpdateDistribution(
437443 try {
438444 await installOrUpdateDistributionWithProgressTitle (
439445 ctx ,
446+ app ,
440447 distributionManager ,
441448 messageText ,
442449 config ,
@@ -522,11 +529,12 @@ async function getDistributionDisplayingDistributionWarnings(
522529
523530async function installOrUpdateThenTryActivate (
524531 ctx : ExtensionContext ,
532+ app : ExtensionApp ,
525533 distributionManager : DistributionManager ,
526534 distributionConfigListener : DistributionConfigListener ,
527535 config : DistributionUpdateConfig ,
528536) : Promise < CodeQLExtensionInterface | Record < string , never > > {
529- await installOrUpdateDistribution ( ctx , distributionManager , config ) ;
537+ await installOrUpdateDistribution ( ctx , app , distributionManager , config ) ;
530538
531539 try {
532540 await prepareCodeTour ( ) ;
@@ -546,6 +554,7 @@ async function installOrUpdateThenTryActivate(
546554 ) {
547555 extensionInterface = await activateWithInstalledDistribution (
548556 ctx ,
557+ app ,
549558 distributionManager ,
550559 distributionConfigListener ,
551560 ) ;
@@ -563,6 +572,7 @@ async function installOrUpdateThenTryActivate(
563572 if ( chosenAction === installActionName ) {
564573 await installOrUpdateThenTryActivate (
565574 ctx ,
575+ app ,
566576 distributionManager ,
567577 distributionConfigListener ,
568578 {
@@ -589,6 +599,7 @@ const PACK_GLOBS = [
589599
590600async function activateWithInstalledDistribution (
591601 ctx : ExtensionContext ,
602+ app : ExtensionApp ,
592603 distributionManager : DistributionManager ,
593604 distributionConfigListener : DistributionConfigListener ,
594605) : Promise < CodeQLExtensionInterface > {
@@ -597,8 +608,6 @@ async function activateWithInstalledDistribution(
597608 // of activation.
598609 errorStubs . forEach ( ( stub ) => stub . dispose ( ) ) ;
599610
600- const app = new ExtensionApp ( ctx ) ;
601-
602611 void extLogger . log ( "Initializing configuration listener..." ) ;
603612 const qlConfigurationListener =
604613 await QueryServerConfigListener . createQueryServerConfigListener (
@@ -831,7 +840,7 @@ async function activateWithInstalledDistribution(
831840
832841 void extLogger . log ( "Registering top-level command palette commands." ) ;
833842
834- const allCommands : AllCommands = {
843+ const allCommands : AllExtensionCommands = {
835844 ...getCommands ( cliServer , qs ) ,
836845 ...getQueryEditorCommands ( {
837846 queryRunner : qs ,
@@ -864,7 +873,7 @@ async function activateWithInstalledDistribution(
864873 } ;
865874
866875 for ( const [ commandName , command ] of Object . entries ( allCommands ) ) {
867- app . commands . register ( commandName as keyof AllCommands , command ) ;
876+ app . commands . register ( commandName as keyof AllExtensionCommands , command ) ;
868877 }
869878
870879 const queryServerCommands : QueryServerCommands = {
@@ -955,7 +964,7 @@ async function activateWithInstalledDistribution(
955964 ) ,
956965 ) ;
957966
958- await commands . executeCommand ( "codeQLDatabases.removeOrphanedDatabases" ) ;
967+ await app . commands . execute ( "codeQLDatabases.removeOrphanedDatabases" ) ;
959968
960969 void extLogger . log ( "Reading query history" ) ;
961970 await qhm . readQueryHistory ( ) ;
0 commit comments