Skip to content

Commit 2c8c7ce

Browse files
committed
Convert codeQL.restartQueryServer to a typed command
1 parent 1c6d9f3 commit 2c8c7ce

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
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 the query history panel

extensions/ql-vscode/src/extension.ts

Lines changed: 19 additions & 20 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

@@ -1097,7 +1114,7 @@ async function activateWithInstalledDistribution(
10971114
);
10981115

10991116
const allCommands: AllCommands = {
1100-
...getCommands(),
1117+
...getCommands(cliServer, qs),
11011118
...qhm.getCommands(),
11021119
...variantAnalysisManager.getCommands(),
11031120
...databaseUI.getCommands(),
@@ -1212,24 +1229,6 @@ async function activateWithInstalledDistribution(
12121229
}),
12131230
);
12141231

1215-
ctx.subscriptions.push(
1216-
commandRunner("codeQL.restartQueryServer", async () =>
1217-
withProgress(
1218-
async (progress: ProgressCallback, token: CancellationToken) => {
1219-
// We restart the CLI server too, to ensure they are the same version
1220-
cliServer.restartCliServer();
1221-
await qs.restartQueryServer(progress, token);
1222-
void showAndLogInformationMessage("CodeQL Query Server restarted.", {
1223-
outputLogger: queryServerLogger,
1224-
});
1225-
},
1226-
{
1227-
title: "Restarting Query Server",
1228-
},
1229-
),
1230-
),
1231-
);
1232-
12331232
ctx.subscriptions.push(
12341233
commandRunnerWithProgress(
12351234
"codeQL.chooseDatabaseFolder",

0 commit comments

Comments
 (0)