Skip to content

Commit 3240809

Browse files
authored
Merge pull request #2200 from github/koesie10/restart-typed-command
Convert codeQL.restartQueryServer to a typed command
2 parents 71831fe + 3e66e7a commit 3240809

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

extensions/ql-vscode/src/common/commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export type SingleSelectionCommandFunction<Item> = (
2727
// Base commands not tied directly to a module like e.g. variant analysis.
2828
export type BaseCommands = {
2929
"codeQL.openDocumentation": () => Promise<void>;
30+
31+
"codeQL.restartQueryServer": () => Promise<void>;
3032
};
3133

3234
// Commands used for running local queries

extensions/ql-vscode/src/extension.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,28 @@ const extension = extensions.getExtension(extensionId);
169169
/**
170170
* Return all commands that are not tied to the more specific managers.
171171
*/
172-
function getCommands(): BaseCommands {
172+
function getCommands(
173+
cliServer: CodeQLCliServer,
174+
queryRunner: QueryRunner,
175+
): BaseCommands {
173176
return {
174177
"codeQL.openDocumentation": async () => {
175178
await env.openExternal(Uri.parse("https://codeql.github.com/docs/"));
176179
},
180+
"codeQL.restartQueryServer": async () =>
181+
withProgress(
182+
async (progress: ProgressCallback, token: CancellationToken) => {
183+
// We restart the CLI server too, to ensure they are the same version
184+
cliServer.restartCliServer();
185+
await queryRunner.restartQueryServer(progress, token);
186+
void showAndLogInformationMessage("CodeQL Query Server restarted.", {
187+
outputLogger: queryServerLogger,
188+
});
189+
},
190+
{
191+
title: "Restarting Query Server",
192+
},
193+
),
177194
};
178195
}
179196

@@ -799,7 +816,7 @@ async function activateWithInstalledDistribution(
799816
void extLogger.log("Registering top-level command palette commands.");
800817

801818
const allCommands: AllCommands = {
802-
...getCommands(),
819+
...getCommands(cliServer, qs),
803820
...qhm.getCommands(),
804821
...variantAnalysisManager.getCommands(),
805822
...databaseUI.getCommands(),
@@ -935,23 +952,6 @@ async function activateWithInstalledDistribution(
935952
}),
936953
);
937954

938-
ctx.subscriptions.push(
939-
commandRunnerWithProgress(
940-
"codeQL.restartQueryServer",
941-
async (progress: ProgressCallback, token: CancellationToken) => {
942-
// We restart the CLI server too, to ensure they are the same version
943-
cliServer.restartCliServer();
944-
await qs.restartQueryServer(progress, token);
945-
void showAndLogInformationMessage("CodeQL Query Server restarted.", {
946-
outputLogger: queryServerLogger,
947-
});
948-
},
949-
{
950-
title: "Restarting Query Server",
951-
},
952-
),
953-
);
954-
955955
ctx.subscriptions.push(
956956
commandRunner("codeQL.copyVersion", async () => {
957957
const text = `CodeQL extension version: ${

0 commit comments

Comments
 (0)