Skip to content

Commit f25d7ba

Browse files
robertbrignullnorascheuch
authored andcommitted
Expose QueryServerCommandManager from app
1 parent 3f1b619 commit f25d7ba

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

extensions/ql-vscode/src/common/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Disposable } from "./disposable-object";
33
import { AppEventEmitter } from "./events";
44
import { NotificationLogger } from "./logging";
55
import { Memento } from "./memento";
6-
import { AppCommandManager } from "./commands";
6+
import { AppCommandManager, QueryServerCommandManager } from "./commands";
77
import { AppTelemetry } from "./telemetry";
88

99
export interface App {
@@ -18,6 +18,7 @@ export interface App {
1818
readonly workspaceState: Memento;
1919
readonly credentials: Credentials;
2020
readonly commands: AppCommandManager;
21+
readonly queryServerCommands: QueryServerCommandManager;
2122
readonly environment: EnvironmentContext;
2223
}
2324

extensions/ql-vscode/src/common/commands.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,7 @@ export type AllExtensionCommands = BaseCommands &
353353

354354
export type AllCommands = AllExtensionCommands &
355355
PreActivationCommands &
356-
BuiltInVsCodeCommands &
357-
QueryServerCommands;
356+
BuiltInVsCodeCommands;
358357

359358
export type AppCommandManager = CommandManager<AllCommands>;
360359

extensions/ql-vscode/src/queries-panel/queries-panel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class QueriesPanel extends DisposableObject {
3030
private async runLocalQuery(
3131
queryTreeViewItem: QueryTreeViewItem,
3232
): Promise<void> {
33-
await this.app.commands.execute(
33+
await this.app.queryServerCommands.execute(
3434
"codeQL.runLocalQueryFromQueriesPanel",
3535
vscode.Uri.parse(queryTreeViewItem.path),
3636
);

extensions/ql-vscode/test/__mocks__/appMock.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { createMockLogger } from "./loggerMock";
66
import { createMockMemento } from "../mock-memento";
77
import { testCredentialsWithStub } from "../factories/authentication";
88
import { Credentials } from "../../src/common/authentication";
9-
import { AppCommandManager } from "../../src/common/commands";
9+
import {
10+
AppCommandManager,
11+
QueryServerCommandManager,
12+
} from "../../src/common/commands";
1013
import { createMockCommandManager } from "./commandsMock";
1114
import { NotificationLogger } from "../../src/common/logging";
1215
import { AppTelemetry } from "../../src/common/telemetry";
@@ -20,6 +23,7 @@ export function createMockApp({
2023
workspaceState = createMockMemento(),
2124
credentials = testCredentialsWithStub(),
2225
commands = createMockCommandManager(),
26+
queryServerCommands = createMockCommandManager(),
2327
environment = createMockEnvironmentContext(),
2428
logger = createMockLogger(),
2529
telemetry = createMockTelemetryReporter(),
@@ -31,6 +35,7 @@ export function createMockApp({
3135
workspaceState?: Memento;
3236
credentials?: Credentials;
3337
commands?: AppCommandManager;
38+
queryServerCommands?: QueryServerCommandManager;
3439
environment?: EnvironmentContext;
3540
logger?: NotificationLogger;
3641
telemetry?: AppTelemetry;
@@ -47,6 +52,7 @@ export function createMockApp({
4752
createEventEmitter,
4853
credentials,
4954
commands,
55+
queryServerCommands,
5056
environment,
5157
};
5258
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { AppCommandManager } from "../../src/common/commands";
21
import { CommandFunction, CommandManager } from "../../src/packages/commands";
32
import { Disposable } from "../../src/packages/commands/Disposable";
43

5-
export function createMockCommandManager({
4+
export function createMockCommandManager<
5+
Commands extends Record<string, CommandFunction>,
6+
>({
67
registerCommand = jest.fn(),
78
executeCommand = jest.fn(),
89
}: {
910
registerCommand?: (commandName: string, fn: CommandFunction) => Disposable;
1011
executeCommand?: (commandName: string, ...args: any[]) => Promise<any>;
11-
} = {}): AppCommandManager {
12-
return new CommandManager(registerCommand, executeCommand);
12+
} = {}): CommandManager<Commands> {
13+
return new CommandManager<Commands>(registerCommand, executeCommand);
1314
}

0 commit comments

Comments
 (0)