Skip to content

Commit bf58e31

Browse files
Delete withInheritedProgress because we always have a progress context
1 parent a559a0a commit bf58e31

File tree

2 files changed

+29
-61
lines changed

2 files changed

+29
-61
lines changed

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,6 @@ export interface ProgressContext {
9090
token: CancellationToken;
9191
}
9292

93-
/**
94-
* Like `withProgress()`, except that the caller is not required to provide a progress context. If
95-
* the caller does provide one, any long-running operations performed by `task` will use the
96-
* supplied progress context. Otherwise, this function wraps `task` in a new progress context with
97-
* the supplied options.
98-
*/
99-
export function withInheritedProgress<R>(
100-
parent: ProgressContext | undefined,
101-
task: ProgressTask<R>,
102-
options: ProgressOptions,
103-
): Thenable<R> {
104-
if (parent !== undefined) {
105-
return task(parent.progress, parent.token);
106-
} else {
107-
return withProgress(task, options);
108-
}
109-
}
110-
11193
/**
11294
* Displays a progress monitor that indicates how much progess has been made
11395
* reading from a stream.

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

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
ThemeIcon,
1717
ThemeColor,
1818
workspace,
19-
ProgressLocation,
2019
} from "vscode";
2120
import { pathExists, stat, readdir, remove } from "fs-extra";
2221

@@ -31,7 +30,6 @@ import type {
3130
} from "../common/vscode/progress";
3231
import {
3332
UserCancellationException,
34-
withInheritedProgress,
3533
withProgress,
3634
} from "../common/vscode/progress";
3735
import {
@@ -330,10 +328,9 @@ export class DatabaseUI extends DisposableObject {
330328

331329
private async chooseDatabaseFolder(
332330
progress: ProgressCallback,
333-
token: CancellationToken,
334331
): Promise<void> {
335332
try {
336-
await this.chooseAndSetDatabase(true, { progress, token });
333+
await this.chooseAndSetDatabase(true, progress);
337334
} catch (e) {
338335
void showAndLogExceptionWithTelemetry(
339336
this.app.logger,
@@ -347,8 +344,8 @@ export class DatabaseUI extends DisposableObject {
347344

348345
private async handleChooseDatabaseFolder(): Promise<void> {
349346
return withProgress(
350-
async (progress, token) => {
351-
await this.chooseDatabaseFolder(progress, token);
347+
async (progress) => {
348+
await this.chooseDatabaseFolder(progress);
352349
},
353350
{
354351
title: "Adding database from folder",
@@ -358,8 +355,8 @@ export class DatabaseUI extends DisposableObject {
358355

359356
private async handleChooseDatabaseFolderFromPalette(): Promise<void> {
360357
return withProgress(
361-
async (progress, token) => {
362-
await this.chooseDatabaseFolder(progress, token);
358+
async (progress) => {
359+
await this.chooseDatabaseFolder(progress);
363360
},
364361
{
365362
title: "Choose a Database from a Folder",
@@ -500,10 +497,9 @@ export class DatabaseUI extends DisposableObject {
500497

501498
private async chooseDatabaseArchive(
502499
progress: ProgressCallback,
503-
token: CancellationToken,
504500
): Promise<void> {
505501
try {
506-
await this.chooseAndSetDatabase(false, { progress, token });
502+
await this.chooseAndSetDatabase(false, progress);
507503
} catch (e: unknown) {
508504
void showAndLogExceptionWithTelemetry(
509505
this.app.logger,
@@ -517,8 +513,8 @@ export class DatabaseUI extends DisposableObject {
517513

518514
private async handleChooseDatabaseArchive(): Promise<void> {
519515
return withProgress(
520-
async (progress, token) => {
521-
await this.chooseDatabaseArchive(progress, token);
516+
async (progress) => {
517+
await this.chooseDatabaseArchive(progress);
522518
},
523519
{
524520
title: "Adding database from archive",
@@ -528,8 +524,8 @@ export class DatabaseUI extends DisposableObject {
528524

529525
private async handleChooseDatabaseArchiveFromPalette(): Promise<void> {
530526
return withProgress(
531-
async (progress, token) => {
532-
await this.chooseDatabaseArchive(progress, token);
527+
async (progress) => {
528+
await this.chooseDatabaseArchive(progress);
533529
},
534530
{
535531
title: "Choose a Database from an Archive",
@@ -940,41 +936,31 @@ export class DatabaseUI extends DisposableObject {
940936
*/
941937
private async chooseAndSetDatabase(
942938
byFolder: boolean,
943-
progress: ProgressContext | undefined,
939+
progress: ProgressCallback,
944940
): Promise<DatabaseItem | undefined> {
945941
const uri = await chooseDatabaseDir(byFolder);
946942
if (!uri) {
947943
return undefined;
948944
}
949945

950-
return await withInheritedProgress(
951-
progress,
952-
async (progress) => {
953-
if (byFolder) {
954-
const fixedUri = await this.fixDbUri(uri);
955-
// we are selecting a database folder
956-
return await this.databaseManager.openDatabase(fixedUri, {
957-
type: "folder",
958-
});
959-
} else {
960-
// we are selecting a database archive. Must unzip into a workspace-controlled area
961-
// before importing.
962-
return await importArchiveDatabase(
963-
this.app.commands,
964-
uri.toString(true),
965-
this.databaseManager,
966-
this.storagePath,
967-
progress,
968-
this.queryServer.cliServer,
969-
);
970-
}
971-
},
972-
{
973-
location: ProgressLocation.Notification,
974-
cancellable: true,
975-
title: "Opening database",
976-
},
977-
);
946+
if (byFolder) {
947+
const fixedUri = await this.fixDbUri(uri);
948+
// we are selecting a database folder
949+
return await this.databaseManager.openDatabase(fixedUri, {
950+
type: "folder",
951+
});
952+
} else {
953+
// we are selecting a database archive. Must unzip into a workspace-controlled area
954+
// before importing.
955+
return await importArchiveDatabase(
956+
this.app.commands,
957+
uri.toString(true),
958+
this.databaseManager,
959+
this.storagePath,
960+
progress,
961+
this.queryServer.cliServer,
962+
);
963+
}
978964
}
979965

980966
/**

0 commit comments

Comments
 (0)