Skip to content

Commit 8b9003e

Browse files
Convert extensions/ql-vscode/src/local-databases.ts to call typed commands
1 parent c394b7c commit 8b9003e

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

extensions/ql-vscode/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ async function activateWithInstalledDistribution(
678678
}
679679

680680
void extLogger.log("Initializing database manager.");
681-
const dbm = new DatabaseManager(ctx, qs, cliServer, extLogger);
681+
const dbm = new DatabaseManager(ctx, app, qs, cliServer, extLogger);
682682

683683
// Let this run async.
684684
void dbm.loadPersistedState();

extensions/ql-vscode/src/local-databases.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { redactableError } from "./pure/errors";
2828
import { isCodespacesTemplate } from "./config";
2929
import { QlPackGenerator } from "./qlpack-generator";
3030
import { QueryLanguage } from "./common/query-language";
31+
import { App } from "./common/app";
3132

3233
/**
3334
* databases.ts
@@ -593,6 +594,7 @@ export class DatabaseManager extends DisposableObject {
593594

594595
constructor(
595596
private readonly ctx: ExtensionContext,
597+
private readonly app: App,
596598
private readonly qs: QueryRunner,
597599
private readonly cli: cli.CodeQLCliServer,
598600
public logger: Logger,
@@ -875,7 +877,7 @@ export class DatabaseManager extends DisposableObject {
875877
this._currentDatabaseItem = item;
876878
this.updatePersistedCurrentDatabaseItem();
877879

878-
await vscode.commands.executeCommand(
880+
await this.app.commands.execute(
879881
"setContext",
880882
"codeQL.currentDatabaseItem",
881883
item?.name,

extensions/ql-vscode/test/vscode-tests/minimal-workspace/local-databases.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import * as helpers from "../../../src/helpers";
2525
import { Setting } from "../../../src/config";
2626
import { QlPackGenerator } from "../../../src/qlpack-generator";
2727
import { mockedObject } from "../utils/mocking.helpers";
28+
import { createMockApp } from "../../__mocks__/appMock";
2829

2930
describe("local databases", () => {
3031
const MOCK_DB_OPTIONS: FullDatabaseOptions = {
@@ -87,6 +88,7 @@ describe("local databases", () => {
8788

8889
databaseManager = new DatabaseManager(
8990
extensionContext,
91+
createMockApp({}),
9092
mockedObject<QueryRunner>({
9193
registerDatabase: registerSpy,
9294
deregisterDatabase: deregisterSpy,

0 commit comments

Comments
 (0)