Skip to content

Commit 35427f5

Browse files
author
Alexander Eyers-Taylor
committed
Add support for running quick-eval-count from the command pallete
1 parent b6fa1cd commit 35427f5

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"
@@ -1220,6 +1224,10 @@
12201224
"command": "codeQL.quickEval",
12211225
"when": "editorLangId == ql"
12221226
},
1227+
{
1228+
"command": "codeQL.quickEvalCount",
1229+
"when": "editorLangId == ql && codeql.supportsQuickEvalCount"
1230+
},
12231231
{
12241232
"command": "codeQL.quickEvalContextEditor",
12251233
"when": "false"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export type LocalQueryCommands = {
133133
"codeQLQueries.runLocalQueryFromQueriesPanel": TreeViewContextSingleSelectionCommandFunction<QueryTreeViewItem>;
134134
"codeQL.runQueries": ExplorerSelectionCommandFunction<Uri>;
135135
"codeQL.quickEval": (uri: Uri) => Promise<void>;
136+
"codeQL.quickEvalCount": (uri: Uri) => Promise<void>;
136137
"codeQL.quickEvalContextEditor": (uri: Uri) => Promise<void>;
137138
"codeQL.codeLensQuickEval": (uri: Uri, range: Range) => Promise<void>;
138139
"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
@@ -107,6 +107,7 @@ export class LocalQueries extends DisposableObject {
107107
this.runQueries.bind(this),
108108
),
109109
"codeQL.quickEval": this.quickEval.bind(this),
110+
"codeQL.quickEvalCount": this.quickEvalCount.bind(this),
110111
"codeQL.quickEvalContextEditor": this.quickEval.bind(this),
111112
"codeQL.codeLensQuickEval": this.codeLensQuickEval.bind(this),
112113
"codeQL.quickQuery": this.quickQuery.bind(this),
@@ -240,6 +241,29 @@ export class LocalQueries extends DisposableObject {
240241
);
241242
}
242243

244+
private async quickEvalCount(uri: Uri): Promise<void> {
245+
await withProgress(
246+
async (progress, token) => {
247+
if (!(await this.cliServer.cliConstraints.supportsQuickEvalCount())) {
248+
throw new Error(
249+
"Quick evaluation counts is not supported by this version of CodeQL CLI.",
250+
);
251+
}
252+
await this.compileAndRunQuery(
253+
QuickEvalType.QuickEvalCount,
254+
uri,
255+
progress,
256+
token,
257+
undefined,
258+
);
259+
},
260+
{
261+
title: "Running query",
262+
cancellable: true,
263+
},
264+
);
265+
}
266+
243267
private async codeLensQuickEval(uri: Uri, range: Range): Promise<void> {
244268
await withProgress(
245269
async (progress, token) =>

0 commit comments

Comments
 (0)