Convert codeQL.restartQueryServer to a typed command

This commit is contained in:
Koen Vlaswinkel
2023-03-22 10:29:09 +01:00
parent 1c6d9f3f22
commit 2c8c7cec8f
2 changed files with 21 additions and 20 deletions

View File

@@ -27,6 +27,8 @@ export type SingleSelectionCommandFunction<Item> = (
// Base commands not tied directly to a module like e.g. variant analysis.
export type BaseCommands = {
"codeQL.openDocumentation": () => Promise<void>;
"codeQL.restartQueryServer": () => Promise<void>;
};
// Commands used for the query history panel

View File

@@ -169,11 +169,28 @@ const extension = extensions.getExtension(extensionId);
/**
* Return all commands that are not tied to the more specific managers.
*/
function getCommands(): BaseCommands {
function getCommands(
cliServer: CodeQLCliServer,
queryRunner: QueryRunner,
): BaseCommands {
return {
"codeQL.openDocumentation": async () => {
await env.openExternal(Uri.parse("https://codeql.github.com/docs/"));
},
"codeQL.restartQueryServer": async () =>
withProgress(
async (progress: ProgressCallback, token: CancellationToken) => {
// We restart the CLI server too, to ensure they are the same version
cliServer.restartCliServer();
await queryRunner.restartQueryServer(progress, token);
void showAndLogInformationMessage("CodeQL Query Server restarted.", {
outputLogger: queryServerLogger,
});
},
{
title: "Restarting Query Server",
},
),
};
}
@@ -1097,7 +1114,7 @@ async function activateWithInstalledDistribution(
);
const allCommands: AllCommands = {
...getCommands(),
...getCommands(cliServer, qs),
...qhm.getCommands(),
...variantAnalysisManager.getCommands(),
...databaseUI.getCommands(),
@@ -1212,24 +1229,6 @@ async function activateWithInstalledDistribution(
}),
);
ctx.subscriptions.push(
commandRunner("codeQL.restartQueryServer", async () =>
withProgress(
async (progress: ProgressCallback, token: CancellationToken) => {
// We restart the CLI server too, to ensure they are the same version
cliServer.restartCliServer();
await qs.restartQueryServer(progress, token);
void showAndLogInformationMessage("CodeQL Query Server restarted.", {
outputLogger: queryServerLogger,
});
},
{
title: "Restarting Query Server",
},
),
),
);
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.chooseDatabaseFolder",