diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index 7df629fd58f..1a024d3395c 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -1,5 +1,12 @@ # CodeQL for Visual Studio Code: Changelog +## 1.0.7 + +- Add a "Show log" button to all information, error, and warning + popups that will display the CodeQL extension log. +- Display a message when a query times out. +- Show canceled queries in query history. + ## 1.0.6 - 28 February 2020 - Add command to restart query server. diff --git a/extensions/ql-vscode/src/databases.ts b/extensions/ql-vscode/src/databases.ts index 5ddda564a87..15d3e60f45e 100644 --- a/extensions/ql-vscode/src/databases.ts +++ b/extensions/ql-vscode/src/databases.ts @@ -571,7 +571,7 @@ export class DatabaseManager extends DisposableObject { } } catch (e) { // database list had an unexpected type - nothing to be done? - showAndLogErrorMessage('Database list loading failed: ${}', e.message); + showAndLogErrorMessage(`Database list loading failed: ${e.message}`); } } diff --git a/extensions/ql-vscode/src/extension.ts b/extensions/ql-vscode/src/extension.ts index 1c6e6957fb0..847c2e9e8fe 100644 --- a/extensions/ql-vscode/src/extension.ts +++ b/extensions/ql-vscode/src/extension.ts @@ -201,7 +201,9 @@ export async function activate(ctx: ExtensionContext): Promise { } else if (distributionResult.kind === FindDistributionResultKind.NoDistribution) { registerErrorStubs([checkForUpdatesCommand], command => async () => { const installActionName = "Install CodeQL CLI"; - const chosenAction = await helpers.showAndLogErrorMessage(`Can't execute ${command}: missing CodeQL CLI.`, installActionName); + const chosenAction = await helpers.showAndLogErrorMessage(`Can't execute ${command}: missing CodeQL CLI.`, { + items: [installActionName] + }); if (chosenAction === installActionName) { installOrUpdateThenTryActivate({ isUserInitiated: true, @@ -319,10 +321,7 @@ async function activateWithInstalledDistribution(ctx: ExtensionContext, distribu ctx.subscriptions.push(commands.registerCommand('codeQL.quickQuery', async () => displayQuickQuery(ctx, cliServer, databaseUI))); ctx.subscriptions.push(commands.registerCommand('codeQL.restartQueryServer', async () => { await qs.restartQueryServer(); - const response = await Window.showInformationMessage('CodeQL Query Server restarted.', 'Show Log'); - if (response === 'Show Log') { - qs.showLog(); - } + helpers.showAndLogInformationMessage('CodeQL Query Server restarted.', { outputLogger: queryServerLogger }); })); ctx.subscriptions.push(client.start()); diff --git a/extensions/ql-vscode/src/helpers.ts b/extensions/ql-vscode/src/helpers.ts index 17c8b70fbd1..c9285067b5e 100644 --- a/extensions/ql-vscode/src/helpers.ts +++ b/extensions/ql-vscode/src/helpers.ts @@ -47,37 +47,59 @@ export function withProgress( * Show an error message and log it to the console * * @param message The message to show. - * @param items A set of items that will be rendered as actions in the message. + * @param options.outputLogger The output logger that will receive the message + * @param options.items A set of items that will be rendered as actions in the message. * - * @return A thenable that resolves to the selected item or undefined when being dismissed. + * @return A promise that resolves to the selected item or undefined when being dismissed. */ -export function showAndLogErrorMessage(message: string, ...items: string[]): Thenable { - logger.log(message); - return Window.showErrorMessage(message, ...items); +export async function showAndLogErrorMessage(message: string, { + outputLogger = logger, + items = [] as string[] +} = {}): Promise { + return internalShowAndLog(message, items, outputLogger, Window.showErrorMessage); } /** * Show a warning message and log it to the console * * @param message The message to show. - * @param items A set of items that will be rendered as actions in the message. + * @param options.outputLogger The output logger that will receive the message + * @param options.items A set of items that will be rendered as actions in the message. * - * @return A thenable that resolves to the selected item or undefined when being dismissed. + * @return A promise that resolves to the selected item or undefined when being dismissed. */ -export function showAndLogWarningMessage(message: string, ...items: string[]): Thenable { - logger.log(message); - return Window.showWarningMessage(message, ...items); +export async function showAndLogWarningMessage(message: string, { + outputLogger = logger, + items = [] as string[] +} = {}): Promise { + return internalShowAndLog(message, items, outputLogger, Window.showWarningMessage); } /** * Show an information message and log it to the console * * @param message The message to show. - * @param items A set of items that will be rendered as actions in the message. + * @param options.outputLogger The output logger that will receive the message + * @param options.items A set of items that will be rendered as actions in the message. * - * @return A thenable that resolves to the selected item or undefined when being dismissed. + * @return A promise that resolves to the selected item or undefined when being dismissed. */ -export function showAndLogInformationMessage(message: string, ...items: string[]): Thenable { - logger.log(message); - return Window.showInformationMessage(message, ...items); +export async function showAndLogInformationMessage(message: string, { + outputLogger = logger, + items = [] as string[] +} = {}): Promise { + return internalShowAndLog(message, items, outputLogger, Window.showInformationMessage); +} + +type ShowMessageFn = (message: string, ...items: string[]) => Thenable; + +async function internalShowAndLog(message: string, items: string[], outputLogger = logger, + fn: ShowMessageFn): Promise { + const label = 'Show Log'; + outputLogger.log(message); + const result = await fn(message, label, ...items); + if (result === label) { + outputLogger.show(); + } + return result; } /**