Skip to content

Commit f84bf2d

Browse files
Convert extensions/ql-vscode/src/mocks/vscode-mock-gh-api-server.ts to call typed commands
1 parent 6b3a235 commit f84bf2d

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

extensions/ql-vscode/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ async function activateWithInstalledDistribution(
879879
const summaryLanguageSupport = new SummaryLanguageSupport(app);
880880
ctx.subscriptions.push(summaryLanguageSupport);
881881

882-
const mockServer = new VSCodeMockGitHubApiServer(ctx);
882+
const mockServer = new VSCodeMockGitHubApiServer(ctx, app);
883883
ctx.subscriptions.push(mockServer);
884884

885885
void extLogger.log("Registering top-level command palette commands.");

extensions/ql-vscode/src/mocks/vscode-mock-gh-api-server.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { pathExists } from "fs-extra";
22
import {
3-
commands,
43
env,
54
ExtensionContext,
65
ExtensionMode,
@@ -16,6 +15,7 @@ import {
1615
import { DisposableObject } from "../pure/disposable-object";
1716
import { MockGitHubApiServer } from "./mock-gh-api-server";
1817
import { MockGitHubApiServerCommands } from "../common/commands";
18+
import { App } from "../common/app";
1919

2020
/**
2121
* "Interface" to the mock GitHub API server which implements VSCode interactions, such as
@@ -27,7 +27,10 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
2727
private readonly server: MockGitHubApiServer;
2828
private readonly config: MockGitHubApiConfigListener;
2929

30-
constructor(private readonly ctx: ExtensionContext) {
30+
constructor(
31+
private readonly ctx: ExtensionContext,
32+
private readonly app: App,
33+
) {
3134
super();
3235
this.server = new MockGitHubApiServer();
3336
this.config = new MockGitHubApiConfigListener();
@@ -55,12 +58,12 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
5558
public async stopServer(): Promise<void> {
5659
this.server.stopServer();
5760

58-
await commands.executeCommand(
61+
await this.app.commands.execute(
5962
"setContext",
6063
"codeQL.mockGitHubApiServer.scenarioLoaded",
6164
false,
6265
);
63-
await commands.executeCommand(
66+
await this.app.commands.execute(
6467
"setContext",
6568
"codeQL.mockGitHubApiServer.recording",
6669
false,
@@ -92,7 +95,7 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
9295

9396
// Set a value in the context to track whether we have a scenario loaded.
9497
// This allows us to use this to show/hide commands (see package.json)
95-
await commands.executeCommand(
98+
await this.app.commands.execute(
9699
"setContext",
97100
"codeQL.mockGitHubApiServer.scenarioLoaded",
98101
true,
@@ -106,7 +109,7 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
106109
await window.showInformationMessage("No scenario currently loaded");
107110
} else {
108111
await this.server.unloadScenario();
109-
await commands.executeCommand(
112+
await this.app.commands.execute(
110113
"setContext",
111114
"codeQL.mockGitHubApiServer.scenarioLoaded",
112115
false,
@@ -125,7 +128,7 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
125128

126129
if (this.server.isScenarioLoaded) {
127130
await this.server.unloadScenario();
128-
await commands.executeCommand(
131+
await this.app.commands.execute(
129132
"setContext",
130133
"codeQL.mockGitHubApiServer.scenarioLoaded",
131134
false,
@@ -137,7 +140,7 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
137140

138141
await this.server.startRecording();
139142
// Set a value in the context to track whether we are recording. This allows us to use this to show/hide commands (see package.json)
140-
await commands.executeCommand(
143+
await this.app.commands.execute(
141144
"setContext",
142145
"codeQL.mockGitHubApiServer.recording",
143146
true,
@@ -155,7 +158,7 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
155158
}
156159

157160
// Set a value in the context to track whether we are recording. This allows us to use this to show/hide commands (see package.json)
158-
await commands.executeCommand(
161+
await this.app.commands.execute(
159162
"setContext",
160163
"codeQL.mockGitHubApiServer.recording",
161164
false,
@@ -210,7 +213,7 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
210213

211214
private async stopRecording(): Promise<void> {
212215
// Set a value in the context to track whether we are recording. This allows us to use this to show/hide commands (see package.json)
213-
await commands.executeCommand(
216+
await this.app.commands.execute(
214217
"setContext",
215218
"codeQL.mockGitHubApiServer.recording",
216219
false,

0 commit comments

Comments
 (0)