Merge pull request #2245 from github/dbartol/local-queries-commands

Move `LocalQueries` commands to be member functions
This commit is contained in:
Dave Bartolomeo
2023-03-31 14:31:44 -04:00
committed by GitHub

View File

@@ -225,8 +225,23 @@ export class LocalQueries extends DisposableObject {
}
public getCommands(): LocalQueryCommands {
const runQuery = async (uri: Uri | undefined) =>
withProgress(
return {
"codeQL.runQuery": this.runQuery.bind(this),
"codeQL.runQueryContextEditor": this.runQuery.bind(this),
"codeQL.runQueryOnMultipleDatabases":
this.runQueryOnMultipleDatabases.bind(this),
"codeQL.runQueryOnMultipleDatabasesContextEditor":
this.runQueryOnMultipleDatabases.bind(this),
"codeQL.runQueries": this.runQueries.bind(this),
"codeQL.quickEval": this.quickEval.bind(this),
"codeQL.quickEvalContextEditor": this.quickEval.bind(this),
"codeQL.codeLensQuickEval": this.codeLensQuickEval.bind(this),
"codeQL.quickQuery": this.quickQuery.bind(this),
};
}
private async runQuery(uri: Uri | undefined): Promise<void> {
await withProgress(
async (progress, token) => {
await this.compileAndRunQuery(false, uri, progress, token, undefined);
},
@@ -235,23 +250,23 @@ export class LocalQueries extends DisposableObject {
cancellable: true,
},
);
}
const runQueryOnMultipleDatabases = async (uri: Uri | undefined) =>
withProgress(
private async runQueryOnMultipleDatabases(
uri: Uri | undefined,
): Promise<void> {
await withProgress(
async (progress, token) =>
await this.compileAndRunQueryOnMultipleDatabases(
progress,
token,
uri,
),
await this.compileAndRunQueryOnMultipleDatabases(progress, token, uri),
{
title: "Running query on selected databases",
cancellable: true,
},
);
}
const runQueries = async (_: Uri | undefined, multi: Uri[]) =>
withProgress(
private async runQueries(_: Uri | undefined, multi: Uri[]): Promise<void> {
await withProgress(
async (progress, token) => {
const maxQueryCount = MAX_QUERIES.getValue() as number;
const [files, dirFound] = await gatherQlFiles(
@@ -273,9 +288,7 @@ export class LocalQueries extends DisposableObject {
return;
}
}
const queryUris = files.map((path) =>
Uri.parse(`file:${path}`, true),
);
const queryUris = files.map((path) => Uri.parse(`file:${path}`, true));
// Use a wrapped progress so that messages appear with the queries remaining in it.
let queriesRemaining = queryUris.length;
@@ -314,9 +327,10 @@ export class LocalQueries extends DisposableObject {
cancellable: true,
},
);
}
const quickEval = async (uri: Uri) =>
withProgress(
private async quickEval(uri: Uri): Promise<void> {
await withProgress(
async (progress, token) => {
await this.compileAndRunQuery(true, uri, progress, token, undefined);
},
@@ -325,9 +339,10 @@ export class LocalQueries extends DisposableObject {
cancellable: true,
},
);
}
const codeLensQuickEval = async (uri: Uri, range: Range) =>
withProgress(
private async codeLensQuickEval(uri: Uri, range: Range): Promise<void> {
await withProgress(
async (progress, token) =>
await this.compileAndRunQuery(
true,
@@ -342,9 +357,10 @@ export class LocalQueries extends DisposableObject {
cancellable: true,
},
);
}
const quickQuery = async () =>
withProgress(
private async quickQuery(): Promise<void> {
await withProgress(
async (progress, token) =>
displayQuickQuery(
this.app,
@@ -357,19 +373,6 @@ export class LocalQueries extends DisposableObject {
title: "Run Quick Query",
},
);
return {
"codeQL.runQuery": runQuery,
"codeQL.runQueryContextEditor": runQuery,
"codeQL.runQueryOnMultipleDatabases": runQueryOnMultipleDatabases,
"codeQL.runQueryOnMultipleDatabasesContextEditor":
runQueryOnMultipleDatabases,
"codeQL.runQueries": runQueries,
"codeQL.quickEval": quickEval,
"codeQL.quickEvalContextEditor": quickEval,
"codeQL.codeLensQuickEval": codeLensQuickEval,
"codeQL.quickQuery": quickQuery,
};
}
/**