Expose QueryServerCommandManager from app
This commit is contained in:
@@ -3,7 +3,7 @@ import { Disposable } from "./disposable-object";
|
||||
import { AppEventEmitter } from "./events";
|
||||
import { NotificationLogger } from "./logging";
|
||||
import { Memento } from "./memento";
|
||||
import { AppCommandManager } from "./commands";
|
||||
import { AppCommandManager, QueryServerCommandManager } from "./commands";
|
||||
import { AppTelemetry } from "./telemetry";
|
||||
|
||||
export interface App {
|
||||
@@ -18,6 +18,7 @@ export interface App {
|
||||
readonly workspaceState: Memento;
|
||||
readonly credentials: Credentials;
|
||||
readonly commands: AppCommandManager;
|
||||
readonly queryServerCommands: QueryServerCommandManager;
|
||||
readonly environment: EnvironmentContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -353,8 +353,7 @@ export type AllExtensionCommands = BaseCommands &
|
||||
|
||||
export type AllCommands = AllExtensionCommands &
|
||||
PreActivationCommands &
|
||||
BuiltInVsCodeCommands &
|
||||
QueryServerCommands;
|
||||
BuiltInVsCodeCommands;
|
||||
|
||||
export type AppCommandManager = CommandManager<AllCommands>;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export class QueriesPanel extends DisposableObject {
|
||||
private async runLocalQuery(
|
||||
queryTreeViewItem: QueryTreeViewItem,
|
||||
): Promise<void> {
|
||||
await this.app.commands.execute(
|
||||
await this.app.queryServerCommands.execute(
|
||||
"codeQL.runLocalQueryFromQueriesPanel",
|
||||
vscode.Uri.parse(queryTreeViewItem.path),
|
||||
);
|
||||
|
||||
@@ -6,7 +6,10 @@ import { createMockLogger } from "./loggerMock";
|
||||
import { createMockMemento } from "../mock-memento";
|
||||
import { testCredentialsWithStub } from "../factories/authentication";
|
||||
import { Credentials } from "../../src/common/authentication";
|
||||
import { AppCommandManager } from "../../src/common/commands";
|
||||
import {
|
||||
AppCommandManager,
|
||||
QueryServerCommandManager,
|
||||
} from "../../src/common/commands";
|
||||
import { createMockCommandManager } from "./commandsMock";
|
||||
import { NotificationLogger } from "../../src/common/logging";
|
||||
import { AppTelemetry } from "../../src/common/telemetry";
|
||||
@@ -20,6 +23,7 @@ export function createMockApp({
|
||||
workspaceState = createMockMemento(),
|
||||
credentials = testCredentialsWithStub(),
|
||||
commands = createMockCommandManager(),
|
||||
queryServerCommands = createMockCommandManager(),
|
||||
environment = createMockEnvironmentContext(),
|
||||
logger = createMockLogger(),
|
||||
telemetry = createMockTelemetryReporter(),
|
||||
@@ -31,6 +35,7 @@ export function createMockApp({
|
||||
workspaceState?: Memento;
|
||||
credentials?: Credentials;
|
||||
commands?: AppCommandManager;
|
||||
queryServerCommands?: QueryServerCommandManager;
|
||||
environment?: EnvironmentContext;
|
||||
logger?: NotificationLogger;
|
||||
telemetry?: AppTelemetry;
|
||||
@@ -47,6 +52,7 @@ export function createMockApp({
|
||||
createEventEmitter,
|
||||
credentials,
|
||||
commands,
|
||||
queryServerCommands,
|
||||
environment,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { AppCommandManager } from "../../src/common/commands";
|
||||
import { CommandFunction, CommandManager } from "../../src/packages/commands";
|
||||
import { Disposable } from "../../src/packages/commands/Disposable";
|
||||
|
||||
export function createMockCommandManager({
|
||||
export function createMockCommandManager<
|
||||
Commands extends Record<string, CommandFunction>,
|
||||
>({
|
||||
registerCommand = jest.fn(),
|
||||
executeCommand = jest.fn(),
|
||||
}: {
|
||||
registerCommand?: (commandName: string, fn: CommandFunction) => Disposable;
|
||||
executeCommand?: (commandName: string, ...args: any[]) => Promise<any>;
|
||||
} = {}): AppCommandManager {
|
||||
return new CommandManager(registerCommand, executeCommand);
|
||||
} = {}): CommandManager<Commands> {
|
||||
return new CommandManager<Commands>(registerCommand, executeCommand);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user