Skip to content

Commit 14dc391

Browse files
Convert extensions/ql-vscode/src/legacy-query-server/queryserver-client.ts to call typed commands
1 parent d7e061e commit 14dc391

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

extensions/ql-vscode/src/extension.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,12 @@ async function activateWithInstalledDistribution(
667667
ctx.subscriptions.push(statusBar);
668668

669669
void extLogger.log("Initializing query server client.");
670-
const qs = await createQueryServer(qlConfigurationListener, cliServer, ctx);
670+
const qs = await createQueryServer(
671+
app,
672+
qlConfigurationListener,
673+
cliServer,
674+
ctx,
675+
);
671676

672677
for (const glob of PACK_GLOBS) {
673678
const fsWatcher = workspace.createFileSystemWatcher(glob);
@@ -1044,6 +1049,7 @@ function addUnhandledRejectionListener() {
10441049
}
10451050

10461051
async function createQueryServer(
1052+
app: ExtensionApp,
10471053
qlConfigurationListener: QueryServerConfigListener,
10481054
cliServer: CodeQLCliServer,
10491055
ctx: ExtensionContext,
@@ -1074,6 +1080,7 @@ async function createQueryServer(
10741080
return new NewQueryRunner(qs);
10751081
} else {
10761082
const qs = new LegacyQueryServerClient(
1083+
app,
10771084
qlConfigurationListener,
10781085
cliServer,
10791086
qsOpts,

extensions/ql-vscode/src/legacy-query-server/queryserver-client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ensureFile } from "fs-extra";
22

33
import { DisposableObject } from "../pure/disposable-object";
4-
import { CancellationToken, commands } from "vscode";
4+
import { CancellationToken } from "vscode";
55
import { createMessageConnection, RequestType } from "vscode-jsonrpc/node";
66
import * as cli from "../cli";
77
import { QueryServerConfig } from "../config";
@@ -15,6 +15,7 @@ import {
1515
} from "../pure/legacy-messages";
1616
import { ProgressCallback, ProgressTask } from "../progress";
1717
import { ServerProcess } from "../json-rpc-server";
18+
import { App } from "../common/app";
1819

1920
type WithProgressReporting = (
2021
task: (
@@ -56,6 +57,7 @@ export class QueryServerClient extends DisposableObject {
5657
public activeQueryLogger: Logger;
5758

5859
constructor(
60+
app: App,
5961
readonly config: QueryServerConfig,
6062
readonly cliServer: cli.CodeQLCliServer,
6163
readonly opts: ServerOpts,
@@ -69,7 +71,7 @@ export class QueryServerClient extends DisposableObject {
6971
if (config.onDidChangeConfiguration !== undefined) {
7072
this.push(
7173
config.onDidChangeConfiguration(() =>
72-
commands.executeCommand("codeQL.restartQueryServer"),
74+
app.commands.execute("codeQL.restartQueryServer"),
7375
),
7476
);
7577
}

extensions/ql-vscode/test/vscode-tests/cli-integration/legacy-query.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { CodeQLExtensionInterface } from "../../../src/extension";
1212
import { describeWithCodeQL } from "../cli";
1313
import { QueryServerClient } from "../../../src/legacy-query-server/queryserver-client";
1414
import { extLogger, ProgressReporter } from "../../../src/common";
15+
import { createMockApp } from "../../__mocks__/appMock";
1516

1617
const baseDir = join(__dirname, "../../../test/data");
1718

@@ -121,6 +122,7 @@ describeWithCodeQL()("using the legacy query server", () => {
121122
cliServer.quiet = true;
122123

123124
qs = new QueryServerClient(
125+
createMockApp({}),
124126
{
125127
codeQlPath:
126128
(await extension.distributionManager.getCodeQlPathWithoutVersionCheck()) ||

0 commit comments

Comments
 (0)