Skip to content

Commit b7edf1e

Browse files
Convert extensions/ql-vscode/src/query-server/queryserver-client.ts to call typed commands
1 parent f84bf2d commit b7edf1e

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

extensions/ql-vscode/src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ async function createQueryServer(
10741074
);
10751075
if (await cliServer.cliConstraints.supportsNewQueryServer()) {
10761076
const qs = new QueryServerClient(
1077+
app,
10771078
qlConfigurationListener,
10781079
cliServer,
10791080
qsOpts,

extensions/ql-vscode/src/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";
@@ -13,6 +13,7 @@ import {
1313
} from "../pure/new-messages";
1414
import { ProgressCallback, ProgressTask } from "../progress";
1515
import { ServerProcess } from "../json-rpc-server";
16+
import { App } from "../common/app";
1617

1718
type ServerOpts = {
1819
logger: Logger;
@@ -53,6 +54,7 @@ export class QueryServerClient extends DisposableObject {
5354
public activeQueryLogger: Logger;
5455

5556
constructor(
57+
app: App,
5658
readonly config: QueryServerConfig,
5759
readonly cliServer: cli.CodeQLCliServer,
5860
readonly opts: ServerOpts,
@@ -66,7 +68,7 @@ export class QueryServerClient extends DisposableObject {
6668
if (config.onDidChangeConfiguration !== undefined) {
6769
this.push(
6870
config.onDidChangeConfiguration(() =>
69-
commands.executeCommand("codeQL.restartQueryServer"),
71+
app.commands.execute("codeQL.restartQueryServer"),
7072
),
7173
);
7274
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { extLogger, ProgressReporter } from "../../../src/common";
1313
import { QueryResultType } from "../../../src/pure/new-messages";
1414
import { cleanDatabases, dbLoc, storagePath } from "../global.helper";
1515
import { importArchiveDatabase } from "../../../src/databaseFetcher";
16-
import { createMockCommandManager } from "../../__mocks__/commandsMock";
16+
import { createMockApp } from "../../__mocks__/appMock";
1717

1818
const baseDir = join(__dirname, "../../../test/data");
1919

@@ -110,6 +110,7 @@ describeWithCodeQL()("using the new query server", () => {
110110
let supportNewQueryServer = true;
111111

112112
beforeAll(async () => {
113+
const app = createMockApp({});
113114
const extension = await extensions
114115
.getExtension<CodeQLExtensionInterface | Record<string, never>>(
115116
"GitHub.vscode-codeql",
@@ -123,6 +124,7 @@ describeWithCodeQL()("using the new query server", () => {
123124
supportNewQueryServer = false;
124125
}
125126
qs = new QueryServerClient(
127+
app,
126128
{
127129
codeQlPath:
128130
(await extension.distributionManager.getCodeQlPathWithoutVersionCheck()) ||
@@ -148,7 +150,7 @@ describeWithCodeQL()("using the new query server", () => {
148150
await cleanDatabases(extension.databaseManager);
149151
const uri = Uri.file(dbLoc);
150152
const maybeDbItem = await importArchiveDatabase(
151-
createMockCommandManager(),
153+
app.commands,
152154
uri.toString(true),
153155
extension.databaseManager,
154156
storagePath,

0 commit comments

Comments
 (0)