Skip to content

Commit ff418b5

Browse files
Convert extensions/ql-vscode/src/query-editor.ts to call typed commands
1 parent 8b9003e commit ff418b5

2 files changed

Lines changed: 14 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
@@ -879,6 +879,7 @@ async function activateWithInstalledDistribution(
879879
const allCommands: AllExtensionCommands = {
880880
...getCommands(app, cliServer, qs),
881881
...getQueryEditorCommands({
882+
commandManager: app.commands,
882883
queryRunner: qs,
883884
cliServer,
884885
qhelpTmpDir: qhelpTmpDir.name,

extensions/ql-vscode/src/query-editor.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
import { commands, Uri, window } from "vscode";
1+
import { Uri, window } from "vscode";
22
import { CodeQLCliServer } from "./cli";
33
import { QueryRunner } from "./queryRunner";
44
import { basename, join } from "path";
55
import { getErrorMessage } from "./pure/helpers-pure";
66
import { redactableError } from "./pure/errors";
77
import { showAndLogExceptionWithTelemetry } from "./helpers";
8-
import { QueryEditorCommands } from "./common/commands";
8+
import { AppCommandManager, QueryEditorCommands } from "./common/commands";
99

1010
type QueryEditorOptions = {
11+
commandManager: AppCommandManager;
12+
1113
queryRunner: QueryRunner;
1214
cliServer: CodeQLCliServer;
1315

1416
qhelpTmpDir: string;
1517
};
1618

1719
export function getQueryEditorCommands({
20+
commandManager,
1821
queryRunner,
1922
cliServer,
2023
qhelpTmpDir,
@@ -29,11 +32,17 @@ export function getQueryEditorCommands({
2932
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
3033
"codeQL.openReferencedFileContextExplorer": openReferencedFileCommand,
3134
"codeQL.previewQueryHelp": async (selectedQuery: Uri) =>
32-
await previewQueryHelp(cliServer, qhelpTmpDir, selectedQuery),
35+
await previewQueryHelp(
36+
commandManager,
37+
cliServer,
38+
qhelpTmpDir,
39+
selectedQuery,
40+
),
3341
};
3442
}
3543

3644
async function previewQueryHelp(
45+
commandManager: AppCommandManager,
3746
cliServer: CodeQLCliServer,
3847
qhelpTmpDir: string,
3948
selectedQuery: Uri,
@@ -49,7 +58,7 @@ async function previewQueryHelp(
4958
const uri = Uri.file(absolutePathToMd);
5059
try {
5160
await cliServer.generateQueryHelp(pathToQhelp, absolutePathToMd);
52-
await commands.executeCommand("markdown.showPreviewToSide", uri);
61+
await commandManager.execute("markdown.showPreviewToSide", uri);
5362
} catch (e) {
5463
const errorMessage = getErrorMessage(e).includes(
5564
"Generating qhelp in markdown",

0 commit comments

Comments
 (0)