Convert test UI commands to typed commands
This commit is contained in:
@@ -5,6 +5,7 @@ import type { DbTreeViewItem } from "../databases/ui/db-tree-view-item";
|
||||
import type { DatabaseItem } from "../local-databases";
|
||||
import type { QueryHistoryInfo } from "../query-history/query-history-info";
|
||||
import type { RepositoriesFilterSortStateWithIds } from "../pure/variant-analysis-filter-sort";
|
||||
import type { TestTreeNode } from "../test-tree-node";
|
||||
import type {
|
||||
VariantAnalysis,
|
||||
VariantAnalysisScannedRepository,
|
||||
@@ -195,6 +196,11 @@ export type SummaryLanguageSupportCommands = {
|
||||
"codeQL.gotoQL": () => Promise<void>;
|
||||
};
|
||||
|
||||
export type TestUICommands = {
|
||||
"codeQLTests.showOutputDifferences": (node: TestTreeNode) => Promise<void>;
|
||||
"codeQLTests.acceptOutput": (node: TestTreeNode) => Promise<void>;
|
||||
};
|
||||
|
||||
export type AllCommands = BaseCommands &
|
||||
QueryHistoryCommands &
|
||||
LocalDatabasesCommands &
|
||||
@@ -204,7 +210,8 @@ export type AllCommands = BaseCommands &
|
||||
AstViewerCommands &
|
||||
PackagingCommands &
|
||||
EvalLogViewerCommands &
|
||||
SummaryLanguageSupportCommands;
|
||||
SummaryLanguageSupportCommands &
|
||||
Partial<TestUICommands>;
|
||||
|
||||
export type AppCommandManager = CommandManager<AllCommands>;
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@ import {
|
||||
AllCommands,
|
||||
BaseCommands,
|
||||
QueryServerCommands,
|
||||
TestUICommands,
|
||||
} from "./common/commands";
|
||||
import {
|
||||
getLocalQueryCommands,
|
||||
@@ -795,6 +796,7 @@ async function activateWithInstalledDistribution(
|
||||
const testExplorerExtension = extensions.getExtension<TestHub>(
|
||||
testExplorerExtensionId,
|
||||
);
|
||||
let testUiCommands: Partial<TestUICommands> = {};
|
||||
if (testExplorerExtension) {
|
||||
const testHub = testExplorerExtension.exports;
|
||||
const testAdapterFactory = new QLTestAdapterFactory(
|
||||
@@ -806,6 +808,8 @@ async function activateWithInstalledDistribution(
|
||||
|
||||
const testUIService = new TestUIService(testHub);
|
||||
ctx.subscriptions.push(testUIService);
|
||||
|
||||
testUiCommands = testUIService.getCommands();
|
||||
}
|
||||
|
||||
const astViewer = new AstViewer();
|
||||
@@ -846,6 +850,7 @@ async function activateWithInstalledDistribution(
|
||||
}),
|
||||
...evalLogViewer.getCommands(),
|
||||
...summaryLanguageSupport.getCommands(),
|
||||
...testUiCommands,
|
||||
};
|
||||
|
||||
for (const [commandName, command] of Object.entries(allCommands)) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import { TestTreeNode } from "./test-tree-node";
|
||||
import { DisposableObject } from "./pure/disposable-object";
|
||||
import { UIService } from "./vscode-utils/ui-service";
|
||||
import { QLTestAdapter, getExpectedFile, getActualFile } from "./test-adapter";
|
||||
import { extLogger } from "./common";
|
||||
import { TestUICommands } from "./common/commands";
|
||||
|
||||
type VSCodeTestEvent =
|
||||
| TestRunStartedEvent
|
||||
@@ -48,16 +48,17 @@ export class TestUIService extends UIService implements TestController {
|
||||
constructor(private readonly testHub: TestHub) {
|
||||
super();
|
||||
|
||||
void extLogger.log("Registering CodeQL test panel commands.");
|
||||
this.registerCommand(
|
||||
"codeQLTests.showOutputDifferences",
|
||||
this.showOutputDifferences,
|
||||
);
|
||||
this.registerCommand("codeQLTests.acceptOutput", this.acceptOutput);
|
||||
|
||||
testHub.registerTestController(this);
|
||||
}
|
||||
|
||||
public getCommands(): TestUICommands {
|
||||
return {
|
||||
"codeQLTests.showOutputDifferences":
|
||||
this.showOutputDifferences.bind(this),
|
||||
"codeQLTests.acceptOutput": this.acceptOutput.bind(this),
|
||||
};
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.testHub.unregisterTestController(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user