Add codeQL.runVariantAnalysisContextExplorer command

This commit is contained in:
Robert 2024-01-15 17:07:41 +00:00
Родитель ea1419add2
Коммит 1bc560518f
3 изменённых файлов: 25 добавлений и 1 удалений

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

@ -545,6 +545,10 @@
"command": "codeQL.runVariantAnalysisContextEditor",
"title": "CodeQL: Run Variant Analysis"
},
{
"command": "codeQL.runVariantAnalysisContextExplorer",
"title": "CodeQL: Run Variant Analysis"
},
{
"command": "codeQL.exportSelectedVariantAnalysisResults",
"title": "CodeQL: Export Variant Analysis Results"
@ -1321,6 +1325,11 @@
"group": "9_qlCommands",
"when": "resourceScheme != codeql-zip-archive"
},
{
"command": "codeQL.runVariantAnalysisContextExplorer",
"group": "9_qlCommands",
"when": "resourceExtname == .ql && config.codeQL.canary && config.codeQL.variantAnalysis.multiQuery"
},
{
"command": "codeQL.openReferencedFileContextExplorer",
"group": "9_qlCommands",
@ -1397,6 +1406,10 @@
"command": "codeQL.runVariantAnalysis",
"when": "editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.runVariantAnalysisContextExplorer",
"when": "false"
},
{
"command": "codeQL.runVariantAnalysisContextEditor",
"when": "false"

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

@ -277,6 +277,7 @@ export type VariantAnalysisCommands = {
) => Promise<void>;
"codeQL.runVariantAnalysis": (uri?: Uri) => Promise<void>;
"codeQL.runVariantAnalysisContextEditor": (uri?: Uri) => Promise<void>;
"codeQL.runVariantAnalysisContextExplorer": ExplorerSelectionCommandFunction<Uri>;
"codeQLQueries.runVariantAnalysisContextMenu": TreeViewContextSingleSelectionCommandFunction<QueryTreeViewItem>;
};

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

@ -86,6 +86,7 @@ import {
import type { QueryTreeViewItem } from "../queries-panel/query-tree-view-item";
import { RequestError } from "@octokit/request-error";
import { handleRequestError } from "./custom-errors";
import { createMultiSelectionCommand } from "../common/vscode/selection-commands";
const maxRetryCount = 3;
@ -167,9 +168,11 @@ export class VariantAnalysisManager
"codeQL.openVariantAnalysisView": this.showView.bind(this),
"codeQL.runVariantAnalysis":
this.runVariantAnalysisFromCommand.bind(this),
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.runVariantAnalysis" command
"codeQL.runVariantAnalysisContextEditor":
this.runVariantAnalysisFromCommand.bind(this),
"codeQL.runVariantAnalysisContextExplorer": createMultiSelectionCommand(
this.runVariantAnalysisFromExplorer.bind(this),
),
"codeQLQueries.runVariantAnalysisContextMenu":
this.runVariantAnalysisFromQueriesPanel.bind(this),
};
@ -194,6 +197,13 @@ export class VariantAnalysisManager
);
}
private async runVariantAnalysisFromExplorer(fileURIs: Uri[]): Promise<void> {
if (fileURIs.length !== 1) {
throw new Error("Can only run a single query at a time");
}
return this.runVariantAnalysisFromCommand(fileURIs[0]);
}
private async runVariantAnalysisFromQueriesPanel(
queryTreeViewItem: QueryTreeViewItem,
): Promise<void> {