Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extensions/ql-vscode/src/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ export type VariantAnalysisCommands = {
"codeQL.openVariantAnalysisView": (
variantAnalysisId: number,
) => Promise<void>;
"codeQL.runVariantAnalysis": (uri?: Uri) => Promise<void>;
"codeQL.runVariantAnalysisContextEditor": (uri?: Uri) => Promise<void>;
"codeQL.runVariantAnalysis": () => Promise<void>;
"codeQL.runVariantAnalysisContextEditor": (uri: Uri) => Promise<void>;
"codeQL.runVariantAnalysisContextExplorer": ExplorerSelectionCommandFunction<Uri>;
"codeQLQueries.runVariantAnalysisContextMenu": TreeViewContextSingleSelectionCommandFunction<QueryTreeViewItem>;
"codeQL.runVariantAnalysisPublishedPack": () => Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ interface PreparedRemoteQuery {
export async function prepareRemoteQueryRun(
cliServer: CodeQLCliServer,
credentials: Credentials,
uri: Uri | undefined,
uri: Uri,
progress: ProgressCallback,
token: CancellationToken,
dbManager: DbManager,
): Promise<PreparedRemoteQuery> {
if (!uri?.fsPath.endsWith(".ql")) {
if (!uri.fsPath.endsWith(".ql")) {
throw new UserCancellationException("Not a CodeQL query file.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ export class VariantAnalysisManager
"codeQL.openVariantAnalysisLogs": this.openVariantAnalysisLogs.bind(this),
"codeQL.openVariantAnalysisView": this.showView.bind(this),
"codeQL.runVariantAnalysis":
this.runVariantAnalysisFromCommand.bind(this),
this.runVariantAnalysisFromCommandPalette.bind(this),
"codeQL.runVariantAnalysisContextEditor":
this.runVariantAnalysisFromCommand.bind(this),
this.runVariantAnalysisFromContextEditor.bind(this),
"codeQL.runVariantAnalysisContextExplorer": createMultiSelectionCommand(
this.runVariantAnalysisFromExplorer.bind(this),
),
Expand All @@ -184,44 +184,53 @@ export class VariantAnalysisManager
return this.app.commands;
}

private async runVariantAnalysisFromCommand(uri?: Uri) {
return withProgress(
async (progress, token) =>
this.runVariantAnalysis(
uri || Window.activeTextEditor?.document.uri,
progress,
token,
),
{
title: "Run Variant Analysis",
cancellable: true,
},
);
private async runVariantAnalysisFromCommandPalette() {
const fileUri = Window.activeTextEditor?.document.uri;
if (!fileUri) {
throw new Error("Please select a .ql file to run as a variant analysis");
}

await this.runVariantAnalysisCommand(fileUri);
}

private async runVariantAnalysisFromContextEditor(uri: Uri) {
await this.runVariantAnalysisCommand(uri);
}

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]);

return this.runVariantAnalysisCommand(fileURIs[0]);
}

private async runVariantAnalysisFromQueriesPanel(
queryTreeViewItem: QueryTreeViewItem,
): Promise<void> {
if (queryTreeViewItem.path !== undefined) {
await this.runVariantAnalysisFromCommand(
Uri.file(queryTreeViewItem.path),
);
await this.runVariantAnalysisCommand(Uri.file(queryTreeViewItem.path));
}
}

private async runVariantAnalysisFromPublishedPack(): Promise<void> {
throw new Error("Command not yet implemented");
}

private async runVariantAnalysisCommand(uri: Uri): Promise<void> {
return withProgress(
async (progress, token) => {
await this.runVariantAnalysis(uri, progress, token);
},
{
title: "Run Variant Analysis",
cancellable: true,
},
);
}

public async runVariantAnalysis(
uri: Uri | undefined,
uri: Uri,
progress: ProgressCallback,
token: CancellationToken,
): Promise<void> {
Expand Down