Introduce "Create Query" command
This commit is contained in:
@@ -361,6 +361,10 @@
|
|||||||
"command": "codeQL.quickQuery",
|
"command": "codeQL.quickQuery",
|
||||||
"title": "CodeQL: Quick Query"
|
"title": "CodeQL: Quick Query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "codeQL.createSkeletonQuery",
|
||||||
|
"title": "CodeQL: Create Query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "codeQL.openDocumentation",
|
"command": "codeQL.openDocumentation",
|
||||||
"title": "CodeQL: Open Documentation"
|
"title": "CodeQL: Open Documentation"
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ export type LocalQueryCommands = {
|
|||||||
"codeQL.quickEvalContextEditor": (uri: Uri) => Promise<void>;
|
"codeQL.quickEvalContextEditor": (uri: Uri) => Promise<void>;
|
||||||
"codeQL.codeLensQuickEval": (uri: Uri, range: Range) => Promise<void>;
|
"codeQL.codeLensQuickEval": (uri: Uri, range: Range) => Promise<void>;
|
||||||
"codeQL.quickQuery": () => Promise<void>;
|
"codeQL.quickQuery": () => Promise<void>;
|
||||||
|
"codeQL.createSkeletonQuery": () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResultsViewCommands = {
|
export type ResultsViewCommands = {
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ import { ProgressCallback, ProgressUpdate, withProgress } from "./progress";
|
|||||||
import {
|
import {
|
||||||
CancellationToken,
|
CancellationToken,
|
||||||
CancellationTokenSource,
|
CancellationTokenSource,
|
||||||
|
ExtensionContext,
|
||||||
QuickPickItem,
|
QuickPickItem,
|
||||||
Range,
|
Range,
|
||||||
Uri,
|
Uri,
|
||||||
window,
|
window,
|
||||||
} from "vscode";
|
} from "vscode";
|
||||||
import { BaseLogger, extLogger, Logger, TeeLogger } from "./common";
|
import { BaseLogger, extLogger, Logger, TeeLogger } from "./common";
|
||||||
import { MAX_QUERIES } from "./config";
|
import { isCanary, MAX_QUERIES } from "./config";
|
||||||
import { gatherQlFiles } from "./pure/files";
|
import { gatherQlFiles } from "./pure/files";
|
||||||
import { basename } from "path";
|
import { basename } from "path";
|
||||||
import {
|
import {
|
||||||
@@ -51,6 +52,7 @@ import { App } from "./common/app";
|
|||||||
import { DisposableObject } from "./pure/disposable-object";
|
import { DisposableObject } from "./pure/disposable-object";
|
||||||
import { QueryResultType } from "./pure/new-messages";
|
import { QueryResultType } from "./pure/new-messages";
|
||||||
import { redactableError } from "./pure/errors";
|
import { redactableError } from "./pure/errors";
|
||||||
|
import { SkeletonQueryWizard } from "./skeleton-query";
|
||||||
|
|
||||||
interface DatabaseQuickPickItem extends QuickPickItem {
|
interface DatabaseQuickPickItem extends QuickPickItem {
|
||||||
databaseItem: DatabaseItem;
|
databaseItem: DatabaseItem;
|
||||||
@@ -220,6 +222,7 @@ export class LocalQueries extends DisposableObject {
|
|||||||
private readonly databaseUI: DatabaseUI,
|
private readonly databaseUI: DatabaseUI,
|
||||||
private readonly localQueryResultsView: ResultsView,
|
private readonly localQueryResultsView: ResultsView,
|
||||||
private readonly queryStorageDir: string,
|
private readonly queryStorageDir: string,
|
||||||
|
private readonly ctx: ExtensionContext,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -237,6 +240,7 @@ export class LocalQueries extends DisposableObject {
|
|||||||
"codeQL.quickEvalContextEditor": this.quickEval.bind(this),
|
"codeQL.quickEvalContextEditor": this.quickEval.bind(this),
|
||||||
"codeQL.codeLensQuickEval": this.codeLensQuickEval.bind(this),
|
"codeQL.codeLensQuickEval": this.codeLensQuickEval.bind(this),
|
||||||
"codeQL.quickQuery": this.quickQuery.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
|
* 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
|
* file in the query's output directory, creates a `LocalQueryInfo` object, and registers that
|
||||||
|
|||||||
Reference in New Issue
Block a user