Skip to content

Commit 91c4c91

Browse files
committed
Introduce "Create Query" command
1 parent ddd00d1 commit 91c4c91

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

extensions/ql-vscode/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@
361361
"command": "codeQL.quickQuery",
362362
"title": "CodeQL: Quick Query"
363363
},
364+
{
365+
"command": "codeQL.createSkeletonQuery",
366+
"title": "CodeQL: Create Query"
367+
},
364368
{
365369
"command": "codeQL.openDocumentation",
366370
"title": "CodeQL: Open Documentation"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export type LocalQueryCommands = {
9898
"codeQL.quickEvalContextEditor": (uri: Uri) => Promise<void>;
9999
"codeQL.codeLensQuickEval": (uri: Uri, range: Range) => Promise<void>;
100100
"codeQL.quickQuery": () => Promise<void>;
101+
"codeQL.createSkeletonQuery": () => Promise<void>;
101102
};
102103

103104
export type ResultsViewCommands = {

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { ProgressCallback, ProgressUpdate, withProgress } from "./progress";
22
import {
33
CancellationToken,
44
CancellationTokenSource,
5+
ExtensionContext,
56
QuickPickItem,
67
Range,
78
Uri,
89
window,
910
} from "vscode";
1011
import { BaseLogger, extLogger, Logger, TeeLogger } from "./common";
11-
import { MAX_QUERIES } from "./config";
12+
import { isCanary, MAX_QUERIES } from "./config";
1213
import { gatherQlFiles } from "./pure/files";
1314
import { basename } from "path";
1415
import {
@@ -51,6 +52,7 @@ import { App } from "./common/app";
5152
import { DisposableObject } from "./pure/disposable-object";
5253
import { QueryResultType } from "./pure/new-messages";
5354
import { redactableError } from "./pure/errors";
55+
import { SkeletonQueryWizard } from "./skeleton-query";
5456

5557
interface DatabaseQuickPickItem extends QuickPickItem {
5658
databaseItem: DatabaseItem;
@@ -220,6 +222,7 @@ export class LocalQueries extends DisposableObject {
220222
private readonly databaseUI: DatabaseUI,
221223
private readonly localQueryResultsView: ResultsView,
222224
private readonly queryStorageDir: string,
225+
private readonly ctx: ExtensionContext,
223226
) {
224227
super();
225228
}
@@ -237,6 +240,7 @@ export class LocalQueries extends DisposableObject {
237240
"codeQL.quickEvalContextEditor": this.quickEval.bind(this),
238241
"codeQL.codeLensQuickEval": this.codeLensQuickEval.bind(this),
239242
"codeQL.quickQuery": this.quickQuery.bind(this),
243+
"codeQL.createSkeletonQuery": this.createSkeletonQuery.bind(this),
240244
};
241245
}
242246

@@ -375,6 +379,27 @@ export class LocalQueries extends DisposableObject {
375379
);
376380
}
377381

382+
private async createSkeletonQuery(): Promise<void> {
383+
await withProgress(
384+
async (progress: ProgressCallback, token: CancellationToken) => {
385+
const credentials = isCanary() ? this.app.credentials : undefined;
386+
const skeletonQueryWizard = new SkeletonQueryWizard(
387+
this.cliServer,
388+
this.ctx.storageUri?.fsPath,
389+
progress,
390+
credentials,
391+
extLogger,
392+
this.databaseManager,
393+
token,
394+
);
395+
await skeletonQueryWizard.execute();
396+
},
397+
{
398+
title: "Create Query",
399+
},
400+
);
401+
}
402+
378403
/**
379404
* Creates a new `LocalQueryRun` object to track a query evaluation. This creates a timestamp
380405
* file in the query's output directory, creates a `LocalQueryInfo` object, and registers that

0 commit comments

Comments
 (0)