Convert extensions/ql-vscode/src/legacy-query-server/queryserver-client.ts to call typed commands

This commit is contained in:
Robert
2023-03-22 17:06:24 +00:00
parent d7e061e159
commit 14dc391229
3 changed files with 14 additions and 3 deletions

View File

@@ -667,7 +667,12 @@ async function activateWithInstalledDistribution(
ctx.subscriptions.push(statusBar);
void extLogger.log("Initializing query server client.");
const qs = await createQueryServer(qlConfigurationListener, cliServer, ctx);
const qs = await createQueryServer(
app,
qlConfigurationListener,
cliServer,
ctx,
);
for (const glob of PACK_GLOBS) {
const fsWatcher = workspace.createFileSystemWatcher(glob);
@@ -1044,6 +1049,7 @@ function addUnhandledRejectionListener() {
}
async function createQueryServer(
app: ExtensionApp,
qlConfigurationListener: QueryServerConfigListener,
cliServer: CodeQLCliServer,
ctx: ExtensionContext,
@@ -1074,6 +1080,7 @@ async function createQueryServer(
return new NewQueryRunner(qs);
} else {
const qs = new LegacyQueryServerClient(
app,
qlConfigurationListener,
cliServer,
qsOpts,

View File

@@ -1,7 +1,7 @@
import { ensureFile } from "fs-extra";
import { DisposableObject } from "../pure/disposable-object";
import { CancellationToken, commands } from "vscode";
import { CancellationToken } from "vscode";
import { createMessageConnection, RequestType } from "vscode-jsonrpc/node";
import * as cli from "../cli";
import { QueryServerConfig } from "../config";
@@ -15,6 +15,7 @@ import {
} from "../pure/legacy-messages";
import { ProgressCallback, ProgressTask } from "../progress";
import { ServerProcess } from "../json-rpc-server";
import { App } from "../common/app";
type WithProgressReporting = (
task: (
@@ -56,6 +57,7 @@ export class QueryServerClient extends DisposableObject {
public activeQueryLogger: Logger;
constructor(
app: App,
readonly config: QueryServerConfig,
readonly cliServer: cli.CodeQLCliServer,
readonly opts: ServerOpts,
@@ -69,7 +71,7 @@ export class QueryServerClient extends DisposableObject {
if (config.onDidChangeConfiguration !== undefined) {
this.push(
config.onDidChangeConfiguration(() =>
commands.executeCommand("codeQL.restartQueryServer"),
app.commands.execute("codeQL.restartQueryServer"),
),
);
}

View File

@@ -12,6 +12,7 @@ import { CodeQLExtensionInterface } from "../../../src/extension";
import { describeWithCodeQL } from "../cli";
import { QueryServerClient } from "../../../src/legacy-query-server/queryserver-client";
import { extLogger, ProgressReporter } from "../../../src/common";
import { createMockApp } from "../../__mocks__/appMock";
const baseDir = join(__dirname, "../../../test/data");
@@ -121,6 +122,7 @@ describeWithCodeQL()("using the legacy query server", () => {
cliServer.quiet = true;
qs = new QueryServerClient(
createMockApp({}),
{
codeQlPath:
(await extension.distributionManager.getCodeQlPathWithoutVersionCheck()) ||