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 ,
@@ -297,6 +296,8 @@ export async function activate(
297296 addUnhandledRejectionListener ( ) ;
298297 install ( ) ;
299298
299+ const app = new ExtensionApp ( ctx ) ;
300+
300301 const codelensProvider = new QuickEvalCodeLensProvider ( ) ;
301302 languages . registerCodeLensProvider (
302303 { scheme : "file" , language : "ql" } ,
@@ -323,6 +324,7 @@ export async function activate(
323324 distributionConfigListener . onDidChangeConfiguration ( ( ) =>
324325 installOrUpdateThenTryActivate (
325326 ctx ,
327+ app ,
326328 distributionManager ,
327329 distributionConfigListener ,
328330 {
@@ -337,6 +339,7 @@ export async function activate(
337339 commandRunner ( checkForUpdatesCommand , ( ) =>
338340 installOrUpdateThenTryActivate (
339341 ctx ,
342+ app ,
340343 distributionManager ,
341344 distributionConfigListener ,
342345 {
@@ -356,6 +359,7 @@ export async function activate(
356359
357360 const codeQlExtension = await installOrUpdateThenTryActivate (
358361 ctx ,
362+ app ,
359363 distributionManager ,
360364 distributionConfigListener ,
361365 {
@@ -377,6 +381,7 @@ export async function activate(
377381
378382async function installOrUpdateDistributionWithProgressTitle (
379383 ctx : ExtensionContext ,
384+ app : ExtensionApp ,
380385 distributionManager : DistributionManager ,
381386 progressTitle : string ,
382387 config : DistributionUpdateConfig ,
@@ -421,7 +426,7 @@ async function installOrUpdateDistributionWithProgressTitle(
421426 "Restart and Upgrade" ,
422427 )
423428 ) {
424- await commands . executeCommand ( "workbench.action.reloadWindow" ) ;
429+ await app . commands . execute ( "workbench.action.reloadWindow" ) ;
425430 }
426431 } else {
427432 await withProgress (
@@ -448,6 +453,7 @@ async function installOrUpdateDistributionWithProgressTitle(
448453
449454async function installOrUpdateDistribution (
450455 ctx : ExtensionContext ,
456+ app : ExtensionApp ,
451457 distributionManager : DistributionManager ,
452458 config : DistributionUpdateConfig ,
453459) : Promise < void > {
@@ -468,6 +474,7 @@ async function installOrUpdateDistribution(
468474 try {
469475 await installOrUpdateDistributionWithProgressTitle (
470476 ctx ,
477+ app ,
471478 distributionManager ,
472479 messageText ,
473480 config ,
@@ -553,11 +560,12 @@ async function getDistributionDisplayingDistributionWarnings(
553560
554561async function installOrUpdateThenTryActivate (
555562 ctx : ExtensionContext ,
563+ app : ExtensionApp ,
556564 distributionManager : DistributionManager ,
557565 distributionConfigListener : DistributionConfigListener ,
558566 config : DistributionUpdateConfig ,
559567) : Promise < CodeQLExtensionInterface | Record < string , never > > {
560- await installOrUpdateDistribution ( ctx , distributionManager , config ) ;
568+ await installOrUpdateDistribution ( ctx , app , distributionManager , config ) ;
561569
562570 try {
563571 await prepareCodeTour ( ) ;
@@ -577,6 +585,7 @@ async function installOrUpdateThenTryActivate(
577585 ) {
578586 extensionInterface = await activateWithInstalledDistribution (
579587 ctx ,
588+ app ,
580589 distributionManager ,
581590 distributionConfigListener ,
582591 ) ;
@@ -594,6 +603,7 @@ async function installOrUpdateThenTryActivate(
594603 if ( chosenAction === installActionName ) {
595604 await installOrUpdateThenTryActivate (
596605 ctx ,
606+ app ,
597607 distributionManager ,
598608 distributionConfigListener ,
599609 {
@@ -620,6 +630,7 @@ const PACK_GLOBS = [
620630
621631async function activateWithInstalledDistribution (
622632 ctx : ExtensionContext ,
633+ app : ExtensionApp ,
623634 distributionManager : DistributionManager ,
624635 distributionConfigListener : DistributionConfigListener ,
625636) : Promise < CodeQLExtensionInterface > {
@@ -628,8 +639,6 @@ async function activateWithInstalledDistribution(
628639 // of activation.
629640 errorStubs . forEach ( ( stub ) => stub . dispose ( ) ) ;
630641
631- const app = new ExtensionApp ( ctx ) ;
632-
633642 void extLogger . log ( "Initializing configuration listener..." ) ;
634643 const qlConfigurationListener =
635644 await QueryServerConfigListener . createQueryServerConfigListener (
@@ -862,7 +871,7 @@ async function activateWithInstalledDistribution(
862871
863872 void extLogger . log ( "Registering top-level command palette commands." ) ;
864873
865- const allCommands : AllCommands = {
874+ const allCommands : AllExtensionCommands = {
866875 ...getCommands ( app , cliServer , qs ) ,
867876 ...getQueryEditorCommands ( {
868877 queryRunner : qs ,
@@ -895,7 +904,7 @@ async function activateWithInstalledDistribution(
895904 } ;
896905
897906 for ( const [ commandName , command ] of Object . entries ( allCommands ) ) {
898- app . commands . register ( commandName as keyof AllCommands , command ) ;
907+ app . commands . register ( commandName as keyof AllExtensionCommands , command ) ;
899908 }
900909
901910 const queryServerCommands : QueryServerCommands = {
@@ -948,7 +957,7 @@ async function activateWithInstalledDistribution(
948957 ) ,
949958 ) ;
950959
951- await commands . executeCommand ( "codeQLDatabases.removeOrphanedDatabases" ) ;
960+ await app . commands . execute ( "codeQLDatabases.removeOrphanedDatabases" ) ;
952961
953962 void extLogger . log ( "Reading query history" ) ;
954963 await qhm . readQueryHistory ( ) ;
0 commit comments