Skip to content

Commit 352ffd4

Browse files
author
Alexander Eyers-Taylor
committed
Add support for running quick-eval-count from the command pallete
1 parent b8ed251 commit 352ffd4

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

extensions/ql-vscode/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@
457457
"command": "codeQL.quickEval",
458458
"title": "CodeQL: Quick Evaluation"
459459
},
460+
{
461+
"command": "codeQL.quickEvalCount",
462+
"title": "CodeQL: Quick Evaluation Count"
463+
},
460464
{
461465
"command": "codeQL.quickEvalContextEditor",
462466
"title": "CodeQL: Quick Evaluation"
@@ -1206,6 +1210,10 @@
12061210
"command": "codeQL.quickEval",
12071211
"when": "editorLangId == ql"
12081212
},
1213+
{
1214+
"command": "codeQL.quickEvalCount",
1215+
"when": "editorLangId == ql && codeql.supportsQuickEvalCount"
1216+
},
12091217
{
12101218
"command": "codeQL.quickEvalContextEditor",
12111219
"when": "false"

extensions/ql-vscode/src/common/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export type LocalQueryCommands = {
131131
) => Promise<void>;
132132
"codeQL.runQueries": ExplorerSelectionCommandFunction<Uri>;
133133
"codeQL.quickEval": (uri: Uri) => Promise<void>;
134+
"codeQL.quickEvalCount": (uri: Uri) => Promise<void>;
134135
"codeQL.quickEvalContextEditor": (uri: Uri) => Promise<void>;
135136
"codeQL.codeLensQuickEval": (uri: Uri, range: Range) => Promise<void>;
136137
"codeQL.quickQuery": () => Promise<void>;

extensions/ql-vscode/src/local-queries/local-queries.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export class LocalQueries extends DisposableObject {
104104
this.runQueries.bind(this),
105105
),
106106
"codeQL.quickEval": this.quickEval.bind(this),
107+
"codeQL.quickEvalCount": this.quickEvalCount.bind(this),
107108
"codeQL.quickEvalContextEditor": this.quickEval.bind(this),
108109
"codeQL.codeLensQuickEval": this.codeLensQuickEval.bind(this),
109110
"codeQL.quickQuery": this.quickQuery.bind(this),
@@ -231,6 +232,29 @@ export class LocalQueries extends DisposableObject {
231232
);
232233
}
233234

235+
private async quickEvalCount(uri: Uri): Promise<void> {
236+
await withProgress(
237+
async (progress, token) => {
238+
if (!(await this.cliServer.cliConstraints.supportsQuickEvalCount())) {
239+
throw new Error(
240+
"Quick evaluation counts is not supported by this version of CodeQL CLI.",
241+
);
242+
}
243+
await this.compileAndRunQuery(
244+
QuickEvalType.QuickEvalCount,
245+
uri,
246+
progress,
247+
token,
248+
undefined,
249+
);
250+
},
251+
{
252+
title: "Running query",
253+
cancellable: true,
254+
},
255+
);
256+
}
257+
234258
private async codeLensQuickEval(uri: Uri, range: Range): Promise<void> {
235259
await withProgress(
236260
async (progress, token) =>

0 commit comments

Comments
 (0)