Introduce "Create Query" command

This commit is contained in:
Elena Tanasoiu
2023-03-29 14:49:14 +00:00
parent ddd00d16b0
commit 91c4c9189f
3 changed files with 31 additions and 1 deletions

View File

@@ -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"

View File

@@ -98,6 +98,7 @@ export type LocalQueryCommands = {
"codeQL.quickEvalContextEditor": (uri: Uri) => Promise<void>;
"codeQL.codeLensQuickEval": (uri: Uri, range: Range) => Promise<void>;
"codeQL.quickQuery": () => Promise<void>;
"codeQL.createSkeletonQuery": () => Promise<void>;
};
export type ResultsViewCommands = {

View File

@@ -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<void> {
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