Merge pull request #2235 from github/robertbrignull/use_app_commands_5

Convert call sites to use typed commands (part 5): VariantAnalysisView
This commit is contained in:
Robert 2023-03-24 14:45:21 +00:00 коммит произвёл GitHub
Родитель d4a8eb9834 93436ad610
Коммит d35ab77aaf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 18 добавлений и 6 удалений

Просмотреть файл

@ -358,7 +358,10 @@ export async function activate(
),
);
const variantAnalysisViewSerializer = new VariantAnalysisViewSerializer(ctx);
const variantAnalysisViewSerializer = new VariantAnalysisViewSerializer(
ctx,
app,
);
Window.registerWebviewPanelSerializer(
VariantAnalysisView.viewType,
variantAnalysisViewSerializer,

Просмотреть файл

@ -317,7 +317,9 @@ export class VariantAnalysisManager
}
if (!this.views.has(variantAnalysisId)) {
// The view will register itself with the manager, so we don't need to do anything here.
this.track(new VariantAnalysisView(this.ctx, variantAnalysisId, this));
this.track(
new VariantAnalysisView(this.ctx, this.app, variantAnalysisId, this),
);
}
const variantAnalysisView = this.views.get(variantAnalysisId)!;

Просмотреть файл

@ -2,6 +2,7 @@ import { ExtensionContext, WebviewPanel, WebviewPanelSerializer } from "vscode";
import { VariantAnalysisView } from "./variant-analysis-view";
import { VariantAnalysisState } from "../pure/interface-types";
import { VariantAnalysisViewManager } from "./variant-analysis-view-manager";
import { App } from "../common/app";
export class VariantAnalysisViewSerializer implements WebviewPanelSerializer {
private resolvePromises: Array<
@ -10,7 +11,10 @@ export class VariantAnalysisViewSerializer implements WebviewPanelSerializer {
private manager?: VariantAnalysisViewManager<VariantAnalysisView>;
public constructor(private readonly ctx: ExtensionContext) {}
public constructor(
private readonly ctx: ExtensionContext,
private readonly app: App,
) {}
onExtensionLoaded(
manager: VariantAnalysisViewManager<VariantAnalysisView>,
@ -49,6 +53,7 @@ export class VariantAnalysisViewSerializer implements WebviewPanelSerializer {
const view = new VariantAnalysisView(
this.ctx,
this.app,
variantAnalysisState.variantAnalysisId,
manager,
);

Просмотреть файл

@ -1,4 +1,4 @@
import { commands, ExtensionContext, ViewColumn } from "vscode";
import { ExtensionContext, ViewColumn } from "vscode";
import { AbstractWebview, WebviewPanelConfig } from "../abstract-webview";
import { extLogger } from "../common";
import {
@ -23,6 +23,7 @@ import { telemetryListener } from "../telemetry";
import { redactableError } from "../pure/errors";
import { DataFlowPathsView } from "./data-flow-paths-view";
import { DataFlowPaths } from "./shared/data-flow-paths";
import { App } from "../common/app";
export class VariantAnalysisView
extends AbstractWebview<ToVariantAnalysisMessage, FromVariantAnalysisMessage>
@ -33,6 +34,7 @@ export class VariantAnalysisView
public constructor(
ctx: ExtensionContext,
private readonly app: App,
public readonly variantAnalysisId: number,
private readonly manager: VariantAnalysisViewManager<VariantAnalysisView>,
) {
@ -118,7 +120,7 @@ export class VariantAnalysisView
await this.manager.cancelVariantAnalysis(this.variantAnalysisId);
break;
case "requestRepositoryResults":
void commands.executeCommand(
void this.app.commands.execute(
"codeQL.loadVariantAnalysisRepoResults",
this.variantAnalysisId,
msg.repositoryFullName,
@ -131,7 +133,7 @@ export class VariantAnalysisView
await this.manager.openQueryText(this.variantAnalysisId);
break;
case "copyRepositoryList":
void commands.executeCommand(
void this.app.commands.execute(
"codeQL.copyVariantAnalysisRepoList",
this.variantAnalysisId,
msg.filterSort,