@@ -115,10 +115,7 @@ import {
115115 QueryServerCommands ,
116116 TestUICommands ,
117117} from "./common/commands" ;
118- import {
119- getLocalQueryCommands ,
120- showResultsForCompletedQuery ,
121- } from "./local-queries" ;
118+ import { LocalQueries } from "./local-queries" ;
122119import { getAstCfgCommands } from "./ast-cfg-commands" ;
123120import { getQueryEditorCommands } from "./query-editor" ;
124121import { App } from "./common/app" ;
@@ -260,6 +257,7 @@ export interface CodeQLExtensionInterface {
260257 readonly distributionManager : DistributionManager ;
261258 readonly databaseManager : DatabaseManager ;
262259 readonly databaseUI : DatabaseUI ;
260+ readonly localQueries : LocalQueries ;
263261 readonly variantAnalysisManager : VariantAnalysisManager ;
264262 readonly dispose : ( ) => void ;
265263}
@@ -716,12 +714,6 @@ async function activateWithInstalledDistribution(
716714 void extLogger . log ( "Initializing query history manager." ) ;
717715 const queryHistoryConfigurationListener = new QueryHistoryConfigListener ( ) ;
718716 ctx . subscriptions . push ( queryHistoryConfigurationListener ) ;
719- const showResults = async ( item : CompletedLocalQueryInfo ) =>
720- showResultsForCompletedQuery (
721- localQueryResultsView ,
722- item ,
723- WebviewReveal . Forced ,
724- ) ;
725717 const queryStorageDir = join ( ctx . globalStorageUri . fsPath , "queries" ) ;
726718 await ensureDir ( queryStorageDir ) ;
727719
@@ -795,8 +787,10 @@ async function activateWithInstalledDistribution(
795787 ctx ,
796788 queryHistoryConfigurationListener ,
797789 labelProvider ,
798- async ( from : CompletedLocalQueryInfo , to : CompletedLocalQueryInfo ) =>
799- showResultsForComparison ( compareView , from , to ) ,
790+ async (
791+ from : CompletedLocalQueryInfo ,
792+ to : CompletedLocalQueryInfo ,
793+ ) : Promise < void > => showResultsForComparison ( compareView , from , to ) ,
800794 ) ;
801795
802796 ctx . subscriptions . push ( qhm ) ;
@@ -817,7 +811,8 @@ async function activateWithInstalledDistribution(
817811 cliServer ,
818812 queryServerLogger ,
819813 labelProvider ,
820- showResults ,
814+ async ( item : CompletedLocalQueryInfo ) =>
815+ localQueries . showResultsForCompletedQuery ( item , WebviewReveal . Forced ) ,
821816 ) ;
822817 ctx . subscriptions . push ( compareView ) ;
823818
@@ -853,6 +848,18 @@ async function activateWithInstalledDistribution(
853848 true ,
854849 ) ;
855850
851+ const localQueries = new LocalQueries (
852+ app ,
853+ qs ,
854+ qhm ,
855+ dbm ,
856+ cliServer ,
857+ databaseUI ,
858+ localQueryResultsView ,
859+ queryStorageDir ,
860+ ) ;
861+ ctx . subscriptions . push ( localQueries ) ;
862+
856863 void extLogger . log ( "Initializing QLTest interface." ) ;
857864 const testExplorerExtension = extensions . getExtension < TestHub > (
858865 testExplorerExtensionId ,
@@ -906,11 +913,7 @@ async function activateWithInstalledDistribution(
906913 ...databaseUI . getCommands ( ) ,
907914 ...dbModule . getCommands ( ) ,
908915 ...getAstCfgCommands ( {
909- queryRunner : qs ,
910- queryHistoryManager : qhm ,
911- databaseUI,
912- localQueryResultsView,
913- queryStorageDir,
916+ localQueries,
914917 astViewer,
915918 astTemplateProvider,
916919 cfgTemplateProvider,
@@ -930,16 +933,7 @@ async function activateWithInstalledDistribution(
930933 }
931934
932935 const queryServerCommands : QueryServerCommands = {
933- ...getLocalQueryCommands ( {
934- app,
935- queryRunner : qs ,
936- queryHistoryManager : qhm ,
937- databaseManager : dbm ,
938- cliServer,
939- databaseUI,
940- localQueryResultsView,
941- queryStorageDir,
942- } ) ,
936+ ...localQueries . getCommands ( ) ,
943937 } ;
944938
945939 for ( const [ commandName , command ] of Object . entries ( queryServerCommands ) ) {
@@ -989,6 +983,7 @@ async function activateWithInstalledDistribution(
989983 return {
990984 ctx,
991985 cliServer,
986+ localQueries,
992987 qs,
993988 distributionManager,
994989 databaseManager : dbm ,
0 commit comments