Convert extensions/ql-vscode/src/local-databases.ts to call typed commands
This commit is contained in:
@@ -678,7 +678,7 @@ async function activateWithInstalledDistribution(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void extLogger.log("Initializing database manager.");
|
void extLogger.log("Initializing database manager.");
|
||||||
const dbm = new DatabaseManager(ctx, qs, cliServer, extLogger);
|
const dbm = new DatabaseManager(ctx, app, qs, cliServer, extLogger);
|
||||||
|
|
||||||
// Let this run async.
|
// Let this run async.
|
||||||
void dbm.loadPersistedState();
|
void dbm.loadPersistedState();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { redactableError } from "./pure/errors";
|
|||||||
import { isCodespacesTemplate } from "./config";
|
import { isCodespacesTemplate } from "./config";
|
||||||
import { QlPackGenerator } from "./qlpack-generator";
|
import { QlPackGenerator } from "./qlpack-generator";
|
||||||
import { QueryLanguage } from "./common/query-language";
|
import { QueryLanguage } from "./common/query-language";
|
||||||
|
import { App } from "./common/app";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* databases.ts
|
* databases.ts
|
||||||
@@ -593,6 +594,7 @@ export class DatabaseManager extends DisposableObject {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly ctx: ExtensionContext,
|
private readonly ctx: ExtensionContext,
|
||||||
|
private readonly app: App,
|
||||||
private readonly qs: QueryRunner,
|
private readonly qs: QueryRunner,
|
||||||
private readonly cli: cli.CodeQLCliServer,
|
private readonly cli: cli.CodeQLCliServer,
|
||||||
public logger: Logger,
|
public logger: Logger,
|
||||||
@@ -875,7 +877,7 @@ export class DatabaseManager extends DisposableObject {
|
|||||||
this._currentDatabaseItem = item;
|
this._currentDatabaseItem = item;
|
||||||
this.updatePersistedCurrentDatabaseItem();
|
this.updatePersistedCurrentDatabaseItem();
|
||||||
|
|
||||||
await vscode.commands.executeCommand(
|
await this.app.commands.execute(
|
||||||
"setContext",
|
"setContext",
|
||||||
"codeQL.currentDatabaseItem",
|
"codeQL.currentDatabaseItem",
|
||||||
item?.name,
|
item?.name,
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import * as helpers from "../../../src/helpers";
|
|||||||
import { Setting } from "../../../src/config";
|
import { Setting } from "../../../src/config";
|
||||||
import { QlPackGenerator } from "../../../src/qlpack-generator";
|
import { QlPackGenerator } from "../../../src/qlpack-generator";
|
||||||
import { mockedObject } from "../utils/mocking.helpers";
|
import { mockedObject } from "../utils/mocking.helpers";
|
||||||
|
import { createMockApp } from "../../__mocks__/appMock";
|
||||||
|
|
||||||
describe("local databases", () => {
|
describe("local databases", () => {
|
||||||
const MOCK_DB_OPTIONS: FullDatabaseOptions = {
|
const MOCK_DB_OPTIONS: FullDatabaseOptions = {
|
||||||
@@ -87,6 +88,7 @@ describe("local databases", () => {
|
|||||||
|
|
||||||
databaseManager = new DatabaseManager(
|
databaseManager = new DatabaseManager(
|
||||||
extensionContext,
|
extensionContext,
|
||||||
|
createMockApp({}),
|
||||||
mockedObject<QueryRunner>({
|
mockedObject<QueryRunner>({
|
||||||
registerDatabase: registerSpy,
|
registerDatabase: registerSpy,
|
||||||
deregisterDatabase: deregisterSpy,
|
deregisterDatabase: deregisterSpy,
|
||||||
|
|||||||
Reference in New Issue
Block a user