Skip to content

Commit 16b8f84

Browse files
Delete ProgressContext
1 parent bf58e31 commit 16b8f84

File tree

5 files changed

+13
-31
lines changed

5 files changed

+13
-31
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ export function withProgress<R>(
8585
);
8686
}
8787

88-
export interface ProgressContext {
89-
progress: ProgressCallback;
90-
token: CancellationToken;
91-
}
92-
9388
/**
9489
* Displays a progress monitor that indicates how much progess has been made
9590
* reading from a stream.

extensions/ql-vscode/src/databases/local-databases-ui.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ import type {
2424
DatabaseItem,
2525
DatabaseManager,
2626
} from "./local-databases";
27-
import type {
28-
ProgressCallback,
29-
ProgressContext,
30-
} from "../common/vscode/progress";
27+
import type { ProgressCallback } from "../common/vscode/progress";
3128
import {
3229
UserCancellationException,
3330
withProgress,
@@ -791,9 +788,8 @@ export class DatabaseUI extends DisposableObject {
791788
*/
792789
public async getDatabaseItem(
793790
progress: ProgressCallback,
794-
token: CancellationToken,
795791
): Promise<DatabaseItem | undefined> {
796-
return await this.getDatabaseItemInternal({ progress, token });
792+
return await this.getDatabaseItemInternal(progress);
797793
}
798794

799795
/**
@@ -806,10 +802,10 @@ export class DatabaseUI extends DisposableObject {
806802
* notification if it tries to perform any long-running operations.
807803
*/
808804
private async getDatabaseItemInternal(
809-
progressContext: ProgressContext | undefined,
805+
progress: ProgressCallback | undefined,
810806
): Promise<DatabaseItem | undefined> {
811807
if (this.databaseManager.currentDatabaseItem === undefined) {
812-
progressContext?.progress({
808+
progress?.({
813809
maxStep: 2,
814810
step: 1,
815811
message: "Choosing database",

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,8 @@ export class LocalQueries extends DisposableObject {
290290

291291
private async quickQuery(): Promise<void> {
292292
await withProgress(
293-
async (progress, token) =>
294-
displayQuickQuery(
295-
this.app,
296-
this.cliServer,
297-
this.databaseUI,
298-
progress,
299-
token,
300-
),
293+
async (progress) =>
294+
displayQuickQuery(this.app, this.cliServer, this.databaseUI, progress),
301295
{
302296
title: "Run Quick Query",
303297
},
@@ -445,7 +439,7 @@ export class LocalQueries extends DisposableObject {
445439

446440
// If no databaseItem is specified, use the database currently selected in the Databases UI
447441
databaseItem =
448-
databaseItem ?? (await this.databaseUI.getDatabaseItem(progress, token));
442+
databaseItem ?? (await this.databaseUI.getDatabaseItem(progress));
449443
if (databaseItem === undefined) {
450444
throw new Error("Can't run query without a selected database");
451445
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ensureDir, writeFile, pathExists, readFile } from "fs-extra";
22
import { dump, load } from "js-yaml";
33
import { basename, join } from "path";
4-
import type { CancellationToken } from "vscode";
54
import { window as Window, workspace, Uri } from "vscode";
65
import { LSPErrorCodes, ResponseError } from "vscode-languageclient";
76
import type { CodeQLCliServer } from "../codeql-cli/cli";
@@ -56,7 +55,6 @@ export async function displayQuickQuery(
5655
cliServer: CodeQLCliServer,
5756
databaseUI: DatabaseUI,
5857
progress: ProgressCallback,
59-
token: CancellationToken,
6058
) {
6159
try {
6260
// If there is already a quick query open, don't clobber it, just
@@ -111,7 +109,7 @@ export async function displayQuickQuery(
111109
}
112110

113111
// We're going to infer which qlpack to use from the current database
114-
const dbItem = await databaseUI.getDatabaseItem(progress, token);
112+
const dbItem = await databaseUI.getDatabaseItem(progress);
115113
if (dbItem === undefined) {
116114
throw new Error("Can't start quick query without a selected database");
117115
}

extensions/ql-vscode/test/vscode-tests/no-workspace/databases/local-databases-ui.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
createFileSync,
88
pathExistsSync,
99
} from "fs-extra";
10-
import { CancellationTokenSource, Uri, window } from "vscode";
10+
import { Uri, window } from "vscode";
1111

1212
import type {
1313
DatabaseImportQuickPickItems,
@@ -127,7 +127,6 @@ describe("local-databases-ui", () => {
127127

128128
describe("getDatabaseItem", () => {
129129
const progress = jest.fn();
130-
const token = new CancellationTokenSource().token;
131130
describe("when there is a current database", () => {
132131
const databaseUI = new DatabaseUI(
133132
app,
@@ -153,7 +152,7 @@ describe("local-databases-ui", () => {
153152
);
154153

155154
it("should return current database", async () => {
156-
const databaseItem = await databaseUI.getDatabaseItem(progress, token);
155+
const databaseItem = await databaseUI.getDatabaseItem(progress);
157156

158157
expect(databaseItem).toEqual({ databaseUri: Uri.file(db1) });
159158
});
@@ -211,7 +210,7 @@ describe("local-databases-ui", () => {
211210
"setCurrentDatabaseItem",
212211
);
213212

214-
await databaseUI.getDatabaseItem(progress, token);
213+
await databaseUI.getDatabaseItem(progress);
215214

216215
expect(showQuickPickSpy).toHaveBeenCalledTimes(2);
217216
expect(setCurrentDatabaseItemSpy).toHaveBeenCalledWith({
@@ -241,7 +240,7 @@ describe("local-databases-ui", () => {
241240
.spyOn(databaseUI as any, "handleChooseDatabaseGithub")
242241
.mockResolvedValue(undefined);
243242

244-
await databaseUI.getDatabaseItem(progress, token);
243+
await databaseUI.getDatabaseItem(progress);
245244

246245
expect(showQuickPickSpy).toHaveBeenCalledTimes(2);
247246
expect(handleChooseDatabaseGithubSpy).toHaveBeenCalledTimes(1);
@@ -264,7 +263,7 @@ describe("local-databases-ui", () => {
264263
.spyOn(databaseUI as any, "handleChooseDatabaseGithub")
265264
.mockResolvedValue(undefined);
266265

267-
await databaseUI.getDatabaseItem(progress, token);
266+
await databaseUI.getDatabaseItem(progress);
268267

269268
expect(showQuickPickSpy).toHaveBeenCalledTimes(1);
270269
expect(handleChooseDatabaseGithubSpy).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)