diff --git a/extensions/ql-vscode/package.json b/extensions/ql-vscode/package.json index 819e78f9a..854b2a170 100644 --- a/extensions/ql-vscode/package.json +++ b/extensions/ql-vscode/package.json @@ -361,6 +361,10 @@ "command": "codeQL.quickQuery", "title": "CodeQL: Quick Query" }, + { + "command": "codeQL.createSkeletonQuery", + "title": "CodeQL: Create Query" + }, { "command": "codeQL.openDocumentation", "title": "CodeQL: Open Documentation" diff --git a/extensions/ql-vscode/src/common/commands.ts b/extensions/ql-vscode/src/common/commands.ts index 0ad3b2990..e52750955 100644 --- a/extensions/ql-vscode/src/common/commands.ts +++ b/extensions/ql-vscode/src/common/commands.ts @@ -98,6 +98,7 @@ export type LocalQueryCommands = { "codeQL.quickEvalContextEditor": (uri: Uri) => Promise; "codeQL.codeLensQuickEval": (uri: Uri, range: Range) => Promise; "codeQL.quickQuery": () => Promise; + "codeQL.createSkeletonQuery": () => Promise; }; export type ResultsViewCommands = { diff --git a/extensions/ql-vscode/src/local-queries.ts b/extensions/ql-vscode/src/local-queries.ts index 01e0d886a..a5a21a764 100644 --- a/extensions/ql-vscode/src/local-queries.ts +++ b/extensions/ql-vscode/src/local-queries.ts @@ -2,13 +2,14 @@ import { ProgressCallback, ProgressUpdate, withProgress } from "./progress"; import { CancellationToken, CancellationTokenSource, + ExtensionContext, QuickPickItem, Range, Uri, window, } from "vscode"; import { BaseLogger, extLogger, Logger, TeeLogger } from "./common"; -import { MAX_QUERIES } from "./config"; +import { isCanary, MAX_QUERIES } from "./config"; import { gatherQlFiles } from "./pure/files"; import { basename } from "path"; import { @@ -51,6 +52,7 @@ import { App } from "./common/app"; import { DisposableObject } from "./pure/disposable-object"; import { QueryResultType } from "./pure/new-messages"; import { redactableError } from "./pure/errors"; +import { SkeletonQueryWizard } from "./skeleton-query"; interface DatabaseQuickPickItem extends QuickPickItem { databaseItem: DatabaseItem; @@ -220,6 +222,7 @@ export class LocalQueries extends DisposableObject { private readonly databaseUI: DatabaseUI, private readonly localQueryResultsView: ResultsView, private readonly queryStorageDir: string, + private readonly ctx: ExtensionContext, ) { super(); } @@ -237,6 +240,7 @@ export class LocalQueries extends DisposableObject { "codeQL.quickEvalContextEditor": this.quickEval.bind(this), "codeQL.codeLensQuickEval": this.codeLensQuickEval.bind(this), "codeQL.quickQuery": this.quickQuery.bind(this), + "codeQL.createSkeletonQuery": this.createSkeletonQuery.bind(this), }; } @@ -375,6 +379,27 @@ export class LocalQueries extends DisposableObject { ); } + private async createSkeletonQuery(): Promise { + await withProgress( + async (progress: ProgressCallback, token: CancellationToken) => { + const credentials = isCanary() ? this.app.credentials : undefined; + const skeletonQueryWizard = new SkeletonQueryWizard( + this.cliServer, + this.ctx.storageUri?.fsPath, + progress, + credentials, + extLogger, + this.databaseManager, + token, + ); + await skeletonQueryWizard.execute(); + }, + { + title: "Create Query", + }, + ); + } + /** * Creates a new `LocalQueryRun` object to track a query evaluation. This creates a timestamp * file in the query's output directory, creates a `LocalQueryInfo` object, and registers that