From 93436ad610cd789d696e0ee31b11f05443b75ebc Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 24 Mar 2023 14:10:19 +0000 Subject: [PATCH] Convert extensions/ql-vscode/src/variant-analysis/variant-analysis-view.ts to call typed commands --- extensions/ql-vscode/src/extension.ts | 5 ++++- .../src/variant-analysis/variant-analysis-manager.ts | 4 +++- .../variant-analysis/variant-analysis-view-serializer.ts | 7 ++++++- .../src/variant-analysis/variant-analysis-view.ts | 8 +++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/extensions/ql-vscode/src/extension.ts b/extensions/ql-vscode/src/extension.ts index 577f77574..18d3c1a66 100644 --- a/extensions/ql-vscode/src/extension.ts +++ b/extensions/ql-vscode/src/extension.ts @@ -358,7 +358,10 @@ export async function activate( ), ); - const variantAnalysisViewSerializer = new VariantAnalysisViewSerializer(ctx); + const variantAnalysisViewSerializer = new VariantAnalysisViewSerializer( + ctx, + app, + ); Window.registerWebviewPanelSerializer( VariantAnalysisView.viewType, variantAnalysisViewSerializer, diff --git a/extensions/ql-vscode/src/variant-analysis/variant-analysis-manager.ts b/extensions/ql-vscode/src/variant-analysis/variant-analysis-manager.ts index 207410dcc..4fe17cb56 100644 --- a/extensions/ql-vscode/src/variant-analysis/variant-analysis-manager.ts +++ b/extensions/ql-vscode/src/variant-analysis/variant-analysis-manager.ts @@ -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)!; diff --git a/extensions/ql-vscode/src/variant-analysis/variant-analysis-view-serializer.ts b/extensions/ql-vscode/src/variant-analysis/variant-analysis-view-serializer.ts index 2eeb81793..314a3e0ba 100644 --- a/extensions/ql-vscode/src/variant-analysis/variant-analysis-view-serializer.ts +++ b/extensions/ql-vscode/src/variant-analysis/variant-analysis-view-serializer.ts @@ -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; - public constructor(private readonly ctx: ExtensionContext) {} + public constructor( + private readonly ctx: ExtensionContext, + private readonly app: App, + ) {} onExtensionLoaded( manager: VariantAnalysisViewManager, @@ -49,6 +53,7 @@ export class VariantAnalysisViewSerializer implements WebviewPanelSerializer { const view = new VariantAnalysisView( this.ctx, + this.app, variantAnalysisState.variantAnalysisId, manager, ); diff --git a/extensions/ql-vscode/src/variant-analysis/variant-analysis-view.ts b/extensions/ql-vscode/src/variant-analysis/variant-analysis-view.ts index ffd07c146..6f2a81838 100644 --- a/extensions/ql-vscode/src/variant-analysis/variant-analysis-view.ts +++ b/extensions/ql-vscode/src/variant-analysis/variant-analysis-view.ts @@ -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 @@ -33,6 +34,7 @@ export class VariantAnalysisView public constructor( ctx: ExtensionContext, + private readonly app: App, public readonly variantAnalysisId: number, private readonly manager: VariantAnalysisViewManager, ) { @@ -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,