@@ -54,7 +54,15 @@ import {
5454 GithubApiError ,
5555 GithubRateLimitedError
5656} from './distribution' ;
57- import * as helpers from './helpers' ;
57+ import {
58+ findLanguage ,
59+ tmpDirDisposal ,
60+ showBinaryChoiceDialog ,
61+ showAndLogErrorMessage ,
62+ showAndLogWarningMessage ,
63+ showAndLogInformationMessage ,
64+ showInformationMessageWithAction
65+ } from './helpers' ;
5866import { assertNever } from './pure/helpers-pure' ;
5967import { spawnIdeServer } from './ide-server' ;
6068import { InterfaceManager } from './interface' ;
@@ -64,7 +72,7 @@ import { QueryHistoryManager } from './query-history';
6472import { FullCompletedQueryInfo , FullQueryInfo } from './query-results' ;
6573import * as qsClient from './queryserver-client' ;
6674import { displayQuickQuery } from './quick-query' ;
67- import { compileAndRunQueryAgainstDatabase , createInitialQueryInfo , tmpDirDisposal } from './run-queries' ;
75+ import { compileAndRunQueryAgainstDatabase , createInitialQueryInfo } from './run-queries' ;
6876import { QLTestAdapterFactory } from './test-adapter' ;
6977import { TestUIService } from './test-ui' ;
7078import { CompareInterfaceManager } from './compare/compare-interface' ;
@@ -189,7 +197,7 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
189197 const shouldUpdateOnNextActivationKey = 'shouldUpdateOnNextActivation' ;
190198
191199 registerErrorStubs ( [ checkForUpdatesCommand ] , command => ( async ( ) => {
192- void helpers . showAndLogErrorMessage ( `Can't execute ${ command } : waiting to finish loading CodeQL CLI.` ) ;
200+ void showAndLogErrorMessage ( `Can't execute ${ command } : waiting to finish loading CodeQL CLI.` ) ;
193201 } ) ) ;
194202
195203 interface DistributionUpdateConfig {
@@ -201,7 +209,7 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
201209 async function installOrUpdateDistributionWithProgressTitle ( progressTitle : string , config : DistributionUpdateConfig ) : Promise < void > {
202210 const minSecondsSinceLastUpdateCheck = config . isUserInitiated ? 0 : 86400 ;
203211 const noUpdatesLoggingFunc = config . shouldDisplayMessageWhenNoUpdates ?
204- helpers . showAndLogInformationMessage : async ( message : string ) => void logger . log ( message ) ;
212+ showAndLogInformationMessage : async ( message : string ) => void logger . log ( message ) ;
205213 const result = await distributionManager . checkForUpdatesToExtensionManagedDistribution ( minSecondsSinceLastUpdateCheck ) ;
206214
207215 // We do want to auto update if there is no distribution at all
@@ -223,7 +231,7 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
223231 const updateAvailableMessage = `Version "${ result . updatedRelease . name } " of the CodeQL CLI is now available. ` +
224232 'Do you wish to upgrade?' ;
225233 await ctx . globalState . update ( shouldUpdateOnNextActivationKey , true ) ;
226- if ( await helpers . showInformationMessageWithAction ( updateAvailableMessage , 'Restart and Upgrade' ) ) {
234+ if ( await showInformationMessageWithAction ( updateAvailableMessage , 'Restart and Upgrade' ) ) {
227235 await commands . executeCommand ( 'workbench.action.reloadWindow' ) ;
228236 }
229237 } else {
@@ -236,7 +244,7 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
236244 distributionManager . installExtensionManagedDistributionRelease ( result . updatedRelease , progress ) ) ;
237245
238246 await ctx . globalState . update ( shouldUpdateOnNextActivationKey , false ) ;
239- void helpers . showAndLogInformationMessage ( `CodeQL CLI updated to version "${ result . updatedRelease . name } ".` ) ;
247+ void showAndLogInformationMessage ( `CodeQL CLI updated to version "${ result . updatedRelease . name } ".` ) ;
240248 }
241249 break ;
242250 default :
@@ -263,7 +271,7 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
263271 // Don't rethrow the exception, because if the config is changed, we want to be able to retry installing
264272 // or updating the distribution.
265273 const alertFunction = ( codeQlInstalled && ! config . isUserInitiated ) ?
266- helpers . showAndLogWarningMessage : helpers . showAndLogErrorMessage ;
274+ showAndLogWarningMessage : showAndLogErrorMessage ;
267275 const taskDescription = ( willUpdateCodeQl ? 'update' :
268276 codeQlInstalled ? 'check for updates to' : 'install' ) + ' CodeQL CLI' ;
269277
@@ -298,20 +306,20 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
298306 }
299307 } ) ( ) ;
300308
301- void helpers . showAndLogWarningMessage (
309+ void showAndLogWarningMessage (
302310 `The current version of the CodeQL CLI (${ result . version . raw } ) ` +
303311 `is incompatible with this extension. ${ fixGuidanceMessage } `
304312 ) ;
305313 break ;
306314 }
307315 case FindDistributionResultKind . UnknownCompatibilityDistribution :
308- void helpers . showAndLogWarningMessage (
316+ void showAndLogWarningMessage (
309317 'Compatibility with the configured CodeQL CLI could not be determined. ' +
310318 'You may experience problems using the extension.'
311319 ) ;
312320 break ;
313321 case FindDistributionResultKind . NoDistribution :
314- void helpers . showAndLogErrorMessage ( 'The CodeQL CLI could not be found.' ) ;
322+ void showAndLogErrorMessage ( 'The CodeQL CLI could not be found.' ) ;
315323 break ;
316324 default :
317325 assertNever ( result ) ;
@@ -338,7 +346,7 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
338346 } else if ( distributionResult . kind === FindDistributionResultKind . NoDistribution ) {
339347 registerErrorStubs ( [ checkForUpdatesCommand ] , command => async ( ) => {
340348 const installActionName = 'Install CodeQL CLI' ;
341- const chosenAction = await void helpers . showAndLogErrorMessage ( `Can't execute ${ command } : missing CodeQL CLI.` , {
349+ const chosenAction = await void showAndLogErrorMessage ( `Can't execute ${ command } : missing CodeQL CLI.` , {
342350 items : [ installActionName ]
343351 } ) ;
344352 if ( chosenAction === installActionName ) {
@@ -477,7 +485,7 @@ async function activateWithInstalledDistribution(
477485 try {
478486 await cmpm . showResults ( from , to ) ;
479487 } catch ( e ) {
480- void helpers . showAndLogErrorMessage ( e . message ) ;
488+ void showAndLogErrorMessage ( e . message ) ;
481489 }
482490 }
483491
@@ -559,7 +567,7 @@ async function activateWithInstalledDistribution(
559567 const errorMessage = err . message . includes ( 'Generating qhelp in markdown' ) ? (
560568 `Could not generate markdown from ${ pathToQhelp } : Bad formatting in .qhelp file.`
561569 ) : `Could not open a preview of the generated file (${ absolutePathToMd } ).` ;
562- void helpers . showAndLogErrorMessage ( errorMessage , { fullMessage : `${ errorMessage } \n${ err } ` } ) ;
570+ void showAndLogErrorMessage ( errorMessage , { fullMessage : `${ errorMessage } \n${ err } ` } ) ;
563571 }
564572 }
565573
@@ -576,7 +584,7 @@ async function activateWithInstalledDistribution(
576584 const uri = Uri . file ( resolved . resolvedPath ) ;
577585 await window . showTextDocument ( uri , { preview : false } ) ;
578586 } else {
579- void helpers . showAndLogErrorMessage (
587+ void showAndLogErrorMessage (
580588 'Jumping from a .qlref file to the .ql file it references is not '
581589 + 'supported with the CLI version you are running.\n'
582590 + `Please upgrade your CLI to version ${ CliVersionConstraint . CLI_VERSION_WITH_RESOLVE_QLREF
@@ -646,15 +654,15 @@ async function activateWithInstalledDistribution(
646654 ) => {
647655 let filteredDBs = dbm . databaseItems ;
648656 if ( filteredDBs . length === 0 ) {
649- void helpers . showAndLogErrorMessage ( 'No databases found. Please add a suitable database to your workspace.' ) ;
657+ void showAndLogErrorMessage ( 'No databases found. Please add a suitable database to your workspace.' ) ;
650658 return ;
651659 }
652660 // If possible, only show databases with the right language (otherwise show all databases).
653- const queryLanguage = await helpers . findLanguage ( cliServer , uri ) ;
661+ const queryLanguage = await findLanguage ( cliServer , uri ) ;
654662 if ( queryLanguage ) {
655663 filteredDBs = dbm . databaseItems . filter ( db => db . language === queryLanguage ) ;
656664 if ( filteredDBs . length === 0 ) {
657- void helpers . showAndLogErrorMessage ( `No databases found for language ${ queryLanguage } . Please add a suitable database to your workspace.` ) ;
665+ void showAndLogErrorMessage ( `No databases found for language ${ queryLanguage } . Please add a suitable database to your workspace.` ) ;
658666 return ;
659667 }
660668 }
@@ -686,12 +694,12 @@ async function activateWithInstalledDistribution(
686694 }
687695 if ( skippedDatabases . length > 0 ) {
688696 void logger . log ( `Errors:\n${ errors . join ( '\n' ) } ` ) ;
689- void helpers . showAndLogWarningMessage (
697+ void showAndLogWarningMessage (
690698 `The following databases were skipped:\n${ skippedDatabases . join ( '\n' ) } .\nFor details about the errors, see the logs.`
691699 ) ;
692700 }
693701 } else {
694- void helpers . showAndLogErrorMessage ( 'No databases selected.' ) ;
702+ void showAndLogErrorMessage ( 'No databases selected.' ) ;
695703 }
696704 } ,
697705 {
@@ -718,7 +726,7 @@ async function activateWithInstalledDistribution(
718726 // files may be hidden from the user.
719727 if ( dirFound ) {
720728 const fileString = files . map ( file => path . basename ( file ) ) . join ( ', ' ) ;
721- const res = await helpers . showBinaryChoiceDialog (
729+ const res = await showBinaryChoiceDialog (
722730 `You are about to run ${ files . length } queries: ${ fileString } Do you want to continue?`
723731 ) ;
724732 if ( ! res ) {
@@ -882,7 +890,7 @@ async function activateWithInstalledDistribution(
882890 token : CancellationToken
883891 ) => {
884892 await qs . restartQueryServer ( progress , token ) ;
885- void helpers . showAndLogInformationMessage ( 'CodeQL Query Server restarted.' , {
893+ void showAndLogInformationMessage ( 'CodeQL Query Server restarted.' , {
886894 outputLogger : queryServerLogger ,
887895 } ) ;
888896 } , {
@@ -938,7 +946,7 @@ async function activateWithInstalledDistribution(
938946 commandRunner ( 'codeQL.copyVersion' , async ( ) => {
939947 const text = `CodeQL extension version: ${ extension ?. packageJSON . version } \nCodeQL CLI version: ${ await getCliVersion ( ) } \nPlatform: ${ os . platform ( ) } ${ os . arch ( ) } ` ;
940948 await env . clipboard . writeText ( text ) ;
941- void helpers . showAndLogInformationMessage ( text ) ;
949+ void showAndLogInformationMessage ( text ) ;
942950 } ) ) ;
943951
944952 const getCliVersion = async ( ) => {
@@ -960,7 +968,7 @@ async function activateWithInstalledDistribution(
960968 const credentials = await Credentials . initialize ( ctx ) ;
961969 const octokit = await credentials . getOctokit ( ) ;
962970 const userInfo = await octokit . users . getAuthenticated ( ) ;
963- void helpers . showAndLogInformationMessage ( `Authenticated to GitHub as user: ${ userInfo . data . login } ` ) ;
971+ void showAndLogInformationMessage ( `Authenticated to GitHub as user: ${ userInfo . data . login } ` ) ;
964972 }
965973 } ) ) ;
966974
0 commit comments